Commit 37b8c115 authored by bfulgham@webkit.org's avatar bfulgham@webkit.org

2009-07-09 Roland Steiner <rolandsteiner@google.com>

        Reviewed by Maciej Stachowiak.

        added InlineBox::isLeaf()
        firstLeafChild()/lastLeafChild() not virtual and not callable on InlineBox anymore.
        firstLeafChild()/lastLeafChild() will no longer return a node outside of the given subtree.   
        Removed firstLeafChildAfterBox()/lastLeafChildBeforeBox()
        Removed potentially quadratic behavior if all nodes before/after a given box are empty InlineFlowBoxes

        Currently, these methods are called on RootInlineBox objects only, so above changes should not have
        any observable effect (only the removal of the square performance behavior could apply, 
        but the conditions for that are probably of a rather theoretical nature).

        * rendering/InlineBox.cpp:
        (WebCore::InlineBox::nextLeafChild):
        (WebCore::InlineBox::prevLeafChild):
        * rendering/InlineBox.h:
        (WebCore::InlineBox::isLeaf):
        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::firstLeafChild):
        (WebCore::InlineFlowBox::lastLeafChild):
        * rendering/InlineFlowBox.h:
        (WebCore::InlineFlowBox::firstChild):
        (WebCore::InlineFlowBox::lastChild):
        (WebCore::InlineFlowBox::isLeaf):
        * rendering/RootInlineBox.cpp:
        (WebCore::RootInlineBox::closestLeafChildForXPos):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@45702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 395d4a7a
