Title: [183636] trunk/Source/WebCore
Revision
183636
Author
[email protected]
Date
2015-04-30 11:36:56 -0700 (Thu, 30 Apr 2015)

Log Message

Avoid containingBlock() calls when no writing mode flipping is needed.
https://bugs.webkit.org/show_bug.cgi?id=144407

Reviewed by Simon Fraser.

Add a bool to RenderView that indicates whether or not any flipped blocks have been
added to the view. Once tainted, the view just stays dirty forever. If no flipped
blocks are ever seen, we can then optimize away calls to containingBlock().

The motivation for this patch is to improve layer position updating, which makes many
calls to topLeftLocationOffset(), one of the functions that can be optimized by this
change.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::layoutOverflowRectForPropagation):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::updateFromStyle):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLineBoxList.cpp:
(WebCore::RenderLineBoxList::rangeIntersectsRect):
* rendering/RenderView.cpp:
(WebCore::RenderView::RenderView):
* rendering/RenderView.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183635 => 183636)


--- trunk/Source/WebCore/ChangeLog	2015-04-30 18:21:01 UTC (rev 183635)
+++ trunk/Source/WebCore/ChangeLog	2015-04-30 18:36:56 UTC (rev 183636)
@@ -1,3 +1,30 @@
+2015-04-29  David Hyatt  <[email protected]>
+
+        Avoid containingBlock() calls when no writing mode flipping is needed.
+        https://bugs.webkit.org/show_bug.cgi?id=144407
+
+        Reviewed by Simon Fraser.
+
+        Add a bool to RenderView that indicates whether or not any flipped blocks have been
+        added to the view. Once tainted, the view just stays dirty forever. If no flipped
+        blocks are ever seen, we can then optimize away calls to containingBlock().
+
+        The motivation for this patch is to improve layer position updating, which makes many
+        calls to topLeftLocationOffset(), one of the functions that can be optimized by this
+        change.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::layoutOverflowRectForPropagation):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::updateFromStyle):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects):
+        * rendering/RenderLineBoxList.cpp:
+        (WebCore::RenderLineBoxList::rangeIntersectsRect):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::RenderView):
+        * rendering/RenderView.h:
+
 2015-04-29  Jer Noble  <[email protected]>
 
         Make GenericTaskQueue even more generic (and usable inside platform/)

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (183635 => 183636)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2015-04-30 18:21:01 UTC (rev 183635)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2015-04-30 18:36:56 UTC (rev 183636)
@@ -4828,6 +4828,9 @@
 
 LayoutPoint RenderBox::topLeftLocation() const
 {
+    if (!view().hasFlippedBlockDescendants())
+        return location();
+    
     RenderBlock* containerBlock = containingBlock();
     if (!containerBlock || containerBlock == this)
         return location();
@@ -4836,6 +4839,9 @@
 
 LayoutSize RenderBox::topLeftLocationOffset() const
 {
+    if (!view().hasFlippedBlockDescendants())
+        return LayoutSize(m_frameRect.x(), m_frameRect.y());
+
     RenderBlock* containerBlock = containingBlock();
     if (!containerBlock || containerBlock == this)
         return locationOffset();

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (183635 => 183636)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2015-04-30 18:21:01 UTC (rev 183635)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2015-04-30 18:36:56 UTC (rev 183636)
@@ -219,6 +219,8 @@
     setInline(styleToUse.isDisplayInlineType());
     setPositionState(styleToUse.position());
     setHorizontalWritingMode(styleToUse.isHorizontalWritingMode());
+    if (styleToUse.isFlippedBlocksWritingMode())
+        view().setHasFlippedBlockDescendants(true);
 }
 
 static LayoutSize accumulateInFlowPositionOffsets(const RenderObject* child)

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (183635 => 183636)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2015-04-30 18:21:01 UTC (rev 183635)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2015-04-30 18:36:56 UTC (rev 183636)
@@ -5819,11 +5819,13 @@
 LayoutRect RenderLayer::boundingBox(const RenderLayer* ancestorLayer, const LayoutSize& offsetFromRoot, CalculateLayerBoundsFlags flags) const
 {    
     LayoutRect result = localBoundingBox(flags);
-    if (renderer().isBox())
-        renderBox()->flipForWritingMode(result);
-    else
-        renderer().containingBlock()->flipForWritingMode(result);
-    
+    if (renderer().view().hasFlippedBlockDescendants()) {
+        if (renderer().isBox())
+            renderBox()->flipForWritingMode(result);
+        else
+            renderer().containingBlock()->flipForWritingMode(result);
+    }
+
     PaginationInclusionMode inclusionMode = ExcludeCompositedPaginatedLayers;
     if (flags & UseFragmentBoxesIncludingCompositing)
         inclusionMode = IncludeCompositedPaginatedLayers;
@@ -5899,10 +5901,12 @@
 
     LayoutRect boundingBoxRect = localBoundingBox(flags);
 
-    if (is<RenderBox>(renderer()))
-        downcast<RenderBox>(renderer()).flipForWritingMode(boundingBoxRect);
-    else
-        renderer().containingBlock()->flipForWritingMode(boundingBoxRect);
+    if (renderer().view().hasFlippedBlockDescendants()) {
+        if (is<RenderBox>(renderer()))
+            downcast<RenderBox>(renderer()).flipForWritingMode(boundingBoxRect);
+        else
+            renderer().containingBlock()->flipForWritingMode(boundingBoxRect);
+    }
 
     if (renderer().isRoot()) {
         // If the root layer becomes composited (e.g. because some descendant with negative z-index is composited),

Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.cpp (183635 => 183636)


--- trunk/Source/WebCore/rendering/RenderLineBoxList.cpp	2015-04-30 18:21:01 UTC (rev 183635)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.cpp	2015-04-30 18:36:56 UTC (rev 183636)
@@ -152,13 +152,18 @@
 // FIXME: This should take a RenderBoxModelObject&.
 bool RenderLineBoxList::rangeIntersectsRect(RenderBoxModelObject* renderer, LayoutUnit logicalTop, LayoutUnit logicalBottom, const LayoutRect& rect, const LayoutPoint& offset) const
 {
-    RenderBox* block;
-    if (is<RenderBox>(*renderer))
-        block = downcast<RenderBox>(renderer);
-    else
-        block = renderer->containingBlock();
-    LayoutUnit physicalStart = block->flipForWritingMode(logicalTop);
-    LayoutUnit physicalEnd = block->flipForWritingMode(logicalBottom);
+    LayoutUnit physicalStart = logicalTop;
+    LayoutUnit physicalEnd = logicalBottom;
+    if (renderer->view().hasFlippedBlockDescendants()) {
+        RenderBox* block;
+        if (is<RenderBox>(*renderer))
+            block = downcast<RenderBox>(renderer);
+        else
+            block = renderer->containingBlock();
+        physicalStart = block->flipForWritingMode(logicalTop);
+        physicalEnd = block->flipForWritingMode(logicalBottom);
+    }
+
     LayoutUnit physicalExtent = absoluteValue(physicalEnd - physicalStart);
     physicalStart = std::min(physicalStart, physicalEnd);
     

Modified: trunk/Source/WebCore/rendering/RenderView.cpp (183635 => 183636)


--- trunk/Source/WebCore/rendering/RenderView.cpp	2015-04-30 18:21:01 UTC (rev 183635)
+++ trunk/Source/WebCore/rendering/RenderView.cpp	2015-04-30 18:36:56 UTC (rev 183636)
@@ -111,6 +111,7 @@
     , m_renderCounterCount(0)
     , m_selectionWasCaret(false)
     , m_hasSoftwareFilters(false)
+    , m_hasFlippedBlockDescendants(false)
 #if ENABLE(SERVICE_CONTROLS)
     , m_selectionRectGatherer(*this)
 #endif

Modified: trunk/Source/WebCore/rendering/RenderView.h (183635 => 183636)


--- trunk/Source/WebCore/rendering/RenderView.h	2015-04-30 18:21:01 UTC (rev 183635)
+++ trunk/Source/WebCore/rendering/RenderView.h	2015-04-30 18:36:56 UTC (rev 183636)
@@ -102,6 +102,9 @@
 
     LayoutRect viewRect() const;
 
+    bool hasFlippedBlockDescendants() const { return m_hasFlippedBlockDescendants; }
+    void setHasFlippedBlockDescendants(bool b) { m_hasFlippedBlockDescendants = b; }
+
     // layoutDelta is used transiently during layout to store how far an object has moved from its
     // last layout location, in order to repaint correctly.
     // If we're doing a full repaint m_layoutState will be 0, but in that case layoutDelta doesn't matter.
@@ -356,6 +359,7 @@
 
     bool m_selectionWasCaret;
     bool m_hasSoftwareFilters;
+    bool m_hasFlippedBlockDescendants;
 
     HashSet<RenderElement*> m_renderersWithPausedImageAnimation;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to