Changeset 86927 in webkit


Ignore:
Timestamp:
May 20, 2011 12:56:57 AM (13 years ago)
Author:
leo.yang@torchmobile.com.cn
Message:

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:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86926 r86927  
     12011-05-20  Leo Yang  <leo.yang@torchmobile.com.cn>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVGRootInlineBox triggers calculateBoundaries twice in layout
     6        https://bugs.webkit.org/show_bug.cgi?id=60979
     7
     8        SVGRootInlineBox was calculating boundaries for children twice
     9        in computePerCharacterLayoutInformation(). The first time of
     10        calculation was in layoutChildBoxes() which is called by
     11        computePerCharacterLayoutInformation(), and the second time of
     12        calculation was in layoutRootBox() following layoutChildBoxes().
     13
     14        This patch calculates rectangle of children in layoutChildBoxes()
     15        and then uses the rectange in layoutRootBox() to reduce a pass
     16        of calculating child boundaries.
     17
     18        No functionality change, no new tests.
     19
     20        * rendering/svg/SVGRootInlineBox.cpp:
     21        (WebCore::SVGRootInlineBox::computePerCharacterLayoutInformation):
     22        (WebCore::SVGRootInlineBox::layoutChildBoxes):
     23        (WebCore::SVGRootInlineBox::layoutRootBox):
     24        * rendering/svg/SVGRootInlineBox.h:
     25
    1262011-05-19  Naoki Takano  <takano.naoki@gmail.com>
    227
  • trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.cpp

    r86395 r86927  
    44 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
    55 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
     6 * Copyright (C) 2011 Torch Mobile (Beijing) CO. Ltd. All rights reserved.
    67 *
    78 * This library is free software; you can redistribute it and/or
     
    8990    // Perform SVG text layout phase four
    9091    // Position & resize all SVGInlineText/FlowBoxes in the inline box tree, resize the root box as well as the RenderSVGText parent block.
    91     layoutChildBoxes(this);
    92     layoutRootBox();
     92    IntRect childRect;
     93    layoutChildBoxes(this, &childRect);
     94    layoutRootBox(childRect);
    9395}
    9496
     
    132134}
    133135
    134 void SVGRootInlineBox::layoutChildBoxes(InlineFlowBox* start)
     136void SVGRootInlineBox::layoutChildBoxes(InlineFlowBox* start, IntRect* childRect)
    135137{
    136138    for (InlineBox* child = start->firstChild(); child; child = child->nextOnLine()) {
     139        IntRect boxRect;
    137140        if (child->isSVGInlineTextBox()) {
    138141            ASSERT(child->renderer());
     
    140143
    141144            SVGInlineTextBox* textBox = static_cast<SVGInlineTextBox*>(child);
    142             IntRect boxRect = textBox->calculateBoundaries();
     145            boxRect = textBox->calculateBoundaries();
    143146            textBox->setX(boxRect.x());
    144147            textBox->setY(boxRect.y());
     
    155158            layoutChildBoxes(flowBox);
    156159
    157             IntRect boxRect = flowBox->calculateBoundaries();
     160            boxRect = flowBox->calculateBoundaries();
    158161            flowBox->setX(boxRect.x());
    159162            flowBox->setY(boxRect.y());
     
    161164            flowBox->setLogicalHeight(boxRect.height());
    162165        }
    163     }
    164 }
    165 
    166 void SVGRootInlineBox::layoutRootBox()
     166        if (childRect)
     167            childRect->unite(boxRect);
     168    }
     169}
     170
     171void SVGRootInlineBox::layoutRootBox(const IntRect& childRect)
    167172{
    168173    RenderBlock* parentBlock = block();
    169174    ASSERT(parentBlock);
    170 
    171     IntRect childRect;
    172     for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
    173         // Skip generated content.
    174         if (!child->renderer()->node())
    175             continue;
    176         childRect.unite(child->calculateBoundaries());
    177     }
    178175
    179176    int widthBlock = childRect.width();
  • trunk/Source/WebCore/rendering/svg/SVGRootInlineBox.h

    r82611 r86927  
    5858    void reorderValueLists(Vector<SVGTextLayoutAttributes>&);
    5959    void layoutCharactersInTextBoxes(InlineFlowBox*, SVGTextLayoutEngine&);
    60     void layoutChildBoxes(InlineFlowBox*);
    61     void layoutRootBox();
     60    void layoutChildBoxes(InlineFlowBox*, IntRect* = 0);
     61    void layoutRootBox(const IntRect&);
    6262
    6363private:
Note: See TracChangeset for help on using the changeset viewer.