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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 1239
1240 return body; 1240 return body;
1241 } 1241 }
1242 1242
1243 return documentElement(); 1243 return documentElement();
1244 } 1244 }
1245 1245
1246 return body(); 1246 return body();
1247 } 1247 }
1248 1248
1249 // We use HashMap::set over HashMap::add here as we want to
1250 // replace the ComputedStyle but not the Element if the Element is
1251 // already present.
1252 void Document::addNonAttachedStyle(Element* element,
1253 RefPtr<ComputedStyle> computedStyle) {
1254 m_nonAttachedStyle.set(element, computedStyle);
1255 }
1256
1257 RefPtr<ComputedStyle> Document::getNonAttachedStyle(Element* element) {
1258 return m_nonAttachedStyle.get(element);
1259 }
1260
1261 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.
1262 for (NonAttachedStyleMap::iterator iter = m_nonAttachedStyle.begin();
1263 iter != m_nonAttachedStyle.end(); ++iter)
1264 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.
1265 }
1266
1249 /* 1267 /*
1250 * Performs three operations: 1268 * Performs three operations:
1251 * 1. Convert control characters to spaces 1269 * 1. Convert control characters to spaces
1252 * 2. Trim leading and trailing spaces 1270 * 2. Trim leading and trailing spaces
1253 * 3. Collapse internal whitespace. 1271 * 3. Collapse internal whitespace.
1254 */ 1272 */
1255 template <typename CharacterType> 1273 template <typename CharacterType>
1256 static inline String canonicalizedTitle(Document* document, 1274 static inline String canonicalizedTitle(Document* document,
1257 const String& title) { 1275 const String& title) {
1258 unsigned length = title.length(); 1276 unsigned length = title.length();
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 void Document::updateStyle() { 1887 void Document::updateStyle() {
1870 DCHECK(!view()->shouldThrottleRendering()); 1888 DCHECK(!view()->shouldThrottleRendering());
1871 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle"); 1889 TRACE_EVENT_BEGIN0("blink,blink_style", "Document::updateStyle");
1872 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Style.UpdateTime"); 1890 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Style.UpdateTime");
1873 1891
1874 unsigned initialElementCount = styleEngine().styleForElementCount(); 1892 unsigned initialElementCount = styleEngine().styleForElementCount();
1875 1893
1876 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1894 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1877 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); 1895 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc);
1878 1896
1897 // Reserving capacity to avoid rehashes.
1898 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.
1899
1879 StyleRecalcChange change = NoChange; 1900 StyleRecalcChange change = NoChange;
1880 if (getStyleChangeType() >= SubtreeStyleChange) 1901 if (getStyleChangeType() >= SubtreeStyleChange)
1881 change = Force; 1902 change = Force;
1882 1903
1883 NthIndexCache nthIndexCache(*this); 1904 NthIndexCache nthIndexCache(*this);
1884 1905
1885 // FIXME: Cannot access the ensureStyleResolver() before calling 1906 // FIXME: Cannot access the ensureStyleResolver() before calling
1886 // styleForDocument below because apparently the StyleResolver's constructor 1907 // styleForDocument below because apparently the StyleResolver's constructor
1887 // has side effects. We should fix it. See printing/setPrinting.html, 1908 // has side effects. We should fix it. See printing/setPrinting.html,
1888 // printing/width-overflow.html though they only fail on mac when accessing 1909 // printing/width-overflow.html though they only fail on mac when accessing
(...skipping 21 matching lines...) Expand all
1910 inheritHtmlAndBodyElementStyles(change); 1931 inheritHtmlAndBodyElementStyles(change);
1911 dirtyElementsForLayerUpdate(); 1932 dirtyElementsForLayerUpdate();
1912 if (documentElement->shouldCallRecalcStyle(change)) 1933 if (documentElement->shouldCallRecalcStyle(change))
1913 documentElement->recalcStyle(change); 1934 documentElement->recalcStyle(change);
1914 while (dirtyElementsForLayerUpdate()) 1935 while (dirtyElementsForLayerUpdate())
1915 documentElement->recalcStyle(NoChange); 1936 documentElement->recalcStyle(NoChange);
1916 } 1937 }
1917 1938
1918 view()->recalcOverflowAfterStyleChange(); 1939 view()->recalcOverflowAfterStyleChange();
1919 1940
1941 // Only retain the HashMap for the duration of StyleRecalc and
1942 // LayoutTreeConstruction.
1943 m_nonAttachedStyle.clear();
1920 clearChildNeedsStyleRecalc(); 1944 clearChildNeedsStyleRecalc();
1921 1945
1922 resolver.clearStyleSharingList(); 1946 resolver.clearStyleSharingList();
1923 1947
1924 m_wasPrinting = m_printing; 1948 m_wasPrinting = m_printing;
1925 1949
1926 DCHECK(!needsStyleRecalc()); 1950 DCHECK(!needsStyleRecalc());
1927 DCHECK(!childNeedsStyleRecalc()); 1951 DCHECK(!childNeedsStyleRecalc());
1928 DCHECK(inStyleRecalc()); 1952 DCHECK(inStyleRecalc());
1929 DCHECK_EQ(styleResolver(), &resolver); 1953 DCHECK_EQ(styleResolver(), &resolver);
1954 DCHECK(m_nonAttachedStyle.isEmpty());
1930 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean); 1955 m_lifecycle.advanceTo(DocumentLifecycle::StyleClean);
1931 if (shouldRecordStats) { 1956 if (shouldRecordStats) {
1932 TRACE_EVENT_END2("blink,blink_style", "Document::updateStyle", 1957 TRACE_EVENT_END2("blink,blink_style", "Document::updateStyle",
1933 "resolverAccessCount", 1958 "resolverAccessCount",
1934 styleEngine().styleForElementCount() - initialElementCount, 1959 styleEngine().styleForElementCount() - initialElementCount,
1935 "counters", styleEngine().stats()->toTracedValue()); 1960 "counters", styleEngine().stats()->toTracedValue());
1936 } else { 1961 } else {
1937 TRACE_EVENT_END1( 1962 TRACE_EVENT_END1(
1938 "blink,blink_style", "Document::updateStyle", "resolverAccessCount", 1963 "blink,blink_style", "Document::updateStyle", "resolverAccessCount",
1939 styleEngine().styleForElementCount() - initialElementCount); 1964 styleEngine().styleForElementCount() - initialElementCount);
(...skipping 4379 matching lines...) Expand 10 before | Expand all | Expand 10 after
6319 visitor->trace(m_svgExtensions); 6344 visitor->trace(m_svgExtensions);
6320 visitor->trace(m_timeline); 6345 visitor->trace(m_timeline);
6321 visitor->trace(m_compositorPendingAnimations); 6346 visitor->trace(m_compositorPendingAnimations);
6322 visitor->trace(m_contextDocument); 6347 visitor->trace(m_contextDocument);
6323 visitor->trace(m_canvasFontCache); 6348 visitor->trace(m_canvasFontCache);
6324 visitor->trace(m_intersectionObserverController); 6349 visitor->trace(m_intersectionObserverController);
6325 visitor->trace(m_intersectionObserverData); 6350 visitor->trace(m_intersectionObserverData);
6326 visitor->trace(m_snapCoordinator); 6351 visitor->trace(m_snapCoordinator);
6327 visitor->trace(m_resizeObserverController); 6352 visitor->trace(m_resizeObserverController);
6328 visitor->trace(m_propertyRegistry); 6353 visitor->trace(m_propertyRegistry);
6354 visitor->trace(m_nonAttachedStyle);
6329 Supplementable<Document>::trace(visitor); 6355 Supplementable<Document>::trace(visitor);
6330 TreeScope::trace(visitor); 6356 TreeScope::trace(visitor);
6331 ContainerNode::trace(visitor); 6357 ContainerNode::trace(visitor);
6332 ExecutionContext::trace(visitor); 6358 ExecutionContext::trace(visitor);
6333 SecurityContext::trace(visitor); 6359 SecurityContext::trace(visitor);
6334 } 6360 }
6335 6361
6336 void Document::onVisibilityMaybeChanged(bool visible) { 6362 void Document::onVisibilityMaybeChanged(bool visible) {
6337 DCHECK(frame()); 6363 DCHECK(frame());
6338 if (visible && !m_visibilityWasLogged && frame()->isCrossOriginSubframe()) { 6364 if (visible && !m_visibilityWasLogged && frame()->isCrossOriginSubframe()) {
(...skipping 30 matching lines...) Expand all
6369 } 6395 }
6370 6396
6371 void showLiveDocumentInstances() { 6397 void showLiveDocumentInstances() {
6372 WeakDocumentSet& set = liveDocumentSet(); 6398 WeakDocumentSet& set = liveDocumentSet();
6373 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6399 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6374 for (Document* document : set) 6400 for (Document* document : set)
6375 fprintf(stderr, "- Document %p URL: %s\n", document, 6401 fprintf(stderr, "- Document %p URL: %s\n", document,
6376 document->url().getString().utf8().data()); 6402 document->url().getString().utf8().data());
6377 } 6403 }
6378 #endif 6404 #endif
OLDNEW
« 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