Skip to content

Commit

Permalink
SVGAnimatedEnumeration initial values
Browse files Browse the repository at this point in the history
This implements initial values for SVGAnimatedEnumeration properties.

Bug: 225807, 523685
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I857dd5d6a52b2e3c4e866c2b589be3373449fc24
Reviewed-on: https://chromium-review.googlesource.com/1209683
Reviewed-by: Philip Rogers <[email protected]>
Commit-Queue: Fredrik Söderquist <[email protected]>
Cr-Commit-Position: refs/heads/master@{#589217}
  • Loading branch information
Fredrik Söderquist authored and Commit Bot committed Sep 6, 2018
1 parent 9067d0c commit d694dd9
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
const objects = {
SVGCircleElement: 'circle',
SVGClipPathElement: 'clipPath',
SVGComponentTransferFunctionElement: 'feFuncA',
SVGEllipseElement: 'ellipse',
SVGFEBlendElement: 'feBlend',
SVGFEColorMatrixElement: 'feColorMatrix',
SVGFECompositeElement: 'feComposite',
SVGFEConvolveMatrixElement: 'feConvolveMatrix',
SVGFEDisplacementMapElement: 'feDisplacementMap',
SVGFEMorphologyElement: 'feMorphology',
SVGFETurbulenceElement: 'feTurbulence',
SVGFilterElement: 'filter',
SVGFilterPrimitiveStandardAttributes: 'feBlend',
SVGForeignObjectElement: 'foreignObject',
SVGGradientElement: 'linearGradient',
SVGImageElement: 'image',
SVGLineElement: 'line',
SVGLinearGradientElement: 'linearGradient',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<title>SVGAnimatedEnumeration, initial values</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/initial-value-helper.js"></script>
<script>
assert_initial_values([
{ interface: 'SVGClipPathElement', attributes: [ 'clipPathUnits' ],
clipPathUnits: { initial: SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE, valid: 'objectBoundingBox' } },
{ interface: 'SVGComponentTransferFunctionElement', attributes: [ 'type' ],
type: { initial: SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY, valid: 'table' } },
{ interface: 'SVGFEBlendElement', attributes: [ 'mode' ],
mode: { initial: SVGFEBlendElement.SVG_FEBLEND_MODE_NORMAL, valid: 'screen' } },
{ interface: 'SVGFEColorMatrixElement', attributes: [ 'type' ],
type: { initial: SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX, valid: 'saturate' } },
{ interface: 'SVGFECompositeElement', attributes: [ 'operator' ],
operator: { initial: SVGFECompositeElement.SVG_FECOMPOSITE_OPERATOR_OVER, valid: 'in' } },
{ interface: 'SVGFEConvolveMatrixElement', attributes: [ 'edgeMode' ],
edgeMode: { initial: SVGFEConvolveMatrixElement.SVG_EDGEMODE_DUPLICATE, valid: 'wrap' } },
{ interface: 'SVGFEDisplacementMapElement', attributes: [ 'xChannelSelector', 'yChannelSelector' ],
xChannelSelector: { initial: SVGFEDisplacementMapElement.SVG_CHANNEL_A, valid: 'R' },
yChannelSelector: { initial: SVGFEDisplacementMapElement.SVG_CHANNEL_A, valid: 'G' } },
{ interface: 'SVGFEMorphologyElement', attributes: [ 'operator' ],
operator: { initial: SVGFEMorphologyElement.SVG_MORPHOLOGY_OPERATOR_ERODE, valid: 'dilate' } },
{ interface: 'SVGFETurbulenceElement', attributes: [ 'stitchTiles', 'type' ],
stitchTiles: { initial: SVGFETurbulenceElement.SVG_STITCHTYPE_NOSTITCH, valid: 'stitch' },
type: { initial: SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_TURBULENCE, valid: 'fractalNoise' } },
{ interface: 'SVGFilterElement', attributes: [ 'filterUnits', 'primitiveUnits' ],
filterUnits: { initial: SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, valid: 'userSpaceOnUse' },
primitiveUnits: { initial: SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE, valid: 'objectBoundingBox' } },
{ interface: 'SVGGradientElement', attributes: [ 'gradientUnits', 'spreadMethod' ],
gradientUnits: { initial: SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, valid: 'userSpaceOnUse' },
spreadMethod: { initial: SVGGradientElement.SVG_SPREADMETHOD_PAD, valid: 'repeat' } },
{ interface: 'SVGMarkerElement', attributes: [ 'markerUnits', 'orientType' ],
markerUnits: { initial: SVGMarkerElement.SVG_MARKERUNITS_STROKEWIDTH, valid: 'userSpaceOnUse' },
orientType: { initial: SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE, valid: 'auto' } },
{ interface: 'SVGMaskElement', attributes: [ 'maskUnits', 'maskContentUnits' ],
maskUnits: { initial: SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, valid: 'userSpaceOnUse' },
maskContentUnits: { initial: SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE, valid: 'objectBoundingBox' } },
{ interface: 'SVGPatternElement', attributes: [ 'patternUnits', 'patternContentUnits' ],
patternUnits: { initial: SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, valid: 'userSpaceOnUse' },
patternContentUnits: { initial: SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE, valid: 'objectBoundingBox' } },
{ interface: 'SVGTextContentElement', attributes: [ 'lengthAdjust' ],
lengthAdjust: { initial: SVGTextContentElement.LENGTHADJUST_SPACING, valid: 'spacingAndGlyphs' } },
{ interface: 'SVGTextPathElement', attributes: [ 'method', 'spacing' ],
method: { initial: SVGTextPathElement.TEXTPATH_METHODTYPE_ALIGN, valid: 'stretch' },
spacing: { initial: SVGTextPathElement.TEXTPATH_SPACINGTYPE_EXACT, valid: 'auto' } },
], { mapProperty: { orientType: 'orient' } });
</script>
14 changes: 9 additions & 5 deletions third_party/blink/renderer/core/svg/svg_animated_enumeration.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ class SVGAnimatedEnumeration : public SVGAnimatedEnumerationBase {
Enum initial_value) {
return new SVGAnimatedEnumeration(
context_element, attribute_name,
SVGEnumeration<Enum>::Create(initial_value));
SVGEnumeration<Enum>::Create(initial_value),
static_cast<unsigned>(initial_value));
}

static SVGAnimatedEnumeration<Enum>* Create(
SVGElement* context_element,
const QualifiedName& attribute_name,
SVGEnumeration<Enum>* initial_value) {
return new SVGAnimatedEnumeration(context_element, attribute_name,
initial_value);
return new SVGAnimatedEnumeration(
context_element, attribute_name, initial_value,
static_cast<unsigned>(initial_value->EnumValue()));
}

SVGEnumeration<Enum>* BaseValue() {
Expand All @@ -73,10 +75,12 @@ class SVGAnimatedEnumeration : public SVGAnimatedEnumerationBase {
protected:
SVGAnimatedEnumeration(SVGElement* context_element,
const QualifiedName& attribute_name,
SVGEnumeration<Enum>* initial_value)
SVGEnumeration<Enum>* initial_value,
unsigned initial_enum_value)
: SVGAnimatedEnumerationBase(context_element,
attribute_name,
initial_value) {}
initial_value,
initial_enum_value) {}
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ class SVGAnimatedEnumerationBase
protected:
SVGAnimatedEnumerationBase(SVGElement* context_element,
const QualifiedName& attribute_name,
SVGEnumerationBase* initial_value)
SVGEnumerationBase* initial_value,
unsigned initial_enum_value)
: SVGAnimatedProperty<SVGEnumerationBase>(context_element,
attribute_name,
initial_value) {}
initial_value,
CSSPropertyInvalid,
initial_enum_value) {}
};

} // namespace blink
Expand Down
5 changes: 5 additions & 0 deletions third_party/blink/renderer/core/svg/svg_enumeration.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class SVGEnumerationBase : public SVGPropertyBase {
// relevant interface.
unsigned short MaxExposedEnumValue() const { return max_exposed_; }

void SetInitial(unsigned value) {
SetValue(static_cast<unsigned short>(value));
}
static constexpr int kInitialValueBits = 3;

protected:
SVGEnumerationBase(unsigned short value,
const StringEntries& entries,
Expand Down

0 comments on commit d694dd9

Please sign in to comment.