Pass reference instead of pointer to IDL attribute setters if not nullable
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 May 2016 04:21:19 +0000 (04:21 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 May 2016 04:21:19 +0000 (04:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157250

Reviewed by Darin Adler.

Update the bindings generator so that we pass wrapper types by reference
to attribute setters instead of by raw pointer when the attribute is not
marked as nullable in the IDL.

There is no intended Web-exposed behavior change.

* Modules/speech/SpeechSynthesisUtterance.idl:
* Modules/webaudio/ConvolverNode.idl:
* bindings/js/JSDataCueCustom.cpp:
(WebCore::constructJSDataCue):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
* bindings/scripts/CodeGeneratorObjC.pm:
(GenerateImplementation):

* bindings/scripts/test/JS/JSTestInterface.cpp:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/ObjC/DOMTestInterface.mm:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
Rebaseline bindings tests.

* dom/Document.cpp:
(WebCore::Document::moveNodeIteratorsToNewDocument):
* dom/NodeIterator.cpp:
(WebCore::NodeIterator::NodePointer::NodePointer):
(WebCore::NodeIterator::NodePointer::moveToNext):
(WebCore::NodeIterator::NodePointer::moveToPrevious):
(WebCore::NodeIterator::NodeIterator):
(WebCore::NodeIterator::~NodeIterator):
(WebCore::NodeIterator::updateForNodeRemoval):
(WebCore::NodeIterator::NodePointer::clear): Deleted.
(WebCore::NodeIterator::nextNode): Deleted.
* dom/NodeIterator.h:
* dom/Traversal.cpp:
(WebCore::NodeIteratorBase::NodeIteratorBase):
* dom/Traversal.h:
(WebCore::NodeIteratorBase::root):
* dom/TreeWalker.cpp:
(WebCore::TreeWalker::setCurrentNode):
(WebCore::TreeWalker::setCurrent):
(WebCore::TreeWalker::parentNode):
(WebCore::TreeWalker::firstChild):
(WebCore::TreeWalker::lastChild):
(WebCore::TreeWalker::traverseSiblings):
(WebCore::TreeWalker::previousNode):
(WebCore::TreeWalker::nextNode):
* dom/TreeWalker.h:
(WebCore::TreeWalker::currentNode):
* dom/TreeWalker.idl:
* html/HTMLAttachmentElement.idl:
* html/HTMLInputElement.idl:
* html/HTMLTableElement.idl:
* html/track/DataCue.cpp:
(WebCore::DataCue::DataCue):
(WebCore::DataCue::setData):
(WebCore::toDataCue): Deleted.
* html/track/DataCue.h:
* html/track/DataCue.idl:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200316 268f45cc-cd09-0410-ab3c-d52691b4dbfc

30 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl
Source/WebCore/Modules/webaudio/ConvolverNode.idl
Source/WebCore/bindings/js/JSDataCueCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/NodeIterator.cpp
Source/WebCore/dom/NodeIterator.h
Source/WebCore/dom/Traversal.cpp
Source/WebCore/dom/Traversal.h
Source/WebCore/dom/TreeWalker.cpp
Source/WebCore/dom/TreeWalker.h
Source/WebCore/dom/TreeWalker.idl
Source/WebCore/html/HTMLAttachmentElement.idl
Source/WebCore/html/HTMLInputElement.idl
Source/WebCore/html/HTMLTableElement.idl
Source/WebCore/html/track/DataCue.cpp
Source/WebCore/html/track/DataCue.h
Source/WebCore/html/track/DataCue.idl

index 19c8b67..081b519 100644 (file)
@@ -1,3 +1,69 @@
+2016-05-01  Chris Dumez  <cdumez@apple.com>
+
+        Pass reference instead of pointer to IDL attribute setters if not nullable
+        https://bugs.webkit.org/show_bug.cgi?id=157250
+
+        Reviewed by Darin Adler.
+
+        Update the bindings generator so that we pass wrapper types by reference
+        to attribute setters instead of by raw pointer when the attribute is not
+        marked as nullable in the IDL.
+
+        There is no intended Web-exposed behavior change.
+
+        * Modules/speech/SpeechSynthesisUtterance.idl:
+        * Modules/webaudio/ConvolverNode.idl:
+        * bindings/js/JSDataCueCustom.cpp:
+        (WebCore::constructJSDataCue):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        * bindings/scripts/CodeGeneratorObjC.pm:
+        (GenerateImplementation):
+
+        * bindings/scripts/test/JS/JSTestInterface.cpp:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        * bindings/scripts/test/ObjC/DOMTestInterface.mm:
+        * bindings/scripts/test/ObjC/DOMTestObj.mm:
+        Rebaseline bindings tests.
+
+        * dom/Document.cpp:
+        (WebCore::Document::moveNodeIteratorsToNewDocument):
+        * dom/NodeIterator.cpp:
+        (WebCore::NodeIterator::NodePointer::NodePointer):
+        (WebCore::NodeIterator::NodePointer::moveToNext):
+        (WebCore::NodeIterator::NodePointer::moveToPrevious):
+        (WebCore::NodeIterator::NodeIterator):
+        (WebCore::NodeIterator::~NodeIterator):
+        (WebCore::NodeIterator::updateForNodeRemoval):
+        (WebCore::NodeIterator::NodePointer::clear): Deleted.
+        (WebCore::NodeIterator::nextNode): Deleted.
+        * dom/NodeIterator.h:
+        * dom/Traversal.cpp:
+        (WebCore::NodeIteratorBase::NodeIteratorBase):
+        * dom/Traversal.h:
+        (WebCore::NodeIteratorBase::root):
+        * dom/TreeWalker.cpp:
+        (WebCore::TreeWalker::setCurrentNode):
+        (WebCore::TreeWalker::setCurrent):
+        (WebCore::TreeWalker::parentNode):
+        (WebCore::TreeWalker::firstChild):
+        (WebCore::TreeWalker::lastChild):
+        (WebCore::TreeWalker::traverseSiblings):
+        (WebCore::TreeWalker::previousNode):
+        (WebCore::TreeWalker::nextNode):
+        * dom/TreeWalker.h:
+        (WebCore::TreeWalker::currentNode):
+        * dom/TreeWalker.idl:
+        * html/HTMLAttachmentElement.idl:
+        * html/HTMLInputElement.idl:
+        * html/HTMLTableElement.idl:
+        * html/track/DataCue.cpp:
+        (WebCore::DataCue::DataCue):
+        (WebCore::DataCue::setData):
+        (WebCore::toDataCue): Deleted.
+        * html/track/DataCue.h:
+        * html/track/DataCue.idl:
+
 2016-05-01  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r200264 and r200266.
index c34c7fb..e781f52 100644 (file)
@@ -30,7 +30,7 @@
 ] interface SpeechSynthesisUtterance : EventTarget {
     attribute DOMString text;
     attribute DOMString lang;
-    attribute SpeechSynthesisVoice voice;
+    attribute SpeechSynthesisVoice? voice; // FIXME: should not be nullable.
     attribute unrestricted float volume;
     attribute unrestricted float rate;
     attribute unrestricted float pitch;
index dbdc126..f0d3f74 100644 (file)
@@ -27,6 +27,6 @@
     Conditional=WEB_AUDIO,
     JSGenerateToJSObject
 ] interface ConvolverNode : AudioNode {
-    [SetterRaisesException] attribute AudioBuffer buffer;
+    [SetterRaisesException] attribute AudioBuffer? buffer;
     attribute boolean normalize;
 };
index be53ebe..6efbde5 100644 (file)
@@ -53,7 +53,6 @@ EncodedJSValue JSC_HOST_CALL constructJSDataCue(ExecState* exec)
     if (exec->argumentCount() < 3)
         return throwVMError(exec, createNotEnoughArgumentsError(exec));
 
-    ExceptionCode ec = 0;
     double startTime(exec->argument(0).toNumber(exec));
     if (UNLIKELY(exec->hadException()))
         return JSValue::encode(jsUndefined());
@@ -84,16 +83,17 @@ EncodedJSValue JSC_HOST_CALL constructJSDataCue(ExecState* exec)
     RefPtr<DataCue> object;
     if (valueArgument.isCell() && valueArgument.asCell()->inherits(std::remove_pointer<JSArrayBuffer*>::type::info())) {
 
-        ArrayBuffer* data(toArrayBuffer(valueArgument));
+        ArrayBuffer* data = toArrayBuffer(valueArgument);
         if (UNLIKELY(exec->hadException()))
             return JSValue::encode(jsUndefined());
 
-        object = DataCue::create(*context, MediaTime::createWithDouble(startTime), MediaTime::createWithDouble(endTime), data, type, ec);
-        if (ec) {
-            setDOMException(exec, ec);
-            return JSValue::encode(JSValue());
+        if (UNLIKELY(!data)) {
+            setDOMException(exec, TypeError);
+            return JSValue::encode(jsUndefined());
         }
 
+        object = DataCue::create(*context, MediaTime::createWithDouble(startTime), MediaTime::createWithDouble(endTime), *data, type);
+
         return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
     }
 
index adec79b..23b64be 100644 (file)
@@ -1110,9 +1110,7 @@ sub GenerateFunction {
         }
         if ($paramIsGDOMType || ($paramIDLType eq "DOMString")) {
             $paramName = "converted" . $codeGenerator->WK_ucfirst($paramName);
-            if ($prefix ne "set_" && $codeGenerator->ShouldPassWrapperByReference($param, $parentNode)) {
-                $paramName = "*$paramName";
-            }
+            $paramName = "*$paramName" if $codeGenerator->ShouldPassWrapperByReference($param, $parentNode);
         }
         if ($paramIDLType eq "NodeFilter" || $paramIDLType eq "XPathNSResolver") {
             $paramName = "WTF::getPtr(" . $paramName . ")";
@@ -1497,6 +1495,7 @@ sub GenerateFunctions {
         my $param = new domSignature();
         $param->name("value");
         $param->type($attribute->signature->type);
+        $param->isNullable($attribute->signature->isNullable);
         my %attributes = ();
         $param->extendedAttributes(\%attributes);
         my $arrayRef = $function->parameters;
index e87c2c8..771851c 100644 (file)
@@ -2860,6 +2860,14 @@ sub GenerateImplementation
                     push (@implContent, "        return false;\n");
                 }
 
+                my $shouldPassByReference = ShouldPassWrapperByReference($attribute->signature, $interface);
+                if ($shouldPassByReference) {
+                    push(@implContent, "    if (UNLIKELY(!nativeValue)) {\n");
+                    push(@implContent, "        throwVMTypeError(state);\n");
+                    push(@implContent, "        return false;\n");
+                    push(@implContent, "    }\n");
+                }
+
                 if ($type eq "double" or $type eq "float") {
                     push(@implContent, "    if (UNLIKELY(!std::isfinite(nativeValue))) {\n");
                     push(@implContent, "        throwVMTypeError(state);\n");
@@ -2903,7 +2911,7 @@ sub GenerateImplementation
                     } elsif ($codeGenerator->IsEnumType($type) and not $codeGenerator->IsStringBasedEnumType($type)) {
                         push(@arguments, "nativeValue.value()");
                     } else {
-                        push(@arguments, "nativeValue");
+                        push(@arguments, $shouldPassByReference ? "*nativeValue" : "nativeValue");
                     }
                     if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
                         my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
index 61a1d0a..81c45e0 100644 (file)
@@ -1417,6 +1417,12 @@ sub GenerateImplementation
                     $arg = "core(" . $arg . ")";
                 }
 
+                if ($codeGenerator->ShouldPassWrapperByReference($attribute->signature, $interface)) {
+                    push(@implContent, "    if (!$arg)\n");
+                    push(@implContent, "        WebCore::raiseTypeErrorException();\n");
+                    $arg = "*$arg";
+                }
+
                 my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
                 push(@arguments, $arg);
                 push(@arguments, "ec") if $hasSetterException;
index 8867ed6..b6317e1 100644 (file)
@@ -450,7 +450,7 @@ void webkit_dom_test_interface_set_implements_node(WebKitDOMTestInterface* self,
     g_return_if_fail(WEBKIT_DOM_IS_NODE(value));
     WebCore::TestInterface* item = WebKit::core(self);
     WebCore::Node* convertedValue = WebKit::core(value);
-    item->setImplementsNode(convertedValue);
+    item->setImplementsNode(*convertedValue);
 #else
     UNUSED_PARAM(self);
     UNUSED_PARAM(value);
@@ -567,7 +567,7 @@ void webkit_dom_test_interface_set_supplemental_node(WebKitDOMTestInterface* sel
     g_return_if_fail(WEBKIT_DOM_IS_NODE(value));
     WebCore::TestInterface* item = WebKit::core(self);
     WebCore::Node* convertedValue = WebKit::core(value);
-    WebCore::TestSupplemental::setSupplementalNode(*item, convertedValue);
+    WebCore::TestSupplemental::setSupplementalNode(*item, *convertedValue);
 #else
     UNUSED_PARAM(self);
     UNUSED_PARAM(value);
index 7f4d336..e14a63f 100644 (file)
@@ -92,6 +92,7 @@ enum {
     PROP_UNSIGNED_LONG_LONG_ATTR,
     PROP_STRING_ATTR,
     PROP_TEST_OBJ_ATTR,
+    PROP_TEST_NULLABLE_OBJ_ATTR,
     PROP_LENIENT_TEST_OBJ_ATTR,
     PROP_UNFORGEABLE_ATTR,
     PROP_STRING_ATTR_TREATING_NULL_AS_EMPTY_STRING,
@@ -327,6 +328,9 @@ static void webkit_dom_test_obj_get_property(GObject* object, guint propertyId,
     case PROP_TEST_OBJ_ATTR:
         g_value_set_object(value, webkit_dom_test_obj_get_test_obj_attr(self));
         break;
+    case PROP_TEST_NULLABLE_OBJ_ATTR:
+        g_value_set_object(value, webkit_dom_test_obj_get_test_nullable_obj_attr(self));
+        break;
     case PROP_LENIENT_TEST_OBJ_ATTR:
         g_value_set_object(value, webkit_dom_test_obj_get_lenient_test_obj_attr(self));
         break;
@@ -657,6 +661,16 @@ static void webkit_dom_test_obj_class_init(WebKitDOMTestObjClass* requestClass)
 
     g_object_class_install_property(
         gobjectClass,
+        PROP_TEST_NULLABLE_OBJ_ATTR,
+        g_param_spec_object(
+            "test-nullable-obj-attr",
+            "TestObj:test-nullable-obj-attr",
+            "read-only WebKitDOMTestObj* TestObj:test-nullable-obj-attr",
+            WEBKIT_DOM_TYPE_TEST_OBJ,
+            WEBKIT_PARAM_READABLE));
+
+    g_object_class_install_property(
+        gobjectClass,
         PROP_LENIENT_TEST_OBJ_ATTR,
         g_param_spec_object(
             "lenient-test-obj-attr",
@@ -2202,7 +2216,26 @@ void webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTest
     g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(value));
     WebCore::TestObj* item = WebKit::core(self);
     WebCore::TestObj* convertedValue = WebKit::core(value);
-    item->setTestObjAttr(convertedValue);
+    item->setTestObjAttr(*convertedValue);
+}
+
+WebKitDOMTestObj* webkit_dom_test_obj_get_test_nullable_obj_attr(WebKitDOMTestObj* self)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
+    WebCore::TestObj* item = WebKit::core(self);
+    RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->testNullableObjAttr());
+    return WebKit::kit(gobjectResult.get());
+}
+
+void webkit_dom_test_obj_set_test_nullable_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(value));
+    WebCore::TestObj* item = WebKit::core(self);
+    WebCore::TestObj* convertedValue = WebKit::core(value);
+    item->setTestNullableObjAttr(convertedValue);
 }
 
 WebKitDOMTestObj* webkit_dom_test_obj_get_lenient_test_obj_attr(WebKitDOMTestObj* self)
@@ -2221,7 +2254,7 @@ void webkit_dom_test_obj_set_lenient_test_obj_attr(WebKitDOMTestObj* self, WebKi
     g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(value));
     WebCore::TestObj* item = WebKit::core(self);
     WebCore::TestObj* convertedValue = WebKit::core(value);
-    item->setLenientTestObjAttr(convertedValue);
+    item->setLenientTestObjAttr(*convertedValue);
 }
 
 gchar* webkit_dom_test_obj_get_unforgeable_attr(WebKitDOMTestObj* self)
@@ -2268,7 +2301,7 @@ void webkit_dom_test_obj_set_xml_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestO
     g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(value));
     WebCore::TestObj* item = WebKit::core(self);
     WebCore::TestObj* convertedValue = WebKit::core(value);
