Title: [204871] trunk
Revision
204871
Author
[email protected]
Date
2016-08-23 17:24:34 -0700 (Tue, 23 Aug 2016)

Log Message

HTMLAreaElement should have a stringifier
https://bugs.webkit.org/show_bug.cgi?id=161105

Reviewed by Geoffrey Garen.

LayoutTests/imported/w3c:

Rebaseline W3C test now that all checks are passing.

* web-platform-tests/html/semantics/embedded-content/the-area-element/area-stringifier-expected.txt:

Source/WebCore:

HTMLAreaElement should have a stringifier:
- https://html.spec.whatwg.org/multipage/embedded-content.html#htmlareaelement
- https://html.spec.whatwg.org/multipage/semantics.html#htmlhyperlinkelementutils
- http://heycam.github.io/webidl/#idl-stringifiers
- http://heycam.github.io/webidl/#es-stringifier

Chrome and Firefox already support this.

This patch does the following:
- Add support for stringifier on attributes to our bindings generator.
- Add stringifier to the HTMLHyperlinkElementUtils.href attribute as
  per the specification
- Drops the explicit toString on HTMLAnchorElement as HTMLAnchorElement
  implements HTMLHyperlinkElementUtils.

Test: fast/dom/toString_attributes.html

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateInterface):
(AddStringifierOperationIfNeeded):
* bindings/scripts/IDLParser.pm:
(parseAttributeOrOperationOrIterator):
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::toString): Deleted.
* html/HTMLAnchorElement.h:
* html/HTMLAnchorElement.idl:
* html/HTMLHyperlinkElementUtils.idl:

LayoutTests:

Add layout test coverage to check that HTMLAreaElement.prototype.toString
and HTMLAnchorElement.prototype.toString have the right attributes:
- http://heycam.github.io/webidl/#es-stringifier

* fast/dom/toString_attributes-expected.txt: Added.
* fast/dom/toString_attributes.html: Added.
* js/dom/toString-dontEnum-expected.txt:
* js/dom/toString-dontEnum.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (204870 => 204871)


--- trunk/LayoutTests/ChangeLog	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/LayoutTests/ChangeLog	2016-08-24 00:24:34 UTC (rev 204871)
@@ -1,3 +1,19 @@
+2016-08-23  Chris Dumez  <[email protected]>
+
+        HTMLAreaElement should have a stringifier
+        https://bugs.webkit.org/show_bug.cgi?id=161105
+
+        Reviewed by Geoffrey Garen.
+
+        Add layout test coverage to check that HTMLAreaElement.prototype.toString
+        and HTMLAnchorElement.prototype.toString have the right attributes:
+        - http://heycam.github.io/webidl/#es-stringifier
+
+        * fast/dom/toString_attributes-expected.txt: Added.
+        * fast/dom/toString_attributes.html: Added.
+        * js/dom/toString-dontEnum-expected.txt:
+        * js/dom/toString-dontEnum.html:
+
 2016-08-23  Saam Barati  <[email protected]>
 
         JSC should have a "microbenchmarks" directory instead of "regress" directory

Added: trunk/LayoutTests/fast/dom/toString_attributes-expected.txt (0 => 204871)


--- trunk/LayoutTests/fast/dom/toString_attributes-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/toString_attributes-expected.txt	2016-08-24 00:24:34 UTC (rev 204871)
@@ -0,0 +1,20 @@
+Test that the toString() stringifier has the right attributes
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+* HTMLAnchorElement
+PASS descriptor.value is an instance of Function
+PASS descriptor.writable is true
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* HTMLAreaElement
+PASS descriptor.value is an instance of Function
+PASS descriptor.writable is true
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/toString_attributes.html (0 => 204871)


--- trunk/LayoutTests/fast/dom/toString_attributes.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/toString_attributes.html	2016-08-24 00:24:34 UTC (rev 204871)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Test that the toString() stringifier has the right attributes");
+
+function testStringifier(object)
+{
+    descriptor = Object.getOwnPropertyDescriptor(object.__proto__, "toString");
+    shouldBeType("descriptor.value", "Function");
+    shouldBeTrue("descriptor.writable");
+    shouldBeTrue("descriptor.enumerable");
+    shouldBeTrue("descriptor.configurable");
+}
+
+debug("* HTMLAnchorElement");
+var anchor = document.createElement("a");
+testStringifier(anchor);
+
+debug("");
+debug("* HTMLAreaElement");
+var area = document.createElement("area");
+testStringifier(area);
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (204870 => 204871)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-08-24 00:24:34 UTC (rev 204871)
@@ -1,5 +1,16 @@
 2016-08-23  Chris Dumez  <[email protected]>
 
+        HTMLAreaElement should have a stringifier
+        https://bugs.webkit.org/show_bug.cgi?id=161105
+
+        Reviewed by Geoffrey Garen.
+
+        Rebaseline W3C test now that all checks are passing.
+
+        * web-platform-tests/html/semantics/embedded-content/the-area-element/area-stringifier-expected.txt:
+
+2016-08-23  Chris Dumez  <[email protected]>
+
         Import html/browsers web platform tests
         https://bugs.webkit.org/show_bug.cgi?id=161067
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-area-element/area-stringifier-expected.txt (204870 => 204871)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-area-element/area-stringifier-expected.txt	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-area-element/area-stringifier-expected.txt	2016-08-24 00:24:34 UTC (rev 204871)
@@ -1,21 +1,13 @@
 
 PASS HTMLAreaElement stringifier 
-FAIL HTMLAreaElement stringifier 1 assert_throws: function "function () {
-        aObject.toString.call(v);
-      }" did not throw
-FAIL HTMLAreaElement stringifier 2 assert_throws: function "function () {
-        aObject.toString.call(v)
-      }" did not throw
+PASS HTMLAreaElement stringifier 1 
+PASS HTMLAreaElement stringifier 2 
 PASS HTMLAreaElement stringifier 3 
-FAIL HTMLAreaElement stringifier 4 assert_equals: expected "" but got "[object HTMLAreaElement]"
-FAIL HTMLAreaElement stringifier 5 assert_equals: expected "" but got "[object HTMLAreaElement]"
-FAIL HTMLAreaElement stringifier 6 assert_throws: function "function () {
-        aObject.toString.call(v);
-      }" did not throw
-FAIL HTMLAreaElement stringifier 7 assert_throws: function "function () {
-        aObject.toString.call(v)
-      }" did not throw
+PASS HTMLAreaElement stringifier 4 
+PASS HTMLAreaElement stringifier 5 
+PASS HTMLAreaElement stringifier 6 
+PASS HTMLAreaElement stringifier 7 
 PASS HTMLAreaElement stringifier 8 
-FAIL HTMLAreaElement stringifier 9 assert_equals: expected "http://localhost:8800/html/semantics/embedded-content/the-area-element/foo" but got "[object HTMLAreaElement]"
-FAIL HTMLAreaElement stringifier 10 assert_equals: expected "http://localhost:8800/html/semantics/embedded-content/the-area-element/foo" but got "[object HTMLAreaElement]"
+PASS HTMLAreaElement stringifier 9 
+PASS HTMLAreaElement stringifier 10 
 

Modified: trunk/LayoutTests/js/dom/toString-dontEnum-expected.txt (204870 => 204871)


--- trunk/LayoutTests/js/dom/toString-dontEnum-expected.txt	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/LayoutTests/js/dom/toString-dontEnum-expected.txt	2016-08-24 00:24:34 UTC (rev 204871)
@@ -1,6 +1,5 @@
 This tests that the toString() function does not enumerate.
 
-PASS: the toString function is not enumerable for HTMLAnchorElement.
 PASS: the toString function is not enumerable for Location.
 PASS: the toString function is not enumerable for Selection.
 PASS: the toString function is not enumerable for HTMLDivElement.

Modified: trunk/LayoutTests/js/dom/toString-dontEnum.html (204870 => 204871)


--- trunk/LayoutTests/js/dom/toString-dontEnum.html	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/LayoutTests/js/dom/toString-dontEnum.html	2016-08-24 00:24:34 UTC (rev 204871)
@@ -25,7 +25,6 @@
                 testRunner.dumpAsText();
 
             // DOM objects with custom toString() functions
-            test(document.createElement('a'), "HTMLAnchorElement");
             test(window.location, "Location");
             test(window.getSelection(), "Selection");
 

Modified: trunk/Source/WebCore/ChangeLog (204870 => 204871)


--- trunk/Source/WebCore/ChangeLog	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/ChangeLog	2016-08-24 00:24:34 UTC (rev 204871)
@@ -1,3 +1,38 @@
+2016-08-23  Chris Dumez  <[email protected]>
+
+        HTMLAreaElement should have a stringifier
+        https://bugs.webkit.org/show_bug.cgi?id=161105
+
+        Reviewed by Geoffrey Garen.
+
+        HTMLAreaElement should have a stringifier:
+        - https://html.spec.whatwg.org/multipage/embedded-content.html#htmlareaelement
+        - https://html.spec.whatwg.org/multipage/semantics.html#htmlhyperlinkelementutils
+        - http://heycam.github.io/webidl/#idl-stringifiers
+        - http://heycam.github.io/webidl/#es-stringifier
+
+        Chrome and Firefox already support this.
+
+        This patch does the following:
+        - Add support for stringifier on attributes to our bindings generator.
+        - Add stringifier to the HTMLHyperlinkElementUtils.href attribute as
+          per the specification
+        - Drops the explicit toString on HTMLAnchorElement as HTMLAnchorElement
+          implements HTMLHyperlinkElementUtils.
+
+        Test: fast/dom/toString_attributes.html
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateInterface):
+        (AddStringifierOperationIfNeeded):
+        * bindings/scripts/IDLParser.pm:
+        (parseAttributeOrOperationOrIterator):
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::toString): Deleted.
+        * html/HTMLAnchorElement.h:
+        * html/HTMLAnchorElement.idl:
+        * html/HTMLHyperlinkElementUtils.idl:
+
 2016-08-23  Alex Christensen  <[email protected]>
 
         Fix clean Windows build.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (204870 => 204871)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-08-24 00:24:34 UTC (rev 204871)
@@ -123,6 +123,8 @@
     my ($object, $interface, $defines, $enumerations, $dictionaries) = @_;
 
     $codeGenerator->LinkOverloadedFunctions($interface);
+    AddStringifierOperationIfNeeded($interface);
+
     if ($interface->isCallback) {
         $object->GenerateCallbackHeader($interface);
         $object->GenerateCallbackImplementation($interface, $enumerations, $dictionaries);
@@ -132,6 +134,26 @@
     }
 }
 
+sub AddStringifierOperationIfNeeded
+{
+    my $interface = shift;
+
+    foreach my $attribute (@{$interface->attributes}) {
+        next unless $attribute->isStringifier;
+
+        my $stringifier = domFunction->new();
+        $stringifier->signature(domSignature->new());
+        my $extendedAttributeList = {};
+        $extendedAttributeList->{"ImplementedAs"} = $attribute->signature->name;
+        $stringifier->signature->extendedAttributes($extendedAttributeList);
+        $stringifier->signature->name("toString");
+        die "stringifier can only be used on attributes of String types" unless $codeGenerator->IsStringType($attribute->signature->type);
+        $stringifier->signature->type($attribute->signature->type);
+        push(@{$interface->functions}, $stringifier);
+        last;
+    }
+}
+
 sub EventHandlerAttributeEventName
 {
     my $attribute = shift;

Modified: trunk/Source/WebCore/bindings/scripts/IDLParser.pm (204870 => 204871)


--- trunk/Source/WebCore/bindings/scripts/IDLParser.pm	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/bindings/scripts/IDLParser.pm	2016-08-24 00:24:34 UTC (rev 204871)
@@ -73,6 +73,7 @@
 struct( domAttribute => {
     type => '$',              # Attribute type (including namespace)
     isStatic => '$',
+    isStringifier => '$',
     isReadOnly => '$',
     signature => '$',         # Attribute signature
 });
@@ -1032,8 +1033,9 @@
     if ($next->value() =~ /$nextAttributeOrOperation_1/) {
         my $qualifier = $self->parseQualifier();
         my $newDataNode = $self->parseAttributeOrOperationRest($extendedAttributeList);
-        if (defined($newDataNode) && $qualifier eq "static") {
-            $newDataNode->isStatic(1);
+        if (defined($newDataNode)) {
+            $newDataNode->isStatic(1) if $qualifier eq "static";
+            $newDataNode->isStringifier(1) if $qualifier eq "stringifier";
         }
         return $newDataNode;
     }

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp (204870 => 204871)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp	2016-08-24 00:24:34 UTC (rev 204871)
@@ -146,6 +146,7 @@
     PROP_ATTRIBUTE,
     PROP_PUT_FORWARDS_ATTRIBUTE,
     PROP_PUT_FORWARDS_NULLABLE_ATTRIBUTE,
+    PROP_STRINGIFIER_ATTRIBUTE,
 };
 
 static void webkit_dom_test_obj_finalize(GObject* object)
@@ -271,6 +272,9 @@
     case PROP_NULLABLE_STRING_VALUE:
         webkit_dom_test_obj_set_nullable_string_value(self, g_value_get_long(value));
         break;
+    case PROP_STRINGIFIER_ATTRIBUTE:
+        webkit_dom_test_obj_set_stringifier_attribute(self, g_value_get_string(value));
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
         break;
@@ -483,6 +487,9 @@
     case PROP_PUT_FORWARDS_NULLABLE_ATTRIBUTE:
         g_value_set_object(value, webkit_dom_test_obj_get_put_forwards_nullable_attribute(self));
         break;
+    case PROP_STRINGIFIER_ATTRIBUTE:
+        g_value_take_string(value, webkit_dom_test_obj_get_stringifier_attribute(self));
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
         break;
@@ -1179,6 +1186,16 @@
             WEBKIT_DOM_TYPE_TEST_NODE,
             WEBKIT_PARAM_READABLE));
 
