Title: [157985] trunk/Source/WebCore
Revision
157985
Author
[email protected]
Date
2013-10-24 19:33:11 -0700 (Thu, 24 Oct 2013)

Log Message

Cache line layout path
https://bugs.webkit.org/show_bug.cgi?id=123298

Reviewed by Sam Weinig.

Determining the path can be non-trivial. Avoid computing it repeatedly on relayouts.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::RenderBlock):
(WebCore::RenderBlock::addChildIgnoringAnonymousColumnBlocks):
(WebCore::RenderBlock::invalidateLineLayoutPath):
(WebCore::RenderBlock::removeChild):

    Invalidate the path when children change.

* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutInlineChildren):
(WebCore::RenderBlockFlow::styleDidChange):

    Invalidate the path when style changes.

(WebCore::RenderBlockFlow::deleteLineBoxesBeforeSimpleLineLayout):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderText.cpp:
(WebCore::RenderText::setText):

    Invalidate the path when text changes.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (157984 => 157985)


--- trunk/Source/WebCore/ChangeLog	2013-10-25 01:48:25 UTC (rev 157984)
+++ trunk/Source/WebCore/ChangeLog	2013-10-25 02:33:11 UTC (rev 157985)
@@ -1,3 +1,34 @@
+2013-10-24  Antti Koivisto  <[email protected]>
+
+        Cache line layout path
+        https://bugs.webkit.org/show_bug.cgi?id=123298
+
+        Reviewed by Sam Weinig.
+        
+        Determining the path can be non-trivial. Avoid computing it repeatedly on relayouts.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::RenderBlock):
+        (WebCore::RenderBlock::addChildIgnoringAnonymousColumnBlocks):
+        (WebCore::RenderBlock::invalidateLineLayoutPath):
+        (WebCore::RenderBlock::removeChild):
+        
+            Invalidate the path when children change.
+
+        * rendering/RenderBlock.h:
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::layoutInlineChildren):
+        (WebCore::RenderBlockFlow::styleDidChange):
+        
+            Invalidate the path when style changes.
+
+        (WebCore::RenderBlockFlow::deleteLineBoxesBeforeSimpleLineLayout):
+        (WebCore::RenderBlockFlow::ensureLineBoxes):
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::setText):
+        
+            Invalidate the path when text changes.
+
 2013-10-24  Mark Rowe  <[email protected]>
 
         <rdar://problem/15312643> Prepare for the mysterious future.

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (157984 => 157985)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-10-25 01:48:25 UTC (rev 157984)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2013-10-25 02:33:11 UTC (rev 157985)
@@ -152,7 +152,7 @@
     , m_beingDestroyed(false)
     , m_hasMarkupTruncation(false)
     , m_hasBorderOrPaddingLogicalWidthChanged(false)
-    , m_forceLineBoxLayout(false)
+    , m_lineLayoutPath(UndeterminedPath)
 #if ENABLE(IOS_TEXT_AUTOSIZING)
     , m_widthForTextAutosizing(-1)
     , m_lineCountForTextAutosizing(NOT_SET)
@@ -168,7 +168,7 @@
     , m_beingDestroyed(false)
     , m_hasMarkupTruncation(false)
     , m_hasBorderOrPaddingLogicalWidthChanged(false)
-    , m_forceLineBoxLayout(false)
+    , m_lineLayoutPath(UndeterminedPath)
 #if ENABLE(IOS_TEXT_AUTOSIZING)
     , m_widthForTextAutosizing(-1)
     , m_lineCountForTextAutosizing(NOT_SET)
@@ -822,6 +822,8 @@
         }
     }
 
+    invalidateLineLayoutPath();
+
     RenderBox::addChild(newChild, beforeChild);
  
     // Handle placement of run-ins.
@@ -894,6 +896,13 @@
         cache->recomputeIsIgnored(this);
 }
 
+void RenderBlock::invalidateLineLayoutPath()
+{
+    if (m_lineLayoutPath == ForceLineBoxesPath)
+        return;
+    m_lineLayoutPath = UndeterminedPath;
+}
+
 void RenderBlock::makeChildrenNonInline(RenderObject* insertionPoint)
 {    
     // makeChildrenNonInline takes a block whose children are *all* inline and it
@@ -1115,6 +1124,8 @@
         }
     }
 
