Changeset 112391 in webkit
- Timestamp:
- Mar 28, 2012 6:14:20 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r112387 r112391 1 2012-03-27 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Enable animVal support for SVGAnimatedPreserveAspectRatio 4 https://bugs.webkit.org/show_bug.cgi?id=82326 5 6 Reviewed by Zoltan Herczeg. 7 8 Extend SVGAnimatedPreserveAspectRatio tests to cover animVal support. 9 10 * svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js: 11 (sample1): 12 (sample2): 13 (sample3): 14 * svg/animations/svgPreserveAspectRatio-animation-1-expected.txt: 15 * svg/dom/preserve-aspect-ratio-parser-expected.txt: 16 * svg/dom/preserve-aspect-ratio-parser.html: Parsing errors now yield to 'unknown' pAR values, as desired. 17 1 18 2012-03-28 Alexis Menard <alexis.menard@openbossa.org> 2 19 -
trunk/LayoutTests/svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js
r110574 r112391 27 27 shouldBe("rootSVGElement.preserveAspectRatio.animVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN"); 28 28 shouldBe("rootSVGElement.preserveAspectRatio.animVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET"); 29 30 shouldBe("rootSVGElement.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN"); 31 shouldBe("rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET"); 29 32 } 30 33 … … 32 35 shouldBe("rootSVGElement.preserveAspectRatio.animVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN"); 33 36 shouldBe("rootSVGElement.preserveAspectRatio.animVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET"); 37 38 shouldBe("rootSVGElement.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN"); 39 shouldBe("rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET"); 34 40 } 35 41 … … 37 43 shouldBe("rootSVGElement.preserveAspectRatio.animVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID"); 38 44 shouldBe("rootSVGElement.preserveAspectRatio.animVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE"); 45 46 shouldBe("rootSVGElement.preserveAspectRatio.baseVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN"); 47 shouldBe("rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET"); 39 48 } 40 49 -
trunk/LayoutTests/svg/animations/svgPreserveAspectRatio-animation-1-expected.txt
r89833 r112391 8 8 PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN 9 9 PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET 10 PASS rootSVGElement.preserveAspectRatio.baseVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN 11 PASS rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET 10 12 PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN 11 13 PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET 14 PASS rootSVGElement.preserveAspectRatio.baseVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN 15 PASS rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET 12 16 PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID 13 17 PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE 18 PASS rootSVGElement.preserveAspectRatio.baseVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN 19 PASS rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET 14 20 PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN 15 21 PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET 22 PASS rootSVGElement.preserveAspectRatio.baseVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN 23 PASS rootSVGElement.preserveAspectRatio.baseVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET 16 24 PASS successfullyParsed is true 17 25 -
trunk/LayoutTests/svg/dom/preserve-aspect-ratio-parser-expected.txt
r19121 r112391 311 311 312 312 Test string: 'slice' 313 PASS imageElement.preserveAspectRatio.baseVal.align is 1314 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1315 316 Strings that fail to parse, and hence parse as "none".313 PASS imageElement.preserveAspectRatio.baseVal.align is 0 314 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0 315 316 Strings that fail to parse, and hence parse as unknown 317 317 318 318 Test string: '' 319 PASS imageElement.preserveAspectRatio.baseVal.align is 1320 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1319 PASS imageElement.preserveAspectRatio.baseVal.align is 0 320 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0 321 321 322 322 Test string: 'defer' 323 PASS imageElement.preserveAspectRatio.baseVal.align is 1324 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1323 PASS imageElement.preserveAspectRatio.baseVal.align is 0 324 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0 325 325 326 326 Test string: 'meet' 327 PASS imageElement.preserveAspectRatio.baseVal.align is 1328 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1327 PASS imageElement.preserveAspectRatio.baseVal.align is 0 328 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0 329 329 330 330 Test string: 'slice' 331 PASS imageElement.preserveAspectRatio.baseVal.align is 1332 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1331 PASS imageElement.preserveAspectRatio.baseVal.align is 0 332 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0 333 333 334 334 Test string: 'xminymin' 335 PASS imageElement.preserveAspectRatio.baseVal.align is 1336 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1335 PASS imageElement.preserveAspectRatio.baseVal.align is 0 336 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0 337 337 338 338 Test string: 'refer xMinYMin slice' 339 PASS imageElement.preserveAspectRatio.baseVal.align is 1340 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1339 PASS imageElement.preserveAspectRatio.baseVal.align is 0 340 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0 341 341 342 342 Test string: 'xMinYMin defer' 343 PASS imageElement.preserveAspectRatio.baseVal.align is 1344 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1343 PASS imageElement.preserveAspectRatio.baseVal.align is 0 344 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0 345 345 346 346 Test string: 'slice xMinYMin' 347 PASS imageElement.preserveAspectRatio.baseVal.align is 1348 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1347 PASS imageElement.preserveAspectRatio.baseVal.align is 0 348 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0 349 349 350 350 Test string: 'xMinYMin ' 351 PASS imageElement.preserveAspectRatio.baseVal.align is 1352 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 1351 PASS imageElement.preserveAspectRatio.baseVal.align is 0 352 PASS imageElement.preserveAspectRatio.baseVal.meetOrSlice is 0 353 353 354 354 PASS successfullyParsed is true -
trunk/LayoutTests/svg/dom/preserve-aspect-ratio-parser.html
r99258 r112391 113 113 114 114 parsePreserveAspectRatio("xMinYMin", 2, 1); 115 parsePreserveAspectRatio("slice", 1, 1);115 parsePreserveAspectRatio("slice", 0, 0); 116 116 117 debug('Strings that fail to parse, and hence parse as "none".');117 debug('Strings that fail to parse, and hence parse as unknown'); 118 118 debug(''); 119 119 120 parsePreserveAspectRatio("", 1, 1);121 parsePreserveAspectRatio("defer", 1, 1);122 parsePreserveAspectRatio("meet", 1, 1);123 parsePreserveAspectRatio("slice", 1, 1);124 parsePreserveAspectRatio("xminymin", 1, 1);125 parsePreserveAspectRatio("refer xMinYMin slice", 1, 1);126 parsePreserveAspectRatio("xMinYMin defer", 1, 1);127 parsePreserveAspectRatio("slice xMinYMin", 1, 1);128 parsePreserveAspectRatio("xMinYMin" + String.fromCharCode(0xa0), 1, 1);120 parsePreserveAspectRatio("", 0, 0); 121 parsePreserveAspectRatio("defer", 0, 0); 122 parsePreserveAspectRatio("meet", 0, 0); 123 parsePreserveAspectRatio("slice", 0, 0); 124 parsePreserveAspectRatio("xminymin", 0, 0); 125 parsePreserveAspectRatio("refer xMinYMin slice", 0, 0); 126 parsePreserveAspectRatio("xMinYMin defer", 0, 0); 127 parsePreserveAspectRatio("slice xMinYMin", 0, 0); 128 parsePreserveAspectRatio("xMinYMin" + String.fromCharCode(0xa0), 0, 0); 129 129 130 130 -
trunk/Source/WebCore/ChangeLog
r112390 r112391 1 2012-03-27 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Enable animVal support for SVGAnimatedPreserveAspectRatio 4 https://bugs.webkit.org/show_bug.cgi?id=82326 5 6 Reviewed by Zoltan Herczeg. 7 8 Enable animVal support for SVGAnimatedPreserveAspectRatio. Very simple now that everything is prepared. 9 All we have to do is add startAnimValAnimation/etc. methods to SVGAnimatedPreserveAspectRatioAnimator. 10 11 Modernize SVGPreserveAspectRatio, align parsing this object from String, with the other SVG DOM primitives, 12 who supply a "void parse(const String&)" method, for this task. 13 14 Extended existing tests to cover this. 15 16 * svg/SVGAnimatedPreserveAspectRatio.cpp: 17 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::constructFromString): 18 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::startAnimValAnimation): 19 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::stopAnimValAnimation): 20 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::resetAnimValToBaseVal): 21 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::animValWillChange): 22 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::animValDidChange): 23 * svg/SVGAnimatedPreserveAspectRatio.h: 24 (SVGAnimatedPreserveAspectRatioAnimator): 25 * svg/SVGAnimatedType.cpp: 26 (WebCore::SVGAnimatedType::valueAsString): 27 (WebCore::SVGAnimatedType::setValueAsString): 28 (WebCore::SVGAnimatedType::supportsAnimVal): 29 * svg/SVGFEImageElement.cpp: 30 (WebCore::SVGFEImageElement::parseAttribute): 31 * svg/SVGFitToViewBox.cpp: 32 (WebCore::SVGFitToViewBox::parseAttribute): 33 * svg/SVGImageElement.cpp: 34 (WebCore::SVGImageElement::parseAttribute): 35 * svg/SVGPreserveAspectRatio.cpp: 36 (WebCore::SVGPreserveAspectRatio::parse): 37 (WebCore): 38 * svg/SVGPreserveAspectRatio.h: 39 (SVGPreserveAspectRatio): 40 * svg/SVGViewSpec.cpp: 41 (WebCore::SVGViewSpec::setPreserveAspectRatioString): 42 (WebCore::SVGViewSpec::parseViewSpec): 43 1 44 2012-03-28 Pavel Feldman <pfeldman@chromium.org> 2 45 -
trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp
r95901 r112391 35 35 { 36 36 OwnPtr<SVGAnimatedType> animatedType = SVGAnimatedType::createPreserveAspectRatio(new SVGPreserveAspectRatio); 37 SVGPreserveAspectRatio::parsePreserveAspectRatio(animatedType.get(),string);37 animatedType->preserveAspectRatio().parse(string); 38 38 return animatedType.release(); 39 } 40 41 PassOwnPtr<SVGAnimatedType> SVGAnimatedPreserveAspectRatioAnimator::startAnimValAnimation(const Vector<SVGAnimatedProperty*>& properties) 42 { 43 return SVGAnimatedType::createPreserveAspectRatio(constructFromOneBaseValue<SVGPreserveAspectRatio, SVGAnimatedPreserveAspectRatio>(properties)); 44 } 45 46 void SVGAnimatedPreserveAspectRatioAnimator::stopAnimValAnimation(const Vector<SVGAnimatedProperty*>& properties) 47 { 48 SVGAnimatedTypeAnimator::stopAnimValAnimationForType<SVGAnimatedPreserveAspectRatio>(properties); 49 } 50 51 void SVGAnimatedPreserveAspectRatioAnimator::resetAnimValToBaseVal(const Vector<SVGAnimatedProperty*>& properties, SVGAnimatedType* type) 52 { 53 resetFromOneBaseValue<SVGPreserveAspectRatio, SVGAnimatedPreserveAspectRatio>(properties, type, &SVGAnimatedType::preserveAspectRatio); 54 } 55 56 void SVGAnimatedPreserveAspectRatioAnimator::animValWillChange(const Vector<SVGAnimatedProperty*>& properties) 57 { 58 animValWillChangeForType<SVGAnimatedPreserveAspectRatio>(properties); 59 } 60 61 void SVGAnimatedPreserveAspectRatioAnimator::animValDidChange(const Vector<SVGAnimatedProperty*>& properties) 62 { 63 animValDidChangeForType<SVGAnimatedPreserveAspectRatio>(properties); 39 64 } 40 65 -
trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h
r95901 r112391 46 46 47 47 virtual PassOwnPtr<SVGAnimatedType> constructFromString(const String&); 48 48 virtual PassOwnPtr<SVGAnimatedType> startAnimValAnimation(const Vector<SVGAnimatedProperty*>&); 49 virtual void stopAnimValAnimation(const Vector<SVGAnimatedProperty*>&); 50 virtual void resetAnimValToBaseVal(const Vector<SVGAnimatedProperty*>&, SVGAnimatedType*); 51 virtual void animValWillChange(const Vector<SVGAnimatedProperty*>&); 52 virtual void animValDidChange(const Vector<SVGAnimatedProperty*>&); 53 49 54 virtual void calculateFromAndToValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& toString); 50 55 virtual void calculateFromAndByValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& byString); -
trunk/Source/WebCore/svg/SVGAnimatedType.cpp
r112247 r112391 341 341 ASSERT(m_data.color); 342 342 return m_data.color->serialized(); 343 case AnimatedEnumeration: 344 // FIXME: AnimatedEnumeration is left todo. 345 ASSERT_NOT_REACHED(); 346 break; 343 347 case AnimatedInteger: 344 348 ASSERT(m_data.integer); … … 384 388 ASSERT(m_data.transformList); 385 389 return m_data.transformList->valueAsString(); 386 case AnimatedEnumeration:387 // FIXME: AnimatedEnumeration is left todo.388 ASSERT_NOT_REACHED();389 break;390 390 case AnimatedUnknown: 391 391 break; … … 432 432 pointsListFromSVGData(*m_data.pointList, value); 433 433 break; 434 case AnimatedPreserveAspectRatio:435 ASSERT(m_data.preserveAspectRatio);436 SVGPreserveAspectRatio::parsePreserveAspectRatio(this, value);437 break;438 434 case AnimatedRect: 439 435 ASSERT(m_data.rect); … … 448 444 case AnimatedAngle: 449 445 case AnimatedBoolean: 446 case AnimatedInteger: 447 case AnimatedIntegerOptionalInteger: 450 448 case AnimatedNumberList: 451 449 case AnimatedNumberOptionalNumber: 452 case AnimatedInteger: 453 case AnimatedIntegerOptionalInteger: 450 case AnimatedPreserveAspectRatio: 454 451 case AnimatedTransformList: 455 452 case AnimatedUnknown: … … 469 466 bool SVGAnimatedType::supportsAnimVal(AnimatedPropertyType type) 470 467 { 471 // FIXME: This lists the current state of our animVal support.472 468 switch (type) { 473 469 case AnimatedAngle: … … 480 476 case AnimatedNumberList: 481 477 case AnimatedNumberOptionalNumber: 478 case AnimatedPreserveAspectRatio: 482 479 case AnimatedRect: 483 480 case AnimatedString: 484 481 case AnimatedTransformList: 485 482 return true; 483 484 // Types only used for CSS property animations. 486 485 case AnimatedColor: 486 return false; 487 488 // FIXME: Handle the remaining types in animVal concept. 487 489 case AnimatedEnumeration: 488 490 case AnimatedPath: 489 491 case AnimatedPoints: 490 case AnimatedPreserveAspectRatio:491 492 case AnimatedUnknown: 492 493 return false; -
trunk/Source/WebCore/svg/SVGFEImageElement.cpp
r107067 r112391 134 134 } 135 135 136 const AtomicString& value = attr->value();137 136 if (attr->name() == SVGNames::preserveAspectRatioAttr) { 138 SVGPreserveAspectRatio::parsePreserveAspectRatio(this, value); 137 SVGPreserveAspectRatio preserveAspectRatio; 138 preserveAspectRatio.parse(attr->value()); 139 setPreserveAspectRatioBaseValue(preserveAspectRatio); 139 140 return; 140 141 } -
trunk/Source/WebCore/svg/SVGFitToViewBox.cpp
r106769 r112391 98 98 return true; 99 99 } else if (attr->name() == SVGNames::preserveAspectRatioAttr) { 100 SVGPreserveAspectRatio::parsePreserveAspectRatio(this, attr->value()); 100 SVGPreserveAspectRatio preserveAspectRatio; 101 preserveAspectRatio.parse(attr->value()); 102 setPreserveAspectRatioBaseValue(preserveAspectRatio); 101 103 return true; 102 104 } -
trunk/Source/WebCore/svg/SVGImageElement.cpp
r112215 r112391 119 119 else if (attr->name() == SVGNames::yAttr) 120 120 setYBaseValue(SVGLength::construct(LengthModeHeight, attr->value(), parseError)); 121 else if (attr->name() == SVGNames::preserveAspectRatioAttr) 122 SVGPreserveAspectRatio::parsePreserveAspectRatio(this, attr->value()); 123 else if (attr->name() == SVGNames::widthAttr) 121 else if (attr->name() == SVGNames::preserveAspectRatioAttr) { 122 SVGPreserveAspectRatio preserveAspectRatio; 123 preserveAspectRatio.parse(attr->value()); 124 setPreserveAspectRatioBaseValue(preserveAspectRatio); 125 } else if (attr->name() == SVGNames::widthAttr) 124 126 setWidthBaseValue(SVGLength::construct(LengthModeWidth, attr->value(), parseError, ForbidNegativeLengths)); 125 127 else if (attr->name() == SVGNames::heightAttr) -
trunk/Source/WebCore/svg/SVGPreserveAspectRatio.cpp
r105575 r112391 59 59 } 60 60 61 SVGPreserveAspectRatio SVGPreserveAspectRatio::parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result) 62 { 63 SVGPreserveAspectRatio aspectRatio; 64 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_NONE; 65 aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET; 66 result = false; 61 void SVGPreserveAspectRatio::parse(const String& value) 62 { 63 const UChar* begin = value.characters(); 64 parse(begin, begin + value.length(), true); 65 } 66 67 bool SVGPreserveAspectRatio::parse(const UChar*& currParam, const UChar* end, bool validate) 68 { 69 m_align = SVG_PRESERVEASPECTRATIO_NONE; 70 m_meetOrSlice = SVG_MEETORSLICE_MEET; 67 71 68 72 // FIXME: Rewrite this parser, without gotos! … … 91 95 if (currParam[6] == 'i') { 92 96 if (currParam[7] == 'n') 93 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMIN;97 m_align = SVG_PRESERVEASPECTRATIO_XMINYMIN; 94 98 else if (currParam[7] == 'd') 95 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMID;99 m_align = SVG_PRESERVEASPECTRATIO_XMINYMID; 96 100 else 97 101 goto bailOut; 98 102 } else if (currParam[6] == 'a' && currParam[7] == 'x') 99 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMINYMAX;103 m_align = SVG_PRESERVEASPECTRATIO_XMINYMAX; 100 104 else 101 105 goto bailOut; … … 103 107 if (currParam[6] == 'i') { 104 108 if (currParam[7] == 'n') 105 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;109 m_align = SVG_PRESERVEASPECTRATIO_XMIDYMIN; 106 110 else if (currParam[7] == 'd') 107 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMID;111 m_align = SVG_PRESERVEASPECTRATIO_XMIDYMID; 108 112 else 109 113 goto bailOut; 110 114 } else if (currParam[6] == 'a' && currParam[7] == 'x') 111 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;115 m_align = SVG_PRESERVEASPECTRATIO_XMIDYMAX; 112 116 else 113 117 goto bailOut; … … 117 121 if (currParam[6] == 'i') { 118 122 if (currParam[7] == 'n') 119 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;123 m_align = SVG_PRESERVEASPECTRATIO_XMAXYMIN; 120 124 else if (currParam[7] == 'd') 121 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMID;125 m_align = SVG_PRESERVEASPECTRATIO_XMAXYMID; 122 126 else 123 127 goto bailOut; 124 128 } else if (currParam[6] == 'a' && currParam[7] == 'x') 125 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;129 m_align = SVG_PRESERVEASPECTRATIO_XMAXYMAX; 126 130 else 127 131 goto bailOut; … … 142 146 goto bailOut; 143 147 skipOptionalSVGSpaces(currParam, end); 144 if ( aspectRatio.m_align != SVG_PRESERVEASPECTRATIO_NONE)145 aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_SLICE;148 if (m_align != SVG_PRESERVEASPECTRATIO_NONE) 149 m_meetOrSlice = SVG_MEETORSLICE_SLICE; 146 150 } 147 151 } … … 149 153 if (end != currParam && validate) { 150 154 bailOut: 151 // FIXME: Should the two values be set to UNKNOWN instead? 152 aspectRatio.m_align = SVG_PRESERVEASPECTRATIO_NONE; 153 aspectRatio.m_meetOrSlice = SVG_MEETORSLICE_MEET; 154 } else 155 result = true; 156 157 return aspectRatio; 155 m_align = SVG_PRESERVEASPECTRATIO_UNKNOWN; 156 m_meetOrSlice = SVG_MEETORSLICE_UNKNOWN; 157 return false; 158 } 159 return true; 158 160 } 159 161 -
trunk/Source/WebCore/svg/SVGPreserveAspectRatio.h
r99645 r112391 68 68 float physWidth, float physHeight) const; 69 69 70 template<class Consumer> 71 static bool parsePreserveAspectRatio(Consumer* consumer, const String& value, bool validate = true) 72 { 73 bool result = false; 74 const UChar* begin = value.characters(); 75 const UChar* end = begin + value.length(); 76 consumer->setPreserveAspectRatioBaseValue(parsePreserveAspectRatio(begin, end, validate, result)); 77 return result; 78 } 79 80 // It's recommended to use the method above, only SVGViewSpec needs this parsing method 81 static SVGPreserveAspectRatio parsePreserveAspectRatio(const UChar*& currParam, const UChar* end, bool validate, bool& result); 70 void parse(const String&); 71 bool parse(const UChar*& currParam, const UChar* end, bool validate); 82 72 83 73 String valueAsString() const; -
trunk/Source/WebCore/svg/SVGViewSpec.cpp
r110838 r112391 64 64 void SVGViewSpec::setPreserveAspectRatioString(const String& preserve) 65 65 { 66 SVGPreserveAspectRatio::parsePreserveAspectRatio(this, preserve); 66 SVGPreserveAspectRatio preserveAspectRatio; 67 preserveAspectRatio.parse(preserve); 68 setPreserveAspectRatioBaseValue(preserveAspectRatio); 67 69 } 68 70 … … 141 143 return false; 142 144 currViewSpec++; 143 bool result = false; 144 setPreserveAspectRatioBaseValue(SVGPreserveAspectRatio::parsePreserveAspectRatio(currViewSpec, end, false, result)); 145 if (!result) 145 SVGPreserveAspectRatio preserveAspectRatio; 146 if (!preserveAspectRatio.parse(currViewSpec, end, false)) 146 147 return false; 148 setPreserveAspectRatioBaseValue(preserveAspectRatio); 147 149 if (currViewSpec >= end || *currViewSpec != ')') 148 150 return false;
Note: See TracChangeset
for help on using the changeset viewer.