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

Changeset 196991 in webkit


Ignore:
Timestamp:
Feb 23, 2016, 1:18:05 PM (11 years ago)
Author:
Simon Fraser
Message:

Lay the groundwork for more constness in StyleResolver-related code
​https://bugs.webkit.org/show_bug.cgi?id=154598

Reviewed by Antti Koivisto.

Make some of the leaf functions that are used by the style resolver take
const CSSValues, and use 'auto' more to automatically get const stack variables
when appropriate.

  • css/CSSBorderImageSliceValue.h:

(WebCore::CSSBorderImageSliceValue::slices):

  • css/CSSPrimitiveValue.h:

(WebCore::CSSPrimitiveValue::isQuirkValue):

  • css/FontVariantBuilder.cpp:

(WebCore::extractFontVariantLigatures):
(WebCore::extractFontVariantNumeric):
(WebCore::extractFontVariantEastAsian):

  • css/FontVariantBuilder.h:
  • css/StyleBuilderConverter.h:

(WebCore::StyleBuilderConverter::convertReflection):
(WebCore::StyleBuilderConverter::convertGridAutoFlow):

  • css/StyleBuilderCustom.h:

(WebCore::StyleBuilderCustom::applyValueSize):
(WebCore::StyleBuilderCustom::applyValueStroke):

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::colorFromPrimitiveValueIsDerivedFromElement):
(WebCore::StyleResolver::colorFromPrimitiveValue):
(WebCore::StyleResolver::createFilterOperations):

  • css/StyleResolver.h:
  • css/TransformFunctions.cpp:

(WebCore::transformsForValue):

  • css/TransformFunctions.h:
  • rendering/style/StylePendingImage.h:
  • svg/SVGLength.cpp:

