Update Node::appendChild() / replaceChild() / removeChild() / insertBefore() to take...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 May 2016 19:02:09 +0000 (19:02 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 May 2016 19:02:09 +0000 (19:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157556

Reviewed by Darin Adler.

Source/WebCore:

Update Node::appendChild() / replaceChild() / removeChild() / insertBefore()
to take references instead of pointers. Do the parameter null checks in the
bindings instead of doing it in the implementation on Node.

Also update the ContainerNode::appendChild() / replaceChild() /
insertBefore() to take C++ references instead of Ref<>&& to avoid
unnecessarily causing ref counting churns at some call sites (including
in the bindings since they are a raw pointer to the nodes). The
implementation on ContainerNode was not actually using WTFMove() on the
Ref<>&& anyway.

* Modules/plugins/YouTubePluginReplacement.cpp:
(WebCore::YouTubePluginReplacement::installReplacement):
* bindings/js/JSNodeCustom.cpp:
(WebCore::JSNode::insertBefore):
(WebCore::JSNode::replaceChild):
(WebCore::JSNode::removeChild):
(WebCore::JSNode::appendChild):
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::insertBefore):
(WebCore::ContainerNode::parserInsertBefore):
(WebCore::ContainerNode::replaceChild):
(WebCore::ContainerNode::appendChild):
(WebCore::ContainerNode::parserAppendChild):
(WebCore::ContainerNode::cloneChildNodes):
(WebCore::ContainerNode::append):
(WebCore::ContainerNode::prepend):
* dom/ContainerNode.h:
* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):
(WebCore::DOMImplementation::createHTMLDocument):
* dom/Document.cpp:
(WebCore::Document::setBodyOrFrameset):
* dom/Element.cpp:
(WebCore::Element::setOuterHTML):
* dom/Node.cpp:
(WebCore::Node::insertBefore):
(WebCore::Node::replaceChild):
(WebCore::Node::removeChild):
(WebCore::Node::appendChild):
(WebCore::Node::before):
(WebCore::Node::after):
(WebCore::Node::replaceWith):
(WebCore::nodeSetPreTransformedFromNodeOrStringVector): Deleted.
(WebCore::Node::normalize): Deleted.
* dom/Node.h:
* dom/Node.idl:
* dom/NodeOrString.cpp:
(WebCore::convertNodesOrStringsIntoNode):
* dom/Range.cpp:
(WebCore::Range::processContents):
(WebCore::Range::processContentsBetweenOffsets):
(WebCore::Range::processNodes):
(WebCore::Range::processAncestorsAndTheirSiblings):
(WebCore::Range::insertNode):
(WebCore::Range::surroundContents):
* dom/Range.h:
* dom/Text.cpp:
(WebCore::Text::splitText):
* editing/AppendNodeCommand.cpp:
(WebCore::AppendNodeCommand::doApply):
* editing/Editor.cpp:
(WebCore::Editor::setTextAsChildOfElement):
* editing/EditorCommand.cpp:
(WebCore::executeInsertNode):
* editing/MergeIdenticalElementsCommand.cpp:
(WebCore::MergeIdenticalElementsCommand::doApply):
(WebCore::MergeIdenticalElementsCommand::doUnapply):
* editing/RemoveNodeCommand.cpp:
(WebCore::RemoveNodeCommand::doUnapply):
* editing/ReplaceNodeWithSpanCommand.cpp:
(WebCore::swapInNodePreservingAttributesAndChildren):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplacementFragment::insertFragmentForTestRendering):
* editing/SplitElementCommand.cpp:
(WebCore::SplitElementCommand::executeApply):
(WebCore::SplitElementCommand::doUnapply):
* editing/WrapContentsInDummySpanCommand.cpp:
(WebCore::WrapContentsInDummySpanCommand::executeApply):
(WebCore::WrapContentsInDummySpanCommand::doUnapply):
* editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::styleForSelectionStart):
* editing/htmlediting.cpp:
(WebCore::createTabSpanElement):
* editing/ios/EditorIOS.mm:
(WebCore::Editor::WebContentReader::readURL):
(WebCore::Editor::createFragmentForImageResourceAndAddResource):
* editing/mac/EditorMac.mm:
(WebCore::Editor::WebContentReader::readFilenames):
(WebCore::Editor::WebContentReader::readURL):
(WebCore::Editor::createFragmentForImageResourceAndAddResource):
* editing/markup.cpp:
(WebCore::fillContainerFromString):
(WebCore::createFragmentFromText):
(WebCore::replaceChildrenWithFragment):
(WebCore::replaceChildrenWithText):
* html/BaseChooserOnlyDateAndTimeInputType.cpp:
(WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree):
* html/ColorInputType.cpp:
(WebCore::ColorInputType::createShadowSubtree):
* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocumentParser::appendEntry):
(WebCore::FTPDirectoryDocumentParser::createTDForFilename):
(WebCore::FTPDirectoryDocumentParser::createBasicDocument):
* html/HTMLDetailsElement.cpp:
(WebCore::HTMLDetailsElement::didAddUserAgentShadowRoot):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::setOuterText):
(WebCore::HTMLElement::insertAdjacent):
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::tryCreateImageControls):
* html/HTMLKeygenElement.cpp:
(WebCore::HTMLKeygenElement::HTMLKeygenElement):
* html/HTMLMeterElement.cpp:
(WebCore::HTMLMeterElement::didAddUserAgentShadowRoot):
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::createForJSConstructor):
* html/HTMLProgressElement.cpp:
(WebCore::HTMLProgressElement::didAddUserAgentShadowRoot):
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::createTBody):
(WebCore::HTMLTableElement::insertRow):
* html/HTMLTableRowElement.cpp:
(WebCore::HTMLTableRowElement::insertCell):
* html/ImageDocument.cpp:
(WebCore::ImageDocument::createDocumentStructure):
* html/MediaDocument.cpp:
(WebCore::MediaDocumentParser::createDocumentStructure):
* html/PluginDocument.cpp:
(WebCore::PluginDocumentParser::createDocumentStructure):
* html/RangeInputType.cpp:
(WebCore::RangeInputType::createShadowSubtree):
* html/SearchInputType.cpp:
(WebCore::SearchInputType::createShadowSubtree):
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::buildBubbleTree):
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu):
* html/shadow/MediaControls.cpp:
(WebCore::MediaControls::createTextTrackDisplay):
* html/shadow/MediaControlsApple.cpp:
(WebCore::MediaControlsApple::tryCreateControls):
* html/shadow/mac/ImageControlsRootElementMac.cpp:
(WebCore::ImageControlsRootElement::tryCreate):
* html/track/VTTCue.cpp:
(WebCore::VTTCue::updateDisplayTree):
* html/track/WebVTTParser.cpp:
(WebCore::WebVTTTreeBuilder::constructTreeFromToken):
* inspector/DOMEditor.cpp:
(WebCore::DOMEditor::RemoveChildAction::RemoveChildAction):
(WebCore::DOMEditor::InsertBeforeAction::InsertBeforeAction):
(WebCore::DOMEditor::ReplaceChildNodeAction::ReplaceChildNodeAction):
(WebCore::DOMEditor::insertBefore):
(WebCore::DOMEditor::removeChild):
(WebCore::DOMEditor::replaceChild):
* inspector/DOMEditor.h:
* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::patchNode):
(WebCore::DOMPatchSupport::innerPatchNode):
(WebCore::DOMPatchSupport::innerPatchChildren):
(WebCore::DOMPatchSupport::insertBeforeAndMarkAsUsed):
(WebCore::DOMPatchSupport::removeChildAndMoveToNew):
* inspector/DOMPatchSupport.h:
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::removeNode):
(WebCore::InspectorDOMAgent::setNodeName):
(WebCore::InspectorDOMAgent::moveTo):
* page/DragController.cpp:
(WebCore::documentFragmentFromDragData):
* page/ios/FrameIOS.mm:
(WebCore::Frame::initWithSimpleHTMLDocument):
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::cloneTarget):
(WebCore::SVGUseElement::expandUseElementsInShadowTree):
(WebCore::SVGUseElement::expandSymbolElementsInShadowTree):
* xml/XMLErrors.cpp:
(WebCore::createXHTMLParserErrorHeader):
(WebCore::XMLErrors::insertErrorMessageBlock):
* xml/XMLTreeViewer.cpp:
(WebCore::XMLTreeViewer::transformDocumentToTreeView):
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::startElementNs):
(WebCore::XMLDocumentParser::processingInstruction):
(WebCore::XMLDocumentParser::cdataBlock):
(WebCore::XMLDocumentParser::comment):

Source/WebKit/mac:

* WebView/WebFrame.mm:
(-[WebFrame _documentFragmentWithNodesAsParagraphs:]):

Source/WebKit/win:

* DOMCoreClasses.cpp:
(DOMNode::insertBefore):
(DOMNode::removeChild):

Source/WebKit2:

* WebProcess/InjectedBundle/API/mac/WKDOMNode.mm:
(-[WKDOMNode insertNode:before:]):
(-[WKDOMNode appendChild:]):
(-[WKDOMNode removeChild:]):
* WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm:
(WebKit::PDFPlugin::PDFPlugin):
* WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm:
(WebKit::PDFPluginChoiceAnnotation::createAnnotationElement):

LayoutTests:

Rebaseline several tests now that the Node API provides more useful
exception messages.

* fast/dom/Document/replaceChild-null-oldChild-expected.txt:
* fast/dom/Document/script-tests/replaceChild-null-oldChild.js:
* fast/dom/incompatible-operations-expected.txt:
* fast/dom/incompatible-operations.html:
* fast/dom/processing-instruction-appendChild-exceptions-expected.txt:
* fast/dom/processing-instruction-appendChild-exceptions.xhtml:
* fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt:
* js/dom/dot-node-base-exception-expected.txt:
* js/dom/script-tests/dot-node-base-exception.js:

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

85 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Document/replaceChild-null-oldChild-expected.txt
LayoutTests/fast/dom/Document/script-tests/replaceChild-null-oldChild.js
LayoutTests/fast/dom/incompatible-operations-expected.txt
LayoutTests/fast/dom/incompatible-operations.html
LayoutTests/fast/dom/processing-instruction-appendChild-exceptions-expected.txt
LayoutTests/fast/dom/processing-instruction-appendChild-exceptions.xhtml
LayoutTests/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt
LayoutTests/fast/events/remove-target-with-shadow-in-drag-expected.txt
LayoutTests/js/dom/dot-node-base-exception-expected.txt
LayoutTests/js/dom/script-tests/dot-node-base-exception.js
Source/WebCore/ChangeLog
Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp
Source/WebCore/bindings/js/JSNodeCustom.cpp
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNode.h
Source/WebCore/dom/DOMImplementation.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/Node.idl
Source/WebCore/dom/NodeOrString.cpp
Source/WebCore/dom/Range.cpp
Source/WebCore/dom/Range.h
Source/WebCore/dom/Text.cpp
Source/WebCore/editing/AppendNodeCommand.cpp
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/editing/EditorCommand.cpp
Source/WebCore/editing/MergeIdenticalElementsCommand.cpp
Source/WebCore/editing/RemoveNodeCommand.cpp
Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/SplitElementCommand.cpp
Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp
Source/WebCore/editing/cocoa/EditorCocoa.mm
Source/WebCore/editing/htmlediting.cpp
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/editing/markup.cpp
Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp
Source/WebCore/html/ColorInputType.cpp
Source/WebCore/html/FTPDirectoryDocument.cpp
Source/WebCore/html/HTMLDetailsElement.cpp
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLKeygenElement.cpp
Source/WebCore/html/HTMLMeterElement.cpp
Source/WebCore/html/HTMLOptionElement.cpp
Source/WebCore/html/HTMLProgressElement.cpp
Source/WebCore/html/HTMLTableElement.cpp
Source/WebCore/html/HTMLTableRowElement.cpp
Source/WebCore/html/ImageDocument.cpp
Source/WebCore/html/MediaDocument.cpp
Source/WebCore/html/PluginDocument.cpp
Source/WebCore/html/RangeInputType.cpp
Source/WebCore/html/SearchInputType.cpp
Source/WebCore/html/ValidationMessage.cpp
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/shadow/MediaControls.cpp
Source/WebCore/html/shadow/MediaControlsApple.cpp
Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp
Source/WebCore/html/track/VTTCue.cpp
Source/WebCore/html/track/WebVTTParser.cpp
Source/WebCore/inspector/DOMEditor.cpp
Source/WebCore/inspector/DOMEditor.h
Source/WebCore/inspector/DOMPatchSupport.cpp
Source/WebCore/inspector/DOMPatchSupport.h
Source/WebCore/inspector/InspectorCSSAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/page/DragController.cpp
Source/WebCore/page/ios/FrameIOS.mm
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/xml/XMLErrors.cpp
Source/WebCore/xml/XMLTreeViewer.cpp
Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebFrame.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/DOMCoreClasses.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKDOMNode.mm
Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm
Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm

index 3299684..9a4dca0 100644 (file)
@@ -1,3 +1,23 @@
+2016-05-11  Chris Dumez  <cdumez@apple.com>
+
+        Update Node::appendChild() / replaceChild() / removeChild() / insertBefore() to take references instead of pointers
+        https://bugs.webkit.org/show_bug.cgi?id=157556
+
+        Reviewed by Darin Adler.
+
+        Rebaseline several tests now that the Node API provides more useful
+        exception messages.
+
+        * fast/dom/Document/replaceChild-null-oldChild-expected.txt:
+        * fast/dom/Document/script-tests/replaceChild-null-oldChild.js:
+        * fast/dom/incompatible-operations-expected.txt:
+        * fast/dom/incompatible-operations.html:
+        * fast/dom/processing-instruction-appendChild-exceptions-expected.txt:
+        * fast/dom/processing-instruction-appendChild-exceptions.xhtml:
+        * fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt:
+        * js/dom/dot-node-base-exception-expected.txt:
+        * js/dom/script-tests/dot-node-base-exception.js:
+
 2016-05-11  Brady Eidson  <beidson@apple.com>
 
         Modern IDB: IDBOpenDBRequests that are stop()'ed don't notify the IDBServer of that fact.
index af5a469..7ed7311 100644 (file)
@@ -3,7 +3,7 @@ Test behavior of Document.replaceChild() when oldChild is null.
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.replaceChild(document.firstChild, null) threw exception TypeError: Type error.
+PASS document.replaceChild(document.firstChild, null) threw exception TypeError: Argument 2 ('child') to Node.replaceChild must be an instance of Node.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index c09bf1b..e262a18 100644 (file)
@@ -1,3 +1,3 @@
 description('Test behavior of Document.replaceChild() when oldChild is null.');
 
-shouldThrow('document.replaceChild(document.firstChild, null)', '"TypeError: Type error"');
+shouldThrow('document.replaceChild(document.firstChild, null)');
index 85ccd54..6145797 100644 (file)
@@ -3,9 +3,9 @@ This test checks the behavior of DOM operations when called on non-DOM or incomp
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS aNode.appendChild(aDOMImplementation) threw exception TypeError: Type error.
-PASS aNode.appendChild('knort') threw exception TypeError: Type error.
-PASS aNode.appendChild(void 0) threw exception TypeError: Type error.
+PASS aNode.appendChild(aDOMImplementation) threw exception TypeError: Argument 1 ('node') to Node.appendChild must be an instance of Node.
+PASS aNode.appendChild('knort') threw exception TypeError: Argument 1 ('node') to Node.appendChild must be an instance of Node.
+PASS aNode.appendChild(void 0) threw exception TypeError: Argument 1 ('node') to Node.appendChild must be an instance of Node.
 PASS aNode.isSameNode(aDOMImplementation) is false
 PASS aNode.isSameNode('foo') is false
 PASS aNode.isSameNode(void 0) is false
index 2f0e4af..20d9597 100644 (file)
@@ -28,11 +28,11 @@ var aNode = document.createElement("div");
 var aSecondNode = document.createElement("div");
 aNode.appendChild(aSecondNode);
 
-shouldThrow("aNode.appendChild(aDOMImplementation)", "'TypeError: Type error'");
+shouldThrow("aNode.appendChild(aDOMImplementation)");
 
-shouldThrow("aNode.appendChild('knort')", "'TypeError: Type error'");
+shouldThrow("aNode.appendChild('knort')");
 
-shouldThrow("aNode.appendChild(void 0)", "'TypeError: Type error'");
+shouldThrow("aNode.appendChild(void 0)");
 
 shouldBeFalse("aNode.isSameNode(aDOMImplementation)");
 shouldBeFalse("aNode.isSameNode('foo')");
index 0e3bdf2..f7caffe 100644 (file)
@@ -3,7 +3,7 @@ Test that appropriate exceptions are thrown when adding children to a Processing
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS pi.appendChild(null) threw exception TypeError: Type error.
+PASS pi.appendChild(null) threw exception TypeError: Argument 1 ('node') to Node.appendChild must be an instance of Node.
 PASS pi.appendChild(div) threw exception Error: HierarchyRequestError: DOM Exception 3.
 PASS pi.appendChild(textNode) threw exception Error: HierarchyRequestError: DOM Exception 3.
 PASS successfullyParsed is true
