Title: [131549] trunk/Source
Revision
131549
Author
morr...@google.com
Date
2012-10-16 22:39:01 -0700 (Tue, 16 Oct 2012)

Log Message

[Shadow DOM][V8] WebCore::V8DOMWindow::installPerContextProperties() is slow when shadowDOMEnabled flag is on.
https://bugs.webkit.org/show_bug.cgi?id=99428

Reviewed by Adam Barth.

Source/WebCore:

A benchmark unveiled that installPerContextProperties() could have made DOMWindow setup slower when
- Some properties are added per-context basis by turnin the flag on and
- There are bunch of DOMWindow object in the page (that is, there are many iframes.)

This change eliminates Shadow DOM related per-context properties from DOMWindow for getting rid of that slowness.

* dom/ContextFeatures.cpp:
* dom/ContextFeatures.h: Removed shadowDOMEnabled() method and related enum entry.
* dom/Position.cpp:
(WebCore::Position::Position):
(WebCore::Position::findParent):
* dom/TreeScope.cpp:
(WebCore::TreeScope::getSelection):
* dom/make_names.pl: Re-introduced "runtimeConditional" directive.
(defaultTagPropertyHash):
(printConstructorInterior):
(printFactoryCppFile):
(printWrapperFunctions):
(printWrapperFactoryCppFile):
* html/HTMLTagNames.in:
* html/shadow/HTMLContentElement.cpp:
(WebCore::contentTagName):
* page/DOMWindow.idl:

Source/WebKit/chromium:

* src/ContextFeaturesClientImpl.cpp:
(WebKit::ContextFeaturesClientImpl::askIfIsEnabled):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (131548 => 131549)


--- trunk/Source/WebCore/ChangeLog	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebCore/ChangeLog	2012-10-17 05:39:01 UTC (rev 131549)
@@ -1,3 +1,34 @@
+2012-10-16  MORITA Hajime  <morr...@google.com>
+
+        [Shadow DOM][V8] WebCore::V8DOMWindow::installPerContextProperties() is slow when shadowDOMEnabled flag is on.
+        https://bugs.webkit.org/show_bug.cgi?id=99428
+
+        Reviewed by Adam Barth.
+
+        A benchmark unveiled that installPerContextProperties() could have made DOMWindow setup slower when
+        - Some properties are added per-context basis by turnin the flag on and
+        - There are bunch of DOMWindow object in the page (that is, there are many iframes.)
+
+        This change eliminates Shadow DOM related per-context properties from DOMWindow for getting rid of that slowness.
+
+        * dom/ContextFeatures.cpp:
+        * dom/ContextFeatures.h: Removed shadowDOMEnabled() method and related enum entry.
+        * dom/Position.cpp:
+        (WebCore::Position::Position):
+        (WebCore::Position::findParent):
+        * dom/TreeScope.cpp:
+        (WebCore::TreeScope::getSelection):
+        * dom/make_names.pl: Re-introduced "runtimeConditional" directive.
+        (defaultTagPropertyHash):
+        (printConstructorInterior):
+        (printFactoryCppFile):
+        (printWrapperFunctions):
+        (printWrapperFactoryCppFile):
+        * html/HTMLTagNames.in:
+        * html/shadow/HTMLContentElement.cpp:
+        (WebCore::contentTagName):
+        * page/DOMWindow.idl:
+
 2012-10-16  Julien Chaffraix  <jchaffr...@webkit.org>
 
         Make RenderObject destruction during detach a top-down operation

Modified: trunk/Source/WebCore/dom/ContextFeatures.cpp (131548 => 131549)


--- trunk/Source/WebCore/dom/ContextFeatures.cpp	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebCore/dom/ContextFeatures.cpp	2012-10-17 05:39:01 UTC (rev 131549)
@@ -63,18 +63,6 @@
 #endif
 }
 
