Ignore:
Timestamp:
Feb 20, 2013, 7:39:42 PM (12 years ago)
Author:
[email protected]
Message:

[Refactoring] Make m_state an on-stack object
https://bugs.webkit.org/show_bug.cgi?id=109909

Reviewed by Antti Koivisto.

Mode m_state, an instance of StyleResolver::State, an on-stack object.
The state is only required in styleForElement, styleForKeyframe and
so on. No need to keep the state outside of those methods.

No new tests, because just refactoring.

  • css/BasicShapeFunctions.cpp:

(WebCore::convertToLength):
(WebCore::basicShapeForValue):

  • css/BasicShapeFunctions.h:

(WebCore):
Replaced StyleResolver* with StyleResolver::State&.

  • css/CSSGradientValue.cpp:

(WebCore::CSSGradientValue::gradientWithStylesResolved):

  • css/CSSGradientValue.h:

(CSSGradientValue):
Replaced StyleResolver* with StyleResolver::State&.

  • css/CSSToStyleMap.cpp:

(WebCore::CSSToStyleMap::style):
(WebCore::CSSToStyleMap::rootElementStyle):
(WebCore::CSSToStyleMap::useSVGZoomRules):
(WebCore::CSSToStyleMap::styleImage):

  • css/CSSToStyleMap.h:

(WebCore):
(WebCore::CSSToStyleMap::CSSToStyleMap):
(CSSToStyleMap):
Replaced StyleResolver* with StyleResolver::State&.

  • css/SVGCSSStyleSelector.cpp:

(WebCore::StyleResolver::applySVGProperty):
Replaced m_state with state which is given as an argument of
applySVGProperty.

  • css/StyleBuilder.cpp:

(WebCore::ApplyPropertyExpanding::applyInheritValue):
(WebCore::ApplyPropertyExpanding::applyInitialValue):
(WebCore::ApplyPropertyExpanding::applyValue):
(WebCore::ApplyPropertyDefaultBase::applyInheritValue):
(WebCore::ApplyPropertyDefaultBase::applyInitialValue):
(WebCore::ApplyPropertyDefaultBase::applyValue):
(WebCore::ApplyPropertyDefault::applyValue):
(WebCore::ApplyPropertyNumber::applyValue):
(WebCore::ApplyPropertyStyleImage::applyValue):
(WebCore::ApplyPropertyAuto::applyInheritValue):
(WebCore::ApplyPropertyAuto::applyInitialValue):
(WebCore::ApplyPropertyAuto::applyValue):
(WebCore::ApplyPropertyClip::convertToLength):
(WebCore::ApplyPropertyClip::applyInheritValue):
(WebCore::ApplyPropertyClip::applyInitialValue):
(WebCore::ApplyPropertyClip::applyValue):
(WebCore::ApplyPropertyColor::applyInheritValue):
(WebCore::ApplyPropertyColor::applyInitialValue):
(WebCore::ApplyPropertyColor::applyValue):
(WebCore::ApplyPropertyColor::applyColorValue):
(WebCore::ApplyPropertyDirection::applyValue):
(WebCore::ApplyPropertyLength::applyValue):
(WebCore::ApplyPropertyString::applyValue):
(WebCore::ApplyPropertyBorderRadius::applyValue):
(WebCore::ApplyPropertyFillLayer::applyInheritValue):
(WebCore::ApplyPropertyFillLayer::applyInitialValue):
(WebCore::ApplyPropertyFillLayer::applyValue):
(WebCore::ApplyPropertyComputeLength::applyValue):
(WebCore::ApplyPropertyFont::applyInheritValue):
(WebCore::ApplyPropertyFont::applyInitialValue):
(WebCore::ApplyPropertyFont::applyValue):
(WebCore::ApplyPropertyFontSize::applyInheritValue):
(WebCore::ApplyPropertyFontSize::applyInitialValue):
(WebCore::ApplyPropertyFontSize::applyValue):
(WebCore::ApplyPropertyFontWeight::applyValue):
(WebCore::ApplyPropertyFontVariantLigatures::applyInheritValue):
(WebCore::ApplyPropertyFontVariantLigatures::applyInitialValue):
(WebCore::ApplyPropertyFontVariantLigatures::applyValue):
(WebCore::ApplyPropertyBorderImage::applyValue):
(WebCore::ApplyPropertyBorderImageModifier::applyInheritValue):
(WebCore::ApplyPropertyBorderImageModifier::applyInitialValue):
(WebCore::ApplyPropertyBorderImageModifier::applyValue):
(WebCore::ApplyPropertyBorderImageSource::applyValue):
(WebCore::ApplyPropertyCounter::emptyFunction):
(WebCore::ApplyPropertyCounter::applyInheritValue):
(WebCore::ApplyPropertyCounter::applyValue):
(WebCore::ApplyPropertyCursor::applyInheritValue):
(WebCore::ApplyPropertyCursor::applyInitialValue):
(WebCore::ApplyPropertyCursor::applyValue):
(WebCore::ApplyPropertyTextAlign::applyValue):
(WebCore::ApplyPropertyTextDecoration::applyValue):
(WebCore::ApplyPropertyLineHeight::applyValue):
(WebCore::ApplyPropertyPageSize::applyInheritValue):
(WebCore::ApplyPropertyPageSize::applyInitialValue):
(WebCore::ApplyPropertyPageSize::applyValue):
(WebCore::ApplyPropertyTextEmphasisStyle::applyInheritValue):
(WebCore::ApplyPropertyTextEmphasisStyle::applyInitialValue):
(WebCore::ApplyPropertyTextEmphasisStyle::applyValue):
(WebCore::ApplyPropertyAnimation::map):
(WebCore::ApplyPropertyAnimation::applyInheritValue):
(WebCore::ApplyPropertyAnimation::applyInitialValue):
(WebCore::ApplyPropertyAnimation::applyValue):
(WebCore::ApplyPropertyOutlineStyle::applyInheritValue):
(WebCore::ApplyPropertyOutlineStyle::applyInitialValue):
(WebCore::ApplyPropertyOutlineStyle::applyValue):
(WebCore::ApplyPropertyResize::applyValue):
(WebCore::ApplyPropertyVerticalAlign::applyValue):
(WebCore::ApplyPropertyAspectRatio::applyInheritValue):
(WebCore::ApplyPropertyAspectRatio::applyInitialValue):
(WebCore::ApplyPropertyAspectRatio::applyValue):
(WebCore::ApplyPropertyZoom::resetEffectiveZoom):
(WebCore::ApplyPropertyZoom::applyInheritValue):
(WebCore::ApplyPropertyZoom::applyInitialValue):
(WebCore::ApplyPropertyZoom::applyValue):
(WebCore::ApplyPropertyDisplay::isValidDisplayValue):
(WebCore::ApplyPropertyDisplay::applyInheritValue):
(WebCore::ApplyPropertyDisplay::applyInitialValue):
(WebCore::ApplyPropertyDisplay::applyValue):
(WebCore::ApplyPropertyClipPath::applyValue):
(WebCore::ApplyPropertyExclusionShape::applyValue):
(WebCore::ApplyPropertyImageResolution::applyInheritValue):
(WebCore::ApplyPropertyImageResolution::applyInitialValue):
(WebCore::ApplyPropertyImageResolution::applyValue):

  • css/StyleBuilder.h:

(WebCore):
(PropertyHandler):
(WebCore::PropertyHandler::applyInheritValue):
(WebCore::PropertyHandler::applyInitialValue):
(WebCore::PropertyHandler::applyValue):
Replaced StyleResolver* with StyleResolver::State&.

  • css/StyleResolver.cpp:

