Changeset 199056 in webkit
- Timestamp:
- Apr 5, 2016, 8:04:02 AM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r199055 r199056 1 2016-04-05 Antti Koivisto <antti@apple.com> 2 3 Render tree teardown should be iterative 4 https://bugs.webkit.org/show_bug.cgi?id=156233 5 6 Reviewed by Andreas Kling. 7 8 * dom/ContainerNode.cpp: 9 (WebCore::destroyRenderTreeIfNeeded): 10 (WebCore::ContainerNode::takeAllChildrenFrom): 11 * dom/Document.cpp: 12 (WebCore::Document::destroyRenderTree): 13 * dom/Element.cpp: 14 (WebCore::disconnectPseudoElement): 15 * html/HTMLPlugInImageElement.cpp: 16 (WebCore::HTMLPlugInImageElement::prepareForDocumentSuspension): 17 * mathml/MathMLSelectElement.cpp: 18 (WebCore::MathMLSelectElement::updateSelectedChild): 19 * style/RenderTreeUpdater.cpp: 20 (WebCore::RenderTreeUpdater::updateElementRenderer): 21 (WebCore::RenderTreeUpdater::updateTextRenderer): 22 (WebCore::RenderTreeUpdater::updateBeforeOrAfterPseudoElement): 23 (WebCore::RenderTreeUpdater::tearDownRenderers): 24 25 Tear down render tree using ComposedTreeIterator for traversal. 26 27 (WebCore::RenderTreeUpdater::tearDownRenderer): 28 29 * style/RenderTreeUpdater.h: 30 * style/StyleTreeResolver.cpp: 31 (WebCore::Style::ensurePlaceholderStyle): 32 (WebCore::Style::TreeResolver::styleForElement): 33 (WebCore::Style::resetStyleForNonRenderedDescendants): 34 (WebCore::Style::affectsRenderedSubtree): 35 (WebCore::Style::SelectorFilterPusher::SelectorFilterPusher): Deleted. 36 (WebCore::Style::SelectorFilterPusher::push): Deleted. 37 (WebCore::Style::SelectorFilterPusher::~SelectorFilterPusher): Deleted. 38 39 Unused class. 40 41 (WebCore::Style::detachTextRenderer): Deleted. 42 (WebCore::Style::detachChildren): Deleted. 43 (WebCore::Style::detachShadowRoot): Deleted. 44 (WebCore::Style::detachSlotAssignees): Deleted. 45 (WebCore::Style::detachRenderTree): Deleted. 46 47 Remove the old recursive code. 48 49 * style/StyleTreeResolver.h: 50 1 51 2016-04-05 Antoine Quint <graouts@apple.com> 2 52 -
trunk/Source/WebCore/dom/ContainerNode.cpp
r199003 r199056 50 50 #include "RenderBox.h" 51 51 #include "RenderTheme.h" 52 #include "RenderTreeUpdater.h" 52 53 #include "RenderWidget.h" 53 54 #include "RootInlineBox.h" … … 56 57 #include "SVGNames.h" 57 58 #include "SelectorQuery.h" 58 #include "StyleTreeResolver.h"59 59 #include "TemplateContentDocumentFragment.h" 60 60 #include <algorithm> … … 104 104 return; 105 105 if (is<Element>(child)) 106 Style::detachRenderTree(downcast<Element>(child));106 RenderTreeUpdater::tearDownRenderers(downcast<Element>(child)); 107 107 else if (is<Text>(child)) 108 Style::detachTextRenderer(downcast<Text>(child));108 RenderTreeUpdater::tearDownRenderer(downcast<Text>(child)); 109 109 } 110 110 -
trunk/Source/WebCore/dom/Document.cpp
r199003 r199056 2354 2354 2355 2355 if (m_documentElement) 2356 Style::detachRenderTree(*m_documentElement);2356 RenderTreeUpdater::tearDownRenderers(*m_documentElement); 2357 2357 2358 2358 clearChildNeedsStyleRecalc(); -
trunk/Source/WebCore/dom/Element.cpp
r199003 r199056 76 76 #include "RenderRegion.h" 77 77 #include "RenderTheme.h" 78 #include "RenderTreeUpdater.h" 78 79 #include "RenderView.h" 79 80 #include "RenderWidget.h" … … 2704 2705 return; 2705 2706 if (pseudoElement->renderer()) 2706 Style::detachRenderTree(*pseudoElement);2707 RenderTreeUpdater::tearDownRenderers(*pseudoElement); 2707 2708 ASSERT(pseudoElement->hostElement()); 2708 2709 pseudoElement->clearHostElement(); -
trunk/Source/WebCore/html/HTMLPlugInImageElement.cpp
r197794 r199056 44 44 #include "RenderImage.h" 45 45 #include "RenderSnapshottedPlugIn.h" 46 #include "RenderTreeUpdater.h" 46 47 #include "SchemeRegistry.h" 47 48 #include "ScriptController.h" … … 323 324 { 324 325 if (renderer()) 325 Style::detachRenderTree(*this);326 RenderTreeUpdater::tearDownRenderers(*this); 326 327 327 328 HTMLPlugInElement::prepareForDocumentSuspension(); -
trunk/Source/WebCore/mathml/MathMLSelectElement.cpp
r194691 r199056 34 34 #include "MathMLNames.h" 35 35 #include "RenderMathMLRow.h" 36 #include "RenderTreeUpdater.h" 36 37 #include "SVGElement.h" 37 38 #include "SVGNames.h" 38 #include "StyleTreeResolver.h"39 39 40 40 namespace WebCore { … … 203 203 204 204 if (m_selectedChild && m_selectedChild->renderer()) 205 Style::detachRenderTree(*m_selectedChild);205 RenderTreeUpdater::tearDownRenderers(*m_selectedChild); 206 206 207 207 m_selectedChild = newSelectedChild; -
trunk/Source/WebCore/style/RenderTreeUpdater.cpp
r199054 r199056 243 243 bool shouldTearDownRenderers = update.change == Style::Detach && (element.renderer() || element.isNamedFlowContentNode()); 244 244 if (shouldTearDownRenderers) 245 detachRenderTree(element, Style::ReattachDetach);245 tearDownRenderers(element, TeardownType::KeepHoverAndActive); 246 246 247 247 bool shouldCreateNewRenderer = !element.renderer() && update.style && !hasImplicitDisplayContents(element); … … 410 410 if (needsRenderer) 411 411 return; 412 Style::detachTextRenderer(text);412 tearDownRenderer(text); 413 413 invalidateWhitespaceOnlyTextSiblingsAfterAttachIfNeeded(text); 414 414 return; … … 507 507 } 508 508 509 } 509 void RenderTreeUpdater::tearDownRenderers(Element& root, TeardownType teardownType) 510 { 511 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; 512 513 Vector<Element*, 30> teardownStack; 514 515 auto push = [&] (Element& element) { 516 if (element.hasCustomStyleResolveCallbacks()) 517 element.willDetachRenderers(); 518 if (teardownType != TeardownType::KeepHoverAndActive) 519 element.clearHoverAndActiveStatusBeforeDetachingRenderer(); 520 element.clearStyleDerivedDataBeforeDetachingRenderer(); 521 522 teardownStack.append(&element); 523 }; 524 525 auto pop = [&] (unsigned depth) { 526 while (teardownStack.size() > depth) { 527 auto& element = *teardownStack.takeLast(); 528 529 if (auto* renderer = element.renderer()) { 530 renderer->destroyAndCleanupAnonymousWrappers(); 531 element.setRenderer(nullptr); 532 } 533 if (element.hasCustomStyleResolveCallbacks()) 534 element.didDetachRenderers(); 535 } 536 }; 537 538 push(root); 539 540 auto descendants = composedTreeDescendants(root); 541 for (auto it = descendants.begin(), end = descendants.end(); it != end; ++it) { 542 pop(it.depth()); 543 544 if (is<Text>(*it)) { 545 tearDownRenderer(downcast<Text>(*it)); 546 continue; 547 } 548 549 push(downcast<Element>(*it)); 550 } 551 552 pop(0); 553 } 554 555 void RenderTreeUpdater::tearDownRenderer(Text& text) 556 { 557 auto* renderer = text.renderer(); 558 if (!renderer) 559 return; 560 renderer->destroyAndCleanupAnonymousWrappers(); 561 text.setRenderer(nullptr); 562 } 563 564 } -
trunk/Source/WebCore/style/RenderTreeUpdater.h
r198943 r199056 51 51 void commit(std::unique_ptr<const Style::Update>); 52 52 53 enum class TeardownType { Normal, KeepHoverAndActive }; 54 static void tearDownRenderers(Element&, TeardownType = TeardownType::Normal); 55 static void tearDownRenderer(Text&); 56 53 57 private: 54 58 void updateRenderTree(ContainerNode& root); -
trunk/Source/WebCore/style/StyleTreeResolver.cpp
r199054 r199056 51 51 namespace Style { 52 52 53 class SelectorFilterPusher {54 public:55 enum PushMode { Push, NoPush };56 SelectorFilterPusher(SelectorFilter& selectorFilter, Element& parent, PushMode pushMode = Push)57 : m_selectorFilter(selectorFilter)58 , m_parent(parent)59 {60 if (pushMode == Push)61 push();62 }63 void push()64 {65 if (m_didPush)66 return;67 m_didPush = true;68 m_selectorFilter.pushParent(&m_parent);69 }70 ~SelectorFilterPusher()71 {72 if (!m_didPush)73 return;74 m_selectorFilter.popParent();75 }76 77 private:78 SelectorFilter& m_selectorFilter;79 Element& m_parent;80 bool m_didPush { false };81 };82 83 84 53 static RenderStyle* placeholderStyle; 85 54 … … 175 144 176 145 return WTFMove(elementStyle.renderStyle); 177 }178 179 void detachTextRenderer(Text& textNode)180 {181 if (textNode.renderer())182 textNode.renderer()->destroyAndCleanupAnonymousWrappers();183 textNode.setRenderer(0);184 146 } 185 147 … … 203 165 } 204 166 } 205 }206 207 static void detachChildren(ContainerNode& current, DetachType detachType)208 {209 for (Node* child = current.firstChild(); child; child = child->nextSibling()) {210 if (is<Text>(*child))211 detachTextRenderer(downcast<Text>(*child));212 else if (is<Element>(*child))213 detachRenderTree(downcast<Element>(*child), detachType);214 }215 current.clearChildNeedsStyleRecalc();216 }217 218 static void detachShadowRoot(ShadowRoot& shadowRoot, DetachType detachType)219 {220 detachChildren(shadowRoot, detachType);221 }222 223 #if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)224 static void detachSlotAssignees(HTMLSlotElement& slot, DetachType detachType)225 {226 ASSERT(!slot.renderer());227 if (auto* assignedNodes = slot.assignedNodes()) {228 for (auto* child : *assignedNodes) {229 if (is<Text>(*child))230 detachTextRenderer(downcast<Text>(*child));231 else if (is<Element>(*child))232 detachRenderTree(downcast<Element>(*child), detachType);233 }234 } else235 detachChildren(slot, detachType);236 237 slot.clearNeedsStyleRecalc();238 slot.clearChildNeedsStyleRecalc();239 }240 #endif241 242 void detachRenderTree(Element& current, DetachType detachType)243 {244 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;245 246 if (current.hasCustomStyleResolveCallbacks())247 current.willDetachRenderers();248 249 current.clearStyleDerivedDataBeforeDetachingRenderer();250 251 // Do not remove the element's hovered and active status252 // if performing a reattach.253 if (detachType != ReattachDetach)254 current.clearHoverAndActiveStatusBeforeDetachingRenderer();255 256 #if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)257 if (is<HTMLSlotElement>(current))258 detachSlotAssignees(downcast<HTMLSlotElement>(current), detachType);259 #endif260 else if (ShadowRoot* shadowRoot = current.shadowRoot())261 detachShadowRoot(*shadowRoot, detachType);262 263 detachChildren(current, detachType);264 265 if (current.renderer())266 current.renderer()->destroyAndCleanupAnonymousWrappers();267 current.setRenderer(nullptr);268 269 if (current.hasCustomStyleResolveCallbacks())270 current.didDetachRenderers();271 167 } 272 168 -
trunk/Source/WebCore/style/StyleTreeResolver.h
r199054 r199056 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 109 109 }; 110 110 111 enum DetachType { NormalDetach, ReattachDetach };112 void detachRenderTree(Element&, DetachType = NormalDetach);113 void detachTextRenderer(Text&);114 115 111 void queuePostResolutionCallback(std::function<void ()>); 116 112 bool postResolutionCallbacksAreSuspended();
Note:
See TracChangeset
for help on using the changeset viewer.