Commit 65ea5f3f authored by weinig@apple.com's avatar weinig@apple.com

CTTE: Thread references through markup.h

https://bugs.webkit.org/show_bug.cgi?id=122403

Reviewed by Darin Adler and Andreas Kling.

Source/WebCore: 

Highlights:
- Removed createFragmentFromMarkupWithContext(), it was unused.
- Moved createFragmentFromNodes() into its one caller (in WebKit/mac)
- Add a bunch more toFoo() overloads.

Source/WebKit/mac: 

* DOM/WebDOMOperations.mm:
(-[DOMNode markupString]):
(-[DOMRange markupString]):
* WebView/WebFrame.mm:
(-[WebFrame _documentFragmentWithMarkupString:baseURLString:]):
(-[WebFrame _documentFragmentWithNodesAsParagraphs:]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157002 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c974991d
2013-10-05 Sam Weinig <sam@webkit.org>
CTTE: Thread references through markup.h
https://bugs.webkit.org/show_bug.cgi?id=122403
Reviewed by Darin Adler and Andreas Kling.
Highlights:
- Removed createFragmentFromMarkupWithContext(), it was unused.
- Moved createFragmentFromNodes() into its one caller (in WebKit/mac)
- Add a bunch more toFoo() overloads.
2013-10-06 Zan Dobersek <zdobersek@igalia.com>
[WebIDL] Annotate IDL interfaces under Source/WebCore/Modules/ with the OperationsNotDeletable attribute
......@@ -232,7 +232,6 @@ __ZN7WebCore12TextIteratorC1EPKNS_5RangeENS_20TextIteratorBehaviorE
__ZN7WebCore12TextIteratorD1Ev
__ZN7WebCore12UTF8EncodingEv
__ZN7WebCore12cacheStorageEv
__ZN7WebCore12createMarkupEPKNS_5RangeEPN3WTF6VectorIPNS_4NodeELm0ENS3_15CrashOnOverflowEEENS_23EAnnotateForInterchangeEbNS_13EAbsoluteURLsE
__ZN7WebCore12deleteCookieERKNS_21NetworkStorageSessionERKNS_3URLERKN3WTF6StringE
__ZN7WebCore12gcControllerEv
__ZN7WebCore12iconDatabaseEv
......@@ -580,8 +579,8 @@ __ZN7WebCore16VisibleSelection22expandUsingGranularityENS_15TextGranularityE
__ZN7WebCore16VisibleSelectionC1EPKNS_5RangeENS_9EAffinityEb
__ZN7WebCore16VisibleSelectionC1ERKNS_15VisiblePositionES3_b
__ZN7WebCore16VisibleSelectionC1ERKNS_15VisiblePositionEb
__ZN7WebCore16createFullMarkupEPKNS_4NodeE
__ZN7WebCore16createFullMarkupEPKNS_5RangeE
__ZN7WebCore16createFullMarkupERKNS_4NodeE
__ZN7WebCore16createFullMarkupERKNS_5RangeE
__ZN7WebCore16deleteAllCookiesERKNS_21NetworkStorageSessionE
__ZN7WebCore16enclosingIntRectERK6CGRect
__ZN7WebCore16enclosingIntRectERKNS_9FloatRectE
......@@ -764,7 +763,6 @@ __ZN7WebCore23AuthenticationChallengeC1ERKNS_15ProtectionSpaceERKNS_10Credential
__ZN7WebCore23MutableStylePropertySet25ensureCSSStyleDeclarationEv
__ZN7WebCore23MutableStylePropertySetD1Ev
__ZN7WebCore23SynchronousLoaderClient24platformBadResponseErrorEv
__ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0ENS2_15CrashOnOverflowEEE
__ZN7WebCore23dataForURLComponentTypeEP5NSURLl
__ZN7WebCore23decodeHostNameWithRangeEP8NSString8_NSRange
__ZN7WebCore23encodeHostNameWithRangeEP8NSString8_NSRange
......@@ -780,7 +778,7 @@ __ZN7WebCore24FrameDestructionObserver14frameDestroyedEv
__ZN7WebCore24FrameDestructionObserver14willDetachPageEv
__ZN7WebCore24FrameDestructionObserverC2EPNS_5FrameE
__ZN7WebCore24FrameDestructionObserverD2Ev
__ZN7WebCore24createFragmentFromMarkupEPNS_8DocumentERKN3WTF6StringES5_NS_19ParserContentPolicyE
__ZN7WebCore24createFragmentFromMarkupERNS_8DocumentERKN3WTF6StringES5_NS_19ParserContentPolicyE
__ZN7WebCore24decodeURLEscapeSequencesERKN3WTF6StringE
__ZN7WebCore24deleteCookiesForHostnameERKNS_21NetworkStorageSessionERKN3WTF6StringE
__ZN7WebCore24fileSystemRepresentationERKN3WTF6StringE
......@@ -810,6 +808,7 @@ __ZN7WebCore28DocumentStyleSheetCollection14addAuthorSheetEN3WTF10PassRefPtrINS_
__ZN7WebCore28encodeWithURLEscapeSequencesERKN3WTF6StringE
__ZN7WebCore28removeLanguageChangeObserverEPv
__ZN7WebCore29cookieRequestHeaderFieldValueERKNS_21NetworkStorageSessionERKNS_3URLES5_
__ZN7WebCore29createDefaultParagraphElementERNS_8DocumentE
__ZN7WebCore29isCharacterSmartReplaceExemptEib
__ZN7WebCore30hostNameNeedsDecodingWithRangeEP8NSString8_NSRange
__ZN7WebCore30hostNameNeedsEncodingWithRangeEP8NSString8_NSRange
......
......@@ -796,7 +796,7 @@
1C11CCC80AA6093700DADB20 /* DOMHTMLElement.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 85DF2EEB0AA387CB00AD64C5 /* DOMHTMLElement.h */; };
1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */; };
1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */; };
1C4C8F020AD85D87009475CE /* DeleteButtonController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4C8F000AD85D87009475CE /* DeleteButtonController.h */; };
1C4C8F020AD85D87009475CE /* DeleteButtonController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4C8F000AD85D87009475CE /* DeleteButtonController.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C4C8F660AD8655D009475CE /* DeleteButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C4C8F640AD8655D009475CE /* DeleteButton.h */; };
1C5FAED10DCFD90100D58F78 /* JSJavaScriptCallFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C5FAECF0DCFD90100D58F78 /* JSJavaScriptCallFrame.cpp */; };
1C5FAED20DCFD90100D58F78 /* JSJavaScriptCallFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5FAED00DCFD90100D58F78 /* JSJavaScriptCallFrame.h */; };
......@@ -56,7 +56,7 @@
- (DOMDocumentFragment *)createDocumentFragmentWithMarkupString:(NSString *)markupString baseURL:(NSURL *)baseURL
{
return kit(createFragmentFromMarkup(core(self), markupString, [baseURL absoluteString]).get());
return kit(createFragmentFromMarkup(*core(self), markupString, [baseURL absoluteString]).get());
}
- (DOMDocumentFragment *)createDocumentFragmentWithText:(NSString *)text
......
......@@ -41,6 +41,13 @@ private:
virtual PassRefPtr<Text> virtualCreate(const String&);
};
inline bool isCDATASection(const Node& node)
{
return node.nodeType() == Node::CDATA_SECTION_NODE;
}
NODE_TYPE_CASTS(CDATASection)
} // namespace WebCore
#endif // CDATASection_h
......@@ -27,7 +27,7 @@
namespace WebCore {
class Comment FINAL : public CharacterData {
class Comment final : public CharacterData {
public:
static PassRefPtr<Comment> create(Document&, const String&);
......@@ -40,6 +40,13 @@ private:
virtual bool childTypeAllowed(NodeType) const;
};
inline bool isComment(const Node& node)
{
return node.nodeType() == Node::COMMENT_NODE;
}
NODE_TYPE_CASTS(Comment)
} // namespace WebCore
#endif // Comment_h
......@@ -4267,7 +4267,7 @@ void Document::applyXSLTransform(ProcessingInstruction* pi)
String resultMIMEType;
String newSource;
String resultEncoding;
if (!processor->transformToString(this, resultMIMEType, newSource, resultEncoding))
if (!processor->transformToString(*this, resultMIMEType, newSource, resultEncoding))
return;
// FIXME: If the transform failed we should probably report an error (like Mozilla does).
Frame* ownerFrame = frame();
......
......@@ -1595,33 +1595,6 @@ inline const Document* Document::templateDocument() const
}
#endif
inline Document* toDocument(ScriptExecutionContext* scriptExecutionContext)
{
ASSERT_WITH_SECURITY_IMPLICATION(!scriptExecutionContext || scriptExecutionContext->isDocument());
return static_cast<Document*>(scriptExecutionContext);
}
inline const Document* toDocument(const ScriptExecutionContext* scriptExecutionContext)
{
ASSERT_WITH_SECURITY_IMPLICATION(!scriptExecutionContext || scriptExecutionContext->isDocument());
return static_cast<const Document*>(scriptExecutionContext);
}
inline Document* toDocument(Node* node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isDocumentNode());
return static_cast<Document*>(node);
}
inline const Document* toDocument(const Node* node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isDocumentNode());
return static_cast<const Document*>(node);
}
// This will catch anyone doing an unnecessary cast.
void toDocument(const Document*);
// Put these methods here, because they require the Document definition, but we really want to inline them.
inline bool Node::isDocumentNode() const
......@@ -1652,6 +1625,25 @@ inline ScriptExecutionContext* Node::scriptExecutionContext() const
Element* eventTargetElementForDocument(Document*);
inline Document* toDocument(ScriptExecutionContext* scriptExecutionContext)
{
ASSERT_WITH_SECURITY_IMPLICATION(!scriptExecutionContext || scriptExecutionContext->isDocument());
return static_cast<Document*>(scriptExecutionContext);
}
inline const Document* toDocument(const ScriptExecutionContext* scriptExecutionContext)
{
ASSERT_WITH_SECURITY_IMPLICATION(!scriptExecutionContext || scriptExecutionContext->isDocument());
return static_cast<const Document*>(scriptExecutionContext);
}
inline bool isDocument(const Node& node)
{
return node.isDocumentNode();
}
NODE_TYPE_CASTS(Document)
} // namespace WebCore
namespace WTF {
......
......@@ -63,6 +63,13 @@ private:
String m_subset;
};
inline bool isDocumentType(const Node& node)
{
return node.nodeType() == Node::DOCUMENT_TYPE_NODE;
}
NODE_TYPE_CASTS(DocumentType)
} // namespace WebCore
#endif
......@@ -731,7 +731,31 @@ inline ContainerNode* Node::parentNodeGuaranteedHostFree() const
return parentNode();
}
} //namespace
#define NODE_TYPE_CASTS(NodeClassName) \
inline const NodeClassName* to##NodeClassName(const Node* node) \
{ \
ASSERT_WITH_SECURITY_IMPLICATION(!node || is##NodeClassName(*node)); \
return static_cast<const NodeClassName*>(node); \
} \
inline NodeClassName* to##NodeClassName(Node* node) \
{ \
ASSERT_WITH_SECURITY_IMPLICATION(!node || is##NodeClassName(*node)); \
return static_cast<NodeClassName*>(node); \
} \
inline const NodeClassName& to##NodeClassName(const Node& node) \
{ \
ASSERT_WITH_SECURITY_IMPLICATION(is##NodeClassName(node)); \
return static_cast<const NodeClassName&>(node); \
} \
inline NodeClassName& to##NodeClassName(Node& node) \
{ \
ASSERT_WITH_SECURITY_IMPLICATION(is##NodeClassName(node)); \
return static_cast<NodeClassName&>(node); \
} \
void to##NodeClassName(const NodeClassName*); \
void to##NodeClassName(const NodeClassName&);
} // namespace WebCore
#ifndef NDEBUG
// Outside the WebCore namespace for ease of invocation from gdb.
......
......@@ -32,7 +32,7 @@ namespace WebCore {
class StyleSheet;
class CSSStyleSheet;
class ProcessingInstruction FINAL : public CharacterData, private CachedStyleSheetClient {
class ProcessingInstruction final : public CharacterData, private CachedStyleSheetClient {
public:
static PassRefPtr<ProcessingInstruction> create(Document&, const String& target, const String& data);
virtual ~ProcessingInstruction();
......@@ -91,12 +91,13 @@ private:
#endif
};
inline ProcessingInstruction* toProcessingInstruction(Node* node)
inline bool isProcessingInstruction(const Node& node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE);
return static_cast<ProcessingInstruction*>(node);
return node.nodeType() == Node::PROCESSING_INSTRUCTION_NODE;
}
NODE_TYPE_CASTS(ProcessingInstruction)
} //namespace
#endif
......@@ -1083,7 +1083,7 @@ String Range::toString(ExceptionCode& ec) const
String Range::toHTML() const
{
return createMarkup(this);
return createMarkup(*this);
}
String Range::text() const
......
......@@ -94,7 +94,7 @@ PassRefPtr<Node> ShadowRoot::cloneNode(bool, ExceptionCode& ec)
String ShadowRoot::innerHTML() const
{
return createMarkup(this, ChildrenOnly);
return createMarkup(*this, ChildrenOnly);
}
void ShadowRoot::setInnerHTML(const String& markup, ExceptionCode& ec)
......
......@@ -105,6 +105,10 @@ inline const StylePropertySet* StyledElement::presentationAttributeStyle()
return elementData()->presentationAttributeStyle();
}
inline bool isStyledElement(const Node& node) { return node.isStyledElement(); }
ELEMENT_TYPE_CASTS(StyledElement)
} //namespace
#endif
......@@ -70,26 +70,12 @@ private:
#endif
};
inline Text& toText(Node& node)
inline bool isText(const Node& node)
{
ASSERT_WITH_SECURITY_IMPLICATION(node.isTextNode());
return static_cast<Text&>(node);
return node.isTextNode();
}
inline Text* toText(Node* node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isTextNode());
return static_cast<Text*>(node);
}
inline const Text* toText(const Node* node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isTextNode());
return static_cast<const Text*>(node);
}
void toText(const Text&);
void toText(const Text*);
NODE_TYPE_CASTS(Text)
} // namespace WebCore
......
......@@ -1195,7 +1195,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
RefPtr<DocumentFragment> fragment;
// This used to use a ternary for initialization, but that confused some versions of GCC, see bug 37912
if (startOfParagraphToMove != endOfParagraphToMove)
fragment = createFragmentFromMarkup(&document(), createMarkup(range.get(), 0, DoNotAnnotateForInterchange, true), "");
fragment = createFragmentFromMarkup(document(), createMarkup(*range, 0, DoNotAnnotateForInterchange, true), "");
// A non-empty paragraph's style is moved when we copy and move it. We don't move
// anything if we're given an empty paragraph, but an empty paragraph can have style
......
......@@ -501,7 +501,7 @@ static bool executeInsertHorizontalRule(Frame& frame, Event*, EditorCommandSourc
static bool executeInsertHTML(Frame& frame, Event*, EditorCommandSource, const String& value)
{
return executeInsertFragment(frame, createFragmentFromMarkup(frame.document(), value, ""));
return executeInsertFragment(frame, createFragmentFromMarkup(*frame.document(), value, ""));
}
static bool executeInsertImage(Frame& frame, Event*, EditorCommandSource, const String& value)
......
......@@ -69,48 +69,52 @@ public:
MarkupAccumulator(Vector<Node*>*, EAbsoluteURLs, const Range* = 0, EFragmentSerialization = HTMLFragmentSerialization);
virtual ~MarkupAccumulator();
String serializeNodes(Node* targetNode, Node* nodeToSkip, EChildrenOnly);
String serializeNodes(Node* targetNode, Node* nodeToSkip, EChildrenOnly, Vector<QualifiedName>* tagNamesToSkip);
static void appendComment(StringBuilder&, const String&);
String serializeNodes(Node& targetNode, Node* nodeToSkip, EChildrenOnly, Vector<QualifiedName>* tagNamesToSkip = nullptr);
static void appendCharactersReplacingEntities(StringBuilder&, const String&, unsigned, unsigned, EntityMask);
protected:
virtual void appendString(const String&);
void appendStartTag(Node*, Namespaces* = 0);
virtual void appendEndTag(Node*);
static size_t totalLength(const Vector<String>&);
size_t length() const { return m_markup.length(); }
void concatenateMarkup(StringBuilder&);
virtual void appendString(const String&);
virtual void appendEndTag(const Node&);
virtual void appendCustomAttributes(StringBuilder&, const Element&, Namespaces*);
virtual void appendText(StringBuilder&, const Text&);
virtual void appendElement(StringBuilder&, const Element&, Namespaces*);
void appendStartTag(const Node&, Namespaces* = 0);
void appendOpenTag(StringBuilder&, const Element&, Namespaces*);
void appendCloseTag(StringBuilder&, const Element&);
void appendStartMarkup(StringBuilder&, const Node&, Namespaces*);
void appendEndMarkup(StringBuilder&, const Node&);
void appendAttributeValue(StringBuilder&, const String&, bool);
virtual void appendCustomAttributes(StringBuilder&, Element*, Namespaces*);
void appendNodeValue(StringBuilder&, const Node*, const Range*, EntityMask);
bool shouldAddNamespaceElement(const Element*);
bool shouldAddNamespaceAttribute(const Attribute&, Namespaces&);
void appendNodeValue(StringBuilder&, const Node&, const Range*, EntityMask);
void appendNamespace(StringBuilder&, const AtomicString& prefix, const AtomicString& namespaceURI, Namespaces&, bool allowEmptyDefaultNS = false);
EntityMask entityMaskForText(Text*) const;
virtual void appendText(StringBuilder&, Text*);
void appendXMLDeclaration(StringBuilder&, const Document*);
void appendDocumentType(StringBuilder&, const DocumentType*);
void appendXMLDeclaration(StringBuilder&, const Document&);
void appendDocumentType(StringBuilder&, const DocumentType&);
void appendProcessingInstruction(StringBuilder&, const String& target, const String& data);
virtual void appendElement(StringBuilder&, Element*, Namespaces*);
void appendOpenTag(StringBuilder&, Element*, Namespaces*);
void appendCloseTag(StringBuilder&, Element*);
void appendAttribute(StringBuilder&, Element*, const Attribute&, Namespaces*);
void appendAttribute(StringBuilder&, const Element&, const Attribute&, Namespaces*);
void appendCDATASection(StringBuilder&, const String&);
void appendStartMarkup(StringBuilder&, const Node*, Namespaces*);
bool shouldSelfClose(const Node*);
bool elementCannotHaveEndTag(const Node*);
void appendEndMarkup(StringBuilder&, const Node*);
bool shouldAddNamespaceElement(const Element&);
bool shouldAddNamespaceAttribute(const Attribute&, Namespaces&);
bool shouldSelfClose(const Node&);
bool elementCannotHaveEndTag(const Node&);
EntityMask entityMaskForText(const Text&) const;
Vector<Node*>* const m_nodes;
const Range* const m_range;
private:
String resolveURLIfNeeded(const Element*, const String&) const;
void appendQuotedURLAttributeValue(StringBuilder&, const Element*, const Attribute&);
void serializeNodesWithNamespaces(Node* targetNode, Node* nodeToSkip, EChildrenOnly, const Namespaces*, Vector<QualifiedName>* tagNamesToSkip);
String resolveURLIfNeeded(const Element&, const String&) const;
void appendQuotedURLAttributeValue(StringBuilder&, const Element&, const Attribute&);
void serializeNodesWithNamespaces(Node& targetNode, Node* nodeToSkip, EChildrenOnly, const Namespaces*, Vector<QualifiedName>* tagNamesToSkip);
bool inXMLFragmentSerialization() const { return m_fragmentSerialization == XMLFragmentSerialization; }
void generateUniquePrefix(QualifiedName&, const Namespaces&);
......
......@@ -439,7 +439,7 @@ bool Editor::WebContentReader::readWebArchive(PassRefPtr<SharedBuffer> buffer)
loader->addAllArchiveResources(archive.get());
String markupString = String::fromUTF8(mainResource->data()->data(), mainResource->data()->size());
addFragment(createFragmentFromMarkup(frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent));
addFragment(createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent));
return true;
}
......
......@@ -462,7 +462,7 @@ bool Editor::WebContentReader::readWebArchive(PassRefPtr<SharedBuffer> buffer)
loader->addAllArchiveResources(archive.get());
String markupString = String::fromUTF8(mainResource->data()->data(), mainResource->data()->size());
fragment = createFragmentFromMarkup(frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent);
fragment = createFragmentFromMarkup(*frame.document(), markupString, mainResource->url(), DisallowScriptingAndPluginContent);
return true;
}
......@@ -514,7 +514,11 @@ bool Editor::WebContentReader::readHTML(const String& string)
if (stringOmittingMicrosoftPrefix.isEmpty())
return false;
fragment = createFragmentFromMarkup(frame.document(), stringOmittingMicrosoftPrefix, emptyString(), DisallowScriptingAndPluginContent);
if (!frame.document())
return false;
Document& document = *frame.document();
fragment = createFragmentFromMarkup(document, stringOmittingMicrosoftPrefix, emptyString(), DisallowScriptingAndPluginContent);
return fragment;
}
......
This diff is collapsed.
......@@ -50,9 +50,7 @@ enum EAbsoluteURLs { DoNotResolveURLs, ResolveAllURLs, ResolveNonLocalURLs };
enum EFragmentSerialization { HTMLFragmentSerialization, XMLFragmentSerialization };
PassRefPtr<DocumentFragment> createFragmentFromText(Range* context, const String& text);
PassRefPtr<DocumentFragment> createFragmentFromMarkup(Document*, const String& markup, const String& baseURL, ParserContentPolicy = AllowScriptingContent);
PassRefPtr<DocumentFragment> createFragmentFromMarkupWithContext(Document*, const String& markup, unsigned fragmentStart, unsigned fragmentEnd, const String& baseURL, ParserContentPolicy);
PassRefPtr<DocumentFragment> createFragmentFromNodes(Document*, const Vector<Node*>&);
PassRefPtr<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);
PassRefPtr<DocumentFragment> createContextualFragment(const String&, HTMLElement*, ParserContentPolicy, ExceptionCode&);
......@@ -64,11 +62,11 @@ bool isPlainTextMarkup(Node*);
void replaceChildrenWithFragment(ContainerNode&, PassRefPtr<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*>* = 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 createFullMarkup(const Node*);
String createFullMarkup(const Range*);
String createFullMarkup(const Node&);
String createFullMarkup(const Range&);
String urlToMarkup(const URL&, const String& title);
......
......@@ -345,12 +345,12 @@ void HTMLElement::parseAttribute(const QualifiedName& name, const AtomicString&
String HTMLElement::innerHTML() const
{
return createMarkup(this, ChildrenOnly);
return createMarkup(*this, ChildrenOnly);
}
String HTMLElement::outerHTML() const
{
return createMarkup(this);
return createMarkup(*this);
}
void HTMLElement::setInnerHTML(const String& html, ExceptionCode& ec)
......
......@@ -77,12 +77,27 @@ inline HTMLFrameOwnerElement& toFrameOwnerElement(Node& node)
return static_cast<HTMLFrameOwnerElement&>(node);
}
inline const HTMLFrameOwnerElement& toFrameOwnerElement(const Node& node)
{
ASSERT_WITH_SECURITY_IMPLICATION(node.isFrameOwnerElement());
return static_cast<const HTMLFrameOwnerElement&>(node);
}
inline HTMLFrameOwnerElement* toFrameOwnerElement(Node* node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isFrameOwnerElement());
return static_cast<HTMLFrameOwnerElement*>(node);
}
inline const HTMLFrameOwnerElement* toFrameOwnerElement(const Node* node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isFrameOwnerElement());
return static_cast<const HTMLFrameOwnerElement*>(node);
}
void toFrameOwnerElement(const HTMLFrameOwnerElement&);
void toFrameOwnerElement(const HTMLFrameOwnerElement*);
class SubframeLoadingDisabler {
public:
explicit SubframeLoadingDisabler(ContainerNode& root)
......
......@@ -85,14 +85,6 @@ void HTMLTemplateElement::didMoveToNewDocument(Document* oldDocument)
document().ensureTemplateDocument()->adoptIfNeeded(m_content.get());
}
#ifndef NDEBUG
const HTMLTemplateElement* toHTMLTemplateElement(const Node* node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || (node->isHTMLElement() && node->hasTagName(templateTag)));
return static_cast<const HTMLTemplateElement*>(node);
}
#endif
} // namespace WebCore
#endif // ENABLE(TEMPLATE_ELEMENT)
......@@ -54,21 +54,7 @@ private:
mutable RefPtr<DocumentFragment> m_content;
};
const HTMLTemplateElement* toHTMLTemplateElement(const Node*);
inline HTMLTemplateElement* toHTMLTemplateElement(Node* node)
{
return const_cast<HTMLTemplateElement*>(toHTMLTemplateElement(static_cast<const Node*>(node)));
}
#ifdef NDEBUG
// The debug version of this, with assertions, is not inlined.
inline const HTMLTemplateElement* toHTMLTemplateElement(const Node* node)
{
return static_cast<const HTMLTemplateElement*>(node);
}
#endif // NDEBUG
ELEMENT_TYPE_CASTS(HTMLTemplateElement)
} // namespace WebCore
......
......@@ -206,10 +206,10 @@ private:
class DOMEditor::SetOuterHTMLAction : public InspectorHistory::Action {
WTF_MAKE_NONCOPYABLE(SetOuterHTMLAction);
public:
SetOuterHTMLAction(Node* node, const String& html)
SetOuterHTMLAction(Node& node, const String& html)
: InspectorHistory::Action("SetOuterHTML")
, m_node(node)
, m_nextSibling(node->nextSibling())
, m_nextSibling(node.nextSibling())
, m_html(html)
, m_newNode(0)
, m_history(adoptPtr(new InspectorHistory()))
......@@ -241,7 +241,7 @@ public:
}
private:
RefPtr<Node> m_node;
Ref<Node> m_node;
RefPtr<Node> m_nextSibling;
String m_html;
String m_oldHTML;
......@@ -374,7 +374,7 @@ bool DOMEditor::removeAttribute(Element* element, const String& name, ExceptionC
return m_history->perform(adoptPtr(new RemoveAttributeAction(element, name)), ec);
}
bool DOMEditor::setOuterHTML(Node* node, const String& html, Node** newNode, ExceptionCode& ec)
bool DOMEditor::setOuterHTML(Node& node, const String& html, Node** newNode, ExceptionCode& ec)
{
OwnPtr<SetOuterHTMLAction> action = adoptPtr(new SetOuterHTMLAction(node, html));
SetOuterHTMLAction* rawAction = action.get();
......@@ -439,7 +439,7 @@ bool DOMEditor::removeAttribute(Element* element, const String& name, ErrorStrin
return result;
}
bool DOMEditor::setOuterHTML(Node* node, const String& html, Node** newNode, ErrorString* errorString)
bool DOMEditor::setOuterHTML(Node& node, const String& html, Node** newNode, ErrorString* errorString)
{
ExceptionCode ec = 0;
bool result = setOuterHTML(node, html, newNode, ec);
......
......@@ -56,7 +56,7 @@ public:
bool removeChild(Node* parentNode, Node*, ExceptionCode&);
bool setAttribute(Element*, const String& name, const String& value, ExceptionCode&);
bool removeAttribute(Element*, const String& name, ExceptionCode&);
bool setOuterHTML(Node*, const String& html, Node** newNode, ExceptionCode&);
bool setOuterHTML(Node&, const String& html, Node** newNode, ExceptionCode&);
bool replaceWholeText(Text*, const String& text, ExceptionCode&);
bool replaceChild(Node* parentNode, PassRefPtr<Node> newNode, Node* oldNode, ExceptionCode&);
bool setNodeValue(Node* parentNode, const String& value, ExceptionCode&);
......@@ -65,7 +65,7 @@ public:
bool removeChild(Node* parentNode, Node*, ErrorString*);
bool setAttribute(Element*, const String& name, const String& value, ErrorString*);
bool removeAttribute(Element*, const String& name, ErrorString*);
bool setOuterHTML(Node*, const String& html, Node** newNode, ErrorString*);
bool setOuterHTML(Node&, const String& html, Node** newNode, ErrorString*);
bool replaceWholeText(Text*, const String& text, ErrorString*);
private:
......
......@@ -119,32 +119,32 @@ void DOMPatchSupport::patchDocument(const String& markup)
}
}
Node* DOMPatchSupport::patchNode(Node* node, const String& markup, ExceptionCode& ec)
Node* DOMPatchSupport::patchNode(Node& node, const String& markup, ExceptionCode& ec)
{
// Don't parse <html> as a fragment.
if (node->isDocumentNode() || (node->parentNode() && node->parentNode()->isDocumentNode())) {
if (node.isDocumentNode() || (node.parentNode() && node.parentNode()->isDocumentNode())) {
patchDocument(markup);
return 0;
}
Node* previousSibling = node->previousSibling();
Node* previousSibling = node.previousSibling();
// FIXME: This code should use one of createFragment* in markup.h
RefPtr<DocumentFragment> fragment = DocumentFragment::create(*m_document);