(WebCore):
(WebCore::StyleResolver::StyleResolver):
Removed m_styleMap. Now m_styleMap is an on-stack object.
(WebCore::StyleResolver::collectMatchingRules):
(WebCore::StyleResolver::collectMatchingRulesForRegion):
(WebCore::StyleResolver::sortAndTransferMatchedRules):
(WebCore::StyleResolver::matchScopedAuthorRules):
(WebCore::StyleResolver::styleSharingCandidateMatchesHostRules):
(WebCore::StyleResolver::matchHostRules):
(WebCore::StyleResolver::matchAuthorRules):
(WebCore::StyleResolver::matchUserRules):
(WebCore::StyleResolver::matchUARules):
(WebCore::StyleResolver::collectMatchingRulesForList):
(WebCore::StyleResolver::sortMatchedRules):
(WebCore::StyleResolver::matchAllRules):
(WebCore::StyleResolver::initElement):
(WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet):
(WebCore::StyleResolver::canShareStyleWithControl):
(WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes):
(WebCore::StyleResolver::canShareStyleWithElement):
(WebCore::StyleResolver::findSiblingForStyleSharing):
(WebCore::StyleResolver::locateSharedStyle):
(WebCore::StyleResolver::styleForElement):
(WebCore::StyleResolver::styleForKeyframe):
(WebCore::StyleResolver::keyframeStylesForAnimation):
(WebCore::StyleResolver::pseudoStyleForElement):
(WebCore::StyleResolver::styleForPage):
(WebCore::StyleResolver::defaultStyleForElement):
(WebCore::StyleResolver::adjustRenderStyle):
(WebCore::StyleResolver::updateFont):
(WebCore::StyleResolver::pseudoStyleRulesForElement):
(WebCore::StyleResolver::ruleMatches):
(WebCore::StyleResolver::checkRegionSelector):
(WebCore::StyleResolver::applyProperties):
(WebCore::StyleResolver::applyMatchedProperties):
(WebCore::StyleResolver::isLeftPage):
(WebCore::StyleResolver::applyPropertyWithNullCheck):
(WebCore::StyleResolver::applyFontPropertyToStyle):
(WebCore::StyleResolver::resolveVariables):
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::styleImage):
(WebCore::StyleResolver::cachedOrPendingFromValue):
(WebCore::StyleResolver::generatedOrPendingFromValue):
(WebCore::StyleResolver::setOrPendingFromValue):
(WebCore::StyleResolver::cursorOrPendingFromValue):
(WebCore::StyleResolver::checkForTextSizeAdjust):
(WebCore::StyleResolver::checkForZoomChange):
(WebCore::StyleResolver::checkForGenericFamilyChange):
(WebCore::StyleResolver::initializeFontStyle):
(WebCore::StyleResolver::setFontSize):
(WebCore::StyleResolver::colorFromPrimitiveValue):
(WebCore::StyleResolver::loadPendingSVGDocuments):
(WebCore::StyleResolver::styleShader):
(WebCore::StyleResolver::cachedOrPendingStyleShaderFromValue):
(WebCore::StyleResolver::loadPendingShaders):
(WebCore::StyleResolver::parseCustomFilterTransformParameter):
(WebCore::StyleResolver::parseCustomFilterParameter):
(WebCore::StyleResolver::parseCustomFilterParameterList):
(WebCore::StyleResolver::createCustomFilterOperationWithInlineSyntax):
(WebCore::StyleResolver::createCustomFilterOperation):
(WebCore::StyleResolver::createFilterOperations):
(WebCore::StyleResolver::loadPendingImage):
(WebCore::StyleResolver::loadPendingImages):
(WebCore::StyleResolver::loadPendingResources):
Just replaced m_state with state and added one more parameter to
provide the state.
(WebCore::StyleResolver::reportMemoryUsage):
Since m_state was removed, removed a code for reporting m_state's
memory usage.

  • css/StyleResolver.h:

(StyleResolver):
(WebCore::StyleResolver::isRightPage):
(WebCore::StyleResolver::State::State):
(WebCore::StyleResolver::State::document):
Since State::m_element is not always available (sometimes, 0),
added m_document to State and modified to return the m_document.
(WebCore::StyleResolver::State::useSVGZoomRules):
Moved StyleResolver to State.
(State):

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::setFont):
Moved the code, updating a style by using a given StylePropertySet,
to StyleResolver.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r142444 r143556  
    3636#include "NodeRenderStyle.h"
    3737#include "RenderObject.h"
    38 #include "StyleResolver.h"
    3938#include "WebCoreMemoryInstrumentation.h"
    4039#include <wtf/MemoryInstrumentationVector.h>
     
    116115};
    117116
    118 PassRefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(StyleResolver* styleResolver)
     117PassRefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(StyleResolver::State& state)
    119118{
    120119    bool derived = false;
    121120    for (unsigned i = 0; i < m_stops.size(); i++)
    122         if (styleResolver->colorFromPrimitiveValueIsDerivedFromElement(m_stops[i].m_color.get())) {
     121        if (StyleResolver::colorFromPrimitiveValueIsDerivedFromElement(m_stops[i].m_color.get())) {
    123122            m_stops[i].m_colorIsDerivedFromElement = true;
    124123            derived = true;
     
    139138
    140139    for (unsigned i = 0; i < result->m_stops.size(); i++)
    141         result->m_stops[i].m_resolvedColor = styleResolver->colorFromPrimitiveValue(result->m_stops[i].m_color.get());
     140        result->m_stops[i].m_resolvedColor = StyleResolver::colorFromPrimitiveValue(state, result->m_stops[i].m_color.get());
    142141
    143142    return result.release();
Note: See TracChangeset for help on using the changeset viewer.