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

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2376453004: Stash ComputedStyles on new HeapHashMap on Document. (Closed)
Patch Set: CL for src perf tryjob to run blink_perf.svg benchmark on all platform(s) Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/dom/Element.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index cc1a8a9ad6e01f3107621b34bdde57373c14ca40..fd5e9f7301da01091c9373a72fe833e18d62fdda 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -1246,6 +1246,24 @@ Element* Document::scrollingElement() {
return body();
}
+// We use HashMap::set over HashMap::add here as we want to
+// replace the ComputedStyle but not the Element if the Element is
+// already present.
+void Document::addNonAttachedStyle(Element* element,
+ RefPtr<ComputedStyle> computedStyle) {
+ m_nonAttachedStyle.set(element, computedStyle);
+}
+
+RefPtr<ComputedStyle> Document::getNonAttachedStyle(Element* element) {
+ return m_nonAttachedStyle.get(element);
+}
+
+void Document::clear() {
esprehn 2016/10/05 01:04:25 Remove this function, you can't add something so g
nainar 2016/10/05 02:00:01 Done.
+ for (NonAttachedStyleMap::iterator iter = m_nonAttachedStyle.begin();
+ iter != m_nonAttachedStyle.end(); ++iter)
+ m_nonAttachedStyle.remove(iter);
esprehn 2016/10/05 01:04:25 m_nonAttachedStyle.clear(), note that calling remo
nainar 2016/10/05 02:00:01 Done.
+}
+
/*
* Performs three operations:
* 1. Convert control characters to spaces
@@ -1876,6 +1894,9 @@ void Document::updateStyle() {
HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc);
+ // Reserving capacity to avoid rehashes.
+ m_nonAttachedStyle.reserveCapacityForSize(initialElementCount);
esprehn 2016/10/05 01:04:25 initialElementCount doesn't mean what you think it
nainar 2016/10/05 02:00:01 Done.
+
StyleRecalcChange change = NoChange;
if (getStyleChangeType() >= SubtreeStyleChange)
change = Force;
@@ -1917,6 +1938,9 @@ void Document::updateStyle() {
view()->recalcOverflowAfterStyleChange();
+ // Only retain the HashMap for the duration of StyleRecalc and
+ // LayoutTreeConstruction.
+ m_nonAttachedStyle.clear();
clearChildNeedsStyleRecalc();
resolver.clearStyleSharingList();
@@ -1927,6 +1951,7 @@ void Document::updateStyle() {
DCHECK(!childNeedsStyleRecalc());
DCHECK(inStyleRecalc());
DCHECK_EQ(styleResolver(), &resolver);
+ DCHECK(m_nonAttachedStyle.isEmpty());
m_lifecycle.advanceTo(DocumentLifecycle::StyleClean);
if (shouldRecordStats) {
TRACE_EVENT_END2("blink,blink_style", "Document::updateStyle",
@@ -6326,6 +6351,7 @@ DEFINE_TRACE(Document) {
visitor->trace(m_snapCoordinator);
visitor->trace(m_resizeObserverController);
visitor->trace(m_propertyRegistry);
+ visitor->trace(m_nonAttachedStyle);
Supplementable<Document>::trace(visitor);
TreeScope::trace(visitor);
ContainerNode::trace(visitor);
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698