index c902ba4..4ce7e0d 100644 (file)
@@ -5,7 +5,7 @@
 <![CDATA[
 description("Test that appropriate exceptions are thrown when adding children to a ProcessingInstruction.");
 var pi = document.createProcessingInstruction('target', 'data');
-shouldThrow("pi.appendChild(null)", "'TypeError: Type error'");
+shouldThrow("pi.appendChild(null)");
 var div = document.createElement('div');
 shouldThrow("pi.appendChild(div)", "'Error: HierarchyRequestError: DOM Exception 3'");
 var textNode = document.createTextNode('sometext');
index 128964f..8638978 100644 (file)
@@ -1,3 +1,3 @@
-CONSOLE MESSAGE: line 34: TypeError: Type error
-CONSOLE MESSAGE: line 34: TypeError: Type error
+CONSOLE MESSAGE: line 34: TypeError: Argument 1 ('child') to Node.removeChild must be an instance of Node
+CONSOLE MESSAGE: line 34: TypeError: Argument 1 ('child') to Node.removeChild must be an instance of Node
 PASS. DRT didn't crash.
index 36d53b4..d823a95 100644 (file)
@@ -3,7 +3,7 @@ This test checks that a correct exception is raised when calculating the base va
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS (document.appendChild()).foobar() threw exception TypeError: Type error.
+PASS (document.appendChild()).foobar() threw exception TypeError: Argument 1 ('node') to Node.appendChild must be an instance of Node.
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 71d4719..a516059 100644 (file)
@@ -3,4 +3,4 @@ description(
 );
 
 // Should be a DOM exception, not just some "TypeError: Null value".
-shouldThrow('(document.appendChild()).foobar()', '"TypeError: Type error"');
+shouldThrow('(document.appendChild()).foobar()');
index 2639657..a980962 100644 (file)
@@ -1,3 +1,198 @@
+2016-05-11  Chris Dumez  <cdumez@apple.com>
+
+        Update Node::appendChild() / replaceChild() / removeChild() / insertBefore() to take references instead of pointers
+        https://bugs.webkit.org/show_bug.cgi?id=157556
+
+        Reviewed by Darin Adler.
+
+        Update Node::appendChild() / replaceChild() / removeChild() / insertBefore()
+        to take references instead of pointers. Do the parameter null checks in the
+        bindings instead of doing it in the implementation on Node.
+
+        Also update the ContainerNode::appendChild() / replaceChild() /
+        insertBefore() to take C++ references instead of Ref<>&& to avoid
+        unnecessarily causing ref counting churns at some call sites (including
+        in the bindings since they are a raw pointer to the nodes). The
+        implementation on ContainerNode was not actually using WTFMove() on the
+        Ref<>&& anyway.
+
+        * Modules/plugins/YouTubePluginReplacement.cpp:
+        (WebCore::YouTubePluginReplacement::installReplacement):
+        * bindings/js/JSNodeCustom.cpp:
+        (WebCore::JSNode::insertBefore):
+        (WebCore::JSNode::replaceChild):
+        (WebCore::JSNode::removeChild):
+        (WebCore::JSNode::appendChild):
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::insertBefore):
+        (WebCore::ContainerNode::parserInsertBefore):
+        (WebCore::ContainerNode::replaceChild):
+        (WebCore::ContainerNode::appendChild):
+        (WebCore::ContainerNode::parserAppendChild):
+        (WebCore::ContainerNode::cloneChildNodes):
+        (WebCore::ContainerNode::append):
+        (WebCore::ContainerNode::prepend):
+        * dom/ContainerNode.h:
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::createDocument):
+        (WebCore::DOMImplementation::createHTMLDocument):
+        * dom/Document.cpp:
+        (WebCore::Document::setBodyOrFrameset):
+        * dom/Element.cpp:
+        (WebCore::Element::setOuterHTML):
+        * dom/Node.cpp:
+        (WebCore::Node::insertBefore):
+        (WebCore::Node::replaceChild):
+        (WebCore::Node::removeChild):
+        (WebCore::Node::appendChild):
+        (WebCore::Node::before):
+        (WebCore::Node::after):
+        (WebCore::Node::replaceWith):
+        (WebCore::nodeSetPreTransformedFromNodeOrStringVector): Deleted.
+        (WebCore::Node::normalize): Deleted.
+        * dom/Node.h:
+        * dom/Node.idl:
+        * dom/NodeOrString.cpp:
+        (WebCore::convertNodesOrStringsIntoNode):
+        * dom/Range.cpp:
+        (WebCore::Range::processContents):
+        (WebCore::Range::processContentsBetweenOffsets):
+        (WebCore::Range::processNodes):
+        (WebCore::Range::processAncestorsAndTheirSiblings):
+        (WebCore::Range::insertNode):
+        (WebCore::Range::surroundContents):
+        * dom/Range.h:
+        * dom/Text.cpp:
+        (WebCore::Text::splitText):
+        * editing/AppendNodeCommand.cpp:
+        (WebCore::AppendNodeCommand::doApply):
+        * editing/Editor.cpp:
+        (WebCore::Editor::setTextAsChildOfElement):
+        * editing/EditorCommand.cpp:
+        (WebCore::executeInsertNode):
+        * editing/MergeIdenticalElementsCommand.cpp:
+        (WebCore::MergeIdenticalElementsCommand::doApply):
+        (WebCore::MergeIdenticalElementsCommand::doUnapply):
+        * editing/RemoveNodeCommand.cpp:
+        (WebCore::RemoveNodeCommand::doUnapply):
+        * editing/ReplaceNodeWithSpanCommand.cpp:
+        (WebCore::swapInNodePreservingAttributesAndChildren):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplacementFragment::insertFragmentForTestRendering):
+        * editing/SplitElementCommand.cpp:
+        (WebCore::SplitElementCommand::executeApply):
+        (WebCore::SplitElementCommand::doUnapply):
+        * editing/WrapContentsInDummySpanCommand.cpp:
+        (WebCore::WrapContentsInDummySpanCommand::executeApply):
+        (WebCore::WrapContentsInDummySpanCommand::doUnapply):
+        * editing/cocoa/EditorCocoa.mm:
+        (WebCore::Editor::styleForSelectionStart):
+        * editing/htmlediting.cpp:
+        (WebCore::createTabSpanElement):
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::WebContentReader::readURL):
+        (WebCore::Editor::createFragmentForImageResourceAndAddResource):
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::WebContentReader::readFilenames):
+        (WebCore::Editor::WebContentReader::readURL):
+        (WebCore::Editor::createFragmentForImageResourceAndAddResource):
+        * editing/markup.cpp:
+        (WebCore::fillContainerFromString):
+        (WebCore::createFragmentFromText):
+        (WebCore::replaceChildrenWithFragment):
+        (WebCore::replaceChildrenWithText):
+        * html/BaseChooserOnlyDateAndTimeInputType.cpp:
+        (WebCore::BaseChooserOnlyDateAndTimeInputType::createShadowSubtree):
+        * html/ColorInputType.cpp:
+        (WebCore::ColorInputType::createShadowSubtree):
+        * html/FTPDirectoryDocument.cpp:
+        (WebCore::FTPDirectoryDocumentParser::appendEntry):
+        (WebCore::FTPDirectoryDocumentParser::createTDForFilename):
+        (WebCore::FTPDirectoryDocumentParser::createBasicDocument):
+        * html/HTMLDetailsElement.cpp:
+        (WebCore::HTMLDetailsElement::didAddUserAgentShadowRoot):
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::setOuterText):
+        (WebCore::HTMLElement::insertAdjacent):
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::tryCreateImageControls):
+        * html/HTMLKeygenElement.cpp:
+        (WebCore::HTMLKeygenElement::HTMLKeygenElement):
+        * html/HTMLMeterElement.cpp:
+        (WebCore::HTMLMeterElement::didAddUserAgentShadowRoot):
+        * html/HTMLOptionElement.cpp:
+        (WebCore::HTMLOptionElement::createForJSConstructor):
+        * html/HTMLProgressElement.cpp:
+        (WebCore::HTMLProgressElement::didAddUserAgentShadowRoot):
+        * html/HTMLTableElement.cpp:
+        (WebCore::HTMLTableElement::createTBody):
+        (WebCore::HTMLTableElement::insertRow):
+        * html/HTMLTableRowElement.cpp:
+        (WebCore::HTMLTableRowElement::insertCell):
+        * html/ImageDocument.cpp:
+        (WebCore::ImageDocument::createDocumentStructure):
+        * html/MediaDocument.cpp:
+        (WebCore::MediaDocumentParser::createDocumentStructure):
+        * html/PluginDocument.cpp:
+        (WebCore::PluginDocumentParser::createDocumentStructure):
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::createShadowSubtree):
+        * html/SearchInputType.cpp:
+        (WebCore::SearchInputType::createShadowSubtree):
+        * html/ValidationMessage.cpp:
+        (WebCore::ValidationMessage::buildBubbleTree):
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu):
+        * html/shadow/MediaControls.cpp:
+        (WebCore::MediaControls::createTextTrackDisplay):
+        * html/shadow/MediaControlsApple.cpp:
+        (WebCore::MediaControlsApple::tryCreateControls):
+        * html/shadow/mac/ImageControlsRootElementMac.cpp:
+        (WebCore::ImageControlsRootElement::tryCreate):
+        * html/track/VTTCue.cpp:
+        (WebCore::VTTCue::updateDisplayTree):
+        * html/track/WebVTTParser.cpp:
+        (WebCore::WebVTTTreeBuilder::constructTreeFromToken):
+        * inspector/DOMEditor.cpp:
+        (WebCore::DOMEditor::RemoveChildAction::RemoveChildAction):
+        (WebCore::DOMEditor::InsertBeforeAction::InsertBeforeAction):
+        (WebCore::DOMEditor::ReplaceChildNodeAction::ReplaceChildNodeAction):
+        (WebCore::DOMEditor::insertBefore):
+        (WebCore::DOMEditor::removeChild):
+        (WebCore::DOMEditor::replaceChild):
+        * inspector/DOMEditor.h:
+        * inspector/DOMPatchSupport.cpp:
+        (WebCore::DOMPatchSupport::patchNode):
+        (WebCore::DOMPatchSupport::innerPatchNode):
+        (WebCore::DOMPatchSupport::innerPatchChildren):
+        (WebCore::DOMPatchSupport::insertBeforeAndMarkAsUsed):
+        (WebCore::DOMPatchSupport::removeChildAndMoveToNew):
+        * inspector/DOMPatchSupport.h:
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::createInspectorStyleSheetForDocument):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::removeNode):
+        (WebCore::InspectorDOMAgent::setNodeName):
+        (WebCore::InspectorDOMAgent::moveTo):
+        * page/DragController.cpp:
+        (WebCore::documentFragmentFromDragData):
+        * page/ios/FrameIOS.mm:
+        (WebCore::Frame::initWithSimpleHTMLDocument):
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::cloneTarget):
+        (WebCore::SVGUseElement::expandUseElementsInShadowTree):
+        (WebCore::SVGUseElement::expandSymbolElementsInShadowTree):
+        * xml/XMLErrors.cpp:
+        (WebCore::createXHTMLParserErrorHeader):
+        (WebCore::XMLErrors::insertErrorMessageBlock):
+        * xml/XMLTreeViewer.cpp:
+        (WebCore::XMLTreeViewer::transformDocumentToTreeView):
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::startElementNs):
+        (WebCore::XMLDocumentParser::processingInstruction):
+        (WebCore::XMLDocumentParser::cdataBlock):
+        (WebCore::XMLDocumentParser::comment):
+
 2016-05-11  Brady Eidson  <beidson@apple.com>
 
         Modern IDB: IDBOpenDBRequests that are stop()'ed don't notify the IDBServer of that fact.
index 81e279d..907fc0a 100644 (file)
@@ -83,7 +83,7 @@ bool YouTubePluginReplacement::installReplacement(ShadowRoot& root)
 
     root.appendChild(*m_embedShadowElement);
 
-    Ref<HTMLIFrameElement> iframeElement = HTMLIFrameElement::create(HTMLNames::iframeTag, m_parentElement->document());
+    auto iframeElement = HTMLIFrameElement::create(HTMLNames::iframeTag, m_parentElement->document());
     if (m_attributes.contains("width"))
         iframeElement->setAttribute(HTMLNames::widthAttr, AtomicString("100%", AtomicString::ConstructFromLiteral));
     
@@ -98,7 +98,7 @@ bool YouTubePluginReplacement::installReplacement(ShadowRoot& root)
     
     // Disable frame flattening for this iframe.
     iframeElement->setAttribute(HTMLNames::scrollingAttr, AtomicString("no", AtomicString::ConstructFromLiteral));
-    m_embedShadowElement->appendChild(WTFMove(iframeElement));
+    m_embedShadowElement->appendChild(iframeElement);
 
     return true;
 }
index 26fa9e5..11680f6 100644 (file)
@@ -114,42 +114,74 @@ bool JSNodeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, v
 
 JSValue JSNode::insertBefore(ExecState& state)
 {
+    JSValue newChildValue = state.argument(0);
+    auto* newChild = JSNode::toWrapped(newChildValue);
+    if (UNLIKELY(!newChild))
+        return JSValue::decode(throwArgumentTypeError(state, 0, "node", "Node", "insertBefore", "Node"));
+
     ExceptionCode ec = 0;
-    bool ok = wrapped().insertBefore(JSNode::toWrapped(state.argument(0)), JSNode::toWrapped(state.argument(1)), ec);
-    setDOMException(&state, ec);
-    if (ok)
-        return state.argument(0);
-    return jsNull();
+    if (UNLIKELY(!wrapped().insertBefore(*newChild, JSNode::toWrapped(state.argument(1)), ec))) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    ASSERT(!ec);
+    return newChildValue;
 }
 
 JSValue JSNode::replaceChild(ExecState& state)
 {
+    auto* newChild = JSNode::toWrapped(state.argument(0));
+    JSValue oldChildValue = state.argument(1);
+    auto* oldChild = JSNode::toWrapped(oldChildValue);
+    if (UNLIKELY(!newChild || !oldChild)) {
+        if (!newChild)
+            return JSValue::decode(throwArgumentTypeError(state, 0, "node", "Node", "replaceChild", "Node"));
+        return JSValue::decode(throwArgumentTypeError(state, 1, "child", "Node", "replaceChild", "Node"));
+    }
+
     ExceptionCode ec = 0;
-    bool ok = wrapped().replaceChild(JSNode::toWrapped(state.argument(0)), JSNode::toWrapped(state.argument(1)), ec);
-    setDOMException(&state, ec);
-    if (ok)
-        return state.argument(1);
-    return jsNull();
+    if (UNLIKELY(!wrapped().replaceChild(*newChild, *oldChild, ec))) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    ASSERT(!ec);
+    return oldChildValue;
 }
 
 JSValue JSNode::removeChild(ExecState& state)
 {
+    JSValue childValue = state.argument(0);
+    auto* child = JSNode::toWrapped(childValue);
+    if (UNLIKELY(!child))
+        return JSValue::decode(throwArgumentTypeError(state, 0, "child", "Node", "removeChild", "Node"));
+
     ExceptionCode ec = 0;
-    bool ok = wrapped().removeChild(JSNode::toWrapped(state.argument(0)), ec);
-    setDOMException(&state, ec);
-    if (ok)
-        return state.argument(0);
-    return jsNull();
+    if (UNLIKELY(!wrapped().removeChild(*child, ec))) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    ASSERT(!ec);
+    return childValue;
 }
 
 JSValue JSNode::appendChild(ExecState& state)
 {
+    JSValue newChildValue = state.argument(0);
+    auto newChild = JSNode::toWrapped(newChildValue);
+    if (UNLIKELY(!newChild))
+        return JSValue::decode(throwArgumentTypeError(state, 0, "node", "Node", "appendChild", "Node"));
+
     ExceptionCode ec = 0;
-    bool ok = wrapped().appendChild(JSNode::toWrapped(state.argument(0)), ec);
-    setDOMException(&state, ec);
-    if (ok)
-        return state.argument(0);
-    return jsNull();
+    if (UNLIKELY(!wrapped().appendChild(*newChild, ec))) {
+        setDOMException(&state, ec);
+        return jsUndefined();
+    }
+
+    ASSERT(!ec);
+    return newChildValue;
 }
 
 JSScope* JSNode::pushEventHandlerScope(ExecState* exec, JSScope* node) const
index 6234190..9e23d9c 100644 (file)
@@ -225,7 +225,7 @@ static inline bool checkPreReplacementValidity(ContainerNode& newParent, Node& n
     return !ec;
 }
 
