Commit 09c83517 authored by antti@apple.com's avatar antti@apple.com
Browse files

Make SimpleLineLayout::Layout a class

https://bugs.webkit.org/show_bug.cgi?id=123508

Reviewed by Mario Sanchez Prada.

Improve encapsulation.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158268 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b048e184
2013-10-30 Antti Koivisto <antti@apple.com>
Make SimpleLineLayout::Layout a class
https://bugs.webkit.org/show_bug.cgi?id=123508
Reviewed by Mario Sanchez Prada.
Improve encapsulation.
2013-10-30 Antti Koivisto <antti@apple.com>
REGRESSION(r158214): It made zillion tests crash on GTK and EFL
......
......@@ -3148,7 +3148,7 @@ bool RenderBlockFlow::hasLines() const
ASSERT(childrenInline());
if (m_simpleLineLayout)
return m_simpleLineLayout->lineCount;
return m_simpleLineLayout->lineCount();
return lineBoxes().firstLineBox();
}
......
......@@ -334,10 +334,10 @@ std::unique_ptr<Layout> Layout::create(const RunVector& runVector, unsigned line
}
Layout::Layout(const RunVector& runVector, unsigned lineCount)
: runCount(runVector.size())
, lineCount(lineCount)
: m_lineCount(lineCount)
, m_runCount(runVector.size())
{
memcpy(runs, runVector.data(), runCount * sizeof(Run));
memcpy(m_runs, runVector.data(), m_runCount * sizeof(Run));
}
}
......
......@@ -59,18 +59,23 @@ struct Run {
float right;
};
struct Layout {
class Layout {
WTF_MAKE_FAST_ALLOCATED;
public:
typedef Vector<Run, 10> RunVector;
static std::unique_ptr<Layout> create(const RunVector&, unsigned lineCount);
unsigned runCount;
unsigned lineCount;
Run runs[0];
unsigned lineCount() const { return m_lineCount; }
unsigned runCount() const { return m_runCount; }
const Run& runAt(unsigned i) const { return m_runs[i]; }
private:
Layout(const RunVector&, unsigned lineCount);
unsigned m_lineCount;
unsigned m_runCount;
Run m_runs[0];
};
std::unique_ptr<Layout> create(RenderBlockFlow&);
......
......@@ -74,7 +74,7 @@ bool hitTestFlow(const RenderBlockFlow& flow, const Layout& layout, const HitTes
if (hitTestAction != HitTestForeground)
return false;
if (!layout.runCount)
if (!layout.runCount())
return false;
RenderStyle& style = flow.style();
......
......@@ -65,43 +65,43 @@ namespace SimpleLineLayout {
inline LayoutUnit computeFlowHeight(const RenderBlockFlow& flow, const Layout& layout)
{
return lineHeightFromFlow(flow) * layout.lineCount;
return lineHeightFromFlow(flow) * layout.lineCount();
}
inline LayoutUnit computeFlowFirstLineBaseline(const RenderBlockFlow& flow, const Layout& layout)
{
ASSERT_UNUSED(layout, layout.runCount);
ASSERT_UNUSED(layout, layout.runCount());
return flow.borderAndPaddingBefore() + baselineFromFlow(flow);
}
inline LayoutUnit computeFlowLastLineBaseline(const RenderBlockFlow& flow, const Layout& layout)
{
ASSERT(layout.runCount);
return flow.borderAndPaddingBefore() + lineHeightFromFlow(flow) * (layout.runCount - 1) + baselineFromFlow(flow);
ASSERT(layout.runCount());
return flow.borderAndPaddingBefore() + lineHeightFromFlow(flow) * (layout.runCount() - 1) + baselineFromFlow(flow);
}
inline unsigned findTextCaretMinimumOffset(const RenderText&, const Layout& layout)
{
if (!layout.runCount)
if (!layout.runCount())
return 0;
return layout.runs[0].textOffset;
return layout.runAt(0).textOffset;
}
inline unsigned findTextCaretMaximumOffset(const RenderText& renderer, const Layout& layout)
{
if (!layout.runCount)
if (!layout.runCount())
return renderer.textLength();
auto& last = layout.runs[layout.runCount - 1];
auto& last = layout.runAt(layout.runCount() - 1);
return last.textOffset + last.textLength;
}
inline bool containsTextCaretOffset(const RenderText&, const Layout& layout, unsigned offset)
{
for (unsigned i = 0; i < layout.runCount; ++i) {
auto& line = layout.runs[i];
if (offset < line.textOffset)
for (unsigned i = 0; i < layout.runCount(); ++i) {
auto& run = layout.runAt(i);
if (offset < run.textOffset)
return false;
if (offset <= line.textOffset + line.textLength)
if (offset <= run.textOffset + run.textLength)
return true;
}
return false;
......@@ -109,8 +109,8 @@ inline bool containsTextCaretOffset(const RenderText&, const Layout& layout, uns
inline bool isTextRendered(const RenderText&, const Layout& layout)
{
for (unsigned i = 0; i < layout.runCount; ++i) {
if (layout.runs[i].textLength)
for (unsigned i = 0; i < layout.runCount(); ++i) {
if (layout.runAt(i).textLength)
return true;
}
return false;
......
......@@ -189,7 +189,7 @@ inline RunResolver::Run RunResolver::Iterator::operator*() const
inline const SimpleLineLayout::Run& RunResolver::Iterator::simpleRun() const
{
return m_resolver.m_layout.runs[m_runIndex];
return m_resolver.m_layout.runAt(m_runIndex);
}
inline RunResolver::RunResolver(const RenderBlockFlow& flow, const Layout& layout)
......@@ -210,7 +210,7 @@ inline RunResolver::Iterator RunResolver::begin() const
inline RunResolver::Iterator RunResolver::end() const
{
return Iterator(*this, m_layout.runCount);
return Iterator(*this, m_layout.runCount());
}
inline LineResolver::Iterator::Iterator(RunResolver::Iterator runIterator)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment