Diff
Modified: trunk/Source/WebCore/ChangeLog (149704 => 149705)
--- trunk/Source/WebCore/ChangeLog 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/ChangeLog 2013-05-08 01:41:16 UTC (rev 149705)
@@ -1,3 +1,52 @@
+2013-05-07 Ryosuke Niwa <[email protected]>
+
+ Devirtualize Document class type checking
+ https://bugs.webkit.org/show_bug.cgi?id=115755
+
+ Reviewed by Benjamin Poulain.
+
+ Merge https://chromium.googlesource.com/chromium/blink/+/dae5adc768d5ce6bff301df6515745da8ea24950
+
+ Document has a bunch of virtual bool is*Document() methods on it, but it also has
+ two bools for XHTML and HTML documents which is silly. We can merge them all
+ together into an enum of values and devirtualize the type checking methods.
+
+ * dom/Document.cpp:
+ (WebCore::Document::Document):
+ (WebCore::Document::createElement):
+ * dom/Document.h:
+ (WebCore::Document::create):
+ (WebCore::Document::createXHTML):
+ (WebCore::Document::isHTMLDocument):
+ (WebCore::Document::isXHTMLDocument):
+ (WebCore::Document::isImageDocument):
+ (WebCore::Document::isSVGDocument):
+ (WebCore::Document::isPluginDocument):
+ (WebCore::Document::isMediaDocument):
+ (WebCore::Document):
+ * html/HTMLDocument.cpp:
+ (WebCore::HTMLDocument::HTMLDocument):
+ * html/HTMLDocument.h:
+ (WebCore::HTMLDocument):
+ * html/ImageDocument.cpp:
+ (WebCore::ImageDocument::ImageDocument):
+ * html/ImageDocument.h:
+ (WebCore::ImageDocument):
+ * html/MediaDocument.cpp:
+ (WebCore::MediaDocument::MediaDocument):
+ * html/MediaDocument.h:
+ (WebCore::MediaDocument):
+ * html/PluginDocument.cpp:
+ (WebCore::PluginDocument::PluginDocument):
+ * html/PluginDocument.h:
+ (WebCore::PluginDocument):
+ * loader/PlaceholderDocument.h:
+ (WebCore::PlaceholderDocument::PlaceholderDocument):
+ * svg/SVGDocument.cpp:
+ (WebCore::SVGDocument::SVGDocument):
+ * svg/SVGDocument.h:
+ (WebCore::SVGDocument):
+
2013-05-07 Anders Carlsson <[email protected]>
Begin unraveling the mess that is QuotesData
Modified: trunk/Source/WebCore/dom/Document.cpp (149704 => 149705)
--- trunk/Source/WebCore/dom/Document.cpp 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/dom/Document.cpp 2013-05-08 01:41:16 UTC (rev 149705)
@@ -413,7 +413,7 @@
uint64_t Document::s_globalTreeVersion = 0;
-Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
+Document::Document(Frame* frame, const KURL& url, unsigned documentClasses)
: ContainerNode(0, CreateDocument)
, TreeScope(this)
, m_styleResolverThrowawayTimer(this, &Document::styleResolverThrowawayTimerFired)
@@ -451,8 +451,7 @@
, m_createRenderers(true)
, m_inPageCache(false)
, m_accessKeyMapValid(false)
- , m_isXHTML(isXHTML)
- , m_isHTML(isHTML)
+ , m_documentClasses(documentClasses)
, m_isViewSource(false)
, m_sawElementsInKnownNamespaces(false)
, m_isSrcdocDocument(false)
@@ -828,7 +827,7 @@
return 0;
}
- if (m_isXHTML)
+ if (isXHTMLDocument())
return HTMLElementFactory::createHTMLElement(QualifiedName(nullAtom, name, xhtmlNamespaceURI), this, 0, false);
return createElement(QualifiedName(nullAtom, name, nullAtom), false);
Modified: trunk/Source/WebCore/dom/Document.h (149704 => 149705)
--- trunk/Source/WebCore/dom/Document.h 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/dom/Document.h 2013-05-08 01:41:16 UTC (rev 149705)
@@ -220,15 +220,27 @@
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,
+};
+
+typedef unsigned char DocumentClassFlags;
+
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();
@@ -427,18 +439,17 @@
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_documentClasses & HTMLDocumentClass; }
+ bool isXHTMLDocument() const { return m_documentClasses & XHTMLDocumentClass; }
+ bool isImageDocument() const { return m_documentClasses & ImageDocumentClass; }
+ bool isSVGDocument() const { return m_documentClasses & SVGDocumentClass; }
+ bool isPluginDocument() const { return m_documentClasses & PluginDocumentClass; }
+ bool isMediaDocument() const { return m_documentClasses & 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; }
@@ -1207,7 +1218,7 @@
void ensurePlugInsInjectedScript(DOMWrapperWorld*);
protected:
- Document(Frame*, const KURL&, bool isXHTML, bool isHTML);
+ Document(Frame*, const KURL&, unsigned = DefaultDocumentClass);
virtual void didUpdateSecurityOrigin() OVERRIDE;
@@ -1474,8 +1485,7 @@
OwnPtr<SelectorQueryCache> m_selectorQueryCache;
- bool m_isXHTML;
- bool m_isHTML;
+ DocumentClassFlags m_documentClasses;
bool m_isViewSource;
bool m_sawElementsInKnownNamespaces;
Modified: trunk/Source/WebCore/html/HTMLDocument.cpp (149704 => 149705)
--- trunk/Source/WebCore/html/HTMLDocument.cpp 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/html/HTMLDocument.cpp 2013-05-08 01:41:16 UTC (rev 149705)
@@ -81,8 +81,8 @@
using namespace HTMLNames;
-HTMLDocument::HTMLDocument(Frame* frame, const KURL& url)
- : Document(frame, url, false, true)
+HTMLDocument::HTMLDocument(Frame* frame, const KURL& url, DocumentClassFlags documentClasses)
+ : Document(frame, url, documentClasses | HTMLDocumentClass)
{
clearXMLVersion();
}
Modified: trunk/Source/WebCore/html/HTMLDocument.h (149704 => 149705)
--- trunk/Source/WebCore/html/HTMLDocument.h 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/html/HTMLDocument.h 2013-05-08 01:41:16 UTC (rev 149705)
@@ -75,7 +75,7 @@
static bool isCaseSensitiveAttribute(const QualifiedName&);
protected:
- HTMLDocument(Frame*, const KURL&);
+ HTMLDocument(Frame*, const KURL&, DocumentClassFlags = 0);
private:
virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
Modified: trunk/Source/WebCore/html/ImageDocument.cpp (149704 => 149705)
--- trunk/Source/WebCore/html/ImageDocument.cpp 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/html/ImageDocument.cpp 2013-05-08 01:41:16 UTC (rev 149705)
@@ -177,7 +177,7 @@
// --------
ImageDocument::ImageDocument(Frame* frame, const KURL& url)
- : HTMLDocument(frame, url)
+ : HTMLDocument(frame, url, ImageDocumentClass)
, m_imageElement(0)
, m_imageSizeIsKnown(false)
, m_didShrinkImage(false)
Modified: trunk/Source/WebCore/html/ImageDocument.h (149704 => 149705)
--- trunk/Source/WebCore/html/ImageDocument.h 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/html/ImageDocument.h 2013-05-08 01:41:16 UTC (rev 149705)
@@ -51,7 +51,6 @@
ImageDocument(Frame*, const KURL&);
virtual PassRefPtr<DocumentParser> createParser();
- virtual bool isImageDocument() const { return true; }
void createDocumentStructure();
void resizeImageToFit();
Modified: trunk/Source/WebCore/html/MediaDocument.cpp (149704 => 149705)
--- trunk/Source/WebCore/html/MediaDocument.cpp 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/html/MediaDocument.cpp 2013-05-08 01:41:16 UTC (rev 149705)
@@ -118,7 +118,7 @@
}
MediaDocument::MediaDocument(Frame* frame, const KURL& url)
- : HTMLDocument(frame, url)
+ : HTMLDocument(frame, url, MediaDocumentClass)
, m_replaceMediaElementTimer(this, &MediaDocument::replaceMediaElementTimerFired)
{
setCompatibilityMode(QuirksMode);
Modified: trunk/Source/WebCore/html/MediaDocument.h (149704 => 149705)
--- trunk/Source/WebCore/html/MediaDocument.h 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/html/MediaDocument.h 2013-05-08 01:41:16 UTC (rev 149705)
@@ -45,7 +45,6 @@
private:
MediaDocument(Frame*, const KURL&);
- virtual bool isMediaDocument() const { return true; }
virtual PassRefPtr<DocumentParser> createParser();
virtual void defaultEventHandler(Event*);
Modified: trunk/Source/WebCore/html/PluginDocument.cpp (149704 => 149705)
--- trunk/Source/WebCore/html/PluginDocument.cpp 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/html/PluginDocument.cpp 2013-05-08 01:41:16 UTC (rev 149705)
@@ -136,7 +136,7 @@
}
PluginDocument::PluginDocument(Frame* frame, const KURL& url)
- : HTMLDocument(frame, url)
+ : HTMLDocument(frame, url, PluginDocumentClass)
, m_shouldLoadPluginManually(true)
{
setCompatibilityMode(QuirksMode);
Modified: trunk/Source/WebCore/html/PluginDocument.h (149704 => 149705)
--- trunk/Source/WebCore/html/PluginDocument.h 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/html/PluginDocument.h 2013-05-08 01:41:16 UTC (rev 149705)
@@ -54,8 +54,7 @@
PluginDocument(Frame*, const KURL&);
virtual PassRefPtr<DocumentParser> createParser() OVERRIDE;
- virtual bool isPluginDocument() const OVERRIDE { return true; }
-
+
void setShouldLoadPluginManually(bool loadManually) { m_shouldLoadPluginManually = loadManually; }
bool m_shouldLoadPluginManually;
Modified: trunk/Source/WebCore/loader/PlaceholderDocument.h (149704 => 149705)
--- trunk/Source/WebCore/loader/PlaceholderDocument.h 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/loader/PlaceholderDocument.h 2013-05-08 01:41:16 UTC (rev 149705)
@@ -40,7 +40,9 @@
virtual void attach();
private:
- PlaceholderDocument(Frame* frame, const KURL& url) : Document(frame, url, false, false) { }
+ PlaceholderDocument(Frame* frame, const KURL& url)
+ : Document(frame, url)
+ { }
};
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/SVGDocument.cpp (149704 => 149705)
--- trunk/Source/WebCore/svg/SVGDocument.cpp 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/svg/SVGDocument.cpp 2013-05-08 01:41:16 UTC (rev 149705)
@@ -37,7 +37,7 @@
namespace WebCore {
SVGDocument::SVGDocument(Frame* frame, const KURL& url)
- : Document(frame, url, false, false)
+ : Document(frame, url, SVGDocumentClass)
{
}
Modified: trunk/Source/WebCore/svg/SVGDocument.h (149704 => 149705)
--- trunk/Source/WebCore/svg/SVGDocument.h 2013-05-08 01:35:51 UTC (rev 149704)
+++ trunk/Source/WebCore/svg/SVGDocument.h 2013-05-08 01:41:16 UTC (rev 149705)
@@ -51,8 +51,6 @@
private:
SVGDocument(Frame*, const KURL&);
- virtual bool isSVGDocument() const { return true; }
-
virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const;
FloatPoint m_translate;