Devirtualize isHTMLUnknownElement().
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Apr 2014 21:33:19 +0000 (21:33 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Apr 2014 21:33:19 +0000 (21:33 +0000)
<https://webkit.org/b/131269>

We were hitting isHTMLUnknownElement() pretty hard when marking
out-of-document Nodes. (The check is part of isHTMLAudioElement()
which is called by JSNodeOwner::isReachableFromOpaqueRoots().)

This patch uses a Node flag for the unknown element instead.
I'm also adding HTMLUnknownElement.{h,idl} to the Xcode project
since they were suspiciously missing.

Reviewed by Benjamin Poulain.

* WebCore.xcodeproj/project.pbxproj:
* dom/Node.h:
* html/HTMLElement.h:
(WebCore::HTMLElement::isHTMLUnknownElement):
* html/HTMLUnknownElement.h:
(WebCore::toHTMLUnknownElement): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166839 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Node.h
Source/WebCore/html/HTMLElement.h
Source/WebCore/html/HTMLUnknownElement.h

index d63ec16..387d6af 100644 (file)
@@ -1,3 +1,25 @@
+2014-04-05  Andreas Kling  <akling@apple.com>
+
+        Devirtualize isHTMLUnknownElement().
+        <https://webkit.org/b/131269>
+
+        We were hitting isHTMLUnknownElement() pretty hard when marking
+        out-of-document Nodes. (The check is part of isHTMLAudioElement()
+        which is called by JSNodeOwner::isReachableFromOpaqueRoots().)
+
+        This patch uses a Node flag for the unknown element instead.
+        I'm also adding HTMLUnknownElement.{h,idl} to the Xcode project
+        since they were suspiciously missing.
+
+        Reviewed by Benjamin Poulain.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Node.h:
+        * html/HTMLElement.h:
+        (WebCore::HTMLElement::isHTMLUnknownElement):
+        * html/HTMLUnknownElement.h:
+        (WebCore::toHTMLUnknownElement): Deleted.
+
 2014-04-05  Dirk Schulze  <krit@webkit.org>
 
         Canvas stroke and strokeRect with SourceIn, DestinationIn, SourceOut, DestinationAtop and Copy have errors
index 66b9eb4..1fdefe3 100644 (file)
                AD20B18D18E9D237005A8083 /* JSNodeListCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AD4495F3141FC08900541EDF /* EventListenerMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4495F1141FC08900541EDF /* EventListenerMap.cpp */; };
                AD4495F4141FC08900541EDF /* EventListenerMap.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4495F2141FC08900541EDF /* EventListenerMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               AD49914318F0815100BF0092 /* HTMLUnknownElement.h in Headers */ = {isa = PBXBuildFile; fileRef = AD49914118F0815100BF0092 /* HTMLUnknownElement.h */; };
                AD6E71AC1668899D00320C13 /* DocumentSharedObjectPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */; };
                AD6E71AD1668899D00320C13 /* DocumentSharedObjectPool.h in Headers */ = {isa = PBXBuildFile; fileRef = AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */; };
                AD726FED16DA1171003A4E6D /* JSCSSStyleDeclarationCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
                AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNodeListCustom.h; sourceTree = "<group>"; };
                AD4495F1141FC08900541EDF /* EventListenerMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventListenerMap.cpp; sourceTree = "<group>"; };
                AD4495F2141FC08900541EDF /* EventListenerMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventListenerMap.h; sourceTree = "<group>"; };
+               AD49914118F0815100BF0092 /* HTMLUnknownElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLUnknownElement.h; sourceTree = "<group>"; };
+               AD49914218F0815100BF0092 /* HTMLUnknownElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLUnknownElement.idl; sourceTree = "<group>"; };
                AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentSharedObjectPool.cpp; sourceTree = "<group>"; };
                AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentSharedObjectPool.h; sourceTree = "<group>"; };
                AD726FE716D9F204003A4E6D /* JSMediaListCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaListCustom.h; sourceTree = "<group>"; };
                                A8EA79E70A1916DF00A8EF5F /* HTMLUListElement.cpp */,
                                A8EA79E60A1916DF00A8EF5F /* HTMLUListElement.h */,
                                1A85B1D50A1B236C00D8C87C /* HTMLUListElement.idl */,
+                               AD49914118F0815100BF0092 /* HTMLUnknownElement.h */,
+                               AD49914218F0815100BF0092 /* HTMLUnknownElement.idl */,
                                E44613980CD6331000FADA75 /* HTMLVideoElement.cpp */,
                                E44613990CD6331000FADA75 /* HTMLVideoElement.h */,
                                E446139A0CD6331000FADA75 /* HTMLVideoElement.idl */,
                                0F54DCE61881051D003EEDBB /* TextAutoSizing.h in Headers */,
                                B2C3DA340D006C1D00EF6F26 /* TextBoundaries.h in Headers */,
                                B2C3DA360D006C1D00EF6F26 /* TextBreakIterator.h in Headers */,
+                               AD49914318F0815100BF0092 /* HTMLUnknownElement.h in Headers */,
                                B2C3DA380D006C1D00EF6F26 /* TextBreakIteratorInternalICU.h in Headers */,
                                A7151BD812F1558F005A0F64 /* TextCheckerClient.h in Headers */,
                                A77D0012133B0AEB00D6658C /* TextChecking.h in Headers */,
index c914e70..85ab487 100644 (file)
@@ -611,6 +611,8 @@ protected:
 
         SelfOrAncestorHasDirAutoFlag = 1 << 29,
 
+        IsHTMLUnknownElementFlag = 1 << 30,
+
         DefaultNodeFlags = IsParsingChildrenFinishedFlag
     };
 
@@ -634,6 +636,7 @@ protected:
         CreateInsertionPoint = CreateHTMLElement | NeedsNodeRenderingTraversalSlowPathFlag,
         CreateEditingText = CreateText | IsEditingTextFlag,
         CreateMathMLElement = CreateStyledElement | IsMathMLFlag,
+        CreateHTMLUnknownElement = CreateHTMLElement | IsHTMLUnknownElementFlag,
     };
     Node(Document&, ConstructionType);
 
index c9b60df..cc0452d 100644 (file)
@@ -89,7 +89,7 @@ public:
     bool hasDirectionAuto() const;
     TextDirection directionalityIfhasDirAutoAttribute(bool& isAuto) const;
 
-    virtual bool isHTMLUnknownElement() const { return false; }
+    bool isHTMLUnknownElement() const { return getFlag(IsHTMLUnknownElementFlag); }
     virtual bool isTextControlInnerTextElement() const { return false; }
 
     virtual bool willRespondToMouseMoveEvents() override;
index 755caef..cd36d7d 100644 (file)
@@ -41,20 +41,14 @@ public:
         return adoptRef(new HTMLUnknownElement(tagName, document));
     }
 
-    virtual bool isHTMLUnknownElement() const override { return true; }
-
 private:
     HTMLUnknownElement(const QualifiedName& tagName, Document& document)
-        : HTMLElement(tagName, document)
+        : HTMLElement(tagName, document, CreateHTMLUnknownElement)
     {
     }
 };
 
-inline HTMLUnknownElement* toHTMLUnknownElement(HTMLElement* element)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!element || element->isHTMLUnknownElement());
-    return static_cast<HTMLUnknownElement*>(element);
-}
+NODE_TYPE_CASTS(HTMLUnknownElement)
 
 } // namespace