-bool ContainerNode::insertBefore(Ref<Node>&& newChild, Node* refChild, ExceptionCode& ec)
+bool ContainerNode::insertBefore(Node& newChild, Node* refChild, ExceptionCode& ec)
 {
     // Check that this node is not "floating".
     // If it is, it can be deleted as a side effect of sending mutation events.
@@ -237,7 +237,7 @@ bool ContainerNode::insertBefore(Ref<Node>&& newChild, Node* refChild, Exception
 
     // insertBefore(node, 0) is equivalent to appendChild(node)
     if (!refChild)
-        return appendChild(WTFMove(newChild), ec);
+        return appendChild(newChild, ec);
 
     // Make sure adding the new child is OK.
     if (!ensurePreInsertionValidity(newChild, refChild, ec))
@@ -249,7 +249,7 @@ bool ContainerNode::insertBefore(Ref<Node>&& newChild, Node* refChild, Exception
         return false;
     }
 
-    if (refChild->previousSibling() == newChild.ptr() || refChild == newChild.ptr()) // nothing to do
+    if (refChild->previousSibling() == &newChild || refChild == &newChild) // nothing to do
         return true;
 
     Ref<Node> next(*refChild);
@@ -359,28 +359,28 @@ void ContainerNode::notifyChildRemoved(Node& child, Node* previousSibling, Node*
     childrenChanged(change);
 }
 
-void ContainerNode::parserInsertBefore(Ref<Node>&& newChild, Node& nextChild)
+void ContainerNode::parserInsertBefore(Node& newChild, Node& nextChild)
 {
     ASSERT(nextChild.parentNode() == this);
-    ASSERT(!newChild->isDocumentFragment());
+    ASSERT(!newChild.isDocumentFragment());
     ASSERT(!hasTagName(HTMLNames::templateTag));
 
-    if (nextChild.previousSibling() == newChild.ptr() || &nextChild == newChild.ptr()) // nothing to do
+    if (nextChild.previousSibling() == &newChild || &nextChild == &newChild) // nothing to do
         return;
 
-    if (&document() != &newChild->document())
+    if (&document() != &newChild.document())
         document().adoptNode(newChild, ASSERT_NO_EXCEPTION);
 
     insertBeforeCommon(nextChild, newChild);
 
-    newChild->updateAncestorConnectedSubframeCountForInsertion();
+    newChild.updateAncestorConnectedSubframeCountForInsertion();
 
     notifyChildInserted(newChild, ChildChangeSourceParser);
 
-    newChild->setNeedsStyleRecalc(ReconstructRenderTree);
+    newChild.setNeedsStyleRecalc(ReconstructRenderTree);
 }
 
-bool ContainerNode::replaceChild(Ref<Node>&& newChild, Node& oldChild, ExceptionCode& ec)
+bool ContainerNode::replaceChild(Node& newChild, Node& oldChild, ExceptionCode& ec)
 {
     // Check that this node is not "floating".
     // If it is, it can be deleted as a side effect of sending mutation events.
@@ -390,7 +390,7 @@ bool ContainerNode::replaceChild(Ref<Node>&& newChild, Node& oldChild, Exception
 
     ec = 0;
 
-    if (&oldChild == newChild.ptr()) // nothing to do
+    if (&oldChild == &newChild) // nothing to do
         return true;
 
     // Make sure replacing the old child with the new is ok
@@ -406,7 +406,7 @@ bool ContainerNode::replaceChild(Ref<Node>&& newChild, Node& oldChild, Exception
     ChildListMutationScope mutation(*this);
 
     RefPtr<Node> refChild = oldChild.nextSibling();
-    if (refChild.get() == newChild.ptr())
+    if (refChild.get() == &newChild)
         refChild = refChild->nextSibling();
 
     NodeVector targets;
@@ -647,7 +647,7 @@ void ContainerNode::removeChildren()
     dispatchSubtreeModifiedEvent();
 }
 
-bool ContainerNode::appendChild(Ref<Node>&& newChild, ExceptionCode& ec)
+bool ContainerNode::appendChild(Node& newChild, ExceptionCode& ec)
 {
     Ref<ContainerNode> protect(*this);
 
@@ -661,7 +661,7 @@ bool ContainerNode::appendChild(Ref<Node>&& newChild, ExceptionCode& ec)
     if (!ensurePreInsertionValidity(newChild, nullptr, ec))
         return false;
 
-    if (newChild.ptr() == m_lastChild) // nothing to do
+    if (&newChild == m_lastChild) // nothing to do
         return true;
 
     NodeVector targets;
@@ -702,27 +702,27 @@ bool ContainerNode::appendChild(Ref<Node>&& newChild, ExceptionCode& ec)
     return true;
 }
 
-void ContainerNode::parserAppendChild(Ref<Node>&& newChild)
+void ContainerNode::parserAppendChild(Node& newChild)
 {
-    ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle reparenting (and want DOM mutation events).
-    ASSERT(!newChild->isDocumentFragment());
+    ASSERT(!newChild.parentNode()); // Use appendChild if you need to handle reparenting (and want DOM mutation events).
+    ASSERT(!newChild.isDocumentFragment());
     ASSERT(!hasTagName(HTMLNames::templateTag));
 
-    if (&document() != &newChild->document())
+    if (&document() != &newChild.document())
         document().adoptNode(newChild, ASSERT_NO_EXCEPTION);
 
     {
         NoEventDispatchAssertion assertNoEventDispatch;
         // FIXME: This method should take a PassRefPtr.
         appendChildCommon(newChild);
-        treeScope().adoptIfNeeded(newChild.ptr());
+        treeScope().adoptIfNeeded(&newChild);
     }
 
-    newChild->updateAncestorConnectedSubframeCountForInsertion();
+    newChild.updateAncestorConnectedSubframeCountForInsertion();
 
     notifyChildInserted(newChild, ChildChangeSourceParser);
 
-    newChild->setNeedsStyleRecalc(ReconstructRenderTree);
+    newChild.setNeedsStyleRecalc(ReconstructRenderTree);
 }
 
 void ContainerNode::childrenChanged(const ChildChange& change)
@@ -739,7 +739,7 @@ void ContainerNode::cloneChildNodes(ContainerNode& clone)
     Document& targetDocument = clone.document();
     for (Node* child = firstChild(); child && !ec; child = child->nextSibling()) {
         Ref<Node> clonedChild = child->cloneNodeInternal(targetDocument, CloningOperation::SelfWithTemplateContent);
-        clone.appendChild(clonedChild.copyRef(), ec);
+        clone.appendChild(clonedChild, ec);
 
         if (!ec && is<ContainerNode>(*child))
             downcast<ContainerNode>(*child).cloneChildNodes(downcast<ContainerNode>(clonedChild.get()));
@@ -916,7 +916,7 @@ void ContainerNode::append(Vector<NodeOrString>&& nodeOrStringVector, ExceptionC
     if (ec || !node)
         return;
 
-    appendChild(node.releaseNonNull(), ec);
+    appendChild(*node, ec);
 }
 
 void ContainerNode::prepend(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec)
@@ -925,7 +925,7 @@ void ContainerNode::prepend(Vector<NodeOrString>&& nodeOrStringVector, Exception
     if (ec || !node)
         return;
 
-    insertBefore(node.releaseNonNull(), firstChild(), ec);
+    insertBefore(*node, firstChild(), ec);
 }
 
 HTMLCollection* ContainerNode::cachedHTMLCollection(CollectionType type)
index edf4042..091f5e8 100644 (file)
@@ -50,17 +50,17 @@ public:
     WEBCORE_EXPORT unsigned countChildNodes() const;
     WEBCORE_EXPORT Node* traverseToChildAt(unsigned) const;
 
-    bool insertBefore(Ref<Node>&& newChild, Node* refChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
-    bool replaceChild(Ref<Node>&& newChild, Node& oldChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
+    bool insertBefore(Node& newChild, Node* refChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
+    bool replaceChild(Node& newChild, Node& oldChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
     WEBCORE_EXPORT bool removeChild(Node& child, ExceptionCode& = ASSERT_NO_EXCEPTION);
-    WEBCORE_EXPORT bool appendChild(Ref<Node>&& newChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
+    WEBCORE_EXPORT bool appendChild(Node& newChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
 
     // These methods are only used during parsing.
     // They don't send DOM mutation events or handle reparenting.
     // However, arbitrary code may be run by beforeload handlers.
-    void parserAppendChild(Ref<Node>&&);
+    void parserAppendChild(Node&);
     void parserRemoveChild(Node&);
-    void parserInsertBefore(Ref<Node>&& newChild, Node& refChild);
+    void parserInsertBefore(Node& newChild, Node& refChild);
 
     void removeChildren();
     void takeAllChildrenFrom(ContainerNode*);
index 36ecd58..e53cbd0 100644 (file)
@@ -238,13 +238,13 @@ RefPtr<XMLDocument> DOMImplementation::createDocument(const String& namespaceURI
     if (!qualifiedName.isEmpty()) {
         documentElement = doc->createElementNS(namespaceURI, qualifiedName, ec);
         if (ec)
-            return 0;
+            return nullptr;
     }
 
     if (doctype)
         doc->appendChild(*doctype);
     if (documentElement)
-        doc->appendChild(documentElement.releaseNonNull());
+        doc->appendChild(*documentElement);
 
     return doc;
 }
@@ -312,7 +312,7 @@ Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
         auto titleElement = HTMLTitleElement::create(titleTag, document);
         titleElement->appendChild(document->createTextNode(title));
         ASSERT(document->head());
-        document->head()->appendChild(WTFMove(titleElement));
+        document->head()->appendChild(titleElement);
     }
     document->setSecurityOriginPolicy(m_document.securityOriginPolicy());
     return document;
index c0692ad..5f770ae 100644 (file)
@@ -2631,9 +2631,9 @@ void Document::setBodyOrFrameset(RefPtr<HTMLElement>&& newBody, ExceptionCode& e
     }
 
     if (auto* body = bodyOrFrameset())
-        documentElement()->replaceChild(newBody.releaseNonNull(), *body, ec);
+        documentElement()->replaceChild(*newBody, *body, ec);
     else
-        documentElement()->appendChild(newBody.releaseNonNull(), ec);
+        documentElement()->appendChild(*newBody, ec);
 }
 
 Location* Document::location() const
index f7b0575..5bdaadf 100644 (file)
@@ -2369,7 +2369,7 @@ void Element::setOuterHTML(const String& html, ExceptionCode& ec)
     if (ec)
         return;
     
-    parent->replaceChild(fragment.releaseNonNull(), *this, ec);
+    parent->replaceChild(*fragment, *this, ec);
     RefPtr<Node> node = next ? next->previousSibling() : nullptr;
     if (!ec && is<Text>(node.get()))
         mergeWithNextTextNode(downcast<Text>(*node), ec);
index a242776..25f07d2 100644 (file)
@@ -398,56 +398,40 @@ Element* Node::nextElementSibling() const
     return ElementTraversal::nextSibling(*this);
 }
 
-bool Node::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& ec)
+bool Node::insertBefore(Node& newChild, Node* refChild, ExceptionCode& ec)
 {
-    if (!newChild) {
-        ec = TypeError;
-        return false;
-    }
     if (!is<ContainerNode>(*this)) {
         ec = HIERARCHY_REQUEST_ERR;
         return false;
     }
-    return downcast<ContainerNode>(*this).insertBefore(*newChild, refChild, ec);
+    return downcast<ContainerNode>(*this).insertBefore(newChild, refChild, ec);
 }
 
-bool Node::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode& ec)
+bool Node::replaceChild(Node& newChild, Node& oldChild, ExceptionCode& ec)
 {
-    if (!newChild || !oldChild) {
-        ec = TypeError;
-        return false;
-    }
     if (!is<ContainerNode>(*this)) {
         ec = HIERARCHY_REQUEST_ERR;
         return false;
     }
-    return downcast<ContainerNode>(*this).replaceChild(*newChild, *oldChild, ec);
+    return downcast<ContainerNode>(*this).replaceChild(newChild, oldChild, ec);
 }
 
-bool Node::removeChild(Node* oldChild, ExceptionCode& ec)
+bool Node::removeChild(Node& oldChild, ExceptionCode& ec)
 {
-    if (!oldChild) {
-        ec = TypeError;
-        return false;
-    }
     if (!is<ContainerNode>(*this)) {
         ec = NOT_FOUND_ERR;
         return false;
     }
-    return downcast<ContainerNode>(*this).removeChild(*oldChild, ec);
+    return downcast<ContainerNode>(*this).removeChild(oldChild, ec);
 }
 
-bool Node::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec)
+bool Node::appendChild(Node& newChild, ExceptionCode& ec)
 {
-    if (!newChild) {
-        ec = TypeError;
-        return false;
-    }
     if (!is<ContainerNode>(*this)) {
         ec = HIERARCHY_REQUEST_ERR;
         return false;
     }
-    return downcast<ContainerNode>(*this).appendChild(*newChild, ec);
+    return downcast<ContainerNode>(*this).appendChild(newChild, ec);
 }
 
 static HashSet<RefPtr<Node>> nodeSetPreTransformedFromNodeOrStringVector(const Vector<NodeOrString>& nodeOrStringVector)
@@ -502,7 +486,7 @@ void Node::before(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec)
     else
         viablePreviousSibling = parent->firstChild();
 
-    parent->insertBefore(node.releaseNonNull(), viablePreviousSibling.get(), ec);
+    parent->insertBefore(*node, viablePreviousSibling.get(), ec);
 }
 
 void Node::after(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec)
@@ -518,7 +502,7 @@ void Node::after(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec)
     if (ec || !node)
         return;
 
-    parent->insertBefore(node.releaseNonNull(), viableNextSibling.get(), ec);
+    parent->insertBefore(*node, viableNextSibling.get(), ec);
 }
 
 void Node::replaceWith(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec)
@@ -536,11 +520,11 @@ void Node::replaceWith(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode&
 
     if (parentNode() == parent) {
         if (node)
-            parent->replaceChild(node.releaseNonNull(), *this, ec);
+            parent->replaceChild(*node, *this, ec);
         else
             parent->removeChild(*this);
     } else if (node)
-        parent->insertBefore(node.releaseNonNull(), viableNextSibling.get(), ec);
+        parent->insertBefore(*node, viableNextSibling.get(), ec);
 }
 
 void Node::remove(ExceptionCode& ec)
index d66a8ef..a680acc 100644 (file)
@@ -167,10 +167,10 @@ public:
     // These should all actually return a node, but this is only important for language bindings,
     // which will already know and hold a ref on the right node to return. Returning bool allows
     // these methods to be more efficient since they don't need to return a ref
-    WEBCORE_EXPORT bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode&);
-    bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode&);
-    WEBCORE_EXPORT bool removeChild(Node* child, ExceptionCode&);
-    WEBCORE_EXPORT bool appendChild(PassRefPtr<Node> newChild, ExceptionCode&);
+    WEBCORE_EXPORT bool insertBefore(Node& newChild, Node* refChild, ExceptionCode&);
+    bool replaceChild(Node& newChild, Node& oldChild, ExceptionCode&);
+    WEBCORE_EXPORT bool removeChild(Node& child, ExceptionCode&);
+    WEBCORE_EXPORT bool appendChild(Node& newChild, ExceptionCode&);
 
     bool hasChildNodes() const { return firstChild(); }
 
index be0879b..1dbf305 100644 (file)
     readonly attribute Node             nextSibling;
     readonly attribute Document         ownerDocument;
 
-    // FIXME: newChild should not be nullable.
-    [ObjCLegacyUnnamedParameters, Custom, RaisesException] Node insertBefore([CustomReturn] Node? newChild,
-                                                            Node? refChild);
-    // FIXME: newChild and oldChild should not be nullable.
-    [ObjCLegacyUnnamedParameters, Custom, RaisesException] Node replaceChild(Node? newChild,
-                                                            [CustomReturn] Node? oldChild);
-    // FIXME: oldChild should not be nullable.
-    [Custom, RaisesException] Node removeChild([CustomReturn] Node? oldChild);
-    // FIXME: newChild should not be nullable.
-    [Custom, RaisesException] Node appendChild([CustomReturn] Node? newChild);
+    [ObjCLegacyUnnamedParameters, Custom, RaisesException] Node insertBefore([CustomReturn] Node newChild, Node? refChild);
+    [ObjCLegacyUnnamedParameters, Custom, RaisesException] Node replaceChild(Node newChild, [CustomReturn] Node oldChild);
+    [Custom, RaisesException] Node removeChild([CustomReturn] Node oldChild);
+    [Custom, RaisesException] Node appendChild([CustomReturn] Node newChild);
 
     boolean            hasChildNodes();
 
index d5f25e4..7ba14b2 100644 (file)
@@ -36,7 +36,7 @@ RefPtr<Node> convertNodesOrStringsIntoNode(Node& context, Vector<NodeOrString>&&
     if (nodeOrStringVector.isEmpty())
         return nullptr;
 
-    Vector<RefPtr<Node>> nodes;
+    Vector<Ref<Node>> nodes;
     nodes.reserveInitialCapacity(nodeOrStringVector.size());
     for (auto& nodeOrString : nodeOrStringVector) {
         switch (nodeOrString.type()) {
@@ -44,24 +44,20 @@ RefPtr<Node> convertNodesOrStringsIntoNode(Node& context, Vector<NodeOrString>&&
             nodes.uncheckedAppend(Text::create(context.document(), nodeOrString.string()));
             break;
         case NodeOrString::Type::Node:
-            nodes.uncheckedAppend(&nodeOrString.node());
+            nodes.uncheckedAppend(nodeOrString.node());
             break;
         }
     }
 
-    RefPtr<Node> nodeToReturn;
     if (nodes.size() == 1)
-        nodeToReturn = nodes.first();
-    else {
-        nodeToReturn = DocumentFragment::create(context.document());
-        for (auto& node : nodes) {
-            nodeToReturn->appendChild(node, ec);
-            if (ec)
-                return nullptr;
-        }
+        return WTFMove(nodes.first());
+
+    auto nodeToReturn = DocumentFragment::create(context.document());
+    for (auto& node : nodes) {
+        if (!nodeToReturn->appendChild(node, ec))
+            return nullptr;
     }
-    
-    return nodeToReturn;
+    return WTFMove(nodeToReturn);
 }
 
 } // namespace WebCore
index e4f11fa..f882234 100644 (file)
@@ -554,7 +554,7 @@ static inline unsigned lengthOfContentsInNode(Node& node)
 
 RefPtr<DocumentFragment> Range::processContents(ActionType action, ExceptionCode& ec)
 {
-    typedef Vector<RefPtr<Node>> NodeVector;
+    typedef Vector<Ref<Node>> NodeVector;
 
     RefPtr<DocumentFragment> fragment;
     if (action == Extract || action == Clone)
@@ -602,13 +602,13 @@ RefPtr<DocumentFragment> Range::processContents(ActionType action, ExceptionCode
     RefPtr<Node> leftContents;
     if (originalStart.container() != commonRoot && commonRoot->contains(originalStart.container())) {
         leftContents = processContentsBetweenOffsets(action, 0, originalStart.container(), originalStart.offset(), lengthOfContentsInNode(*originalStart.container()), ec);
-        leftContents = processAncestorsAndTheirSiblings(action, originalStart.container(), ProcessContentsForward, leftContents, commonRoot.get(), ec);
+        leftContents = processAncestorsAndTheirSiblings(action, originalStart.container(), ProcessContentsForward, WTFMove(leftContents), commonRoot.get(), ec);
     }
 
     RefPtr<Node> rightContents;
     if (&endContainer() != commonRoot && commonRoot->contains(originalEnd.container())) {
         rightContents = processContentsBetweenOffsets(action, 0, originalEnd.container(), 0, originalEnd.offset(), ec);
-        rightContents = processAncestorsAndTheirSiblings(action, originalEnd.container(), ProcessContentsBackward, rightContents, commonRoot.get(), ec);
+        rightContents = processAncestorsAndTheirSiblings(action, originalEnd.container(), ProcessContentsBackward, WTFMove(rightContents), commonRoot.get(), ec);
     }
 
     // delete all children of commonRoot between the start and end container
@@ -637,9 +637,9 @@ RefPtr<DocumentFragment> Range::processContents(ActionType action, ExceptionCode
 
     if (processStart) {
         NodeVector nodes;
-        for (Node* n = processStart.get(); n && n != processEnd; n = n->nextSibling())
-            nodes.append(n);
-        processNodes(action, nodes, commonRoot, fragment, ec);
+        for (Node* node = processStart.get(); node && node != processEnd; node = node->nextSibling())
+            nodes.append(*node);
+        processNodes(action, nodes, commonRoot.get(), fragment.get(), ec);
     }
 
     if ((action == Extract || action == Clone) && rightContents)
@@ -648,12 +648,12 @@ RefPtr<DocumentFragment> Range::processContents(ActionType action, ExceptionCode
     return fragment;
 }
 
-static inline void deleteCharacterData(PassRefPtr<CharacterData> data, unsigned startOffset, unsigned endOffset, ExceptionCode& ec)
+static inline void deleteCharacterData(CharacterData& data, unsigned startOffset, unsigned endOffset, ExceptionCode& ec)
 {
-    if (data->length() - endOffset)
-        data->deleteData(endOffset, data->length() - endOffset, ec);
+    if (data.length() - endOffset)
+        data.deleteData(endOffset, data.length() - endOffset, ec);
     if (startOffset)
-        data->deleteData(0, startOffset, ec);
+        data.deleteData(0, startOffset, ec);
 }
 
 RefPtr<Node> Range::processContentsBetweenOffsets(ActionType action, PassRefPtr<DocumentFragment> fragment, Node* container, unsigned startOffset, unsigned endOffset, ExceptionCode& ec)
@@ -670,11 +670,11 @@ RefPtr<Node> Range::processContentsBetweenOffsets(ActionType action, PassRefPtr<
         endOffset = std::min(endOffset, static_cast<CharacterData*>(container)->length());
         startOffset = std::min(startOffset, endOffset);
         if (action == Extract || action == Clone) {
-            RefPtr<CharacterData> characters = static_cast<CharacterData*>(container->cloneNode(true).ptr());
+            Ref<CharacterData> characters = static_cast<CharacterData&>(container->cloneNode(true).get());
             deleteCharacterData(characters, startOffset, endOffset, ec);
             if (fragment) {
                 result = fragment;
-                result->appendChild(characters.release(), ec);
+                result->appendChild(characters, ec);
             } else
                 result = WTFMove(characters);
         }
@@ -685,11 +685,11 @@ RefPtr<Node> Range::processContentsBetweenOffsets(ActionType action, PassRefPtr<
         endOffset = std::min(endOffset, static_cast<ProcessingInstruction*>(container)->data().length());
         startOffset = std::min(startOffset, endOffset);
         if (action == Extract || action == Clone) {
-            RefPtr<ProcessingInstruction> processingInstruction = static_cast<ProcessingInstruction*>(container->cloneNode(true).ptr());
+            Ref<ProcessingInstruction> processingInstruction = static_cast<ProcessingInstruction&>(container->cloneNode(true).get());
             processingInstruction->setData(processingInstruction->data().substring(startOffset, endOffset - startOffset));
             if (fragment) {
                 result = fragment;
-                result->appendChild(processingInstruction.release(), ec);
+                result->appendChild(processingInstruction, ec);
             } else
                 result = WTFMove(processingInstruction);
         }
@@ -714,7 +714,7 @@ RefPtr<Node> Range::processContentsBetweenOffsets(ActionType action, PassRefPtr<
         }
 
         Node* n = container->firstChild();
-        Vector<RefPtr<Node>> nodes;
+        Vector<Ref<Node>> nodes;
         for (unsigned i = startOffset; n && i; i--)
             n = n->nextSibling();
         for (unsigned i = startOffset; n && i < endOffset; i++, n = n->nextSibling()) {
@@ -722,25 +722,25 @@ RefPtr<Node> Range::processContentsBetweenOffsets(ActionType action, PassRefPtr<
                 ec = HIERARCHY_REQUEST_ERR;
                 return nullptr;
             }
-            nodes.append(n);
+            nodes.append(*n);
         }
 
-        processNodes(action, nodes, container, result, ec);
+        processNodes(action, nodes, container, result.get(), ec);
         break;
     }
 
     return result;
 }
 
-void Range::processNodes(ActionType action, Vector<RefPtr<Node>>& nodes, PassRefPtr<Node> oldContainer, PassRefPtr<Node> newContainer, ExceptionCode& ec)
+void Range::processNodes(ActionType action, Vector<Ref<Node>>& nodes, Node* oldContainer, Node* newContainer, ExceptionCode& ec)
 {
     for (auto& node : nodes) {
         switch (action) {
         case Delete:
-            oldContainer->removeChild(node.get(), ec);
+            oldContainer->removeChild(node, ec);
             break;
         case Extract:
-            newContainer->appendChild(node.release(), ec); // will remove n from its parent
+            newContainer->appendChild(node, ec); // will remove n from its parent
             break;
         case Clone:
             newContainer->appendChild(node->cloneNode(true), ec);
@@ -749,44 +749,44 @@ void Range::processNodes(ActionType action, Vector<RefPtr<Node>>& nodes, PassRef
     }
 }
 
-RefPtr<Node> Range::processAncestorsAndTheirSiblings(ActionType action, Node* container, ContentsProcessDirection direction, PassRefPtr<Node> passedClonedContainer, Node* commonRoot, ExceptionCode& ec)
+RefPtr<Node> Range::processAncestorsAndTheirSiblings(ActionType action, Node* container, ContentsProcessDirection direction, RefPtr<Node>&& passedClonedContainer, Node* commonRoot, ExceptionCode& ec)
 {
-    typedef Vector<RefPtr<Node>> NodeVector;
+    typedef Vector<Ref<Node>> NodeVector;
 
-    RefPtr<Node> clonedContainer = passedClonedContainer;
-    Vector<RefPtr<Node>> ancestors;
-    for (ContainerNode* n = container->parentNode(); n && n != commonRoot; n = n->parentNode())
-        ancestors.append(n);
+    RefPtr<Node> clonedContainer = WTFMove(passedClonedContainer);
+    Vector<Ref<ContainerNode>> ancestors;
+    for (ContainerNode* ancestor = container->parentNode(); ancestor && ancestor != commonRoot; ancestor = ancestor->parentNode())
+        ancestors.append(*ancestor);
 
     RefPtr<Node> firstChildInAncestorToProcess = direction == ProcessContentsForward ? container->nextSibling() : container->previousSibling();
     for (auto& ancestor : ancestors) {
         if (action == Extract || action == Clone) {
-            if (RefPtr<Node> clonedAncestor = ancestor->cloneNode(false)) { // Might have been removed already during mutation event.
-                clonedAncestor->appendChild(clonedContainer, ec);
-                clonedContainer = clonedAncestor;
-            }
+            auto clonedAncestor = ancestor->cloneNode(false); // Might have been removed already during mutation event.
+            if (clonedContainer)
+                clonedAncestor->appendChild(*clonedContainer, ec);
+            clonedContainer = WTFMove(clonedAncestor);
         }
 
         // Copy siblings of an ancestor of start/end containers
         // FIXME: This assertion may fail if DOM is modified during mutation event
         // FIXME: Share code with Range::processNodes
-        ASSERT(!firstChildInAncestorToProcess || firstChildInAncestorToProcess->parentNode() == ancestor);
+        ASSERT(!firstChildInAncestorToProcess || firstChildInAncestorToProcess->parentNode() == ancestor.ptr());
         
         NodeVector nodes;
         for (Node* child = firstChildInAncestorToProcess.get(); child;
             child = (direction == ProcessContentsForward) ? child->nextSibling() : child->previousSibling())
-            nodes.append(child);
+            nodes.append(*child);
 
         for (auto& child : nodes) {
             switch (action) {
             case Delete:
-                ancestor->removeChild(child.get(), ec);
+                ancestor->removeChild(child, ec);
                 break;
             case Extract: // will remove child from ancestor
                 if (direction == ProcessContentsForward)
-                    clonedContainer->appendChild(child.get(), ec);
+                    clonedContainer->appendChild(child, ec);
                 else
-                    clonedContainer->insertBefore(child.get(), clonedContainer->firstChild(), ec);
+                    clonedContainer->insertBefore(child, clonedContainer->firstChild(), ec);
                 break;
             case Clone:
                 if (direction == ProcessContentsForward)
@@ -853,7 +853,7 @@ void Range::insertNode(Ref<Node>&& node, ExceptionCode& ec)
     else
         ++newOffset;
 
-    parent->insertBefore(WTFMove(node), referenceNode.get(), ec);
+    parent->insertBefore(node, referenceNode.get(), ec);
     if (ec)
         return;
 
@@ -1084,7 +1084,7 @@ void Range::surroundContents(Node& passNewParent, ExceptionCode& ec)
     insertNode(newParent.copyRef(), ec);
     if (ec)
         return;
-    newParent->appendChild(fragment.release(), ec);
+    newParent->appendChild(*fragment, ec);
     if (ec)
         return;
     selectNode(newParent, ec);
index 23ac357..db6dd40 100644 (file)
@@ -164,9 +164,9 @@ private:
     enum ActionType { Delete, Extract, Clone };
     RefPtr<DocumentFragment> processContents(ActionType, ExceptionCode&);
     static RefPtr<Node> processContentsBetweenOffsets(ActionType, PassRefPtr<DocumentFragment>, Node*, unsigned startOffset, unsigned endOffset, ExceptionCode&);
-    static void processNodes(ActionType, Vector<RefPtr<Node>>&, PassRefPtr<Node> oldContainer, PassRefPtr<Node> newContainer, ExceptionCode&);
+    static void processNodes(ActionType, Vector<Ref<Node>>&, Node* oldContainer, Node* newContainer, ExceptionCode&);
     enum ContentsProcessDirection { ProcessContentsForward, ProcessContentsBackward };
-    static RefPtr<Node> processAncestorsAndTheirSiblings(ActionType, Node* container, ContentsProcessDirection, PassRefPtr<Node> clonedContainer, Node* commonRoot, ExceptionCode&);
+    static RefPtr<Node> processAncestorsAndTheirSiblings(ActionType, Node* container, ContentsProcessDirection, RefPtr<Node>&& clonedContainer, Node* commonRoot, ExceptionCode&);
 
     enum class CoordinateSpace { Absolute, Client };
     void getBorderAndTextQuads(Vector<FloatQuad>&, CoordinateSpace) const;
index 25a6bda..3688292 100644 (file)
@@ -75,7 +75,7 @@ RefPtr<Text> Text::splitText(unsigned offset, ExceptionCode& ec)
     dispatchModifiedEvent(oldStr);
 
     if (parentNode())
-        parentNode()->insertBefore(newText.copyRef(), nextSibling(), ec);
+        parentNode()->insertBefore(newText, nextSibling(), ec);
     if (ec)
         return 0;
 
index 50498e7..1e19ce0 100644 (file)
@@ -51,7 +51,7 @@ void AppendNodeCommand::doApply()
     if (!m_parent->hasEditableStyle() && m_parent->renderer())
         return;
 
-    m_parent->appendChild(m_node.copyRef(), IGNORE_EXCEPTION);
+    m_parent->appendChild(m_node, IGNORE_EXCEPTION);
 }
 
 void AppendNodeCommand::doUnapply()
index 8d0457a..a006567 100644 (file)
@@ -593,7 +593,7 @@ void Editor::confirmMarkedText()
         confirmComposition();
 }
 
-void Editor::setTextAsChildOfElement(const String& text, Element* elem)
+void Editor::setTextAsChildOfElement(const String& text, Element& element)
 {
     // Clear the composition
     clear();
@@ -604,7 +604,7 @@ void Editor::setTextAsChildOfElement(const String& text, Element* elem)
     
     // If the element is empty already and we're not adding text, we can early return and avoid clearing/setting
     // a selection at [0, 0] and the expense involved in creation VisiblePositions.
-    if (!elem->firstChild() && text.isEmpty())
+    if (!element.firstChild() && text.isEmpty())
         return;
     
     // As a side effect this function sets a caret selection after the inserted content.  Much of what 
@@ -612,7 +612,7 @@ void Editor::setTextAsChildOfElement(const String& text, Element* elem)
     m_frame.selection().clear();
     
     // clear out all current children of element
-    elem->removeChildren();
+    element.removeChildren();
 
     if (text.length()) {
         // insert new text
@@ -621,29 +621,28 @@ void Editor::setTextAsChildOfElement(const String& text, Element* elem)
         // (even if it is only temporary).  ReplaceSelectionCommand doesn't bother doing this when it inserts
         // content, why should we here?
         ExceptionCode ec;
-        RefPtr<Node> parent = elem->parentNode();
-        RefPtr<Node> siblingAfter = elem->nextSibling();
+        RefPtr<Node> parent = element.parentNode();
+        RefPtr<Node> siblingAfter = element.nextSibling();
         if (parent)
-            elem->remove(ec);    
+            element.remove(ec);
             
-        RefPtr<Range> context = document().createRange();
-        context->selectNodeContents(*elem, ec);
-        Ref<DocumentFragment> fragment = createFragmentFromText(*context.get(), text);
-        elem->appendChild(WTFMove(fragment), ec);
+        auto context = document().createRange();
+        context->selectNodeContents(element, ec);
+        element.appendChild(createFragmentFromText(context, text), ec);
     
         // restore element to document
         if (parent) {
             if (siblingAfter)
-                parent->insertBefore(elem, siblingAfter.get(), ec);
+                parent->insertBefore(element, siblingAfter.get(), ec);
             else
-                parent->appendChild(elem, ec);
+                parent->appendChild(element, ec);
         }
     }
 
     // set the selection to the end
     VisibleSelection selection;
 
-    Position pos = createLegacyEditingPosition(elem, elem->countChildNodes());
+    Position pos = createLegacyEditingPosition(&element, element.countChildNodes());
 
     VisiblePosition visiblePos(pos, VP_DEFAULT_AFFINITY);
     if (visiblePos.isNull())
index 9eaad45..84ff4b9 100644 (file)
@@ -333,7 +333,7 @@ public:
 
 #if PLATFORM(IOS)
     WEBCORE_EXPORT void confirmMarkedText();
-    WEBCORE_EXPORT void setTextAsChildOfElement(const String&, Element*);
+    WEBCORE_EXPORT void setTextAsChildOfElement(const String&, Element&);
     WEBCORE_EXPORT void setTextAlignmentForChangedBaseWritingDirection(WritingDirection);
     WEBCORE_EXPORT void insertDictationPhrases(Vector<Vector<String>>&& dictationPhrases, RetainPtr<id> metadata);
     WEBCORE_EXPORT void setDictationPhrasesAsChildOfElement(const Vector<Vector<String>>& dictationPhrases, RetainPtr<id> metadata, Element&);
index 81aa000..427b3b3 100644 (file)
@@ -167,7 +167,7 @@ static bool executeInsertNode(Frame& frame, Ref<Node>&& content)
 {
     RefPtr<DocumentFragment> fragment = DocumentFragment::create(*frame.document());
     ExceptionCode ec = 0;
-    fragment->appendChild(WTFMove(content), ec);
+    fragment->appendChild(content, ec);
     if (ec)
         return false;
     return executeInsertFragment(frame, fragment.release());
index 1db30f7..6184de8 100644 (file)
@@ -52,7 +52,7 @@ void MergeIdenticalElementsCommand::doApply()
         children.append(*child);
 
     for (auto& child : children)
-        m_element2->insertBefore(WTFMove(child), m_atChild.get(), IGNORE_EXCEPTION);
+        m_element2->insertBefore(child, m_atChild.get(), IGNORE_EXCEPTION);
 
     m_element1->remove(IGNORE_EXCEPTION);
 }
@@ -79,7 +79,7 @@ void MergeIdenticalElementsCommand::doUnapply()
         children.append(*child);
 
     for (auto& child : children)
-        m_element1->appendChild(WTFMove(child), ec);
+        m_element1->appendChild(child, ec);
 }
 
 #ifndef NDEBUG
index 00eda48..b2a7bc6 100644 (file)
@@ -63,7 +63,7 @@ void RemoveNodeCommand::doUnapply()
     if (!parent || !parent->hasEditableStyle())
         return;
 
-    parent->insertBefore(m_node.copyRef(), refChild.get(), IGNORE_EXCEPTION);
+    parent->insertBefore(m_node, refChild.get(), IGNORE_EXCEPTION);
 }
 
 #ifndef NDEBUG
index a4c6858..3682bc3 100644 (file)
@@ -58,7 +58,7 @@ static void swapInNodePreservingAttributesAndChildren(HTMLElement& newNode, HTML
     NodeVector children;
     getChildNodes(nodeToReplace, children);
     for (auto& child : children)
-        newNode.appendChild(WTFMove(child), ASSERT_NO_EXCEPTION);
+        newNode.appendChild(child, ASSERT_NO_EXCEPTION);
 
     parentNode->insertBefore(newNode, &nodeToReplace, ASSERT_NO_EXCEPTION);
     parentNode->removeChild(nodeToReplace, ASSERT_NO_EXCEPTION);
index 070fb81..8b68cfb 100644 (file)
@@ -257,7 +257,7 @@ Ref<HTMLElement> ReplacementFragment::insertFragmentForTestRendering(Node* rootE
     auto holder = createDefaultParagraphElement(document());
 
     holder->appendChild(*m_fragment, ASSERT_NO_EXCEPTION);
-    rootEditableElement->appendChild(holder.ptr(), ASSERT_NO_EXCEPTION);
+    rootEditableElement->appendChild(holder, ASSERT_NO_EXCEPTION);
     document().updateLayoutIgnorePendingStylesheets();
 
     return holder;
index ae48809..9f989ce 100644 (file)
@@ -64,7 +64,7 @@ void SplitElementCommand::executeApply()
     m_element2->removeAttribute(HTMLNames::idAttr);
 
     for (auto& child : children)
-        m_element1->appendChild(WTFMove(child), ec);
+        m_element1->appendChild(child, ec);
 }
     
 void SplitElementCommand::doApply()
@@ -86,7 +86,7 @@ void SplitElementCommand::doUnapply()
     RefPtr<Node> refChild = m_element2->firstChild();
 
     for (auto& child : children)
-        m_element2->insertBefore(WTFMove(child), refChild.get(), IGNORE_EXCEPTION);
+        m_element2->insertBefore(child, refChild.get(), IGNORE_EXCEPTION);
 
     // Recover the id attribute of the original element.
     const AtomicString& id = m_element1->getIdAttribute();
index 768f33f..608a3c3 100644 (file)
@@ -44,7 +44,7 @@ void WrapContentsInDummySpanCommand::executeApply()
         children.append(*child);
 
     for (auto& child : children)
-        m_dummySpan->appendChild(WTFMove(child), IGNORE_EXCEPTION);
+        m_dummySpan->appendChild(child, IGNORE_EXCEPTION);
 
     m_element->appendChild(*m_dummySpan, IGNORE_EXCEPTION);
 }
@@ -66,7 +66,7 @@ void WrapContentsInDummySpanCommand::doUnapply()
         children.append(*child);
 
     for (auto& child : children)
-        m_element->appendChild(WTFMove(child), IGNORE_EXCEPTION);
+        m_element->appendChild(child, IGNORE_EXCEPTION);
 
     m_dummySpan->remove(IGNORE_EXCEPTION);
 }
index e4f94f3..0afcfa8 100644 (file)
@@ -68,7 +68,7 @@ const RenderStyle* Editor::styleForSelectionStart(Frame* frame, Node *&nodeToRem
     if (!parentNode->ensurePreInsertionValidity(styleElement.copyRef(), nullptr, IGNORE_EXCEPTION))
         return nullptr; 
 
-    parentNode->appendChild(styleElement.copyRef(), ASSERT_NO_EXCEPTION);
+    parentNode->appendChild(styleElement, ASSERT_NO_EXCEPTION);
 
     nodeToRemove = styleElement.ptr();
 
index a233517..6735956 100644 (file)
@@ -977,7 +977,7 @@ Ref<Element> createTabSpanElement(Document& document, RefPtr<Node>&& tabTextNode
     if (!tabTextNode)
         tabTextNode = document.createEditingTextNode("\t");
 
-    spanElement->appendChild(tabTextNode.releaseNonNull(), ASSERT_NO_EXCEPTION);
+    spanElement->appendChild(*tabTextNode, ASSERT_NO_EXCEPTION);
 
     return spanElement;
 }
index 578eeb6..1fa145b 100644 (file)
@@ -493,7 +493,7 @@ bool Editor::WebContentReader::readURL(const URL& url, const String&)
         anchor->appendChild(frame.document()->createTextNode([[(NSURL *)url absoluteString] precomposedStringWithCanonicalMapping]));
 
         auto newFragment = frame.document()->createDocumentFragment();
-        newFragment->appendChild(WTFMove(anchor));
+        newFragment->appendChild(anchor);
         addFragment(WTFMove(newFragment));
         return true;
     }
@@ -589,7 +589,7 @@ RefPtr<DocumentFragment> Editor::createFragmentForImageResourceAndAddResource(Re
         loader->addArchiveResource(resource.releaseNonNull());
 
     auto fragment = m_frame.document()->createDocumentFragment();
-    fragment->appendChild(WTFMove(imageElement));
+    fragment->appendChild(imageElement);
 
     return WTFMove(fragment);
 }
index 0836634..733e194 100644 (file)
@@ -521,13 +521,13 @@ bool Editor::WebContentReader::readFilenames(const Vector<String>& paths)
 
     for (auto& text : paths) {
 #if ENABLE(ATTACHMENT_ELEMENT)
-        Ref<HTMLAttachmentElement> attachment = HTMLAttachmentElement::create(attachmentTag, document);
+        auto attachment = HTMLAttachmentElement::create(attachmentTag, document);
         attachment->setFile(File::create([[NSURL fileURLWithPath:text] path]).ptr());
-        fragment->appendChild(WTFMove(attachment));
+        fragment->appendChild(attachment);
 #else
-        Ref<HTMLElement> paragraph = createDefaultParagraphElement(document);
+        auto paragraph = createDefaultParagraphElement(document);
         paragraph->appendChild(document.createTextNode(frame.editor().client()->userVisibleString([NSURL fileURLWithPath:text])));
-        fragment->appendChild(WTFMove(paragraph));
+        fragment->appendChild(paragraph);
 #endif
     }
 
@@ -591,7 +591,7 @@ bool Editor::WebContentReader::readURL(const URL& url, const String& title)
     anchor->appendChild(frame.document()->createTextNode([title precomposedStringWithCanonicalMapping]));
 
     fragment = frame.document()->createDocumentFragment();
-    fragment->appendChild(WTFMove(anchor));
+    fragment->appendChild(anchor);
     return true;
 }
 
@@ -631,7 +631,7 @@ RefPtr<DocumentFragment> Editor::createFragmentForImageResourceAndAddResource(Re
         loader->addArchiveResource(resource.releaseNonNull());
 
     auto fragment = document().createDocumentFragment();
-    fragment->appendChild(WTFMove(imageElement));
+    fragment->appendChild(imageElement);
 
     return WTFMove(fragment);
 }
index 65de8fa..c0c03fd 100644 (file)
@@ -729,7 +729,7 @@ static void fillContainerFromString(ContainerNode& paragraph, const String& stri
                 tabText = emptyString();
             }
             Ref<Node> textNode = document.createTextNode(stringWithRebalancedWhitespace(s, first, i + 1 == numEntries));
-            paragraph.appendChild(WTFMove(textNode), ASSERT_NO_EXCEPTION);
+            paragraph.appendChild(textNode, ASSERT_NO_EXCEPTION);
         }
 
         // there is a tab after every entry, except the last entry
@@ -792,9 +792,9 @@ Ref<DocumentFragment> createFragmentFromText(Range& context, const String& text)
     if (contextPreservesNewline(context)) {
         fragment->appendChild(document.createTextNode(string), ASSERT_NO_EXCEPTION);
         if (string.endsWith('\n')) {
-            Ref<Element> element = createBreakElement(document);
+            auto element = createBreakElement(document);
             element->setAttribute(classAttr, AppleInterchangeNewline);            
-            fragment->appendChild(WTFMove(element), ASSERT_NO_EXCEPTION);
+            fragment->appendChild(element, ASSERT_NO_EXCEPTION);
         }
         return fragment;
     }
@@ -836,7 +836,7 @@ Ref<DocumentFragment> createFragmentFromText(Range& context, const String& text)
                 element = createDefaultParagraphElement(document);
             fillContainerFromString(*element, s);
         }
-        fragment->appendChild(element.releaseNonNull(), ASSERT_NO_EXCEPTION);
+        fragment->appendChild(*element, ASSERT_NO_EXCEPTION);
     }
     return fragment;
 }
@@ -1020,12 +1020,12 @@ void replaceChildrenWithFragment(ContainerNode& container, Ref<DocumentFragment>
             return;
         }
 
-        containerNode->replaceChild(WTFMove(fragment), *containerChild, ec);
+        containerNode->replaceChild(fragment, *containerChild, ec);
         return;
     }
 
     containerNode->removeChildren();
-    containerNode->appendChild(WTFMove(fragment), ec);
+    containerNode->appendChild(fragment, ec);
 }
 
 void replaceChildrenWithText(ContainerNode& container, const String& text, ExceptionCode& ec)
