Title: [86927] trunk/Source/WebCore
Revision
86927
Author
[email protected]
Date
2011-05-20 00:56:57 -0700 (Fri, 20 May 2011)

Log Message

2011-05-20  Leo Yang  <[email protected]>

        Reviewed by Nikolas Zimmermann.

        SVGRootInlineBox triggers calculateBoundaries twice in layout
        https://bugs.webkit.org/show_bug.cgi?id=60979

        SVGRootInlineBox was calculating boundaries for children twice
        in computePerCharacterLayoutInformation(). The first time of
        calculation was in layoutChildBoxes() which is called by
        computePerCharacterLayoutInformation(), and the second time of
        calculation was in layoutRootBox() following layoutChildBoxes().

        This patch calculates rectangle of children in layoutChildBoxes()
        and then uses the rectange in layoutRootBox() to reduce a pass
        of calculating child boundaries.

        No functionality change, no new tests.

        * rendering/svg/SVGRootInlineBox.cpp:
        (WebCore::SVGRootInlineBox::computePerCharacterLayoutInformation):
        (WebCore::SVGRootInlineBox::layoutChildBoxes):
        (WebCore::SVGRootInlineBox::layoutRootBox):
        * rendering/svg/SVGRootInlineBox.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (86926 => 86927)


--- trunk/Source/WebCore/ChangeLog	2011-05-20 06:37:01 UTC (rev 86926)
+++ trunk/Source/WebCore/ChangeLog	2011-05-20 07:56:57 UTC (rev 86927)
@@ -1,3 +1,28 @@
+2011-05-20  Leo Yang  <[email protected]>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVGRootInlineBox triggers calculateBoundaries twice in layout
+        https://bugs.webkit.org/show_bug.cgi?id=60979
+
+        SVGRootInlineBox was calculating boundaries for children twice
+        in computePerCharacterLayoutInformation(). The first time of
+        calculation was in layoutChildBoxes() which is called by
+        computePerCharacterLayoutInformation(), and the second time of
+        calculation was in layoutRootBox() following layoutChildBoxes().
+
+        This patch calculates rectangle of children in layoutChildBoxes()
+        and then uses the rectange in layoutRootBox() to reduce a pass
+        of calculating child boundaries.
+
+        No functionality change, no new tests.
+
+        * rendering/svg/SVGRootInlineBox.cpp:
+        (WebCore::SVGRootInlineBox::computePerCharacterLayoutInformation):
+        (WebCore::SVGRootInlineBox::layoutChildBoxes):
+        (WebCore::SVGRootInlineBox::layoutRootBox):
+        * rendering/svg/SVGRootInlineBox.h:
+
 2011-05-19  Naoki Takano  <[email protected]>
 
         Reviewed by Kent Tamura.

Modified: trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp (86926 => 86927)


--- trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp	2011-05-20 06:37:01 UTC (rev 86926)
+++ trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp	2011-05-20 07:56:57 UTC (rev 86927)
@@ -3,6 +3,7 @@
  * Copyright (C) 2006 Apple Computer Inc.
  * Copyright (C) 2007 Nikolas Zimmermann <[email protected]>
  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
+ * Copyright (C) 2011 Torch Mobile (Beijing) CO. Ltd. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -88,8 +89,9 @@
 
     // Perform SVG text layout phase four
     // Position & resize all SVGInlineText/FlowBoxes in the inline box tree, resize the root box as well as the RenderSVGText parent block.
-    layoutChildBoxes(this);
-    layoutRootBox();
+    IntRect childRect;
+    layoutChildBoxes(this, &childRect);
+    layoutRootBox(childRect);
 }
 
 void SVGRootInlineBox::layoutCharactersInTextBoxes(InlineFlowBox* start, SVGTextLayoutEngine& characterLayout)
@@ -131,15 +133,16 @@
     }
 }
 
-void SVGRootInlineBox::layoutChildBoxes(InlineFlowBox* start)
+void SVGRootInlineBox::layoutChildBoxes(InlineFlowBox* start, IntRect* childRect)
 {
     for (InlineBox* child = start->firstChild(); child; child = child->nextOnLine()) {
+        IntRect boxRect;
         if (child->isSVGInlineTextBox()) {
             ASSERT(child->renderer());
             ASSERT(child->renderer()->isSVGInlineText());
 
             SVGInlineTextBox* textBox = static_cast<SVGInlineTextBox*>(child);
-            IntRect boxRect = textBox->calculateBoundaries();
+            boxRect = textBox->calculateBoundaries();
             textBox->setX(boxRect.x());
             textBox->setY(boxRect.y());
             textBox->setLogicalWidth(boxRect.width());
@@ -154,28 +157,22 @@
             SVGInlineFlowBox* flowBox = static_cast<SVGInlineFlowBox*>(child);
             layoutChildBoxes(flowBox);
 
-            IntRect boxRect = flowBox->calculateBoundaries();
+            boxRect = flowBox->calculateBoundaries();
             flowBox->setX(boxRect.x());
             flowBox->setY(boxRect.y());
             flowBox->setLogicalWidth(boxRect.width());
             flowBox->setLogicalHeight(boxRect.height());
         }
+        if (childRect)
+            childRect->unite(boxRect);
     }
 }
 
-void SVGRootInlineBox::layoutRootBox()
+void SVGRootInlineBox::layoutRootBox(const IntRect& childRect)
 {
     RenderBlock* parentBlock = block();
     ASSERT(parentBlock);
 
-    IntRect childRect;
-    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
-        // Skip generated content.
-        if (!child->renderer()->node())
-            continue;
-        childRect.unite(child->calculateBoundaries());
-    }
-
     int widthBlock = childRect.width();
     int heightBlock = childRect.height();
 

Modified: trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h (86926 => 86927)


--- trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h	2011-05-20 06:37:01 UTC (rev 86926)
+++ trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h	2011-05-20 07:56:57 UTC (rev 86927)
@@ -57,8 +57,8 @@
 private:
     void reorderValueLists(Vector<SVGTextLayoutAttributes>&);
     void layoutCharactersInTextBoxes(InlineFlowBox*, SVGTextLayoutEngine&);
-    void layoutChildBoxes(InlineFlowBox*);
-    void layoutRootBox();
+    void layoutChildBoxes(InlineFlowBox*, IntRect* = 0);
+    void layoutRootBox(const IntRect&);
 
 private:
     int m_logicalHeight;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to