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

Unified Diff: third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp

Issue 1853713002: Fixed ::slotted performance in pure v1 shadow documents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing Member<> in HeapVector template Created 4 years, 9 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
Index: third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
index 3cee9f558ddf9765e536d184c327ffd0ce364493..c733d5a45a557316d9ba7a4d404a99d9cb103e86 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
@@ -81,6 +81,7 @@
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLIFrameElement.h"
+#include "core/html/HTMLSlotElement.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/layout/GeneratedChildren.h"
#include "core/layout/LayoutView.h"
@@ -431,6 +432,25 @@ static void matchHostRules(const Element& element, ElementRuleCollector& collect
}
}
+static void matchSlottedRules(const Element& element, ElementRuleCollector& collector)
+{
+ HTMLSlotElement* slot = element.assignedSlot();
+ if (!slot)
+ return;
+
+ HeapVector<Member<ScopedStyleResolver>> resolvers;
+ for (; slot; slot = slot->assignedSlot()) {
+ if (ScopedStyleResolver* resolver = slot->treeScope().scopedStyleResolver())
+ resolvers.append(resolver);
+ }
+ for (auto it = resolvers.rbegin(); it != resolvers.rend(); ++it) {
+ collector.clearMatchedRules();
+ (*it)->collectMatchingTreeBoundaryCrossingRules(collector);
+ collector.sortAndTransferMatchedRules();
+ collector.finishAddingAuthorRulesForTreeScope();
+ }
+}
+
static void matchElementScopeRules(const Element& element, ScopedStyleResolver* elementScopeResolver, ElementRuleCollector& collector)
{
if (elementScopeResolver) {
@@ -482,11 +502,15 @@ void StyleResolver::matchScopedRules(const Element& element, ElementRuleCollecto
// scope, only tree-boundary-crossing rules may match.
ScopedStyleResolver* elementScopeResolver = scopedResolverFor(element);
+
+ if (!document().styleEngine().mayContainV0Shadow()) {
+ matchSlottedRules(element, collector);
+ matchElementScopeRules(element, elementScopeResolver, collector);
+ return;
+ }
+
bool matchElementScopeDone = !elementScopeResolver && !element.inlineStyle();
- // TODO(kochi): This loops through m_treeBoundaryCrossingScopes because to handle
- // Shadow DOM V0 documents as well. In pure V1 document only have to go through
- // the chain of scopes for assigned slots. Add fast path for pure V1 document.
for (auto it = m_treeBoundaryCrossingScopes.rbegin(); it != m_treeBoundaryCrossingScopes.rend(); ++it) {
const TreeScope& scope = (*it)->treeScope();
ScopedStyleResolver* resolver = scope.scopedStyleResolver();

Powered by Google App Engine
This is Rietveld 408576698