Changeset 92164 in webkit


Ignore:
Timestamp:
Aug 1, 2011 6:42:08 PM (13 years ago)
Author:
macpherson@chromium.org
Message:

Don't set m_fontDirty when setting zoom unless zoom has actually changed
https://bugs.webkit.org/show_bug.cgi?id=65092

Reviewed by Darin Adler.

No new tests as no functionality changed - this is an optimization that
should be logically equivalent to the current code.

The intent here is to avoid setting m_fontDirty unless the fornt information is actually dirty.

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::styleForDocument):
(WebCore::CSSStyleSelector::applyProperty):
Use setZoom and setEffectiveZoom wrapper functions.

  • css/CSSStyleSelector.h:

(WebCore::CSSStyleSelector::setZoom):
Wrapper for m_style->setZoom() that automatically updates m_fontDirty.
(WebCore::CSSStyleSelector::setEffectiveZoom):
Wrapper for m_style->setEffectiveZoom that automatically updates m_fontDirty.

  • page/animation/AnimationBase.cpp:

(WebCore::AnimationBase::ensurePropertyMap):
Use

  • rendering/style/RenderStyle.h:

(WebCore::InheritedFlags::setZoom):
Return true only if underlying values change.
(WebCore::InheritedFlags::setZoomWithoutReturnValue):
Return void to match function pointer type where required.
(WebCore::InheritedFlags::setEffectiveZoom):
Return true only if underlying values change.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r92161 r92164  
     12011-08-01  Luke Macpherson   <macpherson@chromium.org>
     2
     3        Don't set m_fontDirty when setting zoom unless zoom has actually changed
     4        https://bugs.webkit.org/show_bug.cgi?id=65092
     5
     6        Reviewed by Darin Adler.
     7
     8        No new tests as no functionality changed - this is an optimization that
     9        should be logically equivalent to the current code.
     10
     11        The intent here is to avoid setting m_fontDirty unless the fornt information is actually dirty.
     12
     13        * css/CSSStyleSelector.cpp:
     14        (WebCore::CSSStyleSelector::styleForDocument):
     15        (WebCore::CSSStyleSelector::applyProperty):
     16        Use setZoom and setEffectiveZoom wrapper functions.
     17        * css/CSSStyleSelector.h:
     18        (WebCore::CSSStyleSelector::setZoom):
     19        Wrapper for m_style->setZoom() that automatically updates m_fontDirty.
     20        (WebCore::CSSStyleSelector::setEffectiveZoom):
     21        Wrapper for m_style->setEffectiveZoom that automatically updates m_fontDirty.
     22        * page/animation/AnimationBase.cpp:
     23        (WebCore::AnimationBase::ensurePropertyMap):
     24        Use
     25        * rendering/style/RenderStyle.h:
     26        (WebCore::InheritedFlags::setZoom):
     27        Return true only if underlying values change.
     28        (WebCore::InheritedFlags::setZoomWithoutReturnValue):
     29        Return void to match function pointer type where required.
     30        (WebCore::InheritedFlags::setEffectiveZoom):
     31        Return true only if underlying values change.
     32
    1332011-08-01  Jean-luc Brouillet  <jeanluc@chromium.org>
    234
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r92140 r92164  
    42774277        // Reset the zoom in effect before we do anything.  This allows the setZoom method to accurately compute a new
    42784278        // zoom in effect.
    4279         m_style->setEffectiveZoom(m_parentStyle ? m_parentStyle->effectiveZoom() : RenderStyle::initialZoom());
    4280        
    4281         // Now we can handle inherit and initial.
    4282         HANDLE_INHERIT_AND_INITIAL(zoom, Zoom)
    4283        
    4284         // Handle normal/reset, numbers and percentages.
    4285         int type = primitiveValue->primitiveType();
    4286         if (primitiveValue->getIdent() == CSSValueNormal)
    4287             m_style->setZoom(RenderStyle::initialZoom());
     4279        setEffectiveZoom(m_parentStyle ? m_parentStyle->effectiveZoom() : RenderStyle::initialZoom());
     4280
     4281        if (isInherit)
     4282            setZoom(m_parentStyle->zoom());
     4283        else if (isInitial || primitiveValue->getIdent() == CSSValueNormal)
     4284            setZoom(RenderStyle::initialZoom());
    42884285        else if (primitiveValue->getIdent() == CSSValueReset) {
    4289             m_style->setEffectiveZoom(RenderStyle::initialZoom());
    4290             m_style->setZoom(RenderStyle::initialZoom());
     4286            setEffectiveZoom(RenderStyle::initialZoom());
     4287            setZoom(RenderStyle::initialZoom());
    42914288        } else if (primitiveValue->getIdent() == CSSValueDocument) {
    42924289            float docZoom = m_checker.m_document->renderer()->style()->zoom();
    4293             m_style->setEffectiveZoom(docZoom);
    4294             m_style->setZoom(docZoom);
    4295         } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) {
     4290            setEffectiveZoom(docZoom);
     4291            setZoom(docZoom);
     4292        } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE) {
    42964293            if (primitiveValue->getFloatValue())
    4297                 m_style->setZoom(primitiveValue->getFloatValue() / 100.0f);
    4298         } else if (type == CSSPrimitiveValue::CSS_NUMBER) {
     4294                setZoom(primitiveValue->getFloatValue() / 100.0f);
     4295        } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) {
    42994296            if (primitiveValue->getFloatValue())
    4300                 m_style->setZoom(primitiveValue->getFloatValue());
    4301         }
    4302        
    4303         m_fontDirty = true;
     4297                setZoom(primitiveValue->getFloatValue());
     4298        }
    43044299        return;
    43054300    }
  • trunk/Source/WebCore/css/CSSStyleSelector.h

    r91860 r92164  
    117117        FontDescription parentFontDescription() {return parentStyle()->fontDescription(); }
    118118        void setFontDescription(FontDescription fontDescription) { m_fontDirty |= style()->setFontDescription(fontDescription); }
     119        void setZoom(float f) { m_fontDirty |= style()->setZoom(f); }
     120        void setEffectiveZoom(float f) { m_fontDirty |= style()->setEffectiveZoom(f); }
    119121
    120122    private:
  • trunk/Source/WebCore/page/animation/AnimationBase.cpp

    r91187 r92164  
    742742        gPropertyWrappers->append(new PropertyWrapper<LengthSize>(CSSPropertyBorderBottomRightRadius, &RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius));
    743743        gPropertyWrappers->append(new PropertyWrapper<EVisibility>(CSSPropertyVisibility, &RenderStyle::visibility, &RenderStyle::setVisibility));
    744         gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyZoom, &RenderStyle::zoom, &RenderStyle::setZoom));
     744        gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyZoom, &RenderStyle::zoom, &RenderStyle::setZoomWithoutReturnValue));
    745745
    746746        gPropertyWrappers->append(new PropertyWrapper<LengthBox>(CSSPropertyClip, &RenderStyle::clip, &RenderStyle::setClip));
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r91702 r92164  
    946946    void setDirection(TextDirection v) { inherited_flags._direction = v; }
    947947    void setLineHeight(Length v) { SET_VAR(inherited, line_height, v) }
    948     void setZoom(float f) { SET_VAR(visual, m_zoom, f); setEffectiveZoom(effectiveZoom() * zoom()); }
    949     void setEffectiveZoom(float f) { SET_VAR(rareInheritedData, m_effectiveZoom, f) }
     948    bool setZoom(float);
     949    void setZoomWithoutReturnValue(float f) { setZoom(f); }
     950    bool setEffectiveZoom(float);
    950951    void setImageRendering(EImageRendering v) { SET_VAR(rareInheritedData, m_imageRendering, v) }
    951952
     
    14321433}
    14331434
     1435inline bool RenderStyle::setZoom(float f)
     1436{
     1437    if (compareEqual(visual->m_zoom, f))
     1438        return false;
     1439    visual.access()->m_zoom = f;
     1440    setEffectiveZoom(effectiveZoom() * zoom());
     1441    return true;
     1442}
     1443
     1444inline bool RenderStyle::setEffectiveZoom(float f)
     1445{
     1446    if (compareEqual(rareInheritedData->m_effectiveZoom, f))
     1447        return false;
     1448    rareInheritedData.access()->m_effectiveZoom = f;
     1449    return true;
     1450}
     1451
    14341452} // namespace WebCore
    14351453
Note: See TracChangeset for help on using the changeset viewer.