Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Unified Diff: Source/core/dom/Document.h

Issue 14839007: Devirtualize Document class type checking (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Try again Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/dom/Document.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.h
diff --git a/Source/core/dom/Document.h b/Source/core/dom/Document.h
index b5949b1c80a940236046f9a717fc6e7536654823..ec25a1190347b3bcb26d1abd29a879480cd84eeb 100644
--- a/Source/core/dom/Document.h
+++ b/Source/core/dom/Document.h
@@ -191,15 +191,25 @@ const int numNodeListInvalidationTypes = InvalidateOnAnyAttrChange + 1;
typedef HashCountedSet<Node*> TouchEventTargetSet;
+enum DocumentClass {
+ DefaultDocumentClass = 0,
+ HTMLDocumentClass = 1,
+ XHTMLDocumentClass = 1 << 1,
+ ImageDocumentClass = 1 << 2,
+ PluginDocumentClass = 1 << 3,
+ MediaDocumentClass = 1 << 4,
+ SVGDocumentClass = 1 << 5,
+};
+
class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext {
public:
static PassRefPtr<Document> create(Frame* frame, const KURL& url)
{
- return adoptRef(new Document(frame, url, false, false));
+ return adoptRef(new Document(frame, url));
}
static PassRefPtr<Document> createXHTML(Frame* frame, const KURL& url)
{
- return adoptRef(new Document(frame, url, true, false));
+ return adoptRef(new Document(frame, url, XHTMLDocumentClass));
}
virtual ~Document();
@@ -391,19 +401,19 @@ public:
PassRefPtr<HTMLCollection> windowNamedItems(const AtomicString& name);
PassRefPtr<HTMLCollection> documentNamedItems(const AtomicString& name);
- // Other methods (not part of DOM)
- bool isHTMLDocument() const { return m_isHTML; }
- bool isXHTMLDocument() const { return m_isXHTML; }
- virtual bool isImageDocument() const { return false; }
+ bool isHTMLDocument() const { return m_documentClass & HTMLDocumentClass; }
+ bool isXHTMLDocument() const { return m_documentClass & XHTMLDocumentClass; }
+ bool isImageDocument() const { return m_documentClass & ImageDocumentClass; }
+ bool isSVGDocument() const { return m_documentClass & SVGDocumentClass; }
+ bool isPluginDocument() const { return m_documentClass & PluginDocumentClass; }
+ bool isMediaDocument() const { return m_documentClass & MediaDocumentClass; }
+
#if ENABLE(SVG)
- virtual bool isSVGDocument() const { return false; }
bool hasSVGRootNode() const;
#else
- static bool isSVGDocument() { return false; }
static bool hasSVGRootNode() { return false; }
#endif
- virtual bool isPluginDocument() const { return false; }
- virtual bool isMediaDocument() const { return false; }
+
virtual bool isFrameSet() const { return false; }
bool isSrcdocDocument() const { return m_isSrcdocDocument; }
@@ -1108,7 +1118,7 @@ public:
PassRefPtr<FontLoader> fontloader();
protected:
- Document(Frame*, const KURL&, bool isXHTML, bool isHTML);
+ Document(Frame*, const KURL&, unsigned documentClass = DefaultDocumentClass);
virtual void didUpdateSecurityOrigin() OVERRIDE;
@@ -1355,8 +1365,7 @@ private:
bool m_useSecureKeyboardEntryWhenActive;
- bool m_isXHTML;
- bool m_isHTML;
+ unsigned m_documentClass;
bool m_isViewSource;
bool m_sawElementsInKnownNamespaces;
« no previous file with comments | « no previous file | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698