Chromium Code Reviews| 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..22b43b63a054e374565f133c1ab1880f07fc6530 100644 |
| --- a/third_party/WebKit/Source/core/dom/Document.cpp |
| +++ b/third_party/WebKit/Source/core/dom/Document.cpp |
| @@ -1246,6 +1246,18 @@ 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); |
|
esprehn
2016/10/05 02:17:40
&element
nainar
2016/10/05 03:32:37
Done.
|
| +} |
| + |
| +RefPtr<ComputedStyle> Document::getNonAttachedStyle(Element* element) { |
| + return m_nonAttachedStyle.get(element); |
|
esprehn
2016/10/05 02:17:40
&element
nainar
2016/10/05 03:32:37
Done.
|
| +} |
| + |
| /* |
| * Performs three operations: |
| * 1. Convert control characters to spaces |
| @@ -1917,6 +1929,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 +1942,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 +6342,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); |