@@ -1038,15 +1038,15 @@ void replaceChildrenWithText(ContainerNode& container, const String& text, Excep
         return;
     }
 
-    Ref<Text> textNode = Text::create(containerNode->document(), text);
+    auto textNode = Text::create(containerNode->document(), text);
 
     if (hasOneChild(containerNode)) {
-        containerNode->replaceChild(WTFMove(textNode), *containerNode->firstChild(), ec);
+        containerNode->replaceChild(textNode, *containerNode->firstChild(), ec);
         return;
     }
 
     containerNode->removeChildren();
-    containerNode->appendChild(WTFMove(textNode), ec);
+    containerNode->appendChild(textNode, ec);
 }
 
 }
index adb0e06..eb5c672 100644 (file)
@@ -61,9 +61,9 @@ void BaseChooserOnlyDateAndTimeInputType::createShadowSubtree()
 {
     static NeverDestroyed<AtomicString> valueContainerPseudo("-webkit-date-and-time-value", AtomicString::ConstructFromLiteral);
 
-    Ref<HTMLDivElement> valueContainer = HTMLDivElement::create(element().document());
+    auto valueContainer = HTMLDivElement::create(element().document());
     valueContainer->setPseudo(valueContainerPseudo);
-    element().userAgentShadowRoot()->appendChild(WTFMove(valueContainer));
+    element().userAgentShadowRoot()->appendChild(valueContainer);
     updateAppearance();
 }
 
