Changeset 71014 in webkit
- Timestamp:
- Nov 1, 2010 1:57:11 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 27 added
- 2 deleted
- 18 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r71013 r71014 1 2010-11-01 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Rob Buis. 4 5 Enable StrictTypeChecking for all types using SVG(Animated)PropertyTearOff 6 https://bugs.webkit.org/show_bug.cgi?id=48715 7 8 * svg/dom/SVGAngle-expected.txt: 9 * svg/dom/SVGAnimatedAngle-expected.txt: Added. 10 * svg/dom/SVGAnimatedAngle.html: Added. 11 * svg/dom/SVGAnimatedBoolean-expected.txt: Copied from LayoutTests/svg/dom/SVGExternalResourcesRequired-expected.txt. 12 * svg/dom/SVGAnimatedBoolean.html: Copied from LayoutTests/svg/dom/SVGExternalResourcesRequired.html. 13 * svg/dom/SVGAnimatedEnumeration-expected.txt: Added. 14 * svg/dom/SVGAnimatedEnumeration.html: Added. 15 * svg/dom/SVGAnimatedInteger-expected.txt: Added. 16 * svg/dom/SVGAnimatedInteger.html: Added. 17 * svg/dom/SVGAnimatedLength-expected.txt: Added. 18 * svg/dom/SVGAnimatedLength.html: Added. 19 * svg/dom/SVGAnimatedLengthList-expected.txt: Added. 20 * svg/dom/SVGAnimatedLengthList.html: Added. 21 * svg/dom/SVGAnimatedRect-expected.txt: Added. 22 * svg/dom/SVGAnimatedRect.html: Added. 23 * svg/dom/SVGExternalResourcesRequired-expected.txt: Removed. 24 * svg/dom/SVGExternalResourcesRequired.html: Removed. 25 * svg/dom/SVGLength-expected.txt: Added. 26 * svg/dom/SVGLength-px-expected.txt: Added. 27 * svg/dom/SVGLength-px-with-context-expected.txt: Added. 28 * svg/dom/SVGLength-px-with-context.html: Added. 29 * svg/dom/SVGLength-px.html: Added. 30 * svg/dom/SVGLength.html: Added. 31 * svg/dom/script-tests/SVGAngle.js: 32 * svg/dom/script-tests/SVGAnimatedAngle.js: Added. 33 * svg/dom/script-tests/SVGAnimatedBoolean.js: Copied from LayoutTests/svg/dom/script-tests/SVGExternalResourcesRequired.js. 34 * svg/dom/script-tests/SVGAnimatedEnumeration.js: Added. 35 * svg/dom/script-tests/SVGAnimatedInteger.js: Added. 36 * svg/dom/script-tests/SVGAnimatedLength.js: Added. 37 * svg/dom/script-tests/SVGAnimatedLengthList.js: Added. 38 * svg/dom/script-tests/SVGAnimatedRect.js: Added. 39 * svg/dom/script-tests/SVGExternalResourcesRequired.js: Removed. 40 * svg/dom/script-tests/SVGLength-px-with-context.js: Added. Tests various operations on a SVGLength object obtained via rectElement.x.baseVal. 41 * svg/dom/script-tests/SVGLength-px.js: Added. Tests various operations on a SVGLength object created via svgElement.createSVGLength(). 42 * svg/dom/script-tests/SVGLength.js: Added. 43 * svg/dom/svg-length-units-expected.txt: Removed. 44 * svg/dom/svg-length-units.html: Removed. Test is obsolete now, as SVGLength* covers this in detail. 45 * svg/dynamic-updates/script-tests/SVGCircleElement-svgdom-cx-prop.js: 46 (executeTest): Fixed StrictTypeChecking correctness, don't assign strings as SVGLength value. 47 * svg/dynamic-updates/script-tests/SVGCircleElement-svgdom-cy-prop.js: 48 (executeTest): Ditto. 49 * svg/dynamic-updates/script-tests/SVGCircleElement-svgdom-r-prop.js: 50 (executeTest): Ditto. 51 * svg/dynamic-updates/script-tests/SVGEllipseElement-svgdom-cx-prop.js: 52 (executeTest): Ditto. 53 * svg/dynamic-updates/script-tests/SVGEllipseElement-svgdom-cy-prop.js: 54 (executeTest): Ditto. 55 * svg/dynamic-updates/script-tests/SVGEllipseElement-svgdom-rx-prop.js: 56 (executeTest): Ditto. 57 * svg/dynamic-updates/script-tests/SVGEllipseElement-svgdom-ry-prop.js: 58 (executeTest): Ditto. 59 * svg/dynamic-updates/script-tests/SVGForeignObjectElement-svgdom-height-prop.js: 60 (executeTest): Ditto. 61 * svg/dynamic-updates/script-tests/SVGForeignObjectElement-svgdom-width-prop.js: 62 (executeTest): Ditto. 63 * svg/dynamic-updates/script-tests/SVGForeignObjectElement-svgdom-x-prop.js: 64 (executeTest): Ditto. 65 * svg/dynamic-updates/script-tests/SVGForeignObjectElement-svgdom-y-prop.js: 66 (executeTest): Ditto. 67 1 68 2010-11-01 Roland Steiner <rolandsteiner@chromium.org> 2 69 -
trunk/LayoutTests/svg/dom/SVGAngle-expected.txt
r70410 r71014 15 15 PASS angle.convertToSpecifiedUnits(-1) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 16 16 PASS angle.convertToSpecifiedUnits(5) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 17 PASS angle.convertToSpecifiedUnits('aString') threw exception TypeError: Type error. 18 PASS angle.convertToSpecifiedUnits(angle) threw exception TypeError: Type error. 19 PASS angle.convertToSpecifiedUnits(svgElement) threw exception TypeError: Type error. 20 PASS angle.convertToSpecifiedUnits() threw exception SyntaxError: Not enough arguments. 17 21 PASS angle.unitType is SVGAngle.SVG_ANGLETYPE_UNSPECIFIED 18 22 … … 43 47 PASS angle.newValueSpecifiedUnits(-1, 50) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 44 48 PASS angle.newValueSpecifiedUnits(5, 50) threw exception Error: NOT_SUPPORTED_ERR: DOM Exception 9. 49 PASS angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG) threw exception SyntaxError: Not enough arguments. 50 PASS angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 'aString') threw exception TypeError: Type error. 51 PASS angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, angle) threw exception TypeError: Type error. 52 PASS angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, svgElement) threw exception TypeError: Type error. 53 PASS angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG) threw exception SyntaxError: Not enough arguments. 54 PASS angle.newValueSpecifiedUnits('aString', 4) threw exception TypeError: Type error. 55 PASS angle.newValueSpecifiedUnits(angle, 4) threw exception TypeError: Type error. 56 PASS angle.newValueSpecifiedUnits(svgElement, 4) threw exception TypeError: Type error. 57 PASS angle.newValueSpecifiedUnits('aString', 'aString') threw exception TypeError: Type error. 58 PASS angle.newValueSpecifiedUnits(angle, angle) threw exception TypeError: Type error. 59 PASS angle.newValueSpecifiedUnits(svgElement, svgElement) threw exception TypeError: Type error. 60 PASS angle.newValueSpecifiedUnits() threw exception SyntaxError: Not enough arguments. 45 61 PASS angle.unitType is SVGAngle.SVG_ANGLETYPE_UNSPECIFIED 46 62 -
trunk/LayoutTests/svg/dom/SVGAnimatedBoolean-expected.txt
r70977 r71014 1 This test checks the SVG ExternalResourcesRequired API1 This test checks the SVGAnimatedBoolean API - utilizing the externalResourcesRequired property of SVGRectElement 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". -
trunk/LayoutTests/svg/dom/SVGAnimatedBoolean.html
r70977 r71014 8 8 <p id="description"></p> 9 9 <div id="console"></div> 10 <script src="script-tests/SVG ExternalResourcesRequired.js"></script>10 <script src="script-tests/SVGAnimatedBoolean.js"></script> 11 11 <script src="../../fast/js/resources/js-test-post.js"></script> 12 12 </body> -
trunk/LayoutTests/svg/dom/SVGAnimatedNumberList-expected.txt
r70979 r71014 14 14 PASS textElement.rotate.baseVal.getItem(0).value is 100 15 15 16 Check assigning to baseVal has no effect, as no setter is defined16 Check that assigning to baseVal has no effect, as no setter is defined 17 17 PASS textElement.rotate.baseVal = -1 is -1 18 18 PASS textElement.rotate.baseVal = 'aString' is "aString" -
trunk/LayoutTests/svg/dom/script-tests/SVGAngle.js
r70410 r71014 17 17 shouldThrow("angle.convertToSpecifiedUnits(-1)"); 18 18 shouldThrow("angle.convertToSpecifiedUnits(5)"); 19 shouldThrow("angle.convertToSpecifiedUnits('aString')"); 20 shouldThrow("angle.convertToSpecifiedUnits(angle)"); 21 shouldThrow("angle.convertToSpecifiedUnits(svgElement)"); 22 shouldThrow("angle.convertToSpecifiedUnits()"); 19 23 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED"); 20 24 … … 51 55 shouldThrow("angle.newValueSpecifiedUnits(-1, 50)"); 52 56 shouldThrow("angle.newValueSpecifiedUnits(5, 50)"); 57 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG)"); 58 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 'aString')"); 59 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, angle)"); 60 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, svgElement)"); 61 shouldThrow("angle.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG)"); 62 shouldThrow("angle.newValueSpecifiedUnits('aString', 4)"); 63 shouldThrow("angle.newValueSpecifiedUnits(angle, 4)"); 64 shouldThrow("angle.newValueSpecifiedUnits(svgElement, 4)"); 65 shouldThrow("angle.newValueSpecifiedUnits('aString', 'aString')"); 66 shouldThrow("angle.newValueSpecifiedUnits(angle, angle)"); 67 shouldThrow("angle.newValueSpecifiedUnits(svgElement, svgElement)"); 68 shouldThrow("angle.newValueSpecifiedUnits()"); 53 69 shouldBe("angle.unitType", "SVGAngle.SVG_ANGLETYPE_UNSPECIFIED"); 54 70 -
trunk/LayoutTests/svg/dom/script-tests/SVGAnimatedBoolean.js
r70977 r71014 1 description("This test checks the SVG ExternalResourcesRequired API");1 description("This test checks the SVGAnimatedBoolean API - utilizing the externalResourcesRequired property of SVGRectElement"); 2 2 3 3 var rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect"); -
trunk/LayoutTests/svg/dom/script-tests/SVGAnimatedNumberList.js
r70979 r71014 18 18 19 19 debug(""); 20 debug("Check assigning to baseVal has no effect, as no setter is defined");20 debug("Check that assigning to baseVal has no effect, as no setter is defined"); 21 21 shouldBe("textElement.rotate.baseVal = -1", "-1"); 22 22 shouldBeEqualToString("textElement.rotate.baseVal = 'aString'", "aString"); -
trunk/WebCore/ChangeLog
r71010 r71014 1 2010-11-01 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Rob Buis. 4 5 Enable StrictTypeChecking for all types using SVG(Animated)PropertyTearOff 6 https://bugs.webkit.org/show_bug.cgi?id=48715 7 8 Enable StrictTypeChecking for all readwrite attributes and function calls of all types using the new SVG(Animated)PropertyTearOff concept. 9 Also enable RequiresAllArguments=Raise for all function calls of these new types. Cover this functionality by tests for each of them. 10 11 When testing SVGLength it became obvious that quite a lot of functionality was missing. 12 Conversion from relative arguments (percentage, ems, exs) to user specified units was missing, added that functionality and tested it. 13 User units to pt conversion was wrong, fixed that. 14 15 Tests: svg/dom/SVGAnimatedAngle.html 16 svg/dom/SVGAnimatedBoolean.html 17 svg/dom/SVGAnimatedEnumeration.html 18 svg/dom/SVGAnimatedInteger.html 19 svg/dom/SVGAnimatedLength.html 20 svg/dom/SVGAnimatedLengthList.html 21 svg/dom/SVGAnimatedRect.html 22 svg/dom/SVGLength-px-with-context.html 23 svg/dom/SVGLength-px.html 24 svg/dom/SVGLength.html 25 26 * bindings/js/JSSVGLengthCustom.cpp: These SVGLength methods now take an ExceptionCode parameter, adapt to that. 27 (WebCore::JSSVGLength::value): 28 (WebCore::JSSVGLength::setValue): 29 (WebCore::JSSVGLength::convertToSpecifiedUnits): 30 * bindings/scripts/CodeGeneratorObjC.pm: Remove FIXMEs, pass real context instead off null pointer. DOMSVGLength::value is functional now. 31 * bindings/v8/custom/V8SVGLengthCustom.cpp: These SVGLength methods now take an ExceptionCode parameter, adapt to that. 32 (WebCore::V8SVGLength::valueAccessorGetter): 33 (WebCore::V8SVGLength::valueAccessorSetter): 34 (WebCore::V8SVGLength::convertToSpecifiedUnitsCallback): 35 * rendering/style/SVGRenderStyle.h: Adapt to SVGLength API changes. 36 (WebCore::SVGRenderStyle::initialBaselineShiftValue): 37 (WebCore::SVGRenderStyle::initialKerning): 38 (WebCore::SVGRenderStyle::initialStrokeDashOffset): 39 (WebCore::SVGRenderStyle::initialStrokeWidth): 40 * svg/SVGAngle.idl: Add StrictTypeChecking, RequiresAllArguments=Raise to all methods. 41 * svg/SVGAnimatedBoolean.idl: Remove StrictTypeChecking from animVal, it's readonly so this is useless. 42 * svg/SVGAnimatedEnumeration.idl: Add StrictTypeChecking to all attributes. 43 * svg/SVGAnimatedInteger.idl: Ditto. 44 * svg/SVGLength.cpp: Implement all missing features of SVGLength. Conform to our style guide (s/.0f// etc) 45 (WebCore::lengthTypeToString): 46 (WebCore::SVGLength::SVGLength): 47 (WebCore::SVGLength::value): Throw NOT_SUPPORTED_ERR when trying to obtain to relative units, when no context is given (SVGLength created by createSVGLength()). 48 (WebCore::SVGLength::setValue): Ditto, for the setter. 49 (WebCore::SVGLength::valueAsPercentage): Use m_valueInSpecifiedUnits instead of valueInSpecifiedUnits(). 50 (WebCore::SVGLength::setValueAsString): Throw SYNTAX_ERR if parsing failed. 51 (WebCore::SVGLength::valueAsString): Use makeString() instead of String and operator+. 52 (WebCore::SVGLength::newValueSpecifiedUnits): Add ExceptionCode parameter, throw NOT_SUPPORTED_ERR, if the given unit type is invalid. 53 (WebCore::SVGLength::convertToSpecifiedUnits): Ditto. 54 (WebCore::SVGLength::determineViewport): Added helper function used by convertValue*Percentage*. 55 (WebCore::SVGLength::convertValueFromUserUnitsToPercentage): Add new helper functions, used by value/setValue. 56 (WebCore::SVGLength::convertValueFromPercentageToUserUnits): Ditto. 57 (WebCore::SVGLength::convertValueFromUserUnitsToEMS): Ditto. 58 (WebCore::SVGLength::convertValueFromEMSToUserUnits): Ditto. 59 (WebCore::SVGLength::convertValueFromUserUnitsToEXS): Ditto. 60 (WebCore::SVGLength::convertValueFromEXSToUserUnits): Ditto. 61 (WebCore::SVGLength::fromCSSPrimitiveValue): Adapt to newValueSpecifiedUnits API change. 62 (WebCore::SVGLength::toCSSPrimitiveValue): Remove default switch case. 63 * svg/SVGLength.h: 64 (WebCore::SVGLength::valueInSpecifiedUnits): Inlined. 65 (WebCore::SVGLength::setValueInSpecifiedUnits): Ditto. 66 (WebCore::SVGLength::isRelative): 67 * svg/SVGLength.idl: Add StrictTypeChecking for all attributes/functions and RequiresAllArguments=Raise for all functions. 68 * svg/SVGLengthList.cpp: Adapt to SVGLength API changes. 69 (WebCore::SVGLengthList::parse): 70 1 71 2010-10-31 Pavel Feldman <pfeldman@chromium.org> 2 72 -
trunk/WebCore/bindings/js/JSSVGLengthCustom.cpp
r70496 r71014 23 23 #include "JSSVGLength.h" 24 24 25 #include <runtime/Error.h> 25 26 #include "SVGAnimatedProperty.h" 27 #include "SVGException.h" 26 28 27 29 using namespace JSC; … … 29 31 namespace WebCore { 30 32 31 JSValue JSSVGLength::value(ExecState* ) const33 JSValue JSSVGLength::value(ExecState* exec) const 32 34 { 33 35 SVGLength& podImp = impl()->propertyReference(); 34 return jsNumber(podImp.value(impl()->contextElement())); 36 ExceptionCode ec = 0; 37 float value = podImp.value(impl()->contextElement(), ec); 38 if (ec) { 39 setDOMException(exec, ec); 40 return jsUndefined(); 41 } 42 43 return jsNumber(value); 44 } 45 46 void JSSVGLength::setValue(ExecState* exec, JSValue value) 47 { 48 if (!value.isUndefinedOrNull() && !value.isNumber() && !value.isBoolean()) { 49 throwVMTypeError(exec); 50 return; 51 } 52 53 SVGLength& podImp = impl()->propertyReference(); 54 55 ExceptionCode ec = 0; 56 podImp.setValue(value.toFloat(exec), impl()->contextElement(), ec); 57 if (ec) { 58 setDOMException(exec, ec); 59 return; 60 } 61 62 impl()->commitChange(); 35 63 } 36 64 … … 38 66 { 39 67 SVGLength& podImp = impl()->propertyReference(); 40 podImp.convertToSpecifiedUnits(exec->argument(0).toInt32(exec), impl()->contextElement()); 68 69 // Mimic the behaviour of RequiresAllArguments=Raise. 70 if (exec->argumentCount() < 1) 71 return throwError(exec, createSyntaxError(exec, "Not enough arguments")); 72 73 unsigned short unitType = exec->argument(0).toUInt32(exec); 74 if (exec->hadException()) 75 return jsUndefined(); 76 77 ExceptionCode ec = 0; 78 podImp.convertToSpecifiedUnits(unitType, impl()->contextElement(), ec); 79 if (ec) { 80 setDOMException(exec, ec); 81 return jsUndefined(); 82 } 41 83 42 84 impl()->commitChange(); -
trunk/WebCore/bindings/scripts/CodeGeneratorObjC.pm
r70979 r71014 1 # 1 # 2 2 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 3 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> … … 1247 1247 # TODO: Handle special case for DOMSVGLength. We do need Custom code support for this. 1248 1248 if ($svgPropertyType eq "WebCore::SVGLength" and $attributeName eq "value") { 1249 $getterContentHead = "value( 0 /* FIXME */";1249 $getterContentHead = "value(IMPL->contextElement(), "; 1250 1250 } 1251 1251 } … … 1394 1394 push(@implContent, " podImpl = $arg;\n"); 1395 1395 } else { 1396 push(@implContent, " podImpl.$coreSetterName($arg$ec);\n"); 1396 # FIXME: Special case for DOMSVGLength. We do need Custom code support for this. 1397 if ($svgPropertyType eq "WebCore::SVGLength" and $attributeName eq "value") { 1398 push(@implContent, " podImpl.$coreSetterName($arg, IMPL->contextElement()$ec);\n"); 1399 } else { 1400 push(@implContent, " podImpl.$coreSetterName($arg$ec);\n"); 1401 } 1397 1402 } 1398 1403 … … 1529 1534 my $svgLengthConvertToSpecifiedUnits = ($svgPropertyType and $svgPropertyType eq "WebCore::SVGLength" and $functionName eq "convertToSpecifiedUnits"); 1530 1535 1536 push(@parameterNames, "IMPL->contextElement()") if $svgLengthConvertToSpecifiedUnits; 1531 1537 push(@parameterNames, "ec") if $raisesExceptions and !($svgMatrixRotateFromVector || $svgMatrixInverse); 1532 push(@parameterNames, "0 /* FIXME */") if $svgLengthConvertToSpecifiedUnits;1533 1538 1534 1539 # Handle arguments that are 'SVGProperty' based (SVGAngle/SVGLength). We need to convert from SVGPropertyTearOff<Type>* to Type, -
trunk/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp
r70223 r71014 36 36 #include "SVGPropertyTearOff.h" 37 37 #include "V8Binding.h" 38 #include "V8BindingMacros.h" 38 39 39 40 namespace WebCore { … … 41 42 v8::Handle<v8::Value> V8SVGLength::valueAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 42 43 { 43 INC_STATS("DOM.SVGLength.value ");44 INC_STATS("DOM.SVGLength.value._get"); 44 45 SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(info.Holder()); 45 46 SVGLength& imp = wrapper->propertyReference(); 46 return v8::Number::New(imp.value(wrapper->contextElement())); 47 ExceptionCode ec = 0; 48 float value = imp.value(wrapper->contextElement(), ec); 49 if (UNLIKELY(ec)) { 50 V8Proxy::setDOMException(ec); 51 return v8::Handle<v8::Value>(); 52 } 53 return v8::Number::New(value); 54 } 55 56 void V8SVGLength::valueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) 57 { 58 INC_STATS("DOM.SVGLength.value._set"); 59 if (!isUndefinedOrNull(value) && !value->IsNumber() && !value->IsBoolean()) { 60 V8Proxy::throwTypeError(); 61 return; 62 } 63 64 SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(info.Holder()); 65 SVGLength& imp = wrapper->propertyReference(); 66 ExceptionCode ec = 0; 67 imp.setValue(static_cast<float>(value->NumberValue()), wrapper->contextElement(), ec); 68 if (UNLIKELY(ec)) 69 V8Proxy::setDOMException(ec); 70 else 71 wrapper->commitChange(); 47 72 } 48 73 … … 50 75 { 51 76 INC_STATS("DOM.SVGLength.convertToSpecifiedUnits"); 77 if (args.Length() < 1) 78 return throwError("Not enough arguments", V8Proxy::SyntaxError); 79 52 80 SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(args.Holder()); 53 81 SVGLength& imp = wrapper->propertyReference(); 54 imp.convertToSpecifiedUnits(toInt32(args[0]), wrapper->contextElement()); 55 wrapper->commitChange(); 56 return v8::Undefined(); 82 ExceptionCode ec = 0; 83 EXCEPTION_BLOCK(int, unitType, toUInt32(args[0])); 84 imp.convertToSpecifiedUnits(unitType, wrapper->contextElement(), ec); 85 if (UNLIKELY(ec)) 86 V8Proxy::setDOMException(ec); 87 else 88 wrapper->commitChange(); 89 return v8::Handle<v8::Value>(); 57 90 } 58 91 -
trunk/WebCore/rendering/style/SVGRenderStyle.h
r69220 r71014 93 93 { 94 94 SVGLength length; 95 length.newValueSpecifiedUnits(LengthTypeNumber, 0); 95 ExceptionCode ec = 0; 96 length.newValueSpecifiedUnits(LengthTypeNumber, 0, ec); 97 ASSERT(!ec); 96 98 return length; 97 99 } … … 100 102 { 101 103 SVGLength length; 102 length.newValueSpecifiedUnits(LengthTypeNumber, 0); 104 ExceptionCode ec = 0; 105 length.newValueSpecifiedUnits(LengthTypeNumber, 0, ec); 106 ASSERT(!ec); 103 107 return length; 104 108 } … … 107 111 { 108 112 SVGLength length; 109 length.newValueSpecifiedUnits(LengthTypeNumber, 0); 113 ExceptionCode ec = 0; 114 length.newValueSpecifiedUnits(LengthTypeNumber, 0, ec); 115 ASSERT(!ec); 110 116 return length; 111 117 } … … 114 120 { 115 121 SVGLength length; 116 length.newValueSpecifiedUnits(LengthTypeNumber, 1); 122 ExceptionCode ec = 0; 123 length.newValueSpecifiedUnits(LengthTypeNumber, 1, ec); 124 ASSERT(!ec); 117 125 return length; 118 126 } -
trunk/WebCore/svg/SVGAngle.idl
r70631 r71014 38 38 setter raises(DOMException); 39 39 40 void newValueSpecifiedUnits(in unsigned short unitType, in float valueInSpecifiedUnits)40 [StrictTypeChecking, RequiresAllArguments=Raise] void newValueSpecifiedUnits(in unsigned short unitType, in float valueInSpecifiedUnits) 41 41 raises(DOMException); 42 42 43 void convertToSpecifiedUnits(in unsigned short unitType)43 [StrictTypeChecking, RequiresAllArguments=Raise] void convertToSpecifiedUnits(in unsigned short unitType) 44 44 raises(DOMException); 45 45 }; -
trunk/WebCore/svg/SVGAnimatedBoolean.idl
r70857 r71014 28 28 interface [Conditional=SVG] SVGAnimatedBoolean { 29 29 attribute [StrictTypeChecking] boolean baseVal; 30 readonly attribute [StrictTypeChecking]boolean animVal;30 readonly attribute boolean animVal; 31 31 }; 32 32 -
trunk/WebCore/svg/SVGAnimatedEnumeration.idl
r70872 r71014 27 27 28 28 interface [Conditional=SVG] SVGAnimatedEnumeration { 29 attribute unsigned short baseVal;29 attribute [StrictTypeChecking] unsigned short baseVal; 30 30 readonly attribute unsigned short animVal; 31 31 }; -
trunk/WebCore/svg/SVGAnimatedInteger.idl
r64579 r71014 27 27 28 28 interface [Conditional=SVG] SVGAnimatedInteger { 29 attribute long baseVal 30 /*setter raises(DOMException)*/; 29 attribute [StrictTypeChecking] long baseVal; 31 30 readonly attribute long animVal; 32 31 }; -
trunk/WebCore/svg/SVGLength.cpp
r68307 r71014 28 28 #include "FloatConversion.h" 29 29 #include "FrameView.h" 30 #include "NotImplemented.h"31 30 #include "RenderObject.h" 32 31 #include "RenderView.h" … … 34 33 #include "SVGSVGElement.h" 35 34 36 #include < math.h>37 #include <wtf/ Assertions.h>35 #include <wtf/MathExtras.h> 36 #include <wtf/text/StringConcatenate.h> 38 37 39 38 namespace WebCore { … … 84 83 } 85 84 85 ASSERT_NOT_REACHED(); 86 86 return String(); 87 87 } … … 127 127 128 128 SVGLength::SVGLength(SVGLengthMode mode, const String& valueAsString) 129 : m_valueInSpecifiedUnits(0 .0f)129 : m_valueInSpecifiedUnits(0) 130 130 , m_unit(storeUnit(mode, LengthTypeNumber)) 131 131 { 132 setValueAsString(valueAsString); 132 ExceptionCode ec = 0; 133 setValueAsString(valueAsString, ec); 133 134 } 134 135 … … 157 158 float SVGLength::value(const SVGElement* context) const 158 159 { 159 SVGLengthType type = extractType(m_unit); 160 if (type == LengthTypeUnknown) 161 return 0.0f; 162 163 switch (type) { 160 ExceptionCode ec = 0; 161 return value(context, ec); 162 } 163 164 float SVGLength::value(const SVGElement* context, ExceptionCode& ec) const 165 { 166 switch (extractType(m_unit)) { 167 case LengthTypeUnknown: 168 ec = NOT_SUPPORTED_ERR; 169 return 0; 164 170 case LengthTypeNumber: 165 171 return m_valueInSpecifiedUnits; 166 172 case LengthTypePercentage: 167 return SVGLength::PercentageOfViewport(m_valueInSpecifiedUnits / 100.0f, context, extractMode(m_unit));173 return convertValueFromPercentageToUserUnits(m_valueInSpecifiedUnits / 100, context, ec); 168 174 case LengthTypeEMS: 175 return convertValueFromEMSToUserUnits(m_valueInSpecifiedUnits, context, ec); 169 176 case LengthTypeEXS: 170 { 171 RenderStyle* style = 0; 172 if (context && context->renderer()) 173 style = context->renderer()->style(); 174 if (style) { 175 float useSize = style->fontSize(); 176 ASSERT(useSize > 0); 177 if (type == LengthTypeEMS) 178 return m_valueInSpecifiedUnits * useSize; 179 else { 180 float xHeight = style->font().xHeight(); 181 // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg 182 // if this causes problems in real world cases maybe it would be best to remove this 183 return m_valueInSpecifiedUnits * ceilf(xHeight); 184 } 185 } 186 return 0.0f; 187 } 177 return convertValueFromEXSToUserUnits(m_valueInSpecifiedUnits, context, ec); 188 178 case LengthTypePX: 189 179 return m_valueInSpecifiedUnits; … … 195 185 return m_valueInSpecifiedUnits * cssPixelsPerInch; 196 186 case LengthTypePT: 197 return m_valueInSpecifiedUnits / 72 .0f* cssPixelsPerInch;187 return m_valueInSpecifiedUnits / 72 * cssPixelsPerInch; 198 188 case LengthTypePC: 199 return m_valueInSpecifiedUnits / 6.0f * cssPixelsPerInch; 200 default: 201 break; 189 return m_valueInSpecifiedUnits / 6 * cssPixelsPerInch; 202 190 } 203 191 204 192 ASSERT_NOT_REACHED(); 205 return 0 .0f;206 } 207 208 void SVGLength::setValue(float value )209 { 210 SVGLengthType type = extractType(m_unit);211 ASSERT(type != LengthTypeUnknown);212 213 switch (type) {193 return 0; 194 } 195 196 void SVGLength::setValue(float value, const SVGElement* context, ExceptionCode& ec) 197 { 198 switch (extractType(m_unit)) { 199 case LengthTypeUnknown: 200 ec = NOT_SUPPORTED_ERR; 201 break; 214 202 case LengthTypeNumber: 215 203 m_valueInSpecifiedUnits = value; 216 204 break; 217 205 case LengthTypePercentage: 206 { 207 float result = convertValueFromUserUnitsToPercentage(value, context, ec); 208 if (!ec) 209 m_valueInSpecifiedUnits = result; 210 break; 211 } 218 212 case LengthTypeEMS: 213 { 214 float result = convertValueFromUserUnitsToEMS(value, context, ec); 215 if (!ec) 216 m_valueInSpecifiedUnits = result; 217 break; 218 } 219 219 case LengthTypeEXS: 220 notImplemented(); 221 break; 220 { 221 float result = convertValueFromUserUnitsToEXS(value, context, ec); 222 if (!ec) 223 m_valueInSpecifiedUnits = result; 224 break; 225 } 222 226 case LengthTypePX: 223 227 m_valueInSpecifiedUnits = value; … … 233 237 break; 234 238 case LengthTypePT: 235 m_valueInSpecifiedUnits = value * 72 .0f/ cssPixelsPerInch;239 m_valueInSpecifiedUnits = value * 72 / cssPixelsPerInch; 236 240 break; 237 241 case LengthTypePC: 238 m_valueInSpecifiedUnits = value / 6.0f * cssPixelsPerInch; 239 break; 240 default: 241 break; 242 } 243 } 244 245 void SVGLength::setValueInSpecifiedUnits(float value) 246 { 247 m_valueInSpecifiedUnits = value; 248 } 249 250 float SVGLength::valueInSpecifiedUnits() const 251 { 252 return m_valueInSpecifiedUnits; 242 m_valueInSpecifiedUnits = value * 6 / cssPixelsPerInch; 243 break; 244 } 253 245 } 254 246 … … 257 249 // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed 258 250 if (extractType(m_unit) == LengthTypePercentage) 259 return valueInSpecifiedUnits() / 100.0f; 260 261 return valueInSpecifiedUnits(); 262 } 263 264 bool SVGLength::setValueAsString(const String& s) 265 { 266 if (s.isEmpty()) 267 return false; 268 269 float convertedNumber = 0.0f; 270 const UChar* ptr = s.characters(); 271 const UChar* end = ptr + s.length(); 272 273 if (!parseNumber(ptr, end, convertedNumber, false)) 274 return false; 251 return m_valueInSpecifiedUnits / 100; 252 253 return m_valueInSpecifiedUnits; 254 } 255 256 void SVGLength::setValueAsString(const String& string, ExceptionCode& ec) 257 { 258 if (string.isEmpty()) 259 return; 260 261 float convertedNumber = 0; 262 const UChar* ptr = string.characters(); 263 const UChar* end = ptr + string.length(); 264 265 if (!parseNumber(ptr, end, convertedNumber, false)) { 266 ec = SYNTAX_ERR; 267 return; 268 } 275 269 276 270 SVGLengthType type = stringToLengthType(ptr, end); 277 if (type == LengthTypeUnknown) 278 return false; 271 if (type == LengthTypeUnknown) { 272 ec = SYNTAX_ERR; 273 return; 274 } 279 275 280 276 m_unit = storeUnit(extractMode(m_unit), type); 281 277 m_valueInSpecifiedUnits = convertedNumber; 282 return true;283 278 } 284 279 285 280 String SVGLength::valueAsString() const 286 281 { 287 return String::number(m_valueInSpecifiedUnits) + lengthTypeToString(extractType(m_unit)); 288 } 289 290 void SVGLength::newValueSpecifiedUnits(unsigned short type, float value) 291 { 292 if (type == LengthTypeUnknown || type > LengthTypePC) 293 return; 294 295 m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type); 282 return makeString(String::number(m_valueInSpecifiedUnits), lengthTypeToString(extractType(m_unit))); 283 } 284 285 void SVGLength::newValueSpecifiedUnits(unsigned short type, float value, ExceptionCode& ec) 286 { 287 if (type == LengthTypeUnknown || type > LengthTypePC) { 288 ec = NOT_SUPPORTED_ERR; 289 return; 290 } 291 292 m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type)); 296 293 m_valueInSpecifiedUnits = value; 297 294 } 298 295 299 void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGElement* context) 300 { 301 if (type == LengthTypeUnknown || type > LengthTypePC) 302 return; 303 304 float valueInUserUnits = value(context); 305 m_unit = storeUnit(extractMode(m_unit), (SVGLengthType) type); 306 setValue(valueInUserUnits); 307 } 308 309 float SVGLength::PercentageOfViewport(float value, const SVGElement* context, SVGLengthMode mode) 310 { 311 ASSERT(context); 312 313 float width = 0.0f, height = 0.0f; 314 SVGElement* viewportElement = context->viewportElement(); 315 316 // PercentageOfViewport() is used to resolve all relative-positioned values within a SVG document (fragment) 317 Document* doc = context->document(); 318 if (doc->documentElement() == context) { 319 // Resolve value against outermost <svg> element 320 if (RenderView* view = toRenderView(doc->renderer())) { 296 void SVGLength::convertToSpecifiedUnits(unsigned short type, const SVGElement* context, ExceptionCode& ec) 297 { 298 if (type == LengthTypeUnknown || type > LengthTypePC) { 299 ec = NOT_SUPPORTED_ERR; 300 return; 301 } 302 303 float valueInUserUnits = value(context, ec); 304 if (ec) 305 return; 306 307 unsigned int originalUnitAndType = m_unit; 308 m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type)); 309 setValue(valueInUserUnits, context, ec); 310 if (!ec) 311 return; 312 313 // Eventually restore old unit and type 314 m_unit = originalUnitAndType; 315 } 316 317 bool SVGLength::determineViewport(const SVGElement* context, float& width, float& height) const 318 { 319 if (!context) 320 return false; 321 322 // Take size from outermost <svg> element. 323 Document* document = context->document(); 324 if (document->documentElement() == context) { 325 if (RenderView* view = toRenderView(document->renderer())) { 321 326 width = view->viewWidth(); 322 327 height = view->viewHeight(); 323 } 324 } else if (viewportElement && viewportElement->isSVG()) { 325 // Resolve value against nearest viewport element (common case: inner <svg> elements) 328 return true; 329 } 330 331 return false; 332 } 333 334 // Resolve value against nearest viewport element (common case: inner <svg> elements) 335 SVGElement* viewportElement = context->viewportElement(); 336 if (viewportElement && viewportElement->isSVG()) { 326 337 const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement); 327 338 if (svg->hasAttribute(SVGNames::viewBoxAttr)) { … … 332 343 height = svg->height().value(svg); 333 344 } 334 } else if (context->parent() && !context->parent()->isSVGElement()) { 335 // Resolve value against enclosing non-SVG RenderBox 336 if (RenderObject* renderer = context->renderer()) { 337 if (renderer->isBox()) { 338 RenderBox* box = toRenderBox(renderer); 339 width = box->width(); 340 height = box->height(); 341 } 342 } 343 } 344 345 if (mode == LengthModeWidth) 345 346 return true; 347 } 348 349 // Resolve value against enclosing non-SVG RenderBox 350 if (!context->parent() || context->parent()->isSVGElement()) 351 return false; 352 353 RenderObject* renderer = context->renderer(); 354 if (!renderer || !renderer->isBox()) 355 return false; 356 357 RenderBox* box = toRenderBox(renderer); 358 width = box->width(); 359 height = box->height(); 360 return true; 361 } 362 363 float SVGLength::convertValueFromUserUnitsToPercentage(float value, const SVGElement* context, ExceptionCode& ec) const 364 { 365 float width = 0; 366 float height = 0; 367 if (!determineViewport(context, width, height)) { 368 ec = NOT_SUPPORTED_ERR; 369 return 0; 370 } 371 372 switch (extractMode(m_unit)) { 373 case LengthModeWidth: 374 return value / width * 100; 375 case LengthModeHeight: 376 return value / height * 100; 377 case LengthModeOther: 378 return value / (sqrtf((width * width + height * height) / 2)) * 100; 379 }; 380 381 ASSERT_NOT_REACHED(); 382 return 0; 383 } 384 385 float SVGLength::convertValueFromPercentageToUserUnits(float value, const SVGElement* context, ExceptionCode& ec) const 386 { 387 float width = 0; 388 float height = 0; 389 if (!determineViewport(context, width, height)) { 390 ec = NOT_SUPPORTED_ERR; 391 return 0; 392 } 393 394 switch (extractMode(m_unit)) { 395 case LengthModeWidth: 346 396 return value * width; 347 else if (mode == LengthModeHeight)397 case LengthModeHeight: 348 398 return value * height; 349 else if (mode == LengthModeOther) 350 return value * sqrtf(powf(width, 2) + powf(height, 2)) / sqrtf(2.0f); 351 352 return 0.0f; 399 case LengthModeOther: 400 return value * sqrtf((width * width + height * height) / 2); 401 }; 402 403 ASSERT_NOT_REACHED(); 404 return 0; 405 } 406 407 float SVGLength::convertValueFromUserUnitsToEMS(float value, const SVGElement* context, ExceptionCode& ec) const 408 { 409 if (!context || !context->renderer() || !context->renderer()->style()) { 410 ec = NOT_SUPPORTED_ERR; 411 return 0; 412 } 413 414 RenderStyle* style = context->renderer()->style(); 415 float fontSize = style->fontSize(); 416 if (!fontSize) { 417 ec = NOT_SUPPORTED_ERR; 418 return 0; 419 } 420 421 return value / fontSize; 422 } 423 424 float SVGLength::convertValueFromEMSToUserUnits(float value, const SVGElement* context, ExceptionCode& ec) const 425 { 426 if (!context || !context->renderer() || !context->renderer()->style()) { 427 ec = NOT_SUPPORTED_ERR; 428 return 0; 429 } 430 431 RenderStyle* style = context->renderer()->style(); 432 return value * style->fontSize(); 433 } 434 435 float SVGLength::convertValueFromUserUnitsToEXS(float value, const SVGElement* context, ExceptionCode& ec) const 436 { 437 if (!context || !context->renderer() || !context->renderer()->style()) { 438 ec = NOT_SUPPORTED_ERR; 439 return 0; 440 } 441 442 RenderStyle* style = context->renderer()->style(); 443 444 // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg 445 // if this causes problems in real world cases maybe it would be best to remove this 446 float xHeight = ceilf(style->font().xHeight()); 447 if (!xHeight) { 448 ec = NOT_SUPPORTED_ERR; 449 return 0; 450 } 451 452 return value / xHeight; 453 } 454 455 float SVGLength::convertValueFromEXSToUserUnits(float value, const SVGElement* context, ExceptionCode& ec) const 456 { 457 if (!context || !context->renderer() || !context->renderer()->style()) { 458 ec = NOT_SUPPORTED_ERR; 459 return 0; 460 } 461 462 RenderStyle* style = context->renderer()->style(); 463 // Use of ceil allows a pixel match to the W3Cs expected output of coords-units-03-b.svg 464 // if this causes problems in real world cases maybe it would be best to remove this 465 return value * ceilf(style->font().xHeight()); 353 466 } 354 467 … … 398 511 return SVGLength(); 399 512 513 ExceptionCode ec = 0; 400 514 SVGLength length; 401 length.newValueSpecifiedUnits(svgType, value->getFloatValue()); 515 length.newValueSpecifiedUnits(svgType, value->getFloatValue(), ec); 516 if (ec) 517 return SVGLength(); 518 402 519 return length; 403 520 } … … 439 556 cssType = CSSPrimitiveValue::CSS_PC; 440 557 break; 441 default:442 ASSERT_NOT_REACHED();443 558 }; 444 559 -
trunk/WebCore/svg/SVGLength.h
r64830 r71014 23 23 24 24 #if ENABLE(SVG) 25 #include "PlatformString.h" 25 #include "ExceptionCode.h" 26 #include <wtf/text/WTFString.h> 26 27 27 28 namespace WebCore { … … 77 78 78 79 float value(const SVGElement* context) const; 79 void setValue(float); 80 float value(const SVGElement* context, ExceptionCode&) const; 81 void setValue(float, const SVGElement* context, ExceptionCode&); 80 82 81 float valueInSpecifiedUnits() const ;82 void setValueInSpecifiedUnits(float );83 83 float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; } 84 void setValueInSpecifiedUnits(float value) { m_valueInSpecifiedUnits = value; } 85 84 86 float valueAsPercentage() const; 85 87 86 88 String valueAsString() const; 87 bool setValueAsString(const String&);89 void setValueAsString(const String&, ExceptionCode&); 88 90 89 void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits );90 void convertToSpecifiedUnits(unsigned short, const SVGElement* context );91 void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits, ExceptionCode&); 92 void convertToSpecifiedUnits(unsigned short, const SVGElement* context, ExceptionCode&); 91 93 92 94 // Helper functions 93 static float PercentageOfViewport(float value, const SVGElement* context, SVGLengthMode);94 95 95 inline bool isRelative() const 96 96 { 97 97 SVGLengthType type = unitType(); 98 return (type == LengthTypePercentage || type == LengthTypeEMS || type == LengthTypeEXS);98 return type == LengthTypePercentage || type == LengthTypeEMS || type == LengthTypeEXS; 99 99 } 100 100 101 101 static SVGLength fromCSSPrimitiveValue(CSSPrimitiveValue*); 102 102 static PassRefPtr<CSSPrimitiveValue> toCSSPrimitiveValue(const SVGLength&); 103 104 private: 105 bool determineViewport(const SVGElement* context, float& width, float& height) const; 106 107 float convertValueFromPercentageToUserUnits(float value, const SVGElement* context, ExceptionCode&) const; 108 float convertValueFromUserUnitsToPercentage(float value, const SVGElement* context, ExceptionCode&) const; 109 110 float convertValueFromUserUnitsToEMS(float value, const SVGElement* context, ExceptionCode&) const; 111 float convertValueFromEMSToUserUnits(float value, const SVGElement* context, ExceptionCode&) const; 112 113 float convertValueFromUserUnitsToEXS(float value, const SVGElement* context, ExceptionCode&) const; 114 float convertValueFromEXSToUserUnits(float value, const SVGElement* context, ExceptionCode&) const; 103 115 104 116 private: -
trunk/WebCore/svg/SVGLength.idl
r70631 r71014 38 38 39 39 readonly attribute unsigned short unitType; 40 attribute [Custom Getter] float value;41 attribute float valueInSpecifiedUnits;42 attribute [ConvertNullToNullString] DOMString valueAsString;40 attribute [Custom, StrictTypeChecking] float value 41 setter raises(DOMException), 42 getter raises(DOMException); 43 43 44 void newValueSpecifiedUnits(in unsigned short unitType, 45 in float valueInSpecifiedUnits); 44 attribute [StrictTypeChecking] float valueInSpecifiedUnits; 45 attribute [ConvertNullToNullString, StrictTypeChecking] DOMString valueAsString 46 setter raises(DOMException); 46 47 47 [Custom] void convertToSpecifiedUnits(in unsigned short unitType); 48 [StrictTypeChecking, RequiresAllArguments=Raise] void newValueSpecifiedUnits(in unsigned short unitType, 49 in float valueInSpecifiedUnits) 50 raises(DOMException); 51 52 [Custom, StrictTypeChecking, RequiresAllArguments=Raise] void convertToSpecifiedUnits(in unsigned short unitType) 53 raises(DOMException); 48 54 }; 49 55 -
trunk/WebCore/svg/SVGLengthList.cpp
r70223 r71014 32 32 { 33 33 clear(); 34 ExceptionCode ec = 0; 34 35 35 36 const UChar* ptr = value.characters(); … … 41 42 if (ptr == start) 42 43 break; 44 43 45 SVGLength length(mode); 44 if (!length.setValueAsString(String(start, ptr - start))) 46 String valueString(start, ptr - start); 47 if (valueString.isEmpty()) 48 return; 49 length.setValueAsString(valueString, ec); 50 if (ec) 45 51 return; 46 52 append(length);
Note: See TracChangeset
for help on using the changeset viewer.