Changeset 149705 in webkit
- Timestamp:
- May 7, 2013 6:41:16 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r149700 r149705 1 2013-05-07 Ryosuke Niwa <rniwa@webkit.org> 2 3 Devirtualize Document class type checking 4 https://bugs.webkit.org/show_bug.cgi?id=115755 5 6 Reviewed by Benjamin Poulain. 7 8 Merge https://chromium.googlesource.com/chromium/blink/+/dae5adc768d5ce6bff301df6515745da8ea24950 9 10 Document has a bunch of virtual bool is*Document() methods on it, but it also has 11 two bools for XHTML and HTML documents which is silly. We can merge them all 12 together into an enum of values and devirtualize the type checking methods. 13 14 * dom/Document.cpp: 15 (WebCore::Document::Document): 16 (WebCore::Document::createElement): 17 * dom/Document.h: 18 (WebCore::Document::create): 19 (WebCore::Document::createXHTML): 20 (WebCore::Document::isHTMLDocument): 21 (WebCore::Document::isXHTMLDocument): 22 (WebCore::Document::isImageDocument): 23 (WebCore::Document::isSVGDocument): 24 (WebCore::Document::isPluginDocument): 25 (WebCore::Document::isMediaDocument): 26 (WebCore::Document): 27 * html/HTMLDocument.cpp: 28 (WebCore::HTMLDocument::HTMLDocument): 29 * html/HTMLDocument.h: 30 (WebCore::HTMLDocument): 31 * html/ImageDocument.cpp: 32 (WebCore::ImageDocument::ImageDocument): 33 * html/ImageDocument.h: 34 (WebCore::ImageDocument): 35 * html/MediaDocument.cpp: 36 (WebCore::MediaDocument::MediaDocument): 37 * html/MediaDocument.h: 38 (WebCore::MediaDocument): 39 * html/PluginDocument.cpp: 40 (WebCore::PluginDocument::PluginDocument): 41 * html/PluginDocument.h: 42 (WebCore::PluginDocument): 43 * loader/PlaceholderDocument.h: 44 (WebCore::PlaceholderDocument::PlaceholderDocument): 45 * svg/SVGDocument.cpp: 46 (WebCore::SVGDocument::SVGDocument): 47 * svg/SVGDocument.h: 48 (WebCore::SVGDocument): 49 1 50 2013-05-07 Anders Carlsson <andersca@apple.com> 2 51 -
trunk/Source/WebCore/dom/Document.cpp
r149652 r149705 414 414 uint64_t Document::s_globalTreeVersion = 0; 415 415 416 Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)416 Document::Document(Frame* frame, const KURL& url, unsigned documentClasses) 417 417 : ContainerNode(0, CreateDocument) 418 418 , TreeScope(this) … … 452 452 , m_inPageCache(false) 453 453 , m_accessKeyMapValid(false) 454 , m_isXHTML(isXHTML) 455 , m_isHTML(isHTML) 454 , m_documentClasses(documentClasses) 456 455 , m_isViewSource(false) 457 456 , m_sawElementsInKnownNamespaces(false) … … 829 828 } 830 829 831 if ( m_isXHTML)830 if (isXHTMLDocument()) 832 831 return HTMLElementFactory::createHTMLElement(QualifiedName(nullAtom, name, xhtmlNamespaceURI), this, 0, false); 833 832 -
trunk/Source/WebCore/dom/Document.h
r149586 r149705 221 221 typedef HashCountedSet<Node*> TouchEventTargetSet; 222 222 223 enum DocumentClass { 224 DefaultDocumentClass = 0, 225 HTMLDocumentClass = 1, 226 XHTMLDocumentClass = 1 << 1, 227 ImageDocumentClass = 1 << 2, 228 PluginDocumentClass = 1 << 3, 229 MediaDocumentClass = 1 << 4, 230 SVGDocumentClass = 1 << 5, 231 }; 232 233 typedef unsigned char DocumentClassFlags; 234 223 235 class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext { 224 236 public: 225 237 static PassRefPtr<Document> create(Frame* frame, const KURL& url) 226 238 { 227 return adoptRef(new Document(frame, url , false, false));239 return adoptRef(new Document(frame, url)); 228 240 } 229 241 static PassRefPtr<Document> createXHTML(Frame* frame, const KURL& url) 230 242 { 231 return adoptRef(new Document(frame, url, true, false));243 return adoptRef(new Document(frame, url, XHTMLDocumentClass)); 232 244 } 233 245 virtual ~Document(); … … 428 440 429 441 // Other methods (not part of DOM) 430 bool isHTMLDocument() const { return m_isHTML; } 431 bool isXHTMLDocument() const { return m_isXHTML; } 432 virtual bool isImageDocument() const { return false; } 442 bool isHTMLDocument() const { return m_documentClasses & HTMLDocumentClass; } 443 bool isXHTMLDocument() const { return m_documentClasses & XHTMLDocumentClass; } 444 bool isImageDocument() const { return m_documentClasses & ImageDocumentClass; } 445 bool isSVGDocument() const { return m_documentClasses & SVGDocumentClass; } 446 bool isPluginDocument() const { return m_documentClasses & PluginDocumentClass; } 447 bool isMediaDocument() const { return m_documentClasses & MediaDocumentClass; } 433 448 #if ENABLE(SVG) 434 virtual bool isSVGDocument() const { return false; }435 449 bool hasSVGRootNode() const; 436 450 #else 437 static bool isSVGDocument() { return false; }438 451 static bool hasSVGRootNode() { return false; } 439 452 #endif 440 virtual bool isPluginDocument() const { return false; }441 virtual bool isMediaDocument() const { return false; }442 453 virtual bool isFrameSet() const { return false; } 443 454 … … 1208 1219 1209 1220 protected: 1210 Document(Frame*, const KURL&, bool isXHTML, bool isHTML);1221 Document(Frame*, const KURL&, unsigned = DefaultDocumentClass); 1211 1222 1212 1223 virtual void didUpdateSecurityOrigin() OVERRIDE; … … 1475 1486 OwnPtr<SelectorQueryCache> m_selectorQueryCache; 1476 1487 1477 bool m_isXHTML; 1478 bool m_isHTML; 1488 DocumentClassFlags m_documentClasses; 1479 1489 1480 1490 bool m_isViewSource; -
trunk/Source/WebCore/html/HTMLDocument.cpp
r149652 r149705 82 82 using namespace HTMLNames; 83 83 84 HTMLDocument::HTMLDocument(Frame* frame, const KURL& url )85 : Document(frame, url, false, true)84 HTMLDocument::HTMLDocument(Frame* frame, const KURL& url, DocumentClassFlags documentClasses) 85 : Document(frame, url, documentClasses | HTMLDocumentClass) 86 86 { 87 87 clearXMLVersion(); -
trunk/Source/WebCore/html/HTMLDocument.h
r149652 r149705 76 76 77 77 protected: 78 HTMLDocument(Frame*, const KURL& );78 HTMLDocument(Frame*, const KURL&, DocumentClassFlags = 0); 79 79 80 80 private: -
trunk/Source/WebCore/html/ImageDocument.cpp
r145745 r149705 178 178 179 179 ImageDocument::ImageDocument(Frame* frame, const KURL& url) 180 : HTMLDocument(frame, url )180 : HTMLDocument(frame, url, ImageDocumentClass) 181 181 , m_imageElement(0) 182 182 , m_imageSizeIsKnown(false) -
trunk/Source/WebCore/html/ImageDocument.h
r145745 r149705 52 52 53 53 virtual PassRefPtr<DocumentParser> createParser(); 54 virtual bool isImageDocument() const { return true; }55 54 56 55 void createDocumentStructure(); -
trunk/Source/WebCore/html/MediaDocument.cpp
r147888 r149705 119 119 120 120 MediaDocument::MediaDocument(Frame* frame, const KURL& url) 121 : HTMLDocument(frame, url )121 : HTMLDocument(frame, url, MediaDocumentClass) 122 122 , m_replaceMediaElementTimer(this, &MediaDocument::replaceMediaElementTimerFired) 123 123 { -
trunk/Source/WebCore/html/MediaDocument.h
r145745 r149705 46 46 MediaDocument(Frame*, const KURL&); 47 47 48 virtual bool isMediaDocument() const { return true; }49 48 virtual PassRefPtr<DocumentParser> createParser(); 50 49 -
trunk/Source/WebCore/html/PluginDocument.cpp
r145914 r149705 137 137 138 138 PluginDocument::PluginDocument(Frame* frame, const KURL& url) 139 : HTMLDocument(frame, url )139 : HTMLDocument(frame, url, PluginDocumentClass) 140 140 , m_shouldLoadPluginManually(true) 141 141 { -
trunk/Source/WebCore/html/PluginDocument.h
r145399 r149705 55 55 56 56 virtual PassRefPtr<DocumentParser> createParser() OVERRIDE; 57 virtual bool isPluginDocument() const OVERRIDE { return true; } 58 57 59 58 void setShouldLoadPluginManually(bool loadManually) { m_shouldLoadPluginManually = loadManually; } 60 59 -
trunk/Source/WebCore/loader/PlaceholderDocument.h
r95901 r149705 41 41 42 42 private: 43 PlaceholderDocument(Frame* frame, const KURL& url) : Document(frame, url, false, false) { } 43 PlaceholderDocument(Frame* frame, const KURL& url) 44 : Document(frame, url) 45 { } 44 46 }; 45 47 -
trunk/Source/WebCore/svg/SVGDocument.cpp
r145459 r149705 38 38 39 39 SVGDocument::SVGDocument(Frame* frame, const KURL& url) 40 : Document(frame, url, false, false)40 : Document(frame, url, SVGDocumentClass) 41 41 { 42 42 } -
trunk/Source/WebCore/svg/SVGDocument.h
r145745 r149705 52 52 SVGDocument(Frame*, const KURL&); 53 53 54 virtual bool isSVGDocument() const { return true; }55 56 54 virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const; 57 55
Note: See TracChangeset
for help on using the changeset viewer.