-    item->setXMLObjAttr(convertedValue);
+    item->setXMLObjAttr(*convertedValue);
 }
 
 gboolean webkit_dom_test_obj_get_create(WebKitDOMTestObj* self)
@@ -2622,7 +2655,7 @@ void webkit_dom_test_obj_set_strict_type_checking_attribute(WebKitDOMTestObj* se
     g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(value));
     WebCore::TestObj* item = WebKit::core(self);
     WebCore::TestObj* convertedValue = WebKit::core(value);
-    item->setStrictTypeCheckingAttribute(convertedValue);
+    item->setStrictTypeCheckingAttribute(*convertedValue);
 }
 
 glong webkit_dom_test_obj_get_with_script_state_attribute(WebKitDOMTestObj* self)
index 0c31b24..10ba441 100644 (file)
@@ -1177,6 +1177,27 @@ WEBKIT_API void
 webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value);
 
 /**
+ * webkit_dom_test_obj_get_test_nullable_obj_attr:
+ * @self: A #WebKitDOMTestObj
+ *
+ * Returns: (transfer none): A #WebKitDOMTestObj
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API WebKitDOMTestObj*
+webkit_dom_test_obj_get_test_nullable_obj_attr(WebKitDOMTestObj* self);
+
+/**
+ * webkit_dom_test_obj_set_test_nullable_obj_attr:
+ * @self: A #WebKitDOMTestObj
+ * @value: A #WebKitDOMTestObj
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_set_test_nullable_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value);
+
+/**
  * webkit_dom_test_obj_get_lenient_test_obj_attr:
  * @self: A #WebKitDOMTestObj
  *
index 971cca4..fa723a7 100644 (file)
@@ -686,7 +686,11 @@ bool setJSTestInterfaceImplementsNode(ExecState* state, EncodedJSValue thisValue
     Node* nativeValue = JSNode::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
-    impl.setImplementsNode(nativeValue);
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
+    impl.setImplementsNode(*nativeValue);
     return true;
 }
 
@@ -752,7 +756,11 @@ bool setJSTestInterfaceSupplementalNode(ExecState* state, EncodedJSValue thisVal
     Node* nativeValue = JSNode::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
-    WebCore::TestSupplemental::setSupplementalNode(impl, nativeValue);
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
+    WebCore::TestSupplemental::setSupplementalNode(impl, *nativeValue);
     return true;
 }
 
index 78d5beb..ccd13ba 100644 (file)
@@ -430,6 +430,8 @@ JSC::EncodedJSValue jsTestObjStringAttr(JSC::ExecState*, JSC::EncodedJSValue, JS
 bool setJSTestObjStringAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjTestObjAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjTestObjAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
+JSC::EncodedJSValue jsTestObjTestNullableObjAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
+bool setJSTestObjTestNullableObjAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjLenientTestObjAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
 bool setJSTestObjLenientTestObjAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
 JSC::EncodedJSValue jsTestObjUnforgeableAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
@@ -743,6 +745,7 @@ static const HashTableValue JSTestObjPrototypeTableValues[] =
     { "unsignedLongLongAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedLongLongAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjUnsignedLongLongAttr) } },
     { "stringAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjStringAttr) } },
     { "testObjAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTestObjAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjTestObjAttr) } },
+    { "testNullableObjAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTestNullableObjAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjTestNullableObjAttr) } },
     { "lenientTestObjAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjLenientTestObjAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjLenientTestObjAttr) } },
     { "stringAttrTreatingNullAsEmptyString", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttrTreatingNullAsEmptyString), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjStringAttrTreatingNullAsEmptyString) } },
     { "XMLObjAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjXMLObjAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjXMLObjAttr) } },
@@ -1329,6 +1332,21 @@ EncodedJSValue jsTestObjTestObjAttr(ExecState* state, EncodedJSValue thisValue,
 }
 
 
+EncodedJSValue jsTestObjTestNullableObjAttr(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, "TestObj", "testNullableObjAttr");
+    }
+    auto& impl = castedThis->wrapped();
+    JSValue result = toJS(state, castedThis->globalObject(), WTF::getPtr(impl.testNullableObjAttr()));
+    return JSValue::encode(result);
+}
+
+
 EncodedJSValue jsTestObjLenientTestObjAttr(ExecState* state, EncodedJSValue thisValue, PropertyName)
 {
     UNUSED_PARAM(state);
@@ -2572,7 +2590,28 @@ bool setJSTestObjTestObjAttr(ExecState* state, EncodedJSValue thisValue, Encoded
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
-    impl.setTestObjAttr(nativeValue);
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
+    impl.setTestObjAttr(*nativeValue);
+    return true;
+}
+
+
+bool setJSTestObjTestNullableObjAttr(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, "TestObj", "testNullableObjAttr");
+    }
+    auto& impl = castedThis->wrapped();
+    TestObj* nativeValue = JSTestObj::toWrapped(value);
+    if (UNLIKELY(state->hadException()))
+        return false;
+    impl.setTestNullableObjAttr(nativeValue);
     return true;
 }
 
@@ -2589,7 +2628,11 @@ bool setJSTestObjLenientTestObjAttr(ExecState* state, EncodedJSValue thisValue,
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
-    impl.setLenientTestObjAttr(nativeValue);
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
+    impl.setLenientTestObjAttr(*nativeValue);
     return true;
 }
 
@@ -2623,7 +2666,11 @@ bool setJSTestObjXMLObjAttr(ExecState* state, EncodedJSValue thisValue, EncodedJ
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
-    impl.setXMLObjAttr(nativeValue);
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
+    impl.setXMLObjAttr(*nativeValue);
     return true;
 }
 
@@ -2829,6 +2876,10 @@ bool setJSTestObjTypedArrayAttr(ExecState* state, EncodedJSValue thisValue, Enco
     RefPtr<Float32Array> nativeValue = toFloat32Array(value);
     if (UNLIKELY(state->hadException()))
         return false;
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
     impl.setTypedArrayAttr(nativeValue.get());
     return true;
 }
@@ -2958,7 +3009,11 @@ bool setJSTestObjStrictTypeCheckingAttribute(ExecState* state, EncodedJSValue th
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
-    impl.setStrictTypeCheckingAttribute(nativeValue);
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
+    impl.setStrictTypeCheckingAttribute(*nativeValue);
     return true;
 }
 
@@ -3048,10 +3103,14 @@ bool setJSTestObjWithScriptExecutionContextAttribute(ExecState* state, EncodedJS
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
     auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
     if (!context)
         return false;
-    impl.setWithScriptExecutionContextAttribute(*context, nativeValue);
+    impl.setWithScriptExecutionContextAttribute(*context, *nativeValue);
     return true;
 }
 
@@ -3068,7 +3127,11 @@ bool setJSTestObjWithScriptStateAttributeRaises(ExecState* state, EncodedJSValue
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
-    impl.setWithScriptStateAttributeRaises(*state, nativeValue);
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
+    impl.setWithScriptStateAttributeRaises(*state, *nativeValue);
     return true;
 }
 
@@ -3085,10 +3148,14 @@ bool setJSTestObjWithScriptExecutionContextAttributeRaises(ExecState* state, Enc
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
     auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
     if (!context)
         return false;
-    impl.setWithScriptExecutionContextAttributeRaises(*context, nativeValue);
+    impl.setWithScriptExecutionContextAttributeRaises(*context, *nativeValue);
     return true;
 }
 
@@ -3105,10 +3172,14 @@ bool setJSTestObjWithScriptExecutionContextAndScriptStateAttribute(ExecState* st
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
     auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
     if (!context)
         return false;
-    impl.setWithScriptExecutionContextAndScriptStateAttribute(*state, *context, nativeValue);
+    impl.setWithScriptExecutionContextAndScriptStateAttribute(*state, *context, *nativeValue);
     return true;
 }
 
@@ -3125,10 +3196,14 @@ bool setJSTestObjWithScriptExecutionContextAndScriptStateAttributeRaises(ExecSta
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
     auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
     if (!context)
         return false;
-    impl.setWithScriptExecutionContextAndScriptStateAttributeRaises(*state, *context, nativeValue);
+    impl.setWithScriptExecutionContextAndScriptStateAttributeRaises(*state, *context, *nativeValue);
     return true;
 }
 
@@ -3145,10 +3220,14 @@ bool setJSTestObjWithScriptExecutionContextAndScriptStateWithSpacesAttribute(Exe
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
     auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext();
     if (!context)
         return false;
-    impl.setWithScriptExecutionContextAndScriptStateWithSpacesAttribute(*state, *context, nativeValue);
+    impl.setWithScriptExecutionContextAndScriptStateWithSpacesAttribute(*state, *context, *nativeValue);
     return true;
 }
 
@@ -3165,7 +3244,11 @@ bool setJSTestObjWithScriptArgumentsAndCallStackAttribute(ExecState* state, Enco
     TestObj* nativeValue = JSTestObj::toWrapped(value);
     if (UNLIKELY(state->hadException()))
         return false;
-    impl.setWithScriptArgumentsAndCallStackAttribute(nativeValue);
+    if (UNLIKELY(!nativeValue)) {
+        throwVMTypeError(state);
+        return false;
+    }
+    impl.setWithScriptArgumentsAndCallStackAttribute(*nativeValue);
     return true;
 }
 
index 098a11d..7bd2471 100644 (file)
     WebCore::JSMainThreadNullState state;
     ASSERT(newImplementsNode);
 
-    IMPL->setImplementsNode(core(newImplementsNode));
+    if (!core(newImplementsNode))
+        WebCore::raiseTypeErrorException();
+    IMPL->setImplementsNode(*core(newImplementsNode));
 }
 #endif
 
     WebCore::JSMainThreadNullState state;
     ASSERT(newSupplementalNode);
 
-    WebCore::TestSupplemental::setSupplementalNode(*IMPL, core(newSupplementalNode));
+    if (!core(newSupplementalNode))
+        WebCore::raiseTypeErrorException();
+    WebCore::TestSupplemental::setSupplementalNode(*IMPL, *core(newSupplementalNode));
 }
 #endif
 
index dea3d26..b38b3d9 100644 (file)
@@ -75,6 +75,7 @@ WEBCORE_EXPORT @interface DOMTestObj : DOMObject
 @property unsigned long long unsignedLongLongAttr;
 @property (copy) NSString *stringAttr;
 @property (strong) DOMTestObj *testObjAttr;
+@property (strong) DOMTestObj *testNullableObjAttr;
 @property (strong) DOMTestObj *lenientTestObjAttr;
 @property (readonly, copy) NSString *unforgeableAttr;
 @property (copy) NSString *stringAttrTreatingNullAsEmptyString;
index 397c3fe..20e11c4 100644 (file)
     WebCore::JSMainThreadNullState state;
     ASSERT(newTestSubObjEnabledBySetting);
 
-    IMPL->setTestSubObjEnabledBySetting(core(newTestSubObjEnabledBySetting));
+    if (!core(newTestSubObjEnabledBySetting))
+        WebCore::raiseTypeErrorException();
+    IMPL->setTestSubObjEnabledBySetting(*core(newTestSubObjEnabledBySetting));
 }
 
 - (char)byteAttr
     WebCore::JSMainThreadNullState state;
     ASSERT(newTestObjAttr);
 
-    IMPL->setTestObjAttr(core(newTestObjAttr));
+    if (!core(newTestObjAttr))
+        WebCore::raiseTypeErrorException();
+    IMPL->setTestObjAttr(*core(newTestObjAttr));
+}
+
+- (DOMTestObj *)testNullableObjAttr
+{
+    WebCore::JSMainThreadNullState state;
+    return kit(WTF::getPtr(IMPL->testNullableObjAttr()));
+}
+
+- (void)setTestNullableObjAttr:(DOMTestObj *)newTestNullableObjAttr
+{
+    WebCore::JSMainThreadNullState state;
+    ASSERT(newTestNullableObjAttr);
+
+    IMPL->setTestNullableObjAttr(core(newTestNullableObjAttr));
 }
 
 - (DOMTestObj *)lenientTestObjAttr
     WebCore::JSMainThreadNullState state;
     ASSERT(newLenientTestObjAttr);
 
-    IMPL->setLenientTestObjAttr(core(newLenientTestObjAttr));
+    if (!core(newLenientTestObjAttr))
+        WebCore::raiseTypeErrorException();
+    IMPL->setLenientTestObjAttr(*core(newLenientTestObjAttr));
 }
 
 - (NSString *)unforgeableAttr
     WebCore::JSMainThreadNullState state;
     ASSERT(newXMLObjAttr);
 
-    IMPL->setXMLObjAttr(core(newXMLObjAttr));
+    if (!core(newXMLObjAttr))
+        WebCore::raiseTypeErrorException();
+    IMPL->setXMLObjAttr(*core(newXMLObjAttr));
 }
 
 - (BOOL)create
     WebCore::JSMainThreadNullState state;
     ASSERT(newStrictTypeCheckingAttribute);
 
-    IMPL->setStrictTypeCheckingAttribute(core(newStrictTypeCheckingAttribute));
+    if (!core(newStrictTypeCheckingAttribute))
+        WebCore::raiseTypeErrorException();
+    IMPL->setStrictTypeCheckingAttribute(*core(newStrictTypeCheckingAttribute));
 }
 
 - (int)customAttr
     WebCore::JSMainThreadNullState state;
     ASSERT(newJsBuiltinAttribute);
 
-    IMPL->setJsBuiltinAttribute(core(newJsBuiltinAttribute));
+    if (!core(newJsBuiltinAttribute))
+        WebCore::raiseTypeErrorException();
+    IMPL->setJsBuiltinAttribute(*core(newJsBuiltinAttribute));
 }
 #endif
 
     WebCore::JSMainThreadNullState state;
     ASSERT(newWithScriptExecutionContextAttribute);
 
-    IMPL->setWithScriptExecutionContextAttribute(core(newWithScriptExecutionContextAttribute));
+    if (!core(newWithScriptExecutionContextAttribute))
+        WebCore::raiseTypeErrorException();
+    IMPL->setWithScriptExecutionContextAttribute(*core(newWithScriptExecutionContextAttribute));
 }
 
 - (DOMTestObj *)withScriptStateAttributeRaises
     WebCore::JSMainThreadNullState state;
     ASSERT(newWithScriptStateAttributeRaises);
 
-    IMPL->setWithScriptStateAttributeRaises(core(newWithScriptStateAttributeRaises));
+    if (!core(newWithScriptStateAttributeRaises))
+        WebCore::raiseTypeErrorException();
+    IMPL->setWithScriptStateAttributeRaises(*core(newWithScriptStateAttributeRaises));
 }
 
 - (DOMTestObj *)withScriptExecutionContextAttributeRaises
     WebCore::JSMainThreadNullState state;
     ASSERT(newWithScriptExecutionContextAttributeRaises);
 
-    IMPL->setWithScriptExecutionContextAttributeRaises(core(newWithScriptExecutionContextAttributeRaises));
+    if (!core(newWithScriptExecutionContextAttributeRaises))
+        WebCore::raiseTypeErrorException();
+    IMPL->setWithScriptExecutionContextAttributeRaises(*core(newWithScriptExecutionContextAttributeRaises));
 }
 
 - (DOMTestObj *)withScriptExecutionContextAndScriptStateAttribute
     WebCore::JSMainThreadNullState state;
     ASSERT(newWithScriptExecutionContextAndScriptStateAttribute);
 
-    IMPL->setWithScriptExecutionContextAndScriptStateAttribute(core(newWithScriptExecutionContextAndScriptStateAttribute));
+    if (!core(newWithScriptExecutionContextAndScriptStateAttribute))
+        WebCore::raiseTypeErrorException();
+    IMPL->setWithScriptExecutionContextAndScriptStateAttribute(*core(newWithScriptExecutionContextAndScriptStateAttribute));
 }
 
 - (DOMTestObj *)withScriptExecutionContextAndScriptStateAttributeRaises
     WebCore::JSMainThreadNullState state;
     ASSERT(newWithScriptExecutionContextAndScriptStateAttributeRaises);
 
-    IMPL->setWithScriptExecutionContextAndScriptStateAttributeRaises(core(newWithScriptExecutionContextAndScriptStateAttributeRaises));
+    if (!core(newWithScriptExecutionContextAndScriptStateAttributeRaises))
+        WebCore::raiseTypeErrorException();
+    IMPL->setWithScriptExecutionContextAndScriptStateAttributeRaises(*core(newWithScriptExecutionContextAndScriptStateAttributeRaises));
 }
 
 - (DOMTestObj *)withScriptExecutionContextAndScriptStateWithSpacesAttribute
     WebCore::JSMainThreadNullState state;
     ASSERT(newWithScriptExecutionContextAndScriptStateWithSpacesAttribute);
 
-    IMPL->setWithScriptExecutionContextAndScriptStateWithSpacesAttribute(core(newWithScriptExecutionContextAndScriptStateWithSpacesAttribute));
+    if (!core(newWithScriptExecutionContextAndScriptStateWithSpacesAttribute))
+        WebCore::raiseTypeErrorException();
+    IMPL->setWithScriptExecutionContextAndScriptStateWithSpacesAttribute(*core(newWithScriptExecutionContextAndScriptStateWithSpacesAttribute));
 }
 
 - (DOMTestObj *)withScriptArgumentsAndCallStackAttribute
     WebCore::JSMainThreadNullState state;
     ASSERT(newWithScriptArgumentsAndCallStackAttribute);
 
-    IMPL->setWithScriptArgumentsAndCallStackAttribute(core(newWithScriptArgumentsAndCallStackAttribute));
+    if (!core(newWithScriptArgumentsAndCallStackAttribute))
+        WebCore::raiseTypeErrorException();
+    IMPL->setWithScriptArgumentsAndCallStackAttribute(*core(newWithScriptArgumentsAndCallStackAttribute));
 }
 
 #if ENABLE(Condition1)
     WebCore::JSMainThreadNullState state;
     ASSERT(newConditionalAttr4);
 
-    IMPL->setConditionalAttr4(core(newConditionalAttr4));
+    if (!core(newConditionalAttr4))
+        WebCore::raiseTypeErrorException();
+    IMPL->setConditionalAttr4(*core(newConditionalAttr4));
 }
 #endif
 
     WebCore::JSMainThreadNullState state;
     ASSERT(newConditionalAttr5);
 
-    IMPL->setConditionalAttr5(core(newConditionalAttr5));
+    if (!core(newConditionalAttr5))
+        WebCore::raiseTypeErrorException();
+    IMPL->setConditionalAttr5(*core(newConditionalAttr5));
 }
 #endif
 
     WebCore::JSMainThreadNullState state;
     ASSERT(newConditionalAttr6);
 
-    IMPL->setConditionalAttr6(core(newConditionalAttr6));
+    if (!core(newConditionalAttr6))
+        WebCore::raiseTypeErrorException();
+    IMPL->setConditionalAttr6(*core(newConditionalAttr6));
 }
 #endif
 
index 98a7b4d..fe13ce7 100644 (file)
@@ -63,6 +63,7 @@ enum _optional { "", "OptionalValue1", "OptionalValue2", "OptionalValue3" };
     attribute unsigned long long       unsignedLongLongAttr;
     attribute DOMString                stringAttr;
     attribute TestObj                  testObjAttr;
+    attribute TestObj?                 testNullableObjAttr;
     [LenientThis] attribute TestObj    lenientTestObjAttr;
     [Unforgeable] readonly attribute DOMString unforgeableAttr;
     [TreatNullAs=EmptyString] attribute DOMString stringAttrTreatingNullAsEmptyString;
index 03f9df9..0545efc 100644 (file)
@@ -3964,7 +3964,7 @@ void Document::moveNodeIteratorsToNewDocument(Node* node, Document* newDocument)
     Vector<NodeIterator*> nodeIterators;
     copyToVector(m_nodeIterators, nodeIterators);
     for (auto* it : nodeIterators) {
-        if (it->root() == node) {
+        if (&it->root() == node) {
             detachNodeIterator(it);
             newDocument->attachNodeIterator(it);
         }
index 74290a9..b59e0f9 100644 (file)
 
 namespace WebCore {
 
-NodeIterator::NodePointer::NodePointer()
-{
-}
-
-NodeIterator::NodePointer::NodePointer(Node* n, bool b)
-    : node(n)
-    , isPointerBeforeNode(b)
+NodeIterator::NodePointer::NodePointer(Node& node, bool isPointerBeforeNode)
+    : node(&node)
+    , isPointerBeforeNode(isPointerBeforeNode)
 {
 }
 
@@ -48,7 +44,7 @@ void NodeIterator::NodePointer::clear()
     node = nullptr;
 }
 
-bool NodeIterator::NodePointer::moveToNext(Node* root)
+bool NodeIterator::NodePointer::moveToNext(Node& root)
 {
     if (!node)
         return false;
@@ -56,11 +52,11 @@ bool NodeIterator::NodePointer::moveToNext(Node* root)
         isPointerBeforeNode = false;
         return true;
     }
-    node = NodeTraversal::next(*node, root);
+    node = NodeTraversal::next(*node, &root);
     return node;
 }
 
-bool NodeIterator::NodePointer::moveToPrevious(Node* root)
+bool NodeIterator::NodePointer::moveToPrevious(Node& root)
 {
     if (!node)
         return false;
@@ -68,7 +64,7 @@ bool NodeIterator::NodePointer::moveToPrevious(Node* root)
         isPointerBeforeNode = true;
         return true;
     }
-    if (node == root) {
+    if (node == &root) {
         node = nullptr;
         return false;
     }
@@ -80,12 +76,12 @@ NodeIterator::NodeIterator(Node& rootNode, unsigned long whatToShow, RefPtr<Node
     : NodeIteratorBase(rootNode, whatToShow, WTFMove(filter))
     , m_referenceNode(root(), true)
 {
-    root()->document().attachNodeIterator(this);
+    root().document().attachNodeIterator(this);
 }
 
 NodeIterator::~NodeIterator()
 {
-    root()->document().detachNodeIterator(this);
+    root().document().detachNodeIterator(this);
 }
 
 RefPtr<Node> NodeIterator::nextNode()
@@ -145,11 +141,11 @@ void NodeIterator::nodeWillBeRemoved(Node& removedNode)
 
 void NodeIterator::updateForNodeRemoval(Node& removedNode, NodePointer& referenceNode) const
 {
-    ASSERT(&root()->document() == &removedNode.document());
+    ASSERT(&root().document() == &removedNode.document());
 
     // Iterator is not affected if the removed node is the reference node and is the root.
     // or if removed node is not the reference node, or the ancestor of the reference node.
-    if (!removedNode.isDescendantOf(root()))
+    if (!removedNode.isDescendantOf(&root()))
         return;
     bool willRemoveReferenceNode = &removedNode == referenceNode.node;
     bool willRemoveReferenceNodeAncestor = referenceNode.node && referenceNode.node->isDescendantOf(&removedNode);
@@ -157,12 +153,12 @@ void NodeIterator::updateForNodeRemoval(Node& removedNode, NodePointer& referenc
         return;
 
     if (referenceNode.isPointerBeforeNode) {
-        Node* node = NodeTraversal::next(removedNode, root());
+        Node* node = NodeTraversal::next(removedNode, &root());
         if (node) {
             // Move out from under the node being removed if the new reference
             // node is a descendant of the node being removed.
             while (node && node->isDescendantOf(&removedNode))
-                node = NodeTraversal::next(*node, root());
+                node = NodeTraversal::next(*node, &root());
             if (node)
                 referenceNode.node = node;
         } else {
@@ -196,7 +192,7 @@ void NodeIterator::updateForNodeRemoval(Node& removedNode, NodePointer& referenc
                 referenceNode.node = node;
         } else {
             // FIXME: This branch doesn't appear to have any LayoutTests.
-            node = NodeTraversal::next(removedNode, root());
+            node = NodeTraversal::next(removedNode, &root());
             // Move out from under the node being removed if the reference node is
             // a descendant of the node being removed.
             if (willRemoveReferenceNodeAncestor) {
index f6bba32..ca8e8d4 100644 (file)
@@ -57,12 +57,14 @@ namespace WebCore {
 
         struct NodePointer {
             RefPtr<Node> node;
-            bool isPointerBeforeNode;
-            NodePointer();
-            NodePointer(Node*, bool);
+            bool isPointerBeforeNode { true };
+
+            NodePointer() = default;
+            NodePointer(Node&, bool);
+
             void clear();
-            bool moveToNext(Node* root);
-            bool moveToPrevious(Node* root);
+            bool moveToNext(Node& root);
+            bool moveToPrevious(Node& root);
         };
 
         void updateForNodeRemoval(Node& nodeToBeRemoved, NodePointer&) const;
index 0fdf858..3c82a76 100644 (file)
@@ -31,7 +31,7 @@
 namespace WebCore {
 
 NodeIteratorBase::NodeIteratorBase(Node& rootNode, unsigned whatToShow, RefPtr<NodeFilter>&& nodeFilter)
-    : m_root(&rootNode)
+    : m_root(rootNode)
     , m_whatToShow(whatToShow)
     , m_filter(WTFMove(nodeFilter))
 {
index b8b9ec4..a1e0ffc 100644 (file)
@@ -33,7 +33,9 @@ class NodeFilter;
 
 class NodeIteratorBase {
 public:
-    Node* root() const { return m_root.get(); }
+    Node& root() { return m_root.get(); }
+    const Node& root() const { return m_root.get(); }
+
     unsigned whatToShow() const { return m_whatToShow; }
     NodeFilter* filter() const { return m_filter.get(); }
     bool expandEntityReferences() const { return false; }
@@ -43,7 +45,7 @@ protected:
     short acceptNode(Node*) const;
 
 private:
-    RefPtr<Node> m_root;
+    Ref<Node> m_root;
     unsigned m_whatToShow;
     RefPtr<NodeFilter> m_filter;
 };
index ab86d59..a0c09f9 100644 (file)
@@ -39,31 +39,27 @@ TreeWalker::TreeWalker(Node& rootNode, unsigned long whatToShow, RefPtr<NodeFilt
 {
 }
 
-void TreeWalker::setCurrentNode(Node* node, ExceptionCode& ec)
+void TreeWalker::setCurrentNode(Node& node)
 {
-    if (!node) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
-    }
     m_current = node;
 }
 
-inline Node* TreeWalker::setCurrent(RefPtr<Node>&& node)
+inline Node* TreeWalker::setCurrent(Ref<Node>&& node)
 {
-    m_current = node;
-    return m_current.get();
+    m_current = WTFMove(node);
+    return m_current.ptr();
 }
 
 Node* TreeWalker::parentNode()
 {
-    RefPtr<Node> node = m_current;
-    while (node != root()) {
+    RefPtr<Node> node = m_current.ptr();
+    while (node != &root()) {
         node = node->parentNode();
         if (!node)
             return nullptr;
         short acceptNodeResult = acceptNode(node.get());
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
-            return setCurrent(WTFMove(node));
+            return setCurrent(node.releaseNonNull());
     }
     return nullptr;
 }
@@ -74,8 +70,8 @@ Node* TreeWalker::firstChild()
         short acceptNodeResult = acceptNode(node.get());
         switch (acceptNodeResult) {
             case NodeFilter::FILTER_ACCEPT:
-                m_current = node.release();
-                return m_current.get();
+                m_current = node.releaseNonNull();
+                return m_current.ptr();
             case NodeFilter::FILTER_SKIP:
                 if (node->firstChild()) {
                     node = node->firstChild();
@@ -91,7 +87,7 @@ Node* TreeWalker::firstChild()
                 break;
             }
             ContainerNode* parent = node->parentNode();
-            if (!parent || parent == root() || parent == m_current)
+            if (!parent || parent == &root() || parent == m_current.ptr())
                 return nullptr;
             node = parent;
         } while (node);
@@ -105,8 +101,8 @@ Node* TreeWalker::lastChild()
         short acceptNodeResult = acceptNode(node.get());
         switch (acceptNodeResult) {
             case NodeFilter::FILTER_ACCEPT:
-                m_current = node.release();
-                return m_current.get();
+                m_current = node.releaseNonNull();
+                return m_current.ptr();
             case NodeFilter::FILTER_SKIP:
                 if (node->lastChild()) {
                     node = node->lastChild();
@@ -122,7 +118,7 @@ Node* TreeWalker::lastChild()
                 break;
             }
             ContainerNode* parent = node->parentNode();
-            if (!parent || parent == root() || parent == m_current)
+            if (!parent || parent == &root() || parent == m_current.ptr())
                 return nullptr;
             node = parent;
         } while (node);
@@ -132,8 +128,8 @@ Node* TreeWalker::lastChild()
 
 template<TreeWalker::SiblingTraversalType type> Node* TreeWalker::traverseSiblings()
 {
-    RefPtr<Node> node = m_current;
-    if (node == root())
+    RefPtr<Node> node = m_current.ptr();
+    if (node == &root())
         return nullptr;
 
     auto isNext = type == SiblingTraversalType::Next;
@@ -141,8 +137,8 @@ template<TreeWalker::SiblingTraversalType type> Node* TreeWalker::traverseSiblin
         for (RefPtr<Node> sibling = isNext ? node->nextSibling() : node->previousSibling(); sibling; ) {
             short acceptNodeResult = acceptNode(sibling.get());
             if (acceptNodeResult == NodeFilter::FILTER_ACCEPT) {
-                m_current = WTFMove(sibling);
-                return m_current.get();
+                m_current = sibling.releaseNonNull();
+                return m_current.ptr();
             }
             node = sibling;
             sibling = isNext ? sibling->firstChild() : sibling->lastChild();
@@ -150,7 +146,7 @@ template<TreeWalker::SiblingTraversalType type> Node* TreeWalker::traverseSiblin
                 sibling = isNext ? node->nextSibling() : node->previousSibling();
         }
         node = node->parentNode();
-        if (!node || node == root())
+        if (!node || node == &root())
             return nullptr;
         short acceptNodeResult = acceptNode(node.get());
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
@@ -170,8 +166,8 @@ Node* TreeWalker::nextSibling()
 
 Node* TreeWalker::previousNode()
 {
-    RefPtr<Node> node = m_current;
-    while (node != root()) {
+    RefPtr<Node> node = m_current.ptr();
+    while (node != &root()) {
         while (Node* previousSibling = node->previousSibling()) {
             node = previousSibling;
             short acceptNodeResult = acceptNode(node.get());
@@ -184,11 +180,11 @@ Node* TreeWalker::previousNode()
                     break;
             }
             if (acceptNodeResult == NodeFilter::FILTER_ACCEPT) {
-                m_current = node.release();
-                return m_current.get();
+                m_current = node.releaseNonNull();
+                return m_current.ptr();
             }
         }
-        if (node == root())
+        if (node == &root())
             return nullptr;
         ContainerNode* parent = node->parentNode();
         if (!parent)
@@ -196,28 +192,28 @@ Node* TreeWalker::previousNode()
         node = parent;
         short acceptNodeResult = acceptNode(node.get());
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
-            return setCurrent(WTFMove(node));
+            return setCurrent(node.releaseNonNull());
     }
     return nullptr;
 }
 
 Node* TreeWalker::nextNode()
 {
-    RefPtr<Node> node = m_current;
+    RefPtr<Node> node = m_current.ptr();
 Children:
     while (Node* firstChild = node->firstChild()) {
         node = firstChild;
         short acceptNodeResult = acceptNode(node.get());
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
-            return setCurrent(WTFMove(node));
+            return setCurrent(node.releaseNonNull());
         if (acceptNodeResult == NodeFilter::FILTER_REJECT)
             break;
     }
-    while (Node* nextSibling = NodeTraversal::nextSkippingChildren(*node, root())) {
+    while (Node* nextSibling = NodeTraversal::nextSkippingChildren(*node, &root())) {
         node = nextSibling;
         short acceptNodeResult = acceptNode(node.get());
         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
-            return setCurrent(WTFMove(node));
+            return setCurrent(node.releaseNonNull());
         if (acceptNodeResult == NodeFilter::FILTER_SKIP)
             goto Children;
     }
index 1b5be1c..4540074 100644 (file)
@@ -41,8 +41,10 @@ namespace WebCore {
             return adoptRef(*new TreeWalker(rootNode, whatToShow, WTFMove(filter)));
         }                            
 
-        Node* currentNode() const { return m_current.get(); }
-        void setCurrentNode(Node*, ExceptionCode&);
+        Node& currentNode() { return m_current.get(); }
+        const Node& currentNode() const { return m_current.get(); }
+
+        void setCurrentNode(Node&);
 
         Node* parentNode();
         Node* firstChild();
@@ -57,9 +59,9 @@ namespace WebCore {
         enum class SiblingTraversalType { Previous, Next };
         template<SiblingTraversalType> Node* traverseSiblings();
         
-        Node* setCurrent(RefPtr<Node>&&);
+        Node* setCurrent(Ref<Node>&&);
 
-        RefPtr<Node> m_current;
+        Ref<Node> m_current;
     };
 
 } // namespace WebCore
index ad5cb5d..be92776 100644 (file)
@@ -29,7 +29,7 @@
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
     readonly attribute boolean expandEntityReferences;
 #endif
-    [SetterRaisesException] attribute Node currentNode;
+    attribute Node currentNode;
 
     Node parentNode();
     Node firstChild();
index 85bd478..d69a157 100644 (file)
@@ -26,5 +26,5 @@
 [
     Conditional=ATTACHMENT_ELEMENT
 ] interface HTMLAttachmentElement : HTMLElement {
-    attribute File file;
+    attribute File? file;
 };
index e3d0f9f..62274ea 100644 (file)
@@ -32,7 +32,7 @@
     [Reflect] attribute DOMString dirName;
     [Reflect] attribute boolean disabled;
     readonly attribute HTMLFormElement form;
-    attribute FileList files;
+    attribute FileList? files;
     attribute DOMString formAction;
 
     // FIXME: These should not use [TreatNullAs=LegacyNullString].
index bb37bcd..a8e792e 100644 (file)
@@ -19,9 +19,9 @@
  */
 
 interface HTMLTableElement : HTMLElement {
-    [SetterRaisesException, StrictTypeChecking] attribute HTMLTableCaptionElement caption;
-    [SetterRaisesException, StrictTypeChecking] attribute HTMLTableSectionElement tHead;
-    [SetterRaisesException, StrictTypeChecking] attribute HTMLTableSectionElement tFoot;
+    [SetterRaisesException, StrictTypeChecking] attribute HTMLTableCaptionElement? caption;
+    [SetterRaisesException, StrictTypeChecking] attribute HTMLTableSectionElement? tHead;
+    [SetterRaisesException, StrictTypeChecking] attribute HTMLTableSectionElement? tFoot;
 
     readonly attribute HTMLCollection rows;
     readonly attribute HTMLCollection tBodies;
index 39a78ad..5d9e04e 100644 (file)
 
 namespace WebCore {
 
-DataCue::DataCue(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, ArrayBuffer* data, const String& type, ExceptionCode& ec)
+DataCue::DataCue(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, ArrayBuffer& data, const String& type)
     : TextTrackCue(context, start, end)
     , m_type(type)
 {
-    setData(data, ec);
+    setData(data);
 }
 
 DataCue::DataCue(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, const void* data, unsigned length)
@@ -88,13 +88,8 @@ RefPtr<ArrayBuffer> DataCue::data() const
     return ArrayBuffer::create(*m_data);
 }
 
-void DataCue::setData(ArrayBuffer* data, ExceptionCode& ec)
+void DataCue::setData(ArrayBuffer& data)
 {
-    if (!data) {
-        ec = TypeError;
-        return;
-    }
-
 #if ENABLE(DATACUE_VALUE)
     m_platformValue = nullptr;
     if (m_value)
@@ -102,7 +97,7 @@ void DataCue::setData(ArrayBuffer* data, ExceptionCode& ec)
     m_value = JSC::JSValue();
 #endif
 
-    m_data = ArrayBuffer::create(*data);
+    m_data = ArrayBuffer::create(data);
 }
 
 DataCue* toDataCue(TextTrackCue* cue)
index d71fb81..6232774 100644 (file)
@@ -45,9 +45,9 @@ class ScriptExecutionContext;
 
 class DataCue final : public TextTrackCue {
 public:
-    static Ref<DataCue> create(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, ArrayBuffer* data, ExceptionCode& ec)
+    static Ref<DataCue> create(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, ArrayBuffer& data)
     {
-        return adoptRef(*new DataCue(context, start, end, data, emptyString(), ec));
+        return adoptRef(*new DataCue(context, start, end, data, emptyString()));
     }
 
     static Ref<DataCue> create(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, const void* data, unsigned length)
@@ -55,9 +55,9 @@ public:
         return adoptRef(*new DataCue(context, start, end, data, length));
     }
 
-    static Ref<DataCue> create(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, ArrayBuffer* data, const String& type, ExceptionCode& ec)
+    static Ref<DataCue> create(ScriptExecutionContext& context, const MediaTime& start, const MediaTime& end, ArrayBuffer& data, const String& type)
     {
-        return adoptRef(*new DataCue(context, start, end, data, type, ec));
+        return adoptRef(*new DataCue(context, start, end, data, type));
     }
 
 #if ENABLE(DATACUE_VALUE)
@@ -76,7 +76,7 @@ public:
     CueType cueType() const override { return Data; }
 
     RefPtr<ArrayBuffer> data() const;
-    void setData(ArrayBuffer*, ExceptionCode&);
+    void setData(ArrayBuffer&);
 
 #if ENABLE(DATACUE_VALUE)
     const SerializedPlatformRepresentation* platformValue() const { return m_platformValue.get(); }
@@ -93,7 +93,7 @@ public:
     bool doesExtendCue(const TextTrackCue&) const override;
 
 protected:
-    DataCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, ArrayBuffer*, const String&, ExceptionCode&);
+    DataCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, ArrayBuffer&, const String&);
     DataCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, const void*, unsigned);
 #if ENABLE(DATACUE_VALUE)
     DataCue(ScriptExecutionContext&, const MediaTime& start, const MediaTime& end, RefPtr<SerializedPlatformRepresentation>&&, const String&);
index fa5e25e..5923489 100644 (file)
@@ -34,7 +34,7 @@
 #endif
     ConstructorRaisesException,
 ] interface DataCue : TextTrackCue {
-    [SetterRaisesException] attribute ArrayBuffer data;
+    attribute ArrayBuffer data;
 
 #if defined(ENABLE_DATACUE_VALUE) && ENABLE_DATACUE_VALUE
     [CustomGetter, CustomSetter] attribute any value;