Changeset 207716 in webkit
- Timestamp:
- Oct 22, 2016, 1:56:47 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 81 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207715 r207716 1 2016-10-22 Darin Adler <darin@apple.com> 2 3 Move SVG from ExceptionCode to Exception 4 https://bugs.webkit.org/show_bug.cgi?id=163837 5 6 Reviewed by Chris Dumez. 7 8 * WebCore.xcodeproj/project.pbxproj: Added SVGGraphicsElement.idl. 9 10 * bindings/js/JSSVGLengthCustom.cpp: 11 (WebCore::JSSVGLength::value): Use toJSNumber. 12 (WebCore::JSSVGLength::setValue): Use propagateException. 13 (WebCore::JSSVGLength::convertToSpecifiedUnits): Ditto. 14 15 * bindings/scripts/CodeGeneratorJS.pm: 16 (GenerateImplementation): Properly handle SetterMayThrowException 17 in the special case for SVG setters. 18 19 * rendering/style/SVGRenderStyle.h: 20 (WebCore::SVGRenderStyle::initialBaselineShiftValue): Removed 21 ASSERT_NO_EXCEPTION, no longer needed. 22 (WebCore::SVGRenderStyle::initialKerning): Ditto. 23 24 * svg/SVGAltGlyphElement.cpp: 25 (WebCore::SVGAltGlyphElement::setGlyphRef): Use ExceptionOr. 26 (WebCore::SVGAltGlyphElement::setFormat): Ditto. 27 (WebCore::SVGAltGlyphElement::hasValidGlyphElements): Tweaked a bit. 28 * svg/SVGAltGlyphElement.h: Updated for above changes. 29 * svg/SVGAltGlyphElement.idl: Use non-legacy exceptions. 30 31 * svg/SVGAngle.cpp: 32 (WebCore::SVGAngle::valueAsString): Removed unneeded String globals. 33 (WebCore::parseAngleType): Rewrote to be simpler and more direct. 34 (WebCore::SVGAngle::setValueAsString): Use ExceptionOr. 35 (WebCore::SVGAngle::newValueSpecifiedUnits): Ditto. 36 (WebCore::SVGAngle::convertToSpecifiedUnits): Ditto. 37 * svg/SVGAngle.h: Updated for above changes. Initialized data members 38 here in the class definite and removed constructor; default now works. 39 * svg/SVGAngle.idl: Use non-legacy exceptions. 40 41 * svg/SVGAnimateElementBase.cpp: 42 (WebCore::SVGAnimateElementBase::calculateAnimatedValue): Update since 43 CalcMode is now an enum class. 44 * svg/SVGAnimateMotionElement.cpp: 45 (WebCore::SVGAnimateMotionElement::SVGAnimateMotionElement): Ditto. 46 47 * svg/SVGAnimateTransformElement.cpp: 48 (WebCore::SVGAnimateTransformElement::hasValidAttributeType): Update 49 since AttributeType is now an enum class. 50 51 * svg/SVGAnimatedAngle.cpp: 52 (WebCore::SVGAnimatedAngleAnimator::calculateDistance): Removed 53 ASSERT_NO_EXCEPTION, no longer needed. 54 55 * svg/SVGAnimatedBoolean.idl: Use non-legacy exception. 56 * svg/SVGAnimatedEnumeration.idl: Ditto. 57 * svg/SVGAnimatedInteger.idl: Ditto. 58 59 * svg/SVGAnimatedLength.cpp: 60 (WebCore::sharedSVGLength): Deleted. 61 (WebCore::SVGAnimatedLengthAnimator::addAnimatedTypes): Removed 62 ASSERT_NO_EXCEPTION, no longer needed. 63 (WebCore::parseLengthFromString): Ditto. Also rewrote to not use 64 a shared SVGLength; no benefit to doing that. 65 (WebCore::SVGAnimatedLengthAnimator::calculateAnimatedValue): Ditto. 66 * svg/SVGAnimatedLengthList.cpp: 67 (WebCore::SVGAnimatedLengthListAnimator::addAnimatedTypes): Ditto. 68 (WebCore::SVGAnimatedLengthListAnimator::calculateAnimatedValue): Ditto. 69 70 * svg/SVGAnimatedNumber.idl: Use non-legacy exception. 71 * svg/SVGAnimatedString.idl: Ditto. 72 73 * svg/SVGAnimatedType.cpp: 74 (WebCore::SVGAnimatedType::setValueAsString): Updated since 75 setValueAsString now uses ExceptionOr. 76 77 * svg/SVGAnimationElement.cpp: 78 (WebCore::SVGAnimationElement::SVGAnimationElement): Initialized scalars 79 in the class definition instead of here. 80 (WebCore::SVGAnimationElement::getSimpleDuration): Removed uneeded ExceptionCode&. 81 (WebCore::SVGAnimationElement::setCalcMode): Updated since CalcMode is now an enum class. 82 (WebCore::SVGAnimationElement::setAttributeType): Updated since AttributeType 83 is now an enum class. 84 (WebCore::SVGAnimationElement::shouldApplyAnimation): Ditto. 85 (WebCore::SVGAnimationElement::calculateKeyTimesForCalcModePaced): Ditto. 86 (WebCore::SVGAnimationElement::calculatePercentForSpline): Ditto. 87 (WebCore::SVGAnimationElement::calculatePercentFromKeyPoints): Ditto. 88 (WebCore::SVGAnimationElement::calculatePercentForFromTo): Ditto. 89 (WebCore::SVGAnimationElement::currentValuesFromKeyPoints): Ditto. 90 (WebCore::SVGAnimationElement::currentValuesForValuesAnimation): Ditto. 91 (WebCore::SVGAnimationElement::startedActiveInterval): Ditto. 92 (WebCore::SVGAnimationElement::updateAnimation): Ditto. 93 (WebCore::SVGAnimationElement::checkInvalidCSSAttributeType): Ditto. 94 95 * svg/SVGAnimationElement.h: Changed CalcMode into an enum class. 96 Updated for above changes. 97 98 * svg/SVGAnimationElement.idl: Removed MayThrowLegacyException from 99 getSimpleDuration. 100 101 * svg/SVGColor.cpp: 102 (WebCore::SVGColor::SVGColor): Updated to take scalar in the straightforward 103 manner instead of constt SVGColorType&. 104 (WebCore::SVGColor::setRGBColor): Use ExceptionOr. 105 (WebCore::SVGColor::setRGBColorICCColor): Ditto. 106 (WebCore::SVGColor::setColor): Ditto. 107 * svg/SVGColor.h: Updated for above changes. Removed unneeded destructor. 108 * svg/SVGColor.idl: Use non-legacy exceptions. 109 110 * svg/SVGGlyphRefElement.cpp: 111 (WebCore::SVGGlyphRefElement::SVGGlyphRefElement): Initialize data members 112 in class definition, not here. 113 (WebCore::parseFloat): Added helper. Used in parseAttribute. 114 (WebCore::SVGGlyphRefElement::parseAttribute): Updated to use parseFloat helper. 115 (WebCore::SVGGlyphRefElement::glyphRef): Deleted. 116 (WebCore::SVGGlyphRefElement::setGlyphRef): Deleted. 117 (WebCore::SVGGlyphRefElement::setX): Removed unused Exception& argument. 118 (WebCore::SVGGlyphRefElement::setY): Ditto. 119 (WebCore::SVGGlyphRefElement::setDx): Ditto. 120 (WebCore::SVGGlyphRefElement::setDy): Ditto. 121 * svg/SVGGlyphRefElement.h: Updated for above changes. 122 * svg/SVGGlyphRefElement.idl: Use Reflect on glyphRef. Removed incorrect 123 SetterMayThrowLegacyException attributes for x, y, dx, and dy. Longer term 124 it might be nice to use [Reflect] on these too. 125 126 * svg/SVGGraphicsElement.idl: Use non-legacy exception. 127 128 * svg/SVGLength.cpp: 129 (WebCore::parseLengthType): Changed argument type since caller does not 130 need to know how many characters are consumed. 131 (WebCore::SVGLength::SVGLength): Removed IGNORE_EXCEPTION and ASSERT_NO_EXCEPTION. 132 Also removed the copy constructor, letting the compiler generate the default. 133 (WebCore::SVGLength::setValueAsString): Use ExceptionOr. 134 (WebCore::SVGLength::construct): Updated since setValueAsString uses ExceptionOr. 135 (WebCore::SVGLength::value): Ditto. 136 (WebCore::SVGLength::valueForBindings): Use ExceptionOr. Also renamed to 137 disambiguate with the version used outside of bindings. 138 (WebCore::SVGLength::setValue): Use ExceptionOr. 139 (WebCore::SVGLength::newValueSpecifiedUnits): Ditto. 140 (WebCore::SVGLength::convertToSpecifiedUnits): Ditto. 141 (WebCore::SVGLength::fromCSSPrimitiveValue): Updated since newValueSpecifiedUnits 142 uses ExceptionOr. 143 (WebCore::SVGLength::lengthModeForAnimatedLengthAttribute): Rewrote map generation 144 code to be more efficient and not unrolled. Only do one hash table lookup. 145 * svg/SVGLength.h: Updated for above changes. 146 * svg/SVGLength.idl: Use non-legacy exceptions. 147 148 * svg/SVGLengthContext.cpp: 149 (WebCore::SVGLengthContext::valueForLength): Update since function 150 uses ExceptionOr. 151 (WebCore::SVGLengthContext::convertValueToUserUnits): Use ExceptionOr. 152 (WebCore::SVGLengthContext::convertValueFromUserUnits): Ditto. 153 (WebCore::SVGLengthContext::convertValueFromUserUnitsToPercentage): Ditto. 154 (WebCore::SVGLengthContext::convertValueFromPercentageToUserUnits): Ditto. 155 (WebCore::SVGLengthContext::convertValueFromUserUnitsToEMS): Ditto. 156 (WebCore::SVGLengthContext::convertValueFromEMSToUserUnits): Ditto. 157 (WebCore::SVGLengthContext::convertValueFromUserUnitsToEXS): Ditto. 158 (WebCore::SVGLengthContext::convertValueFromEXSToUserUnits): Ditto. 159 * svg/SVGLengthContext.h: Updatedfor above changes. 160 161 * svg/SVGLengthList.cpp: 162 (WebCore::SVGLengthList::parse): Updated since setValueAsString uses 163 ExceptionOr now. 164 * svg/SVGLengthList.h: Removed unneeded constructor. 165 * svg/SVGLengthList.idl: Use non-legacy exceptions. 166 167 * svg/SVGLocatable.cpp: 168 (WebCore::SVGLocatable::getTransformToElement): Use ExceptionOr. 169 * svg/SVGLocatable.h: Updated for above change. 170 171 * svg/SVGMarkerElement.h: 172 (WebCore::SVGPropertyTraits<SVGMarkerOrientType>::fromString): 173 Updated since setValueAsString uses ExceptionOr now. 174 175 * svg/SVGMatrix.h: Use ExceptionOr. 176 * svg/SVGMatrix.idl: Use non-legacy exceptions. 177 178 * svg/SVGNumberList.h: Removed unneeded constructor. 179 * svg/SVGNumberList.idl: Use non-legacy exceptions. 180 181 * svg/SVGPaint.cpp: 182 (WebCore::SVGPaint::setPaint): Use ExceptionOr. 183 * svg/SVGPaint.h: Updated for above chagne. 184 * svg/SVGPaint.idl: Use non-legacy exception. 185 186 * svg/SVGPathSegList.h: Tweaked a bit. 187 * svg/SVGPathSegList.idl: Use non-legacy exceptions. 188 189 * svg/SVGPointList.h: Removed unneeded constructor. 190 * svg/SVGPointList.idl: Use non-legacy exceptions. 191 192 * svg/SVGPreserveAspectRatio.cpp: 193 (WebCore::SVGPreserveAspectRatio::setAlign): Use ExceptionOr. 194 (WebCore::SVGPreserveAspectRatio::setMeetOrSlice): Ditto. 195 * svg/SVGPreserveAspectRatio.h: Updated for above changes. 196 * svg/SVGPreserveAspectRatio.idl: Use non-legacy exceptions. 197 198 * svg/SVGSVGElement.cpp: 199 (WebCore::SVGSVGElement::currentView): Pass a reference. 200 201 * svg/SVGStringList.h: Tweaked a bit. 202 * svg/SVGStringList.idl: Use non-legacy exceptions. 203 204 * svg/SVGStyleElement.cpp: 205 (WebCore::SVGStyleElement::setType): Removed unneeded ExceptionCode&. 206 (WebCore::SVGStyleElement::setMedia): Ditto. 207 (WebCore::SVGStyleElement::setTitle): Deleted. 208 * svg/SVGStyleElement.h: Updated for above changes, and made the title 209 function override be private. 210 * svg/SVGStyleElement.idl: Use Reflect for title. Removed unneeded 211 SetterMayThrowLegacyException on all attributes. 212 213 * svg/SVGTextContentElement.cpp: 214 (WebCore::SVGTextContentElement::textLengthAnimated): Removed 215 ASSERT_NO_EXCEPTION, won't work any more. 216 (WebCore::SVGTextContentElement::getSubStringLength): Use ExceptionOr. 217 Also remove redundant call to updateLayoutIgnorePendingStylesheets, 218 called by getNumberOfChars. 219 (WebCore::SVGTextContentElement::getStartPositionOfChar): Ditto. 220 (WebCore::SVGTextContentElement::getEndPositionOfChar): Ditto. 221 (WebCore::SVGTextContentElement::getExtentOfChar): Ditto. 222 (WebCore::SVGTextContentElement::getRotationOfChar): Ditto. 223 (WebCore::SVGTextContentElement::selectSubString): Ditto. 224 * svg/SVGTextContentElement.h: Updated for above changes. 225 * svg/SVGTextContentElement.idl: Use non-legacy exceptions. 226 227 * svg/SVGTransformList.h: Removed unneeded constructor. 228 * svg/SVGTransformList.idl: Use non-legacy exceptions. 229 230 * svg/SVGViewSpec.cpp: 231 (WebCore::SVGViewSpec::SVGViewSpec): Updated to take a reference. 232 (WebCore::SVGViewSpec::setZoomAndPan): Use ExceptionOr. 233 (WebCore::SVGViewSpec::setTransformString): Deleted. 234 (WebCore::SVGViewSpec::viewBoxString): Use m_viewBox directly. 235 (WebCore::SVGViewSpec::preserveAspectRatioString): Use 236 m_preserveAspectRatio directly. 237 (WebCore::SVGViewSpec::viewTarget): Use is<SVGElement>. 238 (WebCore::SVGViewSpec::lookupOrCreateViewBoxWrapper): Use 239 m_contextElement directly. 240 (WebCore::SVGViewSpec::lookupOrCreatePreserveAspectRatioWrapper): 241 Ditto. 242 (WebCore::SVGViewSpec::lookupOrCreateTransformWrapper): Ditto. 243 (WebCore::SVGViewSpec::parseViewSpec): Set m_viewTargetString directly. 244 * svg/SVGViewSpec.h: Updated for above changes. Removed unneeded virtual 245 destructor, unneeded using for ref/deref, unused functions including 246 setTransformString, setViewTargetString, non-exception setZoomAndPan, 247 contextElement, viewBoxBaseValue, and preserveAspectRatioBaseValue. 248 * svg/SVGViewSpec.idl: Use non-legacy exceptions. Also specify 249 ImplementationLacksVTable. 250 251 * svg/properties/SVGAnimatedEnumerationPropertyTearOff.h: 252 Use ExceptionOr. 253 * svg/properties/SVGAnimatedStaticPropertyTearOff.h: Ditto. 254 * svg/properties/SVGListProperty.h: Ditto. 255 * svg/properties/SVGListPropertyTearOff.h: Ditto. 256 * svg/properties/SVGPathSegListPropertyTearOff.cpp: 257 (WebCore::SVGPathSegListPropertyTearOff::clear): Ditto. 258 (WebCore::SVGPathSegListPropertyTearOff::getItem): Ditto. 259 (WebCore::SVGPathSegListPropertyTearOff::replaceItem): Ditto. 260 (WebCore::SVGPathSegListPropertyTearOff::removeItem): Ditto. 261 * svg/properties/SVGPathSegListPropertyTearOff.h: Ditto. 262 * svg/properties/SVGPropertyTearOff.h: Ditto. Also added an overload 263 of create that knows how to deal with exceptions. 264 * svg/properties/SVGStaticListPropertyTearOff.h: Ditto. 265 * svg/properties/SVGTransformListPropertyTearOff.h: Ditto. 266 1 267 2016-10-22 Chris Dumez <cdumez@apple.com> 2 268 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r207689 r207716 10614 10614 933A14B70B7D1D5200A53FFD /* JSTextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextEvent.h; sourceTree = "<group>"; }; 10615 10615 933C7A741C0FBC440034FB97 /* NSSpellCheckerSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSSpellCheckerSPI.h; sourceTree = "<group>"; }; 10616 934305961DB9FA0E00E712A7 /* SVGGraphicsElement.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SVGGraphicsElement.idl; sourceTree = "<group>"; }; 10616 10617 9343CB7F12F25E510033C5EE /* TextCodecUTF8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecUTF8.cpp; sourceTree = "<group>"; }; 10617 10618 9343CB8012F25E510033C5EE /* TextCodecUTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecUTF8.h; sourceTree = "<group>"; }; … … 20714 20715 B222791F0D00BF210071B782 /* SVGGraphicsElement.cpp */, 20715 20716 B22279200D00BF210071B782 /* SVGGraphicsElement.h */, 20717 934305961DB9FA0E00E712A7 /* SVGGraphicsElement.idl */, 20716 20718 650FBF270D9AF046008FC292 /* SVGHKernElement.cpp */, 20717 20719 650FBF280D9AF047008FC292 /* SVGHKernElement.h */, -
trunk/Source/WebCore/bindings/js/JSSVGLengthCustom.cpp
r206386 r207716 35 35 JSValue JSSVGLength::value(ExecState& state) const 36 36 { 37 SVGLength& podImp = wrapped().propertyReference(); 38 ExceptionCode ec = 0; 39 SVGLengthContext lengthContext(wrapped().contextElement()); 40 float value = podImp.value(lengthContext, ec); 41 if (ec) { 42 setDOMException(&state, ec); 43 return jsUndefined(); 44 } 45 46 return jsNumber(value); 37 VM& vm = state.vm(); 38 auto scope = DECLARE_THROW_SCOPE(vm); 39 return toJSNumber(state, scope, wrapped().propertyReference().valueForBindings(SVGLengthContext { wrapped().contextElement() })); 47 40 } 48 41 … … 62 55 } 63 56 64 SVGLength& podImp = wrapped().propertyReference(); 57 auto floatValue = value.toFloat(&state); 58 RETURN_IF_EXCEPTION(scope, void()); 65 59 66 ExceptionCode ec = 0; 67 SVGLengthContext lengthContext(wrapped().contextElement()); 68 podImp.setValue(value.toFloat(&state), lengthContext, ec); 69 if (ec) { 70 setDOMException(&state, ec); 60 auto result = wrapped().propertyReference().setValue(floatValue, SVGLengthContext { wrapped().contextElement() }); 61 if (result.hasException()) { 62 propagateException(state, scope, result.releaseException()); 71 63 return; 72 64 } … … 82 74 if (wrapped().isReadOnly()) { 83 75 setDOMException(&state, NO_MODIFICATION_ALLOWED_ERR); 84 return jsUndefined();76 return { }; 85 77 } 86 87 SVGLength& podImp = wrapped().propertyReference();88 78 89 79 if (state.argumentCount() < 1) … … 93 83 RETURN_IF_EXCEPTION(scope, JSValue()); 94 84 95 ExceptionCode ec = 0; 96 SVGLengthContext lengthContext(wrapped().contextElement()); 97 podImp.convertToSpecifiedUnits(unitType, lengthContext, ec); 98 if (ec) { 99 setDOMException(&state, ec); 100 return jsUndefined(); 85 auto result = wrapped().propertyReference().convertToSpecifiedUnits(unitType, SVGLengthContext { wrapped().contextElement() }); 86 if (result.hasException()) { 87 propagateException(state, scope, result.releaseException()); 88 return { }; 101 89 } 102 90 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r207715 r207716 3539 3539 push(@implContent, " podImpl = nativeValue;\n"); 3540 3540 } else { 3541 push(@implContent, " podImpl.set$implSetterFunctionName(nativeValue"); 3542 push(@implContent, ", ec") if $setterMayThrowLegacyException; 3543 push(@implContent, ");\n"); 3541 my $functionString = "podImpl.set$implSetterFunctionName(nativeValue"; 3542 $functionString .= ", ec" if $setterMayThrowLegacyException; 3543 $functionString .= ")"; 3544 $functionString = "propagateException(state, throwScope, $functionString)" if $attribute->signature->extendedAttributes->{SetterMayThrowException}; 3545 push(@implContent, " $functionString;\n"); 3544 3546 push(@implContent, " setDOMException(&state, throwScope, ec);\n") if $setterMayThrowLegacyException; 3545 3547 } -
trunk/Source/WebCore/rendering/style/SVGRenderStyle.h
r194496 r207716 101 101 { 102 102 SVGLength length; 103 length.newValueSpecifiedUnits(LengthTypeNumber, 0 , ASSERT_NO_EXCEPTION);103 length.newValueSpecifiedUnits(LengthTypeNumber, 0); 104 104 return length; 105 105 } … … 108 108 { 109 109 SVGLength length; 110 length.newValueSpecifiedUnits(LengthTypeNumber, 0 , ASSERT_NO_EXCEPTION);110 length.newValueSpecifiedUnits(LengthTypeNumber, 0); 111 111 return length; 112 112 } -
trunk/Source/WebCore/svg/SVGAltGlyphElement.cpp
r203324 r207716 56 56 } 57 57 58 void SVGAltGlyphElement::setGlyphRef(const AtomicString&, ExceptionCode& ec)58 ExceptionOr<void> SVGAltGlyphElement::setGlyphRef(const AtomicString&) 59 59 { 60 ec = NO_MODIFICATION_ALLOWED_ERR;60 return Exception { NO_MODIFICATION_ALLOWED_ERR }; 61 61 } 62 62 … … 66 66 } 67 67 68 void SVGAltGlyphElement::setFormat(const AtomicString&, ExceptionCode& ec)68 ExceptionOr<void> SVGAltGlyphElement::setFormat(const AtomicString&) 69 69 { 70 ec = NO_MODIFICATION_ALLOWED_ERR;70 return Exception { NO_MODIFICATION_ALLOWED_ERR }; 71 71 } 72 72 … … 78 78 bool SVGAltGlyphElement::childShouldCreateRenderer(const Node& child) const 79 79 { 80 if (child.isTextNode()) 81 return true; 82 return false; 80 return child.isTextNode(); 83 81 } 84 82 … … 91 89 { 92 90 String target; 93 Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), document(), &target); 94 if (!element) 95 return false; 91 auto* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), document(), &target); 96 92 97 if (is<SVGGlyphElement>( *element)) {93 if (is<SVGGlyphElement>(element)) { 98 94 glyphNames.append(target); 99 95 return true; 100 96 } 101 97 102 if (is<SVGAltGlyphDefElement>(*element) 103 && downcast<SVGAltGlyphDefElement>(*element).hasValidGlyphElements(glyphNames)) 98 if (is<SVGAltGlyphDefElement>(element) && downcast<SVGAltGlyphDefElement>(*element).hasValidGlyphElements(glyphNames)) 104 99 return true; 105 100 -
trunk/Source/WebCore/svg/SVGAltGlyphElement.h
r200041 r207716 20 20 */ 21 21 22 #ifndef SVGAltGlyphElement_h 23 #define SVGAltGlyphElement_h 22 #pragma once 24 23 25 24 #if ENABLE(SVG_FONTS) … … 27 26 #include "SVGTextPositioningElement.h" 28 27 #include "SVGURIReference.h" 29 #include <wtf/Vector.h>30 28 31 29 namespace WebCore { … … 33 31 class SVGGlyphElement; 34 32 35 class SVGAltGlyphElement final : public SVGTextPositioningElement, 36 public SVGURIReference { 33 class SVGAltGlyphElement final : public SVGTextPositioningElement, public SVGURIReference { 37 34 public: 38 35 static Ref<SVGAltGlyphElement> create(const QualifiedName&, Document&); 39 36 40 37 const AtomicString& glyphRef() const; 41 void setGlyphRef(const AtomicString&, ExceptionCode&);38 ExceptionOr<void> setGlyphRef(const AtomicString&); 42 39 const AtomicString& format() const; 43 void setFormat(const AtomicString&, ExceptionCode&);40 ExceptionOr<void> setFormat(const AtomicString&); 44 41 45 42 bool hasValidGlyphElements(Vector<String>& glyphNames) const; … … 59 56 60 57 #endif 61 #endif -
trunk/Source/WebCore/svg/SVGAltGlyphElement.idl
r206723 r207716 27 27 Conditional=SVG_FONTS, 28 28 ] interface SVGAltGlyphElement : SVGTextPositioningElement { 29 [SetterMayThrow LegacyException] attribute DOMString glyphRef;30 [SetterMayThrow LegacyException] attribute DOMString format;29 [SetterMayThrowException] attribute DOMString glyphRef; 30 [SetterMayThrowException] attribute DOMString format; 31 31 }; 32 32 -
trunk/Source/WebCore/svg/SVGAngle.cpp
r194819 r207716 26 26 #include "SVGParserUtilities.h" 27 27 #include <wtf/MathExtras.h> 28 #include <wtf/NeverDestroyed.h>29 28 #include <wtf/text/StringView.h> 30 29 31 30 namespace WebCore { 32 31 33 SVGAngle::SVGAngle()34 : m_unitType(SVG_ANGLETYPE_UNSPECIFIED)35 , m_valueInSpecifiedUnits(0)36 {37 }38 39 32 float SVGAngle::value() const 40 33 { … … 49 42 return m_valueInSpecifiedUnits; 50 43 } 51 52 44 ASSERT_NOT_REACHED(); 53 45 return 0; … … 59 51 case SVG_ANGLETYPE_GRAD: 60 52 m_valueInSpecifiedUnits = deg2grad(value); 61 break;53 return; 62 54 case SVG_ANGLETYPE_RAD: 63 55 m_valueInSpecifiedUnits = deg2rad(value); 64 break;56 return; 65 57 case SVG_ANGLETYPE_UNSPECIFIED: 66 58 case SVG_ANGLETYPE_UNKNOWN: 67 59 case SVG_ANGLETYPE_DEG: 68 60 m_valueInSpecifiedUnits = value; 69 break; 70 } 71 } 72 73 inline SVGAngle::SVGAngleType stringToAngleType(const UChar*& ptr, const UChar* end) 74 { 75 // If there's no unit given, the angle type is unspecified. 76 if (ptr == end) 77 return SVGAngle::SVG_ANGLETYPE_UNSPECIFIED; 78 79 const UChar firstChar = *ptr; 80 81 // If the unit contains only one character, the angle type is unknown. 82 ++ptr; 83 if (ptr == end) 84 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; 85 86 const UChar secondChar = *ptr; 87 88 // If the unit contains only two characters, the angle type is unknown. 89 ++ptr; 90 if (ptr == end) 91 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; 92 93 const UChar thirdChar = *ptr; 94 if (firstChar == 'd' && secondChar == 'e' && thirdChar == 'g') 95 return SVGAngle::SVG_ANGLETYPE_DEG; 96 if (firstChar == 'r' && secondChar == 'a' && thirdChar == 'd') 97 return SVGAngle::SVG_ANGLETYPE_RAD; 98 99 // If the unit contains three characters, but is not deg or rad, then it's unknown. 100 ++ptr; 101 if (ptr == end) 102 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; 103 104 const UChar fourthChar = *ptr; 105 106 if (firstChar == 'g' && secondChar == 'r' && thirdChar == 'a' && fourthChar == 'd') 107 return SVGAngle::SVG_ANGLETYPE_GRAD; 108 109 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; 61 return; 62 } 63 ASSERT_NOT_REACHED(); 110 64 } 111 65 … … 113 67 { 114 68 switch (m_unitType) { 115 case SVG_ANGLETYPE_DEG: { 116 static NeverDestroyed<String> degString(ASCIILiteral("deg")); 117 return String::number(m_valueInSpecifiedUnits) + degString.get(); 118 } 119 case SVG_ANGLETYPE_RAD: { 120 static NeverDestroyed<String> radString(ASCIILiteral("rad")); 121 return String::number(m_valueInSpecifiedUnits) + radString.get(); 122 } 123 case SVG_ANGLETYPE_GRAD: { 124 static NeverDestroyed<String> gradString(ASCIILiteral("grad")); 125 return String::number(m_valueInSpecifiedUnits) + gradString.get(); 126 } 69 case SVG_ANGLETYPE_DEG: 70 return String::number(m_valueInSpecifiedUnits) + "deg"; 71 case SVG_ANGLETYPE_RAD: 72 return String::number(m_valueInSpecifiedUnits) + "rad"; 73 case SVG_ANGLETYPE_GRAD: 74 return String::number(m_valueInSpecifiedUnits) + "grad"; 127 75 case SVG_ANGLETYPE_UNSPECIFIED: 128 76 case SVG_ANGLETYPE_UNKNOWN: … … 134 82 } 135 83 136 void SVGAngle::setValueAsString(const String& value, ExceptionCode& ec) 84 static inline SVGAngle::SVGAngleType parseAngleType(const UChar* ptr, const UChar* end) 85 { 86 switch (end - ptr) { 87 case 0: 88 return SVGAngle::SVG_ANGLETYPE_UNSPECIFIED; 89 case 3: 90 if (ptr[0] == 'd' && ptr[1] == 'e' && ptr[2] == 'g') 91 return SVGAngle::SVG_ANGLETYPE_DEG; 92 if (ptr[0] == 'r' && ptr[1] == 'a' && ptr[2] == 'd') 93 return SVGAngle::SVG_ANGLETYPE_RAD; 94 break; 95 case 4: 96 if (ptr[0] == 'g' && ptr[1] == 'r' && ptr[2] == 'a' && ptr[3] == 'd') 97 return SVGAngle::SVG_ANGLETYPE_GRAD; 98 break; 99 } 100 return SVGAngle::SVG_ANGLETYPE_UNKNOWN; 101 } 102 103 ExceptionOr<void> SVGAngle::setValueAsString(const String& value) 137 104 { 138 105 if (value.isEmpty()) { 139 106 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; 140 return; 141 } 142 143 float valueInSpecifiedUnits = 0; 107 return { }; 108 } 109 144 110 auto upconvertedCharacters = StringView(value).upconvertedCharacters(); 145 111 const UChar* ptr = upconvertedCharacters; 146 112 const UChar* end = ptr + value.length(); 147 113 148 if (!parseNumber(ptr, end, valueInSpecifiedUnits, false)) { 149 ec = SYNTAX_ERR; 150 return; 151 } 152 153 SVGAngleType unitType = stringToAngleType(ptr, end); 154 if (unitType == SVG_ANGLETYPE_UNKNOWN) { 155 ec = SYNTAX_ERR; 156 return; 157 } 114 float valueInSpecifiedUnits = 0; 115 if (!parseNumber(ptr, end, valueInSpecifiedUnits, false)) 116 return Exception { SYNTAX_ERR }; 117 118 auto unitType = parseAngleType(ptr, end); 119 if (unitType == SVG_ANGLETYPE_UNKNOWN) 120 return Exception { SYNTAX_ERR }; 158 121 159 122 m_unitType = unitType; 160 123 m_valueInSpecifiedUnits = valueInSpecifiedUnits; 161 } 162 163 void SVGAngle::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits, ExceptionCode& ec) 164 { 165 if (unitType == SVG_ANGLETYPE_UNKNOWN || unitType > SVG_ANGLETYPE_GRAD) { 166 ec = NOT_SUPPORTED_ERR; 167 return; 168 } 169 170 if (unitType != m_unitType) 171 m_unitType = static_cast<SVGAngleType>(unitType); 172 124 return { }; 125 } 126 127 ExceptionOr<void> SVGAngle::newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits) 128 { 129 if (unitType == SVG_ANGLETYPE_UNKNOWN || unitType > SVG_ANGLETYPE_GRAD) 130 return Exception { NOT_SUPPORTED_ERR }; 131 132 m_unitType = static_cast<SVGAngleType>(unitType); 173 133 m_valueInSpecifiedUnits = valueInSpecifiedUnits; 174 } 175 176 void SVGAngle::convertToSpecifiedUnits(unsigned short unitType, ExceptionCode& ec) 177 { 178 if (unitType == SVG_ANGLETYPE_UNKNOWN || m_unitType == SVG_ANGLETYPE_UNKNOWN || unitType > SVG_ANGLETYPE_GRAD) { 179 ec = NOT_SUPPORTED_ERR; 180 return; 181 } 134 return { }; 135 } 136 137 ExceptionOr<void> SVGAngle::convertToSpecifiedUnits(unsigned short unitType) 138 { 139 if (unitType == SVG_ANGLETYPE_UNKNOWN || m_unitType == SVG_ANGLETYPE_UNKNOWN || unitType > SVG_ANGLETYPE_GRAD) 140 return Exception { NOT_SUPPORTED_ERR }; 182 141 183 142 if (unitType == m_unitType) 184 return ;143 return { }; 185 144 186 145 switch (m_unitType) { … … 226 185 break; 227 186 case SVG_ANGLETYPE_UNSPECIFIED: 228 break;229 187 case SVG_ANGLETYPE_DEG: 188 break; 230 189 case SVG_ANGLETYPE_UNKNOWN: 231 190 ASSERT_NOT_REACHED(); … … 239 198 240 199 m_unitType = static_cast<SVGAngleType>(unitType); 241 } 242 243 } 200 201 return { }; 202 } 203 204 } -
trunk/Source/WebCore/svg/SVGAngle.h
r163440 r207716 20 20 */ 21 21 22 #ifndef SVGAngle_h 23 #define SVGAngle_h 22 #pragma once 24 23 24 #include "ExceptionOr.h" 25 25 #include "SVGPropertyTraits.h" 26 26 27 27 namespace WebCore { 28 28 29 typedef int ExceptionCode;30 31 29 class SVGAngle { 32 30 WTF_MAKE_FAST_ALLOCATED; 33 31 public: 34 SVGAngle();35 36 32 enum SVGAngleType { 37 33 SVG_ANGLETYPE_UNKNOWN = 0, … … 50 46 float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; } 51 47 52 void setValueAsString(const String&, ExceptionCode&);48 ExceptionOr<void> setValueAsString(const String&); 53 49 String valueAsString() const; 54 50 55 void newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits, ExceptionCode&);56 void convertToSpecifiedUnits(unsigned short unitType, ExceptionCode&);51 ExceptionOr<void> newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits); 52 ExceptionOr<void> convertToSpecifiedUnits(unsigned short unitType); 57 53 58 54 private: 59 SVGAngleType m_unitType ;60 float m_valueInSpecifiedUnits ;55 SVGAngleType m_unitType { SVG_ANGLETYPE_UNSPECIFIED }; 56 float m_valueInSpecifiedUnits { 0 }; 61 57 }; 62 58 63 template<> 64 struct SVGPropertyTraits<SVGAngle> { 59 template<> struct SVGPropertyTraits<SVGAngle> { 65 60 static SVGAngle initialValue() { return SVGAngle(); } 66 61 static String toString(const SVGAngle& type) { return type.valueAsString(); } … … 68 63 69 64 } // namespace WebCore 70 71 #endif // SVGAngle_h -
trunk/Source/WebCore/svg/SVGAngle.idl
r206723 r207716 33 33 attribute unrestricted float valueInSpecifiedUnits; 34 34 35 [SetterMayThrow LegacyException] attribute DOMString valueAsString;35 [SetterMayThrowException] attribute DOMString valueAsString; 36 36 37 [MayThrowLegacyException] void newValueSpecifiedUnits(unsigned short unitType, unrestricted float valueInSpecifiedUnits); 38 39 [MayThrowLegacyException] void convertToSpecifiedUnits(unsigned short unitType); 37 [MayThrowException] void newValueSpecifiedUnits(unsigned short unitType, unrestricted float valueInSpecifiedUnits); 38 [MayThrowException] void convertToSpecifiedUnits(unsigned short unitType); 40 39 }; 41 -
trunk/Source/WebCore/svg/SVGAnimateElementBase.cpp
r207458 r207716 110 110 percentage = 1; 111 111 112 if (calcMode() == CalcMode Discrete)112 if (calcMode() == CalcMode::Discrete) 113 113 percentage = percentage < 0.5 ? 0 : 1; 114 114 -
trunk/Source/WebCore/svg/SVGAnimateMotionElement.cpp
r203337 r207716 47 47 , m_hasToPointAtEndOfDuration(false) 48 48 { 49 setCalcMode(CalcMode Paced);49 setCalcMode(CalcMode::Paced); 50 50 ASSERT(hasTagName(animateMotionTag)); 51 51 } -
trunk/Source/WebCore/svg/SVGAnimateTransformElement.cpp
r182121 r207716 47 47 return false; 48 48 49 if (attributeType() == AttributeType CSS)49 if (attributeType() == AttributeType::CSS) 50 50 return false; 51 51 -
trunk/Source/WebCore/svg/SVGAnimatedAngle.cpp
r197738 r207716 138 138 { 139 139 SVGAngle from = SVGAngle(); 140 from.setValueAsString(fromString , ASSERT_NO_EXCEPTION);140 from.setValueAsString(fromString); 141 141 SVGAngle to = SVGAngle(); 142 to.setValueAsString(toString , ASSERT_NO_EXCEPTION);142 to.setValueAsString(toString); 143 143 return fabsf(to.value() - from.value()); 144 144 } -
trunk/Source/WebCore/svg/SVGAnimatedBoolean.idl
r206723 r207716 27 27 SkipVTableValidation 28 28 ] interface SVGAnimatedBoolean { 29 [SetterMayThrow LegacyException] attribute boolean baseVal;29 [SetterMayThrowException] attribute boolean baseVal; 30 30 readonly attribute boolean animVal; 31 31 }; -
trunk/Source/WebCore/svg/SVGAnimatedEnumeration.idl
r206723 r207716 27 27 SkipVTableValidation 28 28 ] interface SVGAnimatedEnumeration { 29 [SetterMayThrow LegacyException] attribute unsigned short baseVal;29 [SetterMayThrowException] attribute unsigned short baseVal; 30 30 readonly attribute unsigned short animVal; 31 31 }; -
trunk/Source/WebCore/svg/SVGAnimatedInteger.idl
r206723 r207716 27 27 SkipVTableValidation 28 28 ] interface SVGAnimatedInteger { 29 [SetterMayThrow LegacyException] attribute long baseVal;29 [SetterMayThrowException] attribute long baseVal; 30 30 readonly attribute long animVal; 31 31 }; -
trunk/Source/WebCore/svg/SVGAnimatedLength.cpp
r193809 r207716 31 31 , m_lengthMode(SVGLength::lengthModeForAnimatedLengthAttribute(animationElement->attributeName())) 32 32 { 33 }34 35 static inline SVGLength& sharedSVGLength(SVGLengthMode mode, const String& valueAsString)36 {37 static NeverDestroyed<SVGLength> sharedLength;38 sharedLength.get().setValueAsString(valueAsString, mode, ASSERT_NO_EXCEPTION);39 return sharedLength;40 33 } 41 34 … … 79 72 SVGLength& toLength = to->length(); 80 73 81 toLength.setValue(toLength.value(lengthContext) + fromLength.value(lengthContext), lengthContext , ASSERT_NO_EXCEPTION);74 toLength.setValue(toLength.value(lengthContext) + fromLength.value(lengthContext), lengthContext); 82 75 } 83 76 84 77 static SVGLength parseLengthFromString(SVGAnimationElement* animationElement, const String& string) 85 78 { 86 return sharedSVGLength(SVGLength::lengthModeForAnimatedLengthAttribute(animationElement->attributeName()), string); 79 SVGLength length; 80 length.setValueAsString(string, SVGLength::lengthModeForAnimatedLengthAttribute(animationElement->attributeName())); 81 return length; 87 82 } 88 83 … … 106 101 m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromSVGLength.value(lengthContext), toSVGLength.value(lengthContext), toAtEndOfDurationSVGLength.value(lengthContext), animatedNumber); 107 102 108 animatedSVGLength.setValue(lengthContext, animatedNumber, m_lengthMode, unitType , ASSERT_NO_EXCEPTION);103 animatedSVGLength.setValue(lengthContext, animatedNumber, m_lengthMode, unitType); 109 104 } 110 105 -
trunk/Source/WebCore/svg/SVGAnimatedLengthList.cpp
r193809 r207716 78 78 SVGLengthContext lengthContext(m_contextElement); 79 79 for (unsigned i = 0; i < fromLengthListSize; ++i) 80 toLengthList[i].setValue(toLengthList[i].value(lengthContext) + fromLengthList[i].value(lengthContext), lengthContext , ASSERT_NO_EXCEPTION);80 toLengthList[i].setValue(toLengthList[i].value(lengthContext) + fromLengthList[i].value(lengthContext), lengthContext); 81 81 } 82 82 … … 122 122 123 123 m_animationElement->animateAdditiveNumber(percentage, repeatCount, effectiveFrom, toLengthList[i].value(lengthContext), effectiveToAtEnd, animatedNumber); 124 animatedLengthList[i].setValue(lengthContext, animatedNumber, m_lengthMode, unitType , ASSERT_NO_EXCEPTION);124 animatedLengthList[i].setValue(lengthContext, animatedNumber, m_lengthMode, unitType); 125 125 } 126 126 } -
trunk/Source/WebCore/svg/SVGAnimatedNumber.idl
r206723 r207716 28 28 SkipVTableValidation 29 29 ] interface SVGAnimatedNumber { 30 [SetterMayThrow LegacyException] attribute unrestricted float baseVal;30 [SetterMayThrowException] attribute unrestricted float baseVal; 31 31 readonly attribute unrestricted float animVal; 32 32 }; -
trunk/Source/WebCore/svg/SVGAnimatedString.idl
r206723 r207716 27 27 SkipVTableValidation 28 28 ] interface SVGAnimatedString { 29 [SetterMayThrow LegacyException] attribute DOMString baseVal;29 [SetterMayThrowException] attribute DOMString baseVal; 30 30 readonly attribute DOMString animVal; 31 31 }; -
trunk/Source/WebCore/svg/SVGAnimatedType.cpp
r190003 r207716 277 277 ASSERT(m_data.color); 278 278 *m_data.color = SVGColor::colorFromRGBColorString(value); 279 break;280 case AnimatedLength: {279 return true; 280 case AnimatedLength: 281 281 ASSERT(m_data.length); 282 ExceptionCode ec = 0; 283 m_data.length->setValueAsString(value, SVGLength::lengthModeForAnimatedLengthAttribute(attrName), ec); 284 return !ec; 285 } 282 return !m_data.length->setValueAsString(value, SVGLength::lengthModeForAnimatedLengthAttribute(attrName)).hasException(); 286 283 case AnimatedLengthList: 287 284 ASSERT(m_data.lengthList); 288 285 m_data.lengthList->parse(value, SVGLength::lengthModeForAnimatedLengthAttribute(attrName)); 289 break;286 return true; 290 287 case AnimatedNumber: 291 288 ASSERT(m_data.number); 292 289 parseNumberFromString(value, *m_data.number); 293 break;290 return true; 294 291 case AnimatedRect: 295 292 ASSERT(m_data.rect); 296 293 parseRect(value, *m_data.rect); 297 break;294 return true; 298 295 case AnimatedString: 299 296 ASSERT(m_data.string); 300 297 *m_data.string = value; 301 break;298 return true; 302 299 303 300 // These types don't appear in the table in SVGElement::cssPropertyToTypeMap() and thus don't need setValueAsString() support. -
trunk/Source/WebCore/svg/SVGAnimationElement.cpp
r203337 r207716 54 54 SVGAnimationElement::SVGAnimationElement(const QualifiedName& tagName, Document& document) 55 55 : SVGSMILElement(tagName, document) 56 , m_fromPropertyValueType(RegularPropertyValue)57 , m_toPropertyValueType(RegularPropertyValue)58 , m_animationValid(false)59 , m_attributeType(AttributeTypeAuto)60 , m_hasInvalidCSSAttributeType(false)61 , m_calcMode(CalcModeLinear)62 , m_animationMode(NoAnimation)63 56 { 64 57 registerAnimatedPropertiesForSVGAnimationElement(); … … 242 235 } 243 236 244 float SVGAnimationElement::getSimpleDuration( ExceptionCode&) const237 float SVGAnimationElement::getSimpleDuration() const 245 238 { 246 239 return narrowPrecisionToFloat(simpleDuration().value()); … … 293 286 static NeverDestroyed<const AtomicString> spline("spline", AtomicString::ConstructFromLiteral); 294 287 if (calcMode == discrete) 295 setCalcMode(CalcMode Discrete);288 setCalcMode(CalcMode::Discrete); 296 289 else if (calcMode == linear) 297 setCalcMode(CalcMode Linear);290 setCalcMode(CalcMode::Linear); 298 291 else if (calcMode == paced) 299 setCalcMode(CalcMode Paced);292 setCalcMode(CalcMode::Paced); 300 293 else if (calcMode == spline) 301 setCalcMode(CalcMode Spline);294 setCalcMode(CalcMode::Spline); 302 295 else 303 setCalcMode(hasTagName(SVGNames::animateMotionTag) ? CalcMode Paced : CalcModeLinear);296 setCalcMode(hasTagName(SVGNames::animateMotionTag) ? CalcMode::Paced : CalcMode::Linear); 304 297 } 305 298 … … 309 302 static NeverDestroyed<const AtomicString> xml("XML", AtomicString::ConstructFromLiteral); 310 303 if (attributeType == css) 311 m_attributeType = AttributeType CSS;304 m_attributeType = AttributeType::CSS; 312 305 else if (attributeType == xml) 313 m_attributeType = AttributeType XML;306 m_attributeType = AttributeType::XML; 314 307 else 315 m_attributeType = AttributeType Auto;308 m_attributeType = AttributeType::Auto; 316 309 checkInvalidCSSAttributeType(targetElement()); 317 310 } … … 369 362 370 363 // If attributeType="CSS" and attributeName doesn't point to a CSS property, ignore the animation. 371 if (attributeType() == AttributeType CSS)364 if (attributeType() == AttributeType::CSS) 372 365 return DontApplyAnimation; 373 366 … … 377 370 void SVGAnimationElement::calculateKeyTimesForCalcModePaced() 378 371 { 379 ASSERT(calcMode() == CalcMode Paced);372 ASSERT(calcMode() == CalcMode::Paced); 380 373 ASSERT(animationMode() == ValuesAnimation); 381 374 … … 429 422 float SVGAnimationElement::calculatePercentForSpline(float percent, unsigned splineIndex) const 430 423 { 431 ASSERT(calcMode() == CalcMode Spline);424 ASSERT(calcMode() == CalcMode::Spline); 432 425 ASSERT_WITH_SECURITY_IMPLICATION(splineIndex < m_keySplines.size()); 433 426 UnitBezier bezier = m_keySplines[splineIndex]; … … 441 434 { 442 435 ASSERT(!m_keyPoints.isEmpty()); 443 ASSERT(calcMode() != CalcMode Paced);436 ASSERT(calcMode() != CalcMode::Paced); 444 437 ASSERT(m_keyTimes.size() > 1); 445 438 ASSERT(m_keyPoints.size() == m_keyTimes.size()); … … 454 447 float toKeyPoint = m_keyPoints[index + 1]; 455 448 456 if (calcMode() == CalcMode Discrete)449 if (calcMode() == CalcMode::Discrete) 457 450 return fromKeyPoint; 458 451 459 452 float keyPointPercent = (percent - fromPercent) / (toPercent - fromPercent); 460 453 461 if (calcMode() == CalcMode Spline) {454 if (calcMode() == CalcMode::Spline) { 462 455 ASSERT(m_keySplines.size() == m_keyPoints.size() - 1); 463 456 keyPointPercent = calculatePercentForSpline(keyPointPercent, index); … … 468 461 float SVGAnimationElement::calculatePercentForFromTo(float percent) const 469 462 { 470 if (calcMode() == CalcMode Discrete && m_keyTimes.size() == 2)463 if (calcMode() == CalcMode::Discrete && m_keyTimes.size() == 2) 471 464 return percent > m_keyTimes[1] ? 1 : 0; 472 465 … … 478 471 ASSERT(!m_keyPoints.isEmpty()); 479 472 ASSERT(m_keyPoints.size() == m_keyTimes.size()); 480 ASSERT(calcMode() != CalcMode Paced);473 ASSERT(calcMode() != CalcMode::Paced); 481 474 effectivePercent = calculatePercentFromKeyPoints(percent); 482 475 unsigned index = effectivePercent == 1 ? m_values.size() - 2 : static_cast<unsigned>(effectivePercent * (m_values.size() - 1)); … … 503 496 AnimatedPropertyType type = downcast<SVGAnimateElementBase>(*this).determineAnimatedPropertyType(*targetElement()); 504 497 if (type == AnimatedBoolean || type == AnimatedEnumeration || type == AnimatedPreserveAspectRatio || type == AnimatedString) 505 calcMode = CalcMode Discrete;506 } 507 if (!m_keyPoints.isEmpty() && calcMode != CalcMode Paced)498 calcMode = CalcMode::Discrete; 499 } 500 if (!m_keyPoints.isEmpty() && calcMode != CalcMode::Paced) 508 501 return currentValuesFromKeyPoints(percent, effectivePercent, from, to); 509 502 … … 513 506 514 507 unsigned index = calculateKeyTimesIndex(percent); 515 if (calcMode == CalcMode Discrete) {508 if (calcMode == CalcMode::Discrete) { 516 509 if (!keyTimesCount) 517 510 index = static_cast<unsigned>(percent * valuesCount); … … 540 533 effectivePercent = (percent - fromPercent) / (toPercent - fromPercent); 541 534 542 if (calcMode == CalcMode Spline) {535 if (calcMode == CalcMode::Spline) { 543 536 ASSERT(m_keySplines.size() == m_values.size() - 1); 544 537 effectivePercent = calculatePercentForSpline(effectivePercent, index); … … 559 552 AnimationMode animationMode = this->animationMode(); 560 553 CalcMode calcMode = this->calcMode(); 561 if (calcMode == CalcMode Spline) {554 if (calcMode == CalcMode::Spline) { 562 555 unsigned splinesCount = m_keySplines.size(); 563 556 if (!splinesCount … … 588 581 else if (animationMode == ValuesAnimation) { 589 582 m_animationValid = m_values.size() >= 1 590 && (calcMode == CalcMode Paced || !hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) || hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (m_values.size() == m_keyTimes.size()))591 && (calcMode == CalcMode Discrete || !m_keyTimes.size() || m_keyTimes.last() == 1)592 && (calcMode != CalcMode Spline || ((m_keySplines.size() && (m_keySplines.size() == m_values.size() - 1)) || m_keySplines.size() == m_keyPoints.size() - 1))583 && (calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) || hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (m_values.size() == m_keyTimes.size())) 584 && (calcMode == CalcMode::Discrete || !m_keyTimes.size() || m_keyTimes.last() == 1) 585 && (calcMode != CalcMode::Spline || ((m_keySplines.size() && (m_keySplines.size() == m_values.size() - 1)) || m_keySplines.size() == m_keyPoints.size() - 1)) 593 586 && (!hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size())); 594 587 if (m_animationValid) 595 588 m_animationValid = calculateToAtEndOfDurationValue(m_values.last()); 596 if (calcMode == CalcMode Paced && m_animationValid)589 if (calcMode == CalcMode::Paced && m_animationValid) 597 590 calculateKeyTimesForCalcModePaced(); 598 591 } else if (animationMode == PathAnimation) 599 m_animationValid = calcMode == CalcMode Paced || !hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size());592 m_animationValid = calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size()); 600 593 } 601 594 … … 619 612 m_lastValuesAnimationTo = to; 620 613 } 621 } else if (!m_keyPoints.isEmpty() && calcMode != CalcMode Paced)614 } else if (!m_keyPoints.isEmpty() && calcMode != CalcMode::Paced) 622 615 effectivePercent = calculatePercentFromKeyPoints(percent); 623 else if (m_keyPoints.isEmpty() && calcMode == CalcMode Spline && m_keyTimes.size() > 1)616 else if (m_keyPoints.isEmpty() && calcMode == CalcMode::Spline && m_keyTimes.size() > 1) 624 617 effectivePercent = calculatePercentForSpline(percent, calculateKeyTimesIndex(percent)); 625 618 else if (animationMode == FromToAnimation || animationMode == ToAnimation) … … 690 683 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) 691 684 { 692 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attributeType() == AttributeType CSS && !isTargetAttributeCSSProperty(target, attributeName());693 } 694 695 } 685 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attributeType() == AttributeType::CSS && !isTargetAttributeCSSProperty(target, attributeName()); 686 } 687 688 } -
trunk/Source/WebCore/svg/SVGAnimationElement.h
r197563 r207716 23 23 */ 24 24 25 #ifndef SVGAnimationElement_h 26 #define SVGAnimationElement_h 25 #pragma once 27 26 28 27 #include "SMILTime.h" … … 34 33 35 34 namespace WebCore { 35 36 class ConditionEventListener; 37 class SVGAnimatedType; 38 class TimeContainer; 36 39 37 40 enum AnimationMode { … … 47 50 // If we have 'currentColor' or 'inherit' as animation value, we need to grab 48 51 // the value during the animation since the value can be animated itself. 49 enum AnimatedPropertyValueType { 50 RegularPropertyValue, 51 CurrentColorValue, 52 InheritValue 53 }; 54 55 enum CalcMode { 56 CalcModeDiscrete, 57 CalcModeLinear, 58 CalcModePaced, 59 CalcModeSpline 60 }; 61 62 class ConditionEventListener; 63 class TimeContainer; 64 class SVGAnimatedType; 65 66 class SVGAnimationElement : public SVGSMILElement, 67 public SVGTests, 68 public SVGExternalResourcesRequired { 52 enum AnimatedPropertyValueType { RegularPropertyValue, CurrentColorValue, InheritValue }; 53 54 enum class CalcMode { Discrete, Linear, Paced, Spline }; 55 56 class SVGAnimationElement : public SVGSMILElement, public SVGTests, public SVGExternalResourcesRequired { 69 57 public: 70 // SVGAnimationElement71 58 float getStartTime() const; 72 59 float getCurrentTime() const; 73 float getSimpleDuration( ExceptionCode&) const;60 float getSimpleDuration() const; 74 61 75 62 void beginElement(); … … 97 84 AnimatedPropertyValueType toPropertyValueType() const { return m_toPropertyValueType; } 98 85 99 template<typename AnimatedType> 100 void adjustForInheritance(AnimatedType (*parseTypeFromString)(SVGAnimationElement*, const String&), 101 AnimatedPropertyValueType valueType, AnimatedType& animatedType, SVGElement* contextElement) 86 template<typename AnimatedType> void adjustForInheritance(AnimatedType (*parseTypeFromString)(SVGAnimationElement*, const String&), AnimatedPropertyValueType valueType, AnimatedType& animatedType, SVGElement* contextElement) 102 87 { 103 88 if (valueType != InheritValue) … … 110 95 } 111 96 112 template<typename AnimatedType> 113 bool adjustFromToListValues(const AnimatedType& fromList, const AnimatedType& toList, AnimatedType& animatedList, float percentage, bool resizeAnimatedListIfNeeded = true) 97 template<typename AnimatedType> bool adjustFromToListValues(const AnimatedType& fromList, const AnimatedType& toList, AnimatedType& animatedList, float percentage, bool resizeAnimatedListIfNeeded = true) 114 98 { 115 99 // If no 'to' value is given, nothing to animate. … … 137 121 } 138 122 139 template<typename AnimatedType> 140 void animateDiscreteType(float percentage, const AnimatedType& fromType, const AnimatedType& toType, AnimatedType& animatedType) 123 template<typename AnimatedType> void animateDiscreteType(float percentage, const AnimatedType& fromType, const AnimatedType& toType, AnimatedType& animatedType) 141 124 { 142 125 if ((animationMode() == FromToAnimation && percentage > 0.5) || animationMode() == ToAnimation || percentage == 1) { … … 150 133 { 151 134 float number; 152 if (calcMode() == CalcMode Discrete)135 if (calcMode() == CalcMode::Discrete) 153 136 number = percentage < 0.5 ? fromNumber : toNumber; 154 137 else … … 175 158 void svgAttributeChanged(const QualifiedName&) override; 176 159 177 enum AttributeType { 178 AttributeTypeCSS, 179 AttributeTypeXML, 180 AttributeTypeAuto 181 }; 160 enum class AttributeType { CSS, XML, Auto }; 182 161 AttributeType attributeType() const { return m_attributeType; } 183 162 … … 192 171 void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) override; 193 172 194 AnimatedPropertyValueType m_fromPropertyValueType ;195 AnimatedPropertyValueType m_toPropertyValueType ;173 AnimatedPropertyValueType m_fromPropertyValueType { RegularPropertyValue }; 174 AnimatedPropertyValueType m_toPropertyValueType { RegularPropertyValue }; 196 175 197 176 void setTargetElement(SVGElement*) override; … … 236 215 void setCalcMode(const AtomicString&); 237 216 238 bool m_animationValid ;239 240 AttributeType m_attributeType ;217 bool m_animationValid { false }; 218 219 AttributeType m_attributeType { AttributeType::Auto }; 241 220 Vector<String> m_values; 242 221 Vector<float> m_keyTimes; … … 245 224 String m_lastValuesAnimationFrom; 246 225 String m_lastValuesAnimationTo; 247 bool m_hasInvalidCSSAttributeType ;248 CalcMode m_calcMode ;249 AnimationMode m_animationMode ;226 bool m_hasInvalidCSSAttributeType { false }; 227 CalcMode m_calcMode { CalcMode::Linear }; 228 AnimationMode m_animationMode { NoAnimation }; 250 229 }; 251 230 252 231 } // namespace WebCore 253 254 #endif // SVGAnimationElement_h -
trunk/Source/WebCore/svg/SVGAnimationElement.idl
r206723 r207716 30 30 unrestricted float getStartTime(); 31 31 unrestricted float getCurrentTime(); 32 [MayThrowLegacyException]unrestricted float getSimpleDuration();32 unrestricted float getSimpleDuration(); 33 33 34 34 void beginElement(); -
trunk/Source/WebCore/svg/SVGColor.cpp
r207361 r207716 29 29 namespace WebCore { 30 30 31 SVGColor::SVGColor( const SVGColorType&colorType)31 SVGColor::SVGColor(SVGColorType colorType) 32 32 : CSSValue(SVGColorClass) 33 33 , m_colorType(colorType) … … 35 35 } 36 36 37 SVGColor::SVGColor(ClassType classType, const SVGColorType&colorType)37 SVGColor::SVGColor(ClassType classType, SVGColorType colorType) 38 38 : CSSValue(classType) 39 39 , m_colorType(colorType) … … 55 55 } 56 56 57 void SVGColor::setRGBColor(const String&, ExceptionCode& ec)57 ExceptionOr<void> SVGColor::setRGBColor(const String&) 58 58 { 59 59 // The whole SVGColor interface is deprecated in SVG 1.1 (2nd edition). 60 60 // Since the setters are the most problematic part, we removed the support for those first. 61 ec = NO_MODIFICATION_ALLOWED_ERR;61 return Exception { NO_MODIFICATION_ALLOWED_ERR }; 62 62 } 63 63 64 void SVGColor::setRGBColorICCColor(const String&, const String&, ExceptionCode& ec)64 ExceptionOr<void> SVGColor::setRGBColorICCColor(const String&, const String&) 65 65 { 66 ec = NO_MODIFICATION_ALLOWED_ERR;66 return Exception { NO_MODIFICATION_ALLOWED_ERR }; 67 67 } 68 68 69 void SVGColor::setColor(unsigned short, const String&, const String&, ExceptionCode& ec)69 ExceptionOr<void> SVGColor::setColor(unsigned short, const String&, const String&) 70 70 { 71 ec = NO_MODIFICATION_ALLOWED_ERR;71 return Exception { NO_MODIFICATION_ALLOWED_ERR }; 72 72 } 73 73 -
trunk/Source/WebCore/svg/SVGColor.h
r183611 r207716 20 20 */ 21 21 22 #ifndef SVGColor_h 23 #define SVGColor_h 22 #pragma once 24 23 25 24 #include "CSSValue.h" … … 64 63 static Color colorFromRGBColorString(const String&); 65 64 66 void setRGBColor(const String& rgbColor, ExceptionCode&);67 void setRGBColorICCColor(const String& rgbColor, const String& iccColor, ExceptionCode&);68 void setColor(unsigned short colorType, const String& rgbColor, const String& iccColor, ExceptionCode&);65 ExceptionOr<void> setRGBColor(const String&); 66 ExceptionOr<void> setRGBColorICCColor(const String& rgbColor, const String& iccColor); 67 ExceptionOr<void> setColor(unsigned short colorType, const String& rgbColor, const String& iccColor); 69 68 70 69 String customCSSText() const; 71 70 72 ~SVGColor() { }73 74 71 Ref<SVGColor> cloneForCSSOM() const; 75 72 … … 79 76 friend class CSSComputedStyleDeclaration; 80 77 81 SVGColor(ClassType, const SVGColorType&);78 SVGColor(ClassType, SVGColorType); 82 79 SVGColor(ClassType, const SVGColor& cloneFrom); 83 80 … … 86 83 87 84 private: 88 SVGColor(const SVGColorType&);85 explicit SVGColor(SVGColorType); 89 86 90 87 Color m_color; … … 95 92 96 93 SPECIALIZE_TYPE_TRAITS_CSS_VALUE(SVGColor, isSVGColor()) 97 98 #endif // SVGColor_h -
trunk/Source/WebCore/svg/SVGColor.idl
r206723 r207716 32 32 // FIXME: readonly attribute SVGICCColor iccColor; 33 33 34 [MayThrowLegacyException] void setRGBColor(DOMString rgbColor); 35 36 [MayThrowLegacyException] void setRGBColorICCColor(DOMString rgbColor, DOMString iccColor); 37 38 [MayThrowLegacyException] void setColor(unsigned short colorType, DOMString rgbColor, DOMString iccColor); 34 [MayThrowException] void setRGBColor(DOMString rgbColor); 35 [MayThrowException] void setRGBColorICCColor(DOMString rgbColor, DOMString iccColor); 36 [MayThrowException] void setColor(unsigned short colorType, DOMString rgbColor, DOMString iccColor); 39 37 }; 40 -
trunk/Source/WebCore/svg/SVGGlyphRefElement.cpp
r203324 r207716 28 28 #include "XLinkNames.h" 29 29 #include <wtf/text/AtomicString.h> 30 #include <wtf/text/StringView.h>31 30 32 31 namespace WebCore { … … 42 41 inline SVGGlyphRefElement::SVGGlyphRefElement(const QualifiedName& tagName, Document& document) 43 42 : SVGElement(tagName, document) 44 , m_x(0)45 , m_y(0)46 , m_dx(0)47 , m_dy(0)48 43 { 49 44 ASSERT(hasTagName(SVGNames::glyphRefTag)); … … 63 58 } 64 59 60 static float parseFloat(const AtomicString& value) 61 { 62 float result; 63 if (!parseNumberFromString(value, result)) 64 return 0; 65 return result; 66 } 67 65 68 void SVGGlyphRefElement::parseAttribute(const QualifiedName& name, const AtomicString& value) 66 69 { 67 auto upconvertedCharacters = StringView(value.string()).upconvertedCharacters(); 68 const UChar* startPtr = upconvertedCharacters; 69 const UChar* endPtr = startPtr + value.length(); 70 71 // FIXME: We need some error handling here. 70 // FIXME: Is the error handling in parseFloat correct for these attributes? 72 71 if (name == SVGNames::xAttr) 73 parseNumber(startPtr, endPtr, m_x);72 m_x = parseFloat(value); 74 73 else if (name == SVGNames::yAttr) 75 parseNumber(startPtr, endPtr, m_y);74 m_y = parseFloat(value); 76 75 else if (name == SVGNames::dxAttr) 77 parseNumber(startPtr, endPtr, m_dx);76 m_dx = parseFloat(value); 78 77 else if (name == SVGNames::dyAttr) 79 parseNumber(startPtr, endPtr, m_dy);78 m_dy = parseFloat(value); 80 79 else { 81 80 SVGURIReference::parseAttribute(name, value); … … 84 83 } 85 84 86 const AtomicString& SVGGlyphRefElement::glyphRef() const 85 void SVGGlyphRefElement::setX(float x) 87 86 { 88 return attributeWithoutSynchronization(SVGNames::glyphRefAttr);87 setAttribute(SVGNames::xAttr, AtomicString::number(x)); 89 88 } 90 89 91 void SVGGlyphRefElement::set GlyphRef(const AtomicString&, ExceptionCode&)90 void SVGGlyphRefElement::setY(float y) 92 91 { 93 // FIXME: Set and honor attribute change. 94 // https://bugs.webkit.org/show_bug.cgi?id=64787 92 setAttribute(SVGNames::yAttr, AtomicString::number(y)); 95 93 } 96 94 97 void SVGGlyphRefElement::set X(float x, ExceptionCode&)95 void SVGGlyphRefElement::setDx(float dx) 98 96 { 99 // FIXME: Honor attribute change. 100 // https://bugs.webkit.org/show_bug.cgi?id=64787 101 m_x = x; 97 setAttribute(SVGNames::dxAttr, AtomicString::number(dx)); 102 98 } 103 99 104 void SVGGlyphRefElement::set Y(float y , ExceptionCode&)100 void SVGGlyphRefElement::setDy(float dy) 105 101 { 106 // FIXME: Honor attribute change. 107 // https://bugs.webkit.org/show_bug.cgi?id=64787 108 m_y = y; 109 } 110 111 void SVGGlyphRefElement::setDx(float dx, ExceptionCode&) 112 { 113 // FIXME: Honor attribute change. 114 // https://bugs.webkit.org/show_bug.cgi?id=64787 115 m_dx = dx; 116 } 117 118 void SVGGlyphRefElement::setDy(float dy, ExceptionCode&) 119 { 120 // FIXME: Honor attribute change. 121 // https://bugs.webkit.org/show_bug.cgi?id=64787 122 m_dy = dy; 102 setAttribute(SVGNames::dyAttr, AtomicString::number(dy)); 123 103 } 124 104 -
trunk/Source/WebCore/svg/SVGGlyphRefElement.h
r203469 r207716 18 18 */ 19 19 20 #ifndef SVGGlyphRefElement_h 21 #define SVGGlyphRefElement_h 20 #pragma once 22 21 23 22 #if ENABLE(SVG_FONTS) 23 24 24 #include "SVGElement.h" 25 25 #include "SVGURIReference.h" … … 27 27 namespace WebCore { 28 28 29 class SVGGlyphRefElement final : public SVGElement, 30 public SVGURIReference { 29 class SVGGlyphRefElement final : public SVGElement, public SVGURIReference { 31 30 public: 32 31 static Ref<SVGGlyphRefElement> create(const QualifiedName&, Document&); 33 32 34 33 bool hasValidGlyphElement(String& glyphName) const; 35 void parseAttribute(const QualifiedName&, const AtomicString&) final;36 34 37 // DOM interface38 const AtomicString& glyphRef() const;39 void setGlyphRef(const AtomicString&, ExceptionCode&);40 35 float x() const { return m_x; } 41 void setX(float , ExceptionCode&);36 void setX(float); 42 37 float y() const { return m_y; } 43 void setY(float , ExceptionCode&);38 void setY(float); 44 39 float dx() const { return m_dx; } 45 void setDx(float , ExceptionCode&);40 void setDx(float); 46 41 float dy() const { return m_dy; } 47 void setDy(float , ExceptionCode&);42 void setDy(float); 48 43 49 44 private: 50 45 SVGGlyphRefElement(const QualifiedName&, Document&); 51 46 47 void parseAttribute(const QualifiedName&, const AtomicString&) final; 52 48 bool rendererIsNeeded(const RenderStyle&) final { return false; } 53 49 … … 56 52 END_DECLARE_ANIMATED_PROPERTIES 57 53 58 float m_x ;59 float m_y ;60 float m_dx ;61 float m_dy ;54 float m_x { 0 }; 55 float m_y { 0 }; 56 float m_dx { 0 }; 57 float m_dy { 0 }; 62 58 }; 63 59 … … 65 61 66 62 #endif 67 #endif -
trunk/Source/WebCore/svg/SVGGlyphRefElement.idl
r206723 r207716 21 21 Conditional=SVG_FONTS 22 22 ] interface SVGGlyphRefElement : SVGElement { 23 // FIXME: Use [Reflect] after https://bugs.webkit.org/show_bug.cgi?id=64843 is fixed. 24 [SetterMayThrowLegacyException] attribute DOMString glyphRef; 23 [Reflect=glyphRef] attribute DOMString glyphRef; 25 24 [Reflect] attribute DOMString format; 26 [SetterMayThrowLegacyException]attribute unrestricted float x;27 [SetterMayThrowLegacyException]attribute unrestricted float y;28 [SetterMayThrowLegacyException]attribute unrestricted float dx;29 [SetterMayThrowLegacyException]attribute unrestricted float dy;25 attribute unrestricted float x; 26 attribute unrestricted float y; 27 attribute unrestricted float dx; 28 attribute unrestricted float dy; 30 29 }; 31 30 -
trunk/Source/WebCore/svg/SVGGraphicsElement.idl
r206723 r207716 33 33 SVGMatrix getCTM(); 34 34 SVGMatrix getScreenCTM(); 35 [MayThrow LegacyException] SVGMatrix getTransformToElement(optional SVGElement? element = null);35 [MayThrowException] SVGMatrix getTransformToElement(optional SVGElement? element = null); 36 36 }; 37 37 -
trunk/Source/WebCore/svg/SVGLength.cpp
r207396 r207716 26 26 #include "CSSPrimitiveValue.h" 27 27 #include "ExceptionCode.h" 28 #include "ExceptionCodePlaceholder.h"29 28 #include "FloatConversion.h" 30 29 #include "SVGNames.h" … … 86 85 } 87 86 88 inline SVGLengthType stringToLengthType(const UChar*&ptr, const UChar* end)87 inline SVGLengthType parseLengthType(const UChar* ptr, const UChar* end) 89 88 { 90 89 if (ptr == end) … … 125 124 , m_unit(storeUnit(mode, LengthTypeNumber)) 126 125 { 127 setValueAsString(valueAsString , IGNORE_EXCEPTION);126 setValueAsString(valueAsString); 128 127 } 129 128 … … 132 131 , m_unit(storeUnit(mode, unitType)) 133 132 { 134 setValue(value, context, ASSERT_NO_EXCEPTION); 135 } 136 137 SVGLength::SVGLength(const SVGLength& other) 138 : m_valueInSpecifiedUnits(other.m_valueInSpecifiedUnits) 139 , m_unit(other.m_unit) 140 { 141 } 142 143 void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode, ExceptionCode& ec) 133 setValue(value, context); 134 } 135 136 ExceptionOr<void> SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode) 144 137 { 145 138 m_valueInSpecifiedUnits = 0; 146 139 m_unit = storeUnit(mode, LengthTypeNumber); 147 setValueAsString(valueAsString, ec);140 return setValueAsString(valueAsString); 148 141 } 149 142 … … 161 154 SVGLength SVGLength::construct(SVGLengthMode mode, const String& valueAsString, SVGParsingError& parseError, SVGLengthNegativeValuesMode negativeValuesMode) 162 155 { 163 ExceptionCode ec = 0;164 156 SVGLength length(mode); 165 157 166 length.setValueAsString(valueAsString, ec); 167 168 if (ec) 158 if (length.setValueAsString(valueAsString).hasException()) 169 159 parseError = ParsingAttributeFailedError; 170 160 else if (negativeValuesMode == ForbidNegativeLengths && length.valueInSpecifiedUnits() < 0) … … 186 176 float SVGLength::value(const SVGLengthContext& context) const 187 177 { 188 return value(context, IGNORE_EXCEPTION); 189 } 190 191 float SVGLength::value(const SVGLengthContext& context, ExceptionCode& ec) const 192 { 193 return context.convertValueToUserUnits(m_valueInSpecifiedUnits, extractMode(m_unit), extractType(m_unit), ec); 194 } 195 196 void SVGLength::setValue(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType, ExceptionCode& ec) 197 { 178 auto result = valueForBindings(context); 179 if (result.hasException()) 180 return 0; 181 return result.releaseReturnValue(); 182 } 183 184 ExceptionOr<float> SVGLength::valueForBindings(const SVGLengthContext& context) const 185 { 186 return context.convertValueToUserUnits(m_valueInSpecifiedUnits, extractMode(m_unit), extractType(m_unit)); 187 } 188 189 ExceptionOr<void> SVGLength::setValue(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType) 190 { 191 // FIXME: Seems like a bug that we change the value of m_unit even if setValue throws an exception. 198 192 m_unit = storeUnit(mode, unitType); 199 setValue(value, context, ec);200 } 201 202 void SVGLength::setValue(float value, const SVGLengthContext& context, ExceptionCode& ec)193 return setValue(value, context); 194 } 195 196 ExceptionOr<void> SVGLength::setValue(float value, const SVGLengthContext& context) 203 197 { 204 198 // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed … … 206 200 value = value / 100; 207 201 208 ec = 0; 209 float convertedValue = context.convertValueFromUserUnits(value, extractMode(m_unit), extractType(m_unit), ec); 210 if (!ec) 211 m_valueInSpecifiedUnits = convertedValue; 202 auto convertedValue = context.convertValueFromUserUnits(value, extractMode(m_unit), extractType(m_unit)); 203 if (convertedValue.hasException()) 204 return convertedValue.releaseException(); 205 m_valueInSpecifiedUnits = convertedValue.releaseReturnValue(); 206 return { }; 212 207 } 213 208 float SVGLength::valueAsPercentage() const … … 220 215 } 221 216 222 void SVGLength::setValueAsString(const String& string, ExceptionCode& ec)217 ExceptionOr<void> SVGLength::setValueAsString(const String& string) 223 218 { 224 219 if (string.isEmpty()) 225 return ;220 return { }; 226 221 227 222 float convertedNumber = 0; … … 230 225 const UChar* end = ptr + string.length(); 231 226 232 if (!parseNumber(ptr, end, convertedNumber, false)) { 233 ec = SYNTAX_ERR; 234 return; 235 } 236 237 SVGLengthType type = stringToLengthType(ptr, end); 238 ASSERT(ptr <= end); 239 if (type == LengthTypeUnknown) { 240 ec = SYNTAX_ERR; 241 return; 242 } 227 if (!parseNumber(ptr, end, convertedNumber, false)) 228 return Exception { SYNTAX_ERR }; 229 230 auto type = parseLengthType(ptr, end); 231 if (type == LengthTypeUnknown) 232 return Exception { SYNTAX_ERR }; 243 233 244 234 m_unit = storeUnit(extractMode(m_unit), type); 245 235 m_valueInSpecifiedUnits = convertedNumber; 236 return { }; 246 237 } 247 238 … … 251 242 } 252 243 253 void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, ExceptionCode& ec) 254 { 255 if (type == LengthTypeUnknown || type > LengthTypePC) { 256 ec = NOT_SUPPORTED_ERR; 257 return; 258 } 244 ExceptionOr<void> SVGLength::newValueSpecifiedUnits(unsigned short type, float value) 245 { 246 if (type == LengthTypeUnknown || type > LengthTypePC) 247 return Exception { NOT_SUPPORTED_ERR }; 259 248 260 249 m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type)); 261 250 m_valueInSpecifiedUnits = value; 262 } 263 264 void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGLengthContext& context, ExceptionCode& ec) 265 { 266 if (type == LengthTypeUnknown || type > LengthTypePC) { 267 ec = NOT_SUPPORTED_ERR; 268 return; 251 return { }; 252 } 253 254 ExceptionOr<void> SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGLengthContext& context) 255 { 256 if (type == LengthTypeUnknown || type > LengthTypePC) 257 return Exception { NOT_SUPPORTED_ERR }; 258 259 auto valueInUserUnits = valueForBindings(context); 260 if (valueInUserUnits.hasException()) 261 return valueInUserUnits.releaseException(); 262 263 auto originalUnitAndType = m_unit; 264 m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type)); 265 auto result = setValue(valueInUserUnits.releaseReturnValue(), context); 266 if (result.hasException()) { 267 m_unit = originalUnitAndType; 268 return result.releaseException(); 269 269 } 270 270 271 float valueInUserUnits = value(context, ec); 272 if (ec) 273 return; 274 275 unsigned int originalUnitAndType = m_unit; 276 m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type)); 277 setValue(valueInUserUnits, context, ec); 278 if (!ec) 279 return; 280 281 // Eventually restore old unit and type 282 m_unit = originalUnitAndType; 271 return { }; 283 272 } 284 273 … … 326 315 return SVGLength(); 327 316 328 ExceptionCode ec = 0;329 317 SVGLength length; 330 length.newValueSpecifiedUnits(svgType, value.floatValue(), ec); 331 if (ec) 332 return SVGLength(); 333 318 length.newValueSpecifiedUnits(svgType, value.floatValue()); 334 319 return length; 335 320 } … … 378 363 SVGLengthMode SVGLength::lengthModeForAnimatedLengthAttribute(const QualifiedName& attrName) 379 364 { 380 typedef HashMap<QualifiedName, SVGLengthMode> LengthModeForLengthAttributeMap; 381 static NeverDestroyed<LengthModeForLengthAttributeMap> s_lengthModeMap; 365 using Map = HashMap<QualifiedName, SVGLengthMode>; 366 static NeverDestroyed<Map> map = [] { 367 struct Mode { 368 const QualifiedName& name; 369 SVGLengthMode mode; 370 }; 371 static const Mode modes[] = { 372 { SVGNames::xAttr, LengthModeWidth }, 373 { SVGNames::yAttr, LengthModeHeight }, 374 { SVGNames::cxAttr, LengthModeWidth }, 375 { SVGNames::cyAttr, LengthModeHeight }, 376 { SVGNames::dxAttr, LengthModeWidth }, 377 { SVGNames::dyAttr, LengthModeHeight }, 378 { SVGNames::fxAttr, LengthModeWidth }, 379 { SVGNames::fyAttr, LengthModeHeight }, 380 { SVGNames::widthAttr, LengthModeWidth }, 381 { SVGNames::heightAttr, LengthModeHeight }, 382 { SVGNames::x1Attr, LengthModeWidth }, 383 { SVGNames::x2Attr, LengthModeWidth }, 384 { SVGNames::y1Attr, LengthModeHeight }, 385 { SVGNames::y2Attr, LengthModeHeight }, 386 { SVGNames::refXAttr, LengthModeWidth }, 387 { SVGNames::refYAttr, LengthModeHeight }, 388 { SVGNames::markerWidthAttr, LengthModeWidth }, 389 { SVGNames::markerHeightAttr, LengthModeHeight }, 390 { SVGNames::textLengthAttr, LengthModeWidth }, 391 { SVGNames::startOffsetAttr, LengthModeWidth }, 392 }; 393 Map map; 394 for (auto& mode : modes) 395 map.add(mode.name, mode.mode); 396 return map; 397 }(); 382 398 383 if (s_lengthModeMap.get().isEmpty()) { 384 s_lengthModeMap.get().set(SVGNames::xAttr, LengthModeWidth); 385 s_lengthModeMap.get().set(SVGNames::yAttr, LengthModeHeight); 386 s_lengthModeMap.get().set(SVGNames::cxAttr, LengthModeWidth); 387 s_lengthModeMap.get().set(SVGNames::cyAttr, LengthModeHeight); 388 s_lengthModeMap.get().set(SVGNames::dxAttr, LengthModeWidth); 389 s_lengthModeMap.get().set(SVGNames::dyAttr, LengthModeHeight); 390 s_lengthModeMap.get().set(SVGNames::fxAttr, LengthModeWidth); 391 s_lengthModeMap.get().set(SVGNames::fyAttr, LengthModeHeight); 392 s_lengthModeMap.get().set(SVGNames::rAttr, LengthModeOther); 393 s_lengthModeMap.get().set(SVGNames::widthAttr, LengthModeWidth); 394 s_lengthModeMap.get().set(SVGNames::heightAttr, LengthModeHeight); 395 s_lengthModeMap.get().set(SVGNames::x1Attr, LengthModeWidth); 396 s_lengthModeMap.get().set(SVGNames::x2Attr, LengthModeWidth); 397 s_lengthModeMap.get().set(SVGNames::y1Attr, LengthModeHeight); 398 s_lengthModeMap.get().set(SVGNames::y2Attr, LengthModeHeight); 399 s_lengthModeMap.get().set(SVGNames::refXAttr, LengthModeWidth); 400 s_lengthModeMap.get().set(SVGNames::refYAttr, LengthModeHeight); 401 s_lengthModeMap.get().set(SVGNames::markerWidthAttr, LengthModeWidth); 402 s_lengthModeMap.get().set(SVGNames::markerHeightAttr, LengthModeHeight); 403 s_lengthModeMap.get().set(SVGNames::textLengthAttr, LengthModeWidth); 404 s_lengthModeMap.get().set(SVGNames::startOffsetAttr, LengthModeWidth); 405 } 406 407 if (s_lengthModeMap.get().contains(attrName)) 408 return s_lengthModeMap.get().get(attrName); 409 410 return LengthModeOther; 399 auto result = map.get().find(attrName); 400 if (result == map.get().end()) 401 return LengthModeOther; 402 return result->value; 411 403 } 412 404 -
trunk/Source/WebCore/svg/SVGLength.h
r200341 r207716 19 19 */ 20 20 21 #ifndef SVGLength_h 22 #define SVGLength_h 21 #pragma once 23 22 24 23 #include "AnimationUtilities.h" … … 31 30 class CSSPrimitiveValue; 32 31 class QualifiedName; 33 34 typedef int ExceptionCode;35 32 36 33 enum SVGLengthNegativeValuesMode { … … 60 57 SVGLength(SVGLengthMode = LengthModeOther, const String& valueAsString = String()); 61 58 SVGLength(const SVGLengthContext&, float, SVGLengthMode = LengthModeOther, SVGLengthType = LengthTypeNumber); 62 SVGLength(const SVGLength&);63 59 64 60 SVGLengthType unitType() const; … … 71 67 72 68 float value(const SVGLengthContext&) const; 73 float value(const SVGLengthContext&, ExceptionCode&) const;74 void setValue(float, const SVGLengthContext&, ExceptionCode&);75 void setValue(const SVGLengthContext&, float, SVGLengthMode, SVGLengthType, ExceptionCode&);69 ExceptionOr<float> valueForBindings(const SVGLengthContext&) const; 70 ExceptionOr<void> setValue(float, const SVGLengthContext&); 71 ExceptionOr<void> setValue(const SVGLengthContext&, float, SVGLengthMode, SVGLengthType); 76 72 77 73 float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; } … … 81 77 82 78 String valueAsString() const; 83 void setValueAsString(const String&, ExceptionCode&);84 void setValueAsString(const String&, SVGLengthMode, ExceptionCode&);79 ExceptionOr<void> setValueAsString(const String&); 80 ExceptionOr<void> setValueAsString(const String&, SVGLengthMode); 85 81 86 void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits, ExceptionCode&);87 void convertToSpecifiedUnits(unsigned short, const SVGLengthContext&, ExceptionCode&);82 ExceptionOr<void> newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits); 83 ExceptionOr<void> convertToSpecifiedUnits(unsigned short, const SVGLengthContext&); 88 84 89 85 // Helper functions 90 inlinebool isRelative() const86 bool isRelative() const 91 87 { 92 88 SVGLengthType type = unitType(); … … 95 91 96 92 bool isZero() const 97 { 93 { 98 94 return !m_valueInSpecifiedUnits; 99 95 } … … 116 112 117 113 SVGLength length; 118 ExceptionCode ec = 0;119 114 120 115 if (fromType == LengthTypePercentage || toType == LengthTypePercentage) { 121 116 float fromPercent = from.valueAsPercentage() * 100; 122 117 float toPercent = valueAsPercentage() * 100; 123 length.newValueSpecifiedUnits(LengthTypePercentage, WebCore::blend(fromPercent, toPercent, progress), ec);124 if ( ec)118 auto result = length.newValueSpecifiedUnits(LengthTypePercentage, WebCore::blend(fromPercent, toPercent, progress)); 119 if (result.hasException()) 125 120 return SVGLength(); 126 121 return length; … … 130 125 float fromValue = from.valueInSpecifiedUnits(); 131 126 float toValue = valueInSpecifiedUnits(); 132 if (isZero()) 133 length.newValueSpecifiedUnits(fromType, WebCore::blend(fromValue, toValue, progress), ec); 134 else 135 length.newValueSpecifiedUnits(toType, WebCore::blend(fromValue, toValue, progress), ec); 136 if (ec) 137 return SVGLength(); 127 if (isZero()) { 128 auto result = length.newValueSpecifiedUnits(fromType, WebCore::blend(fromValue, toValue, progress)); 129 if (result.hasException()) 130 return SVGLength(); 131 } else { 132 auto result = length.newValueSpecifiedUnits(toType, WebCore::blend(fromValue, toValue, progress)); 133 if (result.hasException()) 134 return SVGLength(); 135 } 138 136 return length; 139 137 } … … 143 141 144 142 SVGLengthContext nonRelativeLengthContext(nullptr); 145 float fromValueInUserUnits = nonRelativeLengthContext.convertValueToUserUnits(from.valueInSpecifiedUnits(), from.unitMode(), fromType, ec);146 if ( ec)143 auto fromValueInUserUnits = nonRelativeLengthContext.convertValueToUserUnits(from.valueInSpecifiedUnits(), from.unitMode(), fromType); 144 if (fromValueInUserUnits.hasException()) 147 145 return SVGLength(); 148 146 149 float fromValue = nonRelativeLengthContext.convertValueFromUserUnits(fromValueInUserUnits, unitMode(), toType, ec);150 if ( ec)147 auto fromValue = nonRelativeLengthContext.convertValueFromUserUnits(fromValueInUserUnits.releaseReturnValue(), unitMode(), toType); 148 if (fromValue.hasException()) 151 149 return SVGLength(); 152 150 153 151 float toValue = valueInSpecifiedUnits(); 154 length.newValueSpecifiedUnits(toType, WebCore::blend(fromValue, toValue, progress), ec); 155 156 if (ec) 152 auto result = length.newValueSpecifiedUnits(toType, WebCore::blend(fromValue.releaseReturnValue(), toValue, progress)); 153 if (result.hasException()) 157 154 return SVGLength(); 158 155 return length; … … 161 158 private: 162 159 float m_valueInSpecifiedUnits; 163 unsigned intm_unit;160 unsigned m_unit; 164 161 }; 165 162 166 template<> 167 struct SVGPropertyTraits<SVGLength> { 163 template<> struct SVGPropertyTraits<SVGLength> { 168 164 static SVGLength initialValue() { return SVGLength(); } 169 165 static String toString(const SVGLength& type) { return type.valueAsString(); } … … 173 169 174 170 } // namespace WebCore 175 176 #endif // SVGLength_h -
trunk/Source/WebCore/svg/SVGLength.idl
r206723 r207716 23 23 interface SVGLength { 24 24 // Length Unit Types 25 const unsigned short SVG_LENGTHTYPE_UNKNOWN 26 const unsigned short SVG_LENGTHTYPE_NUMBER 25 const unsigned short SVG_LENGTHTYPE_UNKNOWN = 0; 26 const unsigned short SVG_LENGTHTYPE_NUMBER = 1; 27 27 const unsigned short SVG_LENGTHTYPE_PERCENTAGE = 2; 28 const unsigned short SVG_LENGTHTYPE_EMS 29 const unsigned short SVG_LENGTHTYPE_EXS 30 const unsigned short SVG_LENGTHTYPE_PX 31 const unsigned short SVG_LENGTHTYPE_CM 32 const unsigned short SVG_LENGTHTYPE_MM 33 const unsigned short SVG_LENGTHTYPE_IN 34 const unsigned short SVG_LENGTHTYPE_PT 35 const unsigned short SVG_LENGTHTYPE_PC 28 const unsigned short SVG_LENGTHTYPE_EMS = 3; 29 const unsigned short SVG_LENGTHTYPE_EXS = 4; 30 const unsigned short SVG_LENGTHTYPE_PX = 5; 31 const unsigned short SVG_LENGTHTYPE_CM = 6; 32 const unsigned short SVG_LENGTHTYPE_MM = 7; 33 const unsigned short SVG_LENGTHTYPE_IN = 8; 34 const unsigned short SVG_LENGTHTYPE_PT = 9; 35 const unsigned short SVG_LENGTHTYPE_PC = 10; 36 36 37 37 readonly attribute unsigned short unitType; 38 [ GetterMayThrowLegacyException, SetterMayThrowLegacyException, Custom] attribute unrestricted float value;38 [Custom, GetterMayThrowException, SetterMayThrowException] attribute unrestricted float value; 39 39 40 40 attribute unrestricted float valueInSpecifiedUnits; 41 [SetterMayThrowException] attribute DOMString valueAsString; 41 42 42 [SetterMayThrowLegacyException] attribute DOMString valueAsString; 43 44 [MayThrowLegacyException] void newValueSpecifiedUnits(unsigned short unitType, 45 unrestricted float valueInSpecifiedUnits); 46 47 [Custom, MayThrowLegacyException] void convertToSpecifiedUnits(unsigned short unitType); 43 [MayThrowException] void newValueSpecifiedUnits(unsigned short unitType, unrestricted float valueInSpecifiedUnits); 44 [Custom, MayThrowException] void convertToSpecifiedUnits(unsigned short unitType); 48 45 }; 49 -
trunk/Source/WebCore/svg/SVGLengthContext.cpp
r205392 r207716 90 90 float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode) 91 91 { 92 if (length.isPercent()) 93 return convertValueFromPercentageToUserUnits(length.value() / 100, mode, IGNORE_EXCEPTION); 92 if (length.isPercent()) { 93 auto result = convertValueFromPercentageToUserUnits(length.value() / 100, mode); 94 if (result.hasException()) 95 return 0; 96 return result.releaseReturnValue(); 97 } 94 98 if (length.isAuto() || !length.isSpecified()) 95 99 return 0; … … 104 108 return floatValueForLength(length, viewportSize.height()); 105 109 case LengthModeOther: 106 return floatValueForLength(length, s qrtf(viewportSize.diagonalLengthSquared() / 2));110 return floatValueForLength(length, std::sqrt(viewportSize.diagonalLengthSquared() / 2)); 107 111 }; 108 112 return 0; 109 113 } 110 114 111 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit, ExceptionCode& ec) const115 ExceptionOr<float> SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit) const 112 116 { 113 117 // If the SVGLengthContext carries a custom viewport, force resolving against it. … … 116 120 if (fromUnit == LengthTypePercentage) 117 121 value /= 100; 118 return convertValueFromPercentageToUserUnits(value, mode , ec);122 return convertValueFromPercentageToUserUnits(value, mode); 119 123 } 120 124 121 125 switch (fromUnit) { 122 126 case LengthTypeUnknown: 123 ec = NOT_SUPPORTED_ERR; 124 return 0; 127 return Exception { NOT_SUPPORTED_ERR }; 125 128 case LengthTypeNumber: 126 129 return value; … … 128 131 return value; 129 132 case LengthTypePercentage: 130 return convertValueFromPercentageToUserUnits(value / 100, mode , ec);133 return convertValueFromPercentageToUserUnits(value / 100, mode); 131 134 case LengthTypeEMS: 132 return convertValueFromEMSToUserUnits(value , ec);135 return convertValueFromEMSToUserUnits(value); 133 136 case LengthTypeEXS: 134 return convertValueFromEXSToUserUnits(value , ec);137 return convertValueFromEXSToUserUnits(value); 135 138 case LengthTypeCM: 136 139 return value * cssPixelsPerInch / 2.54f; … … 149 152 } 150 153 151 float SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mode, SVGLengthType toUnit, ExceptionCode& ec) const154 ExceptionOr<float> SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mode, SVGLengthType toUnit) const 152 155 { 153 156 switch (toUnit) { 154 157 case LengthTypeUnknown: 155 ec = NOT_SUPPORTED_ERR; 156 return 0; 158 return Exception { NOT_SUPPORTED_ERR }; 157 159 case LengthTypeNumber: 158 160 return value; 159 161 case LengthTypePercentage: 160 return convertValueFromUserUnitsToPercentage(value * 100, mode , ec);162 return convertValueFromUserUnitsToPercentage(value * 100, mode); 161 163 case LengthTypeEMS: 162 return convertValueFromUserUnitsToEMS(value , ec);164 return convertValueFromUserUnitsToEMS(value); 163 165 case LengthTypeEXS: 164 return convertValueFromUserUnitsToEXS(value , ec);166 return convertValueFromUserUnitsToEXS(value); 165 167 case LengthTypePX: 166 168 return value; … … 181 183 } 182 184 183 float SVGLengthContext::convertValueFromUserUnitsToPercentage(float value, SVGLengthMode mode, ExceptionCode& ec) const185 ExceptionOr<float> SVGLengthContext::convertValueFromUserUnitsToPercentage(float value, SVGLengthMode mode) const 184 186 { 185 187 FloatSize viewportSize; 186 if (!determineViewport(viewportSize)) { 187 ec = NOT_SUPPORTED_ERR; 188 return 0; 189 } 188 if (!determineViewport(viewportSize)) 189 return Exception { NOT_SUPPORTED_ERR }; 190 190 191 191 switch (mode) { … … 195 195 return value / viewportSize.height() * 100; 196 196 case LengthModeOther: 197 return value / (s qrtf(viewportSize.diagonalLengthSquared() / 2)) * 100;197 return value / (std::sqrt(viewportSize.diagonalLengthSquared() / 2)) * 100; 198 198 }; 199 199 … … 202 202 } 203 203 204 float SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLengthMode mode, ExceptionCode& ec) const204 ExceptionOr<float> SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLengthMode mode) const 205 205 { 206 206 FloatSize viewportSize; 207 if (!determineViewport(viewportSize)) { 208 ec = NOT_SUPPORTED_ERR; 209 return 0; 210 } 207 if (!determineViewport(viewportSize)) 208 return Exception { NOT_SUPPORTED_ERR }; 211 209 212 210 switch (mode) { … … 216 214 return value * viewportSize.height(); 217 215 case LengthModeOther: 218 return value * s qrtf(viewportSize.diagonalLengthSquared() / 2);216 return value * std::sqrt(viewportSize.diagonalLengthSquared() / 2); 219 217 }; 220 218 … … 240 238 } 241 239 242 float SVGLengthContext::convertValueFromUserUnitsToEMS(float value, ExceptionCode& ec) const240 ExceptionOr<float> SVGLengthContext::convertValueFromUserUnitsToEMS(float value) const 243 241 { 244 242 auto* style = renderStyleForLengthResolving(m_context); 245 if (!style) { 246 ec = NOT_SUPPORTED_ERR; 247 return 0; 248 } 243 if (!style) 244 return Exception { NOT_SUPPORTED_ERR }; 249 245 250 246 float fontSize = style->fontSize(); 251 if (!fontSize) { 252 ec = NOT_SUPPORTED_ERR; 253 return 0; 254 } 247 if (!fontSize) 248 return Exception { NOT_SUPPORTED_ERR }; 255 249 256 250 return value / fontSize; 257 251 } 258 252 259 float SVGLengthContext::convertValueFromEMSToUserUnits(float value, ExceptionCode& ec) const253 ExceptionOr<float> SVGLengthContext::convertValueFromEMSToUserUnits(float value) const 260 254 { 261 255 auto* style = renderStyleForLengthResolving(m_context); 262 if (!style) { 263 ec = NOT_SUPPORTED_ERR; 264 return 0; 265 } 256 if (!style) 257 return Exception { NOT_SUPPORTED_ERR }; 266 258 267 259 return value * style->fontSize(); 268 260 } 269 261 270 float SVGLengthContext::convertValueFromUserUnitsToEXS(float value, ExceptionCode& ec) const262 ExceptionOr<float> SVGLengthContext::convertValueFromUserUnitsToEXS(float value) const 271 263 { 272 264 auto* style = renderStyleForLengthResolving(m_context); 273 if (!style) { 274 ec = NOT_SUPPORTED_ERR; 275 return 0; 276 } 265 if (!style) 266 return Exception { NOT_SUPPORTED_ERR }; 277 267 278 268 // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg 279 269 // if this causes problems in real world cases maybe it would be best to remove this 280 float xHeight = ceilf(style->fontMetrics().xHeight()); 281 if (!xHeight) { 282 ec = NOT_SUPPORTED_ERR; 283 return 0; 284 } 270 float xHeight = std::ceil(style->fontMetrics().xHeight()); 271 if (!xHeight) 272 return Exception { NOT_SUPPORTED_ERR }; 285 273 286 274 return value / xHeight; 287 275 } 288 276 289 float SVGLengthContext::convertValueFromEXSToUserUnits(float value, ExceptionCode& ec) const277 ExceptionOr<float> SVGLengthContext::convertValueFromEXSToUserUnits(float value) const 290 278 { 291 279 auto* style = renderStyleForLengthResolving(m_context); 292 if (!style) { 293 ec = NOT_SUPPORTED_ERR; 294 return 0; 295 } 280 if (!style) 281 return Exception { NOT_SUPPORTED_ERR }; 296 282 297 283 // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg 298 284 // if this causes problems in real world cases maybe it would be best to remove this 299 return value * ceilf(style->fontMetrics().xHeight());285 return value * std::ceil(style->fontMetrics().xHeight()); 300 286 } 301 287 -
trunk/Source/WebCore/svg/SVGLengthContext.h
r171341 r207716 18 18 */ 19 19 20 #ifndef SVGLengthContext_h 21 #define SVGLengthContext_h 20 #pragma once 22 21 22 #include "ExceptionOr.h" 23 23 #include "FloatRect.h" 24 24 #include "SVGUnitTypes.h" … … 28 28 class SVGElement; 29 29 class SVGLength; 30 30 31 struct Length; 31 32 typedef int ExceptionCode;33 32 34 33 enum SVGLengthType { … … 67 66 68 67 float valueForLength(const Length&, SVGLengthMode = LengthModeOther); 69 float convertValueToUserUnits(float, SVGLengthMode, SVGLengthType fromUnit, ExceptionCode&) const;70 float convertValueFromUserUnits(float, SVGLengthMode, SVGLengthType toUnit, ExceptionCode&) const;68 ExceptionOr<float> convertValueToUserUnits(float, SVGLengthMode, SVGLengthType fromUnit) const; 69 ExceptionOr<float> convertValueFromUserUnits(float, SVGLengthMode, SVGLengthType toUnit) const; 71 70 72 71 bool determineViewport(FloatSize&) const; … … 75 74 SVGLengthContext(const SVGElement*, const FloatRect& viewport); 76 75 77 float convertValueFromUserUnitsToPercentage(float value, SVGLengthMode, ExceptionCode&) const;78 float convertValueFromPercentageToUserUnits(float value, SVGLengthMode, ExceptionCode&) const;76 ExceptionOr<float> convertValueFromUserUnitsToPercentage(float value, SVGLengthMode) const; 77 ExceptionOr<float> convertValueFromPercentageToUserUnits(float value, SVGLengthMode) const; 79 78 80 float convertValueFromUserUnitsToEMS(float value, ExceptionCode&) const;81 float convertValueFromEMSToUserUnits(float value, ExceptionCode&) const;79 ExceptionOr<float> convertValueFromUserUnitsToEMS(float value) const; 80 ExceptionOr<float> convertValueFromEMSToUserUnits(float value) const; 82 81 83 float convertValueFromUserUnitsToEXS(float value, ExceptionCode&) const;84 float convertValueFromEXSToUserUnits(float value, ExceptionCode&) const;82 ExceptionOr<float> convertValueFromUserUnitsToEXS(float value) const; 83 ExceptionOr<float> convertValueFromEXSToUserUnits(float value) const; 85 84 86 85 const SVGElement* m_context; … … 89 88 90 89 } // namespace WebCore 91 92 #endif // SVGLengthContext_h -
trunk/Source/WebCore/svg/SVGLengthList.cpp
r165848 r207716 30 30 { 31 31 clear(); 32 ExceptionCode ec = 0;33 32 34 33 auto upconvertedCharacters = StringView(value).upconvertedCharacters(); … … 46 45 if (valueString.isEmpty()) 47 46 return; 48 length.setValueAsString(valueString, ec); 49 if (ec) 47 if (length.setValueAsString(valueString).hasException()) 50 48 return; 51 49 append(length); -
trunk/Source/WebCore/svg/SVGLengthList.h
r203275 r207716 19 19 */ 20 20 21 #ifndef SVGLengthList_h 22 #define SVGLengthList_h 21 #pragma once 23 22 24 23 #include "SVGLength.h" … … 29 28 class SVGLengthList final : public Vector<SVGLength> { 30 29 public: 31 SVGLengthList() { } 32 33 void parse(const String& value, SVGLengthMode); 30 void parse(const String& value, SVGLengthMode); 34 31 String valueAsString() const; 35 32 }; 36 33 37 template<> 38 struct SVGPropertyTraits<SVGLengthList> { 34 template<> struct SVGPropertyTraits<SVGLengthList> { 39 35 typedef SVGLength ListItemType; 40 36 … … 44 40 45 41 } // namespace WebCore 46 47 #endif -
trunk/Source/WebCore/svg/SVGLengthList.idl
r206723 r207716 28 28 readonly attribute unsigned long numberOfItems; 29 29 30 [MayThrow LegacyException] void clear();31 [MayThrow LegacyException] SVGLength initialize(SVGLength item);32 [MayThrow LegacyException] SVGLength getItem(unsigned long index);33 [MayThrow LegacyException] SVGLength insertItemBefore(SVGLength item, unsigned long index);34 [MayThrow LegacyException] SVGLength replaceItem(SVGLength item, unsigned long index);35 [MayThrow LegacyException] SVGLength removeItem(unsigned long index);36 [MayThrow LegacyException] SVGLength appendItem(SVGLength item);30 [MayThrowException] void clear(); 31 [MayThrowException] SVGLength initialize(SVGLength item); 32 [MayThrowException] SVGLength getItem(unsigned long index); 33 [MayThrowException] SVGLength insertItemBefore(SVGLength item, unsigned long index); 34 [MayThrowException] SVGLength replaceItem(SVGLength item, unsigned long index); 35 [MayThrowException] SVGLength removeItem(unsigned long index); 36 [MayThrowException] SVGLength appendItem(SVGLength item); 37 37 }; -
trunk/Source/WebCore/svg/SVGLocatable.cpp
r192900 r207716 98 98 } 99 99 100 AffineTransform SVGLocatable::getTransformToElement(SVGElement* target, ExceptionCode& ec, StyleUpdateStrategy styleUpdateStrategy)100 ExceptionOr<AffineTransform> SVGLocatable::getTransformToElement(SVGElement* target, StyleUpdateStrategy styleUpdateStrategy) 101 101 { 102 102 AffineTransform ctm = getCTM(styleUpdateStrategy); … … 106 106 if (auto inverse = targetCTM.inverse()) 107 107 ctm = inverse.value() * ctm; 108 else { 109 ec = SVGException::SVG_MATRIX_NOT_INVERTABLE; 110 return ctm; 111 } 108 else 109 return Exception { SVGException::SVG_MATRIX_NOT_INVERTABLE }; 112 110 } 113 111 114 return ctm;112 return WTFMove(ctm); 115 113 } 116 114 -
trunk/Source/WebCore/svg/SVGLocatable.h
r163440 r207716 20 20 */ 21 21 22 #ifndef SVGLocatable_h 23 #define SVGLocatable_h 22 #pragma once 24 23 25 24 #include "AffineTransform.h" 25 #include "ExceptionOr.h" 26 26 27 27 namespace WebCore { … … 29 29 class FloatRect; 30 30 class SVGElement; 31 32 typedef int ExceptionCode;33 31 34 32 class SVGLocatable { … … 45 43 virtual AffineTransform getCTM(StyleUpdateStrategy) = 0; 46 44 virtual AffineTransform getScreenCTM(StyleUpdateStrategy) = 0; 47 AffineTransform getTransformToElement(SVGElement*, ExceptionCode&, StyleUpdateStrategy = AllowStyleUpdate);45 ExceptionOr<AffineTransform> getTransformToElement(SVGElement*, StyleUpdateStrategy = AllowStyleUpdate); 48 46 49 47 static SVGElement* nearestViewportElement(const SVGElement*); … … 63 61 64 62 } // namespace WebCore 65 66 #endif // SVGLocatable_h -
trunk/Source/WebCore/svg/SVGMarkerElement.h
r200041 r207716 82 82 inline unsigned SVGIDLEnumLimits<SVGMarkerOrientType>::highestExposedEnumValue() { return SVGMarkerOrientAngle; } 83 83 84 template<> 85 struct SVGPropertyTraits<SVGMarkerOrientType> { 84 template<> struct SVGPropertyTraits<SVGMarkerOrientType> { 86 85 static unsigned highestEnumValue() { return SVGMarkerOrientAutoStartReverse; } 87 86 … … 94 93 if (value == "auto-start-reverse") 95 94 return SVGMarkerOrientAutoStartReverse; 96 97 ExceptionCode ec = 0; 98 angle.setValueAsString(value, ec); 99 if (!ec) 100 return SVGMarkerOrientAngle; 101 return SVGMarkerOrientUnknown; 95 auto setValueResult = angle.setValueAsString(value); 96 if (setValueResult.hasException()) 97 return SVGMarkerOrientUnknown; 98 return SVGMarkerOrientAngle; 102 99 } 103 100 }; -
trunk/Source/WebCore/svg/SVGMatrix.h
r203275 r207716 18 18 */ 19 19 20 #ifndef SVGMatrix_h 21 #define SVGMatrix_h 20 #pragma once 22 21 23 22 #include "AffineTransform.h" 23 #include "ExceptionOr.h" 24 24 #include "SVGException.h" 25 25 26 26 namespace WebCore { 27 27 28 typedef int ExceptionCode;29 30 // Only used in the bindings.31 28 class SVGMatrix final : public AffineTransform { 32 29 public: … … 44 41 SVGMatrix translate(double tx, double ty) 45 42 { 46 AffineTransform copy = *this;43 AffineTransform copy { *this }; 47 44 copy.translate(tx, ty); 48 return static_cast<SVGMatrix>(copy);45 return SVGMatrix { copy }; 49 46 } 50 47 51 48 SVGMatrix scale(double s) 52 49 { 53 AffineTransform copy = *this;50 AffineTransform copy { *this }; 54 51 copy.scale(s, s); 55 return static_cast<SVGMatrix>(copy);52 return SVGMatrix { copy }; 56 53 } 57 54 58 55 SVGMatrix scaleNonUniform(double sx, double sy) 59 56 { 60 AffineTransform copy = *this;57 AffineTransform copy { *this }; 61 58 copy.scale(sx, sy); 62 return static_cast<SVGMatrix>(copy);59 return SVGMatrix { copy }; 63 60 } 64 61 65 62 SVGMatrix rotate(double d) 66 63 { 67 AffineTransform copy = *this;64 AffineTransform copy { *this }; 68 65 copy.rotate(d); 69 return static_cast<SVGMatrix>(copy);66 return SVGMatrix { copy }; 70 67 } 71 68 72 69 SVGMatrix flipX() 73 70 { 74 AffineTransform copy = *this;71 AffineTransform copy { *this }; 75 72 copy.flipX(); 76 return static_cast<SVGMatrix>(copy);73 return SVGMatrix { copy }; 77 74 } 78 75 79 76 SVGMatrix flipY() 80 77 { 81 AffineTransform copy = *this;78 AffineTransform copy { *this }; 82 79 copy.flipY(); 83 return static_cast<SVGMatrix>(copy);80 return SVGMatrix { copy }; 84 81 } 85 82 86 83 SVGMatrix skewX(double angle) 87 84 { 88 AffineTransform copy = *this;85 AffineTransform copy { *this }; 89 86 copy.skewX(angle); 90 return static_cast<SVGMatrix>(copy);87 return SVGMatrix { copy }; 91 88 } 92 89 93 90 SVGMatrix skewY(double angle) 94 91 { 95 AffineTransform copy = *this;92 AffineTransform copy { *this }; 96 93 copy.skewY(angle); 97 return static_cast<SVGMatrix>(copy);94 return SVGMatrix { copy }; 98 95 } 99 96 100 97 SVGMatrix multiply(const SVGMatrix& other) 101 98 { 102 AffineTransform copy = *this;99 AffineTransform copy { *this }; 103 100 copy *= static_cast<const AffineTransform&>(other); 104 return static_cast<SVGMatrix>(copy);101 return SVGMatrix { copy }; 105 102 } 106 103 107 SVGMatrix inverse(ExceptionCode& ec) const104 ExceptionOr<SVGMatrix> inverse() const 108 105 { 109 106 if (auto inverse = AffineTransform::inverse()) 110 return inverse.value();107 return SVGMatrix { inverse.value() }; 111 108 112 ec = SVGException::SVG_MATRIX_NOT_INVERTABLE; 113 return AffineTransform(); 109 return Exception { SVGException::SVG_MATRIX_NOT_INVERTABLE }; 114 110 } 115 111 116 SVGMatrix rotateFromVector(double x, double y, ExceptionCode& ec)112 ExceptionOr<SVGMatrix> rotateFromVector(double x, double y) 117 113 { 118 114 if (!x || !y) 119 ec = SVGException::SVG_INVALID_VALUE_ERR;115 return Exception { SVGException::SVG_INVALID_VALUE_ERR }; 120 116 121 AffineTransform copy = *this;117 AffineTransform copy { *this }; 122 118 copy.rotateFromVector(x, y); 123 return static_cast<SVGMatrix>(copy);119 return SVGMatrix { copy }; 124 120 } 125 121 … … 127 123 128 124 } // namespace WebCore 129 130 #endif -
trunk/Source/WebCore/svg/SVGMatrix.idl
r206723 r207716 32 32 33 33 SVGMatrix multiply(SVGMatrix secondMatrix); 34 [MayThrow LegacyException] SVGMatrix inverse();34 [MayThrowException] SVGMatrix inverse(); 35 35 [Immutable] SVGMatrix translate(unrestricted float x, unrestricted float y); 36 36 [Immutable] SVGMatrix scale(unrestricted float scaleFactor); 37 37 [Immutable] SVGMatrix scaleNonUniform(unrestricted float scaleFactorX, unrestricted float scaleFactorY); 38 38 [Immutable] SVGMatrix rotate(unrestricted float angle); 39 [MayThrow LegacyException] SVGMatrix rotateFromVector(unrestricted float x, unrestricted float y);39 [MayThrowException] SVGMatrix rotateFromVector(unrestricted float x, unrestricted float y); 40 40 [Immutable] SVGMatrix flipX(); 41 41 [Immutable] SVGMatrix flipY(); … … 43 43 [Immutable] SVGMatrix skewY(unrestricted float angle); 44 44 }; 45 -
trunk/Source/WebCore/svg/SVGNumberList.h
r203275 r207716 19 19 */ 20 20 21 #ifndef SVGNumberList_h 22 #define SVGNumberList_h 21 #pragma once 23 22 24 23 #include "SVGPropertyTraits.h" … … 29 28 class SVGNumberList final : public Vector<float> { 30 29 public: 31 SVGNumberList() { }32 33 30 void parse(const String&); 34 31 String valueAsString() const; 35 32 }; 36 33 37 template<> 38 struct SVGPropertyTraits<SVGNumberList> { 34 template<> struct SVGPropertyTraits<SVGNumberList> { 39 35 typedef float ListItemType; 40 36 … … 44 40 45 41 } // namespace WebCore 46 47 #endif -
trunk/Source/WebCore/svg/SVGNumberList.idl
r206723 r207716 28 28 readonly attribute unsigned long numberOfItems; 29 29 30 [MayThrow LegacyException] void clear();31 [MayThrow LegacyException] SVGNumber initialize(SVGNumber item);32 [MayThrow LegacyException] SVGNumber getItem(unsigned long index);33 [MayThrow LegacyException] SVGNumber insertItemBefore(SVGNumber item, unsigned long index);34 [MayThrow LegacyException] SVGNumber replaceItem(SVGNumber item, unsigned long index);35 [MayThrow LegacyException] SVGNumber removeItem(unsigned long index);36 [MayThrow LegacyException] SVGNumber appendItem(SVGNumber item);30 [MayThrowException] void clear(); 31 [MayThrowException] SVGNumber initialize(SVGNumber item); 32 [MayThrowException] SVGNumber getItem(unsigned long index); 33 [MayThrowException] SVGNumber insertItemBefore(SVGNumber item, unsigned long index); 34 [MayThrowException] SVGNumber replaceItem(SVGNumber item, unsigned long index); 35 [MayThrowException] SVGNumber removeItem(unsigned long index); 36 [MayThrowException] SVGNumber appendItem(SVGNumber item); 37 37 }; -
trunk/Source/WebCore/svg/SVGPaint.cpp
r183536 r207716 65 65 } 66 66 67 void SVGPaint::setPaint(unsigned short, const String&, const String&, const String&, ExceptionCode& ec)67 ExceptionOr<void> SVGPaint::setPaint(unsigned short, const String&, const String&, const String&) 68 68 { 69 ec = NO_MODIFICATION_ALLOWED_ERR;69 return Exception { NO_MODIFICATION_ALLOWED_ERR }; 70 70 } 71 71 -
trunk/Source/WebCore/svg/SVGPaint.h
r203275 r207716 21 21 */ 22 22 23 #ifndef SVGPaint_h 24 #define SVGPaint_h 23 #pragma once 25 24 26 25 #include "SVGColor.h" 27 #include <wtf/text/WTFString.h>28 26 29 27 namespace WebCore { … … 82 80 83 81 void setUri(const String&); 84 void setPaint(unsigned short paintType, const String& uri, const String& rgbColor, const String& iccColor, ExceptionCode&);82 ExceptionOr<void> setPaint(unsigned short paintType, const String& uri, const String& rgbColor, const String& iccColor); 85 83 86 84 String customCSSText() const; … … 111 109 112 110 SPECIALIZE_TYPE_TRAITS_CSS_VALUE(SVGPaint, isSVGPaint()) 113 114 #endif // SVGPaint_h -
trunk/Source/WebCore/svg/SVGPaint.idl
r206723 r207716 42 42 43 43 void setUri(DOMString uri); 44 [MayThrow LegacyException] void setPaint(unsigned short paintType, DOMString uri, DOMString rgbColor, DOMString iccColor);44 [MayThrowException] void setPaint(unsigned short paintType, DOMString uri, DOMString rgbColor, DOMString iccColor); 45 45 }; 46 -
trunk/Source/WebCore/svg/SVGPathSegList.h
r163440 r207716 18 18 */ 19 19 20 #ifndef SVGPathSegList_h 21 #define SVGPathSegList_h 20 #pragma once 22 21 23 22 #include "SVGListProperty.h" 24 23 #include "SVGPathSeg.h" 25 24 #include "SVGPropertyTraits.h" 26 27 25 #include <wtf/Vector.h> 28 26 #include <wtf/text/WTFString.h> … … 34 32 class SVGPathSegList : public Vector<RefPtr<SVGPathSeg>> { 35 33 public: 36 SVGPathSegList(SVGPathSegRole role)34 explicit SVGPathSegList(SVGPathSegRole role) 37 35 : m_role(role) 38 36 { … … 48 46 }; 49 47 50 template<> 51 struct SVGPropertyTraits<SVGPathSegList> { 48 template<> struct SVGPropertyTraits<SVGPathSegList> { 52 49 static SVGPathSegList initialValue() { return SVGPathSegList(PathSegUndefinedRole); } 53 50 typedef RefPtr<SVGPathSeg> ListItemType; … … 55 52 56 53 } // namespace WebCore 57 58 #endif -
trunk/Source/WebCore/svg/SVGPathSegList.idl
r206723 r207716 28 28 readonly attribute unsigned long numberOfItems; 29 29 30 [MayThrow LegacyException] void clear();31 [MayThrow LegacyException] SVGPathSeg initialize(SVGPathSeg? newItem); // FIXME: Should not be nullable.32 [MayThrow LegacyException] SVGPathSeg getItem(unsigned long index);33 [MayThrow LegacyException] SVGPathSeg insertItemBefore(SVGPathSeg? newItem, unsigned long index); // FIXME: Should not be nullable.34 [MayThrow LegacyException] SVGPathSeg replaceItem(SVGPathSeg? newItem, unsigned long index); // FIXME: Should not be nullable.35 [MayThrow LegacyException] SVGPathSeg removeItem(unsigned long index);36 [MayThrow LegacyException] SVGPathSeg appendItem(SVGPathSeg? newItem); // FIXME: Should not be nullable.30 [MayThrowException] void clear(); 31 [MayThrowException] SVGPathSeg initialize(SVGPathSeg? newItem); // FIXME: Should not be nullable. 32 [MayThrowException] SVGPathSeg getItem(unsigned long index); 33 [MayThrowException] SVGPathSeg insertItemBefore(SVGPathSeg? newItem, unsigned long index); // FIXME: Should not be nullable. 34 [MayThrowException] SVGPathSeg replaceItem(SVGPathSeg? newItem, unsigned long index); // FIXME: Should not be nullable. 35 [MayThrowException] SVGPathSeg removeItem(unsigned long index); 36 [MayThrowException] SVGPathSeg appendItem(SVGPathSeg? newItem); // FIXME: Should not be nullable. 37 37 }; -
trunk/Source/WebCore/svg/SVGPointList.h
r203275 r207716 19 19 */ 20 20 21 #ifndef SVGPointList_h 22 #define SVGPointList_h 21 #pragma once 23 22 24 23 #include "SVGPoint.h" … … 30 29 class SVGPointList final : public Vector<SVGPoint> { 31 30 public: 32 SVGPointList() { }33 34 31 String valueAsString() const; 35 32 }; 36 33 37 template<> 38 struct SVGPropertyTraits<SVGPointList> { 34 template<> struct SVGPropertyTraits<SVGPointList> { 39 35 static SVGPointList initialValue() { return SVGPointList(); } 40 36 typedef SVGPoint ListItemType; … … 42 38 43 39 } // namespace WebCore 44 45 #endif -
trunk/Source/WebCore/svg/SVGPointList.idl
r206723 r207716 27 27 readonly attribute unsigned long numberOfItems; 28 28 29 [MayThrow LegacyException] void clear();30 [MayThrow LegacyException] SVGPoint initialize(SVGPoint item);31 [MayThrow LegacyException] SVGPoint getItem(unsigned long index);32 [MayThrow LegacyException] SVGPoint insertItemBefore(SVGPoint item, unsigned long index);33 [MayThrow LegacyException] SVGPoint replaceItem(SVGPoint item, unsigned long index);34 [MayThrow LegacyException] SVGPoint removeItem(unsigned long index);35 [MayThrow LegacyException] SVGPoint appendItem(SVGPoint item);29 [MayThrowException] void clear(); 30 [MayThrowException] SVGPoint initialize(SVGPoint item); 31 [MayThrowException] SVGPoint getItem(unsigned long index); 32 [MayThrowException] SVGPoint insertItemBefore(SVGPoint item, unsigned long index); 33 [MayThrowException] SVGPoint replaceItem(SVGPoint item, unsigned long index); 34 [MayThrowException] SVGPoint removeItem(unsigned long index); 35 [MayThrowException] SVGPoint appendItem(SVGPoint item); 36 36 }; -
trunk/Source/WebCore/svg/SVGPreserveAspectRatio.cpp
r183026 r207716 37 37 } 38 38 39 void SVGPreserveAspectRatio::setAlign(unsigned short align, ExceptionCode& ec) 40 { 41 if (align == SVG_PRESERVEASPECTRATIO_UNKNOWN || align > SVG_PRESERVEASPECTRATIO_XMAXYMAX) { 42 ec = NOT_SUPPORTED_ERR; 43 return; 44 } 39 ExceptionOr<void> SVGPreserveAspectRatio::setAlign(unsigned short align) 40 { 41 if (align == SVG_PRESERVEASPECTRATIO_UNKNOWN || align > SVG_PRESERVEASPECTRATIO_XMAXYMAX) 42 return Exception { NOT_SUPPORTED_ERR }; 45 43 46 44 m_align = static_cast<SVGPreserveAspectRatioType>(align); 47 } 48 49 void SVGPreserveAspectRatio::setMeetOrSlice(unsigned short meetOrSlice, ExceptionCode& ec) 50 { 51 if (meetOrSlice == SVG_MEETORSLICE_UNKNOWN || meetOrSlice > SVG_MEETORSLICE_SLICE) { 52 ec = NOT_SUPPORTED_ERR; 53 return; 54 } 45 return { }; 46 } 47 48 ExceptionOr<void> SVGPreserveAspectRatio::setMeetOrSlice(unsigned short meetOrSlice) 49 { 50 if (meetOrSlice == SVG_MEETORSLICE_UNKNOWN || meetOrSlice > SVG_MEETORSLICE_SLICE) 51 return Exception { NOT_SUPPORTED_ERR }; 55 52 56 53 m_meetOrSlice = static_cast<SVGMeetOrSliceType>(meetOrSlice); 54 return { }; 57 55 } 58 56 -
trunk/Source/WebCore/svg/SVGPreserveAspectRatio.h
r164276 r207716 19 19 */ 20 20 21 #ifndef SVGPreserveAspectRatio_h 22 #define SVGPreserveAspectRatio_h 21 #pragma once 23 22 23 #include "ExceptionOr.h" 24 24 #include "SVGPropertyTraits.h" 25 25 … … 28 28 class AffineTransform; 29 29 class FloatRect; 30 31 typedef int ExceptionCode;32 30 33 31 class SVGPreserveAspectRatio { … … 56 54 SVGPreserveAspectRatio(); 57 55 58 void setAlign(unsigned short align, ExceptionCode&);56 ExceptionOr<void> setAlign(unsigned short); 59 57 unsigned short align() const { return m_align; } 60 58 61 void setMeetOrSlice(unsigned short, ExceptionCode&);59 ExceptionOr<void> setMeetOrSlice(unsigned short); 62 60 unsigned short meetOrSlice() const { return m_meetOrSlice; } 63 61 64 62 void transformRect(FloatRect& destRect, FloatRect& srcRect); 65 63 66 AffineTransform getCTM(float logicX, float logicY, 67 float logicWidth, float logicHeight, 68 float physWidth, float physHeight) const; 64 AffineTransform getCTM(float logicalX, float logicalY, float logicalWidth, float logicalHeight, float physicalWidth, float physicalHeight) const; 69 65 70 66 void parse(const String&); … … 80 76 }; 81 77 82 template<> 83 struct SVGPropertyTraits<SVGPreserveAspectRatio> { 78 template<> struct SVGPropertyTraits<SVGPreserveAspectRatio> { 84 79 static SVGPreserveAspectRatio initialValue() { return SVGPreserveAspectRatio(); } 85 80 static String toString(const SVGPreserveAspectRatio& type) { return type.valueAsString(); } … … 87 82 88 83 } // namespace WebCore 89 90 #endif // SVGPreserveAspectRatio_h -
trunk/Source/WebCore/svg/SVGPreserveAspectRatio.idl
r206723 r207716 43 43 const unsigned short SVG_MEETORSLICE_SLICE = 2; 44 44 45 [SetterMayThrowLegacyException] attribute unsigned short align; 46 47 [SetterMayThrowLegacyException] attribute unsigned short meetOrSlice; 45 [SetterMayThrowException] attribute unsigned short align; 46 [SetterMayThrowException] attribute unsigned short meetOrSlice; 48 47 }; 49 -
trunk/Source/WebCore/svg/SVGSVGElement.cpp
r203324 r207716 154 154 { 155 155 if (!m_viewSpec) 156 m_viewSpec = SVGViewSpec::create( this);156 m_viewSpec = SVGViewSpec::create(*this); 157 157 return *m_viewSpec; 158 158 } -
trunk/Source/WebCore/svg/SVGStringList.h
r203275 r207716 19 19 */ 20 20 21 #ifndef SVGStringList_h 22 #define SVGStringList_h 21 #pragma once 23 22 24 23 #include "QualifiedName.h" … … 49 48 }; 50 49 51 template<> 52 struct SVGPropertyTraits<SVGStringList> { 50 template<> struct SVGPropertyTraits<SVGStringList> { 53 51 typedef String ListItemType; 54 52 }; 55 53 56 54 } // namespace WebCore 57 58 #endif -
trunk/Source/WebCore/svg/SVGStringList.idl
r206723 r207716 27 27 readonly attribute unsigned long numberOfItems; 28 28 29 [MayThrow LegacyException] void clear();30 [MayThrow LegacyException] DOMString initialize(DOMString item);31 [MayThrow LegacyException] DOMString getItem(unsigned long index);32 [MayThrow LegacyException] DOMString insertItemBefore(DOMString item, unsigned long index);33 [MayThrow LegacyException] DOMString replaceItem(DOMString item, unsigned long index);34 [MayThrow LegacyException] DOMString removeItem(unsigned long index);35 [MayThrow LegacyException] DOMString appendItem(DOMString item);29 [MayThrowException] void clear(); 30 [MayThrowException] DOMString initialize(DOMString item); 31 [MayThrowException] DOMString getItem(unsigned long index); 32 [MayThrowException] DOMString insertItemBefore(DOMString item, unsigned long index); 33 [MayThrowException] DOMString replaceItem(DOMString item, unsigned long index); 34 [MayThrowException] DOMString removeItem(unsigned long index); 35 [MayThrowException] DOMString appendItem(DOMString item); 36 36 }; 37 -
trunk/Source/WebCore/svg/SVGStyleElement.cpp
r206880 r207716 68 68 } 69 69 70 void SVGStyleElement::setType(const AtomicString& type , ExceptionCode&)70 void SVGStyleElement::setType(const AtomicString& type) 71 71 { 72 72 setAttribute(SVGNames::typeAttr, type); … … 80 80 } 81 81 82 void SVGStyleElement::setMedia(const AtomicString& media , ExceptionCode&)82 void SVGStyleElement::setMedia(const AtomicString& media) 83 83 { 84 84 setAttributeWithoutSynchronization(SVGNames::mediaAttr, media); … … 88 88 { 89 89 return attributeWithoutSynchronization(SVGNames::titleAttr); 90 }91 92 void SVGStyleElement::setTitle(const AtomicString& title, ExceptionCode&)93 {94 setAttributeWithoutSynchronization(SVGNames::titleAttr, title);95 90 } 96 91 -
trunk/Source/WebCore/svg/SVGStyleElement.h
r203469 r207716 20 20 */ 21 21 22 #ifndef SVGStyleElement_h 23 #define SVGStyleElement_h 22 #pragma once 24 23 25 24 #include "InlineStyleSheetOwner.h" … … 39 38 40 39 const AtomicString& type() const; 41 void setType(const AtomicString& , ExceptionCode&);40 void setType(const AtomicString&); 42 41 43 42 const AtomicString& media() const; 44 void setMedia(const AtomicString&, ExceptionCode&); 45 46 String title() const final; 47 void setTitle(const AtomicString&, ExceptionCode&); 43 void setMedia(const AtomicString&); 48 44 49 45 private: … … 64 60 Timer* svgLoadEventTimer() final { return &m_svgLoadEventTimer; } 65 61 62 String title() const final; 63 66 64 InlineStyleSheetOwner m_styleSheetOwner; 67 65 Timer m_svgLoadEventTimer; … … 69 67 70 68 } // namespace WebCore 71 72 #endif // SVGStyleElement_h -
trunk/Source/WebCore/svg/SVGStyleElement.idl
r206723 r207716 26 26 27 27 interface SVGStyleElement : SVGElement { 28 29 [SetterMayThrowLegacyException]attribute DOMString type;30 [SetterMayThrowLegacyException]attribute DOMString media;31 [SetterMayThrowLegacyException] attribute DOMString title;28 attribute boolean disabled; 29 attribute DOMString type; 30 attribute DOMString media; 31 [Reflect] attribute DOMString title; 32 32 }; 33 -
trunk/Source/WebCore/svg/SVGTextContentElement.cpp
r189770 r207716 94 94 static NeverDestroyed<SVGLength> defaultTextLength(LengthModeOther); 95 95 if (m_specifiedTextLength == defaultTextLength) 96 m_textLength.value.newValueSpecifiedUnits(LengthTypeNumber, getComputedTextLength() , ASSERT_NO_EXCEPTION);96 m_textLength.value.newValueSpecifiedUnits(LengthTypeNumber, getComputedTextLength()); 97 97 98 98 m_textLength.shouldSynchronize = true; 99 99 return static_reference_cast<SVGAnimatedLength>(lookupOrCreateTextLengthWrapper(this)); 100 101 100 } 102 101 … … 113 112 } 114 113 115 float SVGTextContentElement::getSubStringLength(unsigned charnum, unsigned nchars, ExceptionCode& ec) 116 { 117 document().updateLayoutIgnorePendingStylesheets(); 118 114 ExceptionOr<float> SVGTextContentElement::getSubStringLength(unsigned charnum, unsigned nchars) 115 { 119 116 unsigned numberOfChars = getNumberOfChars(); 120 if (charnum >= numberOfChars) { 121 ec = INDEX_SIZE_ERR; 122 return 0.0f; 123 } 117 if (charnum >= numberOfChars) 118 return Exception { INDEX_SIZE_ERR }; 124 119 125 120 nchars = std::min(nchars, numberOfChars - charnum); … … 127 122 } 128 123 129 SVGPoint SVGTextContentElement::getStartPositionOfChar(unsigned charnum, ExceptionCode& ec) 130 { 131 document().updateLayoutIgnorePendingStylesheets(); 132 133 if (charnum > getNumberOfChars()) { 134 ec = INDEX_SIZE_ERR; 135 return SVGPoint(); 136 } 124 ExceptionOr<SVGPoint> SVGTextContentElement::getStartPositionOfChar(unsigned charnum) 125 { 126 if (charnum > getNumberOfChars()) 127 return Exception { INDEX_SIZE_ERR }; 137 128 138 129 return SVGTextQuery(renderer()).startPositionOfCharacter(charnum); 139 130 } 140 131 141 SVGPoint SVGTextContentElement::getEndPositionOfChar(unsigned charnum, ExceptionCode& ec) 142 { 143 document().updateLayoutIgnorePendingStylesheets(); 144 145 if (charnum > getNumberOfChars()) { 146 ec = INDEX_SIZE_ERR; 147 return SVGPoint(); 148 } 132 ExceptionOr<SVGPoint> SVGTextContentElement::getEndPositionOfChar(unsigned charnum) 133 { 134 if (charnum > getNumberOfChars()) 135 return Exception { INDEX_SIZE_ERR }; 149 136 150 137 return SVGTextQuery(renderer()).endPositionOfCharacter(charnum); 151 138 } 152 139 153 FloatRect SVGTextContentElement::getExtentOfChar(unsigned charnum, ExceptionCode& ec) 154 { 155 document().updateLayoutIgnorePendingStylesheets(); 156 157 if (charnum > getNumberOfChars()) { 158 ec = INDEX_SIZE_ERR; 159 return FloatRect(); 160 } 140 ExceptionOr<FloatRect> SVGTextContentElement::getExtentOfChar(unsigned charnum) 141 { 142 if (charnum > getNumberOfChars()) 143 return Exception { INDEX_SIZE_ERR }; 161 144 162 145 return SVGTextQuery(renderer()).extentOfCharacter(charnum); 163 146 } 164 147 165 float SVGTextContentElement::getRotationOfChar(unsigned charnum, ExceptionCode& ec) 166 { 167 document().updateLayoutIgnorePendingStylesheets(); 168 169 if (charnum > getNumberOfChars()) { 170 ec = INDEX_SIZE_ERR; 171 return 0.0f; 172 } 148 ExceptionOr<float> SVGTextContentElement::getRotationOfChar(unsigned charnum) 149 { 150 if (charnum > getNumberOfChars()) 151 return Exception { INDEX_SIZE_ERR }; 173 152 174 153 return SVGTextQuery(renderer()).rotationOfCharacter(charnum); … … 181 160 } 182 161 183 void SVGTextContentElement::selectSubString(unsigned charnum, unsigned nchars, ExceptionCode& ec)162 ExceptionOr<void> SVGTextContentElement::selectSubString(unsigned charnum, unsigned nchars) 184 163 { 185 164 unsigned numberOfChars = getNumberOfChars(); 186 if (charnum >= numberOfChars) { 187 ec = INDEX_SIZE_ERR; 188 return; 189 } 165 if (charnum >= numberOfChars) 166 return Exception { INDEX_SIZE_ERR }; 190 167 191 168 nchars = std::min(nchars, numberOfChars - charnum); … … 206 183 207 184 selection.setSelection(VisibleSelection(start, end)); 185 186 return { }; 208 187 } 209 188 -
trunk/Source/WebCore/svg/SVGTextContentElement.h
r197566 r207716 19 19 */ 20 20 21 #ifndef SVGTextContentElement_h 22 #define SVGTextContentElement_h 21 #pragma once 23 22 24 23 #include "SVGAnimatedBoolean.h" … … 36 35 }; 37 36 38 template<> 39 struct SVGPropertyTraits<SVGLengthAdjustType> { 37 template<> struct SVGPropertyTraits<SVGLengthAdjustType> { 40 38 static unsigned highestEnumValue() { return SVGLengthAdjustSpacingAndGlyphs; } 41 39 … … 67 65 class SVGTextContentElement : public SVGGraphicsElement, public SVGExternalResourcesRequired { 68 66 public: 69 // Forward declare enumerations in the W3C naming scheme, for IDL generation.70 67 enum { 71 68 LENGTHADJUST_UNKNOWN = SVGLengthAdjustUnknown, … … 76 73 unsigned getNumberOfChars(); 77 74 float getComputedTextLength(); 78 float getSubStringLength(unsigned charnum, unsigned nchars, ExceptionCode&);79 SVGPoint getStartPositionOfChar(unsigned charnum, ExceptionCode&);80 SVGPoint getEndPositionOfChar(unsigned charnum, ExceptionCode&);81 FloatRect getExtentOfChar(unsigned charnum, ExceptionCode&);82 float getRotationOfChar(unsigned charnum, ExceptionCode&);75 ExceptionOr<float> getSubStringLength(unsigned charnum, unsigned nchars); 76 ExceptionOr<SVGPoint> getStartPositionOfChar(unsigned charnum); 77 ExceptionOr<SVGPoint> getEndPositionOfChar(unsigned charnum); 78 ExceptionOr<FloatRect> getExtentOfChar(unsigned charnum); 79 ExceptionOr<float> getRotationOfChar(unsigned charnum); 83 80 int getCharNumAtPosition(const SVGPoint&); 84 void selectSubString(unsigned charnum, unsigned nchars, ExceptionCode&);81 ExceptionOr<void> selectSubString(unsigned charnum, unsigned nchars); 85 82 86 83 static SVGTextContentElement* elementFromRenderer(RenderObject*); … … 127 124 static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); } 128 125 SPECIALIZE_TYPE_TRAITS_END() 129 130 #endif -
trunk/Source/WebCore/svg/SVGTextContentElement.idl
r206723 r207716 26 26 interface SVGTextContentElement : SVGGraphicsElement { 27 27 // lengthAdjust Types 28 const unsigned short LENGTHADJUST_UNKNOWN 29 const unsigned short LENGTHADJUST_SPACING 28 const unsigned short LENGTHADJUST_UNKNOWN = 0; 29 const unsigned short LENGTHADJUST_SPACING = 1; 30 30 const unsigned short LENGTHADJUST_SPACINGANDGLYPHS = 2; 31 31 32 readonly attribute SVGAnimatedLength 32 readonly attribute SVGAnimatedLength textLength; 33 33 readonly attribute SVGAnimatedEnumeration lengthAdjust; 34 34 35 35 long getNumberOfChars(); 36 36 unrestricted float getComputedTextLength(); 37 [MayThrowLegacyException] unrestricted float getSubStringLength(optional unsigned long offset = 0, 38 optional unsigned long length = 0); 39 [MayThrowLegacyException] SVGPoint getStartPositionOfChar(optional unsigned long offset = 0); 40 [MayThrowLegacyException] SVGPoint getEndPositionOfChar(optional unsigned long offset = 0); 41 [MayThrowLegacyException] SVGRect getExtentOfChar(optional unsigned long offset = 0); 42 [MayThrowLegacyException] unrestricted float getRotationOfChar(optional unsigned long offset = 0); 37 [MayThrowException] unrestricted float getSubStringLength(optional unsigned long offset = 0, optional unsigned long length = 0); 38 [MayThrowException] SVGPoint getStartPositionOfChar(optional unsigned long offset = 0); 39 [MayThrowException] SVGPoint getEndPositionOfChar(optional unsigned long offset = 0); 40 [MayThrowException] SVGRect getExtentOfChar(optional unsigned long offset = 0); 41 [MayThrowException] unrestricted float getRotationOfChar(optional unsigned long offset = 0); 43 42 long getCharNumAtPosition(SVGPoint point); 44 [MayThrow LegacyException] void selectSubString(optional unsigned long offset = 0, optional unsigned long length = 0);43 [MayThrowException] void selectSubString(optional unsigned long offset = 0, optional unsigned long length = 0); 45 44 }; 46 45 -
trunk/Source/WebCore/svg/SVGTransformList.h
r203275 r207716 19 19 */ 20 20 21 #ifndef SVGTransformList_h 22 #define SVGTransformList_h 21 #pragma once 23 22 24 23 #include "SVGPropertyTraits.h" … … 30 29 class SVGTransformList final : public Vector<SVGTransform, 1> { 31 30 public: 32 SVGTransformList() { }33 34 31 SVGTransform createSVGTransformFromMatrix(const SVGMatrix&) const; 35 32 SVGTransform consolidate(); 36 33 37 // Internal use only38 34 bool concatenate(AffineTransform& result) const; 39 35 … … 42 38 }; 43 39 44 template<> 45 struct SVGPropertyTraits<SVGTransformList> { 40 template<> struct SVGPropertyTraits<SVGTransformList> { 46 41 static SVGTransformList initialValue() { return SVGTransformList(); } 47 42 static String toString(const SVGTransformList& type) { return type.valueAsString(); } … … 50 45 51 46 } // namespace WebCore 52 53 #endif // SVGTransformList_h -
trunk/Source/WebCore/svg/SVGTransformList.idl
r206723 r207716 28 28 readonly attribute unsigned long numberOfItems; 29 29 30 [MayThrow LegacyException] void clear();31 [MayThrow LegacyException] SVGTransform initialize(SVGTransform item);32 [MayThrow LegacyException] SVGTransform getItem(unsigned long index);33 [MayThrow LegacyException] SVGTransform insertItemBefore(SVGTransform item, unsigned long index);34 [MayThrow LegacyException] SVGTransform replaceItem(SVGTransform item, unsigned long index);35 [MayThrow LegacyException] SVGTransform removeItem(unsigned long index);36 [MayThrow LegacyException] SVGTransform appendItem(SVGTransform item);30 [MayThrowException] void clear(); 31 [MayThrowException] SVGTransform initialize(SVGTransform item); 32 [MayThrowException] SVGTransform getItem(unsigned long index); 33 [MayThrowException] SVGTransform insertItemBefore(SVGTransform item, unsigned long index); 34 [MayThrowException] SVGTransform replaceItem(SVGTransform item, unsigned long index); 35 [MayThrowException] SVGTransform removeItem(unsigned long index); 36 [MayThrowException] SVGTransform appendItem(SVGTransform item); 37 37 38 [MayThrow LegacyException] SVGTransform createSVGTransformFromMatrix(SVGMatrix matrix);38 [MayThrowException] SVGTransform createSVGTransformFromMatrix(SVGMatrix matrix); 39 39 40 [MayThrow LegacyException] SVGTransform consolidate();40 [MayThrowException] SVGTransform consolidate(); 41 41 }; -
trunk/Source/WebCore/svg/SVGViewSpec.cpp
r196268 r207716 76 76 } 77 77 78 SVGViewSpec::SVGViewSpec(SVGElement* contextElement) 79 : m_contextElement(contextElement) 80 , m_zoomAndPan(SVGZoomAndPanMagnify) 81 { 82 ASSERT(m_contextElement); 78 SVGViewSpec::SVGViewSpec(SVGElement& contextElement) 79 : m_contextElement(&contextElement) 80 { 83 81 } 84 82 … … 101 99 } 102 100 103 void SVGViewSpec::setZoomAndPan(unsigned short, ExceptionCode& ec)101 ExceptionOr<void> SVGViewSpec::setZoomAndPan(unsigned short) 104 102 { 105 103 // SVGViewSpec and all of its content is read-only. 106 ec = NO_MODIFICATION_ALLOWED_ERR; 107 } 108 109 void SVGViewSpec::setTransformString(const String& transform) 110 { 111 if (!m_contextElement) 112 return; 113 114 SVGTransformList newList; 115 newList.parse(transform); 116 117 if (auto wrapper = SVGAnimatedProperty::lookupWrapper<SVGElement, SVGAnimatedTransformList>(m_contextElement, transformPropertyInfo())) 118 static_pointer_cast<SVGAnimatedTransformList>(wrapper)->detachListWrappers(newList.size()); 119 120 m_transform = newList; 104 return Exception { NO_MODIFICATION_ALLOWED_ERR }; 121 105 } 122 106 … … 128 112 String SVGViewSpec::viewBoxString() const 129 113 { 130 return SVGPropertyTraits<FloatRect>::toString( viewBoxBaseValue());114 return SVGPropertyTraits<FloatRect>::toString(m_viewBox); 131 115 } 132 116 133 117 String SVGViewSpec::preserveAspectRatioString() const 134 118 { 135 return SVGPropertyTraits<SVGPreserveAspectRatio>::toString( preserveAspectRatioBaseValue());119 return SVGPropertyTraits<SVGPreserveAspectRatio>::toString(m_preserveAspectRatio); 136 120 } 137 121 … … 140 124 if (!m_contextElement) 141 125 return nullptr; 142 Element* element = m_contextElement->treeScope().getElementById(m_viewTargetString);143 if (! element || !element->isSVGElement())126 auto* element = m_contextElement->treeScope().getElementById(m_viewTargetString); 127 if (!is<SVGElement>(element)) 144 128 return nullptr; 145 129 return downcast<SVGElement>(element); … … 171 155 { 172 156 ASSERT(ownerType); 173 ASSERT(ownerType-> contextElement());174 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedRect, FloatRect>(ownerType-> contextElement(), viewBoxPropertyInfo(), ownerType->m_viewBox);157 ASSERT(ownerType->m_contextElement); 158 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedRect, FloatRect>(ownerType->m_contextElement, viewBoxPropertyInfo(), ownerType->m_viewBox); 175 159 } 176 160 … … 178 162 { 179 163 ASSERT(ownerType); 180 ASSERT(ownerType-> contextElement());181 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatio>(ownerType-> contextElement(), preserveAspectRatioPropertyInfo(), ownerType->m_preserveAspectRatio);164 ASSERT(ownerType->m_contextElement); 165 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatio>(ownerType->m_contextElement, preserveAspectRatioPropertyInfo(), ownerType->m_preserveAspectRatio); 182 166 } 183 167 … … 185 169 { 186 170 ASSERT(ownerType); 187 ASSERT(ownerType-> contextElement());188 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedTransformList, SVGTransformList>(ownerType-> contextElement(), transformPropertyInfo(), ownerType->m_transform);171 ASSERT(ownerType->m_contextElement); 172 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedTransformList, SVGTransformList>(ownerType->m_contextElement, transformPropertyInfo(), ownerType->m_transform); 189 173 } 190 174 … … 242 226 if (currViewSpec >= end) 243 227 return false; 244 setViewTargetString(String(viewTargetStart, currViewSpec - viewTargetStart));228 m_viewTargetString = String(viewTargetStart, currViewSpec - viewTargetStart); 245 229 currViewSpec++; 246 230 } else -
trunk/Source/WebCore/svg/SVGViewSpec.h
r203275 r207716 18 18 */ 19 19 20 #ifndef SVGViewSpec_h 21 #define SVGViewSpec_h 20 #pragma once 22 21 23 22 #include "SVGAnimatedPreserveAspectRatio.h" … … 32 31 class SVGTransformListPropertyTearOff; 33 32 34 class SVGViewSpec final : public RefCounted<SVGViewSpec> 35 , public SVGZoomAndPan 36 , public SVGFitToViewBox { 33 class SVGViewSpec final : public RefCounted<SVGViewSpec>, public SVGZoomAndPan, public SVGFitToViewBox { 37 34 public: 38 virtual ~SVGViewSpec() { } 39 40 using RefCounted<SVGViewSpec>::ref; 41 using RefCounted<SVGViewSpec>::deref; 42 43 static Ref<SVGViewSpec> create(SVGElement* contextElement) 35 static Ref<SVGViewSpec> create(SVGElement& contextElement) 44 36 { 45 37 return adoptRef(*new SVGViewSpec(contextElement)); … … 50 42 51 43 SVGElement* viewTarget() const; 44 45 String transformString() const; 52 46 String viewBoxString() const; 53 54 47 String preserveAspectRatioString() const; 55 56 void setTransformString(const String&); 57 String transformString() const; 58 59 void setViewTargetString(const String& string) { m_viewTargetString = string; } 60 String viewTargetString() const { return m_viewTargetString; } 48 const String& viewTargetString() const { return m_viewTargetString; } 61 49 62 50 SVGZoomAndPanType zoomAndPan() const { return m_zoomAndPan; } 63 void setZoomAndPan(unsigned short zoomAndPan) { setZoomAndPanBaseValue(zoomAndPan); } 64 void setZoomAndPan(unsigned short, ExceptionCode&); 51 ExceptionOr<void> setZoomAndPan(unsigned short); 65 52 void setZoomAndPanBaseValue(unsigned short zoomAndPan) { m_zoomAndPan = SVGZoomAndPan::parseFromNumber(zoomAndPan); } 66 53 67 SVGElement* contextElement() const { return m_contextElement; }68 54 void resetContextElement() { m_contextElement = nullptr; } 69 55 … … 75 61 RefPtr<SVGAnimatedRect> viewBoxAnimated(); 76 62 FloatRect& viewBox() { return m_viewBox; } 77 FloatRect viewBoxBaseValue() const { return m_viewBox; }78 63 void setViewBoxBaseValue(const FloatRect& viewBox) { m_viewBox = viewBox; } 79 64 … … 81 66 RefPtr<SVGAnimatedPreserveAspectRatio> preserveAspectRatioAnimated(); 82 67 SVGPreserveAspectRatio& preserveAspectRatio() { return m_preserveAspectRatio; } 83 SVGPreserveAspectRatio preserveAspectRatioBaseValue() const { return m_preserveAspectRatio; }84 68 void setPreserveAspectRatioBaseValue(const SVGPreserveAspectRatio& preserveAspectRatio) { m_preserveAspectRatio = preserveAspectRatio; } 85 69 86 70 private: 87 SVGViewSpec(SVGElement*);71 explicit SVGViewSpec(SVGElement&); 88 72 89 73 static const SVGPropertyInfo* transformPropertyInfo(); … … 100 84 101 85 SVGElement* m_contextElement; 102 SVGZoomAndPanType m_zoomAndPan; 103 86 SVGZoomAndPanType m_zoomAndPan { SVGZoomAndPanMagnify }; 104 87 SVGTransformList m_transform; 105 88 FloatRect m_viewBox; … … 109 92 110 93 } // namespace WebCore 111 112 #endif -
trunk/Source/WebCore/svg/SVGViewSpec.idl
r206723 r207716 27 27 // It would require that any of those classes would be RefCounted, and we want to avoid that. 28 28 [ 29 JSGenerateToJSObject 29 ImplementationLacksVTable, 30 JSGenerateToJSObject, 30 31 ] interface SVGViewSpec { 31 32 33 34 35 36 32 readonly attribute SVGTransformList transform; 33 readonly attribute SVGElement viewTarget; 34 readonly attribute DOMString viewBoxString; 35 readonly attribute DOMString preserveAspectRatioString; 36 readonly attribute DOMString transformString; 37 readonly attribute DOMString viewTargetString; 37 38 38 39 [SetterMayThrowLegacyException] attribute unsigned short zoomAndPan;39 // SVGZoomAndPan 40 [SetterMayThrowException] attribute unsigned short zoomAndPan; 40 41 }; 41 42 -
trunk/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h
r203469 r207716 50 50 } 51 51 52 void setBaseVal(const unsigned& property, ExceptionCode& ec) final52 ExceptionOr<void> setBaseVal(const unsigned& property) final 53 53 { 54 54 // All SVG enumeration values, that are allowed to be set via SVG DOM start with 1, 0 corresponds to unknown and is not settable through SVG DOM. 55 if (!property || property > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue()) { 56 ec = SVGException::SVG_INVALID_VALUE_ERR; 57 return; 58 } 59 SVGAnimatedStaticPropertyTearOff<unsigned>::setBaseVal(property, ec); 55 if (!property || property > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue()) 56 return Exception { SVGException::SVG_INVALID_VALUE_ERR }; 57 return SVGAnimatedStaticPropertyTearOff<unsigned>::setBaseVal(property); 60 58 } 61 59 -
trunk/Source/WebCore/svg/properties/SVGAnimatedStaticPropertyTearOff.h
r198316 r207716 19 19 */ 20 20 21 #ifndef SVGAnimatedStaticPropertyTearOff_h 22 #define SVGAnimatedStaticPropertyTearOff_h 21 #pragma once 23 22 24 #include "Exception Code.h"23 #include "ExceptionOr.h" 25 24 #include "SVGAnimatedProperty.h" 26 25 … … 44 43 } 45 44 46 virtual void setBaseVal(const PropertyType& property, ExceptionCode&)45 virtual ExceptionOr<void> setBaseVal(const PropertyType& property) 47 46 { 48 47 m_property = property; 49 48 commitChange(); 49 return { }; 50 50 } 51 51 … … 108 108 109 109 } 110 111 #endif // SVGAnimatedStaticPropertyTearOff_h -
trunk/Source/WebCore/svg/properties/SVGListProperty.h
r202242 r207716 18 18 */ 19 19 20 #ifndef SVGListProperty_h 21 #define SVGListProperty_h 20 #pragma once 22 21 23 22 #include "SVGException.h" … … 43 42 typedef SVGListProperty<PropertyType> Self; 44 43 45 typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType; 46 typedef SVGPropertyTearOff<ListItemType> ListItemTearOff; 47 typedef RefPtr<ListItemTearOff> PtrListItemTearOff; 48 typedef SVGAnimatedListPropertyTearOff<PropertyType> AnimatedListPropertyTearOff; 49 typedef typename SVGAnimatedListPropertyTearOff<PropertyType>::ListWrapperCache ListWrapperCache; 50 51 bool canAlterList(ExceptionCode& ec) const 52 { 53 if (m_role == AnimValRole) { 54 ec = NO_MODIFICATION_ALLOWED_ERR; 55 return false; 56 } 44 using ListItemType = typename SVGPropertyTraits<PropertyType>::ListItemType; 45 using ListItemTearOff = SVGPropertyTearOff<ListItemType>; 46 using PtrListItemTearOff = RefPtr<ListItemTearOff>; 47 using AnimatedListPropertyTearOff = SVGAnimatedListPropertyTearOff<PropertyType>; 48 using ListWrapperCache = typename AnimatedListPropertyTearOff::ListWrapperCache; 49 50 ExceptionOr<bool> canAlterList() const 51 { 52 if (m_role == AnimValRole) 53 return Exception { NO_MODIFICATION_ALLOWED_ERR }; 57 54 58 55 return true; … … 96 93 97 94 // SVGList::clear() 98 void clearValues(ExceptionCode& ec) 99 { 100 if (!canAlterList(ec)) 101 return; 95 ExceptionOr<void> clearValues() 96 { 97 auto result = canAlterList(); 98 if (result.hasException()) 99 return result.releaseException(); 100 if (!result.releaseReturnValue()) 101 return { }; 102 102 103 103 m_values->clear(); 104 104 commitChange(); 105 } 106 107 void clearValuesAndWrappers(ExceptionCode& ec) 108 { 109 if (!canAlterList(ec)) 110 return; 105 return { }; 106 } 107 108 ExceptionOr<void> clearValuesAndWrappers() 109 { 110 auto result = canAlterList(); 111 if (result.hasException()) 112 return result.releaseException(); 113 if (!result.releaseReturnValue()) 114 return { }; 111 115 112 116 detachListWrappers(0); 113 117 m_values->clear(); 114 118 commitChange(); 119 return { }; 115 120 } 116 121 … … 122 127 123 128 // SVGList::initialize() 124 ListItemType initializeValues(const ListItemType& newItem, ExceptionCode& ec) 125 { 126 if (!canAlterList(ec)) 127 return ListItemType(); 129 ExceptionOr<ListItemType> initializeValues(const ListItemType& newItem) 130 { 131 auto result = canAlterList(); 132 if (result.hasException()) 133 return result.releaseException(); 134 if (!result.releaseReturnValue()) 135 return ListItemType { }; 128 136 129 137 // Spec: If the inserted item is already in a list, it is removed from its previous list before it is inserted into this list. … … 135 143 136 144 commitChange(); 137 return newItem; 138 } 139 140 PtrListItemTearOff initializeValuesAndWrappers(PtrListItemTearOff newItem, ExceptionCode& ec) 141 { 142 ASSERT(m_wrappers); 143 if (!canAlterList(ec)) 145 return ListItemType { newItem }; 146 } 147 148 ExceptionOr<PtrListItemTearOff> initializeValuesAndWrappers(PtrListItemTearOff newItem) 149 { 150 ASSERT(m_wrappers); 151 152 auto result = canAlterList(); 153 if (result.hasException()) 154 return result.releaseException(); 155 if (!result.releaseReturnValue()) 144 156 return nullptr; 145 157 146 158 // Not specified, but FF/Opera do it this way, and it's just sane. 147 if (!newItem) { 148 ec = SVGException::SVG_WRONG_TYPE_ERR; 149 return nullptr; 150 } 159 if (!newItem) 160 return Exception { SVGException::SVG_WRONG_TYPE_ERR }; 151 161 152 162 ASSERT(m_values->size() == m_wrappers->size()); … … 163 173 164 174 commitChange(); 165 return newItem;175 return WTFMove(newItem); 166 176 } 167 177 168 178 // SVGList::getItem() 169 bool canGetItem(unsigned index, ExceptionCode& ec) 170 { 171 if (index >= m_values->size()) { 172 ec = INDEX_SIZE_ERR; 173 return false; 174 } 179 ExceptionOr<bool> canGetItem(unsigned index) 180 { 181 if (index >= m_values->size()) 182 return Exception { INDEX_SIZE_ERR }; 175 183 176 184 return true; 177 185 } 178 186 179 ListItemType getItemValues(unsigned index, ExceptionCode& ec) 180 { 181 if (!canGetItem(index, ec)) 182 return ListItemType(); 187 ExceptionOr<ListItemType> getItemValues(unsigned index) 188 { 189 auto result = canGetItem(index); 190 if (result.hasException()) 191 return result.releaseException(); 192 if (!result.releaseReturnValue()) 193 return ListItemType { }; 183 194 184 195 // Spec: Returns the specified item from the list. The returned item is the item itself and not a copy. 185 return m_values->at(index); 186 } 187 188 PtrListItemTearOff getItemValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, unsigned index, ExceptionCode& ec) 189 { 190 ASSERT(m_wrappers); 191 if (!canGetItem(index, ec)) 196 return ListItemType { m_values->at(index) }; 197 } 198 199 ExceptionOr<PtrListItemTearOff> getItemValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, unsigned index) 200 { 201 ASSERT(m_wrappers); 202 203 auto result = canGetItem(index); 204 if (result.hasException()) 205 return result.releaseException(); 206 if (!result.releaseReturnValue()) 192 207 return nullptr; 193 208 … … 208 223 209 224 // SVGList::insertItemBefore() 210 ListItemType insertItemBeforeValues(const ListItemType& newItem, unsigned index, ExceptionCode& ec) 211 { 212 if (!canAlterList(ec)) 213 return ListItemType(); 225 ExceptionOr<ListItemType> insertItemBeforeValues(const ListItemType& newItem, unsigned index) 226 { 227 auto result = canAlterList(); 228 if (result.hasException()) 229 return result.releaseException(); 230 if (!result.releaseReturnValue()) 231 return ListItemType { }; 214 232 215 233 // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. … … 220 238 if (!processIncomingListItemValue(newItem, &index)) { 221 239 // Inserting the item before itself is a no-op. 222 return newItem;240 return ListItemType { newItem }; 223 241 } 224 242 … … 228 246 229 247 commitChange(); 230 return newItem; 231 } 232 233 PtrListItemTearOff insertItemBeforeValuesAndWrappers(PtrListItemTearOff newItem, unsigned index, ExceptionCode& ec) 234 { 235 ASSERT(m_wrappers); 236 if (!canAlterList(ec)) 248 return ListItemType { newItem }; 249 } 250 251 ExceptionOr<PtrListItemTearOff> insertItemBeforeValuesAndWrappers(PtrListItemTearOff newItem, unsigned index) 252 { 253 ASSERT(m_wrappers); 254 255 auto result = canAlterList(); 256 if (result.hasException()) 257 return result.releaseException(); 258 if (!result.releaseReturnValue()) 237 259 return nullptr; 238 260 239 261 // Not specified, but FF/Opera do it this way, and it's just sane. 240 if (!newItem) { 241 ec = SVGException::SVG_WRONG_TYPE_ERR; 242 return nullptr; 243 } 262 if (!newItem) 263 return Exception { SVGException::SVG_WRONG_TYPE_ERR }; 244 264 245 265 // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. 246 266 if (index > m_values->size()) 247 267 index = m_values->size(); 248 268 249 269 ASSERT(m_values->size() == m_wrappers->size()); … … 265 285 266 286 // SVGList::replaceItem() 267 bool canReplaceItem(unsigned index, ExceptionCode& ec) 268 { 269 if (!canAlterList(ec)) 287 ExceptionOr<bool> canReplaceItem(unsigned index) 288 { 289 auto result = canAlterList(); 290 if (result.hasException()) 291 return result.releaseException(); 292 if (!result.releaseReturnValue()) 270 293 return false; 271 294 272 if (index >= m_values->size()) { 273 ec = INDEX_SIZE_ERR; 274 return false; 275 } 295 if (index >= m_values->size()) 296 return Exception { INDEX_SIZE_ERR }; 276 297 277 298 return true; 278 299 } 279 300 280 ListItemType replaceItemValues(const ListItemType& newItem, unsigned index, ExceptionCode& ec) 281 { 282 if (!canReplaceItem(index, ec)) 283 return ListItemType(); 301 ExceptionOr<ListItemType> replaceItemValues(const ListItemType& newItem, unsigned index) 302 { 303 auto result = canReplaceItem(index); 304 if (result.hasException()) 305 return result.releaseException(); 306 if (!result.releaseReturnValue()) 307 return ListItemType { }; 284 308 285 309 // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. … … 287 311 if (!processIncomingListItemValue(newItem, &index)) { 288 312 // Replacing the item with itself is a no-op. 289 return newItem;313 return ListItemType { newItem }; 290 314 } 291 315 292 316 if (m_values->isEmpty()) { 293 317 // 'newItem' already lived in our list, we removed it, and now we're empty, which means there's nothing to replace. 294 ec = INDEX_SIZE_ERR; 295 return ListItemType(); 318 return Exception { INDEX_SIZE_ERR }; 296 319 } 297 320 … … 300 323 301 324 commitChange(); 302 return newItem; 303 } 304 305 PtrListItemTearOff replaceItemValuesAndWrappers(PtrListItemTearOff newItem, unsigned index, ExceptionCode& ec) 306 { 307 ASSERT(m_wrappers); 308 if (!canReplaceItem(index, ec)) 325 return ListItemType { newItem }; 326 } 327 328 ExceptionOr<PtrListItemTearOff> replaceItemValuesAndWrappers(PtrListItemTearOff newItem, unsigned index) 329 { 330 ASSERT(m_wrappers); 331 332 auto result = canReplaceItem(index); 333 if (result.hasException()) 334 return result.releaseException(); 335 if (!result.releaseReturnValue()) 309 336 return nullptr; 310 337 311 338 // Not specified, but FF/Opera do it this way, and it's just sane. 312 if (!newItem) { 313 ec = SVGException::SVG_WRONG_TYPE_ERR; 314 return nullptr; 315 } 339 if (!newItem) 340 return Exception { SVGException::SVG_WRONG_TYPE_ERR }; 316 341 317 342 ASSERT(m_values->size() == m_wrappers->size()); … … 320 345 // Spec: If the item is already in this list, note that the index of the item to replace is before the removal of the item. 321 346 if (!processIncomingListItemWrapper(newItem, &index)) 322 return newItem;347 return WTFMove(newItem); 323 348 324 349 if (m_values->isEmpty()) { 325 350 ASSERT(m_wrappers->isEmpty()); 326 351 // 'newItem' already lived in our list, we removed it, and now we're empty, which means there's nothing to replace. 327 ec = INDEX_SIZE_ERR; 328 return nullptr; 352 return Exception { INDEX_SIZE_ERR }; 329 353 } 330 354 … … 339 363 340 364 commitChange(); 341 return newItem;365 return WTFMove(newItem); 342 366 } 343 367 344 368 // SVGList::removeItem() 345 bool canRemoveItem(unsigned index, ExceptionCode& ec) 346 { 347 if (!canAlterList(ec)) 369 ExceptionOr<bool> canRemoveItem(unsigned index) 370 { 371 auto result = canAlterList(); 372 if (result.hasException()) 373 return result.releaseException(); 374 if (!result.releaseReturnValue()) 348 375 return false; 349 376 350 if (index >= m_values->size()) { 351 ec = INDEX_SIZE_ERR; 352 return false; 353 } 377 if (index >= m_values->size()) 378 return Exception { INDEX_SIZE_ERR }; 354 379 355 380 return true; 356 381 } 357 382 358 ListItemType removeItemValues(unsigned index, ExceptionCode& ec) 359 { 360 if (!canRemoveItem(index, ec)) 361 return ListItemType(); 383 ExceptionOr<ListItemType> removeItemValues(unsigned index) 384 { 385 auto result = canRemoveItem(index); 386 if (result.hasException()) 387 return result.releaseException(); 388 if (!result.releaseReturnValue()) 389 return ListItemType { }; 362 390 363 391 ListItemType oldItem = m_values->at(index); … … 365 393 366 394 commitChange(); 367 return oldItem; 368 } 369 370 PtrListItemTearOff removeItemValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, unsigned index, ExceptionCode& ec) 371 { 372 ASSERT(m_wrappers); 373 if (!canRemoveItem(index, ec)) 395 return WTFMove(oldItem); 396 } 397 398 ExceptionOr<PtrListItemTearOff> removeItemValuesAndWrappers(AnimatedListPropertyTearOff* animatedList, unsigned index) 399 { 400 ASSERT(m_wrappers); 401 402 auto result = canRemoveItem(index); 403 if (result.hasException()) 404 return result.releaseException(); 405 if (!result.releaseReturnValue()) 374 406 return nullptr; 375 407 … … 390 422 391 423 // SVGList::appendItem() 392 ListItemType appendItemValues(const ListItemType& newItem, ExceptionCode& ec) 393 { 394 if (!canAlterList(ec)) 395 return ListItemType(); 424 ExceptionOr<ListItemType> appendItemValues(const ListItemType& newItem) 425 { 426 auto result = canAlterList(); 427 if (result.hasException()) 428 return result.releaseException(); 429 if (!result.releaseReturnValue()) 430 return ListItemType { }; 396 431 397 432 // Spec: If newItem is already in a list, it is removed from its previous list before it is inserted into this list. … … 402 437 403 438 commitChange(ListModificationAppend); 404 return newItem; 405 } 406 407 PtrListItemTearOff appendItemValuesAndWrappers(PtrListItemTearOff newItem, ExceptionCode& ec) 408 { 409 ASSERT(m_wrappers); 410 if (!canAlterList(ec)) 439 return ListItemType { newItem }; 440 } 441 442 ExceptionOr<PtrListItemTearOff> appendItemValuesAndWrappers(PtrListItemTearOff newItem) 443 { 444 ASSERT(m_wrappers); 445 446 auto result = canAlterList(); 447 if (result.hasException()) 448 return result.releaseException(); 449 if (!result.releaseReturnValue()) 411 450 return nullptr; 412 451 413 452 // Not specified, but FF/Opera do it this way, and it's just sane. 414 if (!newItem) { 415 ec = SVGException::SVG_WRONG_TYPE_ERR; 416 return nullptr; 417 } 453 if (!newItem) 454 return Exception { SVGException::SVG_WRONG_TYPE_ERR }; 418 455 419 456 ASSERT(m_values->size() == m_wrappers->size()); … … 427 464 428 465 commitChange(ListModificationAppend); 429 return newItem;466 return WTFMove(newItem); 430 467 } 431 468 … … 473 510 474 511 } 475 476 #endif // SVGListProperty_h -
trunk/Source/WebCore/svg/properties/SVGListPropertyTearOff.h
r197563 r207716 18 18 */ 19 19 20 #ifndef SVGListPropertyTearOff_h 21 #define SVGListPropertyTearOff_h 20 #pragma once 22 21 23 22 #include "SVGListProperty.h" … … 79 78 80 79 // SVGList API 81 void clear(ExceptionCode& ec)82 { 83 Base::clearValuesAndWrappers(ec);84 } 85 86 PtrListItemTearOff initialize(PtrListItemTearOff newItem, ExceptionCode& ec)87 { 88 return Base::initializeValuesAndWrappers(newItem , ec);89 } 90 91 PtrListItemTearOff getItem(unsigned index, ExceptionCode& ec)92 { 93 return Base::getItemValuesAndWrappers(m_animatedProperty.get(), index , ec);94 } 95 96 PtrListItemTearOff insertItemBefore(PtrListItemTearOff newItem, unsigned index, ExceptionCode& ec)97 { 98 return Base::insertItemBeforeValuesAndWrappers(newItem, index , ec);99 } 100 101 PtrListItemTearOff replaceItem(PtrListItemTearOff newItem, unsigned index, ExceptionCode& ec)102 { 103 return Base::replaceItemValuesAndWrappers(newItem, index , ec);104 } 105 106 PtrListItemTearOff removeItem(unsigned index, ExceptionCode& ec)107 { 108 return Base::removeItemValuesAndWrappers(m_animatedProperty.get(), index , ec);109 } 110 111 PtrListItemTearOff appendItem(PtrListItemTearOff newItem, ExceptionCode& ec)112 { 113 return Base::appendItemValuesAndWrappers(newItem , ec);80 ExceptionOr<void> clear() 81 { 82 return Base::clearValuesAndWrappers(); 83 } 84 85 ExceptionOr<PtrListItemTearOff> initialize(PtrListItemTearOff newItem) 86 { 87 return Base::initializeValuesAndWrappers(newItem); 88 } 89 90 ExceptionOr<PtrListItemTearOff> getItem(unsigned index) 91 { 92 return Base::getItemValuesAndWrappers(m_animatedProperty.get(), index); 93 } 94 95 ExceptionOr<PtrListItemTearOff> insertItemBefore(PtrListItemTearOff newItem, unsigned index) 96 { 97 return Base::insertItemBeforeValuesAndWrappers(newItem, index); 98 } 99 100 ExceptionOr<PtrListItemTearOff> replaceItem(PtrListItemTearOff newItem, unsigned index) 101 { 102 return Base::replaceItemValuesAndWrappers(newItem, index); 103 } 104 105 ExceptionOr<PtrListItemTearOff> removeItem(unsigned index) 106 { 107 return Base::removeItemValuesAndWrappers(m_animatedProperty.get(), index); 108 } 109 110 ExceptionOr<PtrListItemTearOff> appendItem(PtrListItemTearOff newItem) 111 { 112 return Base::appendItemValuesAndWrappers(newItem); 114 113 } 115 114 … … 215 214 216 215 } 217 218 #endif // SVGListPropertyTearOff_h -
trunk/Source/WebCore/svg/properties/SVGPathSegListPropertyTearOff.cpp
r196268 r207716 36 36 } 37 37 38 void SVGPathSegListPropertyTearOff::clear(ExceptionCode& ec)38 ExceptionOr<void> SVGPathSegListPropertyTearOff::clear() 39 39 { 40 40 ASSERT(m_values); 41 41 if (m_values->isEmpty()) 42 return ;42 return { }; 43 43 44 44 clearContextAndRoles(); 45 SVGPathSegListPropertyTearOff::Base::clearValues(ec);45 return SVGPathSegListPropertyTearOff::Base::clearValues(); 46 46 } 47 47 48 SVGPathSegListPropertyTearOff::PtrListItemType SVGPathSegListPropertyTearOff::getItem(unsigned index, ExceptionCode& ec)48 ExceptionOr<SVGPathSegListPropertyTearOff::PtrListItemType> SVGPathSegListPropertyTearOff::getItem(unsigned index) 49 49 { 50 ListItemType returnedItem = Base::getItemValues(index, ec); 51 if (returnedItem) { 52 ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->contextElement() == contextElement()); 53 ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->role() == m_pathSegRole); 54 } 55 return returnedItem; 50 return Base::getItemValues(index); 56 51 } 57 52 58 SVGPathSegListPropertyTearOff::PtrListItemType SVGPathSegListPropertyTearOff::replaceItem(PtrListItemType newItem, unsigned index, ExceptionCode& ec)53 ExceptionOr<SVGPathSegListPropertyTearOff::PtrListItemType> SVGPathSegListPropertyTearOff::replaceItem(PtrListItemType newItem, unsigned index) 59 54 { 60 55 // Not specified, but FF/Opera do it this way, and it's just sane. 61 if (!newItem) { 62 ec = SVGException::SVG_WRONG_TYPE_ERR; 63 return 0; 64 } 56 if (!newItem) 57 return Exception { SVGException::SVG_WRONG_TYPE_ERR }; 65 58 66 59 if (index < m_values->size()) { … … 70 63 } 71 64 72 return Base::replaceItemValues(newItem, index , ec);65 return Base::replaceItemValues(newItem, index); 73 66 } 74 67 75 SVGPathSegListPropertyTearOff::PtrListItemType SVGPathSegListPropertyTearOff::removeItem(unsigned index, ExceptionCode& ec)68 ExceptionOr<SVGPathSegListPropertyTearOff::PtrListItemType> SVGPathSegListPropertyTearOff::removeItem(unsigned index) 76 69 { 77 SVGPathSegListPropertyTearOff::ListItemType removedItem = SVGPathSegListPropertyTearOff::Base::removeItemValues(index, ec); 70 auto result = SVGPathSegListPropertyTearOff::Base::removeItemValues(index); 71 if (result.hasException()) 72 return result; 73 auto removedItem = result.releaseReturnValue(); 78 74 if (removedItem) 79 static_cast<SVGPathSegWithContext *>(removedItem.get())->setContextAndRole(nullptr, PathSegUndefinedRole);80 return removedItem;75 static_cast<SVGPathSegWithContext&>(*removedItem).setContextAndRole(nullptr, PathSegUndefinedRole); 76 return WTFMove(removedItem); 81 77 } 82 78 -
trunk/Source/WebCore/svg/properties/SVGPathSegListPropertyTearOff.h
r203469 r207716 18 18 */ 19 19 20 #ifndef SVGPathSegListPropertyTearOff_h 21 #define SVGPathSegListPropertyTearOff_h 20 #pragma once 22 21 23 22 #include "SVGAnimatedListPropertyTearOff.h" … … 30 29 class SVGPathSegListPropertyTearOff final : public SVGListProperty<SVGPathSegList> { 31 30 public: 32 typedef SVGListProperty<SVGPathSegList> Base;33 typedef SVGAnimatedListPropertyTearOff<SVGPathSegList> AnimatedListPropertyTearOff;34 typedef SVGPropertyTraits<SVGPathSegList>::ListItemTypeListItemType;35 typedef RefPtr<SVGPathSeg> PtrListItemType;31 using Base = SVGListProperty<SVGPathSegList>; 32 using AnimatedListPropertyTearOff = SVGAnimatedListPropertyTearOff<SVGPathSegList>; 33 using ListItemType = SVGPropertyTraits<SVGPathSegList>::ListItemType; 34 using PtrListItemType = RefPtr<SVGPathSeg>; 36 35 37 36 static Ref<SVGPathSegListPropertyTearOff> create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role, SVGPathSegRole pathSegRole, SVGPathSegList& values, ListWrapperCache& wrappers) … … 66 65 67 66 // SVGList API 68 void clear(ExceptionCode&);67 ExceptionOr<void> clear(); 69 68 70 PtrListItemType initialize(PtrListItemType newItem, ExceptionCode& ec)69 ExceptionOr<PtrListItemType> initialize(PtrListItemType newItem) 71 70 { 72 71 // Not specified, but FF/Opera do it this way, and it's just sane. 73 if (!newItem) { 74 ec = SVGException::SVG_WRONG_TYPE_ERR; 75 return nullptr; 76 } 72 if (!newItem) 73 return Exception { SVGException::SVG_WRONG_TYPE_ERR }; 77 74 78 75 clearContextAndRoles(); 79 return Base::initializeValues(newItem , ec);76 return Base::initializeValues(newItem); 80 77 } 81 78 82 PtrListItemType getItem(unsigned index, ExceptionCode&);79 ExceptionOr<PtrListItemType> getItem(unsigned index); 83 80 84 PtrListItemType insertItemBefore(PtrListItemType newItem, unsigned index, ExceptionCode& ec)81 ExceptionOr<PtrListItemType> insertItemBefore(PtrListItemType newItem, unsigned index) 85 82 { 86 83 // Not specified, but FF/Opera do it this way, and it's just sane. 87 if (!newItem) { 88 ec = SVGException::SVG_WRONG_TYPE_ERR; 89 return 0; 90 } 84 if (!newItem) 85 return Exception { SVGException::SVG_WRONG_TYPE_ERR }; 91 86 92 return Base::insertItemBeforeValues(newItem, index , ec);87 return Base::insertItemBeforeValues(newItem, index); 93 88 } 94 89 95 PtrListItemType replaceItem(PtrListItemType, unsigned index, ExceptionCode&);90 ExceptionOr<PtrListItemType> replaceItem(PtrListItemType, unsigned index); 96 91 97 PtrListItemType removeItem(unsigned index, ExceptionCode&);92 ExceptionOr<PtrListItemType> removeItem(unsigned index); 98 93 99 PtrListItemType appendItem(PtrListItemType newItem, ExceptionCode& ec)94 ExceptionOr<PtrListItemType> appendItem(PtrListItemType newItem) 100 95 { 101 96 // Not specified, but FF/Opera do it this way, and it's just sane. 102 if (!newItem) { 103 ec = SVGException::SVG_WRONG_TYPE_ERR; 104 return nullptr; 105 } 97 if (!newItem) 98 return Exception { SVGException::SVG_WRONG_TYPE_ERR }; 106 99 107 return Base::appendItemValues(newItem , ec);100 return Base::appendItemValues(newItem); 108 101 } 109 102 … … 162 155 163 156 } 164 165 #endif // SVGListPropertyTearOff_h -
trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h
r197967 r207716 19 19 */ 20 20 21 #ifndef SVGPropertyTearOff_h 22 #define SVGPropertyTearOff_h 21 #pragma once 23 22 24 23 #include "SVGAnimatedProperty.h" … … 56 55 { 57 56 return adoptRef(*new Self(initialValue)); 57 } 58 59 template<typename T> static ExceptionOr<Ref<Self>> create(ExceptionOr<T>&& initialValue) 60 { 61 if (initialValue.hasException()) 62 return initialValue.releaseException(); 63 return create(initialValue.releaseReturnValue()); 58 64 } 59 65 … … 173 179 174 180 } 175 176 #endif // SVGPropertyTearOff_h -
trunk/Source/WebCore/svg/properties/SVGStaticListPropertyTearOff.h
r203275 r207716 18 18 */ 19 19 20 #ifndef SVGStaticListPropertyTearOff_h 21 #define SVGStaticListPropertyTearOff_h 20 #pragma once 22 21 23 22 #include "SVGListProperty.h" … … 25 24 namespace WebCore { 26 25 27 template<typename PropertyType> 28 class SVGStaticListPropertyTearOff final : public SVGListProperty<PropertyType> { 26 template<typename PropertyType> class SVGStaticListPropertyTearOff final : public SVGListProperty<PropertyType> { 29 27 public: 30 typedef SVGListProperty<PropertyType> Base; 31 32 typedef typename SVGPropertyTraits<PropertyType>::ListItemType ListItemType; 33 typedef SVGPropertyTearOff<ListItemType> ListItemTearOff; 28 using Base = SVGListProperty<PropertyType>; 29 using ListItemType = typename SVGPropertyTraits<PropertyType>::ListItemType; 30 using ListItemTearOff = SVGPropertyTearOff<ListItemType>; 34 31 35 32 using Base::m_role; … … 38 35 static Ref<SVGStaticListPropertyTearOff<PropertyType>> create(SVGElement& contextElement, PropertyType& values) 39 36 { 40 return adoptRef(*new SVGStaticListPropertyTearOff <PropertyType>(&contextElement, values));37 return adoptRef(*new SVGStaticListPropertyTearOff(contextElement, values)); 41 38 } 42 39 43 // SVGList API 44 void clear(ExceptionCode& ec) 40 ExceptionOr<void> clear() 45 41 { 46 Base::clearValues(ec);42 return Base::clearValues(); 47 43 } 48 44 49 ListItemType initialize(const ListItemType& newItem, ExceptionCode& ec)45 ExceptionOr<ListItemType> initialize(const ListItemType& newItem) 50 46 { 51 return Base::initializeValues(newItem , ec);47 return Base::initializeValues(newItem); 52 48 } 53 49 54 ListItemType getItem(unsigned index, ExceptionCode& ec)50 ExceptionOr<ListItemType> getItem(unsigned index) 55 51 { 56 return Base::getItemValues(index , ec);52 return Base::getItemValues(index); 57 53 } 58 54 59 ListItemType insertItemBefore(const ListItemType& newItem, unsigned index, ExceptionCode& ec)55 ExceptionOr<ListItemType> insertItemBefore(const ListItemType& newItem, unsigned index) 60 56 { 61 return Base::insertItemBeforeValues(newItem, index , ec);57 return Base::insertItemBeforeValues(newItem, index); 62 58 } 63 59 64 ListItemType replaceItem(const ListItemType& newItem, unsigned index, ExceptionCode& ec)60 ExceptionOr<ListItemType> replaceItem(const ListItemType& newItem, unsigned index) 65 61 { 66 return Base::replaceItemValues(newItem, index , ec);62 return Base::replaceItemValues(newItem, index); 67 63 } 68 64 69 ListItemType removeItem(unsigned index, ExceptionCode& ec)65 ExceptionOr<ListItemType> removeItem(unsigned index) 70 66 { 71 return Base::removeItemValues(index , ec);67 return Base::removeItemValues(index); 72 68 } 73 69 74 ListItemType appendItem(const ListItemType& newItem, ExceptionCode& ec)70 ExceptionOr<ListItemType> appendItem(const ListItemType& newItem) 75 71 { 76 return Base::appendItemValues(newItem , ec);72 return Base::appendItemValues(newItem); 77 73 } 78 74 79 75 private: 80 SVGStaticListPropertyTearOff(SVGElement *contextElement, PropertyType& values)81 : SVGListProperty<PropertyType>(UndefinedRole, values, 0)76 SVGStaticListPropertyTearOff(SVGElement& contextElement, PropertyType& values) 77 : SVGListProperty<PropertyType>(UndefinedRole, values, nullptr) 82 78 , m_contextElement(contextElement) 83 79 { … … 92 88 { 93 89 ASSERT(m_values); 94 m_values->commitChange(m_contextElement. get());90 m_values->commitChange(m_contextElement.ptr()); 95 91 } 96 92 … … 107 103 } 108 104 109 private: 110 RefPtr<SVGElement> m_contextElement; 105 Ref<SVGElement> m_contextElement; 111 106 }; 112 107 113 108 } 114 115 #endif // SVGStaticListPropertyTearOff_h -
trunk/Source/WebCore/svg/properties/SVGTransformListPropertyTearOff.h
r203275 r207716 18 18 */ 19 19 20 #ifndef SVGTransformListPropertyTearOff_h 21 #define SVGTransformListPropertyTearOff_h 20 #pragma once 22 21 23 22 #include "SVGListPropertyTearOff.h" … … 26 25 namespace WebCore { 27 26 28 // SVGTransformList contains two additional methods, that can be exposed to the bindings.29 27 class SVGTransformListPropertyTearOff final : public SVGListPropertyTearOff<SVGTransformList> { 30 28 public: 31 typedef SVGAnimatedListPropertyTearOff<SVGTransformList> AnimatedListPropertyTearOff;32 typedef SVGAnimatedListPropertyTearOff<SVGTransformList>::ListWrapperCacheListWrapperCache;29 using AnimatedListPropertyTearOff = SVGAnimatedListPropertyTearOff<SVGTransformList>; 30 using ListWrapperCache = AnimatedListPropertyTearOff::ListWrapperCache; 33 31 34 32 static Ref<SVGListPropertyTearOff<SVGTransformList>> create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role, SVGTransformList& values, ListWrapperCache& wrappers) … … 38 36 } 39 37 40 RefPtr<SVGPropertyTearOff<SVGTransform>> createSVGTransformFromMatrix(SVGPropertyTearOff<SVGMatrix>* matrix, ExceptionCode& ec)38 ExceptionOr<Ref<SVGPropertyTearOff<SVGTransform>>> createSVGTransformFromMatrix(SVGPropertyTearOff<SVGMatrix>* matrix) 41 39 { 42 40 ASSERT(m_values); 43 if (!matrix) { 44 ec = TYPE_MISMATCH_ERR; 45 return nullptr; 46 } 41 if (!matrix) 42 return Exception { TYPE_MISMATCH_ERR }; 47 43 return SVGPropertyTearOff<SVGTransform>::create(m_values->createSVGTransformFromMatrix(matrix->propertyReference())); 48 44 } 49 45 50 RefPtr<SVGPropertyTearOff<SVGTransform>> consolidate(ExceptionCode& ec)46 ExceptionOr<RefPtr<SVGPropertyTearOff<SVGTransform>>> consolidate() 51 47 { 52 48 ASSERT(m_values); 53 49 ASSERT(m_wrappers); 54 if (!canAlterList(ec)) 50 51 auto result = canAlterList(); 52 if (result.hasException()) 53 return result.releaseException(); 54 if (!result.releaseReturnValue()) 55 55 return nullptr; 56 56 … … 66 66 67 67 ASSERT(m_values->size() == m_wrappers->size()); 68 return wrapper;68 return WTFMove(wrapper); 69 69 } 70 70 … … 77 77 78 78 } 79 80 #endif // SVGListPropertyTearOff_h
Note:
See TracChangeset
for help on using the changeset viewer.