+    g_object_class_install_property(
+        gobjectClass,
+        PROP_STRINGIFIER_ATTRIBUTE,
+        g_param_spec_string(
+            "stringifier-attribute",
+            "TestObj:stringifier-attribute",
+            "read-write gchar* TestObj:stringifier-attribute",
+            "",
+            WEBKIT_PARAM_READWRITE));
+
 }
 
 static void webkit_dom_test_obj_init(WebKitDOMTestObj* request)
@@ -3073,3 +3090,22 @@
     return WebKit::kit(gobjectResult.get());
 }
 
+gchar* webkit_dom_test_obj_get_stringifier_attribute(WebKitDOMTestObj* self)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
+    WebCore::TestObj* item = WebKit::core(self);
+    gchar* result = convertToUTF8String(item->stringifierAttribute());
+    return result;
+}
+
+void webkit_dom_test_obj_set_stringifier_attribute(WebKitDOMTestObj* self, const gchar* value)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    g_return_if_fail(value);
+    WebCore::TestObj* item = WebKit::core(self);
+    WTF::String convertedValue = WTF::String::fromUTF8(value);
+    item->setStringifierAttribute(convertedValue);
+}
+

Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h (204870 => 204871)


--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h	2016-08-24 00:24:34 UTC (rev 204871)
@@ -2098,6 +2098,27 @@
 WEBKIT_API WebKitDOMTestNode*
 webkit_dom_test_obj_get_put_forwards_nullable_attribute(WebKitDOMTestObj* self);
 
+/**
+ * webkit_dom_test_obj_get_stringifier_attribute:
+ * @self: A #WebKitDOMTestObj
+ *
+ * Returns: A #gchar
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API gchar*
+webkit_dom_test_obj_get_stringifier_attribute(WebKitDOMTestObj* self);
+
+/**
+ * webkit_dom_test_obj_set_stringifier_attribute:
+ * @self: A #WebKitDOMTestObj
+ * @value: A #gchar
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_set_stringifier_attribute(WebKitDOMTestObj* self, const gchar* value);
+
 G_END_DECLS
 
 #endif /* WEBKIT_DOM_USE_UNSTABLE_API */

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (204870 => 204871)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-08-24 00:24:34 UTC (rev 204871)
@@ -726,6 +726,7 @@
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFunctionWithException(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNeedsCustomElementReactionStack(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAttachShadowRoot(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToString(JSC::ExecState*);
 
 // Attributes
 
@@ -901,6 +902,8 @@
 bool setJSTestObjPutForwardsAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjPutForwardsNullableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjPutForwardsNullableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestObjStringifierAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestObjStringifierAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 
@@ -1178,6 +1181,7 @@
     { "attributeWithReservedEnumType", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttributeWithReservedEnumType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttributeWithReservedEnumType) } },
     { "putForwardsAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjPutForwardsAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjPutForwardsAttribute) } },
     { "putForwardsNullableAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjPutForwardsNullableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjPutForwardsNullableAttribute) } },
+    { "stringifierAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringifierAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjStringifierAttribute) } },
 #if ENABLE(TEST_FEATURE)
     { "enabledAtRuntimeOperation", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionEnabledAtRuntimeOperation), (intptr_t) (1) } },
 #else
@@ -1313,6 +1317,7 @@
     { "testPromiseOverloadedFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseOverloadedFunction), (intptr_t) (1) } },
     { "methodWithNeedsCustomElementReactionStack", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNeedsCustomElementReactionStack), (intptr_t) (0) } },
     { "attachShadowRoot", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAttachShadowRoot), (intptr_t) (1) } },
+    { "toString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionToString), (intptr_t) (0) } },
 #if ENABLE(Condition1)
     { "CONDITIONAL_CONST", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } },
 #else