index 5a6478c..596aaef 100644 (file)
@@ -110,12 +110,12 @@ void ColorInputType::createShadowSubtree()
     ASSERT(element().shadowRoot());
 
     Document& document = element().document();
-    Ref<HTMLDivElement> wrapperElement = HTMLDivElement::create(document);
+    auto wrapperElement = HTMLDivElement::create(document);
     wrapperElement->setPseudo(AtomicString("-webkit-color-swatch-wrapper", AtomicString::ConstructFromLiteral));
-    Ref<HTMLDivElement> colorSwatch = HTMLDivElement::create(document);
+    auto colorSwatch = HTMLDivElement::create(document);
     colorSwatch->setPseudo(AtomicString("-webkit-color-swatch", AtomicString::ConstructFromLiteral));
-    wrapperElement->appendChild(WTFMove(colorSwatch), ASSERT_NO_EXCEPTION);
-    element().userAgentShadowRoot()->appendChild(WTFMove(wrapperElement), ASSERT_NO_EXCEPTION);
+    wrapperElement->appendChild(colorSwatch, ASSERT_NO_EXCEPTION);
+    element().userAgentShadowRoot()->appendChild(wrapperElement, ASSERT_NO_EXCEPTION);
     
     updateColorSwatch();
 }
index a734c75..47e1aa7 100644 (file)
@@ -104,27 +104,27 @@ void FTPDirectoryDocumentParser::appendEntry(const String& filename, const Strin
     RefPtr<Element> rowElement = m_tableElement->insertRow(-1, IGNORE_EXCEPTION);
     rowElement->setAttribute(HTMLNames::classAttr, "ftpDirectoryEntryRow");
 
-    Ref<Element> typeElement = document()->createElement(tdTag, false);
+    auto typeElement = document()->createElement(tdTag, false);
     typeElement->appendChild(Text::create(*document(), String(&noBreakSpace, 1)), IGNORE_EXCEPTION);
     if (isDirectory)
         typeElement->setAttribute(HTMLNames::classAttr, "ftpDirectoryIcon ftpDirectoryTypeDirectory");
     else
         typeElement->setAttribute(HTMLNames::classAttr, "ftpDirectoryIcon ftpDirectoryTypeFile");
-    rowElement->appendChild(WTFMove(typeElement), IGNORE_EXCEPTION);
+    rowElement->appendChild(typeElement, IGNORE_EXCEPTION);
 
-    Ref<Element> nameElement = createTDForFilename(filename);
+    auto nameElement = createTDForFilename(filename);
     nameElement->setAttribute(HTMLNames::classAttr, "ftpDirectoryFileName");
-    rowElement->appendChild(WTFMove(nameElement), IGNORE_EXCEPTION);
+    rowElement->appendChild(nameElement, IGNORE_EXCEPTION);
 
-    Ref<Element> dateElement = document()->createElement(tdTag, false);
+    auto dateElement = document()->createElement(tdTag, false);
     dateElement->appendChild(Text::create(*document(), date), IGNORE_EXCEPTION);
     dateElement->setAttribute(HTMLNames::classAttr, "ftpDirectoryFileDate");
-    rowElement->appendChild(WTFMove(dateElement), IGNORE_EXCEPTION);
+    rowElement->appendChild(dateElement, IGNORE_EXCEPTION);
 
-    Ref<Element> sizeElement = document()->createElement(tdTag, false);
+    auto sizeElement = document()->createElement(tdTag, false);
     sizeElement->appendChild(Text::create(*document(), size), IGNORE_EXCEPTION);
     sizeElement->setAttribute(HTMLNames::classAttr, "ftpDirectoryFileSize");
-    rowElement->appendChild(WTFMove(sizeElement), IGNORE_EXCEPTION);
+    rowElement->appendChild(sizeElement, IGNORE_EXCEPTION);
 }
 
 Ref<Element> FTPDirectoryDocumentParser::createTDForFilename(const String& filename)
@@ -135,12 +135,12 @@ Ref<Element> FTPDirectoryDocumentParser::createTDForFilename(const String& filen
     else
         fullURL = fullURL + '/' + filename;
 
-    Ref<Element> anchorElement = document()->createElement(aTag, false);
+    auto anchorElement = document()->createElement(aTag, false);
     anchorElement->setAttribute(HTMLNames::hrefAttr, fullURL);
     anchorElement->appendChild(Text::create(*document(), filename), IGNORE_EXCEPTION);
 
     Ref<Element> tdElement = document()->createElement(tdTag, false);
-    tdElement->appendChild(WTFMove(anchorElement), IGNORE_EXCEPTION);
+    tdElement->appendChild(anchorElement, IGNORE_EXCEPTION);
 
     return tdElement;
 }
@@ -327,14 +327,14 @@ void FTPDirectoryDocumentParser::createBasicDocument()
 
     Ref<Element> bodyElement = document()->createElement(bodyTag, false);
 
-    document()->appendChild(bodyElement.copyRef(), IGNORE_EXCEPTION);
+    document()->appendChild(bodyElement, IGNORE_EXCEPTION);
 
-    Ref<Element> tableElement = document()->createElement(tableTag, false);
+    auto tableElement = document()->createElement(tableTag, false);
     m_tableElement = downcast<HTMLTableElement>(tableElement.ptr());
     m_tableElement->setAttribute(HTMLNames::idAttr, "ftpDirectoryTable");
     m_tableElement->setAttribute(HTMLNames::styleAttr, "width:100%");
 
-    bodyElement->appendChild(WTFMove(tableElement), IGNORE_EXCEPTION);
+    bodyElement->appendChild(tableElement, IGNORE_EXCEPTION);
 
     document()->processViewport("width=device-width", ViewportArguments::ViewportMeta);
 }
index cf41a47..77e6456 100644 (file)
@@ -102,8 +102,8 @@ void HTMLDetailsElement::didAddUserAgentShadowRoot(ShadowRoot* root)
     defaultSummary->appendChild(Text::create(document(), defaultDetailsSummaryText()), ASSERT_NO_EXCEPTION);
     m_defaultSummary = defaultSummary.ptr();
 
-    summarySlot->appendChild(WTFMove(defaultSummary));
-    root->appendChild(WTFMove(summarySlot));
+    summarySlot->appendChild(defaultSummary);
+    root->appendChild(summarySlot);
 
     m_defaultSlot = HTMLSlotElement::create(slotTag, document());
     ASSERT(!m_isOpen);
index 18818e3..39ec871 100644 (file)
@@ -621,7 +621,7 @@ void HTMLElement::setOuterText(const String& text, ExceptionCode& ec)
         ec = HIERARCHY_REQUEST_ERR;
     if (ec)
         return;
-    parent->replaceChild(newChild.releaseNonNull(), *this, ec);
+    parent->replaceChild(*newChild, *this, ec);
 
     RefPtr<Node> node = next ? next->previousSibling() : nullptr;
     if (!ec && is<Text>(node.get()))
@@ -641,18 +641,18 @@ Node* HTMLElement::insertAdjacent(const String& where, Ref<Node>&& newChild, Exc
 
     if (equalLettersIgnoringASCIICase(where, "beforebegin")) {
         ContainerNode* parent = this->parentNode();
-        return (parent && parent->insertBefore(newChild.copyRef(), this, ec)) ? newChild.ptr() : nullptr;
+        return (parent && parent->insertBefore(newChild, this, ec)) ? newChild.ptr() : nullptr;
     }
 
     if (equalLettersIgnoringASCIICase(where, "afterbegin"))
-        return insertBefore(newChild.copyRef(), firstChild(), ec) ? newChild.ptr() : nullptr;
+        return insertBefore(newChild, firstChild(), ec) ? newChild.ptr() : nullptr;
 
     if (equalLettersIgnoringASCIICase(where, "beforeend"))
-        return appendChild(newChild.copyRef(), ec) ? newChild.ptr() : nullptr;
+        return appendChild(newChild, ec) ? newChild.ptr() : nullptr;
 
     if (equalLettersIgnoringASCIICase(where, "afterend")) {
         ContainerNode* parent = this->parentNode();
-        return (parent && parent->insertBefore(newChild.copyRef(), nextSibling(), ec)) ? newChild.ptr() : nullptr;
+        return (parent && parent->insertBefore(newChild, nextSibling(), ec)) ? newChild.ptr() : nullptr;
     }
     
     // IE throws COM Exception E_INVALIDARG; this is the best DOM exception alternative.
index 8054458..01693f0 100644 (file)
@@ -604,7 +604,7 @@ void HTMLImageElement::tryCreateImageControls()
     if (!imageControls)
         return;
 
-    ensureUserAgentShadowRoot().appendChild(imageControls.releaseNonNull());
+    ensureUserAgentShadowRoot().appendChild(*imageControls);
 
     auto* renderObject = renderer();
     if (!renderObject)
index f61c99b..6a215f7 100644 (file)
@@ -74,14 +74,14 @@ inline HTMLKeygenElement::HTMLKeygenElement(const QualifiedName& tagName, Docume
     Vector<String> keys;
     getSupportedKeySizes(keys);
 
-    Ref<HTMLSelectElement> select = KeygenSelectElement::create(document);
+    auto select = KeygenSelectElement::create(document);
     for (auto& key : keys) {
-        Ref<HTMLOptionElement> option = HTMLOptionElement::create(document);
-        select->appendChild(option.copyRef(), IGNORE_EXCEPTION);
+        auto option = HTMLOptionElement::create(document);
+        select->appendChild(option, IGNORE_EXCEPTION);
         option->appendChild(Text::create(document, key), IGNORE_EXCEPTION);
     }
 
-    ensureUserAgentShadowRoot().appendChild(WTFMove(select), IGNORE_EXCEPTION);
+    ensureUserAgentShadowRoot().appendChild(select, IGNORE_EXCEPTION);
 }
 
 Ref<HTMLKeygenElement> HTMLKeygenElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form)
index 185c995..5f6019d 100644 (file)
@@ -229,16 +229,16 @@ void HTMLMeterElement::didAddUserAgentShadowRoot(ShadowRoot* root)
 {
     ASSERT(!m_value);
 
-    Ref<MeterInnerElement> inner = MeterInnerElement::create(document());
-    root->appendChild(inner.copyRef());
+    auto inner = MeterInnerElement::create(document());
+    root->appendChild(inner);
 
-    Ref<MeterBarElement> bar = MeterBarElement::create(document());
+    auto bar = MeterBarElement::create(document());
     m_value = MeterValueElement::create(document());
     m_value->setWidthPercentage(0);
     m_value->updatePseudo();
     bar->appendChild(*m_value, ASSERT_NO_EXCEPTION);
 
-    inner->appendChild(WTFMove(bar), ASSERT_NO_EXCEPTION);
+    inner->appendChild(bar, ASSERT_NO_EXCEPTION);
 }
 
 } // namespace
index 89c30fd..343ad41 100644 (file)
@@ -69,12 +69,12 @@ Ref<HTMLOptionElement> HTMLOptionElement::create(const QualifiedName& tagName, D
 RefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document& document, const String& data, const String& value,
         bool defaultSelected, bool selected, ExceptionCode& ec)
 {
-    RefPtr<HTMLOptionElement> element = adoptRef(new HTMLOptionElement(optionTag, document));
+    Ref<HTMLOptionElement> element = adoptRef(*new HTMLOptionElement(optionTag, document));
 
-    Ref<Text> text = Text::create(document, data.isNull() ? "" : data);
+    auto text = Text::create(document, data.isNull() ? emptyString() : data);
 
     ec = 0;
-    element->appendChild(WTFMove(text), ec);
+    element->appendChild(text, ec);
     if (ec)
         return nullptr;
 
@@ -84,7 +84,7 @@ RefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document& do
         element->setAttribute(selectedAttr, emptyAtom);
     element->setSelected(selected);
 
-    return element;
+    return WTFMove(element);
 }
 
 bool HTMLOptionElement::isFocusable() const
index 45005f3..354b827 100644 (file)
@@ -149,16 +149,16 @@ void HTMLProgressElement::didAddUserAgentShadowRoot(ShadowRoot* root)
 {
     ASSERT(!m_value);
 
-    Ref<ProgressInnerElement> inner = ProgressInnerElement::create(document());
-    root->appendChild(inner.copyRef());
+    auto inner = ProgressInnerElement::create(document());
+    root->appendChild(inner);
 
-    Ref<ProgressBarElement> bar = ProgressBarElement::create(document());
-    Ref<ProgressValueElement> value = ProgressValueElement::create(document());
+    auto bar = ProgressBarElement::create(document());
+    auto value = ProgressValueElement::create(document());
     m_value = value.ptr();
     m_value->setWidthPercentage(HTMLProgressElement::IndeterminatePosition * 100);
-    bar->appendChild(*m_value, ASSERT_NO_EXCEPTION);
+    bar->appendChild(value, ASSERT_NO_EXCEPTION);
 
-    inner->appendChild(WTFMove(bar), ASSERT_NO_EXCEPTION);
+    inner->appendChild(bar, ASSERT_NO_EXCEPTION);
 }
 
 bool HTMLProgressElement::shouldAppearIndeterminate() const
index a8ba1e8..7490d9a 100644 (file)
@@ -176,7 +176,7 @@ Ref<HTMLTableSectionElement> HTMLTableElement::createTBody()
 {
     Ref<HTMLTableSectionElement> body = HTMLTableSectionElement::create(tbodyTag, document());
     Node* referenceElement = lastBody() ? lastBody()->nextSibling() : nullptr;
-    insertBefore(body.copyRef(), referenceElement, ASSERT_NO_EXCEPTION);
+    insertBefore(body, referenceElement, ASSERT_NO_EXCEPTION);
     return body;
 }
 
@@ -237,16 +237,16 @@ RefPtr<HTMLElement> HTMLTableElement::insertRow(int index, ExceptionCode& ec)
     else {
         parent = lastBody();
         if (!parent) {
-            Ref<HTMLTableSectionElement> newBody = HTMLTableSectionElement::create(tbodyTag, document());
-            Ref<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
-            newBody->appendChild(newRow.copyRef(), ec);
-            appendChild(WTFMove(newBody), ec);
+            auto newBody = HTMLTableSectionElement::create(tbodyTag, document());
+            auto newRow = HTMLTableRowElement::create(document());
+            newBody->appendChild(newRow, ec);
+            appendChild(newBody, ec);
             return WTFMove(newRow);
         }
     }
 
-    Ref<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
-    parent->insertBefore(newRow.copyRef(), row.get(), ec);
+    auto newRow = HTMLTableRowElement::create(document());
+    parent->insertBefore(newRow, row.get(), ec);
     return WTFMove(newRow);
 }
 
index 766bd0c..85ae63a 100644 (file)
@@ -114,14 +114,14 @@ RefPtr<HTMLTableCellElement> HTMLTableRowElement::insertCell(int index, Exceptio
 
     auto cell = HTMLTableDataCellElement::create(document());
     if (index < 0 || index >= numCells)
-        appendChild(cell.copyRef(), ec);
+        appendChild(cell, ec);
     else {
         Node* n;
         if (index < 1)
             n = firstChild();
         else
             n = children->item(index);
-        insertBefore(cell.copyRef(), n, ec);
+        insertBefore(cell, n, ec);
     }
     return WTFMove(cell);
 }
