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)
commit1fb90a9633de89706dc5659dd616b170952ffe9b
treebf67a2e756aa6ff2016d1ec79f41d83eac446a9e
parent0d88d75c828eaad1a4edcc1aa4251660c1defb12
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.

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