2009-07-09 Roland Steiner <rolandsteiner@google.com>
Reviewed by Maciej Stachowiak.
added InlineBox::isLeaf()
firstLeafChild()/lastLeafChild() not virtual and not callable on InlineBox anymore.
firstLeafChild()/lastLeafChild() will no longer return a node outside of the given subtree.
Removed firstLeafChildAfterBox()/lastLeafChildBeforeBox()
Removed potentially quadratic behavior if all nodes before/after a given box are empty InlineFlowBoxes
Currently, these methods are called on RootInlineBox objects only, so above changes should not have
any observable effect (only the removal of the square performance behavior could apply,
but the conditions for that are probably of a rather theoretical nature).
* rendering/InlineBox.cpp:
(WebCore::InlineBox::nextLeafChild):
(WebCore::InlineBox::prevLeafChild):
* rendering/InlineBox.h:
(WebCore::InlineBox::isLeaf):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::firstLeafChild):
(WebCore::InlineFlowBox::lastLeafChild):
* rendering/InlineFlowBox.h:
(WebCore::InlineFlowBox::firstChild):
(WebCore::InlineFlowBox::lastChild):
(WebCore::InlineFlowBox::isLeaf):
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::closestLeafChildForXPos):
2009-07-09 Roland Steiner <rolandsteiner@google.com>
Reviewed by Maciej Stachowiak.
......
......@@ -244,26 +244,26 @@ bool InlineBox::prevOnLineExists() const
return m_prevOnLineExists;
}
InlineBox* InlineBox::firstLeafChild()
InlineBox* InlineBox::nextLeafChild() const
{
return this;
InlineBox* leaf = 0;
for (InlineBox* box = nextOnLine(); box && !leaf; box = box->nextOnLine())
leaf = box->isLeaf() ? box : static_cast<InlineFlowBox*>(box)->firstLeafChild();
if (!leaf && parent())
leaf = parent()->nextLeafChild();
return leaf;
}
InlineBox* InlineBox::lastLeafChild()
{
return this;
}
InlineBox* InlineBox::nextLeafChild()
{
return parent() ? parent()->firstLeafChildAfterBox(this) : 0;
}
InlineBox* InlineBox::prevLeafChild()
InlineBox* InlineBox::prevLeafChild() const
{
return parent() ? parent()->lastLeafChildBeforeBox(this) : 0;
InlineBox* leaf = 0;
for (InlineBox* box = prevOnLine(); box && !leaf; box = box->prevOnLine())
leaf = box->isLeaf() ? box : static_cast<InlineFlowBox*>(box)->lastLeafChild();
if (!leaf && parent())
leaf = parent()->prevLeafChild();
return leaf;
}
RenderObject::SelectionState InlineBox::selectionState()
{
return renderer()->selectionState();
......
......@@ -175,10 +175,10 @@ public:
bool nextOnLineExists() const;
bool prevOnLineExists() const;
virtual InlineBox* firstLeafChild();
virtual InlineBox* lastLeafChild();
InlineBox* nextLeafChild();
InlineBox* prevLeafChild();
virtual bool isLeaf() const { return true; }
InlineBox* nextLeafChild() const;
InlineBox* prevLeafChild() const;
RenderObject* renderer() const { return m_renderer; }
......
......@@ -981,33 +981,19 @@ void InlineFlowBox::paintTextDecorations(RenderObject::PaintInfo& paintInfo, int
}
}
InlineBox* InlineFlowBox::firstLeafChild()
{
return firstLeafChildAfterBox();
}
InlineBox* InlineFlowBox::lastLeafChild()
{
return lastLeafChildBeforeBox();
}
InlineBox* InlineFlowBox::firstLeafChildAfterBox(InlineBox* start)
InlineBox* InlineFlowBox::firstLeafChild() const
{
InlineBox* leaf = 0;
for (InlineBox* box = start ? start->nextOnLine() : firstChild(); box && !leaf; box = box->nextOnLine())
leaf = box->firstLeafChild();
if (start && !leaf && parent())
return parent()->firstLeafChildAfterBox(this);
for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnLine())
leaf = child->isLeaf() ? child : static_cast<InlineFlowBox*>(child)->firstLeafChild();
return leaf;
}
InlineBox* InlineFlowBox::lastLeafChildBeforeBox(InlineBox* start)
InlineBox* InlineFlowBox::lastLeafChild() const
{
InlineBox* leaf = 0;
for (InlineBox* box = start ? start->prevOnLine() : lastChild(); box && !leaf; box = box->prevOnLine())
leaf = box->lastLeafChild();
if (start && !leaf && parent())
return parent()->lastLeafChildBeforeBox(this);
for (InlineBox* child = lastChild(); child && !leaf; child = child->prevOnLine())
leaf = child->isLeaf() ? child : static_cast<InlineFlowBox*>(child)->lastLeafChild();
return leaf;
}
......
......@@ -58,13 +58,13 @@ public:
InlineFlowBox* prevFlowBox() const { return static_cast<InlineFlowBox*>(m_prevLine); }
InlineFlowBox* nextFlowBox() const { return static_cast<InlineFlowBox*>(m_nextLine); }
InlineBox* firstChild() { checkConsistency(); return m_firstChild; }
InlineBox* lastChild() { checkConsistency(); return m_lastChild; }
InlineBox* firstChild() const { checkConsistency(); return m_firstChild; }
InlineBox* lastChild() const { checkConsistency(); return m_lastChild; }
virtual InlineBox* firstLeafChild();
virtual InlineBox* lastLeafChild();
InlineBox* firstLeafChildAfterBox(InlineBox* start = 0);
InlineBox* lastLeafChildBeforeBox(InlineBox* start = 0);
virtual bool isLeaf() const { return false; }
InlineBox* firstLeafChild() const;
InlineBox* lastLeafChild() const;
virtual void setConstructed()
{
......
......@@ -355,8 +355,8 @@ static bool isEditableLeaf(InlineBox* leaf)
InlineBox* RootInlineBox::closestLeafChildForXPos(int x, bool onlyEditableLeaves)
{
InlineBox* firstLeaf = firstLeafChildAfterBox();
InlineBox* lastLeaf = lastLeafChildBeforeBox();
InlineBox* firstLeaf = firstLeafChild();
InlineBox* lastLeaf = lastLeafChild();
if (firstLeaf == lastLeaf && (!onlyEditableLeaves || isEditableLeaf(firstLeaf)))
return firstLeaf;
......
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