Title: [158842] trunk/Source/WebCore
Revision
158842
Author
[email protected]
Date
2013-11-07 04:04:02 -0800 (Thu, 07 Nov 2013)

Log Message

Use tighter InlineBox subtypes in some places.
<https://webkit.org/b/123980>

RenderLineBreak and RenderBox line box wrappers are always going to
be InlineElementBox, so codify this with tighter types. Also made
the various positionLine() functions take tighter reference types.

All the casting to renderer-appropriate box types happens inside of
RenderBlockFlow::computeBlockDirectionPositionsForLine() and
propagates from there.

Reviewed by Antti Koivisto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (158841 => 158842)


--- trunk/Source/WebCore/ChangeLog	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/ChangeLog	2013-11-07 12:04:02 UTC (rev 158842)
@@ -1,3 +1,18 @@
+2013-11-07  Andreas Kling  <[email protected]>
+
+        Use tighter InlineBox subtypes in some places.
+        <https://webkit.org/b/123980>
+
+        RenderLineBreak and RenderBox line box wrappers are always going to
+        be InlineElementBox, so codify this with tighter types. Also made
+        the various positionLine() functions take tighter reference types.
+
+        All the casting to renderer-appropriate box types happens inside of
+        RenderBlockFlow::computeBlockDirectionPositionsForLine() and
+        propagates from there.
+
+        Reviewed by Antti Koivisto.
+
 2013-11-07  Mario Sanchez Prada  <[email protected]>
 
         AX: [ATK] Video and audio elements are not properly exposed

Modified: trunk/Source/WebCore/dom/Position.cpp (158841 => 158842)


--- trunk/Source/WebCore/dom/Position.cpp	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/dom/Position.cpp	2013-11-07 12:04:02 UTC (rev 158842)
@@ -29,6 +29,7 @@
 #include "CSSComputedStyleDeclaration.h"
 #include "HTMLNames.h"
 #include "HTMLTableElement.h"
+#include "InlineElementBox.h"
 #include "InlineIterator.h"
 #include "InlineTextBox.h"
 #include "Logging.h"

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-11-07 12:04:02 UTC (rev 158842)
@@ -38,6 +38,7 @@
 #include "HTMLNames.h"
 #include "HitTestLocation.h"
 #include "HitTestResult.h"
+#include "InlineElementBox.h"
 #include "InlineIterator.h"
 #include "InlineTextBox.h"
 #include "LayoutRepainter.h"

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-11-07 12:04:02 UTC (rev 158842)
@@ -966,19 +966,21 @@
         if (!r->box())
             continue; // Skip runs with no line boxes.
 
+        InlineBox& box = *r->box();
+
         // Align positioned boxes with the top of the line box.  This is
         // a reasonable approximation of an appropriate y position.
         if (r->renderer().isOutOfFlowPositioned())
-            r->box()->setLogicalTop(logicalHeight());
+            box.setLogicalTop(logicalHeight());
 
         // Position is used to properly position both replaced elements and
         // to update the static normal flow x/y of positioned elements.
         if (r->renderer().isText())
-            toRenderText(r->renderer()).positionLineBox(r->box());
+            toRenderText(r->renderer()).positionLineBox(toInlineTextBox(box));
         else if (r->renderer().isBox())
-            toRenderBox(r->renderer()).positionLineBox(r->box());
+            toRenderBox(r->renderer()).positionLineBox(toInlineElementBox(box));
         else if (r->renderer().isLineBreak())
-            toRenderLineBreak(r->renderer()).replaceInlineBoxWrapper(r->box());
+            toRenderLineBreak(r->renderer()).replaceInlineBoxWrapper(toInlineElementBox(box));
     }
     // Positioned objects and zero-length text nodes destroy their boxes in
     // position(), which unnecessarily dirties the line.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-11-07 12:04:02 UTC (rev 158842)
@@ -1956,7 +1956,7 @@
     }
 }
 
