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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2821193003: Store nonAttachedStyle on NodeLayoutData instead of on HashMap in Document. (Closed)
Patch Set: Revert back to rune@'s lgtmed patch Created 3 years, 7 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 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 1426
1427 return body; 1427 return body;
1428 } 1428 }
1429 1429
1430 return documentElement(); 1430 return documentElement();
1431 } 1431 }
1432 1432
1433 return body(); 1433 return body();
1434 } 1434 }
1435 1435
1436 // We use HashMap::set over HashMap::add here as we want to
1437 // replace the ComputedStyle but not the Node if the Node is
1438 // already present.
1439 void Document::AddNonAttachedStyle(const Node& node,
1440 RefPtr<ComputedStyle> computed_style) {
1441 DCHECK(node.IsElementNode() || node.IsTextNode());
1442 non_attached_style_.Set(&node, computed_style);
1443 }
1444
1445 ComputedStyle* Document::GetNonAttachedStyle(const Node& node) const {
1446 return non_attached_style_.at(&node);
1447 }
1448
1449 /* 1436 /*
1450 * Performs three operations: 1437 * Performs three operations:
1451 * 1. Convert control characters to spaces 1438 * 1. Convert control characters to spaces
1452 * 2. Trim leading and trailing spaces 1439 * 2. Trim leading and trailing spaces
1453 * 3. Collapse internal whitespace. 1440 * 3. Collapse internal whitespace.
1454 */ 1441 */
1455 template <typename CharacterType> 1442 template <typename CharacterType>
1456 static inline String CanonicalizedTitle(Document* document, 1443 static inline String CanonicalizedTitle(Document* document,
1457 const String& title) { 1444 const String& title) {
1458 unsigned length = title.length(); 1445 unsigned length = title.length();
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 } 2107 }
2121 if (document_element->NeedsReattachLayoutTree() || 2108 if (document_element->NeedsReattachLayoutTree() ||
2122 document_element->ChildNeedsReattachLayoutTree()) { 2109 document_element->ChildNeedsReattachLayoutTree()) {
2123 TRACE_EVENT0("blink,blink_style", "Document::rebuildLayoutTree"); 2110 TRACE_EVENT0("blink,blink_style", "Document::rebuildLayoutTree");
2124 document_element->RebuildLayoutTree(); 2111 document_element->RebuildLayoutTree();
2125 } 2112 }
2126 } 2113 }
2127 2114
2128 View()->RecalcOverflowAfterStyleChange(); 2115 View()->RecalcOverflowAfterStyleChange();
2129 2116
2130 // Only retain the HashMap for the duration of StyleRecalc and
2131 // LayoutTreeConstruction.
2132 non_attached_style_.clear();
2133 ClearChildNeedsStyleRecalc(); 2117 ClearChildNeedsStyleRecalc();
2134 ClearChildNeedsReattachLayoutTree(); 2118 ClearChildNeedsReattachLayoutTree();
2135 2119
2136 resolver.ClearStyleSharingList(); 2120 resolver.ClearStyleSharingList();
2137 2121
2138 DCHECK(!NeedsStyleRecalc()); 2122 DCHECK(!NeedsStyleRecalc());
2139 DCHECK(!ChildNeedsStyleRecalc()); 2123 DCHECK(!ChildNeedsStyleRecalc());
2140 DCHECK(!NeedsReattachLayoutTree()); 2124 DCHECK(!NeedsReattachLayoutTree());
2141 DCHECK(!ChildNeedsReattachLayoutTree()); 2125 DCHECK(!ChildNeedsReattachLayoutTree());
2142 DCHECK(InStyleRecalc()); 2126 DCHECK(InStyleRecalc());
2143 DCHECK_EQ(GetStyleResolver(), &resolver); 2127 DCHECK_EQ(GetStyleResolver(), &resolver);
2144 DCHECK(non_attached_style_.IsEmpty());
2145 lifecycle_.AdvanceTo(DocumentLifecycle::kStyleClean); 2128 lifecycle_.AdvanceTo(DocumentLifecycle::kStyleClean);
2146 if (should_record_stats) { 2129 if (should_record_stats) {
2147 TRACE_EVENT_END2( 2130 TRACE_EVENT_END2(
2148 "blink,blink_style", "Document::updateStyle", "resolverAccessCount", 2131 "blink,blink_style", "Document::updateStyle", "resolverAccessCount",
2149 GetStyleEngine().StyleForElementCount() - initial_element_count, 2132 GetStyleEngine().StyleForElementCount() - initial_element_count,
2150 "counters", GetStyleEngine().Stats()->ToTracedValue()); 2133 "counters", GetStyleEngine().Stats()->ToTracedValue());
2151 } else { 2134 } else {
2152 TRACE_EVENT_END1( 2135 TRACE_EVENT_END1(
2153 "blink,blink_style", "Document::updateStyle", "resolverAccessCount", 2136 "blink,blink_style", "Document::updateStyle", "resolverAccessCount",
2154 GetStyleEngine().StyleForElementCount() - initial_element_count); 2137 GetStyleEngine().StyleForElementCount() - initial_element_count);
(...skipping 4487 matching lines...) Expand 10 before | Expand all | Expand 10 after
6642 visitor->Trace(user_action_elements_); 6625 visitor->Trace(user_action_elements_);
6643 visitor->Trace(svg_extensions_); 6626 visitor->Trace(svg_extensions_);
6644 visitor->Trace(timeline_); 6627 visitor->Trace(timeline_);
6645 visitor->Trace(compositor_pending_animations_); 6628 visitor->Trace(compositor_pending_animations_);
6646 visitor->Trace(context_document_); 6629 visitor->Trace(context_document_);
6647 visitor->Trace(canvas_font_cache_); 6630 visitor->Trace(canvas_font_cache_);
6648 visitor->Trace(intersection_observer_controller_); 6631 visitor->Trace(intersection_observer_controller_);
6649 visitor->Trace(snap_coordinator_); 6632 visitor->Trace(snap_coordinator_);
6650 visitor->Trace(resize_observer_controller_); 6633 visitor->Trace(resize_observer_controller_);
6651 visitor->Trace(property_registry_); 6634 visitor->Trace(property_registry_);
6652 visitor->Trace(non_attached_style_);
6653 visitor->Trace(network_state_observer_); 6635 visitor->Trace(network_state_observer_);
6654 Supplementable<Document>::Trace(visitor); 6636 Supplementable<Document>::Trace(visitor);
6655 TreeScope::Trace(visitor); 6637 TreeScope::Trace(visitor);
6656 ContainerNode::Trace(visitor); 6638 ContainerNode::Trace(visitor);
6657 ExecutionContext::Trace(visitor); 6639 ExecutionContext::Trace(visitor);
6658 SecurityContext::Trace(visitor); 6640 SecurityContext::Trace(visitor);
6659 SynchronousMutationNotifier::Trace(visitor); 6641 SynchronousMutationNotifier::Trace(visitor);
6660 } 6642 }
6661 6643
6662 void Document::RecordDeferredLoadReason(WouldLoadReason reason) { 6644 void Document::RecordDeferredLoadReason(WouldLoadReason reason) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6701 } 6683 }
6702 6684
6703 void showLiveDocumentInstances() { 6685 void showLiveDocumentInstances() {
6704 WeakDocumentSet& set = liveDocumentSet(); 6686 WeakDocumentSet& set = liveDocumentSet();
6705 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6687 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6706 for (blink::Document* document : set) 6688 for (blink::Document* document : set)
6707 fprintf(stderr, "- Document %p URL: %s\n", document, 6689 fprintf(stderr, "- Document %p URL: %s\n", document,
6708 document->Url().GetString().Utf8().data()); 6690 document->Url().GetString().Utf8().data());
6709 } 6691 }
6710 #endif 6692 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698