Changeset 177289 in webkit


Ignore:
Timestamp:
Dec 15, 2014 10:57:58 AM (9 years ago)
Author:
Bem Jones-Bey
Message:

[CSS Shapes] Fix StyleBuilder code to use CSSValueNone to match spec and other code
https://bugs.webkit.org/show_bug.cgi?id=139601

Reviewed by Chris Dumez.

Change the code to properly use CSSValueNone instead of CSSValueAuto.
Asserts have been added to catch similar errors in the future.
In doing this change, it became apparent that there is nothing
special about the shape-outside property that requires custom code, so
it was changed to use a standard converter function.

No change observable via LayoutTests.

  • css/CSSPropertyNames.in: Use a converter instead of custom code.
  • css/StyleBuilderConverter.h:

(WebCore::isImageShape): Helper function so that isImageSetValue can

be properly guarded.

(WebCore::StyleBuilderConverter::convertShapeValue): Format as a

converter instead of custom code.

  • css/StyleBuilderCustom.h:

(WebCore::StyleBuilderCustom::applyValueWebkitShapeOutside): Deleted.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r177284 r177289  
     12014-12-15  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        [CSS Shapes] Fix StyleBuilder code to use CSSValueNone to match spec and other code
     4        https://bugs.webkit.org/show_bug.cgi?id=139601
     5
     6        Reviewed by Chris Dumez.
     7
     8        Change the code to properly use CSSValueNone instead of CSSValueAuto.
     9        Asserts have been added to catch similar errors in the future.
     10        In doing this change, it became apparent that there is nothing
     11        special about the shape-outside property that requires custom code, so
     12        it was changed to use a standard converter function.
     13
     14        No change observable via LayoutTests.
     15
     16        * css/CSSPropertyNames.in: Use a converter instead of custom code.
     17        * css/StyleBuilderConverter.h:
     18        (WebCore::isImageShape): Helper function so that isImageSetValue can
     19            be properly guarded.
     20        (WebCore::StyleBuilderConverter::convertShapeValue): Format as a
     21            converter instead of custom code.
     22        * css/StyleBuilderCustom.h:
     23        (WebCore::StyleBuilderCustom::applyValueWebkitShapeOutside): Deleted.
     24
    1252014-12-15  Oliver Hunt  <oliver@apple.com>
    226
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r177282 r177289  
    537537#endif
    538538#if defined(ENABLE_CSS_SHAPES) && ENABLE_CSS_SHAPES
    539 -webkit-shape-outside [Custom=Value]
     539-webkit-shape-outside [Converter=ShapeValue]
    540540-webkit-shape-margin [Converter=Length]
    541541-webkit-shape-image-threshold [Converter=Number<float>]
  • trunk/Source/WebCore/css/StyleBuilderConverter.h

    r177282 r177289  
    3030#include "BasicShapeFunctions.h"
    3131#include "CSSCalculationValue.h"
     32#include "CSSImageGeneratorValue.h"
     33#include "CSSImageSetValue.h"
     34#include "CSSImageValue.h"
    3235#include "CSSPrimitiveValue.h"
    3336#include "CSSReflectValue.h"
     
    7578    static LineBoxContain convertLineBoxContain(StyleResolver&, CSSValue&);
    7679    static TextDecorationSkip convertTextDecorationSkip(StyleResolver&, CSSValue&);
     80    static PassRefPtr<ShapeValue> convertShapeValue(StyleResolver&, CSSValue&);
    7781
    7882private:
     
    587591}
    588592
     593#if ENABLE(CSS_SHAPES)
     594static inline bool isImageShape(const CSSValue& value)
     595{
     596    return is<CSSImageValue>(value)
     597#if ENABLE(CSS_IMAGE_SET)
     598        || is<CSSImageSetValue>(value)
     599#endif
     600        || is<CSSImageGeneratorValue>(value);
     601}
     602
     603inline PassRefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleResolver& styleResolver, CSSValue& value)
     604{
     605    if (is<CSSPrimitiveValue>(value)) {
     606        ASSERT(downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueNone);
     607        return nullptr;
     608    }
     609
     610    if (isImageShape(value))
     611        return ShapeValue::createImageValue(styleResolver.styleImage(CSSPropertyWebkitShapeOutside, value));
     612
     613    RefPtr<BasicShape> shape;
     614    CSSBoxType referenceBox = BoxMissing;
     615    for (auto& currentValue : downcast<CSSValueList>(value)) {
     616        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(currentValue.get());
     617        if (primitiveValue.isShape())
     618            shape = basicShapeForValue(styleResolver.state().cssToLengthConversionData(), primitiveValue.getShapeValue());
     619        else if (primitiveValue.getValueID() == CSSValueContentBox
     620            || primitiveValue.getValueID() == CSSValueBorderBox
     621            || primitiveValue.getValueID() == CSSValuePaddingBox
     622            || primitiveValue.getValueID() == CSSValueMarginBox)
     623            referenceBox = primitiveValue;
     624        else {
     625            ASSERT_NOT_REACHED();
     626            return nullptr;
     627        }
     628    }
     629
     630    if (shape)
     631        return ShapeValue::createShapeValue(shape.release(), referenceBox);
     632
     633    if (referenceBox != BoxMissing)
     634        return ShapeValue::createBoxShapeValue(referenceBox);
     635
     636    ASSERT_NOT_REACHED();
     637    return nullptr;
     638}
     639#endif // ENABLE(CSS_SHAPES)
    589640
    590641} // namespace WebCore
  • trunk/Source/WebCore/css/StyleBuilderCustom.h

    r177274 r177289  
    2828#define StyleBuilderCustom_h
    2929
    30 #include "BasicShapeFunctions.h"
    3130#include "CSSAspectRatioValue.h"
    32 #include "CSSImageGeneratorValue.h"
    33 #include "CSSImageSetValue.h"
    34 #include "CSSImageValue.h"
    3531#include "CSSShadowValue.h"
    3632#include "Frame.h"
     
    5349    static void applyInheritZoom(StyleResolver&);
    5450    static void applyValueZoom(StyleResolver&, CSSValue&);
    55 
    56 #if ENABLE(CSS_SHAPES)
    57     static void applyValueWebkitShapeOutside(StyleResolver&, CSSValue&);
    58 #endif // ENABLE(CSS_SHAPES)
    5951
    6052    static void applyValueVerticalAlign(StyleResolver&, CSSValue&);
     
    237229    }
    238230}
    239 
    240 #if ENABLE(CSS_SHAPES)
    241 inline void StyleBuilderCustom::applyValueWebkitShapeOutside(StyleResolver& styleResolver, CSSValue& value)
    242 {
    243     if (is<CSSPrimitiveValue>(value)) {
    244         // FIXME: Shouldn't this be CSSValueNone?
    245         // http://www.w3.org/TR/css-shapes/#shape-outside-property
    246         if (downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueAuto)
    247             styleResolver.style()->setShapeOutside(nullptr);
    248     } if (is<CSSImageValue>(value) || is<CSSImageGeneratorValue>(value) || is<CSSImageSetValue>(value)) {
    249         RefPtr<ShapeValue> shape = ShapeValue::createImageValue(styleResolver.styleImage(CSSPropertyWebkitShapeOutside, value));
    250         styleResolver.style()->setShapeOutside(shape.release());
    251     } else if (is<CSSValueList>(value)) {
    252         RefPtr<BasicShape> shape;
    253         CSSBoxType referenceBox = BoxMissing;
    254         for (auto& currentValue : downcast<CSSValueList>(value)) {
    255             CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(currentValue.get());
    256             if (primitiveValue.isShape())
    257                 shape = basicShapeForValue(styleResolver.state().cssToLengthConversionData(), primitiveValue.getShapeValue());
    258             else if (primitiveValue.getValueID() == CSSValueContentBox
    259                 || primitiveValue.getValueID() == CSSValueBorderBox
    260                 || primitiveValue.getValueID() == CSSValuePaddingBox
    261                 || primitiveValue.getValueID() == CSSValueMarginBox)
    262                 referenceBox = CSSBoxType(primitiveValue);
    263             else
    264                 return;
    265         }
    266 
    267         if (shape)
    268             styleResolver.style()->setShapeOutside(ShapeValue::createShapeValue(shape.release(), referenceBox));
    269         else if (referenceBox != BoxMissing)
    270             styleResolver.style()->setShapeOutside(ShapeValue::createBoxShapeValue(referenceBox));
    271     }
    272 }
    273 #endif // ENABLE(CSS_SHAPES)
    274 
    275231inline Length StyleBuilderCustom::mmLength(double mm)
    276232{
Note: See TracChangeset for help on using the changeset viewer.