-void RenderBox::positionLineBox(InlineBox* box)
+void RenderBox::positionLineBox(InlineElementBox& box)
 {
     if (isOutOfFlowPositioned()) {
         // Cache the x position only if we were an INLINE type originally.
@@ -1965,30 +1965,33 @@
             // The value is cached in the xPos of the box.  We only need this value if
             // our object was inline originally, since otherwise it would have ended up underneath
             // the inlines.
-            RootInlineBox& rootBox = box->root();
-            rootBox.blockFlow().setStaticInlinePositionForChild(*this, rootBox.lineTopWithLeading(), roundedLayoutUnit(box->logicalLeft()));
-            if (style().hasStaticInlinePosition(box->isHorizontal()))
+            RootInlineBox& rootBox = box.root();
+            rootBox.blockFlow().setStaticInlinePositionForChild(*this, rootBox.lineTopWithLeading(), roundedLayoutUnit(box.logicalLeft()));
+            if (style().hasStaticInlinePosition(box.isHorizontal()))
                 setChildNeedsLayout(MarkOnlyThis); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly.
         } else {
             // Our object was a block originally, so we make our normal flow position be
             // just below the line box (as though all the inlines that came before us got
             // wrapped in an anonymous block, which is what would have happened had we been
             // in flow).  This value was cached in the y() of the box.
-            layer()->setStaticBlockPosition(box->logicalTop());
-            if (style().hasStaticBlockPosition(box->isHorizontal()))
+            layer()->setStaticBlockPosition(box.logicalTop());
+            if (style().hasStaticBlockPosition(box.isHorizontal()))
                 setChildNeedsLayout(MarkOnlyThis); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly.
         }
 
         // Nuke the box.
-        box->removeFromParent();
-        delete box;
-    } else if (isReplaced()) {
-        setLocation(roundedLayoutPoint(box->topLeft()));
+        box.removeFromParent();
+        delete &box;
+        return;
+    }
+
+    if (isReplaced()) {
+        setLocation(roundedLayoutPoint(box.topLeft()));
         // m_inlineBoxWrapper should already be 0. Deleting it is a safeguard against security issues.
         ASSERT(!m_inlineBoxWrapper);
         if (m_inlineBoxWrapper)
             deleteLineBoxWrapper();
-        m_inlineBoxWrapper = box;
+        m_inlineBoxWrapper = &box;
     }
 }
 