-bool ContextFeatures::shadowDOMEnabled(Document* document)
-{
-#if ENABLE(SHADOW_DOM)
-    if (!document)
-        return RuntimeEnabledFeatures::shadowDOMEnabled();
-    return document->contextFeatures()->isEnabled(document, ShadowDOM, RuntimeEnabledFeatures::shadowDOMEnabled());
-#else
-    UNUSED_PARAM(document);
-    return false;
-#endif
-}
-
 bool ContextFeatures::styleScopedEnabled(Document* document)
 {
 #if ENABLE(STYLE_SCOPED)

Modified: trunk/Source/WebCore/dom/ContextFeatures.h (131548 => 131549)


--- trunk/Source/WebCore/dom/ContextFeatures.h	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebCore/dom/ContextFeatures.h	2012-10-17 05:39:01 UTC (rev 131549)
@@ -40,7 +40,6 @@
 public:
     enum FeatureType {
         DialogElement = 0,
-        ShadowDOM,
         StyleScoped,
         PagePopup,
         HTMLNotifications,
@@ -53,7 +52,6 @@
     static PassRefPtr<ContextFeatures> create(ContextFeaturesClient*);
 
     static bool dialogElementEnabled(Document*);
-    static bool shadowDOMEnabled(Document*);
     static bool styleScopedEnabled(Document*);
     static bool pagePopupEnabled(Document*);
     static bool htmlNotificationsEnabled(Document*);

Modified: trunk/Source/WebCore/dom/Position.cpp (131548 => 131549)


--- trunk/Source/WebCore/dom/Position.cpp	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebCore/dom/Position.cpp	2012-10-17 05:39:01 UTC (rev 131549)
@@ -27,13 +27,13 @@
 #include "Position.h"
 
 #include "CSSComputedStyleDeclaration.h"
-#include "ContextFeatures.h"
 #include "HTMLNames.h"
 #include "InlineTextBox.h"
 #include "Logging.h"
 #include "PositionIterator.h"
 #include "RenderBlock.h"
 #include "RenderText.h"
+#include "RuntimeEnabledFeatures.h"
 #include "Text.h"
 #include "TextIterator.h"
 #include "VisiblePosition.h"
@@ -82,7 +82,7 @@
     , m_isLegacyEditingPosition(true)
 {
 #if ENABLE(SHADOW_DOM)
-    ASSERT((m_anchorNode && ContextFeatures::shadowDOMEnabled(m_anchorNode->document()))
+    ASSERT((m_anchorNode && RuntimeEnabledFeatures::shadowDOMEnabled())
            || !m_anchorNode || !m_anchorNode->isShadowRoot());
 #else
     ASSERT(!m_anchorNode || !m_anchorNode->isShadowRoot());
@@ -96,7 +96,7 @@
     , m_isLegacyEditingPosition(false)
 {
 #if ENABLE(SHADOW_DOM)
-    ASSERT((m_anchorNode && ContextFeatures::shadowDOMEnabled(m_anchorNode->document()))
+    ASSERT((m_anchorNode && RuntimeEnabledFeatures::shadowDOMEnabled())
            || !m_anchorNode || !m_anchorNode->isShadowRoot());
 #else
     ASSERT(!m_anchorNode || !m_anchorNode->isShadowRoot());
@@ -114,7 +114,7 @@
     , m_isLegacyEditingPosition(false)
 {
 #if ENABLE(SHADOW_DOM)
-    ASSERT((m_anchorNode && ContextFeatures::shadowDOMEnabled(m_anchorNode->document()))
+    ASSERT((m_anchorNode && RuntimeEnabledFeatures::shadowDOMEnabled())
            || !m_anchorNode || !editingIgnoresContent(m_anchorNode.get()) || !m_anchorNode->isShadowRoot());
 #else
     ASSERT(!m_anchorNode || !editingIgnoresContent(m_anchorNode.get()) || !m_anchorNode->isShadowRoot());
@@ -858,7 +858,7 @@
     // FIXME: See http://web.ug/82697
 
 #if ENABLE(SHADOW_DOM)
-    if (ContextFeatures::shadowDOMEnabled(node->document()))
+    if (RuntimeEnabledFeatures::shadowDOMEnabled())
         return node->parentNode();
 #endif
 

Modified: trunk/Source/WebCore/dom/TreeScope.cpp (131548 => 131549)


--- trunk/Source/WebCore/dom/TreeScope.cpp	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebCore/dom/TreeScope.cpp	2012-10-17 05:39:01 UTC (rev 131549)
@@ -28,7 +28,6 @@
 
 #include "ComposedShadowTreeWalker.h"
 #include "ContainerNode.h"
-#include "ContextFeatures.h"
 #include "DOMSelection.h"
 #include "DOMWindow.h"
 #include "Document.h"
@@ -42,6 +41,7 @@
 #include "IdTargetObserverRegistry.h"
 #include "InsertionPoint.h"
 #include "Page.h"
+#include "RuntimeEnabledFeatures.h"
 #include "ShadowRoot.h"
 #include "TreeScopeAdopter.h"
 #include <wtf/Vector.h>
@@ -156,7 +156,7 @@
     // as a container. It is now enabled only if runtime Shadow DOM feature is enabled.
     // See https://bugs.webkit.org/show_bug.cgi?id=82697
 #if ENABLE(SHADOW_DOM)
-    if (ContextFeatures::shadowDOMEnabled(rootNode()->document())) {
+    if (RuntimeEnabledFeatures::shadowDOMEnabled()) {
         m_selection = DOMSelection::create(this);
         return m_selection.get();
     }

Modified: trunk/Source/WebCore/dom/make_names.pl (131548 => 131549)


--- trunk/Source/WebCore/dom/make_names.pl	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebCore/dom/make_names.pl	2012-10-17 05:39:01 UTC (rev 131549)
@@ -186,7 +186,8 @@
         'mapToTagName' => '',
         'wrapperOnlyIfMediaIsAvailable' => 0,
         'conditional' => 0,
-        'contextConditional' => 0
+        'contextConditional' => 0,
+        'runtimeConditional' => 0
     );
 }
 
@@ -384,6 +385,15 @@
 ;
     }
 
+    my $runtimeConditional = $enabledTags{$tagName}{runtimeConditional};
+    if ($runtimeConditional) {
+        print F <<END
+    if (!RuntimeEnabledFeatures::${runtimeConditional}Enabled())
+        return 0;
+END
+;
+    }
+
     # Call the constructor with the right parameters.
     print F "    return ${interfaceName}::create($constructorTagName, document";
     print F ", formElement" if $enabledTags{$tagName}{constructorNeedsFormElement};
@@ -811,6 +821,7 @@
 print F <<END
 
 #include "ContextFeatures.h"
+#include "RuntimeEnabledFeatures.h"
 
 #if ENABLE(DASHBOARD_SUPPORT) || ENABLE(VIDEO)
 #include "Document.h"
@@ -1028,6 +1039,20 @@
 }
 END
 ;
+            } elsif ($enabledTags{$tagName}{runtimeConditional}) {
+                my $runtimeConditional = $enabledTags{$tagName}{runtimeConditional};
+                print F <<END
+static JSDOMWrapper* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element)
+{
+    if (!RuntimeEnabledFeatures::${runtimeConditional}Enabled()) {
+        ASSERT(!element || element->is$parameters{fallbackInterfaceName}());
+        return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{fallbackInterfaceName}, element.get());
+    }
+
+    return CREATE_DOM_WRAPPER(exec, globalObject, ${JSInterfaceName}, element.get());
+}
+END
+;
             } else {
                 print F <<END
 static JSDOMWrapper* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element)
@@ -1062,6 +1087,17 @@
 }
 END
 ;
+            } elsif ($enabledTags{$tagName}{runtimeConditional}) {
+                my $runtimeConditional = $enabledTags{$tagName}{runtimeConditional};
+                print F <<END
+static v8::Handle<v8::Value> create${JSInterfaceName}Wrapper($parameters{namespace}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+{
+    if (!RuntimeEnabledFeatures::${runtimeConditional}Enabled())
+        return V8$parameters{fallbackInterfaceName}::wrap(to$parameters{fallbackInterfaceName}(element), creationContext, isolate);
+    return toV8(static_cast<${JSInterfaceName}*>(element), creationContext, isolate);
+}
+END
+;
             } elsif (${JSInterfaceName} eq "HTMLElement") {
                 print F <<END
 static v8::Handle<v8::Value> create${JSInterfaceName}Wrapper($parameters{namespace}Element* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
@@ -1118,6 +1154,7 @@
     print F <<END
 
 #include "ContextFeatures.h"
+#include "RuntimeEnabledFeatures.h"
 
 #if ENABLE(VIDEO)
 #include "Document.h"

Modified: trunk/Source/WebCore/html/HTMLTagNames.in (131548 => 131549)


--- trunk/Source/WebCore/html/HTMLTagNames.in	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebCore/html/HTMLTagNames.in	2012-10-17 05:39:01 UTC (rev 131549)
@@ -31,7 +31,7 @@
 col interfaceName=HTMLTableColElement
 colgroup interfaceName=HTMLTableColElement
 command interfaceName=HTMLElement
-content interfaceName=HTMLContentElement, conditional=SHADOW_DOM, contextConditional=shadowDOM
+content interfaceName=HTMLContentElement, conditional=SHADOW_DOM, runtimeConditional=shadowDOM
 webkitShadowContent interfaceName=HTMLElement, noConstructor
 datalist interfaceName=HTMLDataListElement, conditional=DATALIST_ELEMENT
 dd interfaceName=HTMLElement
@@ -97,7 +97,7 @@
 optgroup interfaceName=HTMLOptGroupElement
 option
 output constructorNeedsFormElement
-shadow interfaceName=HTMLShadowElement, conditional=SHADOW_DOM, contextConditional=shadowDOM
+shadow interfaceName=HTMLShadowElement, conditional=SHADOW_DOM, runtimeConditional=shadowDOM
 p interfaceName=HTMLParagraphElement
 param
 plaintext interfaceName=HTMLElement

Modified: trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp (131548 => 131549)


--- trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp	2012-10-17 05:39:01 UTC (rev 131549)
@@ -29,10 +29,10 @@
 
 #include "ContentDistributor.h"
 #include "ContentSelectorQuery.h"
-#include "ContextFeatures.h"
 #include "ElementShadow.h"
 #include "HTMLNames.h"
 #include "QualifiedName.h"
+#include "RuntimeEnabledFeatures.h"
 #include "ShadowRoot.h"
 #include <wtf/StdLibExtras.h>
 
@@ -43,7 +43,7 @@
 static const QualifiedName& contentTagName(Document* document)
 {
 #if ENABLE(SHADOW_DOM)
-    if (!ContextFeatures::shadowDOMEnabled(document))
+    if (!RuntimeEnabledFeatures::shadowDOMEnabled())
         return HTMLNames::webkitShadowContentTag;
     return HTMLNames::contentTag;
 #else

Modified: trunk/Source/WebCore/page/DOMWindow.idl (131548 => 131549)


--- trunk/Source/WebCore/page/DOMWindow.idl	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2012-10-17 05:39:01 UTC (rev 131549)
@@ -392,9 +392,9 @@
     attribute EntityConstructor Entity;
     attribute EntityReferenceConstructor EntityReference;
     attribute ProcessingInstructionConstructor ProcessingInstruction;
-    [Conditional=SHADOW_DOM, V8EnabledPerContext=shadowDOM] attribute ShadowRootConstructor WebKitShadowRoot;
-    [Conditional=SHADOW_DOM, V8EnabledPerContext=shadowDOM] attribute HTMLContentElementConstructor HTMLContentElement;
-    [Conditional=SHADOW_DOM, V8EnabledPerContext=shadowDOM] attribute HTMLShadowElementConstructor HTMLShadowElement;
+    [Conditional=SHADOW_DOM, V8EnabledAtRuntime=shadowDOM] attribute ShadowRootConstructor WebKitShadowRoot;
+    [Conditional=SHADOW_DOM, V8EnabledAtRuntime=shadowDOM] attribute HTMLContentElementConstructor HTMLContentElement;
+    [Conditional=SHADOW_DOM, V8EnabledAtRuntime=shadowDOM] attribute HTMLShadowElementConstructor HTMLShadowElement;
 
     attribute DOMSelectionConstructor Selection;
     attribute DOMWindowConstructor Window;

Modified: trunk/Source/WebKit/chromium/ChangeLog (131548 => 131549)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-10-17 05:39:01 UTC (rev 131549)
@@ -1,3 +1,13 @@
+2012-10-16  MORITA Hajime  <morr...@google.com>
+
+        [Shadow DOM][V8] WebCore::V8DOMWindow::installPerContextProperties() is slow when shadowDOMEnabled flag is on.
+        https://bugs.webkit.org/show_bug.cgi?id=99428
+
+        Reviewed by Adam Barth.
+
+        * src/ContextFeaturesClientImpl.cpp:
+        (WebKit::ContextFeaturesClientImpl::askIfIsEnabled):
+
 2012-10-16  Alec Flett  <alecfl...@chromium.org>
 
         IndexedDB: Stub out chromium success handlers for integers and undefined values

Modified: trunk/Source/WebKit/chromium/src/ContextFeaturesClientImpl.cpp (131548 => 131549)


--- trunk/Source/WebKit/chromium/src/ContextFeaturesClientImpl.cpp	2012-10-17 02:48:11 UTC (rev 131548)
+++ trunk/Source/WebKit/chromium/src/ContextFeaturesClientImpl.cpp	2012-10-17 05:39:01 UTC (rev 131549)
@@ -140,7 +140,6 @@
         return defaultValue;
 
     switch (type) {
-    case ContextFeatures::ShadowDOM:
     case ContextFeatures::StyleScoped:
         return m_client->allowWebComponents(WebDocument(document), defaultValue);
     case ContextFeatures::HTMLNotifications:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to