index bf3c148..2f35b29 100644 (file)
@@ -210,19 +210,19 @@ Ref<DocumentParser> ImageDocument::createParser()
 
 void ImageDocument::createDocumentStructure()
 {
-    Ref<Element> rootElement = Document::createElement(htmlTag, false);
-    appendChild(rootElement.copyRef());
+    auto rootElement = Document::createElement(htmlTag, false);
+    appendChild(rootElement);
     downcast<HTMLHtmlElement>(rootElement.get()).insertedByParser();
 
     frame()->injectUserScripts(InjectAtDocumentStart);
 
-    Ref<Element> body = Document::createElement(bodyTag, false);
+    auto body = Document::createElement(bodyTag, false);
     body->setAttribute(styleAttr, "margin: 0px");
     if (MIMETypeRegistry::isPDFMIMEType(document().loader()->responseMIMEType()))
         downcast<HTMLBodyElement>(body.get()).setInlineStyleProperty(CSSPropertyBackgroundColor, "white", CSSPrimitiveValue::CSS_IDENT);
-    rootElement->appendChild(body.copyRef());
+    rootElement->appendChild(body);
     
-    Ref<ImageDocumentElement> imageElement = ImageDocumentElement::create(*this);
+    auto imageElement = ImageDocumentElement::create(*this);
     if (m_shouldShrinkImage)
         imageElement->setAttribute(styleAttr, "-webkit-user-select:none; display:block; margin:auto;");
     else
@@ -230,7 +230,7 @@ void ImageDocument::createDocumentStructure()
     imageElement->setLoadManually(true);
     imageElement->setSrc(url().string());
     imageElement->cachedImage()->setResponse(loader()->response());
-    body->appendChild(imageElement.copyRef());
+    body->appendChild(imageElement);
     
     if (m_shouldShrinkImage) {
 #if PLATFORM(IOS)
index 8bb1628..08259ca 100644 (file)
@@ -78,8 +78,8 @@ private:
     
 void MediaDocumentParser::createDocumentStructure()
 {
-    Ref<Element> rootElement = document()->createElement(htmlTag, false);
-    document()->appendChild(rootElement.copyRef(), IGNORE_EXCEPTION);
+    auto rootElement = document()->createElement(htmlTag, false);
+    document()->appendChild(rootElement, IGNORE_EXCEPTION);
     document()->setCSSTarget(rootElement.ptr());
     downcast<HTMLHtmlElement>(rootElement.get()).insertedByParser();
 
@@ -87,19 +87,19 @@ void MediaDocumentParser::createDocumentStructure()
         document()->frame()->injectUserScripts(InjectAtDocumentStart);
 
 #if PLATFORM(IOS)
-    Ref<Element> headElement = document()->createElement(headTag, false);
-    rootElement->appendChild(headElement.copyRef(), IGNORE_EXCEPTION);
+    auto headElement = document()->createElement(headTag, false);
+    rootElement->appendChild(headElement, IGNORE_EXCEPTION);
 
-    Ref<Element> metaElement = document()->createElement(metaTag, false);
+    auto metaElement = document()->createElement(metaTag, false);
     metaElement->setAttribute(nameAttr, "viewport");
     metaElement->setAttribute(contentAttr, "width=device-width,initial-scale=1,user-scalable=no");
-    headElement->appendChild(WTFMove(metaElement), IGNORE_EXCEPTION);
+    headElement->appendChild(metaElement, IGNORE_EXCEPTION);
 #endif
 
-    Ref<Element> body = document()->createElement(bodyTag, false);
-    rootElement->appendChild(body.copyRef(), IGNORE_EXCEPTION);
+    auto body = document()->createElement(bodyTag, false);
+    rootElement->appendChild(body, IGNORE_EXCEPTION);
 
-    Ref<Element> mediaElement = document()->createElement(videoTag, false);
+    auto mediaElement = document()->createElement(videoTag, false);
 
     m_mediaElement = downcast<HTMLVideoElement>(mediaElement.ptr());
     m_mediaElement->setAttribute(controlsAttr, emptyAtom);
@@ -114,15 +114,15 @@ void MediaDocumentParser::createDocumentStructure()
 #endif
     m_mediaElement->setAttribute(styleAttr, elementStyle.toString());
 
-    Ref<Element> sourceElement = document()->createElement(sourceTag, false);
+    auto sourceElement = document()->createElement(sourceTag, false);
     HTMLSourceElement& source = downcast<HTMLSourceElement>(sourceElement.get());
     source.setSrc(document()->url());
 
     if (DocumentLoader* loader = document()->loader())
         source.setType(loader->responseMIMEType());
 
-    m_mediaElement->appendChild(WTFMove(sourceElement), IGNORE_EXCEPTION);
-    body->appendChild(WTFMove(mediaElement), IGNORE_EXCEPTION);
+    m_mediaElement->appendChild(sourceElement, IGNORE_EXCEPTION);
+    body->appendChild(mediaElement, IGNORE_EXCEPTION);
 
     Frame* frame = document()->frame();
     if (!frame)
index 1807d9e..5f512ea 100644 (file)
@@ -67,8 +67,8 @@ private:
 
 void PluginDocumentParser::createDocumentStructure()
 {
-    Ref<Element> rootElement = document()->createElement(htmlTag, false);
-    document()->appendChild(rootElement.copyRef(), IGNORE_EXCEPTION);
+    auto rootElement = document()->createElement(htmlTag, false);
+    document()->appendChild(rootElement, IGNORE_EXCEPTION);
     downcast<HTMLHtmlElement>(rootElement.get()).insertedByParser();
 
     if (document()->frame())
@@ -79,7 +79,7 @@ void PluginDocumentParser::createDocumentStructure()
     document()->processViewport(ASCIILiteral("user-scalable=no"), ViewportArguments::PluginDocument);
 #endif
 
-    Ref<Element> body = document()->createElement(bodyTag, false);
+    auto body = document()->createElement(bodyTag, false);
     body->setAttribute(marginwidthAttr, AtomicString("0", AtomicString::ConstructFromLiteral));
     body->setAttribute(marginheightAttr, AtomicString("0", AtomicString::ConstructFromLiteral));
 #if PLATFORM(IOS)
@@ -88,9 +88,9 @@ void PluginDocumentParser::createDocumentStructure()
     body->setAttribute(styleAttr, AtomicString("background-color: rgb(38,38,38)", AtomicString::ConstructFromLiteral));
 #endif
 
-    rootElement->appendChild(body.copyRef(), IGNORE_EXCEPTION);
+    rootElement->appendChild(body, IGNORE_EXCEPTION);
         
-    Ref<Element> embedElement = document()->createElement(embedTag, false);
+    auto embedElement = document()->createElement(embedTag, false);
         
     m_embedElement = downcast<HTMLEmbedElement>(embedElement.ptr());
     m_embedElement->setAttribute(widthAttr, "100%");
@@ -106,7 +106,7 @@ void PluginDocumentParser::createDocumentStructure()
 
     downcast<PluginDocument>(*document()).setPluginElement(m_embedElement);
 
-    body->appendChild(WTFMove(embedElement), IGNORE_EXCEPTION);
+    body->appendChild(embedElement, IGNORE_EXCEPTION);
 }
 
 void PluginDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
index 34cf913..c8044b1 100644 (file)
@@ -254,12 +254,12 @@ void RangeInputType::createShadowSubtree()
     ASSERT(element().userAgentShadowRoot());
 
     Document& document = element().document();
-    Ref<HTMLDivElement> track = HTMLDivElement::create(document);
+    auto track = HTMLDivElement::create(document);
     track->setPseudo(AtomicString("-webkit-slider-runnable-track", AtomicString::ConstructFromLiteral));
     track->appendChild(SliderThumbElement::create(document), IGNORE_EXCEPTION);
-    Ref<HTMLElement> container = SliderContainerElement::create(document);
-    container->appendChild(WTFMove(track), IGNORE_EXCEPTION);
-    element().userAgentShadowRoot()->appendChild(WTFMove(container), IGNORE_EXCEPTION);
+    auto container = SliderContainerElement::create(document);
+    container->appendChild(track, IGNORE_EXCEPTION);
+    element().userAgentShadowRoot()->appendChild(container, IGNORE_EXCEPTION);
 }
 
 HTMLElement* RangeInputType::sliderTrackElement() const
index 7acd28e..87d4181 100644 (file)
@@ -107,14 +107,14 @@ void SearchInputType::createShadowSubtree()
     ASSERT(container);
     ASSERT(textWrapper);
 
-    Ref<SearchFieldResultsButtonElement> resultsButton = SearchFieldResultsButtonElement::create(element().document());
+    auto resultsButton = SearchFieldResultsButtonElement::create(element().document());
     m_resultsButton = resultsButton.ptr();
     updateResultButtonPseudoType(resultsButton.get(), element().maxResults());
-    container->insertBefore(WTFMove(resultsButton), textWrapper, IGNORE_EXCEPTION);
+    container->insertBefore(resultsButton, textWrapper, IGNORE_EXCEPTION);
 
-    Ref<SearchFieldCancelButtonElement> cancelButton = SearchFieldCancelButtonElement::create(element().document());
+    auto cancelButton = SearchFieldCancelButtonElement::create(element().document());
     m_cancelButton = cancelButton.ptr();
-    container->insertBefore(WTFMove(cancelButton), textWrapper->nextSibling(), IGNORE_EXCEPTION);
+    container->insertBefore(cancelButton, textWrapper->nextSibling(), IGNORE_EXCEPTION);
 }
 
 HTMLElement* SearchInputType::resultsButtonElement() const
index c7575bf..6079f9d 100644 (file)
@@ -184,19 +184,19 @@ void ValidationMessage::buildBubbleTree()
     document.updateLayout();
     adjustBubblePosition(m_element->renderer()->absoluteBoundingBoxRect(), m_bubble.get());
 
-    Ref<HTMLDivElement> clipper = HTMLDivElement::create(document);
+    auto clipper = HTMLDivElement::create(document);
     clipper->setPseudo(AtomicString("-webkit-validation-bubble-arrow-clipper", AtomicString::ConstructFromLiteral));
-    Ref<HTMLDivElement> bubbleArrow = HTMLDivElement::create(document);
+    auto bubbleArrow = HTMLDivElement::create(document);
     bubbleArrow->setPseudo(AtomicString("-webkit-validation-bubble-arrow", AtomicString::ConstructFromLiteral));
-    clipper->appendChild(WTFMove(bubbleArrow), ASSERT_NO_EXCEPTION);
-    m_bubble->appendChild(WTFMove(clipper), ASSERT_NO_EXCEPTION);
+    clipper->appendChild(bubbleArrow, ASSERT_NO_EXCEPTION);
+    m_bubble->appendChild(clipper, ASSERT_NO_EXCEPTION);
 
-    Ref<HTMLElement> message = HTMLDivElement::create(document);
+    auto message = HTMLDivElement::create(document);
     message->setPseudo(AtomicString("-webkit-validation-bubble-message", AtomicString::ConstructFromLiteral));
-    Ref<HTMLElement> icon = HTMLDivElement::create(document);
+    auto icon = HTMLDivElement::create(document);
     icon->setPseudo(AtomicString("-webkit-validation-bubble-icon", AtomicString::ConstructFromLiteral));
-    message->appendChild(WTFMove(icon), ASSERT_NO_EXCEPTION);
-    Ref<HTMLElement> textBlock = HTMLDivElement::create(document);
+    message->appendChild(icon, ASSERT_NO_EXCEPTION);
+    auto textBlock = HTMLDivElement::create(document);
     textBlock->setPseudo(AtomicString("-webkit-validation-bubble-text-block", AtomicString::ConstructFromLiteral));
     m_messageHeading = HTMLDivElement::create(document);
     m_messageHeading->setPseudo(AtomicString("-webkit-validation-bubble-heading", AtomicString::ConstructFromLiteral));
@@ -204,8 +204,8 @@ void ValidationMessage::buildBubbleTree()
     m_messageBody = HTMLDivElement::create(document);
     m_messageBody->setPseudo(AtomicString("-webkit-validation-bubble-body", AtomicString::ConstructFromLiteral));
     textBlock->appendChild(*m_messageBody, ASSERT_NO_EXCEPTION);
-    message->appendChild(WTFMove(textBlock), ASSERT_NO_EXCEPTION);
-    m_bubble->appendChild(WTFMove(message), ASSERT_NO_EXCEPTION);
+    message->appendChild(textBlock, ASSERT_NO_EXCEPTION);
+    m_bubble->appendChild(message, ASSERT_NO_EXCEPTION);
 
     setMessageDOMAndStartTimer();
 
index dc43e2c..c9f4a49 100644 (file)
@@ -805,20 +805,20 @@ void MediaControlClosedCaptionsTrackListElement::rebuildTrackListMenu()
     auto& captionPreferences = document().page()->group().captionPreferences();
     Vector<RefPtr<TextTrack>> tracksForMenu = captionPreferences.sortedTrackListForMenu(trackList);
 
-    Ref<Element> captionsHeader = document().createElement(h3Tag, ASSERT_NO_EXCEPTION);
+    auto captionsHeader = document().createElement(h3Tag, ASSERT_NO_EXCEPTION);
     captionsHeader->appendChild(document().createTextNode(textTrackSubtitlesText()));
-    appendChild(WTFMove(captionsHeader));
-    Ref<Element> captionsMenuList = document().createElement(ulTag, ASSERT_NO_EXCEPTION);
+    appendChild(captionsHeader);
+    auto captionsMenuList = document().createElement(ulTag, ASSERT_NO_EXCEPTION);
 
     for (auto& textTrack : tracksForMenu) {
-        Ref<Element> menuItem = document().createElement(liTag, ASSERT_NO_EXCEPTION);
+        auto menuItem = document().createElement(liTag, ASSERT_NO_EXCEPTION);
         menuItem->appendChild(document().createTextNode(captionPreferences.displayNameForTrack(textTrack.get())));
-        captionsMenuList->appendChild(menuItem.copyRef());
+        captionsMenuList->appendChild(menuItem);
         m_menuItems.append(menuItem.ptr());
         m_menuToTrackMap.add(menuItem.ptr(), textTrack);
     }
 
-    appendChild(WTFMove(captionsMenuList));
+    appendChild(captionsMenuList);
 #endif
 }
 
index 0ff0e81..6ffb710 100644 (file)
@@ -380,14 +380,14 @@ void MediaControls::createTextTrackDisplay()
     if (m_textDisplayContainer)
         return;
 
-    Ref<MediaControlTextTrackContainerElement> textDisplayContainer = MediaControlTextTrackContainerElement::create(document());
+    auto textDisplayContainer = MediaControlTextTrackContainerElement::create(document());
     m_textDisplayContainer = textDisplayContainer.ptr();
 
     if (m_mediaController)
         m_textDisplayContainer->setMediaController(m_mediaController);
 
     // Insert it before the first controller element so it always displays behind the controls.
-    insertBefore(WTFMove(textDisplayContainer), m_panel, IGNORE_EXCEPTION);
+    insertBefore(textDisplayContainer, m_panel, IGNORE_EXCEPTION);
 }
 
 void MediaControls::showTextTrackDisplay()
