+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.
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
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)');
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
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')");
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
<![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');
-CONSOLE MESSAGE: line 10: TypeError: Type error
+CONSOLE MESSAGE: line 10: TypeError: Argument 1 ('node') to Node.appendChild must be an instance of Node
-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.
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
);
// Should be a DOM exception, not just some "TypeError: Null value".
-shouldThrow('(document.appendChild()).foobar()', '"TypeError: Type error"');
+shouldThrow('(document.appendChild()).foobar()');
+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.
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));
// 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;
}
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
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.
// 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))
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);
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.
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
ChildListMutationScope mutation(*this);
RefPtr<Node> refChild = oldChild.nextSibling();
- if (refChild.get() == newChild.ptr())
+ if (refChild.get() == &newChild)
refChild = refChild->nextSibling();
NodeVector targets;
dispatchSubtreeModifiedEvent();
}
-bool ContainerNode::appendChild(Ref<Node>&& newChild, ExceptionCode& ec)
+bool ContainerNode::appendChild(Node& newChild, ExceptionCode& ec)
{
Ref<ContainerNode> protect(*this);
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;
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)
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()));
if (ec || !node)
return;
- appendChild(node.releaseNonNull(), ec);
+ appendChild(*node, ec);
}
void ContainerNode::prepend(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec)
if (ec || !node)
return;
- insertBefore(node.releaseNonNull(), firstChild(), ec);
+ insertBefore(*node, firstChild(), ec);
}
HTMLCollection* ContainerNode::cachedHTMLCollection(CollectionType type)
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*);
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;
}
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;
}
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
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);
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)
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)
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)
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)
// 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(); }
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();
if (nodeOrStringVector.isEmpty())
return nullptr;
- Vector<RefPtr<Node>> nodes;
+ Vector<Ref<Node>> nodes;
nodes.reserveInitialCapacity(nodeOrStringVector.size());
for (auto& nodeOrString : nodeOrStringVector) {
switch (nodeOrString.type()) {
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
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)
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
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)
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)
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);
}
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);
}
}
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()) {
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);
}
}
-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)
else
++newOffset;
- parent->insertBefore(WTFMove(node), referenceNode.get(), ec);
+ parent->insertBefore(node, referenceNode.get(), ec);
if (ec)
return;
insertNode(newParent.copyRef(), ec);
if (ec)
return;
- newParent->appendChild(fragment.release(), ec);
+ newParent->appendChild(*fragment, ec);
if (ec)
return;
selectNode(newParent, ec);
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;
dispatchModifiedEvent(oldStr);
if (parentNode())
- parentNode()->insertBefore(newText.copyRef(), nextSibling(), ec);
+ parentNode()->insertBefore(newText, nextSibling(), ec);
if (ec)
return 0;
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()
confirmComposition();
}
-void Editor::setTextAsChildOfElement(const String& text, Element* elem)
+void Editor::setTextAsChildOfElement(const String& text, Element& element)
{
// Clear the composition
clear();
// 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
m_frame.selection().clear();
// clear out all current children of element
- elem->removeChildren();
+ element.removeChildren();
if (text.length()) {
// insert new text
// (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())
#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&);
{
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());
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);
}
children.append(*child);
for (auto& child : children)
- m_element1->appendChild(WTFMove(child), ec);
+ m_element1->appendChild(child, ec);
}
#ifndef NDEBUG
if (!parent || !parent->hasEditableStyle())
return;
- parent->insertBefore(m_node.copyRef(), refChild.get(), IGNORE_EXCEPTION);
+ parent->insertBefore(m_node, refChild.get(), IGNORE_EXCEPTION);
}
#ifndef NDEBUG
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);
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;
m_element2->removeAttribute(HTMLNames::idAttr);
for (auto& child : children)
- m_element1->appendChild(WTFMove(child), ec);
+ m_element1->appendChild(child, ec);
}
void SplitElementCommand::doApply()
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();
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);
}
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);
}
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();
if (!tabTextNode)
tabTextNode = document.createEditingTextNode("\t");
- spanElement->appendChild(tabTextNode.releaseNonNull(), ASSERT_NO_EXCEPTION);
+ spanElement->appendChild(*tabTextNode, ASSERT_NO_EXCEPTION);
return spanElement;
}
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;
}
loader->addArchiveResource(resource.releaseNonNull());
auto fragment = m_frame.document()->createDocumentFragment();
- fragment->appendChild(WTFMove(imageElement));
+ fragment->appendChild(imageElement);
return WTFMove(fragment);
}
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
}
anchor->appendChild(frame.document()->createTextNode([title precomposedStringWithCanonicalMapping]));
fragment = frame.document()->createDocumentFragment();
- fragment->appendChild(WTFMove(anchor));
+ fragment->appendChild(anchor);
return true;
}
loader->addArchiveResource(resource.releaseNonNull());
auto fragment = document().createDocumentFragment();
- fragment->appendChild(WTFMove(imageElement));
+ fragment->appendChild(imageElement);
return WTFMove(fragment);
}
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
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;
}
element = createDefaultParagraphElement(document);
fillContainerFromString(*element, s);
}
- fragment->appendChild(element.releaseNonNull(), ASSERT_NO_EXCEPTION);
+ fragment->appendChild(*element, ASSERT_NO_EXCEPTION);
}
return fragment;
}
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)
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);
}
}
{
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();
}
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();
}
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)
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;
}
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);
}
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);
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()))
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.
if (!imageControls)
return;
- ensureUserAgentShadowRoot().appendChild(imageControls.releaseNonNull());
+ ensureUserAgentShadowRoot().appendChild(*imageControls);
auto* renderObject = renderer();
if (!renderObject)
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)
{
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
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;
element->setAttribute(selectedAttr, emptyAtom);
element->setSelected(selected);
- return element;
+ return WTFMove(element);
}
bool HTMLOptionElement::isFocusable() const
{
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
{
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;
}
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);
}
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);
}
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
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)
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();
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);
#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)
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())
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)
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%");
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)
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
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
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));
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();
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
}
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()
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;
}
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;
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;
}
// 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);
auto slider = MediaControlPanelVolumeSliderElement::create(document);
controls->m_volumeSlider = slider.ptr();
- volumeSliderContainer->appendChild(WTFMove(slider), ec);
+ volumeSliderContainer->appendChild(slider, ec);
if (ec)
return nullptr;
// 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;
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);
}
return;
markFutureAndPastNodes(referenceTree.get(), startMediaTime(), movieTime);
- m_cueHighlightBox->appendChild(referenceTree.releaseNonNull());
+ m_cueHighlightBox->appendChild(*referenceTree);
}
VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize)
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: {
}
if (!m_languageStack.isEmpty())
child->setLanguage(m_languageStack.last());
- m_currentNode->parserAppendChild(child.copyRef());
+ m_currentNode->parserAppendChild(child);
m_currentNode = WTFMove(child);
break;
}
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)
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))
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);
{
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;
};
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))
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 {
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);
}
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);
}
}
}
-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);
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);
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&);
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();
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))
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;
}
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;
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
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);
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
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;
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)
return;
ExceptionCode ec = 0;
- RefPtr<Element> newElement = oldNode->document().createElementForBindings(tagName, ec);
+ auto newElement = oldNode->document().createElementForBindings(tagName, ec);
if (ec)
return;
// 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());
}
}
- if (!m_domEditor->insertBefore(targetElement, node, anchorNode, errorString))
+ if (!m_domEditor->insertBefore(*targetElement, *node, anchorNode, errorString))
return;
*newNodeId = pushNodePathToFrontend(node);
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.
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);
}
}
}
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
removeDisallowedElementsFromSubtree(targetClone.get());
removeSymbolElementsFromSubtree(targetClone.get());
transferSizeAttributesToTargetClone(targetClone.get());
- container.appendChild(WTFMove(targetClone));
+ container.appendChild(targetClone);
}
static void cloneDataAndChildren(SVGElement& replacementClone, SVGElement& originalClone)
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());
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());
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;
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);
}
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();
}
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);
}
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;
pi->setCreatedByParser(true);
- m_currentNode->parserAppendChild(pi.copyRef());
+ m_currentNode->parserAppendChild(pi);
pi->finishParsingChildren();
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)
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 {
+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
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());
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
+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
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;
return E_FAIL;
ExceptionCode ec;
- if (!m_node->removeChild(oldChildNode->node(), ec))
+ if (!m_node->removeChild(*oldChildNode->node(), ec))
return E_FAIL;
*result = oldChild;
+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.
- (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
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);
}
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;