⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181898 in webkit


Ignore:
Timestamp:
Mar 24, 2015, 12:13:06 PM (11 years ago)
Author:
hyatt@apple.com
Message:

Improve the offsetWidth/Height layout optimization
https://bugs.webkit.org/show_bug.cgi?id=143008

Reviewed by Dean Jackson.

  • dom/Document.cpp:

(WebCore::Document::updateLayoutIfDimensionsOutOfDate):

  • dom/Document.h:

Change Element* to Element&. Clean up the dimension bits to use shifting. Remove both the inline and
the positioning restrictions on the optimization check.

  • dom/Element.cpp:

(WebCore::Element::offsetWidth):
(WebCore::Element::offsetHeight):
Change to use Element& instead of Element*.

(WebCore::Element::clientWidth):
(WebCore::Element::clientHeight):
(WebCore::Element::scrollWidth):
(WebCore::Element::scrollHeight):
Turn on the optimization for clientWidth/Height and scrollWidth/Height.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181897 r181898  
     12015-03-24  David Hyatt  <hyatt@apple.com>
     2
     3        Improve the offsetWidth/Height layout optimization
     4        https://bugs.webkit.org/show_bug.cgi?id=143008
     5
     6        Reviewed by Dean Jackson.
     7
     8        * dom/Document.cpp:
     9        (WebCore::Document::updateLayoutIfDimensionsOutOfDate):
     10        * dom/Document.h:
     11        Change Element* to Element&. Clean up the dimension bits to use shifting. Remove both the inline and
     12        the positioning restrictions on the optimization check.
     13
     14        * dom/Element.cpp:
     15        (WebCore::Element::offsetWidth):
     16        (WebCore::Element::offsetHeight):
     17        Change to use Element& instead of Element*.
     18
     19        (WebCore::Element::clientWidth):
     20        (WebCore::Element::clientHeight):
     21        (WebCore::Element::scrollWidth):
     22        (WebCore::Element::scrollHeight):
     23        Turn on the optimization for clientWidth/Height and scrollWidth/Height.
     24
    1252015-03-24  Yoav Weiss  <yoav@yoav.ws>
    226
  • trunk/Source/WebCore/dom/Document.cpp

    r181838 r181898  
    18971897}
    18981898
    1899 bool Document::updateLayoutIfDimensionsOutOfDate(Element* element, DimensionsCheck dimensionsCheck)
     1899bool Document::updateLayoutIfDimensionsOutOfDate(Element& element, DimensionsCheck dimensionsCheck)
    19001900{
    19011901    ASSERT(isMainThread());
     
    19211921    bool requireFullLayout = false;
    19221922    if (HTMLFrameOwnerElement* owner = ownerElement()) {
    1923         if (owner->document().updateLayoutIfDimensionsOutOfDate(owner))
     1923        if (owner->document().updateLayoutIfDimensionsOutOfDate(*owner))
    19241924            requireFullLayout = true;
    19251925    }
    19261926   
    19271927    updateStyleIfNeeded();
    1928    
    1929     RenderObject* renderer = element->renderer();
     1928
     1929    RenderObject* renderer = element.renderer();
    19301930    if (!renderer || renderer->needsLayout())
    19311931        requireFullLayout = true;
     
    19411941       
    19421942        // Check our containing block chain. If anything in the chain needs a layout, then require a full layout.
    1943         for (RenderObject* currRenderer = element->renderer(); currRenderer && !currRenderer->isRenderView(); currRenderer = currRenderer->container()) {
     1943        for (RenderObject* currRenderer = element.renderer(); currRenderer && !currRenderer->isRenderView(); currRenderer = currRenderer->container()) {
    19441944           
    19451945            // Require the entire container chain to be boxes.
     
    19701970            }
    19711971           
    1972             if (!currentBox->isRenderBlockFlow() || currentBox->isInline() || currentBox->isOutOfFlowPositioned() || currentBox->flowThreadContainingBlock() || currentBox->isWritingModeRoot()) {
    1973                 // FIXME: For now require only block-level non-positioned
    1974                 // block flows all the way back to the root. This limits the optimization
     1972            if (!currentBox->isRenderBlockFlow() || currentBox->flowThreadContainingBlock() || currentBox->isWritingModeRoot()) {
     1973                // FIXME: For now require only block flows all the way back to the root. This limits the optimization
    19751974                // for now, and we'll expand it in future patches to apply to more and more scenarios.
    19761975                // Disallow regions/columns from having the optimization.
  • trunk/Source/WebCore/dom/Document.h

    r181838 r181898  
    261261};
    262262
    263 enum DimensionsCheck { WidthDimensionsCheck = 0x1, HeightDimensionsCheck = 0x2, AllDimensionsCheck = 0x3 };
     263enum DimensionsCheck { WidthDimensionsCheck = 1 << 0, HeightDimensionsCheck = 1 << 1, AllDimensionsCheck = 1 << 2 };
    264264
    265265class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext, public FontSelectorClient {
     
    570570    bool hasLivingRenderTree() const { return renderView() && !renderTreeBeingDestroyed(); }
    571571   
    572     bool updateLayoutIfDimensionsOutOfDate(Element*, DimensionsCheck = AllDimensionsCheck);
     572    bool updateLayoutIfDimensionsOutOfDate(Element&, DimensionsCheck = AllDimensionsCheck);
    573573   
    574574    AXObjectCache* existingAXObjectCache() const;
  • trunk/Source/WebCore/dom/Element.cpp

    r181484 r181898  
    729729double Element::offsetWidth()
    730730{
    731     document().updateLayoutIfDimensionsOutOfDate(this, WidthDimensionsCheck);
     731    document().updateLayoutIfDimensionsOutOfDate(*this, WidthDimensionsCheck);
    732732    if (RenderBoxModelObject* renderer = renderBoxModelObject()) {
    733733        LayoutUnit offsetWidth = subpixelMetricsEnabled(renderer->document()) ? renderer->offsetWidth() : LayoutUnit(renderer->pixelSnappedOffsetWidth());
     
    739739double Element::offsetHeight()
    740740{
    741     document().updateLayoutIfDimensionsOutOfDate(this, HeightDimensionsCheck);
     741    document().updateLayoutIfDimensionsOutOfDate(*this, HeightDimensionsCheck);
    742742    if (RenderBoxModelObject* renderer = renderBoxModelObject()) {
    743743        LayoutUnit offsetHeight = subpixelMetricsEnabled(renderer->document()) ? renderer->offsetHeight() : LayoutUnit(renderer->pixelSnappedOffsetHeight());
     
    791791double Element::clientWidth()
    792792{
    793     document().updateLayoutIgnorePendingStylesheets();
     793    document().updateLayoutIfDimensionsOutOfDate(*this, WidthDimensionsCheck);
    794794
    795795    if (!document().hasLivingRenderTree())
     
    812812double Element::clientHeight()
    813813{
    814     document().updateLayoutIgnorePendingStylesheets();
    815 
     814    document().updateLayoutIfDimensionsOutOfDate(*this, HeightDimensionsCheck);
    816815    if (!document().hasLivingRenderTree())
    817816        return 0;
     
    873872int Element::scrollWidth()
    874873{
    875     document().updateLayoutIgnorePendingStylesheets();
     874    document().updateLayoutIfDimensionsOutOfDate(*this, WidthDimensionsCheck);
    876875    if (RenderBox* rend = renderBox())
    877876        return adjustForAbsoluteZoom(rend->scrollWidth(), *rend);
     
    881880int Element::scrollHeight()
    882881{
    883     document().updateLayoutIgnorePendingStylesheets();
     882    document().updateLayoutIfDimensionsOutOfDate(*this, HeightDimensionsCheck);
    884883    if (RenderBox* rend = renderBox())
    885884        return adjustForAbsoluteZoom(rend->scrollHeight(), *rend);
Note: See TracChangeset for help on using the changeset viewer.