2011-05-20 Leo Yang <leo.yang@torchmobile.com.cn>
authorleo.yang@torchmobile.com.cn <leo.yang@torchmobile.com.cn@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 May 2011 07:56:57 +0000 (07:56 +0000)
committerleo.yang@torchmobile.com.cn <leo.yang@torchmobile.com.cn@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 May 2011 07:56:57 +0000 (07:56 +0000)
        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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@86927 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/SVGRootInlineBox.cpp
Source/WebCore/rendering/svg/SVGRootInlineBox.h

index aa71df73a9f9bc39bdfba677b2058ac995f47eec..f7e7345480b403c6a627fdadb7eb13088750ea87 100644 (file)
@@ -1,3 +1,28 @@
+2011-05-20  Leo Yang  <leo.yang@torchmobile.com.cn>
+
+        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  <takano.naoki@gmail.com>
 
         Reviewed by Kent Tamura.
index b8caa5417bec3f6726c6cc5c838b4a9e30fc66f4..2cbec0a5c3fdf0ea6c67f688be5eaabb3ef4319a 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright (C) 2006 Apple Computer Inc.
  * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
  * 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 @@ void SVGRootInlineBox::computePerCharacterLayoutInformation()
 
     // 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::layoutCharactersInTextBoxes(InlineFlowBox* start, SVGText
     }
 }
 
-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 @@ void SVGRootInlineBox::layoutChildBoxes(InlineFlowBox* start)
             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();
 
index a83af64ab9b3452719b6339fe98fd3b15743ccdb..48218ec15e2105cda48fd382dd36aa6e51e9c920 100644 (file)
@@ -57,8 +57,8 @@ public:
 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;