index e00bd10..cf7ac4b 100644 (file)
@@ -73,26 +73,26 @@ RefPtr<MediaControlsApple> MediaControlsApple::tryCreateControls(Document& docum
 
     auto rewindButton = MediaControlRewindButtonElement::create(document);
     controls->m_rewindButton = rewindButton.ptr();
-    panel->appendChild(WTFMove(rewindButton), ec);
+    panel->appendChild(rewindButton, ec);
     if (ec)
         return nullptr;
 
     auto playButton = MediaControlPlayButtonElement::create(document);
     controls->m_playButton = playButton.ptr();
-    panel->appendChild(WTFMove(playButton), ec);
+    panel->appendChild(playButton, ec);
     if (ec)
         return nullptr;
 
     auto returnToRealtimeButton = MediaControlReturnToRealtimeButtonElement::create(document);
     controls->m_returnToRealTimeButton = returnToRealtimeButton.ptr();
-    panel->appendChild(WTFMove(returnToRealtimeButton), ec);
+    panel->appendChild(returnToRealtimeButton, ec);
     if (ec)
         return nullptr;
 
     if (document.page()->theme().usesMediaControlStatusDisplay()) {
         auto statusDisplay = MediaControlStatusDisplayElement::create(document);
         controls->m_statusDisplay = statusDisplay.ptr();
-        panel->appendChild(WTFMove(statusDisplay), ec);
+        panel->appendChild(statusDisplay, ec);
         if (ec)
             return nullptr;
     }
@@ -101,38 +101,38 @@ RefPtr<MediaControlsApple> MediaControlsApple::tryCreateControls(Document& docum
 
     auto currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(document);
     controls->m_currentTimeDisplay = currentTimeDisplay.ptr();
-    timelineContainer->appendChild(WTFMove(currentTimeDisplay), ec);
+    timelineContainer->appendChild(currentTimeDisplay, ec);
     if (ec)
         return nullptr;
 
     auto timeline = MediaControlTimelineElement::create(document, controls.ptr());
     controls->m_timeline = timeline.ptr();
-    timelineContainer->appendChild(WTFMove(timeline), ec);
+    timelineContainer->appendChild(timeline, ec);
     if (ec)
         return nullptr;
 
     auto timeRemainingDisplay = MediaControlTimeRemainingDisplayElement::create(document);
     controls->m_timeRemainingDisplay = timeRemainingDisplay.ptr();
-    timelineContainer->appendChild(WTFMove(timeRemainingDisplay), ec);
+    timelineContainer->appendChild(timeRemainingDisplay, ec);
     if (ec)
         return nullptr;
 
     controls->m_timelineContainer = timelineContainer.ptr();
-    panel->appendChild(WTFMove(timelineContainer), ec);
+    panel->appendChild(timelineContainer, ec);
     if (ec)
         return nullptr;
 
     // FIXME: Only create when needed <http://webkit.org/b/57163>
     auto seekBackButton = MediaControlSeekBackButtonElement::create(document);
     controls->m_seekBackButton = seekBackButton.ptr();
-    panel->appendChild(WTFMove(seekBackButton), ec);
+    panel->appendChild(seekBackButton, ec);
     if (ec)
         return nullptr;
 
     // FIXME: Only create when needed <http://webkit.org/b/57163>
     auto seekForwardButton = MediaControlSeekForwardButtonElement::create(document);
     controls->m_seekForwardButton = seekForwardButton.ptr();
-    panel->appendChild(WTFMove(seekForwardButton), ec);
+    panel->appendChild(seekForwardButton, ec);
     if (ec)
         return nullptr;
 
@@ -141,18 +141,18 @@ RefPtr<MediaControlsApple> MediaControlsApple::tryCreateControls(Document& docum
 
         auto closedCaptionsTrackList = MediaControlClosedCaptionsTrackListElement::create(document, controls.ptr());
         controls->m_closedCaptionsTrackList = closedCaptionsTrackList.ptr();
-        closedCaptionsContainer->appendChild(WTFMove(closedCaptionsTrackList), ec);
+        closedCaptionsContainer->appendChild(closedCaptionsTrackList, ec);
         if (ec)
             return nullptr;
 
         auto toggleClosedCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(document, controls.ptr());
         controls->m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.ptr();
-        panel->appendChild(WTFMove(toggleClosedCaptionsButton), ec);
+        panel->appendChild(toggleClosedCaptionsButton, ec);
         if (ec)
             return nullptr;
 
         controls->m_closedCaptionsContainer = closedCaptionsContainer.ptr();
-        controls->appendChild(WTFMove(closedCaptionsContainer), ec);
+        controls->appendChild(closedCaptionsContainer, ec);
         if (ec)
             return nullptr;
     }
@@ -160,7 +160,7 @@ RefPtr<MediaControlsApple> MediaControlsApple::tryCreateControls(Document& docum
     // FIXME: Only create when needed <http://webkit.org/b/57163>
     auto fullScreenButton = MediaControlFullscreenButtonElement::create(document);
     controls->m_fullScreenButton = fullScreenButton.ptr();
-    panel->appendChild(WTFMove(fullScreenButton), ec);
+    panel->appendChild(fullScreenButton, ec);
 
     // The mute button and the slider element should be in the same div.
     auto panelVolumeControlContainer = HTMLDivElement::create(document);
@@ -170,7 +170,7 @@ RefPtr<MediaControlsApple> MediaControlsApple::tryCreateControls(Document& docum
 
         auto slider = MediaControlPanelVolumeSliderElement::create(document);
         controls->m_volumeSlider = slider.ptr();
-        volumeSliderContainer->appendChild(WTFMove(slider), ec);
+        volumeSliderContainer->appendChild(slider, ec);
         if (ec)
             return nullptr;
 
@@ -178,48 +178,48 @@ RefPtr<MediaControlsApple> MediaControlsApple::tryCreateControls(Document& docum
         // It's important only when the volume bar is displayed below the controls.
         auto volumeSliderMuteButton = MediaControlVolumeSliderMuteButtonElement::create(document);
         controls->m_volumeSliderMuteButton = volumeSliderMuteButton.ptr();
-        volumeSliderContainer->appendChild(WTFMove(volumeSliderMuteButton), ec);
+        volumeSliderContainer->appendChild(volumeSliderMuteButton, ec);
 
         if (ec)
             return nullptr;
 
         controls->m_volumeSliderContainer = volumeSliderContainer.ptr();
-        panelVolumeControlContainer->appendChild(WTFMove(volumeSliderContainer), ec);
+        panelVolumeControlContainer->appendChild(volumeSliderContainer, ec);
         if (ec)
             return nullptr;
     }
 
     auto panelMuteButton = MediaControlPanelMuteButtonElement::create(document, controls.ptr());
     controls->m_panelMuteButton = panelMuteButton.ptr();
-    panelVolumeControlContainer->appendChild(WTFMove(panelMuteButton), ec);
+    panelVolumeControlContainer->appendChild(panelMuteButton, ec);
     if (ec)
         return nullptr;
 
-    panel->appendChild(WTFMove(panelVolumeControlContainer), ec);
+    panel->appendChild(panelVolumeControlContainer, ec);
     if (ec)
         return nullptr;
 
     // FIXME: Only create when needed <http://webkit.org/b/57163>
     auto fullScreenMinVolumeButton = MediaControlFullscreenVolumeMinButtonElement::create(document);
     controls->m_fullScreenMinVolumeButton = fullScreenMinVolumeButton.ptr();
-    panel->appendChild(WTFMove(fullScreenMinVolumeButton), ec);
+    panel->appendChild(fullScreenMinVolumeButton, ec);
     if (ec)
         return nullptr;
 
     auto fullScreenVolumeSlider = MediaControlFullscreenVolumeSliderElement::create(document);
     controls->m_fullScreenVolumeSlider = fullScreenVolumeSlider.ptr();
-    panel->appendChild(WTFMove(fullScreenVolumeSlider), ec);
+    panel->appendChild(fullScreenVolumeSlider, ec);
     if (ec)
         return nullptr;
 
     auto fullScreenMaxVolumeButton = MediaControlFullscreenVolumeMaxButtonElement::create(document);
     controls->m_fullScreenMaxVolumeButton = fullScreenMaxVolumeButton.ptr();
-    panel->appendChild(WTFMove(fullScreenMaxVolumeButton), ec);
+    panel->appendChild(fullScreenMaxVolumeButton, ec);
     if (ec)
         return nullptr;
 
     controls->m_panel = panel.ptr();
-    controls->appendChild(WTFMove(panel), ec);
+    controls->appendChild(panel, ec);
     if (ec)
         return nullptr;
 
index 9c9d6e6..dc5e8c3 100644 (file)
@@ -89,7 +89,7 @@ RefPtr<ImageControlsRootElement> ImageControlsRootElement::tryCreate(Document& d
     controls->setAttribute(HTMLNames::classAttr, "x-webkit-image-controls");
 
     if (RefPtr<ImageControlsButtonElementMac> button = ImageControlsButtonElementMac::tryCreate(document))
-        controls->appendChild(button.releaseNonNull());
+        controls->appendChild(*button);
 
     return WTFMove(controls);
 }
index 32f930b..6aaa702 100644 (file)
@@ -784,7 +784,7 @@ void VTTCue::updateDisplayTree(const MediaTime& movieTime)
         return;
 
     markFutureAndPastNodes(referenceTree.get(), startMediaTime(), movieTime);
-    m_cueHighlightBox->appendChild(referenceTree.releaseNonNull());
+    m_cueHighlightBox->appendChild(*referenceTree);
 }
 
 VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize)
index 22238bc..fff0456 100644 (file)
@@ -536,8 +536,7 @@ void WebVTTTreeBuilder::constructTreeFromToken(Document& document)
 
     switch (m_token.type()) {
     case WebVTTTokenTypes::Character: {
-        auto child = Text::create(document, m_token.characters());
-        m_currentNode->parserAppendChild(WTFMove(child));
+        m_currentNode->parserAppendChild(Text::create(document, m_token.characters()));
         break;
     }
     case WebVTTTokenTypes::StartTag: {
@@ -562,7 +561,7 @@ void WebVTTTreeBuilder::constructTreeFromToken(Document& document)
         }
         if (!m_languageStack.isEmpty())
             child->setLanguage(m_languageStack.last());
-        m_currentNode->parserAppendChild(child.copyRef());
+        m_currentNode->parserAppendChild(child);
         m_currentNode = WTFMove(child);
         break;
     }
index efea696..e69ab1f 100644 (file)
@@ -47,7 +47,7 @@ namespace WebCore {
 class DOMEditor::RemoveChildAction : public InspectorHistory::Action {
     WTF_MAKE_NONCOPYABLE(RemoveChildAction);
 public:
-    RemoveChildAction(Node* parentNode, Node* node)
+    RemoveChildAction(Node& parentNode, Node& node)
         : InspectorHistory::Action("RemoveChild")
         , m_parentNode(parentNode)
         , m_node(node)
@@ -62,24 +62,24 @@ public:
 
     bool undo(ExceptionCode& ec) override
     {
-        return m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), ec);
+        return m_parentNode->insertBefore(m_node, m_anchorNode.get(), ec);
     }
 
     bool redo(ExceptionCode& ec) override
     {
-        return m_parentNode->removeChild(m_node.get(), ec);
+        return m_parentNode->removeChild(m_node, ec);
     }
 
 private:
-    RefPtr<Node> m_parentNode;
-    RefPtr<Node> m_node;
+    Ref<Node> m_parentNode;
+    Ref<Node> m_node;
     RefPtr<Node> m_anchorNode;
 };
 
 class DOMEditor::InsertBeforeAction : public InspectorHistory::Action {
     WTF_MAKE_NONCOPYABLE(InsertBeforeAction);
 public:
-    InsertBeforeAction(Node* parentNode, RefPtr<Node>&& node, Node* anchorNode)
+    InsertBeforeAction(Node& parentNode, Ref<Node>&& node, Node* anchorNode)
         : InspectorHistory::Action("InsertBefore")
         , m_parentNode(parentNode)
         , m_node(WTFMove(node))
@@ -90,16 +90,16 @@ public:
     bool perform(ExceptionCode& ec) override
     {
         if (m_node->parentNode()) {
-            m_removeChildAction = std::make_unique<RemoveChildAction>(m_node->parentNode(), m_node.get());
+            m_removeChildAction = std::make_unique<RemoveChildAction>(*m_node->parentNode(), m_node);
             if (!m_removeChildAction->perform(ec))
                 return false;
         }
-        return m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), ec);
+        return m_parentNode->insertBefore(m_node, m_anchorNode.get(), ec);
     }
 
     bool undo(ExceptionCode& ec) override
     {
-        if (!m_parentNode->removeChild(m_node.get(), ec))
+        if (!m_parentNode->removeChild(m_node, ec))
             return false;
         if (m_removeChildAction)
             return m_removeChildAction->undo(ec);
@@ -110,12 +110,12 @@ public:
     {
         if (m_removeChildAction && !m_removeChildAction->redo(ec))
             return false;
-        return m_parentNode->insertBefore(m_node.get(), m_anchorNode.get(), ec);
+        return m_parentNode->insertBefore(m_node, m_anchorNode.get(), ec);
     }
 
 private:
-    RefPtr<Node> m_parentNode;
-    RefPtr<Node> m_node;
+    Ref<Node> m_parentNode;
+    Ref<Node> m_node;
     RefPtr<Node> m_anchorNode;
     std::unique_ptr<RemoveChildAction> m_removeChildAction;
 };
@@ -281,7 +281,7 @@ private:
 class DOMEditor::ReplaceChildNodeAction : public InspectorHistory::Action {
     WTF_MAKE_NONCOPYABLE(ReplaceChildNodeAction);
 public:
-    ReplaceChildNodeAction(Node* parentNode, RefPtr<Node>&& newNode, Node* oldNode)
+    ReplaceChildNodeAction(Node& parentNode, Ref<Node>&& newNode, Node& oldNode)
         : InspectorHistory::Action("ReplaceChildNode")
         , m_parentNode(parentNode)
         , m_newNode(WTFMove(newNode))
@@ -301,13 +301,13 @@ public:
 
     bool redo(ExceptionCode& ec) override
     {
-        return m_parentNode->replaceChild(m_newNode, m_oldNode.get(), ec);
+        return m_parentNode->replaceChild(m_newNode, m_oldNode, ec);
     }
 
 private:
-    RefPtr<Node> m_parentNode;
-    RefPtr<Node> m_newNode;
-    RefPtr<Node> m_oldNode;
+    Ref<Node> m_parentNode;
+    Ref<Node> m_newNode;
+    Ref<Node> m_oldNode;
 };
 
 class DOMEditor::SetNodeValueAction : public InspectorHistory::Action {
@@ -348,12 +348,12 @@ DOMEditor::DOMEditor(InspectorHistory* history) : m_history(history) { }
 
 DOMEditor::~DOMEditor() { }
 
-bool DOMEditor::insertBefore(Node* parentNode, RefPtr<Node>&& node, Node* anchorNode, ExceptionCode& ec)
+bool DOMEditor::insertBefore(Node& parentNode, Ref<Node>&& node, Node* anchorNode, ExceptionCode& ec)
 {
     return m_history->perform(std::make_unique<InsertBeforeAction>(parentNode, WTFMove(node), anchorNode), ec);
 }
 
-bool DOMEditor::removeChild(Node* parentNode, Node* node, ExceptionCode& ec)
+bool DOMEditor::removeChild(Node& parentNode, Node& node, ExceptionCode& ec)
 {
     return m_history->perform(std::make_unique<RemoveChildAction>(parentNode, node), ec);
 }
@@ -383,7 +383,7 @@ bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ExceptionCo
     return m_history->perform(std::make_unique<ReplaceWholeTextAction>(textNode, text), ec);
 }
 
-bool DOMEditor::replaceChild(Node* parentNode, RefPtr<Node>&& newNode, Node* oldNode, ExceptionCode& ec)
+bool DOMEditor::replaceChild(Node& parentNode, Ref<Node>&& newNode, Node& oldNode, ExceptionCode& ec)
 {
     return m_history->perform(std::make_unique<ReplaceChildNodeAction>(parentNode, WTFMove(newNode), oldNode), ec);
 }
@@ -401,7 +401,7 @@ static void populateErrorString(const ExceptionCode& ec, ErrorString& errorStrin
     }
 }
 