+    invalidateLineLayoutPath();
+
     RenderBox::removeChild(oldChild);
 
     RenderObject* child = prev ? prev : next;

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (157984 => 157985)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2013-10-25 01:48:25 UTC (rev 157984)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2013-10-25 02:33:11 UTC (rev 157985)
@@ -117,6 +117,8 @@
 
     virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0);
 
+    void invalidateLineLayoutPath();
+
     void insertPositionedObject(RenderBox&);
     static void removePositionedObject(RenderBox&);
     void removePositionedObjects(RenderBlock*, ContainingBlockState = SameContainingBlock);
@@ -751,13 +753,14 @@
 protected:
     OwnPtr<RenderBlockRareData> m_rareData;
 
-    mutable signed m_lineHeight : 26;
+    mutable signed m_lineHeight : 25;
     unsigned m_hasMarginBeforeQuirk : 1; // Note these quirk values can't be put in RenderBlockRareData since they are set too frequently.
     unsigned m_hasMarginAfterQuirk : 1;
     unsigned m_beingDestroyed : 1;
     unsigned m_hasMarkupTruncation : 1;
     unsigned m_hasBorderOrPaddingLogicalWidthChanged : 1;
-    unsigned m_forceLineBoxLayout : 1;
+    enum LineLayoutPath { UndeterminedPath, SimpleLinesPath, LineBoxesPath, ForceLineBoxesPath };
+    unsigned m_lineLayoutPath : 2;
 
 #if ENABLE(IOS_TEXT_AUTOSIZING)
     int m_widthForTextAutosizing;

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (157984 => 157985)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2013-10-25 01:48:25 UTC (rev 157984)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2013-10-25 02:33:11 UTC (rev 157985)
@@ -522,8 +522,10 @@
 
 void RenderBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom)
 {
-    bool canUseSimpleLineLayout = !m_forceLineBoxLayout && SimpleLineLayout::canUseFor(*this);
-    if (canUseSimpleLineLayout) {
+    if (m_lineLayoutPath == UndeterminedPath)
+        m_lineLayoutPath = SimpleLineLayout::canUseFor(*this) ? SimpleLinesPath : LineBoxesPath;
+
+    if (m_lineLayoutPath == SimpleLinesPath) {
         deleteLineBoxesBeforeSimpleLineLayout();
         layoutSimpleLines(repaintLogicalTop, repaintLogicalBottom);
         return;
@@ -1627,6 +1629,9 @@
 
     if (renderNamedFlowFragment())
         renderNamedFlowFragment()->setStyleForNamedFlowFragment(style());
+
+    if (diff >= StyleDifferenceRepaint)
+        invalidateLineLayoutPath();
 }
 
 void RenderBlockFlow::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
@@ -3020,14 +3025,14 @@
 
 void RenderBlockFlow::deleteLineBoxesBeforeSimpleLineLayout()
 {
-    ASSERT(!m_forceLineBoxLayout);
+    ASSERT(m_lineLayoutPath == SimpleLinesPath);
     lineBoxes().deleteLineBoxes(renderArena());
     toRenderText(firstChild())->deleteLineBoxesBeforeSimpleLineLayout();
 }
 
 void RenderBlockFlow::ensureLineBoxes()
 {
-    m_forceLineBoxLayout = true;
+    m_lineLayoutPath = ForceLineBoxesPath;
 
     if (!m_simpleLines)
         return;

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (157984 => 157985)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2013-10-25 01:48:25 UTC (rev 157984)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2013-10-25 02:33:11 UTC (rev 157985)
@@ -1010,6 +1010,9 @@
     setTextInternal(text);
     setNeedsLayoutAndPrefWidthsRecalc();
     m_knownToHaveNoOverflowAndNoFallbackFonts = false;
+
+    if (parent()->isRenderBlockFlow())
+        toRenderBlockFlow(parent())->invalidateLineLayoutPath();
     
     if (AXObjectCache* cache = document().existingAXObjectCache())
         cache->textChanged(this);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to