@@ -2747,6 +2752,21 @@
 }
 
 
+EncodedJSValue jsTestObjStringifierAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
+{
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(thisValue);
+    JSValue decodedThisValue = JSValue::decode(thisValue);
+    auto* castedThis = jsDynamicCast<JSTestObj*>(decodedThisValue);
+    if (UNLIKELY(!castedThis)) {
+        return throwGetterTypeError(*state, "TestObject", "stringifierAttribute");
+    }
+    auto& impl = castedThis->wrapped();
+    JSValue result = jsStringWithCache(state, impl.stringifierAttribute());
+    return JSValue::encode(result);
+}
+
+
 EncodedJSValue jsTestObjConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
 {
     JSTestObjPrototype* domObject = jsDynamicCast<JSTestObjPrototype*>(JSValue::decode(thisValue));
@@ -4016,6 +4036,23 @@
 }
 
 
+bool setJSTestObjStringifierAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
+{
+    JSValue value = JSValue::decode(encodedValue);
+    UNUSED_PARAM(thisValue);
+    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(JSValue::decode(thisValue));
+    if (UNLIKELY(!castedThis)) {
+        return throwSetterTypeError(*state, "TestObject", "stringifierAttribute");
+    }
+    auto& impl = castedThis->wrapped();
+    auto nativeValue = valueToUSVString(state, value);
+    if (UNLIKELY(state->hadException()))
+        return false;
+    impl.setStringifierAttribute(WTFMove(nativeValue));
+    return true;
+}
+
+
 void JSTestObj::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
 {
     auto* thisObject = jsCast<JSTestObj*>(object);
@@ -6404,6 +6441,18 @@
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToString(ExecState* state)
+{
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, "TestObject", "toString");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    JSValue result = jsStringWithCache(state, impl.stringifierAttribute());
+    return JSValue::encode(result);
+}
+
 void JSTestObj::visitChildren(JSCell* cell, SlotVisitor& visitor)
 {
     auto* thisObject = jsCast<JSTestObj*>(cell);

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (204870 => 204871)


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2016-08-24 00:24:34 UTC (rev 204871)
@@ -394,6 +394,8 @@
 #endif
 
     void attachShadowRoot(TestDictionary init);
+
+    stringifier attribute USVString stringifierAttribute;
 };
 
 // The following comment should not generate any code.

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (204870 => 204871)


--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2016-08-24 00:24:34 UTC (rev 204871)
@@ -337,11 +337,6 @@
     setTextContent(text, ec);
 }
 
-String HTMLAnchorElement::toString() const
-{
-    return href().string();
-}
-
 bool HTMLAnchorElement::isLiveLink() const
 {
     return isLink() && treatLinkAsLiveForEventType(m_wasShiftKeyDownOnMouseDown ? MouseEventWithShiftKey : MouseEventWithoutShiftKey);

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.h (204870 => 204871)


--- trunk/Source/WebCore/html/HTMLAnchorElement.h	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.h	2016-08-24 00:24:34 UTC (rev 204871)
@@ -72,8 +72,6 @@
     WEBCORE_EXPORT String text();
     void setText(const String&, ExceptionCode&);
 
-    String toString() const;
-
     bool isLiveLink() const;
 
     bool willRespondToMouseClickEvents() final;

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.idl (204870 => 204871)


--- trunk/Source/WebCore/html/HTMLAnchorElement.idl	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.idl	2016-08-24 00:24:34 UTC (rev 204871)
@@ -36,10 +36,6 @@
 
     [SetterRaisesException] attribute DOMString text;
 
-#if !(defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT)
-    [NotEnumerable] DOMString toString();
-#endif
-
     [PutForwards=value] readonly attribute DOMTokenList relList;
 };
 

Modified: trunk/Source/WebCore/html/HTMLHyperlinkElementUtils.idl (204870 => 204871)


--- trunk/Source/WebCore/html/HTMLHyperlinkElementUtils.idl	2016-08-23 23:39:05 UTC (rev 204870)
+++ trunk/Source/WebCore/html/HTMLHyperlinkElementUtils.idl	2016-08-24 00:24:34 UTC (rev 204871)
@@ -26,8 +26,8 @@
 [
     NoInterfaceObject
 ] interface HTMLHyperlinkElementUtils {
-    [Reflect, URL] attribute DOMString href;
-    readonly attribute DOMString origin;
+    [Reflect, URL] stringifier attribute USVString href;
+    readonly attribute USVString origin;
 
     attribute USVString protocol;
     attribute USVString username;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to