Commit ad8b341a authored by andersr@opera.com's avatar andersr@opera.com

Move special code for 'shape-outside' out of StyleBuilderFunctions.cpp.tmpl.

There should not be special code generation for a single property, at
least not in cases where a converter can easily be used instead.

Changes:

 * Assume that 'value' is either 'none', an image value, or a list of
   values.
 * Use primitive value mapping for CSSBoxType, since parser ensures
   that only valid values go though.

R=timloh@chromium.org

Review URL: https://codereview.chromium.org/645073003

git-svn-id: svn://svn.chromium.org/blink/trunk@183982 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1402da41
......@@ -509,42 +509,6 @@ static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt
{% endmacro %}
{{apply_value_number('CSSPropertyInternalMarqueeRepetition', 'CSSValueInfinite')}}
{% macro apply_value_shape(property_id) %}
{{declare_value_function(property_id)}}
{
{% set property = properties[property_id] %}
if (value->isPrimitiveValue()) {
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
if (primitiveValue->getValueID() == CSSValueNone)
{{set_value(property)}}(nullptr);
} else if (value->isImageValue() || value->isImageGeneratorValue() || value->isImageSetValue()) {
{{set_value(property)}}(ShapeValue::createImageValue(state.styleImage({{property_id}}, value)));
} else if (value->isValueList()) {
RefPtr<BasicShape> shape;
CSSBoxType cssBox = BoxMissing;
CSSValueList* valueList = toCSSValueList(value);
for (unsigned i = 0; i < valueList->length(); ++i) {
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->item(i));
if (primitiveValue->isShape())
shape = basicShapeForValue(state, primitiveValue->getShapeValue());
else if (primitiveValue->getValueID() == CSSValueContentBox
|| primitiveValue->getValueID() == CSSValueBorderBox
|| primitiveValue->getValueID() == CSSValuePaddingBox
|| primitiveValue->getValueID() == CSSValueMarginBox)
cssBox = CSSBoxType(*primitiveValue);
else
return;
}
if (shape)
{{set_value(property)}}(ShapeValue::createShapeValue(shape.release(), cssBox));
else if (cssBox != BoxMissing)
{{set_value(property)}}(ShapeValue::createBoxShapeValue(cssBox));
}
}
{% endmacro %}
{{apply_value_shape('CSSPropertyShapeOutside')}}
{% macro apply_alignment(property_id, alignment_type) %}
{% set property = properties[property_id] %}
{{declare_initial_function(property_id)}}
......
......@@ -243,7 +243,7 @@ right animatable, initial=initialOffset, converter=convertLengthOrAuto
scroll-behavior runtime_flag=CSSOMSmoothScroll, type_name=ScrollBehavior
shape-image-threshold animatable, type_name=float
shape-margin animatable, converter=convertLength
shape-outside animatable, custom_value
shape-outside animatable, converter=convertShapeValue
shape-rendering inherited, svg
size custom_all
speak inherited
......
......@@ -27,6 +27,7 @@
#include "config.h"
#include "core/css/resolver/StyleBuilderConverter.h"
#include "core/css/BasicShapeFunctions.h"
#include "core/css/CSSFontFeatureValue.h"
#include "core/css/CSSFunctionValue.h"
#include "core/css/CSSGridLineNamesValue.h"
......@@ -718,6 +719,34 @@ PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow(StyleResolverState&
return ShadowList::adopt(shadows);
}
PassRefPtr<ShapeValue> StyleBuilderConverter::convertShapeValue(StyleResolverState& state, CSSValue* value)
{
if (value->isPrimitiveValue()) {
ASSERT(toCSSPrimitiveValue(value)->getValueID() == CSSValueNone);
return nullptr;
}
if (value->isImageValue() || value->isImageGeneratorValue() || value->isImageSetValue())
return ShapeValue::createImageValue(state.styleImage(CSSPropertyShapeOutside, value));
RefPtr<BasicShape> shape;
CSSBoxType cssBox = BoxMissing;
CSSValueList* valueList = toCSSValueList(value);
for (unsigned i = 0; i < valueList->length(); ++i) {
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->item(i));
if (primitiveValue->isShape())
shape = basicShapeForValue(state, primitiveValue->getShapeValue());
else
cssBox = CSSBoxType(*primitiveValue);
}
if (shape)
return ShapeValue::createShapeValue(shape.release(), cssBox);
ASSERT(cssBox != BoxMissing);
return ShapeValue::createBoxShapeValue(cssBox);
}
float StyleBuilderConverter::convertSpacing(StyleResolverState& state, CSSValue* value)
{
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
......
......@@ -73,6 +73,7 @@ public:
static LengthSize convertRadius(StyleResolverState&, CSSValue*);
static EPaintOrder convertPaintOrder(StyleResolverState&, CSSValue*);
static PassRefPtr<ShadowList> convertShadow(StyleResolverState&, CSSValue*);
static PassRefPtr<ShapeValue> convertShapeValue(StyleResolverState&, CSSValue*);
static float convertSpacing(StyleResolverState&, CSSValue*);
template <CSSValueID IdForNone> static AtomicString convertString(StyleResolverState&, CSSValue*);
static PassRefPtr<SVGLengthList> convertStrokeDasharray(StyleResolverState&, CSSValue*);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment