Node.appendChild(null) / replaceChild(null, null) / removeChild(null) / insertBefore(null, ref) should throw a TypeError
https://bugs.webkit.org/show_bug.cgi?id=148971
<rdar://problem/22560883>
<rdar://problem/22559225>
Reviewed by Ryosuke Niwa.
LayoutTests/imported/w3c:
Rebaseline W3C tests now that more checks are passing.
* web-platform-tests/dom/interfaces-expected.txt:
* web-platform-tests/dom/nodes/Node-appendChild-expected.txt:
* web-platform-tests/dom/nodes/Node-insertBefore-expected.txt:
* web-platform-tests/dom/nodes/Node-removeChild-expected.txt:
* web-platform-tests/dom/nodes/Node-replaceChild-expected.txt:
* web-platform-tests/html/dom/interfaces-expected.txt:
Source/WebCore:
Node.appendChild(null) / replaceChild(null, null) / removeChild(null)
and insertBefore(null, ref) should throw a TypeError instead of a
NotFoundError, as per the specification:
https://dom.spec.whatwg.org/#node
The parameters are not nullable so the Web IDL specification says
we should throw a TypeError in this case.
This patch moves the null-checking from ContainerNode to the methods
on Node. The null-checking is supposed to be done by the bindings code
but our generator currently does not support this so we do the null
checking as close to the bindings as possible. The bindings code is
calling the methods on Node. This also makes sure we throw a TypeError
for null-argument when the Node is not a ContainerNode. For e.g.
Text.appendChild(null) should throw a TypeError too.
The methods on ContainerNode now take references insteaad of pointer
parameters now that the null-checking is done at the call site in
Node. This lead to a lot of code update as those methods are used
a lot throughout the code base.
No new tests, already covered by pre-existing layout tests.
Source/WebKit/mac:
ContainerNode::appendChild() now takes a Ref<Node>&& parameter so we
need to update the call site.
* WebView/WebFrame.mm:
(-[WebFrame _documentFragmentWithNodesAsParagraphs:]):
Source/WebKit2:
ContainerNode::appendChild() now takes a Ref<Node>&& parameter so we
need to update the call sites.
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::PDFPlugin):
* WebProcess/Plugins/PDF/PDFPluginAnnotation.mm:
(WebKit::PDFPluginAnnotation::attach):
(WebKit::PDFPluginAnnotation::~PDFPluginAnnotation):
* WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm:
(WebKit::PDFPluginChoiceAnnotation::createAnnotationElement):
LayoutTests:
Update / rebaseline tests now that we throw a different exception type.
* fast/dom/Document/replaceChild-null-oldChild-expected.txt:
* fast/dom/Document/script-tests/replaceChild-null-oldChild.js:
* fast/dom/Node/fragment-mutation-expected.txt:
* fast/dom/Node/fragment-mutation.html:
* fast/dom/incompatible-operations-expected.txt:
* fast/dom/incompatible-operations.html:
* fast/dom/move-nodes-across-documents.html:
* fast/dom/processing-instruction-appendChild-exceptions-expected.txt:
* fast/dom/processing-instruction-appendChild-exceptions.xhtml:
* fast/dom/setter-type-enforcement-expected.txt:
* fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt:
* fast/inspector-support/uncaught-dom8-exception.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@189576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 577c840..15d4325 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,35 @@
+2015-09-10 Chris Dumez <cdumez@apple.com>
+
+ Node.appendChild(null) / replaceChild(null, null) / removeChild(null) / insertBefore(null, ref) should throw a TypeError
+ https://bugs.webkit.org/show_bug.cgi?id=148971
+ <rdar://problem/22560883>
+ <rdar://problem/22559225>
+
+ Reviewed by Ryosuke Niwa.
+
+ Node.appendChild(null) / replaceChild(null, null) / removeChild(null)
+ and insertBefore(null, ref) should throw a TypeError instead of a
+ NotFoundError, as per the specification:
+ https://dom.spec.whatwg.org/#node
+
+ The parameters are not nullable so the Web IDL specification says
+ we should throw a TypeError in this case.
+
+ This patch moves the null-checking from ContainerNode to the methods
+ on Node. The null-checking is supposed to be done by the bindings code
+ but our generator currently does not support this so we do the null
+ checking as close to the bindings as possible. The bindings code is
+ calling the methods on Node. This also makes sure we throw a TypeError
+ for null-argument when the Node is not a ContainerNode. For e.g.
+ Text.appendChild(null) should throw a TypeError too.
+
+ The methods on ContainerNode now take references insteaad of pointer
+ parameters now that the null-checking is done at the call site in
+ Node. This lead to a lot of code update as those methods are used
+ a lot throughout the code base.
+
+ No new tests, already covered by pre-existing layout tests.
+
2015-09-10 Daniel Bates <dabates@apple.com>
Write a test to ensure we don't regress processing of tasks when page defers loading
diff --git a/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp b/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp
index 8f96c9f..b44cfd2 100644
--- a/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp
+++ b/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp
@@ -81,9 +81,9 @@
{
m_embedShadowElement = YouTubeEmbedShadowElement::create(m_parentElement->document());
- root->appendChild(m_embedShadowElement.get());
+ root->appendChild(*m_embedShadowElement);
- RefPtr<HTMLIFrameElement> iframeElement = HTMLIFrameElement::create(HTMLNames::iframeTag, m_parentElement->document());
+ Ref<HTMLIFrameElement> iframeElement = HTMLIFrameElement::create(HTMLNames::iframeTag, m_parentElement->document());
if (m_attributes.contains("width"))
iframeElement->setAttribute(HTMLNames::widthAttr, AtomicString("100%", AtomicString::ConstructFromLiteral));
@@ -98,7 +98,7 @@
// Disable frame flattening for this iframe.
iframeElement->setAttribute(HTMLNames::scrollingAttr, AtomicString("no", AtomicString::ConstructFromLiteral));
- m_embedShadowElement->appendChild(iframeElement);
+ m_embedShadowElement->appendChild(WTF::move(iframeElement));
return true;
}
diff --git a/Source/WebCore/bindings/objc/DOMHTML.mm b/Source/WebCore/bindings/objc/DOMHTML.mm
index 0de22ce..027595e 100644
--- a/Source/WebCore/bindings/objc/DOMHTML.mm
+++ b/Source/WebCore/bindings/objc/DOMHTML.mm
@@ -152,7 +152,7 @@
- (DOMDocumentFragment *)createDocumentFragmentWithText:(NSString *)text
{
// FIXME: Since this is not a contextual fragment, it won't handle whitespace properly.
- return kit(createFragmentFromText(core(self)->createRange(), text).get());
+ return kit(createFragmentFromText(core(self)->createRange(), text).ptr());
}
@end
diff --git a/Source/WebCore/dom/Attr.cpp b/Source/WebCore/dom/Attr.cpp
index 18570f1..ac7b66f 100644
--- a/Source/WebCore/dom/Attr.cpp
+++ b/Source/WebCore/dom/Attr.cpp
@@ -138,11 +138,11 @@
setValue(v, ec);
}
-RefPtr<Node> Attr::cloneNodeInternal(Document& targetDocument, CloningOperation)
+Ref<Node> Attr::cloneNodeInternal(Document& targetDocument, CloningOperation)
{
- RefPtr<Attr> clone = adoptRef(new Attr(targetDocument, qualifiedName(), value()));
- cloneChildNodes(clone.get());
- return clone.release();
+ Ref<Attr> clone = adoptRef(*new Attr(targetDocument, qualifiedName(), value()));
+ cloneChildNodes(clone);
+ return WTF::move(clone);
}
// DOM Section 1.1.1
diff --git a/Source/WebCore/dom/Attr.h b/Source/WebCore/dom/Attr.h
index c7a94f9..124c6d7a 100644
--- a/Source/WebCore/dom/Attr.h
+++ b/Source/WebCore/dom/Attr.h
@@ -80,7 +80,7 @@
virtual String nodeValue() const override { return value(); }
virtual void setNodeValue(const String&, ExceptionCode&) override;
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
virtual bool isAttributeNode() const override { return true; }
virtual bool childTypeAllowed(NodeType) const override;
diff --git a/Source/WebCore/dom/CDATASection.cpp b/Source/WebCore/dom/CDATASection.cpp
index c59bf1e..afd7322 100644
--- a/Source/WebCore/dom/CDATASection.cpp
+++ b/Source/WebCore/dom/CDATASection.cpp
@@ -46,7 +46,7 @@
return CDATA_SECTION_NODE;
}
-RefPtr<Node> CDATASection::cloneNodeInternal(Document& targetDocument, CloningOperation)
+Ref<Node> CDATASection::cloneNodeInternal(Document& targetDocument, CloningOperation)
{
return create(targetDocument, data());
}
diff --git a/Source/WebCore/dom/CDATASection.h b/Source/WebCore/dom/CDATASection.h
index bf5a61c..d6b9937 100644
--- a/Source/WebCore/dom/CDATASection.h
+++ b/Source/WebCore/dom/CDATASection.h
@@ -36,7 +36,7 @@
virtual String nodeName() const override;
virtual NodeType nodeType() const override;
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
virtual bool childTypeAllowed(NodeType) const override;
virtual Ref<Text> virtualCreate(const String&) override;
};
diff --git a/Source/WebCore/dom/Comment.cpp b/Source/WebCore/dom/Comment.cpp
index 4c74aaf..4125a6e 100644
--- a/Source/WebCore/dom/Comment.cpp
+++ b/Source/WebCore/dom/Comment.cpp
@@ -46,7 +46,7 @@
return COMMENT_NODE;
}
-RefPtr<Node> Comment::cloneNodeInternal(Document& targetDocument, CloningOperation)
+Ref<Node> Comment::cloneNodeInternal(Document& targetDocument, CloningOperation)
{
return create(targetDocument, data());
}
diff --git a/Source/WebCore/dom/Comment.h b/Source/WebCore/dom/Comment.h
index fcac60a..1566323 100644
--- a/Source/WebCore/dom/Comment.h
+++ b/Source/WebCore/dom/Comment.h
@@ -36,7 +36,7 @@
virtual String nodeName() const override;
virtual NodeType nodeType() const override;
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
virtual bool childTypeAllowed(NodeType) const override;
};
diff --git a/Source/WebCore/dom/ContainerNode.cpp b/Source/WebCore/dom/ContainerNode.cpp
index f0631b6..6314175 100644
--- a/Source/WebCore/dom/ContainerNode.cpp
+++ b/Source/WebCore/dom/ContainerNode.cpp
@@ -76,7 +76,7 @@
if (!is<DocumentFragment>(node)) {
nodes.append(node);
if (ContainerNode* oldParent = node.parentNode())
- oldParent->removeChild(&node, ec);
+ oldParent->removeChild(node, ec);
return;
}
@@ -146,13 +146,13 @@
removeDetachedChildren();
}
-static inline bool isChildTypeAllowed(ContainerNode* newParent, Node* child)
+static inline bool isChildTypeAllowed(ContainerNode& newParent, Node& child)
{
- if (!child->isDocumentFragment())
- return newParent->childTypeAllowed(child->nodeType());
+ if (!child.isDocumentFragment())
+ return newParent.childTypeAllowed(child.nodeType());
- for (Node* node = child->firstChild(); node; node = node->nextSibling()) {
- if (!newParent->childTypeAllowed(node->nodeType()))
+ for (Node* node = child.firstChild(); node; node = node->nextSibling()) {
+ if (!newParent.childTypeAllowed(node->nodeType()))
return false;
}
return true;
@@ -169,23 +169,19 @@
#endif
}
-static inline bool containsConsideringHostElements(const Node* newChild, const Node* newParent)
+static inline bool containsConsideringHostElements(const Node& newChild, const Node& newParent)
{
- return (newParent->isInShadowTree() || isInTemplateContent(newParent))
- ? newChild->containsIncludingHostElements(newParent)
- : newChild->contains(newParent);
+ return (newParent.isInShadowTree() || isInTemplateContent(&newParent))
+ ? newChild.containsIncludingHostElements(&newParent)
+ : newChild.contains(&newParent);
}
-static inline ExceptionCode checkAcceptChild(ContainerNode* newParent, Node* newChild, Node* oldChild)
+static inline ExceptionCode checkAcceptChild(ContainerNode& newParent, Node& newChild, Node* oldChild)
{
- // Not mentioned in spec: throw NOT_FOUND_ERR if newChild is null
- if (!newChild)
- return NOT_FOUND_ERR;
-
// Use common case fast path if possible.
- if ((newChild->isElementNode() || newChild->isTextNode()) && newParent->isElementNode()) {
- ASSERT(!newParent->isReadOnlyNode());
- ASSERT(!newParent->isDocumentTypeNode());
+ if ((newChild.isElementNode() || newChild.isTextNode()) && newParent.isElementNode()) {
+ ASSERT(!newParent.isReadOnlyNode());
+ ASSERT(!newParent.isDocumentTypeNode());
ASSERT(isChildTypeAllowed(newParent, newChild));
if (containsConsideringHostElements(newChild, newParent))
return HIERARCHY_REQUEST_ERR;
@@ -193,17 +189,17 @@
}
// This should never happen, but also protect release builds from tree corruption.
- ASSERT(!newChild->isPseudoElement());
- if (newChild->isPseudoElement())
+ ASSERT(!newChild.isPseudoElement());
+ if (newChild.isPseudoElement())
return HIERARCHY_REQUEST_ERR;
- if (newParent->isReadOnlyNode())
+ if (newParent.isReadOnlyNode())
return NO_MODIFICATION_ALLOWED_ERR;
if (containsConsideringHostElements(newChild, newParent))
return HIERARCHY_REQUEST_ERR;
- if (oldChild && is<Document>(*newParent)) {
- if (!downcast<Document>(*newParent).canReplaceChild(newChild, oldChild))
+ if (oldChild && is<Document>(newParent)) {
+ if (!downcast<Document>(newParent).canReplaceChild(newChild, *oldChild))
return HIERARCHY_REQUEST_ERR;
} else if (!isChildTypeAllowed(newParent, newChild))
return HIERARCHY_REQUEST_ERR;
@@ -211,12 +207,12 @@
return 0;
}
-static inline bool checkAcceptChildGuaranteedNodeTypes(ContainerNode* newParent, Node* newChild, ExceptionCode& ec)
+static inline bool checkAcceptChildGuaranteedNodeTypes(ContainerNode& newParent, Node& newChild, ExceptionCode& ec)
{
- ASSERT(!newParent->isReadOnlyNode());
- ASSERT(!newParent->isDocumentTypeNode());
+ ASSERT(!newParent.isReadOnlyNode());
+ ASSERT(!newParent.isDocumentTypeNode());
ASSERT(isChildTypeAllowed(newParent, newChild));
- if (newChild->contains(newParent)) {
+ if (newChild.contains(&newParent)) {
ec = HIERARCHY_REQUEST_ERR;
return false;
}
@@ -224,25 +220,19 @@
return true;
}
-static inline bool checkAddChild(ContainerNode* newParent, Node* newChild, ExceptionCode& ec)
+static inline bool checkAddChild(ContainerNode& newParent, Node& newChild, ExceptionCode& ec)
{
- ec = checkAcceptChild(newParent, newChild, 0);
- if (ec)
- return false;
-
- return true;
+ ec = checkAcceptChild(newParent, newChild, nullptr);
+ return !ec;
}
-static inline bool checkReplaceChild(ContainerNode* newParent, Node* newChild, Node* oldChild, ExceptionCode& ec)
+static inline bool checkReplaceChild(ContainerNode& newParent, Node& newChild, Node& oldChild, ExceptionCode& ec)
{
- ec = checkAcceptChild(newParent, newChild, oldChild);
- if (ec)
- return false;
-
- return true;
+ ec = checkAcceptChild(newParent, newChild, &oldChild);
+ return !ec;
}
-bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& ec)
+bool ContainerNode::insertBefore(Ref<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.
@@ -254,10 +244,10 @@
// insertBefore(node, 0) is equivalent to appendChild(node)
if (!refChild)
- return appendChild(newChild, ec);
+ return appendChild(WTF::move(newChild), ec);
// Make sure adding the new child is OK.
- if (!checkAddChild(this, newChild.get(), ec))
+ if (!checkAddChild(*this, newChild, ec))
return false;
// NOT_FOUND_ERR: Raised if refChild is not a child of this node
@@ -266,20 +256,20 @@
return false;
}
- if (refChild->previousSibling() == newChild || refChild == newChild) // nothing to do
+ if (refChild->previousSibling() == newChild.ptr() || refChild == newChild.ptr()) // nothing to do
return true;
Ref<Node> next(*refChild);
NodeVector targets;
- collectChildrenAndRemoveFromOldParent(*newChild.get(), targets, ec);
+ collectChildrenAndRemoveFromOldParent(newChild, targets, ec);
if (ec)
return false;
if (targets.isEmpty())
return true;
// We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
- if (!checkAcceptChildGuaranteedNodeTypes(this, newChild.get(), ec))
+ if (!checkAcceptChildGuaranteedNodeTypes(*this, newChild, ec))
return false;
InspectorInstrumentation::willInsertDOMNode(document(), *this);
@@ -390,7 +380,7 @@
newChild->setNeedsStyleRecalc(ReconstructRenderTree);
}
-bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode& ec)
+bool ContainerNode::replaceChild(Ref<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.
@@ -400,48 +390,43 @@
ec = 0;
- if (oldChild == newChild) // nothing to do
+ if (&oldChild == newChild.ptr()) // nothing to do
return true;
- if (!oldChild) {
- ec = NOT_FOUND_ERR;
- return false;
- }
-
// Make sure replacing the old child with the new is ok
- if (!checkReplaceChild(this, newChild.get(), oldChild, ec))
+ if (!checkReplaceChild(*this, newChild, oldChild, ec))
return false;
// NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
- if (oldChild->parentNode() != this) {
+ if (oldChild.parentNode() != this) {
ec = NOT_FOUND_ERR;
return false;
}
ChildListMutationScope mutation(*this);
- RefPtr<Node> next = oldChild->nextSibling();
+ RefPtr<Node> next = oldChild.nextSibling();
// Remove the node we're replacing
- Ref<Node> removedChild(*oldChild);
+ Ref<Node> removedChild(oldChild);
removeChild(oldChild, ec);
if (ec)
return false;
- if (next && (next->previousSibling() == newChild || next == newChild)) // nothing to do
+ if (next && (next->previousSibling() == newChild.ptr() || next == newChild.ptr())) // nothing to do
return true;
// Does this one more time because removeChild() fires a MutationEvent.
- if (!checkReplaceChild(this, newChild.get(), oldChild, ec))
+ if (!checkReplaceChild(*this, newChild, oldChild, ec))
return false;
NodeVector targets;
- collectChildrenAndRemoveFromOldParent(*newChild.get(), targets, ec);
+ collectChildrenAndRemoveFromOldParent(newChild, targets, ec);
if (ec)
return false;
// Does this yet another check because collectChildrenAndRemoveFromOldParent() fires a MutationEvent.
- if (!checkReplaceChild(this, newChild.get(), oldChild, ec))
+ if (!checkReplaceChild(*this, newChild, oldChild, ec))
return false;
InspectorInstrumentation::willInsertDOMNode(document(), *this);
@@ -515,7 +500,7 @@
disconnectSubframesIfNeeded(*this, RootAndDescendants);
}
-bool ContainerNode::removeChild(Node* oldChild, ExceptionCode& ec)
+bool ContainerNode::removeChild(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.
@@ -532,12 +517,12 @@
}
// NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
- if (!oldChild || oldChild->parentNode() != this) {
+ if (oldChild.parentNode() != this) {
ec = NOT_FOUND_ERR;
return false;
}
- Ref<Node> child(*oldChild);
+ Ref<Node> child(oldChild);
document().removeFocusedNodeOfSubtree(child.ptr());
@@ -670,7 +655,7 @@
dispatchSubtreeModifiedEvent();
}
-bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec)
+bool ContainerNode::appendChild(Ref<Node>&& newChild, ExceptionCode& ec)
{
Ref<ContainerNode> protect(*this);
@@ -681,14 +666,14 @@
ec = 0;
// Make sure adding the new child is ok
- if (!checkAddChild(this, newChild.get(), ec))
+ if (!checkAddChild(*this, newChild, ec))
return false;
- if (newChild == m_lastChild) // nothing to do
- return newChild;
+ if (newChild.ptr() == m_lastChild) // nothing to do
+ return true;
NodeVector targets;
- collectChildrenAndRemoveFromOldParent(*newChild.get(), targets, ec);
+ collectChildrenAndRemoveFromOldParent(newChild, targets, ec);
if (ec)
return false;
@@ -696,7 +681,7 @@
return true;
// We need this extra check because collectChildrenAndRemoveFromOldParent() can fire mutation events.
- if (!checkAcceptChildGuaranteedNodeTypes(this, newChild.get(), ec))
+ if (!checkAcceptChildGuaranteedNodeTypes(*this, newChild, ec))
return false;
InspectorInstrumentation::willInsertDOMNode(document(), *this);
@@ -759,16 +744,16 @@
invalidateNodeListAndCollectionCachesInAncestors();
}
-void ContainerNode::cloneChildNodes(ContainerNode* clone)
+void ContainerNode::cloneChildNodes(ContainerNode& clone)
{
ExceptionCode ec = 0;
- Document& targetDocument = clone->document();
+ Document& targetDocument = clone.document();
for (Node* child = firstChild(); child && !ec; child = child->nextSibling()) {
- RefPtr<Node> clonedChild = child->cloneNodeInternal(targetDocument, CloningOperation::SelfWithTemplateContent);
- clone->appendChild(clonedChild, ec);
+ Ref<Node> clonedChild = child->cloneNodeInternal(targetDocument, CloningOperation::SelfWithTemplateContent);
+ clone.appendChild(clonedChild.copyRef(), ec);
- if (!ec && is<ContainerNode>(child))
- downcast<ContainerNode>(child)->cloneChildNodes(downcast<ContainerNode>(clonedChild.get()));
+ if (!ec && is<ContainerNode>(*child))
+ downcast<ContainerNode>(*child).cloneChildNodes(downcast<ContainerNode>(clonedChild.get()));
}
}
@@ -947,7 +932,7 @@
if (ec || !node)
return;
- appendChild(node.release(), ec);
+ appendChild(node.releaseNonNull(), ec);
}
void ContainerNode::prepend(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec)
@@ -956,7 +941,7 @@
if (ec || !node)
return;
- insertBefore(node.release(), firstChild(), ec);
+ insertBefore(node.releaseNonNull(), firstChild(), ec);
}
HTMLCollection* ContainerNode::cachedHTMLCollection(CollectionType type)
diff --git a/Source/WebCore/dom/ContainerNode.h b/Source/WebCore/dom/ContainerNode.h
index 0452400..a6b10a7 100644
--- a/Source/WebCore/dom/ContainerNode.h
+++ b/Source/WebCore/dom/ContainerNode.h
@@ -102,10 +102,10 @@
WEBCORE_EXPORT unsigned countChildNodes() const;
WEBCORE_EXPORT Node* traverseToChildAt(unsigned) const;
- bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
- bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
- WEBCORE_EXPORT bool removeChild(Node* child, ExceptionCode& = ASSERT_NO_EXCEPTION);
- WEBCORE_EXPORT bool appendChild(PassRefPtr<Node> newChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
+ bool insertBefore(Ref<Node>&& newChild, Node* refChild, ExceptionCode& = ASSERT_NO_EXCEPTION);
+ bool replaceChild(Ref<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);
// These methods are only used during parsing.
// They don't send DOM mutation events or handle reparenting.
@@ -117,7 +117,7 @@
void removeChildren();
void takeAllChildrenFrom(ContainerNode*);
- void cloneChildNodes(ContainerNode* clone);
+ void cloneChildNodes(ContainerNode& clone);
enum ChildChangeType { ElementInserted, ElementRemoved, TextInserted, TextRemoved, TextChanged, AllChildrenRemoved, NonContentsChildChanged };
enum ChildChangeSource { ChildChangeSourceParser, ChildChangeSourceAPI };
diff --git a/Source/WebCore/dom/DOMImplementation.cpp b/Source/WebCore/dom/DOMImplementation.cpp
index a4a3f8d..633d291 100644
--- a/Source/WebCore/dom/DOMImplementation.cpp
+++ b/Source/WebCore/dom/DOMImplementation.cpp
@@ -231,9 +231,9 @@
}
if (doctype)
- doc->appendChild(doctype);
+ doc->appendChild(*doctype);
if (documentElement)
- doc->appendChild(documentElement.release());
+ doc->appendChild(documentElement.releaseNonNull());
return doc;
}
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index d0cdc57..676bdd8 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -1009,7 +1009,7 @@
}
}
if (source->parentNode()) {
- source->parentNode()->removeChild(source.get(), ec);
+ source->parentNode()->removeChild(*source, ec);
if (ec)
return nullptr;
}
@@ -1547,7 +1547,7 @@
if (!headElement)
return;
m_titleElement = createElement(titleTag, false);
- headElement->appendChild(m_titleElement, ASSERT_NO_EXCEPTION);
+ headElement->appendChild(*m_titleElement, ASSERT_NO_EXCEPTION);
}
// The DOM API has no method of specifying direction, so assume LTR.
@@ -2518,11 +2518,10 @@
newBody = downcast<HTMLElement>(node.get());
}
- HTMLElement* b = bodyOrFrameset();
- if (!b)
- documentElement()->appendChild(newBody.release(), ec);
+ if (auto* body = bodyOrFrameset())
+ documentElement()->replaceChild(newBody.releaseNonNull(), *body, ec);
else
- documentElement()->replaceChild(newBody.release(), b, ec);
+ documentElement()->appendChild(newBody.releaseNonNull(), ec);
}
HTMLHeadElement* Document::head()
@@ -3326,13 +3325,9 @@
return false;
}
-bool Document::canReplaceChild(Node* newChild, Node* oldChild)
+bool Document::canReplaceChild(Node& newChild, Node& oldChild)
{
- if (!oldChild)
- // ContainerNode::replaceChild will raise a NOT_FOUND_ERR.
- return true;
-
- if (oldChild->nodeType() == newChild->nodeType())
+ if (oldChild.nodeType() == newChild.nodeType())
return true;
int numDoctypes = 0;
@@ -3341,7 +3336,7 @@
// First, check how many doctypes and elements we have, not counting
// the child we're about to remove.
for (Node* c = firstChild(); c; c = c->nextSibling()) {
- if (c == oldChild)
+ if (c == &oldChild)
continue;
switch (c->nodeType()) {
@@ -3357,8 +3352,8 @@
}
// Then, see how many doctypes and elements might be added by the new child.
- if (newChild->isDocumentFragment()) {
- for (Node* c = newChild->firstChild(); c; c = c->nextSibling()) {
+ if (newChild.isDocumentFragment()) {
+ for (Node* c = newChild.firstChild(); c; c = c->nextSibling()) {
switch (c->nodeType()) {
case ATTRIBUTE_NODE:
case CDATA_SECTION_NODE:
@@ -3381,7 +3376,7 @@
}
}
} else {
- switch (newChild->nodeType()) {
+ switch (newChild.nodeType()) {
case ATTRIBUTE_NODE:
case CDATA_SECTION_NODE:
case DOCUMENT_FRAGMENT_NODE:
@@ -3409,7 +3404,7 @@
return true;
}
-RefPtr<Node> Document::cloneNodeInternal(Document&, CloningOperation type)
+Ref<Node> Document::cloneNodeInternal(Document&, CloningOperation type)
{
Ref<Document> clone = cloneDocumentWithoutChildren();
clone->cloneDataFromDocument(*this);
@@ -3418,7 +3413,7 @@
case CloningOperation::SelfWithTemplateContent:
break;
case CloningOperation::Everything:
- cloneChildNodes(clone.ptr());
+ cloneChildNodes(clone);
break;
}
return WTF::move(clone);
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h
index 4f09b7c..e0ad1bc 100644
--- a/Source/WebCore/dom/Document.h
+++ b/Source/WebCore/dom/Document.h
@@ -746,7 +746,7 @@
void nodeChildrenWillBeRemoved(ContainerNode&);
// nodeWillBeRemoved is only safe when removing one node at a time.
void nodeWillBeRemoved(Node&);
- bool canReplaceChild(Node* newChild, Node* oldChild);
+ bool canReplaceChild(Node& newChild, Node& oldChild);
void textInserted(Node*, unsigned offset, unsigned length);
void textRemoved(Node*, unsigned offset, unsigned length);
@@ -1310,7 +1310,7 @@
virtual String nodeName() const override final;
virtual NodeType nodeType() const override final;
virtual bool childTypeAllowed(NodeType) const override final;
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override final;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override final;
void cloneDataFromDocument(const Document&);
virtual void refScriptExecutionContext() override final { ref(); }
diff --git a/Source/WebCore/dom/DocumentFragment.cpp b/Source/WebCore/dom/DocumentFragment.cpp
index 4fab58e..f9b38a0 100644
--- a/Source/WebCore/dom/DocumentFragment.cpp
+++ b/Source/WebCore/dom/DocumentFragment.cpp
@@ -67,18 +67,18 @@
}
}
-RefPtr<Node> DocumentFragment::cloneNodeInternal(Document& targetDocument, CloningOperation type)
+Ref<Node> DocumentFragment::cloneNodeInternal(Document& targetDocument, CloningOperation type)
{
- RefPtr<DocumentFragment> clone = create(targetDocument);
+ Ref<DocumentFragment> clone = create(targetDocument);
switch (type) {
case CloningOperation::OnlySelf:
case CloningOperation::SelfWithTemplateContent:
break;
case CloningOperation::Everything:
- cloneChildNodes(clone.get());
+ cloneChildNodes(clone);
break;
}
- return clone;
+ return WTF::move(clone);
}
void DocumentFragment::parseHTML(const String& source, Element* contextElement, ParserContentPolicy parserContentPolicy)
diff --git a/Source/WebCore/dom/DocumentFragment.h b/Source/WebCore/dom/DocumentFragment.h
index d07e034..6eb1ed6 100644
--- a/Source/WebCore/dom/DocumentFragment.h
+++ b/Source/WebCore/dom/DocumentFragment.h
@@ -48,7 +48,7 @@
private:
virtual NodeType nodeType() const override final;
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
virtual bool childTypeAllowed(NodeType) const override;
};
diff --git a/Source/WebCore/dom/DocumentType.cpp b/Source/WebCore/dom/DocumentType.cpp
index 67e3d53..c19d018 100644
--- a/Source/WebCore/dom/DocumentType.cpp
+++ b/Source/WebCore/dom/DocumentType.cpp
@@ -51,7 +51,7 @@
return DOCUMENT_TYPE_NODE;
}
-RefPtr<Node> DocumentType::cloneNodeInternal(Document& documentTarget, CloningOperation)
+Ref<Node> DocumentType::cloneNodeInternal(Document& documentTarget, CloningOperation)
{
return create(documentTarget, m_name, m_publicId, m_systemId);
}
diff --git a/Source/WebCore/dom/DocumentType.h b/Source/WebCore/dom/DocumentType.h
index c7a1d9b..c79c0ce 100644
--- a/Source/WebCore/dom/DocumentType.h
+++ b/Source/WebCore/dom/DocumentType.h
@@ -52,7 +52,7 @@
virtual URL baseURI() const override;
virtual String nodeName() const override;
virtual NodeType nodeType() const override;
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
String m_name;
String m_publicId;
diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp
index 675000a..3a89061 100644
--- a/Source/WebCore/dom/Element.cpp
+++ b/Source/WebCore/dom/Element.cpp
@@ -312,38 +312,37 @@
EventDispatcher::dispatchSimulatedClick(this, underlyingEvent, eventOptions, visualOptions);
}
-RefPtr<Node> Element::cloneNodeInternal(Document& targetDocument, CloningOperation type)
+Ref<Node> Element::cloneNodeInternal(Document& targetDocument, CloningOperation type)
{
switch (type) {
case CloningOperation::OnlySelf:
case CloningOperation::SelfWithTemplateContent:
return cloneElementWithoutChildren(targetDocument);
case CloningOperation::Everything:
- return cloneElementWithChildren(targetDocument);
+ break;
}
- ASSERT_NOT_REACHED();
- return nullptr;
+ return cloneElementWithChildren(targetDocument);
}
-RefPtr<Element> Element::cloneElementWithChildren(Document& targetDocument)
+Ref<Element> Element::cloneElementWithChildren(Document& targetDocument)
{
- RefPtr<Element> clone = cloneElementWithoutChildren(targetDocument);
- cloneChildNodes(clone.get());
- return clone.release();
+ Ref<Element> clone = cloneElementWithoutChildren(targetDocument);
+ cloneChildNodes(clone);
+ return clone;
}
-RefPtr<Element> Element::cloneElementWithoutChildren(Document& targetDocument)
+Ref<Element> Element::cloneElementWithoutChildren(Document& targetDocument)
{
- RefPtr<Element> clone = cloneElementWithoutAttributesAndChildren(targetDocument);
+ Ref<Element> clone = cloneElementWithoutAttributesAndChildren(targetDocument);
// This will catch HTML elements in the wrong namespace that are not correctly copied.
// This is a sanity check as HTML overloads some of the DOM methods.
ASSERT(isHTMLElement() == clone->isHTMLElement());
clone->cloneDataFromElement(*this);
- return clone.release();
+ return clone;
}
-RefPtr<Element> Element::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
+Ref<Element> Element::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
{
return targetDocument.createElement(tagQName(), false);
}
@@ -2319,7 +2318,7 @@
if (ec)
return;
- parent->replaceChild(fragment.release(), this, ec);
+ parent->replaceChild(fragment.releaseNonNull(), *this, ec);
RefPtr<Node> node = next ? next->previousSibling() : nullptr;
if (!ec && is<Text>(node.get()))
mergeWithNextTextNode(downcast<Text>(*node), ec);
@@ -2338,7 +2337,7 @@
container = downcast<HTMLTemplateElement>(*this).content();
#endif
- replaceChildrenWithFragment(*container, fragment.release(), ec);
+ replaceChildrenWithFragment(*container, fragment.releaseNonNull(), ec);
}
}
diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h
index 1e60703..04810e1 100644
--- a/Source/WebCore/dom/Element.h
+++ b/Source/WebCore/dom/Element.h
@@ -201,8 +201,8 @@
virtual String nodeName() const override;
- RefPtr<Element> cloneElementWithChildren(Document&);
- RefPtr<Element> cloneElementWithoutChildren(Document&);
+ Ref<Element> cloneElementWithChildren(Document&);
+ Ref<Element> cloneElementWithoutChildren(Document&);
void normalizeAttributes();
String nodeNamePreservingCase() const;
@@ -563,8 +563,8 @@
// cloneNode is private so that non-virtual cloneElementWithChildren and cloneElementWithoutChildren
// are used instead.
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
- virtual RefPtr<Element> cloneElementWithoutAttributesAndChildren(Document&);
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Element> cloneElementWithoutAttributesAndChildren(Document&);
void addShadowRoot(Ref<ShadowRoot>&&);
void removeShadowRoot();
diff --git a/Source/WebCore/dom/EntityReference.cpp b/Source/WebCore/dom/EntityReference.cpp
index a2ff63b..7e91a46 100644
--- a/Source/WebCore/dom/EntityReference.cpp
+++ b/Source/WebCore/dom/EntityReference.cpp
@@ -46,7 +46,7 @@
return ENTITY_REFERENCE_NODE;
}
-RefPtr<Node> EntityReference::cloneNodeInternal(Document& targetDocument, CloningOperation)
+Ref<Node> EntityReference::cloneNodeInternal(Document& targetDocument, CloningOperation)
{
return create(targetDocument, m_entityName);
}
diff --git a/Source/WebCore/dom/EntityReference.h b/Source/WebCore/dom/EntityReference.h
index 03f43cd..86dfeb3 100644
--- a/Source/WebCore/dom/EntityReference.h
+++ b/Source/WebCore/dom/EntityReference.h
@@ -35,7 +35,7 @@
virtual String nodeName() const override;
virtual NodeType nodeType() const override;
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
String m_entityName;
};
diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp
index 8aa4a1f..2f8c6f7 100644
--- a/Source/WebCore/dom/Node.cpp
+++ b/Source/WebCore/dom/Node.cpp
@@ -429,38 +429,54 @@
bool Node::insertBefore(PassRefPtr<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)
{
+ 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)
{
+ 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)
{
+ 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)
@@ -515,7 +531,7 @@
else
viablePreviousSibling = parent->firstChild();
- parent->insertBefore(node.release(), viablePreviousSibling.get(), ec);
+ parent->insertBefore(node.releaseNonNull(), viablePreviousSibling.get(), ec);
}
void Node::after(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec)
@@ -531,7 +547,7 @@
if (ec || !node)
return;
- parent->insertBefore(node.release(), viableNextSibling.get(), ec);
+ parent->insertBefore(node.releaseNonNull(), viableNextSibling.get(), ec);
}
void Node::replaceWith(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec)
@@ -548,15 +564,15 @@
return;
if (parentNode() == parent)
- parent->replaceChild(node.release(), this, ec);
+ parent->replaceChild(node.releaseNonNull(), *this, ec);
else
- parent->insertBefore(node.release(), viableNextSibling.get(), ec);
+ parent->insertBefore(node.releaseNonNull(), viableNextSibling.get(), ec);
}
void Node::remove(ExceptionCode& ec)
{
if (ContainerNode* parent = parentNode())
- parent->removeChild(this, ec);
+ parent->removeChild(*this, ec);
}
void Node::normalize()
diff --git a/Source/WebCore/dom/Node.h b/Source/WebCore/dom/Node.h
index 18487a6..4a46a79 100644
--- a/Source/WebCore/dom/Node.h
+++ b/Source/WebCore/dom/Node.h
@@ -201,8 +201,8 @@
SelfWithTemplateContent,
Everything,
};
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) = 0;
- RefPtr<Node> cloneNode(bool deep) { return cloneNodeInternal(document(), deep ? CloningOperation::Everything : CloningOperation::OnlySelf); }
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) = 0;
+ Ref<Node> cloneNode(bool deep) { return cloneNodeInternal(document(), deep ? CloningOperation::Everything : CloningOperation::OnlySelf); }
virtual const AtomicString& localName() const;
virtual const AtomicString& namespaceURI() const;
diff --git a/Source/WebCore/dom/ProcessingInstruction.cpp b/Source/WebCore/dom/ProcessingInstruction.cpp
index b343ca3..30009b7 100644
--- a/Source/WebCore/dom/ProcessingInstruction.cpp
+++ b/Source/WebCore/dom/ProcessingInstruction.cpp
@@ -79,7 +79,7 @@
return PROCESSING_INSTRUCTION_NODE;
}
-RefPtr<Node> ProcessingInstruction::cloneNodeInternal(Document& targetDocument, CloningOperation)
+Ref<Node> ProcessingInstruction::cloneNodeInternal(Document& targetDocument, CloningOperation)
{
// FIXME: Is it a problem that this does not copy m_localHref?
// What about other data members?
diff --git a/Source/WebCore/dom/ProcessingInstruction.h b/Source/WebCore/dom/ProcessingInstruction.h
index 21fd9e9..efa905b 100644
--- a/Source/WebCore/dom/ProcessingInstruction.h
+++ b/Source/WebCore/dom/ProcessingInstruction.h
@@ -58,7 +58,7 @@
virtual String nodeName() const override;
virtual NodeType nodeType() const override;
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
virtual InsertionNotificationRequest insertedInto(ContainerNode&) override;
virtual void removedFrom(ContainerNode&) override;
diff --git a/Source/WebCore/dom/Range.cpp b/Source/WebCore/dom/Range.cpp
index 4d227da..26508cf 100644
--- a/Source/WebCore/dom/Range.cpp
+++ b/Source/WebCore/dom/Range.cpp
@@ -665,7 +665,7 @@
// (or just delete the stuff in between)
if ((action == Extract || action == Clone) && leftContents)
- fragment->appendChild(leftContents, ec);
+ fragment->appendChild(*leftContents, ec);
if (processStart) {
NodeVector nodes;
@@ -675,7 +675,7 @@
}
if ((action == Extract || action == Clone) && rightContents)
- fragment->appendChild(rightContents, ec);
+ fragment->appendChild(*rightContents, ec);
return fragment;
}
@@ -702,7 +702,7 @@
endOffset = std::min(endOffset, static_cast<CharacterData*>(container)->length());
startOffset = std::min(startOffset, endOffset);
if (action == Extract || action == Clone) {
- RefPtr<CharacterData> c = static_pointer_cast<CharacterData>(container->cloneNode(true));
+ RefPtr<CharacterData> c = static_cast<CharacterData*>(container->cloneNode(true).ptr());
deleteCharacterData(c, startOffset, endOffset, ec);
if (fragment) {
result = fragment;
@@ -717,7 +717,7 @@
endOffset = std::min(endOffset, static_cast<ProcessingInstruction*>(container)->data().length());
startOffset = std::min(startOffset, endOffset);
if (action == Extract || action == Clone) {
- RefPtr<ProcessingInstruction> c = static_pointer_cast<ProcessingInstruction>(container->cloneNode(true));
+ RefPtr<ProcessingInstruction> c = static_cast<ProcessingInstruction*>(container->cloneNode(true).ptr());
c->setData(c->data().substring(startOffset, endOffset - startOffset), ec);
if (fragment) {
result = fragment;
@@ -935,7 +935,7 @@
return;
container = &startContainer();
- container->parentNode()->insertBefore(newNode.release(), newText.get(), ec);
+ container->parentNode()->insertBefore(newNode.releaseNonNull(), newText.get(), ec);
if (ec)
return;
@@ -1303,7 +1303,7 @@
ec = 0;
while (Node* n = newParent->firstChild()) {
- downcast<ContainerNode>(*newParent).removeChild(n, ec);
+ downcast<ContainerNode>(*newParent).removeChild(*n, ec);
if (ec)
return;
}
diff --git a/Source/WebCore/dom/ShadowRoot.cpp b/Source/WebCore/dom/ShadowRoot.cpp
index a12257f..886100d 100644
--- a/Source/WebCore/dom/ShadowRoot.cpp
+++ b/Source/WebCore/dom/ShadowRoot.cpp
@@ -92,7 +92,7 @@
}
if (RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, host(), AllowScriptingContent, ec))
- replaceChildrenWithFragment(*this, fragment.release(), ec);
+ replaceChildrenWithFragment(*this, fragment.releaseNonNull(), ec);
}
bool ShadowRoot::childTypeAllowed(NodeType type) const
@@ -131,9 +131,10 @@
invalidateDistribution();
}
-RefPtr<Node> ShadowRoot::cloneNodeInternal(Document&, CloningOperation)
+Ref<Node> ShadowRoot::cloneNodeInternal(Document&, CloningOperation)
{
- return nullptr; // ShadowRoots should never be cloned.
+ RELEASE_ASSERT_NOT_REACHED();
+ return *static_cast<Node*>(nullptr); // ShadowRoots should never be cloned.
}
void ShadowRoot::removeAllEventListeners()
diff --git a/Source/WebCore/dom/ShadowRoot.h b/Source/WebCore/dom/ShadowRoot.h
index 6d311fd..631608a 100644
--- a/Source/WebCore/dom/ShadowRoot.h
+++ b/Source/WebCore/dom/ShadowRoot.h
@@ -76,7 +76,7 @@
virtual bool childTypeAllowed(NodeType) const override;
virtual void childrenChanged(const ChildChange&) override;
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
// FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=88834
bool isOrphan() const { return !m_host; }
diff --git a/Source/WebCore/dom/Text.cpp b/Source/WebCore/dom/Text.cpp
index b1171d7..6c4c89d 100644
--- a/Source/WebCore/dom/Text.cpp
+++ b/Source/WebCore/dom/Text.cpp
@@ -73,7 +73,7 @@
dispatchModifiedEvent(oldStr);
if (parentNode())
- parentNode()->insertBefore(newText.ptr(), nextSibling(), ec);
+ parentNode()->insertBefore(newText.copyRef(), nextSibling(), ec);
if (ec)
return 0;
@@ -132,28 +132,28 @@
RefPtr<Text> protectedThis(this); // Mutation event handlers could cause our last ref to go away
RefPtr<ContainerNode> parent = parentNode(); // Protect against mutation handlers moving this node during traversal
for (RefPtr<Node> n = startText; n && n != this && n->isTextNode() && n->parentNode() == parent;) {
- RefPtr<Node> nodeToRemove(n.release());
+ Ref<Node> nodeToRemove(n.releaseNonNull());
n = nodeToRemove->nextSibling();
- parent->removeChild(nodeToRemove.get(), IGNORE_EXCEPTION);
+ parent->removeChild(WTF::move(nodeToRemove), IGNORE_EXCEPTION);
}
if (this != endText) {
Node* onePastEndText = endText->nextSibling();
for (RefPtr<Node> n = nextSibling(); n && n != onePastEndText && n->isTextNode() && n->parentNode() == parent;) {
- RefPtr<Node> nodeToRemove(n.release());
+ Ref<Node> nodeToRemove(n.releaseNonNull());
n = nodeToRemove->nextSibling();
- parent->removeChild(nodeToRemove.get(), IGNORE_EXCEPTION);
+ parent->removeChild(WTF::move(nodeToRemove), IGNORE_EXCEPTION);
}
}
if (newText.isEmpty()) {
if (parent && parentNode() == parent)
- parent->removeChild(this, IGNORE_EXCEPTION);
- return 0;
+ parent->removeChild(*this, IGNORE_EXCEPTION);
+ return nullptr;
}
setData(newText, IGNORE_EXCEPTION);
- return protectedThis.release();
+ return protectedThis;
}
String Text::nodeName() const
@@ -166,7 +166,7 @@
return TEXT_NODE;
}
-RefPtr<Node> Text::cloneNodeInternal(Document& targetDocument, CloningOperation)
+Ref<Node> Text::cloneNodeInternal(Document& targetDocument, CloningOperation)
{
return create(targetDocument, data());
}
diff --git a/Source/WebCore/dom/Text.h b/Source/WebCore/dom/Text.h
index a967436..efd6bde 100644
--- a/Source/WebCore/dom/Text.h
+++ b/Source/WebCore/dom/Text.h
@@ -62,7 +62,7 @@
private:
virtual String nodeName() const override;
virtual NodeType nodeType() const override;
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
virtual bool childTypeAllowed(NodeType) const override;
virtual Ref<Text> virtualCreate(const String&);
diff --git a/Source/WebCore/editing/AppendNodeCommand.cpp b/Source/WebCore/editing/AppendNodeCommand.cpp
index 6a8d9e9..b935312 100644
--- a/Source/WebCore/editing/AppendNodeCommand.cpp
+++ b/Source/WebCore/editing/AppendNodeCommand.cpp
@@ -35,13 +35,12 @@
namespace WebCore {
-AppendNodeCommand::AppendNodeCommand(PassRefPtr<ContainerNode> parent, PassRefPtr<Node> node, EditAction editingAction)
+AppendNodeCommand::AppendNodeCommand(PassRefPtr<ContainerNode> parent, Ref<Node>&& node, EditAction editingAction)
: SimpleEditCommand(parent->document(), editingAction)
, m_parent(parent)
- , m_node(node)
+ , m_node(WTF::move(node))
{
ASSERT(m_parent);
- ASSERT(m_node);
ASSERT(!m_node->parentNode());
ASSERT(m_parent->hasEditableStyle() || !m_parent->renderer());
@@ -68,10 +67,10 @@
if (!m_parent->hasEditableStyle() && m_parent->renderer())
return;
- m_parent->appendChild(m_node.get(), IGNORE_EXCEPTION);
+ m_parent->appendChild(m_node.copyRef(), IGNORE_EXCEPTION);
if (shouldPostAccessibilityNotification())
- sendAXTextChangedIgnoringLineBreaks(m_node.get(), applyEditType());
+ sendAXTextChangedIgnoringLineBreaks(m_node.ptr(), applyEditType());
}
void AppendNodeCommand::doUnapply()
@@ -81,7 +80,7 @@
// Need to notify this before actually deleting the text
if (shouldPostAccessibilityNotification())
- sendAXTextChangedIgnoringLineBreaks(m_node.get(), unapplyEditType());
+ sendAXTextChangedIgnoringLineBreaks(m_node.ptr(), unapplyEditType());
m_node->remove(IGNORE_EXCEPTION);
}
@@ -90,7 +89,7 @@
void AppendNodeCommand::getNodesInCommand(HashSet<Node*>& nodes)
{
addNodeAndDescendants(m_parent.get(), nodes);
- addNodeAndDescendants(m_node.get(), nodes);
+ addNodeAndDescendants(m_node.ptr(), nodes);
}
#endif
diff --git a/Source/WebCore/editing/AppendNodeCommand.h b/Source/WebCore/editing/AppendNodeCommand.h
index f782975..640fa75 100644
--- a/Source/WebCore/editing/AppendNodeCommand.h
+++ b/Source/WebCore/editing/AppendNodeCommand.h
@@ -32,13 +32,13 @@
class AppendNodeCommand : public SimpleEditCommand {
public:
- static Ref<AppendNodeCommand> create(PassRefPtr<ContainerNode> parent, PassRefPtr<Node> node, EditAction editingAction)
+ static Ref<AppendNodeCommand> create(PassRefPtr<ContainerNode> parent, Ref<Node>&& node, EditAction editingAction)
{
- return adoptRef(*new AppendNodeCommand(parent, node, editingAction));
+ return adoptRef(*new AppendNodeCommand(parent, WTF::move(node), editingAction));
}
private:
- AppendNodeCommand(PassRefPtr<ContainerNode> parent, PassRefPtr<Node>, EditAction);
+ AppendNodeCommand(PassRefPtr<ContainerNode> parent, Ref<Node>&&, EditAction);
virtual void doApply() override;
virtual void doUnapply() override;
@@ -48,7 +48,7 @@
#endif
RefPtr<ContainerNode> m_parent;
- RefPtr<Node> m_node;
+ Ref<Node> m_node;
};
} // namespace WebCore
diff --git a/Source/WebCore/editing/CompositeEditCommand.cpp b/Source/WebCore/editing/CompositeEditCommand.cpp
index 3d77942..5d9d36f 100644
--- a/Source/WebCore/editing/CompositeEditCommand.cpp
+++ b/Source/WebCore/editing/CompositeEditCommand.cpp
@@ -395,7 +395,8 @@
void CompositeEditCommand::appendNode(PassRefPtr<Node> node, PassRefPtr<ContainerNode> parent)
{
ASSERT(canHaveChildrenForEditing(parent.get()));
- applyCommandToComposite(AppendNodeCommand::create(parent, node, editingAction()));
+ ASSERT(node);
+ applyCommandToComposite(AppendNodeCommand::create(parent, *node, editingAction()));
}
void CompositeEditCommand::removeChildrenInRange(PassRefPtr<Node> node, unsigned from, unsigned to)
@@ -414,7 +415,7 @@
{
if (!node || !node->nonShadowBoundaryParentNode())
return;
- applyCommandToComposite(RemoveNodeCommand::create(node, shouldAssumeContentIsAlwaysEditable));
+ applyCommandToComposite(RemoveNodeCommand::create(*node, shouldAssumeContentIsAlwaysEditable));
}
void CompositeEditCommand::removeNodePreservingChildren(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
@@ -1541,7 +1542,7 @@
return node.release();
}
-PassRefPtr<Element> createBlockPlaceholderElement(Document& document)
+Ref<Element> createBlockPlaceholderElement(Document& document)
{
return document.createElement(brTag, false);
}
diff --git a/Source/WebCore/editing/DeleteSelectionCommand.cpp b/Source/WebCore/editing/DeleteSelectionCommand.cpp
index c6491d2..5609971 100644
--- a/Source/WebCore/editing/DeleteSelectionCommand.cpp
+++ b/Source/WebCore/editing/DeleteSelectionCommand.cpp
@@ -632,7 +632,7 @@
// We need to merge into m_upstreamStart's block, but it's been emptied out and collapsed by deletion.
if (!mergeDestination.deepEquivalent().deprecatedNode() || !mergeDestination.deepEquivalent().deprecatedNode()->isDescendantOf(enclosingBlock(m_upstreamStart.containerNode())) || m_startsAtEmptyLine) {
- insertNodeAt(createBreakElement(document()).get(), m_upstreamStart);
+ insertNodeAt(createBreakElement(document()).ptr(), m_upstreamStart);
mergeDestination = VisiblePosition(m_upstreamStart);
}
@@ -855,7 +855,7 @@
removePreviouslySelectedEmptyTableRows();
- RefPtr<Node> placeholder = m_needPlaceholder ? createBreakElement(document()).get() : 0;
+ RefPtr<Node> placeholder = m_needPlaceholder ? createBreakElement(document()).ptr() : nullptr;
if (placeholder) {
if (m_sanitizeMarkup)
diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp
index 148e35c..44b2ac7 100644
--- a/Source/WebCore/editing/Editor.cpp
+++ b/Source/WebCore/editing/Editor.cpp
@@ -613,8 +613,8 @@
RefPtr<Range> context = document().createRange();
context->selectNodeContents(elem, ec);
- RefPtr<DocumentFragment> fragment = createFragmentFromText(*context.get(), text);
- elem->appendChild(fragment, ec);
+ Ref<DocumentFragment> fragment = createFragmentFromText(*context.get(), text);
+ elem->appendChild(WTF::move(fragment), ec);
// restore element to document
if (parent) {
diff --git a/Source/WebCore/editing/EditorCommand.cpp b/Source/WebCore/editing/EditorCommand.cpp
index 0f8f880..12cdd21 100644
--- a/Source/WebCore/editing/EditorCommand.cpp
+++ b/Source/WebCore/editing/EditorCommand.cpp
@@ -165,11 +165,11 @@
return true;
}
-static bool executeInsertNode(Frame& frame, PassRefPtr<Node> content)
+static bool executeInsertNode(Frame& frame, Ref<Node>&& content)
{
RefPtr<DocumentFragment> fragment = DocumentFragment::create(*frame.document());
ExceptionCode ec = 0;
- fragment->appendChild(content, ec);
+ fragment->appendChild(WTF::move(content), ec);
if (ec)
return false;
return executeInsertFragment(frame, fragment.release());
@@ -464,10 +464,10 @@
static bool executeInsertHorizontalRule(Frame& frame, Event*, EditorCommandSource, const String& value)
{
- RefPtr<HTMLHRElement> rule = HTMLHRElement::create(*frame.document());
+ Ref<HTMLHRElement> rule = HTMLHRElement::create(*frame.document());
if (!value.isEmpty())
rule->setIdAttribute(value);
- return executeInsertNode(frame, rule.release());
+ return executeInsertNode(frame, WTF::move(rule));
}
static bool executeInsertHTML(Frame& frame, Event*, EditorCommandSource, const String& value)
@@ -478,9 +478,9 @@
static bool executeInsertImage(Frame& frame, Event*, EditorCommandSource, const String& value)
{
// FIXME: If userInterface is true, we should display a dialog box and let the user choose a local image.
- RefPtr<HTMLImageElement> image = HTMLImageElement::create(*frame.document());
+ Ref<HTMLImageElement> image = HTMLImageElement::create(*frame.document());
image->setSrc(value);
- return executeInsertNode(frame, image.release());
+ return executeInsertNode(frame, WTF::move(image));
}
static bool executeInsertLineBreak(Frame& frame, Event* event, EditorCommandSource source, const String&)
diff --git a/Source/WebCore/editing/InsertLineBreakCommand.cpp b/Source/WebCore/editing/InsertLineBreakCommand.cpp
index 6ee21d9..25ab071 100644
--- a/Source/WebCore/editing/InsertLineBreakCommand.cpp
+++ b/Source/WebCore/editing/InsertLineBreakCommand.cpp
@@ -129,7 +129,7 @@
// Insert an extra br or '\n' if the just inserted one collapsed.
if (!isStartOfParagraph(positionBeforeNode(nodeToInsert.get())))
- insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get());
+ insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert.get());
setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInsert.get()), DOWNSTREAM, endingSelection().isDirectional()));
// If we're inserting after all of the rendered text in a text node, or into a non-text node,
diff --git a/Source/WebCore/editing/InsertNodeBeforeCommand.cpp b/Source/WebCore/editing/InsertNodeBeforeCommand.cpp
index fa14d07..50f6545 100644
--- a/Source/WebCore/editing/InsertNodeBeforeCommand.cpp
+++ b/Source/WebCore/editing/InsertNodeBeforeCommand.cpp
@@ -55,7 +55,7 @@
return;
ASSERT(isEditableNode(*parent));
- parent->insertBefore(m_insertChild.get(), m_refChild.get(), IGNORE_EXCEPTION);
+ parent->insertBefore(*m_insertChild, m_refChild.get(), IGNORE_EXCEPTION);
if (shouldPostAccessibilityNotification()) {
Position position = is<Text>(m_insertChild.get()) ? Position(downcast<Text>(m_insertChild.get()), 0) : createLegacyEditingPosition(m_insertChild.get(), 0);
diff --git a/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp b/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp
index 7dd0160..1503229 100644
--- a/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp
+++ b/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp
@@ -368,7 +368,7 @@
// created. All of the nodes, starting at visiblePos, are about to be added to the new paragraph
// element. If the first node to be inserted won't be one that will hold an empty line open, add a br.
if (isEndOfParagraph(visiblePos) && !lineBreakExistsAtVisiblePosition(visiblePos))
- appendNode(createBreakElement(document()).get(), blockToInsert.get());
+ appendNode(createBreakElement(document()), blockToInsert.get());
// Move the start node and the siblings of the start node.
if (VisiblePosition(insertionPosition) != VisiblePosition(positionBeforeNode(blockToInsert.get()))) {
diff --git a/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp b/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp
index 4651884..4a59ef6 100644
--- a/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp
+++ b/Source/WebCore/editing/MergeIdenticalElementsCommand.cpp
@@ -47,13 +47,13 @@
m_atChild = m_element2->firstChild();
- Vector<RefPtr<Node>> children;
+ Vector<Ref<Node>> children;
for (Node* child = m_element1->firstChild(); child; child = child->nextSibling())
- children.append(child);
+ children.append(*child);
size_t size = children.size();
for (size_t i = 0; i < size; ++i)
- m_element2->insertBefore(children[i].release(), m_atChild.get(), IGNORE_EXCEPTION);
+ m_element2->insertBefore(WTF::move(children[i]), m_atChild.get(), IGNORE_EXCEPTION);
m_element1->remove(IGNORE_EXCEPTION);
}
@@ -71,17 +71,17 @@
ExceptionCode ec = 0;
- parent->insertBefore(m_element1.get(), m_element2.get(), ec);
+ parent->insertBefore(*m_element1, m_element2.get(), ec);
if (ec)
return;
- Vector<RefPtr<Node>> children;
+ Vector<Ref<Node>> children;
for (Node* child = m_element2->firstChild(); child && child != atChild; child = child->nextSibling())
- children.append(child);
+ children.append(*child);
size_t size = children.size();
for (size_t i = 0; i < size; ++i)
- m_element1->appendChild(children[i].release(), ec);
+ m_element1->appendChild(WTF::move(children[i]), ec);
}
#ifndef NDEBUG
diff --git a/Source/WebCore/editing/RemoveNodeCommand.cpp b/Source/WebCore/editing/RemoveNodeCommand.cpp
index 31c54d1..9ca5f8b 100644
--- a/Source/WebCore/editing/RemoveNodeCommand.cpp
+++ b/Source/WebCore/editing/RemoveNodeCommand.cpp
@@ -34,12 +34,11 @@
namespace WebCore {
-RemoveNodeCommand::RemoveNodeCommand(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
+RemoveNodeCommand::RemoveNodeCommand(Ref<Node>&& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
: SimpleEditCommand(node->document())
- , m_node(node)
+ , m_node(WTF::move(node))
, m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable)
{
- ASSERT(m_node);
ASSERT(m_node->parentNode());
}
@@ -64,7 +63,7 @@
if (!parent || !parent->hasEditableStyle())
return;
- parent->insertBefore(m_node.get(), refChild.get(), IGNORE_EXCEPTION);
+ parent->insertBefore(m_node.copyRef(), refChild.get(), IGNORE_EXCEPTION);
}
#ifndef NDEBUG
@@ -72,7 +71,7 @@
{
addNodeAndDescendants(m_parent.get(), nodes);
addNodeAndDescendants(m_refChild.get(), nodes);
- addNodeAndDescendants(m_node.get(), nodes);
+ addNodeAndDescendants(m_node.ptr(), nodes);
}
#endif
diff --git a/Source/WebCore/editing/RemoveNodeCommand.h b/Source/WebCore/editing/RemoveNodeCommand.h
index 181e985..33a1f8c 100644
--- a/Source/WebCore/editing/RemoveNodeCommand.h
+++ b/Source/WebCore/editing/RemoveNodeCommand.h
@@ -32,13 +32,13 @@
class RemoveNodeCommand : public SimpleEditCommand {
public:
- static Ref<RemoveNodeCommand> create(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
+ static Ref<RemoveNodeCommand> create(Ref<Node>&& node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
{
- return adoptRef(*new RemoveNodeCommand(node, shouldAssumeContentIsAlwaysEditable));
+ return adoptRef(*new RemoveNodeCommand(WTF::move(node), shouldAssumeContentIsAlwaysEditable));
}
private:
- explicit RemoveNodeCommand(PassRefPtr<Node>, ShouldAssumeContentIsAlwaysEditable);
+ RemoveNodeCommand(Ref<Node>&&, ShouldAssumeContentIsAlwaysEditable);
virtual void doApply() override;
virtual void doUnapply() override;
@@ -47,7 +47,7 @@
void getNodesInCommand(HashSet<Node*>&) override;
#endif
- RefPtr<Node> m_node;
+ Ref<Node> m_node;
RefPtr<ContainerNode> m_parent;
RefPtr<Node> m_refChild;
ShouldAssumeContentIsAlwaysEditable m_shouldAssumeContentIsAlwaysEditable;
diff --git a/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp b/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
index 0e189bd..10bef3a 100644
--- a/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
+++ b/Source/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
@@ -48,19 +48,19 @@
ASSERT(m_elementToReplace);
}
-static void swapInNodePreservingAttributesAndChildren(HTMLElement* newNode, HTMLElement* nodeToReplace)
+static void swapInNodePreservingAttributesAndChildren(HTMLElement& newNode, HTMLElement& nodeToReplace)
{
- ASSERT(nodeToReplace->inDocument());
- RefPtr<ContainerNode> parentNode = nodeToReplace->parentNode();
+ ASSERT(nodeToReplace.inDocument());
+ RefPtr<ContainerNode> parentNode = nodeToReplace.parentNode();
// FIXME: Fix this to send the proper MutationRecords when MutationObservers are present.
- newNode->cloneDataFromElement(*nodeToReplace);
+ newNode.cloneDataFromElement(nodeToReplace);
NodeVector children;
- getChildNodes(*nodeToReplace, children);
+ getChildNodes(nodeToReplace, children);
for (auto& child : children)
- newNode->appendChild(child.ptr(), ASSERT_NO_EXCEPTION);
+ newNode.appendChild(WTF::move(child), ASSERT_NO_EXCEPTION);
- parentNode->insertBefore(newNode, nodeToReplace, ASSERT_NO_EXCEPTION);
+ parentNode->insertBefore(newNode, &nodeToReplace, ASSERT_NO_EXCEPTION);
parentNode->removeChild(nodeToReplace, ASSERT_NO_EXCEPTION);
}
@@ -70,14 +70,14 @@
return;
if (!m_spanElement)
m_spanElement = createHTMLElement(m_elementToReplace->document(), spanTag);
- swapInNodePreservingAttributesAndChildren(m_spanElement.get(), m_elementToReplace.get());
+ swapInNodePreservingAttributesAndChildren(*m_spanElement, *m_elementToReplace);
}
void ReplaceNodeWithSpanCommand::doUnapply()
{
if (!m_spanElement->inDocument())
return;
- swapInNodePreservingAttributesAndChildren(m_elementToReplace.get(), m_spanElement.get());
+ swapInNodePreservingAttributesAndChildren(*m_elementToReplace, *m_spanElement);
}
#ifndef NDEBUG
diff --git a/Source/WebCore/editing/ReplaceSelectionCommand.cpp b/Source/WebCore/editing/ReplaceSelectionCommand.cpp
index eee220c..08c6277 100644
--- a/Source/WebCore/editing/ReplaceSelectionCommand.cpp
+++ b/Source/WebCore/editing/ReplaceSelectionCommand.cpp
@@ -238,7 +238,7 @@
if (!parent)
return;
- parent->removeChild(node.get(), ASSERT_NO_EXCEPTION);
+ parent->removeChild(*node, ASSERT_NO_EXCEPTION);
}
void ReplacementFragment::insertNodeBefore(PassRefPtr<Node> node, Node* refNode)
@@ -250,14 +250,14 @@
if (!parent)
return;
- parent->insertBefore(node, refNode, ASSERT_NO_EXCEPTION);
+ parent->insertBefore(*node, refNode, ASSERT_NO_EXCEPTION);
}
PassRefPtr<StyledElement> ReplacementFragment::insertFragmentForTestRendering(Node* rootEditableElement)
{
RefPtr<StyledElement> holder = createDefaultParagraphElement(document());
- holder->appendChild(m_fragment, ASSERT_NO_EXCEPTION);
+ holder->appendChild(*m_fragment, ASSERT_NO_EXCEPTION);
rootEditableElement->appendChild(holder.get(), ASSERT_NO_EXCEPTION);
document().updateLayoutIgnorePendingStylesheets();
@@ -270,8 +270,8 @@
return;
while (RefPtr<Node> node = holder->firstChild()) {
- holder->removeChild(node.get(), ASSERT_NO_EXCEPTION);
- m_fragment->appendChild(node.get(), ASSERT_NO_EXCEPTION);
+ holder->removeChild(*node, ASSERT_NO_EXCEPTION);
+ m_fragment->appendChild(*node, ASSERT_NO_EXCEPTION);
}
removeNode(holder);
@@ -1454,7 +1454,7 @@
}
while (RefPtr<Node> listItem = listElement->firstChild()) {
- listElement->removeChild(listItem.get(), ASSERT_NO_EXCEPTION);
+ listElement->removeChild(*listItem, ASSERT_NO_EXCEPTION);
if (isStart || isMiddle) {
insertNodeBefore(listItem, lastNode);
insertedNodes.respondToNodeInsertion(listItem.get());
diff --git a/Source/WebCore/editing/SplitElementCommand.cpp b/Source/WebCore/editing/SplitElementCommand.cpp
index 09beb85..35d821b 100644
--- a/Source/WebCore/editing/SplitElementCommand.cpp
+++ b/Source/WebCore/editing/SplitElementCommand.cpp
@@ -47,16 +47,16 @@
if (m_atChild->parentNode() != m_element2)
return;
- Vector<RefPtr<Node>> children;
+ Vector<Ref<Node>> children;
for (Node* node = m_element2->firstChild(); node != m_atChild; node = node->nextSibling())
- children.append(node);
+ children.append(*node);
ExceptionCode ec = 0;
ContainerNode* parent = m_element2->parentNode();
if (!parent || !parent->hasEditableStyle())
return;
- parent->insertBefore(m_element1.get(), m_element2.get(), ec);
+ parent->insertBefore(*m_element1, m_element2.get(), ec);
if (ec)
return;
@@ -65,7 +65,7 @@
size_t size = children.size();
for (size_t i = 0; i < size; ++i)
- m_element1->appendChild(children[i], ec);
+ m_element1->appendChild(WTF::move(children[i]), ec);
}
void SplitElementCommand::doApply()
@@ -80,15 +80,15 @@
if (!m_element1 || !m_element1->hasEditableStyle() || !m_element2->hasEditableStyle())
return;
- Vector<RefPtr<Node>> children;
+ Vector<Ref<Node>> children;
for (Node* node = m_element1->firstChild(); node; node = node->nextSibling())
- children.append(node);
+ children.append(*node);
RefPtr<Node> refChild = m_element2->firstChild();
size_t size = children.size();
for (size_t i = 0; i < size; ++i)
- m_element2->insertBefore(children[i].get(), refChild.get(), IGNORE_EXCEPTION);
+ m_element2->insertBefore(WTF::move(children[i]), refChild.get(), IGNORE_EXCEPTION);
// Recover the id attribute of the original element.
const AtomicString& id = m_element1->getIdAttribute();
diff --git a/Source/WebCore/editing/SplitTextNodeCommand.cpp b/Source/WebCore/editing/SplitTextNodeCommand.cpp
index 17a817f..6999139 100644
--- a/Source/WebCore/editing/SplitTextNodeCommand.cpp
+++ b/Source/WebCore/editing/SplitTextNodeCommand.cpp
@@ -95,7 +95,7 @@
void SplitTextNodeCommand::insertText1AndTrimText2()
{
ExceptionCode ec = 0;
- m_text2->parentNode()->insertBefore(m_text1.get(), m_text2.get(), ec);
+ m_text2->parentNode()->insertBefore(*m_text1, m_text2.get(), ec);
if (ec)
return;
m_text2->deleteData(0, m_offset, ec);
diff --git a/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp b/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp
index 5646f34..f80b773 100644
--- a/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp
+++ b/Source/WebCore/editing/WrapContentsInDummySpanCommand.cpp
@@ -40,15 +40,15 @@
void WrapContentsInDummySpanCommand::executeApply()
{
- Vector<RefPtr<Node>> children;
+ Vector<Ref<Node>> children;
for (Node* child = m_element->firstChild(); child; child = child->nextSibling())
- children.append(child);
+ children.append(*child);
size_t size = children.size();
for (size_t i = 0; i < size; ++i)
- m_dummySpan->appendChild(children[i].release(), IGNORE_EXCEPTION);
+ m_dummySpan->appendChild(WTF::move(children[i]), IGNORE_EXCEPTION);
- m_element->appendChild(m_dummySpan.get(), IGNORE_EXCEPTION);
+ m_element->appendChild(*m_dummySpan, IGNORE_EXCEPTION);
}
void WrapContentsInDummySpanCommand::doApply()
@@ -65,13 +65,13 @@
if (!m_dummySpan || !m_element->hasEditableStyle())
return;
- Vector<RefPtr<Node>> children;
+ Vector<Ref<Node>> children;
for (Node* child = m_dummySpan->firstChild(); child; child = child->nextSibling())
- children.append(child);
+ children.append(*child);
size_t size = children.size();
for (size_t i = 0; i < size; ++i)
- m_element->appendChild(children[i].release(), IGNORE_EXCEPTION);
+ m_element->appendChild(WTF::move(children[i]), IGNORE_EXCEPTION);
m_dummySpan->remove(IGNORE_EXCEPTION);
}
diff --git a/Source/WebCore/editing/cocoa/EditorCocoa.mm b/Source/WebCore/editing/cocoa/EditorCocoa.mm
index ce4bcbc..95e66db 100644
--- a/Source/WebCore/editing/cocoa/EditorCocoa.mm
+++ b/Source/WebCore/editing/cocoa/EditorCocoa.mm
@@ -56,16 +56,16 @@
if (!typingStyle || !typingStyle->style())
return &position.deprecatedNode()->renderer()->style();
- RefPtr<Element> styleElement = frame->document()->createElement(HTMLNames::spanTag, false);
+ Ref<Element> styleElement = frame->document()->createElement(HTMLNames::spanTag, false);
String styleText = typingStyle->style()->asText() + " display: inline";
styleElement->setAttribute(HTMLNames::styleAttr, styleText);
styleElement->appendChild(frame->document()->createEditingTextNode(""), ASSERT_NO_EXCEPTION);
- position.deprecatedNode()->parentNode()->appendChild(styleElement, ASSERT_NO_EXCEPTION);
+ position.deprecatedNode()->parentNode()->appendChild(styleElement.copyRef(), ASSERT_NO_EXCEPTION);
- nodeToRemove = styleElement.get();
+ nodeToRemove = styleElement.ptr();
frame->document()->updateStyleIfNeeded();
return styleElement->renderer() ? &styleElement->renderer()->style() : nullptr;
diff --git a/Source/WebCore/editing/htmlediting.cpp b/Source/WebCore/editing/htmlediting.cpp
index 8f04d08..7caa14f 100644
--- a/Source/WebCore/editing/htmlediting.cpp
+++ b/Source/WebCore/editing/htmlediting.cpp
@@ -899,20 +899,18 @@
return !childRenderer->nextSibling();
}
-PassRefPtr<HTMLElement> createDefaultParagraphElement(Document& document)
+Ref<HTMLElement> createDefaultParagraphElement(Document& document)
{
switch (document.frame()->editor().defaultParagraphSeparator()) {
case EditorParagraphSeparatorIsDiv:
return HTMLDivElement::create(document);
case EditorParagraphSeparatorIsP:
- return HTMLParagraphElement::create(document);
+ break;
}
-
- ASSERT_NOT_REACHED();
- return 0;
+ return HTMLParagraphElement::create(document);
}
-PassRefPtr<HTMLElement> createBreakElement(Document& document)
+Ref<HTMLElement> createBreakElement(Document& document)
{
return HTMLBRElement::create(document);
}
@@ -971,7 +969,7 @@
return positionInParentBeforeNode(node);
}
-PassRefPtr<Element> createTabSpanElement(Document& document, PassRefPtr<Node> prpTabTextNode)
+Ref<Element> createTabSpanElement(Document& document, PassRefPtr<Node> prpTabTextNode)
{
RefPtr<Node> tabTextNode = prpTabTextNode;
@@ -984,17 +982,17 @@
if (!tabTextNode)
tabTextNode = document.createEditingTextNode("\t");
- spanElement->appendChild(tabTextNode.release(), ASSERT_NO_EXCEPTION);
+ spanElement->appendChild(tabTextNode.releaseNonNull(), ASSERT_NO_EXCEPTION);
- return spanElement.release();
+ return spanElement.releaseNonNull();
}
-PassRefPtr<Element> createTabSpanElement(Document& document, const String& tabText)
+Ref<Element> createTabSpanElement(Document& document, const String& tabText)
{
return createTabSpanElement(document, document.createTextNode(tabText));
}
-PassRefPtr<Element> createTabSpanElement(Document& document)
+Ref<Element> createTabSpanElement(Document& document)
{
return createTabSpanElement(document, PassRefPtr<Node>());
}
diff --git a/Source/WebCore/editing/htmlediting.h b/Source/WebCore/editing/htmlediting.h
index 788af3f..f69d9d8 100644
--- a/Source/WebCore/editing/htmlediting.h
+++ b/Source/WebCore/editing/htmlediting.h
@@ -206,8 +206,8 @@
// Functions returning HTMLElement
-WEBCORE_EXPORT PassRefPtr<HTMLElement> createDefaultParagraphElement(Document&);
-PassRefPtr<HTMLElement> createBreakElement(Document&);
+WEBCORE_EXPORT Ref<HTMLElement> createDefaultParagraphElement(Document&);
+Ref<HTMLElement> createBreakElement(Document&);
PassRefPtr<HTMLElement> createOrderedListElement(Document&);
PassRefPtr<HTMLElement> createUnorderedListElement(Document&);
PassRefPtr<HTMLElement> createListItemElement(Document&);
@@ -222,10 +222,10 @@
// Element
// -------------------------------------------------------------------------
-PassRefPtr<Element> createTabSpanElement(Document&);
-PassRefPtr<Element> createTabSpanElement(Document&, PassRefPtr<Node> tabTextNode);
-PassRefPtr<Element> createTabSpanElement(Document&, const String& tabText);
-PassRefPtr<Element> createBlockPlaceholderElement(Document&);
+Ref<Element> createTabSpanElement(Document&);
+Ref<Element> createTabSpanElement(Document&, PassRefPtr<Node> tabTextNode);
+Ref<Element> createTabSpanElement(Document&, const String& tabText);
+Ref<Element> createBlockPlaceholderElement(Document&);
Element* editableRootForPosition(const Position&, EditableType = ContentIsEditable);
Element* unsplittableElementForPosition(const Position&);
diff --git a/Source/WebCore/editing/ios/EditorIOS.mm b/Source/WebCore/editing/ios/EditorIOS.mm
index 226ead5..8151985 100644
--- a/Source/WebCore/editing/ios/EditorIOS.mm
+++ b/Source/WebCore/editing/ios/EditorIOS.mm
@@ -397,7 +397,7 @@
if (fragment) {
if (newFragment && newFragment->firstChild()) {
ExceptionCode ec;
- fragment->appendChild(newFragment->firstChild(), ec);
+ fragment->appendChild(*newFragment->firstChild(), ec);
}
} else
fragment = newFragment;
@@ -494,12 +494,12 @@
return fragment;
}
} else {
- RefPtr<Element> anchor = frame.document()->createElement(HTMLNames::aTag, false);
+ Ref<Element> anchor = frame.document()->createElement(HTMLNames::aTag, false);
anchor->setAttribute(HTMLNames::hrefAttr, url.string());
anchor->appendChild(frame.document()->createTextNode([[(NSURL *)url absoluteString] precomposedStringWithCanonicalMapping]));
RefPtr<DocumentFragment> newFragment = frame.document()->createDocumentFragment();
- newFragment->appendChild(anchor.release());
+ newFragment->appendChild(WTF::move(anchor));
addFragment(newFragment);
return true;
}
@@ -583,7 +583,7 @@
if (!resource)
return nullptr;
- RefPtr<Element> imageElement = m_frame.document()->createElement(HTMLNames::imgTag, false);
+ Ref<Element> imageElement = m_frame.document()->createElement(HTMLNames::imgTag, false);
// FIXME: The code in createFragmentAndAddResources calls setDefersLoading(true). Don't we need that here?
if (DocumentLoader* loader = m_frame.loader().documentLoader())
loader->addArchiveResource(resource.get());
@@ -592,7 +592,7 @@
imageElement->setAttribute(HTMLNames::srcAttr, [URL isFileURL] ? [URL absoluteString] : resource->url());
RefPtr<DocumentFragment> fragment = m_frame.document()->createDocumentFragment();
- fragment->appendChild(imageElement.release());
+ fragment->appendChild(WTF::move(imageElement));
return fragment.release();
}
diff --git a/Source/WebCore/editing/mac/EditorMac.mm b/Source/WebCore/editing/mac/EditorMac.mm
index 6cef489..cd252dc 100644
--- a/Source/WebCore/editing/mac/EditorMac.mm
+++ b/Source/WebCore/editing/mac/EditorMac.mm
@@ -527,15 +527,15 @@
for (size_t i = 0; i < size; i++) {
String text = paths[i];
#if ENABLE(ATTACHMENT_ELEMENT)
- RefPtr<HTMLAttachmentElement> attachment = HTMLAttachmentElement::create(attachmentTag, document);
+ Ref<HTMLAttachmentElement> attachment = HTMLAttachmentElement::create(attachmentTag, document);
attachment->setFile(File::create([[NSURL fileURLWithPath:text] path]).ptr());
- fragment->appendChild(attachment.release());
+ fragment->appendChild(WTF::move(attachment));
#else
text = frame.editor().client()->userVisibleString([NSURL fileURLWithPath:text]);
- RefPtr<HTMLElement> paragraph = createDefaultParagraphElement(document);
+ Ref<HTMLElement> paragraph = createDefaultParagraphElement(document);
paragraph->appendChild(document.createTextNode(text));
- fragment->appendChild(paragraph.release());
+ fragment->appendChild(WTF::move(paragraph));
#endif
}
@@ -594,12 +594,12 @@
if (url.string().isEmpty())
return false;
- RefPtr<Element> anchor = frame.document()->createElement(HTMLNames::aTag, false);
+ Ref<Element> anchor = frame.document()->createElement(HTMLNames::aTag, false);
anchor->setAttribute(HTMLNames::hrefAttr, url.string());
anchor->appendChild(frame.document()->createTextNode([title precomposedStringWithCanonicalMapping]));
fragment = frame.document()->createDocumentFragment();
- fragment->appendChild(anchor.release());
+ fragment->appendChild(WTF::move(anchor));
return true;
}
@@ -635,11 +635,11 @@
if (DocumentLoader* loader = m_frame.loader().documentLoader())
loader->addArchiveResource(resource.get());
- RefPtr<Element> imageElement = document().createElement(HTMLNames::imgTag, false);
+ Ref<Element> imageElement = document().createElement(HTMLNames::imgTag, false);
imageElement->setAttribute(HTMLNames::srcAttr, resource->url().string());
RefPtr<DocumentFragment> fragment = document().createDocumentFragment();
- fragment->appendChild(imageElement.release());
+ fragment->appendChild(WTF::move(imageElement));
return fragment.release();
}
diff --git a/Source/WebCore/editing/markup.cpp b/Source/WebCore/editing/markup.cpp
index 0cac8b4..2054c4e 100644
--- a/Source/WebCore/editing/markup.cpp
+++ b/Source/WebCore/editing/markup.cpp
@@ -704,12 +704,12 @@
return accumulator.serializeNodes(const_cast<Node&>(node), childrenOnly, tagNamesToSkip);
}
-static void fillContainerFromString(ContainerNode* paragraph, const String& string)
+static void fillContainerFromString(ContainerNode& paragraph, const String& string)
{
- Document& document = paragraph->document();
+ Document& document = paragraph.document();
if (string.isEmpty()) {
- paragraph->appendChild(createBlockPlaceholderElement(document), ASSERT_NO_EXCEPTION);
+ paragraph.appendChild(createBlockPlaceholderElement(document), ASSERT_NO_EXCEPTION);
return;
}
@@ -726,11 +726,11 @@
// append the non-tab textual part
if (!s.isEmpty()) {
if (!tabText.isEmpty()) {
- paragraph->appendChild(createTabSpanElement(document, tabText), ASSERT_NO_EXCEPTION);
+ paragraph.appendChild(createTabSpanElement(document, tabText), ASSERT_NO_EXCEPTION);
tabText = emptyString();
}
- RefPtr<Node> textNode = document.createTextNode(stringWithRebalancedWhitespace(s, first, i + 1 == numEntries));
- paragraph->appendChild(textNode.release(), ASSERT_NO_EXCEPTION);
+ Ref<Node> textNode = document.createTextNode(stringWithRebalancedWhitespace(s, first, i + 1 == numEntries));
+ paragraph.appendChild(WTF::move(textNode), ASSERT_NO_EXCEPTION);
}
// there is a tab after every entry, except the last entry
@@ -738,7 +738,7 @@
if (i + 1 != numEntries)
tabText.append('\t');
else if (!tabText.isEmpty())
- paragraph->appendChild(createTabSpanElement(document, tabText), ASSERT_NO_EXCEPTION);
+ paragraph.appendChild(createTabSpanElement(document, tabText), ASSERT_NO_EXCEPTION);
first = false;
}
@@ -778,13 +778,13 @@
return container->renderer()->style().preserveNewline();
}
-PassRefPtr<DocumentFragment> createFragmentFromText(Range& context, const String& text)
+Ref<DocumentFragment> createFragmentFromText(Range& context, const String& text)
{
Document& document = context.ownerDocument();
- RefPtr<DocumentFragment> fragment = document.createDocumentFragment();
+ Ref<DocumentFragment> fragment = document.createDocumentFragment();
if (text.isEmpty())
- return fragment.release();
+ return fragment;
String string = text;
string.replace("\r\n", "\n");
@@ -793,17 +793,17 @@
if (contextPreservesNewline(context)) {
fragment->appendChild(document.createTextNode(string), ASSERT_NO_EXCEPTION);
if (string.endsWith('\n')) {
- RefPtr<Element> element = createBreakElement(document);
+ Ref<Element> element = createBreakElement(document);
element->setAttribute(classAttr, AppleInterchangeNewline);
- fragment->appendChild(element.release(), ASSERT_NO_EXCEPTION);
+ fragment->appendChild(WTF::move(element), ASSERT_NO_EXCEPTION);
}
- return fragment.release();
+ return fragment;
}
// A string with no newlines gets added inline, rather than being put into a paragraph.
if (string.find('\n') == notFound) {
- fillContainerFromString(fragment.get(), string);
- return fragment.release();
+ fillContainerFromString(fragment, string);
+ return fragment;
}
// Break string into paragraphs. Extra line breaks turn into empty paragraphs.
@@ -829,17 +829,17 @@
element->setAttribute(classAttr, AppleInterchangeNewline);
} else if (useLineBreak) {
element = createBreakElement(document);
- fillContainerFromString(fragment.get(), s);
+ fillContainerFromString(fragment, s);
} else {
if (useClonesOfEnclosingBlock)
element = block->cloneElementWithoutChildren(document);
else
element = createDefaultParagraphElement(document);
- fillContainerFromString(element.get(), s);
+ fillContainerFromString(*element, s);
}
- fragment->appendChild(element.release(), ASSERT_NO_EXCEPTION);
+ fragment->appendChild(element.releaseNonNull(), ASSERT_NO_EXCEPTION);
}
- return fragment.release();
+ return fragment;
}
String documentTypeString(const Document& document)
@@ -945,10 +945,10 @@
RefPtr<Node> nextChild;
for (RefPtr<Node> child = element.firstChild(); child; child = nextChild) {
nextChild = child->nextSibling();
- element.removeChild(child.get(), ASSERT_NO_EXCEPTION);
- fragment.insertBefore(child, &element, ASSERT_NO_EXCEPTION);
+ element.removeChild(*child, ASSERT_NO_EXCEPTION);
+ fragment.insertBefore(*child, &element, ASSERT_NO_EXCEPTION);
}
- fragment.removeChild(&element, ASSERT_NO_EXCEPTION);
+ fragment.removeChild(element, ASSERT_NO_EXCEPTION);
}
PassRefPtr<DocumentFragment> createContextualFragment(const String& markup, HTMLElement* element, ParserContentPolicy parserContentPolicy, ExceptionCode& ec)
@@ -990,7 +990,7 @@
return hasOneChild(node) && node.firstChild()->isTextNode();
}
-void replaceChildrenWithFragment(ContainerNode& container, PassRefPtr<DocumentFragment> fragment, ExceptionCode& ec)
+void replaceChildrenWithFragment(ContainerNode& container, Ref<DocumentFragment>&& fragment, ExceptionCode& ec)
{
Ref<ContainerNode> containerNode(container);
ChildListMutationScope mutation(containerNode);
@@ -1000,18 +1000,18 @@
return;
}
- if (hasOneTextChild(containerNode) && hasOneTextChild(*fragment)) {
+ if (hasOneTextChild(containerNode) && hasOneTextChild(fragment)) {
downcast<Text>(*containerNode->firstChild()).setData(downcast<Text>(*fragment->firstChild()).data(), ec);
return;
}
if (hasOneChild(containerNode)) {
- containerNode->replaceChild(fragment, containerNode->firstChild(), ec);
+ containerNode->replaceChild(WTF::move(fragment), *containerNode->firstChild(), ec);
return;
}
containerNode->removeChildren();
- containerNode->appendChild(fragment, ec);
+ containerNode->appendChild(WTF::move(fragment), ec);
}
void replaceChildrenWithText(ContainerNode& container, const String& text, ExceptionCode& ec)
@@ -1027,7 +1027,7 @@
Ref<Text> textNode = Text::create(containerNode->document(), text);
if (hasOneChild(containerNode)) {
- containerNode->replaceChild(WTF::move(textNode), containerNode->firstChild(), ec);
+ containerNode->replaceChild(WTF::move(textNode), *containerNode->firstChild(), ec);
return;
}
diff --git a/Source/WebCore/editing/markup.h b/Source/WebCore/editing/markup.h
index c552010..a545ba5 100644
--- a/Source/WebCore/editing/markup.h
+++ b/Source/WebCore/editing/markup.h
@@ -49,7 +49,7 @@
enum EAbsoluteURLs { DoNotResolveURLs, ResolveAllURLs, ResolveNonLocalURLs };
enum EFragmentSerialization { HTMLFragmentSerialization, XMLFragmentSerialization };
-WEBCORE_EXPORT PassRefPtr<DocumentFragment> createFragmentFromText(Range& context, const String& text);
+WEBCORE_EXPORT Ref<DocumentFragment> createFragmentFromText(Range& context, const String& text);
WEBCORE_EXPORT Ref<DocumentFragment> createFragmentFromMarkup(Document&, const String& markup, const String& baseURL, ParserContentPolicy = AllowScriptingContent);
PassRefPtr<DocumentFragment> createFragmentForInnerOuterHTML(const String&, Element*, ParserContentPolicy, ExceptionCode&);
PassRefPtr<DocumentFragment> createFragmentForTransformToFragment(const String&, const String& sourceMIMEType, Document* outputDoc);
@@ -59,11 +59,11 @@
// These methods are used by HTMLElement & ShadowRoot to replace the
// children with respected fragment/text.
-void replaceChildrenWithFragment(ContainerNode&, PassRefPtr<DocumentFragment>, ExceptionCode&);
+void replaceChildrenWithFragment(ContainerNode&, Ref<DocumentFragment>&&, ExceptionCode&);
void replaceChildrenWithText(ContainerNode&, const String&, ExceptionCode&);
-String createMarkup(const Range&, Vector<Node*>* = 0, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false, EAbsoluteURLs = DoNotResolveURLs);
-String createMarkup(const Node&, EChildrenOnly = IncludeNode, Vector<Node*>* = 0, EAbsoluteURLs = DoNotResolveURLs, Vector<QualifiedName>* tagNamesToSkip = 0, EFragmentSerialization = HTMLFragmentSerialization);
+String createMarkup(const Range&, Vector<Node*>* = nullptr, EAnnotateForInterchange = DoNotAnnotateForInterchange, bool convertBlocksToInlines = false, EAbsoluteURLs = DoNotResolveURLs);
+String createMarkup(const Node&, EChildrenOnly = IncludeNode, Vector<Node*>* = nullptr, EAbsoluteURLs = DoNotResolveURLs, Vector<QualifiedName>* tagNamesToSkip = 0, EFragmentSerialization = HTMLFragmentSerialization);
WEBCORE_EXPORT String createFullMarkup(const Node&);
WEBCORE_EXPORT String createFullMarkup(const Range&);
diff --git a/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp b/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp
index dbea0e9..57e388b 100644
--- a/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp
+++ b/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp
@@ -60,9 +60,9 @@
{
DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, valueContainerPseudo, ("-webkit-date-and-time-value", AtomicString::ConstructFromLiteral));
- RefPtr<HTMLDivElement> valueContainer = HTMLDivElement::create(element().document());
+ Ref<HTMLDivElement> valueContainer = HTMLDivElement::create(element().document());
valueContainer->setPseudo(valueContainerPseudo);
- element().userAgentShadowRoot()->appendChild(valueContainer.get());
+ element().userAgentShadowRoot()->appendChild(WTF::move(valueContainer));
updateAppearance();
}
diff --git a/Source/WebCore/html/ColorInputType.cpp b/Source/WebCore/html/ColorInputType.cpp
index 8bbdb97..c5385a04 100644
--- a/Source/WebCore/html/ColorInputType.cpp
+++ b/Source/WebCore/html/ColorInputType.cpp
@@ -107,12 +107,12 @@
ASSERT(element().shadowRoot());
Document& document = element().document();
- RefPtr<HTMLDivElement> wrapperElement = HTMLDivElement::create(document);
+ Ref<HTMLDivElement> wrapperElement = HTMLDivElement::create(document);
wrapperElement->setPseudo(AtomicString("-webkit-color-swatch-wrapper", AtomicString::ConstructFromLiteral));
- RefPtr<HTMLDivElement> colorSwatch = HTMLDivElement::create(document);
+ Ref<HTMLDivElement> colorSwatch = HTMLDivElement::create(document);
colorSwatch->setPseudo(AtomicString("-webkit-color-swatch", AtomicString::ConstructFromLiteral));
- wrapperElement->appendChild(colorSwatch.release(), ASSERT_NO_EXCEPTION);
- element().userAgentShadowRoot()->appendChild(wrapperElement.release(), ASSERT_NO_EXCEPTION);
+ wrapperElement->appendChild(WTF::move(colorSwatch), ASSERT_NO_EXCEPTION);
+ element().userAgentShadowRoot()->appendChild(WTF::move(wrapperElement), ASSERT_NO_EXCEPTION);
updateColorSwatch();
}
diff --git a/Source/WebCore/html/FTPDirectoryDocument.cpp b/Source/WebCore/html/FTPDirectoryDocument.cpp
index 4065a17..1447a46 100644
--- a/Source/WebCore/html/FTPDirectoryDocument.cpp
+++ b/Source/WebCore/html/FTPDirectoryDocument.cpp
@@ -104,27 +104,27 @@
RefPtr<Element> rowElement = m_tableElement->insertRow(-1, IGNORE_EXCEPTION);
rowElement->setAttribute(HTMLNames::classAttr, "ftpDirectoryEntryRow");
- RefPtr<Element> element = document()->createElement(tdTag, false);
+ Ref<Element> element = document()->createElement(tdTag, false);
element->appendChild(Text::create(*document(), String(&noBreakSpace, 1)), IGNORE_EXCEPTION);
if (isDirectory)
element->setAttribute(HTMLNames::classAttr, "ftpDirectoryIcon ftpDirectoryTypeDirectory");
else
element->setAttribute(HTMLNames::classAttr, "ftpDirectoryIcon ftpDirectoryTypeFile");
- rowElement->appendChild(element, IGNORE_EXCEPTION);
+ rowElement->appendChild(WTF::move(element), IGNORE_EXCEPTION);
element = createTDForFilename(filename);
element->setAttribute(HTMLNames::classAttr, "ftpDirectoryFileName");
- rowElement->appendChild(element, IGNORE_EXCEPTION);
+ rowElement->appendChild(WTF::move(element), IGNORE_EXCEPTION);
element = document()->createElement(tdTag, false);
element->appendChild(Text::create(*document(), date), IGNORE_EXCEPTION);
element->setAttribute(HTMLNames::classAttr, "ftpDirectoryFileDate");
- rowElement->appendChild(element, IGNORE_EXCEPTION);
+ rowElement->appendChild(WTF::move(element), IGNORE_EXCEPTION);
element = document()->createElement(tdTag, false);
element->appendChild(Text::create(*document(), size), IGNORE_EXCEPTION);
element->setAttribute(HTMLNames::classAttr, "ftpDirectoryFileSize");
- rowElement->appendChild(element, IGNORE_EXCEPTION);
+ rowElement->appendChild(WTF::move(element), IGNORE_EXCEPTION);
}
Ref<Element> FTPDirectoryDocumentParser::createTDForFilename(const String& filename)
@@ -135,12 +135,12 @@
else
fullURL = fullURL + '/' + filename;
- RefPtr<Element> anchorElement = document()->createElement(aTag, false);
+ Ref<Element> 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(anchorElement, IGNORE_EXCEPTION);
+ tdElement->appendChild(WTF::move(anchorElement), IGNORE_EXCEPTION);
return tdElement;
}
@@ -312,9 +312,9 @@
// If that fails for some reason, cram it on the end of the document as a last
// ditch effort
if (auto* body = document()->bodyOrFrameset())
- body->appendChild(m_tableElement, IGNORE_EXCEPTION);
+ body->appendChild(*m_tableElement, IGNORE_EXCEPTION);
else
- document()->appendChild(m_tableElement, IGNORE_EXCEPTION);
+ document()->appendChild(*m_tableElement, IGNORE_EXCEPTION);
return true;
}
@@ -325,16 +325,16 @@
// FIXME: Make this "basic document" more acceptable
- RefPtr<Element> bodyElement = document()->createElement(bodyTag, false);
+ Ref<Element> bodyElement = document()->createElement(bodyTag, false);
- document()->appendChild(bodyElement, IGNORE_EXCEPTION);
+ document()->appendChild(bodyElement.copyRef(), IGNORE_EXCEPTION);
- RefPtr<Element> tableElement = document()->createElement(tableTag, false);
- m_tableElement = downcast<HTMLTableElement>(tableElement.get());
+ Ref<Element> 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(m_tableElement, IGNORE_EXCEPTION);
+ bodyElement->appendChild(WTF::move(tableElement), IGNORE_EXCEPTION);
document()->processViewport("width=device-width", ViewportArguments::ViewportMeta);
}
diff --git a/Source/WebCore/html/HTMLDetailsElement.cpp b/Source/WebCore/html/HTMLDetailsElement.cpp
index 430212c..48cc9b8 100644
--- a/Source/WebCore/html/HTMLDetailsElement.cpp
+++ b/Source/WebCore/html/HTMLDetailsElement.cpp
@@ -90,11 +90,11 @@
Ref<DetailsSummaryElement> DetailsSummaryElement::create(Document& document)
{
- RefPtr<HTMLSummaryElement> summary = HTMLSummaryElement::create(summaryTag, document);
+ Ref<HTMLSummaryElement> summary = HTMLSummaryElement::create(summaryTag, document);
summary->appendChild(Text::create(document, defaultDetailsSummaryText()), ASSERT_NO_EXCEPTION);
Ref<DetailsSummaryElement> detailsSummary = adoptRef(*new DetailsSummaryElement(document));
- detailsSummary->appendChild(summary);
+ detailsSummary->appendChild(WTF::move(summary));
return detailsSummary;
}
diff --git a/Source/WebCore/html/HTMLElement.cpp b/Source/WebCore/html/HTMLElement.cpp
index 520ce03..5c377da 100644
--- a/Source/WebCore/html/HTMLElement.cpp
+++ b/Source/WebCore/html/HTMLElement.cpp
@@ -584,9 +584,9 @@
// Add text nodes and <br> elements.
ec = 0;
- RefPtr<DocumentFragment> fragment = textToFragment(text, ec);
+ Ref<DocumentFragment> fragment = textToFragment(text, ec);
if (!ec)
- replaceChildrenWithFragment(*this, fragment.release(), ec);
+ replaceChildrenWithFragment(*this, WTF::move(fragment), ec);
}
void HTMLElement::setOuterText(const String& text, ExceptionCode& ec)
@@ -621,7 +621,7 @@
ec = HIERARCHY_REQUEST_ERR;
if (ec)
return;
- parent->replaceChild(newChild.release(), this, ec);
+ parent->replaceChild(newChild.releaseNonNull(), *this, ec);
RefPtr<Node> node = next ? next->previousSibling() : nullptr;
if (!ec && is<Text>(node.get()))
@@ -630,7 +630,7 @@
mergeWithNextTextNode(downcast<Text>(*prev), ec);
}
-Node* HTMLElement::insertAdjacent(const String& where, Node* newChild, ExceptionCode& ec)
+Node* HTMLElement::insertAdjacent(const String& where, Ref<Node>&& newChild, ExceptionCode& ec)
{
// In Internet Explorer if the element has no parent and where is "beforeBegin" or "afterEnd",
// a document fragment is created and the elements appended in the correct order. This document
@@ -641,18 +641,18 @@
if (equalIgnoringCase(where, "beforeBegin")) {
ContainerNode* parent = this->parentNode();
- return (parent && parent->insertBefore(newChild, this, ec)) ? newChild : nullptr;
+ return (parent && parent->insertBefore(newChild.copyRef(), this, ec)) ? newChild.ptr() : nullptr;
}
if (equalIgnoringCase(where, "afterBegin"))
- return insertBefore(newChild, firstChild(), ec) ? newChild : nullptr;
+ return insertBefore(newChild.copyRef(), firstChild(), ec) ? newChild.ptr() : nullptr;
if (equalIgnoringCase(where, "beforeEnd"))
- return appendChild(newChild, ec) ? newChild : nullptr;
+ return appendChild(newChild.copyRef(), ec) ? newChild.ptr() : nullptr;
if (equalIgnoringCase(where, "afterEnd")) {
ContainerNode* parent = this->parentNode();
- return (parent && parent->insertBefore(newChild, nextSibling(), ec)) ? newChild : nullptr;
+ return (parent && parent->insertBefore(newChild.copyRef(), nextSibling(), ec)) ? newChild.ptr() : nullptr;
}
// IE throws COM Exception E_INVALIDARG; this is the best DOM exception alternative.
@@ -668,7 +668,7 @@
return nullptr;
}
- Node* returnValue = insertAdjacent(where, newChild, ec);
+ Node* returnValue = insertAdjacent(where, *newChild, ec);
ASSERT_WITH_SECURITY_IMPLICATION(!returnValue || is<Element>(*returnValue));
return downcast<Element>(returnValue);
}
@@ -699,13 +699,12 @@
RefPtr<DocumentFragment> fragment = createFragmentForInnerOuterHTML(markup, contextElement, AllowScriptingContent, ec);
if (!fragment)
return;
- insertAdjacent(where, fragment.get(), ec);
+ insertAdjacent(where, fragment.releaseNonNull(), ec);
}
void HTMLElement::insertAdjacentText(const String& where, const String& text, ExceptionCode& ec)
{
- RefPtr<Text> textNode = document().createTextNode(text);
- insertAdjacent(where, textNode.get(), ec);
+ insertAdjacent(where, document().createTextNode(text), ec);
}
void HTMLElement::applyAlignmentAttributeToStyle(const AtomicString& alignment, MutableStyleProperties& style)
diff --git a/Source/WebCore/html/HTMLElement.h b/Source/WebCore/html/HTMLElement.h
index 30e3775..70d4961 100644
--- a/Source/WebCore/html/HTMLElement.h
+++ b/Source/WebCore/html/HTMLElement.h
@@ -130,7 +130,7 @@
virtual HTMLFormElement* virtualForm() const;
- Node* insertAdjacent(const String& where, Node* newChild, ExceptionCode&);
+ Node* insertAdjacent(const String& where, Ref<Node>&& newChild, ExceptionCode&);
Ref<DocumentFragment> textToFragment(const String&, ExceptionCode&);
void dirAttributeChanged(const AtomicString&);
diff --git a/Source/WebCore/html/HTMLImageElement.cpp b/Source/WebCore/html/HTMLImageElement.cpp
index b2a277a..a4a73ca 100644
--- a/Source/WebCore/html/HTMLImageElement.cpp
+++ b/Source/WebCore/html/HTMLImageElement.cpp
@@ -504,7 +504,7 @@
if (!imageControls)
return;
- ensureUserAgentShadowRoot().appendChild(imageControls);
+ ensureUserAgentShadowRoot().appendChild(imageControls.releaseNonNull());
auto* renderObject = renderer();
if (!renderObject)
@@ -521,7 +521,7 @@
if (Node* node = shadowRoot->firstChild()) {
ASSERT_WITH_SECURITY_IMPLICATION(node->isImageControlsRootElement());
- shadowRoot->removeChild(node);
+ shadowRoot->removeChild(*node);
}
auto* renderObject = renderer();
diff --git a/Source/WebCore/html/HTMLKeygenElement.cpp b/Source/WebCore/html/HTMLKeygenElement.cpp
index e7d9148..4a63b00 100644
--- a/Source/WebCore/html/HTMLKeygenElement.cpp
+++ b/Source/WebCore/html/HTMLKeygenElement.cpp
@@ -58,7 +58,7 @@
}
private:
- virtual RefPtr<Element> cloneElementWithoutAttributesAndChildren(Document& targetDocument) override
+ virtual Ref<Element> cloneElementWithoutAttributesAndChildren(Document& targetDocument) override
{
return create(targetDocument);
}
@@ -73,14 +73,14 @@
Vector<String> keys;
getSupportedKeySizes(keys);
- RefPtr<HTMLSelectElement> select = KeygenSelectElement::create(document);
+ Ref<HTMLSelectElement> select = KeygenSelectElement::create(document);
for (size_t i = 0; i < keys.size(); ++i) {
- RefPtr<HTMLOptionElement> option = HTMLOptionElement::create(document);
- select->appendChild(option, IGNORE_EXCEPTION);
+ Ref<HTMLOptionElement> option = HTMLOptionElement::create(document);
+ select->appendChild(option.copyRef(), IGNORE_EXCEPTION);
option->appendChild(Text::create(document, keys[i]), IGNORE_EXCEPTION);
}
- ensureUserAgentShadowRoot().appendChild(select, IGNORE_EXCEPTION);
+ ensureUserAgentShadowRoot().appendChild(WTF::move(select), IGNORE_EXCEPTION);
}
Ref<HTMLKeygenElement> HTMLKeygenElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form)
diff --git a/Source/WebCore/html/HTMLMeterElement.cpp b/Source/WebCore/html/HTMLMeterElement.cpp
index 22b2f39..e5e3de0 100644
--- a/Source/WebCore/html/HTMLMeterElement.cpp
+++ b/Source/WebCore/html/HTMLMeterElement.cpp
@@ -229,16 +229,16 @@
{
ASSERT(!m_value);
- RefPtr<MeterInnerElement> inner = MeterInnerElement::create(document());
- root->appendChild(inner);
+ Ref<MeterInnerElement> inner = MeterInnerElement::create(document());
+ root->appendChild(inner.copyRef());
- RefPtr<MeterBarElement> bar = MeterBarElement::create(document());
+ Ref<MeterBarElement> bar = MeterBarElement::create(document());
m_value = MeterValueElement::create(document());
m_value->setWidthPercentage(0);
m_value->updatePseudo();
- bar->appendChild(m_value, ASSERT_NO_EXCEPTION);
+ bar->appendChild(*m_value, ASSERT_NO_EXCEPTION);
- inner->appendChild(bar, ASSERT_NO_EXCEPTION);
+ inner->appendChild(WTF::move(bar), ASSERT_NO_EXCEPTION);
}
} // namespace
diff --git a/Source/WebCore/html/HTMLOptionElement.cpp b/Source/WebCore/html/HTMLOptionElement.cpp
index 2dfff26..ed9caea 100644
--- a/Source/WebCore/html/HTMLOptionElement.cpp
+++ b/Source/WebCore/html/HTMLOptionElement.cpp
@@ -71,12 +71,12 @@
{
RefPtr<HTMLOptionElement> element = adoptRef(new HTMLOptionElement(optionTag, document));
- RefPtr<Text> text = Text::create(document, data.isNull() ? "" : data);
+ Ref<Text> text = Text::create(document, data.isNull() ? "" : data);
ec = 0;
- element->appendChild(text.release(), ec);
+ element->appendChild(WTF::move(text), ec);
if (ec)
- return 0;
+ return nullptr;
if (!value.isNull())
element->setValue(value);
@@ -84,7 +84,7 @@
element->setAttribute(selectedAttr, emptyAtom);
element->setSelected(selected);
- return element.release();
+ return element;
}
bool HTMLOptionElement::isFocusable() const
diff --git a/Source/WebCore/html/HTMLProgressElement.cpp b/Source/WebCore/html/HTMLProgressElement.cpp
index 87f0e37..db7d06a 100644
--- a/Source/WebCore/html/HTMLProgressElement.cpp
+++ b/Source/WebCore/html/HTMLProgressElement.cpp
@@ -149,16 +149,16 @@
{
ASSERT(!m_value);
- RefPtr<ProgressInnerElement> inner = ProgressInnerElement::create(document());
- root->appendChild(inner);
+ Ref<ProgressInnerElement> inner = ProgressInnerElement::create(document());
+ root->appendChild(inner.copyRef());
- RefPtr<ProgressBarElement> bar = ProgressBarElement::create(document());
- RefPtr<ProgressValueElement> value = ProgressValueElement::create(document());
- m_value = value.get();
+ Ref<ProgressBarElement> bar = ProgressBarElement::create(document());
+ Ref<ProgressValueElement> value = ProgressValueElement::create(document());
+ m_value = value.ptr();
m_value->setWidthPercentage(HTMLProgressElement::IndeterminatePosition * 100);
- bar->appendChild(m_value, ASSERT_NO_EXCEPTION);
+ bar->appendChild(*m_value, ASSERT_NO_EXCEPTION);
- inner->appendChild(bar, ASSERT_NO_EXCEPTION);
+ inner->appendChild(WTF::move(bar), ASSERT_NO_EXCEPTION);
}
bool HTMLProgressElement::shouldAppearIndeterminate() const
diff --git a/Source/WebCore/html/HTMLScriptElement.cpp b/Source/WebCore/html/HTMLScriptElement.cpp
index 6951146..e13a5cd 100644
--- a/Source/WebCore/html/HTMLScriptElement.cpp
+++ b/Source/WebCore/html/HTMLScriptElement.cpp
@@ -169,9 +169,9 @@
dispatchEvent(Event::create(eventNames().loadEvent, false, false));
}
-RefPtr<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
+Ref<Element> HTMLScriptElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
{
- return adoptRef(new HTMLScriptElement(tagQName(), targetDocument, false, alreadyStarted()));
+ return adoptRef(*new HTMLScriptElement(tagQName(), targetDocument, false, alreadyStarted()));
}
}
diff --git a/Source/WebCore/html/HTMLScriptElement.h b/Source/WebCore/html/HTMLScriptElement.h
index e39c10c..312c662 100644
--- a/Source/WebCore/html/HTMLScriptElement.h
+++ b/Source/WebCore/html/HTMLScriptElement.h
@@ -65,7 +65,7 @@
virtual void dispatchLoadEvent() override;
- virtual RefPtr<Element> cloneElementWithoutAttributesAndChildren(Document&) override;
+ virtual Ref<Element> cloneElementWithoutAttributesAndChildren(Document&) override;
};
} //namespace
diff --git a/Source/WebCore/html/HTMLSelectElement.cpp b/Source/WebCore/html/HTMLSelectElement.cpp
index eb73945..4f10458 100644
--- a/Source/WebCore/html/HTMLSelectElement.cpp
+++ b/Source/WebCore/html/HTMLSelectElement.cpp
@@ -227,7 +227,7 @@
// Make sure the element is ref'd and deref'd so we don't leak it.
Ref<HTMLElement> protectNewChild(*element);
- insertBefore(element, beforeElement, ec);
+ insertBefore(*element, beforeElement, ec);
updateValidity();
}
@@ -486,12 +486,12 @@
// Removing children fires mutation events, which might mutate the DOM further, so we first copy out a list
// of elements that we intend to remove then attempt to remove them one at a time.
- Vector<RefPtr<Element>> itemsToRemove;
+ Vector<Ref<Element>> itemsToRemove;
size_t optionIndex = 0;
for (auto& item : items) {
if (is<HTMLOptionElement>(*item) && optionIndex++ >= newLen) {
ASSERT(item->parentNode());
- itemsToRemove.append(item);
+ itemsToRemove.append(*item);
}
}
diff --git a/Source/WebCore/html/HTMLTableElement.cpp b/Source/WebCore/html/HTMLTableElement.cpp
index cfb4de3..cf9e9a5 100644
--- a/Source/WebCore/html/HTMLTableElement.cpp
+++ b/Source/WebCore/html/HTMLTableElement.cpp
@@ -81,7 +81,7 @@
{
deleteCaption();
if (newCaption)
- insertBefore(newCaption, firstChild(), ec);
+ insertBefore(*newCaption, firstChild(), ec);
}
HTMLTableSectionElement* HTMLTableElement::tHead() const
@@ -110,7 +110,7 @@
if (child->isElementNode() && !child->hasTagName(captionTag) && !child->hasTagName(colgroupTag))
break;
- insertBefore(newHead, child, ec);
+ insertBefore(*newHead, child, ec);
}
HTMLTableSectionElement* HTMLTableElement::tFoot() const
@@ -139,57 +139,60 @@
if (child->isElementNode() && !child->hasTagName(captionTag) && !child->hasTagName(colgroupTag) && !child->hasTagName(theadTag))
break;
- insertBefore(newFoot, child, ec);
+ insertBefore(*newFoot, child, ec);
}
-RefPtr<HTMLElement> HTMLTableElement::createTHead()
+Ref<HTMLTableSectionElement> HTMLTableElement::createTHead()
{
if (HTMLTableSectionElement* existingHead = tHead())
- return existingHead;
- RefPtr<HTMLTableSectionElement> head = HTMLTableSectionElement::create(theadTag, document());
- setTHead(head, IGNORE_EXCEPTION);
+ return *existingHead;
+ Ref<HTMLTableSectionElement> head = HTMLTableSectionElement::create(theadTag, document());
+ setTHead(head.ptr(), IGNORE_EXCEPTION);
return head;
}
void HTMLTableElement::deleteTHead()
{
- removeChild(tHead(), IGNORE_EXCEPTION);
+ if (auto* tHead = this->tHead())
+ removeChild(*tHead, IGNORE_EXCEPTION);
}
-RefPtr<HTMLElement> HTMLTableElement::createTFoot()
+Ref<HTMLTableSectionElement> HTMLTableElement::createTFoot()
{
if (HTMLTableSectionElement* existingFoot = tFoot())
- return existingFoot;
- RefPtr<HTMLTableSectionElement> foot = HTMLTableSectionElement::create(tfootTag, document());
- setTFoot(foot, IGNORE_EXCEPTION);
+ return *existingFoot;
+ Ref<HTMLTableSectionElement> foot = HTMLTableSectionElement::create(tfootTag, document());
+ setTFoot(foot.ptr(), IGNORE_EXCEPTION);
return foot;
}
void HTMLTableElement::deleteTFoot()
{
- removeChild(tFoot(), IGNORE_EXCEPTION);
+ if (auto* tFoot = this->tFoot())
+ removeChild(*tFoot, IGNORE_EXCEPTION);
}
-RefPtr<HTMLElement> HTMLTableElement::createTBody()
+Ref<HTMLTableSectionElement> HTMLTableElement::createTBody()
{
- RefPtr<HTMLTableSectionElement> body = HTMLTableSectionElement::create(tbodyTag, document());
- Node* referenceElement = lastBody() ? lastBody()->nextSibling() : 0;
- insertBefore(body, referenceElement, ASSERT_NO_EXCEPTION);
+ Ref<HTMLTableSectionElement> body = HTMLTableSectionElement::create(tbodyTag, document());
+ Node* referenceElement = lastBody() ? lastBody()->nextSibling() : nullptr;
+ insertBefore(body.copyRef(), referenceElement, ASSERT_NO_EXCEPTION);
return body;
}
-RefPtr<HTMLElement> HTMLTableElement::createCaption()
+Ref<HTMLTableCaptionElement> HTMLTableElement::createCaption()
{
if (HTMLTableCaptionElement* existingCaption = caption())
- return existingCaption;
- RefPtr<HTMLTableCaptionElement> caption = HTMLTableCaptionElement::create(captionTag, document());
- setCaption(caption, IGNORE_EXCEPTION);
+ return *existingCaption;
+ Ref<HTMLTableCaptionElement> caption = HTMLTableCaptionElement::create(captionTag, document());
+ setCaption(caption.ptr(), IGNORE_EXCEPTION);
return caption;
}
void HTMLTableElement::deleteCaption()
{
- removeChild(caption(), IGNORE_EXCEPTION);
+ if (auto* caption = this->caption())
+ removeChild(*caption, IGNORE_EXCEPTION);
}
HTMLTableSectionElement* HTMLTableElement::lastBody() const
@@ -234,22 +237,22 @@
else {
parent = lastBody();
if (!parent) {
- RefPtr<HTMLTableSectionElement> newBody = HTMLTableSectionElement::create(tbodyTag, document());
- RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
- newBody->appendChild(newRow, ec);
- appendChild(newBody.release(), ec);
- return newRow;
+ Ref<HTMLTableSectionElement> newBody = HTMLTableSectionElement::create(tbodyTag, document());
+ Ref<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
+ newBody->appendChild(newRow.copyRef(), ec);
+ appendChild(WTF::move(newBody), ec);
+ return WTF::move(newRow);
}
}
- RefPtr<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
- parent->insertBefore(newRow, row.get(), ec);
- return newRow;
+ Ref<HTMLTableRowElement> newRow = HTMLTableRowElement::create(document());
+ parent->insertBefore(newRow.copyRef(), row.get(), ec);
+ return WTF::move(newRow);
}
void HTMLTableElement::deleteRow(int index, ExceptionCode& ec)
{
- HTMLTableRowElement* row = 0;
+ HTMLTableRowElement* row = nullptr;
if (index == -1)
row = HTMLTableRowsCollection::lastRow(*this);
else {
diff --git a/Source/WebCore/html/HTMLTableElement.h b/Source/WebCore/html/HTMLTableElement.h
index cf5f4a0..3075835 100644
--- a/Source/WebCore/html/HTMLTableElement.h
+++ b/Source/WebCore/html/HTMLTableElement.h
@@ -49,12 +49,12 @@
HTMLTableSectionElement* tFoot() const;
void setTFoot(PassRefPtr<HTMLTableSectionElement>, ExceptionCode&);
- RefPtr<HTMLElement> createTHead();
+ Ref<HTMLTableSectionElement> createTHead();
void deleteTHead();
- RefPtr<HTMLElement> createTFoot();
+ Ref<HTMLTableSectionElement> createTFoot();
void deleteTFoot();
- RefPtr<HTMLElement> createTBody();
- RefPtr<HTMLElement> createCaption();
+ Ref<HTMLTableSectionElement> createTBody();
+ Ref<HTMLTableCaptionElement> createCaption();
void deleteCaption();
RefPtr<HTMLElement> insertRow(ExceptionCode& ec) { return insertRow(-1, ec); }
RefPtr<HTMLElement> insertRow(int index, ExceptionCode&);
diff --git a/Source/WebCore/html/HTMLTableRowElement.cpp b/Source/WebCore/html/HTMLTableRowElement.cpp
index c87259f..d8893cd 100644
--- a/Source/WebCore/html/HTMLTableRowElement.cpp
+++ b/Source/WebCore/html/HTMLTableRowElement.cpp
@@ -28,7 +28,6 @@
#include "ExceptionCode.h"
#include "GenericCachedHTMLCollection.h"
#include "HTMLNames.h"
-#include "HTMLTableCellElement.h"
#include "HTMLTableElement.h"
#include "HTMLTableSectionElement.h"
#include "NodeList.h"
@@ -119,27 +118,27 @@
return rIndex;
}
-RefPtr<HTMLElement> HTMLTableRowElement::insertCell(int index, ExceptionCode& ec)
+RefPtr<HTMLTableCellElement> HTMLTableRowElement::insertCell(int index, ExceptionCode& ec)
{
Ref<HTMLCollection> children = cells();
int numCells = children->length();
if (index < -1 || index > numCells) {
ec = INDEX_SIZE_ERR;
- return 0;
+ return nullptr;
}
- RefPtr<HTMLTableCellElement> cell = HTMLTableCellElement::create(tdTag, document());
+ Ref<HTMLTableCellElement> cell = HTMLTableCellElement::create(tdTag, document());
if (index < 0 || index >= numCells)
- appendChild(cell, ec);
+ appendChild(cell.copyRef(), ec);
else {
Node* n;
if (index < 1)
n = firstChild();
else
n = children->item(index);
- insertBefore(cell, n, ec);
+ insertBefore(cell.copyRef(), n, ec);
}
- return cell;
+ return WTF::move(cell);
}
void HTMLTableRowElement::deleteCell(int index, ExceptionCode& ec)
@@ -150,7 +149,7 @@
index = numCells-1;
if (index >= 0 && index < numCells) {
RefPtr<Node> cell = children->item(index);
- HTMLElement::removeChild(cell.get(), ec);
+ HTMLElement::removeChild(*cell, ec);
} else
ec = INDEX_SIZE_ERR;
}
diff --git a/Source/WebCore/html/HTMLTableRowElement.h b/Source/WebCore/html/HTMLTableRowElement.h
index c997aec..c9df5b6 100644
--- a/Source/WebCore/html/HTMLTableRowElement.h
+++ b/Source/WebCore/html/HTMLTableRowElement.h
@@ -26,6 +26,7 @@
#ifndef HTMLTableRowElement_h
#define HTMLTableRowElement_h
+#include "HTMLTableCellElement.h"
#include "HTMLTablePartElement.h"
namespace WebCore {
@@ -41,8 +42,8 @@
int sectionRowIndex() const;
void setSectionRowIndex(int);
- RefPtr<HTMLElement> insertCell(ExceptionCode& ec) { return insertCell(-1, ec); }
- RefPtr<HTMLElement> insertCell(int index, ExceptionCode&);
+ RefPtr<HTMLTableCellElement> insertCell(ExceptionCode& ec) { return insertCell(-1, ec); }
+ RefPtr<HTMLTableCellElement> insertCell(int index, ExceptionCode&);
void deleteCell(int index, ExceptionCode&);
Ref<HTMLCollection> cells();
diff --git a/Source/WebCore/html/HTMLTableSectionElement.cpp b/Source/WebCore/html/HTMLTableSectionElement.cpp
index 9e45316..fd02c60 100644
--- a/Source/WebCore/html/HTMLTableSectionElement.cpp
+++ b/Source/WebCore/html/HTMLTableSectionElement.cpp
@@ -68,14 +68,14 @@
else {
row = HTMLTableRowElement::create(trTag, document());
if (numRows == index || index == -1)
- appendChild(row, ec);
+ appendChild(*row, ec);
else {
Node* n;
if (index < 1)
n = firstChild();
else
n = children->item(index);
- insertBefore(row, n, ec);
+ insertBefore(*row, n, ec);
}
}
return row;
@@ -89,7 +89,7 @@
index = numRows - 1;
if (index >= 0 && index < numRows) {
RefPtr<Node> row = children->item(index);
- HTMLElement::removeChild(row.get(), ec);
+ HTMLElement::removeChild(*row, ec);
} else
ec = INDEX_SIZE_ERR;
}
diff --git a/Source/WebCore/html/HTMLTemplateElement.cpp b/Source/WebCore/html/HTMLTemplateElement.cpp
index aec3010..2e1edb2 100644
--- a/Source/WebCore/html/HTMLTemplateElement.cpp
+++ b/Source/WebCore/html/HTMLTemplateElement.cpp
@@ -68,7 +68,7 @@
return m_content.get();
}
-RefPtr<Node> HTMLTemplateElement::cloneNodeInternal(Document& targetDocument, CloningOperation type)
+Ref<Node> HTMLTemplateElement::cloneNodeInternal(Document& targetDocument, CloningOperation type)
{
RefPtr<Node> clone;
switch (type) {
@@ -82,8 +82,8 @@
break;
}
if (m_content)
- content()->cloneChildNodes(downcast<HTMLTemplateElement>(clone.get())->content());
- return clone.release();
+ content()->cloneChildNodes(*downcast<HTMLTemplateElement>(clone.get())->content());
+ return clone.releaseNonNull();
}
void HTMLTemplateElement::didMoveToNewDocument(Document* oldDocument)
diff --git a/Source/WebCore/html/HTMLTemplateElement.h b/Source/WebCore/html/HTMLTemplateElement.h
index 767f2a1..d1fa864 100644
--- a/Source/WebCore/html/HTMLTemplateElement.h
+++ b/Source/WebCore/html/HTMLTemplateElement.h
@@ -50,7 +50,7 @@
private:
HTMLTemplateElement(const QualifiedName&, Document&);
- virtual RefPtr<Node> cloneNodeInternal(Document&, CloningOperation) override;
+ virtual Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
virtual void didMoveToNewDocument(Document* oldDocument) override;
mutable RefPtr<TemplateContentDocumentFragment> m_content;
diff --git a/Source/WebCore/html/HTMLTextAreaElement.cpp b/Source/WebCore/html/HTMLTextAreaElement.cpp
index 9392911..a2de730 100644
--- a/Source/WebCore/html/HTMLTextAreaElement.cpp
+++ b/Source/WebCore/html/HTMLTextAreaElement.cpp
@@ -406,9 +406,9 @@
Ref<HTMLTextAreaElement> protectFromMutationEvents(*this);
// To preserve comments, remove only the text nodes, then add a single text node.
- Vector<RefPtr<Text>> textNodes;
+ Vector<Ref<Text>> textNodes;
for (Text* textNode = TextNodeTraversal::firstChild(*this); textNode; textNode = TextNodeTraversal::nextSibling(*textNode))
- textNodes.append(textNode);
+ textNodes.append(*textNode);
size_t size = textNodes.size();
for (size_t i = 0; i < size; ++i)
@@ -523,8 +523,8 @@
String placeholderText = strippedPlaceholder();
if (placeholderText.isEmpty()) {
if (m_placeholder) {
- userAgentShadowRoot()->removeChild(m_placeholder, ASSERT_NO_EXCEPTION);
- m_placeholder = 0;
+ userAgentShadowRoot()->removeChild(*m_placeholder, ASSERT_NO_EXCEPTION);
+ m_placeholder = nullptr;
}
return;
}
@@ -533,7 +533,7 @@
m_placeholder = placeholder.get();
m_placeholder->setPseudo(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral));
m_placeholder->setInlineStyleProperty(CSSPropertyDisplay, isPlaceholderVisible() ? CSSValueBlock : CSSValueNone, true);
- userAgentShadowRoot()->insertBefore(m_placeholder, innerTextElement()->nextSibling());
+ userAgentShadowRoot()->insertBefore(*m_placeholder, innerTextElement()->nextSibling());
}
m_placeholder->setInnerText(placeholderText, ASSERT_NO_EXCEPTION);
}
diff --git a/Source/WebCore/html/ImageDocument.cpp b/Source/WebCore/html/ImageDocument.cpp
index 980ea4e..0d1ab80 100644
--- a/Source/WebCore/html/ImageDocument.cpp
+++ b/Source/WebCore/html/ImageDocument.cpp
@@ -92,7 +92,7 @@
class ImageDocumentElement final : public HTMLImageElement {
public:
- static RefPtr<ImageDocumentElement> create(ImageDocument&);
+ static Ref<ImageDocumentElement> create(ImageDocument&);
private:
ImageDocumentElement(ImageDocument& document)
@@ -107,9 +107,9 @@
ImageDocument* m_imageDocument;
};
-inline RefPtr<ImageDocumentElement> ImageDocumentElement::create(ImageDocument& document)
+inline Ref<ImageDocumentElement> ImageDocumentElement::create(ImageDocument& document)
{
- return adoptRef(new ImageDocumentElement(document));
+ return adoptRef(*new ImageDocumentElement(document));
}
// --------
@@ -210,19 +210,19 @@
void ImageDocument::createDocumentStructure()
{
- RefPtr<Element> rootElement = Document::createElement(htmlTag, false);
- appendChild(rootElement);
- downcast<HTMLHtmlElement>(*rootElement).insertedByParser();
+ Ref<Element> rootElement = Document::createElement(htmlTag, false);
+ appendChild(rootElement.copyRef());
+ downcast<HTMLHtmlElement>(rootElement.get()).insertedByParser();
frame()->injectUserScripts(InjectAtDocumentStart);
- RefPtr<Element> body = Document::createElement(bodyTag, false);
+ Ref<Element> body = Document::createElement(bodyTag, false);
body->setAttribute(styleAttr, "margin: 0px");
if (MIMETypeRegistry::isPDFMIMEType(document().loader()->responseMIMEType()))
- downcast<HTMLBodyElement>(*body).setInlineStyleProperty(CSSPropertyBackgroundColor, "white", CSSPrimitiveValue::CSS_IDENT);
- rootElement->appendChild(body);
+ downcast<HTMLBodyElement>(body.get()).setInlineStyleProperty(CSSPropertyBackgroundColor, "white", CSSPrimitiveValue::CSS_IDENT);
+ rootElement->appendChild(body.copyRef());
- RefPtr<ImageDocumentElement> imageElement = ImageDocumentElement::create(*this);
+ Ref<ImageDocumentElement> imageElement = ImageDocumentElement::create(*this);
if (m_shouldShrinkImage)
imageElement->setAttribute(styleAttr, "-webkit-user-select:none; display:block; margin:auto;");
else
@@ -230,7 +230,7 @@
imageElement->setLoadManually(true);
imageElement->setSrc(url().string());
imageElement->cachedImage()->setResponse(loader()->response());
- body->appendChild(imageElement);
+ body->appendChild(imageElement.copyRef());
if (m_shouldShrinkImage) {
#if PLATFORM(IOS)
@@ -244,7 +244,7 @@
#endif
}
- m_imageElement = imageElement.get();
+ m_imageElement = imageElement.ptr();
}
void ImageDocument::imageUpdated()
diff --git a/Source/WebCore/html/MediaDocument.cpp b/Source/WebCore/html/MediaDocument.cpp
index 185aba8..d762452 100644
--- a/Source/WebCore/html/MediaDocument.cpp
+++ b/Source/WebCore/html/MediaDocument.cpp
@@ -78,30 +78,30 @@
void MediaDocumentParser::createDocumentStructure()
{
- RefPtr<Element> rootElement = document()->createElement(htmlTag, false);
- document()->appendChild(rootElement, IGNORE_EXCEPTION);
- document()->setCSSTarget(rootElement.get());
- downcast<HTMLHtmlElement>(*rootElement).insertedByParser();
+ Ref<Element> rootElement = document()->createElement(htmlTag, false);
+ document()->appendChild(rootElement.copyRef(), IGNORE_EXCEPTION);
+ document()->setCSSTarget(rootElement.ptr());
+ downcast<HTMLHtmlElement>(rootElement.get()).insertedByParser();
if (document()->frame())
document()->frame()->injectUserScripts(InjectAtDocumentStart);
#if PLATFORM(IOS)
- RefPtr<Element> headElement = document()->createElement(headTag, false);
- rootElement->appendChild(headElement, IGNORE_EXCEPTION);
+ Ref<Element> headElement = document()->createElement(headTag, false);
+ rootElement->appendChild(headElement.copyRef(), IGNORE_EXCEPTION);
- RefPtr<Element> metaElement = document()->createElement(metaTag, false);
+ Ref<Element> metaElement = document()->createElement(metaTag, false);
metaElement->setAttribute(nameAttr, "viewport");
metaElement->setAttribute(contentAttr, "width=device-width,initial-scale=1,user-scalable=no");
- headElement->appendChild(metaElement, IGNORE_EXCEPTION);
+ headElement->appendChild(WTF::move(metaElement), IGNORE_EXCEPTION);
#endif
- RefPtr<Element> body = document()->createElement(bodyTag, false);
- rootElement->appendChild(body, IGNORE_EXCEPTION);
+ Ref<Element> body = document()->createElement(bodyTag, false);
+ rootElement->appendChild(body.copyRef(), IGNORE_EXCEPTION);
- RefPtr<Element> mediaElement = document()->createElement(videoTag, false);
+ Ref<Element> mediaElement = document()->createElement(videoTag, false);
- m_mediaElement = downcast<HTMLVideoElement>(mediaElement.get());
+ m_mediaElement = downcast<HTMLVideoElement>(mediaElement.ptr());
m_mediaElement->setAttribute(controlsAttr, emptyAtom);
m_mediaElement->setAttribute(autoplayAttr, emptyAtom);
@@ -114,15 +114,15 @@
#endif
m_mediaElement->setAttribute(styleAttr, elementStyle.toString());
- RefPtr<Element> sourceElement = document()->createElement(sourceTag, false);
- HTMLSourceElement& source = downcast<HTMLSourceElement>(*sourceElement);
+ Ref<Element> 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(sourceElement, IGNORE_EXCEPTION);
- body->appendChild(mediaElement, IGNORE_EXCEPTION);
+ m_mediaElement->appendChild(WTF::move(sourceElement), IGNORE_EXCEPTION);
+ body->appendChild(WTF::move(mediaElement), IGNORE_EXCEPTION);
Frame* frame = document()->frame();
if (!frame)
@@ -253,7 +253,7 @@
if (documentLoader)
embedElement.setAttribute(typeAttr, documentLoader->writer().mimeType());
- videoElement->parentNode()->replaceChild(&embedElement, videoElement, IGNORE_EXCEPTION);
+ videoElement->parentNode()->replaceChild(embedElement, *videoElement, IGNORE_EXCEPTION);
}
}
diff --git a/Source/WebCore/html/PluginDocument.cpp b/Source/WebCore/html/PluginDocument.cpp
index e967709..c0a80ba 100644
--- a/Source/WebCore/html/PluginDocument.cpp
+++ b/Source/WebCore/html/PluginDocument.cpp
@@ -67,9 +67,9 @@
void PluginDocumentParser::createDocumentStructure()
{
- RefPtr<Element> rootElement = document()->createElement(htmlTag, false);
- document()->appendChild(rootElement, IGNORE_EXCEPTION);
- downcast<HTMLHtmlElement>(*rootElement).insertedByParser();
+ Ref<Element> rootElement = document()->createElement(htmlTag, false);
+ document()->appendChild(rootElement.copyRef(), IGNORE_EXCEPTION);
+ downcast<HTMLHtmlElement>(rootElement.get()).insertedByParser();
if (document()->frame())
document()->frame()->injectUserScripts(InjectAtDocumentStart);
@@ -79,7 +79,7 @@
document()->processViewport(ASCIILiteral("user-scalable=no"), ViewportArguments::PluginDocument);
#endif
- RefPtr<Element> body = document()->createElement(bodyTag, false);
+ Ref<Element> body = document()->createElement(bodyTag, false);
body->setAttribute(marginwidthAttr, AtomicString("0", AtomicString::ConstructFromLiteral));
body->setAttribute(marginheightAttr, AtomicString("0", AtomicString::ConstructFromLiteral));
#if PLATFORM(IOS)
@@ -88,11 +88,11 @@
body->setAttribute(styleAttr, AtomicString("background-color: rgb(38,38,38)", AtomicString::ConstructFromLiteral));
#endif
- rootElement->appendChild(body, IGNORE_EXCEPTION);
+ rootElement->appendChild(body.copyRef(), IGNORE_EXCEPTION);
- RefPtr<Element> embedElement = document()->createElement(embedTag, false);
+ Ref<Element> embedElement = document()->createElement(embedTag, false);
- m_embedElement = downcast<HTMLEmbedElement>(embedElement.get());
+ m_embedElement = downcast<HTMLEmbedElement>(embedElement.ptr());
m_embedElement->setAttribute(widthAttr, "100%");
m_embedElement->setAttribute(heightAttr, "100%");
@@ -106,7 +106,7 @@
downcast<PluginDocument>(*document()).setPluginElement(m_embedElement);
- body->appendChild(embedElement, IGNORE_EXCEPTION);
+ body->appendChild(WTF::move(embedElement), IGNORE_EXCEPTION);
}
void PluginDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
diff --git a/Source/WebCore/html/RangeInputType.cpp b/Source/WebCore/html/RangeInputType.cpp
index b5b9e79..66a7415 100644
--- a/Source/WebCore/html/RangeInputType.cpp
+++ b/Source/WebCore/html/RangeInputType.cpp
@@ -253,12 +253,12 @@
ASSERT(element().userAgentShadowRoot());
Document& document = element().document();
- RefPtr<HTMLDivElement> track = HTMLDivElement::create(document);
+ Ref<HTMLDivElement> track = HTMLDivElement::create(document);
track->setPseudo(AtomicString("-webkit-slider-runnable-track", AtomicString::ConstructFromLiteral));
track->appendChild(SliderThumbElement::create(document), IGNORE_EXCEPTION);
- RefPtr<HTMLElement> container = SliderContainerElement::create(document);
- container->appendChild(track.release(), IGNORE_EXCEPTION);
- element().userAgentShadowRoot()->appendChild(container.release(), IGNORE_EXCEPTION);
+ Ref<HTMLElement> container = SliderContainerElement::create(document);
+ container->appendChild(WTF::move(track), IGNORE_EXCEPTION);
+ element().userAgentShadowRoot()->appendChild(WTF::move(container), IGNORE_EXCEPTION);
}
HTMLElement* RangeInputType::sliderTrackElement() const
diff --git a/Source/WebCore/html/SearchInputType.cpp b/Source/WebCore/html/SearchInputType.cpp
index de43db5..357c7a6 100644
--- a/Source/WebCore/html/SearchInputType.cpp
+++ b/Source/WebCore/html/SearchInputType.cpp
@@ -107,14 +107,14 @@
ASSERT(container);
ASSERT(textWrapper);
- RefPtr<SearchFieldResultsButtonElement> resultsButton = SearchFieldResultsButtonElement::create(element().document());
- m_resultsButton = resultsButton.get();
- updateResultButtonPseudoType(*m_resultsButton, element().maxResults());
- container->insertBefore(m_resultsButton, textWrapper, IGNORE_EXCEPTION);
+ Ref<SearchFieldResultsButtonElement> resultsButton = SearchFieldResultsButtonElement::create(element().document());
+ m_resultsButton = resultsButton.ptr();
+ updateResultButtonPseudoType(resultsButton.get(), element().maxResults());
+ container->insertBefore(WTF::move(resultsButton), textWrapper, IGNORE_EXCEPTION);
- RefPtr<SearchFieldCancelButtonElement> cancelButton = SearchFieldCancelButtonElement::create(element().document());
- m_cancelButton = cancelButton.get();
- container->insertBefore(m_cancelButton, textWrapper->nextSibling(), IGNORE_EXCEPTION);
+ Ref<SearchFieldCancelButtonElement> cancelButton = SearchFieldCancelButtonElement::create(element().document());
+ m_cancelButton = cancelButton.ptr();
+ container->insertBefore(WTF::move(cancelButton), textWrapper->nextSibling(), IGNORE_EXCEPTION);
}
HTMLElement* SearchInputType::resultsButtonElement() const
diff --git a/Source/WebCore/html/TextFieldInputType.cpp b/Source/WebCore/html/TextFieldInputType.cpp
index eae3db2..136f097 100644
--- a/Source/WebCore/html/TextFieldInputType.cpp
+++ b/Source/WebCore/html/TextFieldInputType.cpp
@@ -274,7 +274,7 @@
m_innerText = TextControlInnerTextElement::create(document);
if (!createsContainer) {
- element().userAgentShadowRoot()->appendChild(m_innerText, IGNORE_EXCEPTION);
+ element().userAgentShadowRoot()->appendChild(*m_innerText, IGNORE_EXCEPTION);
updatePlaceholderText();
return;
}
@@ -284,7 +284,7 @@
if (shouldHaveSpinButton) {
m_innerSpinButton = SpinButtonElement::create(document, *this);
- m_container->appendChild(m_innerSpinButton, IGNORE_EXCEPTION);
+ m_container->appendChild(*m_innerSpinButton, IGNORE_EXCEPTION);
}
if (shouldHaveCapsLockIndicator) {
@@ -294,7 +294,7 @@
bool shouldDrawCapsLockIndicator = this->shouldDrawCapsLockIndicator();
m_capsLockIndicator->setInlineStyleProperty(CSSPropertyDisplay, shouldDrawCapsLockIndicator ? CSSValueBlock : CSSValueNone, true);
- m_container->appendChild(m_capsLockIndicator, IGNORE_EXCEPTION);
+ m_container->appendChild(*m_capsLockIndicator, IGNORE_EXCEPTION);
}
updateAutoFillButton();
@@ -461,7 +461,7 @@
String placeholderText = element().strippedPlaceholder();
if (placeholderText.isEmpty()) {
if (m_placeholder) {
- m_placeholder->parentNode()->removeChild(m_placeholder.get(), ASSERT_NO_EXCEPTION);
+ m_placeholder->parentNode()->removeChild(*m_placeholder, ASSERT_NO_EXCEPTION);
m_placeholder = nullptr;
}
return;
@@ -470,7 +470,7 @@
m_placeholder = HTMLDivElement::create(element().document());
m_placeholder->setPseudo(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral));
m_placeholder->setInlineStyleProperty(CSSPropertyDisplay, element().isPlaceholderVisible() ? CSSValueBlock : CSSValueNone, true);
- element().userAgentShadowRoot()->insertBefore(m_placeholder, m_container ? m_container.get() : innerTextElement(), ASSERT_NO_EXCEPTION);
+ element().userAgentShadowRoot()->insertBefore(*m_placeholder, m_container ? m_container.get() : innerTextElement(), ASSERT_NO_EXCEPTION);
}
m_placeholder->setInnerText(placeholderText, ASSERT_NO_EXCEPTION);
@@ -600,10 +600,10 @@
m_container->setPseudo(AtomicString("-webkit-textfield-decoration-container", AtomicString::ConstructFromLiteral));
m_innerBlock = TextControlInnerElement::create(element().document());
- m_innerBlock->appendChild(m_innerText, IGNORE_EXCEPTION);
- m_container->appendChild(m_innerBlock, IGNORE_EXCEPTION);
+ m_innerBlock->appendChild(*m_innerText, IGNORE_EXCEPTION);
+ m_container->appendChild(*m_innerBlock, IGNORE_EXCEPTION);
- element().userAgentShadowRoot()->appendChild(m_container, IGNORE_EXCEPTION);
+ element().userAgentShadowRoot()->appendChild(*m_container, IGNORE_EXCEPTION);
}
void TextFieldInputType::createAutoFillButton()
@@ -612,7 +612,7 @@
m_autoFillButton = AutoFillButtonElement::create(element().document(), *this);
m_autoFillButton->setPseudo(AtomicString("-webkit-auto-fill-button", AtomicString::ConstructFromLiteral));
- m_container->appendChild(m_autoFillButton, IGNORE_EXCEPTION);
+ m_container->appendChild(*m_autoFillButton, IGNORE_EXCEPTION);
}
void TextFieldInputType::updateAutoFillButton()
diff --git a/Source/WebCore/html/ValidationMessage.cpp b/Source/WebCore/html/ValidationMessage.cpp
index f61e1b5..906295e 100644
--- a/Source/WebCore/html/ValidationMessage.cpp
+++ b/Source/WebCore/html/ValidationMessage.cpp
@@ -180,32 +180,32 @@
// Need to force position:absolute because RenderMenuList doesn't assume it
// contains non-absolute or non-fixed renderers as children.
m_bubble->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
- shadowRoot.appendChild(m_bubble.get(), ASSERT_NO_EXCEPTION);
+ shadowRoot.appendChild(*m_bubble, ASSERT_NO_EXCEPTION);
document.updateLayout();
adjustBubblePosition(m_element->renderer()->absoluteBoundingBoxRect(), m_bubble.get());
- RefPtr<HTMLDivElement> clipper = HTMLDivElement::create(document);
+ Ref<HTMLDivElement> clipper = HTMLDivElement::create(document);
clipper->setPseudo(AtomicString("-webkit-validation-bubble-arrow-clipper", AtomicString::ConstructFromLiteral));
- RefPtr<HTMLDivElement> bubbleArrow = HTMLDivElement::create(document);
+ Ref<HTMLDivElement> bubbleArrow = HTMLDivElement::create(document);
bubbleArrow->setPseudo(AtomicString("-webkit-validation-bubble-arrow", AtomicString::ConstructFromLiteral));
- clipper->appendChild(bubbleArrow.release(), ASSERT_NO_EXCEPTION);
- m_bubble->appendChild(clipper.release(), ASSERT_NO_EXCEPTION);
+ clipper->appendChild(WTF::move(bubbleArrow), ASSERT_NO_EXCEPTION);
+ m_bubble->appendChild(WTF::move(clipper), ASSERT_NO_EXCEPTION);
- RefPtr<HTMLElement> message = HTMLDivElement::create(document);
+ Ref<HTMLElement> message = HTMLDivElement::create(document);
message->setPseudo(AtomicString("-webkit-validation-bubble-message", AtomicString::ConstructFromLiteral));
- RefPtr<HTMLElement> icon = HTMLDivElement::create(document);
+ Ref<HTMLElement> icon = HTMLDivElement::create(document);
icon->setPseudo(AtomicString("-webkit-validation-bubble-icon", AtomicString::ConstructFromLiteral));
- message->appendChild(icon.release(), ASSERT_NO_EXCEPTION);
- RefPtr<HTMLElement> textBlock = HTMLDivElement::create(document);
+ message->appendChild(WTF::move(icon), ASSERT_NO_EXCEPTION);
+ Ref<HTMLElement> 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));
- textBlock->appendChild(m_messageHeading, ASSERT_NO_EXCEPTION);
+ textBlock->appendChild(*m_messageHeading, ASSERT_NO_EXCEPTION);
m_messageBody = HTMLDivElement::create(document);
m_messageBody->setPseudo(AtomicString("-webkit-validation-bubble-body", AtomicString::ConstructFromLiteral));
- textBlock->appendChild(m_messageBody, ASSERT_NO_EXCEPTION);
- message->appendChild(textBlock.release(), ASSERT_NO_EXCEPTION);
- m_bubble->appendChild(message.release(), ASSERT_NO_EXCEPTION);
+ textBlock->appendChild(*m_messageBody, ASSERT_NO_EXCEPTION);
+ message->appendChild(WTF::move(textBlock), ASSERT_NO_EXCEPTION);
+ m_bubble->appendChild(WTF::move(message), ASSERT_NO_EXCEPTION);
setMessageDOMAndStartTimer();
@@ -237,7 +237,7 @@
if (m_bubble) {
m_messageHeading = nullptr;
m_messageBody = nullptr;
- m_element->userAgentShadowRoot()->removeChild(m_bubble.get(), ASSERT_NO_EXCEPTION);
+ m_element->userAgentShadowRoot()->removeChild(*m_bubble, ASSERT_NO_EXCEPTION);
m_bubble = nullptr;
}
m_message = String();
diff --git a/Source/WebCore/html/shadow/MediaControlElements.cpp b/Source/WebCore/html/shadow/MediaControlElements.cpp
index 9e483a9..22ce339 100644
--- a/Source/WebCore/html/shadow/MediaControlElements.cpp
+++ b/Source/WebCore/html/shadow/MediaControlElements.cpp
@@ -807,21 +807,21 @@
CaptionUserPreferences* captionPreferences = document().page()->group().captionPreferences();
Vector<RefPtr<TextTrack>> tracksForMenu = captionPreferences->sortedTrackListForMenu(trackList);
- RefPtr<Element> captionsHeader = document().createElement(h3Tag, ASSERT_NO_EXCEPTION);
+ Ref<Element> captionsHeader = document().createElement(h3Tag, ASSERT_NO_EXCEPTION);
captionsHeader->appendChild(document().createTextNode(textTrackSubtitlesText()));
- appendChild(captionsHeader);
- RefPtr<Element> captionsMenuList = document().createElement(ulTag, ASSERT_NO_EXCEPTION);
+ appendChild(WTF::move(captionsHeader));
+ Ref<Element> captionsMenuList = document().createElement(ulTag, ASSERT_NO_EXCEPTION);
for (unsigned i = 0, length = tracksForMenu.size(); i < length; ++i) {
RefPtr<TextTrack> textTrack = tracksForMenu[i];
- RefPtr<Element> menuItem = document().createElement(liTag, ASSERT_NO_EXCEPTION);
+ Ref<Element> menuItem = document().createElement(liTag, ASSERT_NO_EXCEPTION);
menuItem->appendChild(document().createTextNode(captionPreferences->displayNameForTrack(textTrack.get())));
- captionsMenuList->appendChild(menuItem);
- m_menuItems.append(menuItem);
- m_menuToTrackMap.add(menuItem, textTrack);
+ captionsMenuList->appendChild(menuItem.copyRef());
+ m_menuItems.append(menuItem.ptr());
+ m_menuToTrackMap.add(menuItem.ptr(), textTrack);
}
- appendChild(captionsMenuList);
+ appendChild(WTF::move(captionsMenuList));
#endif
}
@@ -1186,16 +1186,16 @@
// track cue region identifier, run the following substeps:
if (displayBox->hasChildNodes() && !contains(displayBox.get())) {
// Note: the display tree of a cue is removed when the active flag of the cue is unset.
- appendChild(displayBox, ASSERT_NO_EXCEPTION);
+ appendChild(*displayBox, ASSERT_NO_EXCEPTION);
cue->setFontSize(m_fontSize, m_videoDisplaySize.size(), m_fontSizeIsImportant);
}
} else {
// Let region be the WebVTT region whose region identifier
// matches the text track cue region identifier of cue.
- RefPtr<HTMLDivElement> regionNode = region->getDisplayTree();
+ Ref<HTMLDivElement> regionNode = region->getDisplayTree();
// Append the region to the viewport, if it was not already.
- if (!contains(regionNode.get()))
+ if (!contains(regionNode.ptr()))
appendChild(region->getDisplayTree());
region->appendTextTrackCueBox(displayBox);
diff --git a/Source/WebCore/html/shadow/MediaControls.cpp b/Source/WebCore/html/shadow/MediaControls.cpp
index 3dd6de8..9df998f 100644
--- a/Source/WebCore/html/shadow/MediaControls.cpp
+++ b/Source/WebCore/html/shadow/MediaControls.cpp
@@ -380,14 +380,14 @@
if (m_textDisplayContainer)
return;
- RefPtr<MediaControlTextTrackContainerElement> textDisplayContainer = MediaControlTextTrackContainerElement::create(document());
- m_textDisplayContainer = textDisplayContainer.get();
+ Ref<MediaControlTextTrackContainerElement> 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(textDisplayContainer.release(), m_panel, IGNORE_EXCEPTION);
+ insertBefore(WTF::move(textDisplayContainer), m_panel, IGNORE_EXCEPTION);
}
void MediaControls::showTextTrackDisplay()
diff --git a/Source/WebCore/html/shadow/MediaControlsApple.cpp b/Source/WebCore/html/shadow/MediaControlsApple.cpp
index 3f42aba..7fb263d 100644
--- a/Source/WebCore/html/shadow/MediaControlsApple.cpp
+++ b/Source/WebCore/html/shadow/MediaControlsApple.cpp
@@ -63,165 +63,165 @@
PassRefPtr<MediaControlsApple> MediaControlsApple::createControls(Document& document)
{
if (!document.page())
- return 0;
+ return nullptr;
RefPtr<MediaControlsApple> controls = adoptRef(new MediaControlsApple(document));
- RefPtr<MediaControlPanelElement> panel = MediaControlPanelElement::create(document);
+ Ref<MediaControlPanelElement> panel = MediaControlPanelElement::create(document);
ExceptionCode ec;
- RefPtr<MediaControlRewindButtonElement> rewindButton = MediaControlRewindButtonElement::create(document);
- controls->m_rewindButton = rewindButton.get();
- panel->appendChild(rewindButton.release(), ec);
+ Ref<MediaControlRewindButtonElement> rewindButton = MediaControlRewindButtonElement::create(document);
+ controls->m_rewindButton = rewindButton.ptr();
+ panel->appendChild(WTF::move(rewindButton), ec);
if (ec)
- return 0;
+ return nullptr;
- RefPtr<MediaControlPlayButtonElement> playButton = MediaControlPlayButtonElement::create(document);
- controls->m_playButton = playButton.get();
- panel->appendChild(playButton.release(), ec);
+ Ref<MediaControlPlayButtonElement> playButton = MediaControlPlayButtonElement::create(document);
+ controls->m_playButton = playButton.ptr();
+ panel->appendChild(WTF::move(playButton), ec);
if (ec)
- return 0;
+ return nullptr;
- RefPtr<MediaControlReturnToRealtimeButtonElement> returnToRealtimeButton = MediaControlReturnToRealtimeButtonElement::create(document);
- controls->m_returnToRealTimeButton = returnToRealtimeButton.get();
- panel->appendChild(returnToRealtimeButton.release(), ec);
+ Ref<MediaControlReturnToRealtimeButtonElement> returnToRealtimeButton = MediaControlReturnToRealtimeButtonElement::create(document);
+ controls->m_returnToRealTimeButton = returnToRealtimeButton.ptr();
+ panel->appendChild(WTF::move(returnToRealtimeButton), ec);
if (ec)
- return 0;
+ return nullptr;
if (document.page()->theme().usesMediaControlStatusDisplay()) {
- RefPtr<MediaControlStatusDisplayElement> statusDisplay = MediaControlStatusDisplayElement::create(document);
- controls->m_statusDisplay = statusDisplay.get();
- panel->appendChild(statusDisplay.release(), ec);
+ Ref<MediaControlStatusDisplayElement> statusDisplay = MediaControlStatusDisplayElement::create(document);
+ controls->m_statusDisplay = statusDisplay.ptr();
+ panel->appendChild(WTF::move(statusDisplay), ec);
if (ec)
- return 0;
+ return nullptr;
}
- RefPtr<MediaControlTimelineContainerElement> timelineContainer = MediaControlTimelineContainerElement::create(document);
+ Ref<MediaControlTimelineContainerElement> timelineContainer = MediaControlTimelineContainerElement::create(document);
- RefPtr<MediaControlCurrentTimeDisplayElement> currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(document);
- controls->m_currentTimeDisplay = currentTimeDisplay.get();
- timelineContainer->appendChild(currentTimeDisplay.release(), ec);
+ Ref<MediaControlCurrentTimeDisplayElement> currentTimeDisplay = MediaControlCurrentTimeDisplayElement::create(document);
+ controls->m_currentTimeDisplay = currentTimeDisplay.ptr();
+ timelineContainer->appendChild(WTF::move(currentTimeDisplay), ec);
if (ec)
- return 0;
+ return nullptr;
- RefPtr<MediaControlTimelineElement> timeline = MediaControlTimelineElement::create(document, controls.get());
- controls->m_timeline = timeline.get();
- timelineContainer->appendChild(timeline.release(), ec);
+ Ref<MediaControlTimelineElement> timeline = MediaControlTimelineElement::create(document, controls.get());
+ controls->m_timeline = timeline.ptr();
+ timelineContainer->appendChild(WTF::move(timeline), ec);
if (ec)
- return 0;
+ return nullptr;
- RefPtr<MediaControlTimeRemainingDisplayElement> timeRemainingDisplay = MediaControlTimeRemainingDisplayElement::create(document);
- controls->m_timeRemainingDisplay = timeRemainingDisplay.get();
- timelineContainer->appendChild(timeRemainingDisplay.release(), ec);
+ Ref<MediaControlTimeRemainingDisplayElement> timeRemainingDisplay = MediaControlTimeRemainingDisplayElement::create(document);
+ controls->m_timeRemainingDisplay = timeRemainingDisplay.ptr();
+ timelineContainer->appendChild(WTF::move(timeRemainingDisplay), ec);
if (ec)
- return 0;
+ return nullptr;
- controls->m_timelineContainer = timelineContainer.get();
- panel->appendChild(timelineContainer.release(), ec);
+ controls->m_timelineContainer = timelineContainer.ptr();
+ panel->appendChild(WTF::move(timelineContainer), ec);
if (ec)
- return 0;
+ return nullptr;
// FIXME: Only create when needed <http://webkit.org/b/57163>
- RefPtr<MediaControlSeekBackButtonElement> seekBackButton = MediaControlSeekBackButtonElement::create(document);
- controls->m_seekBackButton = seekBackButton.get();
- panel->appendChild(seekBackButton.release(), ec);
+ Ref<MediaControlSeekBackButtonElement> seekBackButton = MediaControlSeekBackButtonElement::create(document);
+ controls->m_seekBackButton = seekBackButton.ptr();
+ panel->appendChild(WTF::move(seekBackButton), ec);
if (ec)
- return 0;
+ return nullptr;
// FIXME: Only create when needed <http://webkit.org/b/57163>
- RefPtr<MediaControlSeekForwardButtonElement> seekForwardButton = MediaControlSeekForwardButtonElement::create(document);
- controls->m_seekForwardButton = seekForwardButton.get();
- panel->appendChild(seekForwardButton.release(), ec);
+ Ref<MediaControlSeekForwardButtonElement> seekForwardButton = MediaControlSeekForwardButtonElement::create(document);
+ controls->m_seekForwardButton = seekForwardButton.ptr();
+ panel->appendChild(WTF::move(seekForwardButton), ec);
if (ec)
- return 0;
+ return nullptr;
if (document.page()->theme().supportsClosedCaptioning()) {
- RefPtr<MediaControlClosedCaptionsContainerElement> closedCaptionsContainer = MediaControlClosedCaptionsContainerElement::create(document);
+ Ref<MediaControlClosedCaptionsContainerElement> closedCaptionsContainer = MediaControlClosedCaptionsContainerElement::create(document);
- RefPtr<MediaControlClosedCaptionsTrackListElement> closedCaptionsTrackList = MediaControlClosedCaptionsTrackListElement::create(document, controls.get());
- controls->m_closedCaptionsTrackList = closedCaptionsTrackList.get();
- closedCaptionsContainer->appendChild(closedCaptionsTrackList.release(), ec);
+ Ref<MediaControlClosedCaptionsTrackListElement> closedCaptionsTrackList = MediaControlClosedCaptionsTrackListElement::create(document, controls.get());
+ controls->m_closedCaptionsTrackList = closedCaptionsTrackList.ptr();
+ closedCaptionsContainer->appendChild(WTF::move(closedCaptionsTrackList), ec);
if (ec)
- return 0;
+ return nullptr;
- RefPtr<MediaControlToggleClosedCaptionsButtonElement> toggleClosedCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(document, controls.get());
- controls->m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.get();
- panel->appendChild(toggleClosedCaptionsButton.release(), ec);
+ Ref<MediaControlToggleClosedCaptionsButtonElement> toggleClosedCaptionsButton = MediaControlToggleClosedCaptionsButtonElement::create(document, controls.get());
+ controls->m_toggleClosedCaptionsButton = toggleClosedCaptionsButton.ptr();
+ panel->appendChild(WTF::move(toggleClosedCaptionsButton), ec);
if (ec)
- return 0;
+ return nullptr;
- controls->m_closedCaptionsContainer = closedCaptionsContainer.get();
- controls->appendChild(closedCaptionsContainer.release(), ec);
+ controls->m_closedCaptionsContainer = closedCaptionsContainer.ptr();
+ controls->appendChild(WTF::move(closedCaptionsContainer), ec);
if (ec)
- return 0;
+ return nullptr;
}
// FIXME: Only create when needed <http://webkit.org/b/57163>
- RefPtr<MediaControlFullscreenButtonElement> fullScreenButton = MediaControlFullscreenButtonElement::create(document);
- controls->m_fullScreenButton = fullScreenButton.get();
- panel->appendChild(fullScreenButton.release(), ec);
+ Ref<MediaControlFullscreenButtonElement> fullScreenButton = MediaControlFullscreenButtonElement::create(document);
+ controls->m_fullScreenButton = fullScreenButton.ptr();
+ panel->appendChild(WTF::move(fullScreenButton), ec);
// The mute button and the slider element should be in the same div.
- RefPtr<HTMLDivElement> panelVolumeControlContainer = HTMLDivElement::create(document);
+ Ref<HTMLDivElement> panelVolumeControlContainer = HTMLDivElement::create(document);
if (document.page()->theme().usesMediaControlVolumeSlider()) {
- RefPtr<MediaControlVolumeSliderContainerElement> volumeSliderContainer = MediaControlVolumeSliderContainerElement::create(document);
+ Ref<MediaControlVolumeSliderContainerElement> volumeSliderContainer = MediaControlVolumeSliderContainerElement::create(document);
- RefPtr<MediaControlPanelVolumeSliderElement> slider = MediaControlPanelVolumeSliderElement::create(document);
- controls->m_volumeSlider = slider.get();
- volumeSliderContainer->appendChild(slider.release(), ec);
+ Ref<MediaControlPanelVolumeSliderElement> slider = MediaControlPanelVolumeSliderElement::create(document);
+ controls->m_volumeSlider = slider.ptr();
+ volumeSliderContainer->appendChild(WTF::move(slider), ec);
if (ec)
- return 0;
+ return nullptr;
// This is a duplicate mute button, which is visible in some ports at the bottom of the volume bar.
// It's important only when the volume bar is displayed below the controls.
- RefPtr<MediaControlVolumeSliderMuteButtonElement> volumeSliderMuteButton = MediaControlVolumeSliderMuteButtonElement::create(document);
- controls->m_volumeSliderMuteButton = volumeSliderMuteButton.get();
- volumeSliderContainer->appendChild(volumeSliderMuteButton.release(), ec);
+ Ref<MediaControlVolumeSliderMuteButtonElement> volumeSliderMuteButton = MediaControlVolumeSliderMuteButtonElement::create(document);
+ controls->m_volumeSliderMuteButton = volumeSliderMuteButton.ptr();
+ volumeSliderContainer->appendChild(WTF::move(volumeSliderMuteButton), ec);
if (ec)
- return 0;
+ return nullptr;
- controls->m_volumeSliderContainer = volumeSliderContainer.get();
- panelVolumeControlContainer->appendChild(volumeSliderContainer.release(), ec);
+ controls->m_volumeSliderContainer = volumeSliderContainer.ptr();
+ panelVolumeControlContainer->appendChild(WTF::move(volumeSliderContainer), ec);
if (ec)
- return 0;
+ return nullptr;
}
- RefPtr<MediaControlPanelMuteButtonElement> panelMuteButton = MediaControlPanelMuteButtonElement::create(document, controls.get());
- controls->m_panelMuteButton = panelMuteButton.get();
- panelVolumeControlContainer->appendChild(panelMuteButton.release(), ec);
+ Ref<MediaControlPanelMuteButtonElement> panelMuteButton = MediaControlPanelMuteButtonElement::create(document, controls.get());
+ controls->m_panelMuteButton = panelMuteButton.ptr();
+ panelVolumeControlContainer->appendChild(WTF::move(panelMuteButton), ec);
if (ec)
- return 0;
+ return nullptr;
- panel->appendChild(panelVolumeControlContainer, ec);
+ panel->appendChild(WTF::move(panelVolumeControlContainer), ec);
if (ec)
- return 0;
+ return nullptr;
// FIXME: Only create when needed <http://webkit.org/b/57163>
- RefPtr<MediaControlFullscreenVolumeMinButtonElement> fullScreenMinVolumeButton = MediaControlFullscreenVolumeMinButtonElement::create(document);
- controls->m_fullScreenMinVolumeButton = fullScreenMinVolumeButton.get();
- panel->appendChild(fullScreenMinVolumeButton.release(), ec);
+ Ref<MediaControlFullscreenVolumeMinButtonElement> fullScreenMinVolumeButton = MediaControlFullscreenVolumeMinButtonElement::create(document);
+ controls->m_fullScreenMinVolumeButton = fullScreenMinVolumeButton.ptr();
+ panel->appendChild(WTF::move(fullScreenMinVolumeButton), ec);
if (ec)
- return 0;
+ return nullptr;
- RefPtr<MediaControlFullscreenVolumeSliderElement> fullScreenVolumeSlider = MediaControlFullscreenVolumeSliderElement::create(document);
- controls->m_fullScreenVolumeSlider = fullScreenVolumeSlider.get();
- panel->appendChild(fullScreenVolumeSlider.release(), ec);
+ Ref<MediaControlFullscreenVolumeSliderElement> fullScreenVolumeSlider = MediaControlFullscreenVolumeSliderElement::create(document);
+ controls->m_fullScreenVolumeSlider = fullScreenVolumeSlider.ptr();
+ panel->appendChild(WTF::move(fullScreenVolumeSlider), ec);
if (ec)
- return 0;
+ return nullptr;
- RefPtr<MediaControlFullscreenVolumeMaxButtonElement> fullScreenMaxVolumeButton = MediaControlFullscreenVolumeMaxButtonElement::create(document);
- controls->m_fullScreenMaxVolumeButton = fullScreenMaxVolumeButton.get();
- panel->appendChild(fullScreenMaxVolumeButton.release(), ec);
+ Ref<MediaControlFullscreenVolumeMaxButtonElement> fullScreenMaxVolumeButton = MediaControlFullscreenVolumeMaxButtonElement::create(document);
+ controls->m_fullScreenMaxVolumeButton = fullScreenMaxVolumeButton.ptr();
+ panel->appendChild(WTF::move(fullScreenMaxVolumeButton), ec);
if (ec)
- return 0;
+ return nullptr;
- controls->m_panel = panel.get();
- controls->appendChild(panel.release(), ec);
+ controls->m_panel = panel.ptr();
+ controls->appendChild(WTF::move(panel), ec);
if (ec)
- return 0;
+ return nullptr;
return controls.release();
}
diff --git a/Source/WebCore/html/shadow/SliderThumbElement.cpp b/Source/WebCore/html/shadow/SliderThumbElement.cpp
index 52cac05..2cac6f4 100644
--- a/Source/WebCore/html/shadow/SliderThumbElement.cpp
+++ b/Source/WebCore/html/shadow/SliderThumbElement.cpp
@@ -612,7 +612,7 @@
}
}
-RefPtr<Element> SliderThumbElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
+Ref<Element> SliderThumbElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
{
return create(targetDocument);
}
diff --git a/Source/WebCore/html/shadow/SliderThumbElement.h b/Source/WebCore/html/shadow/SliderThumbElement.h
index 48ecd55..cf2f85a 100644
--- a/Source/WebCore/html/shadow/SliderThumbElement.h
+++ b/Source/WebCore/html/shadow/SliderThumbElement.h
@@ -62,7 +62,7 @@
SliderThumbElement(Document&);
virtual RenderPtr<RenderElement> createElementRenderer(Ref<RenderStyle>&&, const RenderTreePosition&) override;
- virtual RefPtr<Element> cloneElementWithoutAttributesAndChildren(Document&) override;
+ virtual Ref<Element> cloneElementWithoutAttributesAndChildren(Document&) override;
virtual bool isDisabledFormControl() const override;
virtual bool matchesReadWritePseudoClass() const override;
virtual Element* focusDelegate() override;
diff --git a/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp b/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp
index a44a5de..c44c518 100644
--- a/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp
+++ b/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp
@@ -85,12 +85,13 @@
if (!document.page())
return nullptr;
- RefPtr<ImageControlsRootElementMac> controls = adoptRef(*new ImageControlsRootElementMac(document));
+ Ref<ImageControlsRootElementMac> controls = adoptRef(*new ImageControlsRootElementMac(document));
controls->setAttribute(HTMLNames::classAttr, "x-webkit-image-controls");
- controls->appendChild(ImageControlsButtonElementMac::maybeCreate(document));
+ if (RefPtr<ImageControlsButtonElementMac> button = ImageControlsButtonElementMac::maybeCreate(document))
+ controls->appendChild(button.releaseNonNull());
- return controls.release();
+ return WTF::move(controls);
}
ImageControlsRootElementMac::ImageControlsRootElementMac(Document& document)
diff --git a/Source/WebCore/html/track/VTTCue.cpp b/Source/WebCore/html/track/VTTCue.cpp
index a9690d6..9d6ca72 100644
--- a/Source/WebCore/html/track/VTTCue.cpp
+++ b/Source/WebCore/html/track/VTTCue.cpp
@@ -496,7 +496,7 @@
clonedNode = downcast<WebVTTElement>(*node).createEquivalentHTMLElement(ownerDocument());
else
clonedNode = node->cloneNode(false);
- parent->appendChild(clonedNode, ASSERT_NO_EXCEPTION);
+ parent->appendChild(*clonedNode, ASSERT_NO_EXCEPTION);
if (is<ContainerNode>(*node))
copyWebVTTNodeToDOMTree(downcast<ContainerNode>(node), downcast<ContainerNode>(clonedNode.get()));
}
@@ -518,10 +518,10 @@
RefPtr<DocumentFragment> clonedFragment;
createWebVTTNodeTree();
if (!m_webVTTNodeTree)
- return 0;
+ return nullptr;
clonedFragment = DocumentFragment::create(ownerDocument());
- m_webVTTNodeTree->cloneChildNodes(clonedFragment.get());
+ m_webVTTNodeTree->cloneChildNodes(*clonedFragment);
return clonedFragment.release();
}
@@ -785,7 +785,7 @@
return;
markFutureAndPastNodes(referenceTree.get(), startMediaTime(), movieTime);
- m_cueHighlightBox->appendChild(referenceTree);
+ m_cueHighlightBox->appendChild(referenceTree.releaseNonNull());
}
VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize)
@@ -812,8 +812,8 @@
m_cueHighlightBox->setPseudo(cueShadowPseudoId());
m_cueBackdropBox->setPseudo(cueBackdropShadowPseudoId());
- m_cueBackdropBox->appendChild(m_cueHighlightBox, ASSERT_NO_EXCEPTION);
- displayTree->appendChild(m_cueBackdropBox, ASSERT_NO_EXCEPTION);
+ m_cueBackdropBox->appendChild(*m_cueHighlightBox, ASSERT_NO_EXCEPTION);
+ displayTree->appendChild(*m_cueBackdropBox, ASSERT_NO_EXCEPTION);
// FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
// WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
diff --git a/Source/WebCore/html/track/VTTRegion.cpp b/Source/WebCore/html/track/VTTRegion.cpp
index ccb32e0..8579868 100644
--- a/Source/WebCore/html/track/VTTRegion.cpp
+++ b/Source/WebCore/html/track/VTTRegion.cpp
@@ -354,7 +354,7 @@
if (m_cueContainer->contains(displayBox.get()))
return;
- m_cueContainer->appendChild(displayBox, ASSERT_NO_EXCEPTION);
+ m_cueContainer->appendChild(*displayBox, ASSERT_NO_EXCEPTION);
displayLastTextTrackCueBox();
}
@@ -404,14 +404,14 @@
m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSSPrimitiveValue::CSS_PX);
}
-PassRefPtr<HTMLDivElement> VTTRegion::getDisplayTree()
+HTMLDivElement& VTTRegion::getDisplayTree()
{
if (!m_regionDisplayTree) {
m_regionDisplayTree = HTMLDivElement::create(*ownerDocument());
prepareRegionDisplayTree();
}
- return m_regionDisplayTree;
+ return *m_regionDisplayTree;
}
void VTTRegion::prepareRegionDisplayTree()
@@ -453,7 +453,7 @@
m_cueContainer->setInlineStyleProperty(CSSPropertyTop, 0.0f, CSSPrimitiveValue::CSS_PX);
m_cueContainer->setPseudo(textTrackCueContainerShadowPseudoId());
- m_regionDisplayTree->appendChild(m_cueContainer);
+ m_regionDisplayTree->appendChild(*m_cueContainer);
// 7.5 Every WebVTT region object is initialised with the following CSS
m_regionDisplayTree->setPseudo(textTrackRegionShadowPseudoId());
diff --git a/Source/WebCore/html/track/VTTRegion.h b/Source/WebCore/html/track/VTTRegion.h
index 7771e8e..8925af1 100644
--- a/Source/WebCore/html/track/VTTRegion.h
+++ b/Source/WebCore/html/track/VTTRegion.h
@@ -89,7 +89,7 @@
bool isScrollingRegion() { return m_scroll; }
- PassRefPtr<HTMLDivElement> getDisplayTree();
+ HTMLDivElement& getDisplayTree();
void appendTextTrackCueBox(PassRefPtr<VTTCueBox>);
void displayLastTextTrackCueBox();
diff --git a/Source/WebCore/html/track/WebVTTElement.cpp b/Source/WebCore/html/track/WebVTTElement.cpp
index 4a2f31b..1496bb0 100644
--- a/Source/WebCore/html/track/WebVTTElement.cpp
+++ b/Source/WebCore/html/track/WebVTTElement.cpp
@@ -80,11 +80,11 @@
return adoptRef(*new WebVTTElement(nodeType, document));
}
-RefPtr<Element> WebVTTElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
+Ref<Element> WebVTTElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
{
- RefPtr<WebVTTElement> clone = create(static_cast<WebVTTNodeType>(m_webVTTNodeType), targetDocument);
+ Ref<WebVTTElement> clone = create(static_cast<WebVTTNodeType>(m_webVTTNodeType), targetDocument);
clone->setLanguage(m_language);
- return clone;
+ return WTF::move(clone);
}
PassRefPtr<HTMLElement> WebVTTElement::createEquivalentHTMLElement(Document& document)
diff --git a/Source/WebCore/html/track/WebVTTElement.h b/Source/WebCore/html/track/WebVTTElement.h
index 1be7636..89d3d2c 100644
--- a/Source/WebCore/html/track/WebVTTElement.h
+++ b/Source/WebCore/html/track/WebVTTElement.h
@@ -49,7 +49,7 @@
static Ref<WebVTTElement> create(const WebVTTNodeType, Document&);
PassRefPtr<HTMLElement> createEquivalentHTMLElement(Document&);
- virtual RefPtr<Element> cloneElementWithoutAttributesAndChildren(Document&) override;
+ virtual Ref<Element> cloneElementWithoutAttributesAndChildren(Document&) override;
void setWebVTTNodeType(WebVTTNodeType type) { m_webVTTNodeType = static_cast<unsigned>(type); }
WebVTTNodeType webVTTNodeType() const { return static_cast<WebVTTNodeType>(m_webVTTNodeType); }
diff --git a/Source/WebCore/inspector/InspectorCSSAgent.cpp b/Source/WebCore/inspector/InspectorCSSAgent.cpp
index b6a3113..857ad19 100644
--- a/Source/WebCore/inspector/InspectorCSSAgent.cpp
+++ b/Source/WebCore/inspector/InspectorCSSAgent.cpp
@@ -796,7 +796,7 @@
// Set this flag, so when we create it, we put it into the via inspector map.
m_creatingViaInspectorStyleSheet = true;
InlineStyleOverrideScope overrideScope(document);
- targetNode->appendChild(styleElement, ec);
+ targetNode->appendChild(styleElement.releaseNonNull(), ec);
m_creatingViaInspectorStyleSheet = false;
if (ec)
return nullptr;
diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp
index ceb4aa1..c4d963e 100644
--- a/Source/WebCore/page/DragController.cpp
+++ b/Source/WebCore/page/DragController.cpp
@@ -138,7 +138,7 @@
String title;
String url = dragData.asURL(DragData::DoNotConvertFilenames, &title);
if (!url.isEmpty()) {
- RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(document);
+ Ref<HTMLAnchorElement> anchor = HTMLAnchorElement::create(document);
anchor->setHref(url);
if (title.isEmpty()) {
// Try the plain text first because the url might be normalized or escaped.
@@ -147,20 +147,19 @@
if (title.isEmpty())
title = url;
}
- RefPtr<Node> anchorText = document.createTextNode(title);
- anchor->appendChild(anchorText, IGNORE_EXCEPTION);
- RefPtr<DocumentFragment> fragment = document.createDocumentFragment();
- fragment->appendChild(anchor, IGNORE_EXCEPTION);
- return fragment.get();
+ anchor->appendChild(document.createTextNode(title), IGNORE_EXCEPTION);
+ Ref<DocumentFragment> fragment = document.createDocumentFragment();
+ fragment->appendChild(WTF::move(anchor), IGNORE_EXCEPTION);
+ return fragment.ptr();
}
}
}
if (allowPlainText && dragData.containsPlainText()) {
chosePlainText = true;
- return createFragmentFromText(context, dragData.asPlainText()).get();
+ return createFragmentFromText(context, dragData.asPlainText()).ptr();
}
- return 0;
+ return nullptr;
}
bool DragController::dragIsMove(FrameSelection& selection, DragData& dragData)
diff --git a/Source/WebCore/page/ios/FrameIOS.mm b/Source/WebCore/page/ios/FrameIOS.mm
index 46674fc..a3e7e8d 100644
--- a/Source/WebCore/page/ios/FrameIOS.mm
+++ b/Source/WebCore/page/ios/FrameIOS.mm
@@ -95,8 +95,8 @@
if (!style.isEmpty())
body->setAttribute(HTMLNames::styleAttr, style);
- rootElement->appendChild(body, ec);
- document->appendChild(rootElement, ec);
+ rootElement->appendChild(body.releaseNonNull(), ec);
+ document->appendChild(rootElement.releaseNonNull(), ec);
}
const ViewportArguments& Frame::viewportArguments() const
diff --git a/Source/WebCore/svg/SVGScriptElement.cpp b/Source/WebCore/svg/SVGScriptElement.cpp
index 6f3ca83..8adfcfa 100644
--- a/Source/WebCore/svg/SVGScriptElement.cpp
+++ b/Source/WebCore/svg/SVGScriptElement.cpp
@@ -156,9 +156,9 @@
return hasAttribute(XLinkNames::hrefAttr);
}
-RefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
+Ref<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren(Document& targetDocument)
{
- return adoptRef(new SVGScriptElement(tagQName(), targetDocument, false, alreadyStarted()));
+ return adoptRef(*new SVGScriptElement(tagQName(), targetDocument, false, alreadyStarted()));
}
#ifndef NDEBUG
diff --git a/Source/WebCore/svg/SVGScriptElement.h b/Source/WebCore/svg/SVGScriptElement.h
index 4c1aa08..535e42e 100644
--- a/Source/WebCore/svg/SVGScriptElement.h
+++ b/Source/WebCore/svg/SVGScriptElement.h
@@ -65,7 +65,7 @@
virtual void dispatchLoadEvent() override { SVGExternalResourcesRequired::dispatchLoadEvent(this); }
- virtual RefPtr<Element> cloneElementWithoutAttributesAndChildren(Document&) override;
+ virtual Ref<Element> cloneElementWithoutAttributesAndChildren(Document&) override;
virtual bool rendererIsNeeded(const RenderStyle&) override { return false; }
// SVGExternalResourcesRequired
diff --git a/Source/WebCore/svg/SVGUseElement.cpp b/Source/WebCore/svg/SVGUseElement.cpp
index 704fe4a..64e10aa 100644
--- a/Source/WebCore/svg/SVGUseElement.cpp
+++ b/Source/WebCore/svg/SVGUseElement.cpp
@@ -332,7 +332,7 @@
for (auto* element : disallowedElements) {
for (auto& descendant : descendantsOfType<SVGElement>(*element))
descendant.setCorrespondingElement(nullptr);
- element->parentNode()->removeChild(element);
+ element->parentNode()->removeChild(*element);
}
}
@@ -405,7 +405,7 @@
void SVGUseElement::cloneTarget(ContainerNode& container, SVGElement& target) const
{
- Ref<SVGElement> targetClone = static_pointer_cast<SVGElement>(target.cloneElementWithChildren(document())).releaseNonNull();
+ Ref<SVGElement> targetClone = static_cast<SVGElement&>(target.cloneElementWithChildren(document()).get());
associateClonesWithOriginals(targetClone.get(), target);
removeDisallowedElementsFromSubtree(targetClone.get());
transferSizeAttributesToTargetClone(targetClone.get());
@@ -419,7 +419,7 @@
ASSERT(!replacementClone.parentNode());
replacementClone.cloneDataFromElement(originalClone);
- originalClone.cloneChildNodes(&replacementClone);
+ originalClone.cloneChildNodes(replacementClone);
associateReplacementClonesWithOriginals(replacementClone, originalClone);
removeDisallowedElementsFromSubtree(replacementClone);
}
@@ -448,7 +448,7 @@
if (target)
originalClone.cloneTarget(replacementClone.get(), *target);
- originalClone.parentNode()->replaceChild(replacementClone.ptr(), &originalClone);
+ originalClone.parentNode()->replaceChild(replacementClone.copyRef(), originalClone);
// Resume iterating, starting just inside the replacement clone.
it = descendants.from(replacementClone.get());
@@ -472,7 +472,7 @@
auto replacementClone = SVGSVGElement::create(document());
cloneDataAndChildren(replacementClone.get(), originalClone);
- originalClone.parentNode()->replaceChild(replacementClone.ptr(), &originalClone);
+ originalClone.parentNode()->replaceChild(replacementClone.copyRef(), originalClone);
// Resume iterating, starting just inside the replacement clone.
it = descendants.from(replacementClone.get());
diff --git a/Source/WebCore/xml/XMLTreeViewer.cpp b/Source/WebCore/xml/XMLTreeViewer.cpp
index 4096e43..a9f77ea 100644
--- a/Source/WebCore/xml/XMLTreeViewer.cpp
+++ b/Source/WebCore/xml/XMLTreeViewer.cpp
@@ -61,8 +61,8 @@
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));
- RefPtr<Text> text = m_document.createTextNode(cssString);
- m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(text, IGNORE_EXCEPTION);
+ Ref<Text> text = m_document.createTextNode(cssString);
+ m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(WTF::move(text), IGNORE_EXCEPTION);
m_document.styleResolverChanged(RecalcStyleImmediately);
}