-bool DOMEditor::insertBefore(Node* parentNode, RefPtr<Node>&& node, Node* anchorNode, ErrorString& errorString)
+bool DOMEditor::insertBefore(Node& parentNode, Ref<Node>&& node, Node* anchorNode, ErrorString& errorString)
 {
     ExceptionCode ec = 0;
     bool result = insertBefore(parentNode, WTFMove(node), anchorNode, ec);
@@ -409,7 +409,7 @@ bool DOMEditor::insertBefore(Node* parentNode, RefPtr<Node>&& node, Node* anchor
     return result;
 }
 
-bool DOMEditor::removeChild(Node* parentNode, Node* node, ErrorString& errorString)
+bool DOMEditor::removeChild(Node& parentNode, Node& node, ErrorString& errorString)
 {
     ExceptionCode ec = 0;
     bool result = removeChild(parentNode, node, ec);
index 41badf0..99d9ffd 100644 (file)
@@ -50,17 +50,17 @@ public:
     explicit DOMEditor(InspectorHistory*);
     ~DOMEditor();
 
-    bool insertBefore(Node* parentNode, RefPtr<Node>&&, Node* anchorNode, ExceptionCode&);
-    bool removeChild(Node* parentNode, Node*, ExceptionCode&);
+    bool insertBefore(Node& parentNode, Ref<Node>&&, Node* anchorNode, ExceptionCode&);
+    bool removeChild(Node& parentNode, Node&, ExceptionCode&);
     bool setAttribute(Element*, const String& name, const String& value, ExceptionCode&);
     bool removeAttribute(Element*, const String& name, ExceptionCode&);
     bool setOuterHTML(Node&, const String& html, Node** newNode, ExceptionCode&);
     bool replaceWholeText(Text*, const String& text, ExceptionCode&);
-    bool replaceChild(Node* parentNode, RefPtr<Node>&& newNode, Node* oldNode, ExceptionCode&);
+    bool replaceChild(Node& parentNode, Ref<Node>&& newNode, Node& oldNode, ExceptionCode&);
     bool setNodeValue(Node* parentNode, const String& value, ExceptionCode&);
 
-    bool insertBefore(Node* parentNode, RefPtr<Node>&&, Node* anchorNode, ErrorString&);
-    bool removeChild(Node* parentNode, Node*, ErrorString&);
+    bool insertBefore(Node& parentNode, Ref<Node>&&, Node* anchorNode, ErrorString&);
+    bool removeChild(Node& parentNode, Node&, ErrorString&);
     bool setAttribute(Element*, const String& name, const String& value, ErrorString&);
     bool removeAttribute(Element*, const String& name, ErrorString&);
     bool setOuterHTML(Node&, const String& html, Node** newNode, ErrorString&);
index 9ffa00b..61a65a2 100644 (file)
@@ -152,7 +152,7 @@ Node* DOMPatchSupport::patchNode(Node& node, const String& markup, ExceptionCode
     if (!innerPatchChildren(parentNode, oldList, newList, ec)) {
         // Fall back to total replace.
         ec = 0;
-        if (!m_domEditor->replaceChild(parentNode, fragment.release(), &node, ec))
+        if (!m_domEditor->replaceChild(*parentNode, *fragment, node, ec))
             return nullptr;
     }
     return previousSibling ? previousSibling->nextSibling() : parentNode->firstChild();
@@ -167,7 +167,7 @@ bool DOMPatchSupport::innerPatchNode(Digest* oldDigest, Digest* newDigest, Excep
     Node* newNode = newDigest->m_node;
 
     if (newNode->nodeType() != oldNode->nodeType() || newNode->nodeName() != oldNode->nodeName())
-        return m_domEditor->replaceChild(oldNode->parentNode(), newNode, oldNode, ec);
+        return m_domEditor->replaceChild(*oldNode->parentNode(), *newNode, *oldNode, ec);
 
     if (oldNode->nodeValue() != newNode->nodeValue()) {
         if (!m_domEditor->setNodeValue(oldNode, newNode->nodeValue(), ec))
@@ -377,7 +377,7 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
     for (size_t i = 0; i < newMap.size(); ++i) {
         if (newMap[i].first || merges.contains(newList[i].get()))
             continue;
-        if (!insertBeforeAndMarkAsUsed(parentNode, newList[i].get(), parentNode->traverseToChildAt(i), ec))
+        if (!insertBeforeAndMarkAsUsed(*parentNode, *newList[i], parentNode->traverseToChildAt(i), ec))
             return false;
     }
 
@@ -392,7 +392,7 @@ bool DOMPatchSupport::innerPatchChildren(ContainerNode* parentNode, const Vector
         if (node->hasTagName(bodyTag) || node->hasTagName(headTag))
             continue; // Never move head or body, move the rest of the nodes around them.
 
-        if (!m_domEditor->insertBefore(parentNode, node.release(), anchorNode, ec))
+        if (!m_domEditor->insertBefore(*parentNode, node.releaseNonNull(), anchorNode, ec))
             return false;
     }
     return true;
@@ -446,17 +446,19 @@ std::unique_ptr<DOMPatchSupport::Digest> DOMPatchSupport::createDigest(Node* nod
     return digest;
 }
 
-bool DOMPatchSupport::insertBeforeAndMarkAsUsed(ContainerNode* parentNode, Digest* digest, Node* anchor, ExceptionCode& ec)
+bool DOMPatchSupport::insertBeforeAndMarkAsUsed(ContainerNode& parentNode, Digest& digest, Node* anchor, ExceptionCode& ec)
 {
-    bool result = m_domEditor->insertBefore(parentNode, digest->m_node, anchor, ec);
-    markNodeAsUsed(digest);
+    ASSERT(digest.m_node);
+    bool result = m_domEditor->insertBefore(parentNode, *digest.m_node, anchor, ec);
+    markNodeAsUsed(&digest);
     return result;
 }
 
 bool DOMPatchSupport::removeChildAndMoveToNew(Digest* oldDigest, ExceptionCode& ec)
 {
     RefPtr<Node> oldNode = oldDigest->m_node;
-    if (!m_domEditor->removeChild(oldNode->parentNode(), oldNode.get(), ec))
+    ASSERT(oldNode->parentNode());
+    if (!m_domEditor->removeChild(*oldNode->parentNode(), *oldNode, ec))
         return false;
 
     // Diff works within levels. In order not to lose the node identity when user
@@ -468,7 +470,7 @@ bool DOMPatchSupport::removeChildAndMoveToNew(Digest* oldDigest, ExceptionCode&
     if (it != m_unusedNodesMap.end()) {
         Digest* newDigest = it->value;
         Node* newNode = newDigest->m_node;
-        if (!m_domEditor->replaceChild(newNode->parentNode(), WTFMove(oldNode), newNode, ec))
+        if (!m_domEditor->replaceChild(*newNode->parentNode(), *oldNode, *newNode, ec))
             return false;
         newDigest->m_node = oldNode.get();
         markNodeAsUsed(newDigest);
index a877bf6..dd9532a 100644 (file)
@@ -64,7 +64,7 @@ private:
     std::pair<ResultMap, ResultMap> diff(const Vector<std::unique_ptr<Digest>>& oldChildren, const Vector<std::unique_ptr<Digest>>& newChildren);
     bool innerPatchChildren(ContainerNode*, const Vector<std::unique_ptr<Digest>>& oldChildren, const Vector<std::unique_ptr<Digest>>& newChildren, ExceptionCode&);
     std::unique_ptr<Digest> createDigest(Node*, UnusedNodesMap*);
-    bool insertBeforeAndMarkAsUsed(ContainerNode*, Digest*, Node* anchor, ExceptionCode&);
+    bool insertBeforeAndMarkAsUsed(ContainerNode&, Digest&, Node* anchor, ExceptionCode&);
     bool removeChildAndMoveToNew(Digest*, ExceptionCode&);
     void markNodeAsUsed(Digest*);
 #ifdef DEBUG_DOM_PATCH_SUPPORT
index 6516504..05480ca 100644 (file)
@@ -794,7 +794,7 @@ InspectorStyleSheet* InspectorCSSAgent::createInspectorStyleSheetForDocument(Doc
     m_creatingViaInspectorStyleSheet = true;
     InlineStyleOverrideScope overrideScope(document);
     ExceptionCode ec = 0;
-    targetNode->appendChild(WTFMove(styleElement), ec);
+    targetNode->appendChild(styleElement, ec);
     m_creatingViaInspectorStyleSheet = false;
     if (ec)
         return nullptr;
index 7e48d12..74838ba 100644 (file)
@@ -712,7 +712,7 @@ void InspectorDOMAgent::removeNode(ErrorString& errorString, int nodeId)
         return;
     }
 
-    m_domEditor->removeChild(parentNode, node, errorString);
+    m_domEditor->removeChild(*parentNode, *node, errorString);
 }
 
 void InspectorDOMAgent::setNodeName(ErrorString& errorString, int nodeId, const String& tagName, int* newId)
@@ -724,7 +724,7 @@ void InspectorDOMAgent::setNodeName(ErrorString& errorString, int nodeId, const
         return;
 
     ExceptionCode ec = 0;
-    RefPtr<Element> newElement = oldNode->document().createElementForBindings(tagName, ec);
+    auto newElement = oldNode->document().createElementForBindings(tagName, ec);
     if (ec)
         return;
 
@@ -734,15 +734,15 @@ void InspectorDOMAgent::setNodeName(ErrorString& errorString, int nodeId, const
     // Copy over the original node's children.
     RefPtr<Node> child;
     while ((child = oldNode->firstChild())) {
-        if (!m_domEditor->insertBefore(newElement.get(), child.get(), 0, errorString))
+        if (!m_domEditor->insertBefore(*newElement, *child, 0, errorString))
             return;
     }
 
     // Replace the old node with the new node
     RefPtr<ContainerNode> parent = oldNode->parentNode();
-    if (!m_domEditor->insertBefore(parent.get(), newElement.get(), oldNode->nextSibling(), errorString))
+    if (!m_domEditor->insertBefore(*parent, *newElement, oldNode->nextSibling(), errorString))
         return;
-    if (!m_domEditor->removeChild(parent.get(), oldNode.get(), errorString))
+    if (!m_domEditor->removeChild(*parent, *oldNode, errorString))
         return;
 
     *newId = pushNodePathToFrontend(newElement.get());
@@ -1180,7 +1180,7 @@ void InspectorDOMAgent::moveTo(ErrorString& errorString, int nodeId, int targetE
         }
     }
 
-    if (!m_domEditor->insertBefore(targetElement, node, anchorNode, errorString))
+    if (!m_domEditor->insertBefore(*targetElement, *node, anchorNode, errorString))
         return;
 
     *newNodeId = pushNodePathToFrontend(node);
index 0c90b41..69a7d9b 100644 (file)
@@ -125,20 +125,20 @@ DragController::~DragController()
     m_client.dragControllerDestroyed();
 }
 
-static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData& dragData, Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
+static RefPtr<DocumentFragment> documentFragmentFromDragData(DragData& dragData, Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
 {
     chosePlainText = false;
 
     Document& document = context.ownerDocument();
     if (dragData.containsCompatibleContent()) {
-        if (PassRefPtr<DocumentFragment> fragment = frame.editor().webContentFromPasteboard(*Pasteboard::createForDragAndDrop(dragData), context, allowPlainText, chosePlainText))
+        if (auto fragment = frame.editor().webContentFromPasteboard(*Pasteboard::createForDragAndDrop(dragData), context, allowPlainText, chosePlainText))
             return fragment;
 
         if (dragData.containsURL(DragData::DoNotConvertFilenames)) {
             String title;
             String url = dragData.asURL(DragData::DoNotConvertFilenames, &title);
             if (!url.isEmpty()) {
-                Ref<HTMLAnchorElement> anchor = HTMLAnchorElement::create(document);
+                auto anchor = HTMLAnchorElement::create(document);
                 anchor->setHref(url);
                 if (title.isEmpty()) {
                     // Try the plain text first because the url might be normalized or escaped.
@@ -148,9 +148,9 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData& dragD
                         title = url;
                 }
                 anchor->appendChild(document.createTextNode(title), IGNORE_EXCEPTION);
-                Ref<DocumentFragment> fragment = document.createDocumentFragment();
-                fragment->appendChild(WTFMove(anchor), IGNORE_EXCEPTION);
-                return fragment.ptr();
+                auto fragment = document.createDocumentFragment();
+                fragment->appendChild(anchor, IGNORE_EXCEPTION);
+                return WTFMove(fragment);
             }
         }
     }
index af3b12c..b43f01a 100644 (file)
@@ -89,14 +89,14 @@ void Frame::initWithSimpleHTMLDocument(const String& style, const URL& url)
     setDocument(document);
 
     ExceptionCode ec;
-    RefPtr<Element> rootElement = document->createElementNS(xhtmlNamespaceURI, ASCIILiteral("html"), ec);
+    auto rootElement = document->createElementNS(xhtmlNamespaceURI, ASCIILiteral("html"), ec);
 
-    RefPtr<Element> body = document->createElementNS(xhtmlNamespaceURI, ASCIILiteral("body"), ec);
+    auto body = document->createElementNS(xhtmlNamespaceURI, ASCIILiteral("body"), ec);
     if (!style.isEmpty())
         body->setAttribute(HTMLNames::styleAttr, style);
 
-    rootElement->appendChild(body.releaseNonNull(), ec);
-    document->appendChild(rootElement.releaseNonNull(), ec);
+    rootElement->appendChild(*body, ec);
+    document->appendChild(*rootElement, ec);
 }
 
 const ViewportArguments& Frame::viewportArguments() const
index 8a92634..86abf80 100644 (file)
@@ -430,7 +430,7 @@ void SVGUseElement::cloneTarget(ContainerNode& container, SVGElement& target) co
     removeDisallowedElementsFromSubtree(targetClone.get());
     removeSymbolElementsFromSubtree(targetClone.get());
     transferSizeAttributesToTargetClone(targetClone.get());
-    container.appendChild(WTFMove(targetClone));
+    container.appendChild(targetClone);
 }
 
 static void cloneDataAndChildren(SVGElement& replacementClone, SVGElement& originalClone)
@@ -469,7 +469,7 @@ void SVGUseElement::expandUseElementsInShadowTree() const
         if (target)
             originalClone.cloneTarget(replacementClone.get(), *target);
 
-        originalClone.parentNode()->replaceChild(replacementClone.copyRef(), originalClone);
+        originalClone.parentNode()->replaceChild(replacementClone, originalClone);
 
         // Resume iterating, starting just inside the replacement clone.
         it = descendants.from(replacementClone.get());
@@ -493,7 +493,7 @@ void SVGUseElement::expandSymbolElementsInShadowTree() const
         auto replacementClone = SVGSVGElement::create(document());
         cloneDataAndChildren(replacementClone.get(), originalClone);
 
-        originalClone.parentNode()->replaceChild(replacementClone.copyRef(), originalClone);
+        originalClone.parentNode()->replaceChild(replacementClone, originalClone);
 
         // Resume iterating, starting just inside the replacement clone.
         it = descendants.from(replacementClone.get());
index e8f710c..bf4d258 100644 (file)
@@ -93,19 +93,19 @@ static inline Ref<Element> createXHTMLParserErrorHeader(Document* doc, const Str
     reportElement->parserSetAttributes(reportAttributes);
 
     auto h3 = doc->createElement(h3Tag, true);
-    reportElement->parserAppendChild(h3.copyRef());
+    reportElement->parserAppendChild(h3);
     h3->parserAppendChild(doc->createTextNode("This page contains the following errors:"));
 
     auto fixed = doc->createElement(divTag, true);
     Vector<Attribute> fixedAttributes;
     fixedAttributes.append(Attribute(styleAttr, "font-family:monospace;font-size:12px"));
     fixed->parserSetAttributes(fixedAttributes);
-    reportElement->parserAppendChild(fixed.copyRef());
+    reportElement->parserAppendChild(fixed);
 
     fixed->parserAppendChild(doc->createTextNode(errorMessages));
 
     h3 = doc->createElement(h3Tag, true);
-    reportElement->parserAppendChild(h3.get());
+    reportElement->parserAppendChild(h3);
     h3->parserAppendChild(doc->createTextNode("Below is a rendering of the page up to the first error."));
 
     return reportElement;
@@ -122,25 +122,25 @@ void XMLErrors::insertErrorMessageBlock()
     if (!documentElement) {
         auto rootElement = m_document->createElement(htmlTag, true);
         auto body = m_document->createElement(bodyTag, true);
-        rootElement->parserAppendChild(body.copyRef());
-        m_document->parserAppendChild(rootElement.copyRef());
+        rootElement->parserAppendChild(body);
+        m_document->parserAppendChild(rootElement);
         documentElement = WTFMove(body);
     }
     else if (documentElement->namespaceURI() == SVGNames::svgNamespaceURI) {
         auto rootElement = m_document->createElement(htmlTag, true);
         auto head = m_document->createElement(headTag, true);
         auto style = m_document->createElement(styleTag, true);
-        head->parserAppendChild(style.copyRef());
+        head->parserAppendChild(style);
         style->parserAppendChild(m_document->createTextNode("html, body { height: 100% } parsererror + svg { width: 100%; height: 100% }"));
         style->finishParsingChildren();
-        rootElement->parserAppendChild(head.copyRef());
+        rootElement->parserAppendChild(head);
         auto body = m_document->createElement(bodyTag, true);
-        rootElement->parserAppendChild(body.copyRef());
+        rootElement->parserAppendChild(body);
 
         m_document->parserRemoveChild(*documentElement);
 
         body->parserAppendChild(*documentElement);
-        m_document->parserAppendChild(WTFMove(rootElement));
+        m_document->parserAppendChild(rootElement);
 
         documentElement = WTFMove(body);
     }
@@ -155,15 +155,15 @@ void XMLErrors::insertErrorMessageBlock()
         auto paragraph = m_document->createElement(pTag, true);
         paragraph->parserSetAttributes(attributes);
         paragraph->parserAppendChild(m_document->createTextNode("This document was created as the result of an XSL transformation. The line and column numbers given are from the transformed result."));
-        reportElement->parserAppendChild(WTFMove(paragraph));
+        reportElement->parserAppendChild(paragraph);
     }
 #endif
 
     Node* firstChild = documentElement->firstChild();
     if (firstChild)
-        documentElement->parserInsertBefore(WTFMove(reportElement), *firstChild);
+        documentElement->parserInsertBefore(reportElement, *firstChild);
     else
-        documentElement->parserAppendChild(WTFMove(reportElement));
+        documentElement->parserAppendChild(reportElement);
 
     m_document->updateStyleIfNeeded();
 }
index 5f137ad..536e290 100644 (file)
@@ -61,8 +61,8 @@ void XMLTreeViewer::transformDocumentToTreeView()
     m_document.frame()->script().evaluate(ScriptSourceCode(AtomicString("prepareWebKitXMLViewer('This XML file does not appear to have any style information associated with it. The document tree is shown below.');")));
 
     String cssString = StringImpl::createWithoutCopying(XMLViewer_css, sizeof(XMLViewer_css));
-    Ref<Text> text = m_document.createTextNode(cssString);
-    m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(WTFMove(text), IGNORE_EXCEPTION);
+    auto text = m_document.createTextNode(cssString);
+    m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(text, IGNORE_EXCEPTION);
     m_document.styleResolverChanged(RecalcStyleImmediately);
 }
 
index db0cf8a..6eeb11d 100644 (file)
@@ -844,7 +844,7 @@ void XMLDocumentParser::startElementNs(const xmlChar* xmlLocalName, const xmlCha
     if (scriptElement)
         m_scriptStartPosition = textPosition();
 
-    m_currentNode->parserAppendChild(newElement.copyRef());
+    m_currentNode->parserAppendChild(newElement);
     if (!m_currentNode) // Synchronous DOM events may have removed the current node.
         return;
 
@@ -1001,7 +1001,7 @@ void XMLDocumentParser::processingInstruction(const xmlChar* target, const xmlCh
 
     pi->setCreatedByParser(true);
 
-    m_currentNode->parserAppendChild(pi.copyRef());
+    m_currentNode->parserAppendChild(pi);
 
     pi->finishParsingChildren();
 
@@ -1027,8 +1027,7 @@ void XMLDocumentParser::cdataBlock(const xmlChar* s, int len)
     if (!updateLeafTextNode())
         return;
 
-    auto newNode = CDATASection::create(m_currentNode->document(), toString(s, len));
-    m_currentNode->parserAppendChild(WTFMove(newNode));
+    m_currentNode->parserAppendChild(CDATASection::create(m_currentNode->document(), toString(s, len)));
 }
 
 void XMLDocumentParser::comment(const xmlChar* s)
@@ -1044,8 +1043,7 @@ void XMLDocumentParser::comment(const xmlChar* s)
     if (!updateLeafTextNode())
         return;
 
-    auto newNode = Comment::create(m_currentNode->document(), toString(s));
-    m_currentNode->parserAppendChild(WTFMove(newNode));
+    m_currentNode->parserAppendChild(Comment::create(m_currentNode->document(), toString(s)));
 }
 
 enum StandaloneInfo {
index 6626a54..0717c5d 100644 (file)
@@ -1,3 +1,13 @@
+2016-05-11  Chris Dumez  <cdumez@apple.com>
+
+        Update Node::appendChild() / replaceChild() / removeChild() / insertBefore() to take references instead of pointers
+        https://bugs.webkit.org/show_bug.cgi?id=157556
+
+        Reviewed by Darin Adler.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _documentFragmentWithNodesAsParagraphs:]):
+
 2016-05-10  Shaw rich  <richshaw@126.com>
 
         [OS X] Compatible with gnu sed grammar due to compile error with gnu sed
index e01f26c..fd2117f 100644 (file)
@@ -914,9 +914,9 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
     RefPtr<DocumentFragment> fragment = document->createDocumentFragment();
 
     for (auto* node : nodesVector) {
-        Ref<Element> element = createDefaultParagraphElement(*document);
+        auto element = createDefaultParagraphElement(*document);
         element->appendChild(*node);
-        fragment->appendChild(WTFMove(element));
+        fragment->appendChild(element);
     }
 
     return kit(fragment.release().get());
@@ -1691,7 +1691,7 @@ static WebFrameLoadType toWebFrameLoadType(FrameLoadType frameLoadType)
     if (!frame || !frame->document())
         return;
         
-    frame->editor().setTextAsChildOfElement(text, core(element));
+    frame->editor().setTextAsChildOfElement(text, *core(element));
 }
 
 - (void)setDictationPhrases:(NSArray *)dictationPhrases metadata:(id)metadata asChildOfElement:(DOMElement *)element
index 3ac3302..2bafb76 100644 (file)
@@ -1,3 +1,14 @@
+2016-05-11  Chris Dumez  <cdumez@apple.com>
+
+        Update Node::appendChild() / replaceChild() / removeChild() / insertBefore() to take references instead of pointers
+        https://bugs.webkit.org/show_bug.cgi?id=157556
+
+        Reviewed by Darin Adler.
+
+        * DOMCoreClasses.cpp:
+        (DOMNode::insertBefore):
+        (DOMNode::removeChild):
+
 2016-05-11  Joanmarie Diggs  <jdiggs@igalia.com>
 
         [GTK] accessibility/aria-readonly.html is failing
index 5260671..5df7838 100644 (file)
@@ -250,7 +250,7 @@ HRESULT DOMNode::insertBefore(_In_opt_ IDOMNode* newChild, _In_opt_ IDOMNode* re
     COMPtr<DOMNode> refChildNode(Query, refChild);
 
     ExceptionCode ec;
-    if (!m_node->insertBefore(newChildNode->node(), refChildNode ? refChildNode->node() : 0, ec))
+    if (!m_node->insertBefore(*newChildNode->node(), refChildNode ? refChildNode->node() : nullptr, ec))
         return E_FAIL;
 
     *result = newChild;
@@ -282,7 +282,7 @@ HRESULT DOMNode::removeChild(_In_opt_ IDOMNode* oldChild, _COM_Outptr_opt_ IDOMN
         return E_FAIL;
 
     ExceptionCode ec;
-    if (!m_node->removeChild(oldChildNode->node(), ec))
+    if (!m_node->removeChild(*oldChildNode->node(), ec))
         return E_FAIL;
 
     *result = oldChild;
index 077bca7..ba34c63 100644 (file)
@@ -1,3 +1,19 @@
+2016-05-11  Chris Dumez  <cdumez@apple.com>
+
+        Update Node::appendChild() / replaceChild() / removeChild() / insertBefore() to take references instead of pointers
+        https://bugs.webkit.org/show_bug.cgi?id=157556
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/InjectedBundle/API/mac/WKDOMNode.mm:
+        (-[WKDOMNode insertNode:before:]):
+        (-[WKDOMNode appendChild:]):
+        (-[WKDOMNode removeChild:]):
+        * WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm:
+        (WebKit::PDFPlugin::PDFPlugin):
+        * WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm:
+        (WebKit::PDFPluginChoiceAnnotation::createAnnotationElement):
+
 2016-05-11  Brady Eidson  <beidson@apple.com>
 
         Modern IDB: IDBOpenDBRequests that are stop()'ed don't notify the IDBServer of that fact.
index c8aa9d2..7122c3f 100644 (file)
 
 - (void)insertNode:(WKDOMNode *)node before:(WKDOMNode *)refNode
 {
+    if (!node)
+        return;
+
     // FIXME: Do something about the exception.
     WebCore::ExceptionCode ec;
-    _impl->insertBefore(WebKit::toWebCoreNode(node), WebKit::toWebCoreNode(refNode), ec);
+    _impl->insertBefore(*WebKit::toWebCoreNode(node), WebKit::toWebCoreNode(refNode), ec);
 }
 
 - (void)appendChild:(WKDOMNode *)node
 {
+    if (!node)
+        return;
+
     // FIXME: Do something about the exception.
     WebCore::ExceptionCode ec;
-    _impl->appendChild(WebKit::toWebCoreNode(node), ec);
+    _impl->appendChild(*WebKit::toWebCoreNode(node), ec);
 }
 
 - (void)removeChild:(WKDOMNode *)node
 {
+    if (!node)
+        return;
+
     // FIXME: Do something about the exception.
     WebCore::ExceptionCode ec;
-    _impl->removeChild(WebKit::toWebCoreNode(node), ec);
+    _impl->removeChild(*WebKit::toWebCoreNode(node), ec);
 }
 
 - (WKDOMDocument *)document
index 74e228b..dc25923 100644 (file)
@@ -524,10 +524,10 @@ PDFPlugin::PDFPlugin(WebFrame* frame)
         m_annotationContainer = document->createElement(divTag, false);
         m_annotationContainer->setAttribute(idAttr, "annotationContainer");
 
-        Ref<Element> annotationStyleElement = document->createElement(styleTag, false);
+        auto annotationStyleElement = document->createElement(styleTag, false);
         annotationStyleElement->setTextContent(annotationStyle, ASSERT_NO_EXCEPTION);
 
-        m_annotationContainer->appendChild(WTFMove(annotationStyleElement));
+        m_annotationContainer->appendChild(annotationStyleElement);
         document->bodyOrFrameset()->appendChild(*m_annotationContainer);
     }
 
index 608a92e..f9bf5d9 100644 (file)
@@ -83,14 +83,14 @@ PassRefPtr<Element> PDFPluginChoiceAnnotation::createAnnotationElement()
     NSString *selectedChoice = choiceAnnotation.stringValue;
 
     for (NSString *choice in choices) {
-        Ref<Element> choiceOption = document.createElement(optionTag, false);
+        auto choiceOption = document.createElement(optionTag, false);
         choiceOption->setAttribute(valueAttr, choice);
         choiceOption->setTextContent(choice, ASSERT_NO_EXCEPTION);
 
         if (choice == selectedChoice)
             choiceOption->setAttribute(selectedAttr, "selected");
 
-        styledElement->appendChild(WTFMove(choiceOption));
+        styledElement->appendChild(choiceOption);
     }
 
     return element;