Changeset 221596 in webkit
- Timestamp:
- Sep 4, 2017 4:50:04 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r221595 r221596 1 2017-09-03 Darin Adler <darin@apple.com> 2 3 Follow up FrameView::updateLayoutAndStyleIfNeededRecursive changes with related improvements 4 https://bugs.webkit.org/show_bug.cgi?id=176277 5 6 Reviewed by Antti Koivisto. 7 8 * page/FrameView.cpp: 9 (WebCore::FrameView::needsStyleRecalcOrLayout): Deleted. This function was only used 10 by an assertion inside updateLayoutAndStyleIfNeededRecursive, and thus there is no reason 11 for it to be in the header file, or for it to be a public member function. 12 (WebCore::appendRenderedChildren): Deleted. This function was only used inside 13 updateLayoutAndStyleIfNeededRecursive, and it is now packaged in an even better way 14 for efficient use inside that function. 15 (WebCore::FrameView::renderedChildFrameViews): Deleted. This function was only used 16 inside needsStyleRecalcOrLayout, and it's now packaged in a better way inside that function. 17 (WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive): Created a new lambda called 18 nextRendereredDescendant that packages up the process of repeatedly iterating this view 19 and all of its descendants in an easy-to-use way. Replaces both of the functions above. 20 Rewrote to use it; it made the logic clear enough that it was good to get rid of the 21 updateOneFrame lambda, too. Added two separate functions, one that checks for needed 22 style recalculation and a separate one that checked for needed layout. Using those, 23 replaced the old single assertion with two separate assertions. 24 25 * page/FrameView.h: Removed needsStyleRecalcOrLayout, renderedChildFrameViews, and 26 FrameViewList. 27 1 28 2017-09-04 Wenson Hsieh <wenson_hsieh@apple.com> 2 29 -
trunk/Source/WebCore/page/FrameView.cpp
r221423 r221596 3152 3152 } 3153 3153 3154 bool FrameView::needsStyleRecalcOrLayout(bool includeSubframes) const3155 {3156 if (frame().document() && frame().document()->childNeedsStyleRecalc())3157 return true;3158 3159 if (needsLayout())3160 return true;3161 3162 if (!includeSubframes)3163 return false;3164 3165 for (auto& frameView : renderedChildFrameViews()) {3166 if (frameView->needsStyleRecalcOrLayout())3167 return true;3168 }3169 3170 return false;3171 }3172 3173 3154 bool FrameView::needsLayout() const 3174 3155 { … … 4576 4557 } 4577 4558 4578 static void appendRenderedChildren(FrameView& view, Deque<Ref<FrameView>, 16>& deque)4579 {4580 for (Frame* frame = view.frame().tree().firstRenderedChild(); frame; frame = frame->tree().nextRenderedSibling()) {4581 if (frame->view())4582 deque.append(*frame->view());4583 }4584 }4585 4586 // FIXME: Change the one remaining caller of this to use appendRenderedChildren above instead,4587 // and then remove FrameViewList and renderedChildFrameViews.4588 FrameView::FrameViewList FrameView::renderedChildFrameViews() const4589 {4590 FrameViewList childViews;4591 for (Frame* frame = m_frame->tree().firstRenderedChild(); frame; frame = frame->tree().nextRenderedSibling()) {4592 if (frame->view())4593 childViews.append(*frame->view());4594 }4595 4596 return childViews;4597 }4598 4599 4559 void FrameView::updateLayoutAndStyleIfNeededRecursive() 4600 4560 { 4601 // Style updating, render tree ,creation, and layout needs to be done multiple times4561 // Style updating, render tree creation, and layout needs to be done multiple times 4602 4562 // for more than one reason. But one reason is that when an <object> element determines 4603 4563 // what it needs to load a subframe, a second pass is needed. That requires update … … 4612 4572 AnimationUpdateBlock animationUpdateBlock(&frame().animation()); 4613 4573 4614 auto updateOnce = [this] { 4615 auto updateOneFrame = [] (FrameView& view) { 4616 bool didWork = view.frame().document()->updateStyleIfNeeded(); 4617 if (view.needsLayout()) { 4618 view.layout(); 4574 using DescendantsDeque = Deque<Ref<FrameView>, 16>; 4575 auto nextRenderedDescendant = [this] (DescendantsDeque& descendantsDeque) -> RefPtr<FrameView> { 4576 if (descendantsDeque.isEmpty()) 4577 descendantsDeque.append(*this); 4578 else { 4579 // Append renderered children after processing the parent, in case the processing 4580 // affects the set of rendered children. 4581 auto previousView = descendantsDeque.takeFirst(); 4582 for (auto* frame = previousView->frame().tree().firstRenderedChild(); frame; frame = frame->tree().nextRenderedSibling()) { 4583 if (auto* view = frame->view()) 4584 descendantsDeque.append(*view); 4585 } 4586 if (descendantsDeque.isEmpty()) 4587 return nullptr; 4588 } 4589 return descendantsDeque.first().ptr(); 4590 }; 4591 4592 for (unsigned i = 0; i < maxUpdatePasses; ++i) { 4593 bool didWork = false; 4594 DescendantsDeque deque; 4595 while (auto view = nextRenderedDescendant(deque)) { 4596 if (view->frame().document()->updateStyleIfNeeded()) 4597 didWork = true; 4598 if (view->needsLayout()) { 4599 view->layout(); 4619 4600 didWork = true; 4620 4601 } 4621 return didWork; 4622 }; 4623 4624 bool didWork = false; 4625 4626 // Use a copy of the child frame list because it can change while updating. 4627 Deque<Ref<FrameView>, 16> views; 4628 views.append(*this); 4629 while (!views.isEmpty()) { 4630 auto view = views.takeFirst(); 4631 if (updateOneFrame(view.get())) 4632 didWork = true; 4633 appendRenderedChildren(view.get(), views); 4634 } 4635 4636 return didWork; 4602 } 4603 if (!didWork) 4604 break; 4605 } 4606 4607 #if !ASSERT_DISABLED 4608 auto needsStyleRecalc = [&] { 4609 DescendantsDeque deque; 4610 while (auto view = nextRenderedDescendant(deque)) { 4611 auto* document = view->frame().document(); 4612 if (document && document->childNeedsStyleRecalc()) 4613 return true; 4614 } 4615 return false; 4637 4616 }; 4638 4617 4639 for (unsigned i = 0; i < maxUpdatePasses; ++i) { 4640 if (!updateOnce()) 4641 break; 4642 } 4643 4644 // FIXME: Unclear why it's appropriate to skip this assertion for non-main frames. 4645 // The need for this may be obsolete and a leftover from when this fucntion was 4646 // implemented by recursively calling itself. 4647 ASSERT(!frame().isMainFrame() || !needsStyleRecalcOrLayout()); 4618 auto needsLayout = [&] { 4619 DescendantsDeque deque; 4620 while (auto view = nextRenderedDescendant(deque)) { 4621 if (view->needsLayout()) 4622 return true; 4623 } 4624 return false; 4625 }; 4626 #endif 4627 4628 ASSERT(!needsStyleRecalc()); 4629 ASSERT(!needsLayout()); 4648 4630 } 4649 4631 -
trunk/Source/WebCore/page/FrameView.h
r220314 r221596 122 122 WEBCORE_EXPORT void setNeedsLayout(); 123 123 void setViewportConstrainedObjectsNeedLayout(); 124 125 bool needsStyleRecalcOrLayout(bool includeSubframes = true) const;126 124 127 125 bool needsFullRepaint() const { return m_needsFullRepaint; } … … 607 605 const HashSet<Widget*>& widgetsInRenderTree() const { return m_widgetsInRenderTree; } 608 606 609 typedef Vector<Ref<FrameView>, 16> FrameViewList;610 FrameViewList renderedChildFrameViews() const;611 612 607 void addTrackedRepaintRect(const FloatRect&); 613 608
Note: See TracChangeset
for help on using the changeset viewer.