Modified: trunk/Source/WebCore/rendering/RenderBox.h (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderBox.h	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2013-11-07 12:04:02 UTC (rev 158842)
@@ -372,7 +372,7 @@
     void clearRenderBoxRegionInfo();
     virtual LayoutUnit offsetFromLogicalTopOfFirstPage() const;
     
-    void positionLineBox(InlineBox*);
+    void positionLineBox(InlineElementBox&);
 
     virtual std::unique_ptr<InlineElementBox> createInlineBox();
     void dirtyLineBoxes(bool fullLayout);
@@ -380,8 +380,8 @@
     // For inline replaced elements, this function returns the inline box that owns us.  Enables
     // the replaced RenderObject to quickly determine what line it is contained on and to easily
     // iterate over structures on the line.
-    InlineBox* inlineBoxWrapper() const { return m_inlineBoxWrapper; }
-    void setInlineBoxWrapper(InlineBox* boxWrapper) { m_inlineBoxWrapper = boxWrapper; }
+    InlineElementBox* inlineBoxWrapper() const { return m_inlineBoxWrapper; }
+    void setInlineBoxWrapper(InlineElementBox* boxWrapper) { m_inlineBoxWrapper = boxWrapper; }
     void deleteLineBoxWrapper();
 
     virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const OVERRIDE;
@@ -703,7 +703,7 @@
     LayoutUnit m_maxPreferredLogicalWidth;
 
     // For inline replaced elements, the inline box that owns us.
-    InlineBox* m_inlineBoxWrapper;
+    InlineElementBox* m_inlineBoxWrapper;
 
     // Our overflow information.
     OwnPtr<RenderOverflow> m_overflow;

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2013-11-07 12:04:02 UTC (rev 158842)
@@ -27,6 +27,7 @@
 #include "FloatQuad.h"
 #include "GraphicsContext.h"
 #include "HitTestResult.h"
+#include "InlineElementBox.h"
 #include "InlineTextBox.h"
 #include "Page.h"
 #include "RenderBlock.h"

Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.cpp (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderLineBoxList.cpp	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.cpp	2013-11-07 12:04:02 UTC (rev 158842)
@@ -30,6 +30,7 @@
 #include "RenderLineBoxList.h"
 
 #include "HitTestResult.h"
+#include "InlineElementBox.h"
 #include "InlineTextBox.h"
 #include "PaintInfo.h"
 #include "RenderBlockFlow.h"
@@ -343,12 +344,10 @@
             continue;
 
         if (curr->isReplaced()) {
-            InlineBox* wrapper = toRenderBox(curr)->inlineBoxWrapper();
-            if (wrapper)
+            if (auto wrapper = toRenderBox(curr)->inlineBoxWrapper())
                 box = &wrapper->root();
         } if (curr->isLineBreak()) {
-            InlineBox* wrapper = toRenderLineBreak(curr)->inlineBoxWrapper();
-            if (wrapper)
+            if (auto wrapper = toRenderLineBreak(curr)->inlineBoxWrapper())
                 box = &wrapper->root();
         } else if (curr->isText()) {
             InlineTextBox* textBox = toRenderText(curr)->lastTextBox();

Modified: trunk/Source/WebCore/rendering/RenderLineBreak.cpp (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderLineBreak.cpp	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderLineBreak.cpp	2013-11-07 12:04:02 UTC (rev 158842)
@@ -73,16 +73,16 @@
     return std::make_unique<InlineElementBox>(*this);
 }
 
-void RenderLineBreak::setInlineBoxWrapper(InlineBox* inlineBox)
+void RenderLineBreak::setInlineBoxWrapper(InlineElementBox* inlineBox)
 {
     ASSERT(!inlineBox || !m_inlineBoxWrapper);
     m_inlineBoxWrapper = inlineBox;
 }
 
-void RenderLineBreak::replaceInlineBoxWrapper(InlineBox* inlineBox)
+void RenderLineBreak::replaceInlineBoxWrapper(InlineElementBox& inlineBox)
 {
     deleteInlineBoxWrapper();
-    setInlineBoxWrapper(inlineBox);
+    setInlineBoxWrapper(&inlineBox);
 }
 
 void RenderLineBreak::deleteInlineBoxWrapper()

Modified: trunk/Source/WebCore/rendering/RenderLineBreak.h (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderLineBreak.h	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderLineBreak.h	2013-11-07 12:04:02 UTC (rev 158842)
@@ -41,10 +41,10 @@
     virtual bool isWBR() const OVERRIDE { return m_isWBR; }
 
     std::unique_ptr<InlineElementBox> createInlineBox();
-    InlineBox* inlineBoxWrapper() const { return m_inlineBoxWrapper; }
-    void setInlineBoxWrapper(InlineBox*);
+    InlineElementBox* inlineBoxWrapper() const { return m_inlineBoxWrapper; }
+    void setInlineBoxWrapper(InlineElementBox*);
     void deleteInlineBoxWrapper();
-    void replaceInlineBoxWrapper(InlineBox*);
+    void replaceInlineBoxWrapper(InlineElementBox&);
     void dirtyLineBoxes(bool fullLayout);
 
     IntRect linesBoundingBox() const;
@@ -85,7 +85,7 @@
     virtual void updateFromStyle() OVERRIDE;
     virtual bool requiresLayer() const OVERRIDE { return false; }
 
-    InlineBox* m_inlineBoxWrapper;
+    InlineElementBox* m_inlineBoxWrapper;
     mutable int m_cachedLineHeight;
     bool m_isWBR;
 };

Modified: trunk/Source/WebCore/rendering/RenderListItem.cpp (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderListItem.cpp	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderListItem.cpp	2013-11-07 12:04:02 UTC (rev 158842)
@@ -27,6 +27,7 @@
 #include "ElementTraversal.h"
 #include "HTMLNames.h"
 #include "HTMLOListElement.h"
+#include "InlineElementBox.h"
 #include "PseudoElement.h"
 #include "RenderListMarker.h"
 #include "RenderView.h"

Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderReplaced.cpp	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp	2013-11-07 12:04:02 UTC (rev 158842)
@@ -26,6 +26,7 @@
 
 #include "Frame.h"
 #include "GraphicsContext.h"
+#include "InlineElementBox.h"
 #include "LayoutRepainter.h"
 #include "Page.h"
 #include "RenderBlock.h"

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2013-11-07 12:04:02 UTC (rev 158842)
@@ -1028,20 +1028,18 @@
     return std::make_unique<InlineTextBox>(*this);
 }
 
-void RenderText::positionLineBox(InlineBox* box)
+void RenderText::positionLineBox(InlineTextBox& textBox)
 {
-    InlineTextBox* textBox = toInlineTextBox(box);
-
     // FIXME: should not be needed!!!
-    if (!textBox->len()) {
+    if (!textBox.len()) {
         // We want the box to be destroyed.
-        textBox->removeFromParent();
-        m_lineBoxes.remove(*textBox);
-        delete textBox;
+        textBox.removeFromParent();
+        m_lineBoxes.remove(textBox);
+        delete &textBox;
         return;
     }
 
-    m_containsReversedText |= !textBox->isLeftToRightDirection();
+    m_containsReversedText |= !textBox.isLeftToRightDirection();
 }
 
 void RenderText::ensureLineBoxes()

Modified: trunk/Source/WebCore/rendering/RenderText.h (158841 => 158842)


--- trunk/Source/WebCore/rendering/RenderText.h	2013-11-07 11:12:23 UTC (rev 158841)
+++ trunk/Source/WebCore/rendering/RenderText.h	2013-11-07 12:04:02 UTC (rev 158842)
@@ -79,7 +79,7 @@
     UChar characterAt(unsigned i) const { return is8Bit() ? characters8()[i] : characters16()[i]; }
     UChar operator[](unsigned i) const { return characterAt(i); }
     unsigned textLength() const { return m_text.impl()->length(); } // non virtual implementation of length()
-    void positionLineBox(InlineBox*);
+    void positionLineBox(InlineTextBox&);
 
     virtual float width(unsigned from, unsigned len, const Font&, float xPos, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
     virtual float width(unsigned from, unsigned len, float xPos, bool firstLine = false, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to