(WebCore::SVGLength::fromCSSPrimitiveValue):

  • svg/SVGLength.h:
Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r196983 r196991  
     12016-02-23  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Lay the groundwork for more constness in StyleResolver-related code
     4        https://bugs.webkit.org/show_bug.cgi?id=154598
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Make some of the leaf functions that are used by the style resolver take
     9        const CSSValues, and use 'auto' more to automatically get const stack variables
     10        when appropriate.
     11
     12        * css/CSSBorderImageSliceValue.h:
     13        (WebCore::CSSBorderImageSliceValue::slices):
     14        * css/CSSPrimitiveValue.h:
     15        (WebCore::CSSPrimitiveValue::isQuirkValue):
     16        * css/FontVariantBuilder.cpp:
     17        (WebCore::extractFontVariantLigatures):
     18        (WebCore::extractFontVariantNumeric):
     19        (WebCore::extractFontVariantEastAsian):
     20        * css/FontVariantBuilder.h:
     21        * css/StyleBuilderConverter.h:
     22        (WebCore::StyleBuilderConverter::convertReflection):
     23        (WebCore::StyleBuilderConverter::convertGridAutoFlow):
     24        * css/StyleBuilderCustom.h:
     25        (WebCore::StyleBuilderCustom::applyValueSize):
     26        (WebCore::StyleBuilderCustom::applyValueStroke):
     27        * css/StyleResolver.cpp:
     28        (WebCore::StyleResolver::colorFromPrimitiveValueIsDerivedFromElement):
     29        (WebCore::StyleResolver::colorFromPrimitiveValue):
     30        (WebCore::StyleResolver::createFilterOperations):
     31        * css/StyleResolver.h:
     32        * css/TransformFunctions.cpp:
     33        (WebCore::transformsForValue):
     34        * css/TransformFunctions.h:
     35        * rendering/style/StylePendingImage.h:
     36        * svg/SVGLength.cpp:
     37        (WebCore::SVGLength::fromCSSPrimitiveValue):
     38        * svg/SVGLength.h:
     39
    1402016-02-23  Manuel Rego Casasnovas  <rego@igalia.com>
    241
  • trunk/Source/WebCore/css/CSSBorderImageSliceValue.h

    r177259 r196991  
    4444    String customCSSText() const;
    4545
    46     Quad* slices() { return m_slices ? m_slices->getQuadValue() : 0; }
     46    Quad* slices() const { return m_slices ? m_slices->getQuadValue() : nullptr; }
    4747
    4848    bool equals(const CSSBorderImageSliceValue&) const;
  • trunk/Source/WebCore/css/CSSPrimitiveValue.h

    r194851 r196991  
    370370    String customCSSText() const;
    371371
    372     bool isQuirkValue() { return m_isQuirkValue; }
     372    bool isQuirkValue() const { return m_isQuirkValue; }
    373373
    374374    void addSubresourceStyleURLs(ListHashSet<URL>&, const StyleSheetContents*) const;
  • trunk/Source/WebCore/css/FontVariantBuilder.cpp

    r196510 r196991  
    3434namespace WebCore {
    3535
    36 FontVariantLigaturesValues extractFontVariantLigatures(CSSValue& value)
     36FontVariantLigaturesValues extractFontVariantLigatures(const CSSValue& value)
    3737{
    3838    FontVariantLigatures common = FontVariantLigatures::Normal;
    … …  
    9292}
    9393
    94 FontVariantNumericValues extractFontVariantNumeric(CSSValue& value)
     94FontVariantNumericValues extractFontVariantNumeric(const CSSValue& value)
    9595{
    9696    FontVariantNumericFigure figure = FontVariantNumericFigure::Normal;
    … …  
    138138}
    139139
    140 FontVariantEastAsianValues extractFontVariantEastAsian(CSSValue& value)
     140FontVariantEastAsianValues extractFontVariantEastAsian(const CSSValue& value)
    141141{
    142142    FontVariantEastAsianVariant variant = FontVariantEastAsianVariant::Normal;
  • trunk/Source/WebCore/css/FontVariantBuilder.h

    r196510 r196991  
    3737struct FontVariantEastAsianValues;
    3838
    39 FontVariantLigaturesValues extractFontVariantLigatures(CSSValue&);
    40 FontVariantNumericValues extractFontVariantNumeric(CSSValue&);
    41 FontVariantEastAsianValues extractFontVariantEastAsian(CSSValue&);
     39FontVariantLigaturesValues extractFontVariantLigatures(const CSSValue&);
     40FontVariantNumericValues extractFontVariantNumeric(const CSSValue&);
     41FontVariantEastAsianValues extractFontVariantEastAsian(const CSSValue&);
    4242
    4343Ref<CSSValue> computeFontVariant(const FontVariantSettings&);
  • trunk/Source/WebCore/css/StyleBuilderConverter.h

    r196740 r196991  
    568568    }
    569569
    570     CSSReflectValue& reflectValue = downcast<CSSReflectValue>(value);
     570    auto& reflectValue = downcast<CSSReflectValue>(value);
    571571
    572572    RefPtr<StyleReflection> reflection = StyleReflection::create();
    … …  
    917917        return RenderStyle::initialGridAutoFlow();
    918918
    919     CSSPrimitiveValue& first = downcast<CSSPrimitiveValue>(*list.item(0));
    920     CSSPrimitiveValue* second = downcast<CSSPrimitiveValue>(list.item(1));
     919    auto& first = downcast<CSSPrimitiveValue>(*list.item(0));
     920    auto* second = downcast<CSSPrimitiveValue>(list.item(1));
    921921
    922922    GridAutoFlow autoFlow = RenderStyle::initialGridAutoFlow();
  • trunk/Source/WebCore/css/StyleBuilderCustom.h

    r196510 r196991  
    397397    switch (valueList.length()) {
    398398    case 2: {
    399         CSSValue* firstValue = valueList.itemWithoutBoundsCheck(0);
    400         CSSValue* secondValue = valueList.itemWithoutBoundsCheck(1);
     399        auto firstValue = valueList.itemWithoutBoundsCheck(0);
     400        auto secondValue = valueList.itemWithoutBoundsCheck(1);
    401401        // <length>{2} | <page-size> <orientation>
    402402        if (!is<CSSPrimitiveValue>(*firstValue) || !is<CSSPrimitiveValue>(*secondValue))
    … …  
    421421    }
    422422    case 1: {
    423         CSSValue* value = valueList.itemWithoutBoundsCheck(0);
     423        auto value = valueList.itemWithoutBoundsCheck(0);
    424424        // <length> | auto | <page-size> | [ portrait | landscape]
    425425        if (!is<CSSPrimitiveValue>(*value))
    … …  
    11961196{
    11971197    SVGRenderStyle& svgStyle = styleResolver.style()->accessSVGStyle();
    1198     SVGPaint& svgPaint = downcast<SVGPaint>(value);
     1198    auto& svgPaint = downcast<SVGPaint>(value);
    11991199    svgStyle.setStrokePaint(svgPaint.paintType(), StyleBuilderConverter::convertSVGColor(styleResolver, svgPaint), svgPaint.uri(), styleResolver.applyPropertyToRegularStyle(), styleResolver.applyPropertyToVisitedLinkStyle());
    12001200}
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r196555 r196991  
    17911791}
    17921792
    1793 bool StyleResolver::colorFromPrimitiveValueIsDerivedFromElement(CSSPrimitiveValue& value)
     1793bool StyleResolver::colorFromPrimitiveValueIsDerivedFromElement(const CSSPrimitiveValue& value)
    17941794{
    17951795    int ident = value.getValueID();
    … …  
    18051805}
    18061806
    1807 Color StyleResolver::colorFromPrimitiveValue(CSSPrimitiveValue& value, bool forVisitedLink) const
     1807Color StyleResolver::colorFromPrimitiveValue(const CSSPrimitiveValue& value, bool forVisitedLink) const
    18081808{
    18091809    if (value.isRGBColor())
    … …  
    18981898}
    18991899
    1900 bool StyleResolver::createFilterOperations(CSSValue& inValue, FilterOperations& outOperations)
     1900bool StyleResolver::createFilterOperations(const CSSValue& inValue, FilterOperations& outOperations)
    19011901{
    19021902    State& state = m_state;
    … …  
    19041904   
    19051905    if (is<CSSPrimitiveValue>(inValue)) {
    1906         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(inValue);
     1906        auto& primitiveValue = downcast<CSSPrimitiveValue>(inValue);
    19071907        if (primitiveValue.getValueID() == CSSValueNone)
    19081908            return true;
    … …  
    19231923            if (filterValue.length() != 1)
    19241924                continue;
    1925             CSSValue& argument = *filterValue.itemWithoutBoundsCheck(0);
     1925            auto& argument = *filterValue.itemWithoutBoundsCheck(0);
    19261926
    19271927            if (!is<CSSPrimitiveValue>(argument))
    19281928                continue;
    19291929
    1930             CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(argument);
     1930            auto& primitiveValue = downcast<CSSPrimitiveValue>(argument);
    19311931            String cssUrl = primitiveValue.getStringValue();
    19321932            URL url = m_state.document().completeURL(cssUrl);
    … …  
    19421942        // Check that all parameters are primitive values, with the
    19431943        // exception of drop shadow which has a CSSShadowValue parameter.
    1944         CSSPrimitiveValue* firstValue = nullptr;
     1944        const CSSPrimitiveValue* firstValue = nullptr;
    19451945        if (operationType != FilterOperation::DROP_SHADOW) {
    19461946            bool haveNonPrimitiveValue = false;
    … …  
    20072007                return false;
    20082008
    2009             CSSValue& cssValue = *filterValue.itemWithoutBoundsCheck(0);
     2009            auto& cssValue = *filterValue.itemWithoutBoundsCheck(0);
    20102010            if (!is<CSSShadowValue>(cssValue))
    20112011                continue;
    20122012
    2013             CSSShadowValue& item = downcast<CSSShadowValue>(cssValue);
     2013            auto& item = downcast<CSSShadowValue>(cssValue);
    20142014            int x = item.x->computeLength<int>(state.cssToLengthConversionData());
    20152015            int y = item.y->computeLength<int>(state.cssToLengthConversionData());
  • trunk/Source/WebCore/css/StyleResolver.h

    r196031 r196991  
    186186    bool useSVGZoomRulesForLength();
    187187
    188     static bool colorFromPrimitiveValueIsDerivedFromElement(CSSPrimitiveValue&);
    189     Color colorFromPrimitiveValue(CSSPrimitiveValue&, bool forVisitedLink = false) const;
     188    static bool colorFromPrimitiveValueIsDerivedFromElement(const CSSPrimitiveValue&);
     189    Color colorFromPrimitiveValue(const CSSPrimitiveValue&, bool forVisitedLink = false) const;
    190190
    191191    bool hasSelectorForId(const AtomicString&) const;
    … …  
    212212    void clearCachedPropertiesAffectedByViewportUnits();
    213213
    214     bool createFilterOperations(CSSValue& inValue, FilterOperations& outOperations);
     214    bool createFilterOperations(const CSSValue& inValue, FilterOperations& outOperations);
    215215    void loadPendingSVGDocuments();
    216216
  • trunk/Source/WebCore/css/TransformFunctions.cpp

    r196740 r196991  
    8282}
    8383
    84 bool transformsForValue(CSSValue& value, const CSSToLengthConversionData& conversionData, TransformOperations& outOperations)
     84bool transformsForValue(const CSSValue& value, const CSSToLengthConversionData& conversionData, TransformOperations& outOperations)
    8585{
    8686    if (!is<CSSValueList>(value)) {
    … …  
    108108            continue;
    109109
    110         CSSPrimitiveValue& firstValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(0));
     110        auto& firstValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(0));
    111111
    112112        switch (transformValue.operationType()) {
    … …  
    122122                if (transformValue.operationType() != WebKitCSSTransformValue::ScaleXTransformOperation) {
    123123                    if (transformValue.length() > 1) {
    124                         CSSPrimitiveValue& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
     124                        auto& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
    125125                        sy = secondValue.getDoubleValue();
    126126                    } else
    … …  
    144144                if (transformValue.operationType() != WebKitCSSTransformValue::ScaleXTransformOperation) {
    145145                    if (transformValue.length() > 2) {
    146                         CSSPrimitiveValue& thirdValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(2));
     146                        auto& thirdValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(2));
    147147                        sz = thirdValue.getDoubleValue();
    148148                    }
    149149                    if (transformValue.length() > 1) {
    150                         CSSPrimitiveValue& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
     150                        auto& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
    151151                        sy = secondValue.getDoubleValue();
    152152                    } else
    … …  
    168168                if (transformValue.operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    169169                    if (transformValue.length() > 1) {
    170                         CSSPrimitiveValue& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
     170                        auto& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
    171171                        ty = convertToFloatLength(&secondValue, conversionData);
    172172                    }
    … …  
    193193                if (transformValue.operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
    194194                    if (transformValue.length() > 2) {
    195                         CSSPrimitiveValue& thirdValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(2));
     195                        auto& thirdValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(2));
    196196                        tz = convertToFloatLength(&thirdValue, conversionData);
    197197                    }
    198198                    if (transformValue.length() > 1) {
    199                         CSSPrimitiveValue& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
     199                        auto& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
    200200                        ty = convertToFloatLength(&secondValue, conversionData);
    201201                    }
    … …  
    234234            if (transformValue.length() < 4)
    235235                break;
    236             CSSPrimitiveValue& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
    237             CSSPrimitiveValue& thirdValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(2));
    238             CSSPrimitiveValue& fourthValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(3));
     236            auto& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
     237            auto& thirdValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(2));
     238            auto& fourthValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(3));
    239239            double x = firstValue.getDoubleValue();
    240240            double y = secondValue.getDoubleValue();
    … …  
    256256                if (transformValue.operationType() == WebKitCSSTransformValue::SkewTransformOperation) {
    257257                    if (transformValue.length() > 1) {
    258                         CSSPrimitiveValue& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
     258                        auto& secondValue = downcast<CSSPrimitiveValue>(*transformValue.itemWithoutBoundsCheck(1));
    259259                        angleY = secondValue.computeDegrees();
    260260                    }
  • trunk/Source/WebCore/css/TransformFunctions.h

    r196740 r196991  
    4343struct Length;
    4444
    45 bool transformsForValue(CSSValue&, const CSSToLengthConversionData&, TransformOperations&);
     45bool transformsForValue(const CSSValue&, const CSSToLengthConversionData&, TransformOperations&);
    4646Length convertToFloatLength(const CSSPrimitiveValue*, const CSSToLengthConversionData&);
    4747
  • trunk/Source/WebCore/rendering/style/StylePendingImage.h

    r191083 r196991  
    4747
    4848    CSSImageValue* cssImageValue() const { return is<CSSImageValue>(m_value) ? downcast<CSSImageValue>(m_value) : nullptr; }
    49     CSSImageGeneratorValue* cssImageGeneratorValue() const { return m_value && m_value->isImageGeneratorValue() ? static_cast<CSSImageGeneratorValue*>(m_value) : nullptr; }
     49    CSSImageGeneratorValue* cssImageGeneratorValue() const { return is<CSSImageGeneratorValue>(m_value) ? static_cast<CSSImageGeneratorValue*>(m_value) : nullptr; }
    5050    CSSCursorImageValue* cssCursorImageValue() const { return is<CSSCursorImageValue>(m_value) ? downcast<CSSCursorImageValue>(m_value) : nullptr; }
    5151
  • trunk/Source/WebCore/svg/SVGLength.cpp

    r178237 r196991  
    282282}
    283283
    284 SVGLength SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue& value)
     284SVGLength SVGLength::fromCSSPrimitiveValue(const CSSPrimitiveValue& value)
    285285{
    286286    SVGLengthType svgType;
  • trunk/Source/WebCore/svg/SVGLength.h

    r184852 r196991  
    9999    }
    100100
    101     static SVGLength fromCSSPrimitiveValue(CSSPrimitiveValue&);
     101    static SVGLength fromCSSPrimitiveValue(const CSSPrimitiveValue&);
    102102    static Ref<CSSPrimitiveValue> toCSSPrimitiveValue(const SVGLength&);
    103103    static SVGLengthMode lengthModeForAnimatedLengthAttribute(const QualifiedName&);
Note: See TracChangeset for help on using the changeset viewer.