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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2845583002: Remove FrameViewBase as base class of RemoteFrameView. (Closed)
Patch Set: merge 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 237
238 DEFINE_TRACE(FrameView) { 238 DEFINE_TRACE(FrameView) {
239 visitor->Trace(frame_); 239 visitor->Trace(frame_);
240 visitor->Trace(parent_); 240 visitor->Trace(parent_);
241 visitor->Trace(fragment_anchor_); 241 visitor->Trace(fragment_anchor_);
242 visitor->Trace(scrollable_areas_); 242 visitor->Trace(scrollable_areas_);
243 visitor->Trace(animating_scrollable_areas_); 243 visitor->Trace(animating_scrollable_areas_);
244 visitor->Trace(auto_size_info_); 244 visitor->Trace(auto_size_info_);
245 visitor->Trace(children_); 245 visitor->Trace(children_);
246 visitor->Trace(plugins_);
247 visitor->Trace(scrollbars_); 246 visitor->Trace(scrollbars_);
248 visitor->Trace(viewport_scrollable_area_); 247 visitor->Trace(viewport_scrollable_area_);
249 visitor->Trace(visibility_observer_); 248 visitor->Trace(visibility_observer_);
250 visitor->Trace(scroll_anchor_); 249 visitor->Trace(scroll_anchor_);
251 visitor->Trace(anchoring_adjustment_queue_); 250 visitor->Trace(anchoring_adjustment_queue_);
252 visitor->Trace(scrollbar_manager_); 251 visitor->Trace(scrollbar_manager_);
253 visitor->Trace(print_context_); 252 visitor->Trace(print_context_);
254 FrameViewBase::Trace(visitor);
255 ScrollableArea::Trace(visitor); 253 ScrollableArea::Trace(visitor);
256 } 254 }
257 255
258 void FrameView::Reset() { 256 void FrameView::Reset() {
259 // The compositor throttles the main frame using deferred commits, we can't 257 // The compositor throttles the main frame using deferred commits, we can't
260 // throttle it here or it seems the root compositor doesn't get setup 258 // throttle it here or it seems the root compositor doesn't get setup
261 // properly. 259 // properly.
262 if (RuntimeEnabledFeatures:: 260 if (RuntimeEnabledFeatures::
263 renderingPipelineThrottlingLoadingIframesEnabled()) 261 renderingPipelineThrottlingLoadingIframesEnabled())
264 lifecycle_updates_throttled_ = !GetFrame().IsMainFrame(); 262 lifecycle_updates_throttled_ = !GetFrame().IsMainFrame();
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 // Destroy |m_autoSizeInfo| as early as possible, to avoid dereferencing 371 // Destroy |m_autoSizeInfo| as early as possible, to avoid dereferencing
374 // partially destroyed |this| via |m_autoSizeInfo->m_frameView|. 372 // partially destroyed |this| via |m_autoSizeInfo->m_frameView|.
375 auto_size_info_.Clear(); 373 auto_size_info_.Clear();
376 374
377 post_layout_tasks_timer_.Stop(); 375 post_layout_tasks_timer_.Stop();
378 did_scroll_timer_.Stop(); 376 did_scroll_timer_.Stop();
379 377
380 // FIXME: Do we need to do something here for OOPI? 378 // FIXME: Do we need to do something here for OOPI?
381 HTMLFrameOwnerElement* owner_element = frame_->DeprecatedLocalOwner(); 379 HTMLFrameOwnerElement* owner_element = frame_->DeprecatedLocalOwner();
382 // TODO(dcheng): It seems buggy that we can have an owner element that points 380 // TODO(dcheng): It seems buggy that we can have an owner element that points
383 // to another FrameViewBase. This can happen when a plugin element loads a 381 // to another FrameOrPlugin. This can happen when a plugin element loads a
384 // frame (FrameViewBase A of type FrameView) and then loads a plugin 382 // frame (FrameOrPlugin A of type FrameView) and then loads a plugin
385 // (FrameViewBase B of type WebPluginContainerImpl). In this case, the frame's 383 // (FrameOrPlugin B of type WebPluginContainerImpl). In this case, the frame's
386 // view is A and the frame element's owned FrameViewBase is B. See 384 // view is A and the frame element's OwnedWidget is B. See
387 // https://crbug.com/673170 for an example. 385 // https://crbug.com/673170 for an example.
388 if (owner_element && owner_element->OwnedWidget() == this) 386 if (owner_element && owner_element->OwnedWidget() == this)
389 owner_element->SetWidget(nullptr); 387 owner_element->SetWidget(nullptr);
390 388
391 ClearPrintContext(); 389 ClearPrintContext();
392 390
393 #if DCHECK_IS_ON() 391 #if DCHECK_IS_ON()
394 has_been_disposed_ = true; 392 has_been_disposed_ = true;
395 #endif 393 #endif
396 } 394 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 UpdateScrollbarGeometry(); 495 UpdateScrollbarGeometry();
498 UpdateScrollCorner(); 496 UpdateScrollCorner();
499 PositionScrollbarLayers(); 497 PositionScrollbarLayers();
500 } 498 }
501 } 499 }
502 500
503 void FrameView::InvalidateAllCustomScrollbarsOnActiveChanged() { 501 void FrameView::InvalidateAllCustomScrollbarsOnActiveChanged() {
504 bool uses_window_inactive_selector = 502 bool uses_window_inactive_selector =
505 frame_->GetDocument()->GetStyleEngine().UsesWindowInactiveSelector(); 503 frame_->GetDocument()->GetStyleEngine().UsesWindowInactiveSelector();
506 504
507 const ChildrenSet* view_children = Children(); 505 for (const auto& child : children_) {
508 for (const Member<FrameViewBase>& child : *view_children) { 506 if (child->IsFrameView())
509 FrameViewBase* frame_view_base = child.Get(); 507 ToFrameView(child)->InvalidateAllCustomScrollbarsOnActiveChanged();
510 if (frame_view_base->IsFrameView()) {
511 ToFrameView(frame_view_base)
512 ->InvalidateAllCustomScrollbarsOnActiveChanged();
513 }
514 } 508 }
515 509
516 for (const Member<Scrollbar>& scrollbar : *Scrollbars()) { 510 for (const auto& scrollbar : scrollbars_) {
517 if (uses_window_inactive_selector && scrollbar->IsCustomScrollbar()) 511 if (uses_window_inactive_selector && scrollbar->IsCustomScrollbar())
518 scrollbar->StyleChanged(); 512 scrollbar->StyleChanged();
519 } 513 }
520 514
521 if (uses_window_inactive_selector) 515 if (uses_window_inactive_selector)
522 RecalculateCustomScrollbarStyle(); 516 RecalculateCustomScrollbarStyle();
523 } 517 }
524 518
525 void FrameView::Clear() { 519 void FrameView::Clear() {
526 Reset(); 520 Reset();
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 if (!in_synchronous_post_layout_) { 1154 if (!in_synchronous_post_layout_) {
1161 in_synchronous_post_layout_ = true; 1155 in_synchronous_post_layout_ = true;
1162 // Calls resumeScheduledEvents() 1156 // Calls resumeScheduledEvents()
1163 PerformPostLayoutTasks(); 1157 PerformPostLayoutTasks();
1164 in_synchronous_post_layout_ = false; 1158 in_synchronous_post_layout_ = false;
1165 } 1159 }
1166 1160
1167 if (!post_layout_tasks_timer_.IsActive() && 1161 if (!post_layout_tasks_timer_.IsActive() &&
1168 (NeedsLayout() || in_synchronous_post_layout_)) { 1162 (NeedsLayout() || in_synchronous_post_layout_)) {
1169 // If we need layout or are already in a synchronous call to 1163 // If we need layout or are already in a synchronous call to
1170 // postLayoutTasks(), defer FrameViewBase updates and event dispatch until 1164 // postLayoutTasks(), defer FrameView updates and event dispatch until
1171 // after we return. postLayoutTasks() can make us need to update again, and 1165 // after we return. postLayoutTasks() can make us need to update again, and
1172 // we can get stuck in a nasty cycle unless we call it through the timer 1166 // we can get stuck in a nasty cycle unless we call it through the timer
1173 // here. 1167 // here.
1174 post_layout_tasks_timer_.StartOneShot(0, BLINK_FROM_HERE); 1168 post_layout_tasks_timer_.StartOneShot(0, BLINK_FROM_HERE);
1175 if (NeedsLayout()) 1169 if (NeedsLayout())
1176 UpdateLayout(); 1170 UpdateLayout();
1177 } 1171 }
1178 } 1172 }
1179 1173
1180 void FrameView::UpdateLayout() { 1174 void FrameView::UpdateLayout() {
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 frame_view->CheckDoesNotNeedLayout(); 1512 frame_view->CheckDoesNotNeedLayout();
1519 } else { 1513 } else {
1520 part->UpdateGeometry(); 1514 part->UpdateGeometry();
1521 } 1515 }
1522 } 1516 }
1523 } 1517 }
1524 } 1518 }
1525 1519
1526 void FrameView::AddPartToUpdate(LayoutEmbeddedObject& object) { 1520 void FrameView::AddPartToUpdate(LayoutEmbeddedObject& object) {
1527 ASSERT(IsInPerformLayout()); 1521 ASSERT(IsInPerformLayout());
1528 // Tell the DOM element that it needs a FrameViewBase update. 1522 // Tell the DOM element that it needs a FrameView update.
dcheng 2017/05/09 07:50:51 This reads a bit confusing. It says FrameView here
joelhockey 2017/05/10 02:35:43 comment updated
1529 Node* node = object.GetNode(); 1523 Node* node = object.GetNode();
1530 ASSERT(node); 1524 ASSERT(node);
1531 if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node)) 1525 if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node))
1532 ToHTMLPlugInElement(node)->SetNeedsPluginUpdate(true); 1526 ToHTMLPlugInElement(node)->SetNeedsPluginUpdate(true);
1533 1527
1534 part_update_set_.insert(&object); 1528 part_update_set_.insert(&object);
1535 } 1529 }
1536 1530
1537 void FrameView::SetDisplayMode(WebDisplayMode mode) { 1531 void FrameView::SetDisplayMode(WebDisplayMode mode) {
1538 if (mode == display_mode_) 1532 if (mode == display_mode_)
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 !constraints_map.at(layer).HasAncestorStickyElement()) { 2042 !constraints_map.at(layer).HasAncestorStickyElement()) {
2049 // TODO(skobes): Resolve circular dependency between scroll offset and 2043 // TODO(skobes): Resolve circular dependency between scroll offset and
2050 // compositing state, and remove this disabler. https://crbug.com/420741 2044 // compositing state, and remove this disabler. https://crbug.com/420741
2051 DisableCompositingQueryAsserts disabler; 2045 DisableCompositingQueryAsserts disabler;
2052 layer->UpdateLayerPositionsAfterOverflowScroll(); 2046 layer->UpdateLayerPositionsAfterOverflowScroll();
2053 layout_object->SetMayNeedPaintInvalidationSubtree(); 2047 layout_object->SetMayNeedPaintInvalidationSubtree();
2054 } 2048 }
2055 } 2049 }
2056 2050
2057 // If there fixed position elements, scrolling may cause compositing layers to 2051 // If there fixed position elements, scrolling may cause compositing layers to
2058 // change. Update FrameViewBase and layer positions after scrolling, but only 2052 // change. Update FrameView and layer positions after scrolling, but only
2059 // if we're not inside of layout. 2053 // if we're not inside of layout.
2060 if (!nested_layout_count_) { 2054 if (!nested_layout_count_) {
2061 UpdateGeometries(); 2055 UpdateGeometries();
2062 LayoutViewItem layout_view_item = this->GetLayoutViewItem(); 2056 LayoutViewItem layout_view_item = this->GetLayoutViewItem();
2063 if (!layout_view_item.IsNull()) 2057 if (!layout_view_item.IsNull())
2064 layout_view_item.Layer()->SetNeedsCompositingInputsUpdate(); 2058 layout_view_item.Layer()->SetNeedsCompositingInputsUpdate();
2065 } 2059 }
2066 } 2060 }
2067 2061
2068 bool FrameView::ComputeCompositedSelection(LocalFrame& frame, 2062 bool FrameView::ComputeCompositedSelection(LocalFrame& frame,
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 } 2470 }
2477 2471
2478 // The fragment anchor should only be maintained while the frame is still 2472 // The fragment anchor should only be maintained while the frame is still
2479 // loading. If the frame is done loading, clear the anchor now. Otherwise, 2473 // loading. If the frame is done loading, clear the anchor now. Otherwise,
2480 // restore it since it may have been cleared during scrollRectToVisible. 2474 // restore it since it may have been cleared during scrollRectToVisible.
2481 fragment_anchor_ = 2475 fragment_anchor_ =
2482 frame_->GetDocument()->IsLoadCompleted() ? nullptr : anchor_node; 2476 frame_->GetDocument()->IsLoadCompleted() ? nullptr : anchor_node;
2483 } 2477 }
2484 2478
2485 bool FrameView::UpdatePlugins() { 2479 bool FrameView::UpdatePlugins() {
2486 // This is always called from updatePluginsTimerFired. 2480 // This is always called from UpdatePluginsTimerFired.
2487 // m_updatePluginsTimer should only be scheduled if we have FrameViewBases to 2481 // update_plugins_timer should only be scheduled if we have FrameViews to
2488 // update. Thus I believe we can stop checking isEmpty here, and just ASSERT 2482 // update. Thus I believe we can stop checking isEmpty here, and just ASSERT
2489 // isEmpty: 2483 // isEmpty:
2490 // FIXME: This assert has been temporarily removed due to 2484 // FIXME: This assert has been temporarily removed due to
2491 // https://crbug.com/430344 2485 // https://crbug.com/430344
2492 if (nested_layout_count_ > 1 || part_update_set_.IsEmpty()) 2486 if (nested_layout_count_ > 1 || part_update_set_.IsEmpty())
2493 return true; 2487 return true;
2494 2488
2495 // Need to swap because script will run inside the below loop and invalidate 2489 // Need to swap because script will run inside the below loop and invalidate
2496 // the iterator. 2490 // the iterator.
2497 EmbeddedObjectSet objects; 2491 EmbeddedObjectSet objects;
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
3393 if (NeedsLayout()) 3387 if (NeedsLayout())
3394 UpdateLayout(); 3388 UpdateLayout();
3395 3389
3396 CheckDoesNotNeedLayout(); 3390 CheckDoesNotNeedLayout();
3397 3391
3398 // WebView plugins need to update regardless of whether the 3392 // WebView plugins need to update regardless of whether the
3399 // LayoutEmbeddedObject that owns them needed layout. 3393 // LayoutEmbeddedObject that owns them needed layout.
3400 // TODO(leviw): This currently runs the entire lifecycle on plugin WebViews. 3394 // TODO(leviw): This currently runs the entire lifecycle on plugin WebViews.
3401 // We should have a way to only run these other Documents to the same 3395 // We should have a way to only run these other Documents to the same
3402 // lifecycle stage as this frame. 3396 // lifecycle stage as this frame.
3403 for (const Member<PluginView>& plugin : *Plugins()) { 3397 for (const auto& child : children_) {
3404 plugin->UpdateAllLifecyclePhases(); 3398 if (child->IsPluginView())
3399 ToPluginView(child)->UpdateAllLifecyclePhases();
3405 } 3400 }
3406 CheckDoesNotNeedLayout(); 3401 CheckDoesNotNeedLayout();
3407 3402
3408 // FIXME: Calling layout() shouldn't trigger script execution or have any 3403 // FIXME: Calling layout() shouldn't trigger script execution or have any
3409 // observable effects on the frame tree but we're not quite there yet. 3404 // observable effects on the frame tree but we're not quite there yet.
3410 HeapVector<Member<FrameView>> frame_views; 3405 HeapVector<Member<FrameView>> frame_views;
3411 for (Frame* child = frame_->Tree().FirstChild(); child; 3406 for (Frame* child = frame_->Tree().FirstChild(); child;
3412 child = child->Tree().NextSibling()) { 3407 child = child->Tree().NextSibling()) {
3413 if (!child->IsLocalFrame()) 3408 if (!child->IsLocalFrame())
3414 continue; 3409 continue;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
3646 IntPoint FrameView::ConvertToLayoutItem(const LayoutItem& layout_item, 3641 IntPoint FrameView::ConvertToLayoutItem(const LayoutItem& layout_item,
3647 const IntPoint& frame_point) const { 3642 const IntPoint& frame_point) const {
3648 IntPoint point = frame_point; 3643 IntPoint point = frame_point;
3649 3644
3650 // Convert from FrameView coords into page ("absolute") coordinates. 3645 // Convert from FrameView coords into page ("absolute") coordinates.
3651 point += IntSize(ScrollX(), ScrollY()); 3646 point += IntSize(ScrollX(), ScrollY());
3652 3647
3653 return RoundedIntPoint(layout_item.AbsoluteToLocal(point, kUseTransforms)); 3648 return RoundedIntPoint(layout_item.AbsoluteToLocal(point, kUseTransforms));
3654 } 3649 }
3655 3650
3656 IntPoint FrameView::ConvertSelfToChild(const FrameViewBase* child, 3651 IntPoint FrameView::ConvertSelfToChild(const IntPoint& child_location,
3657 const IntPoint& point) const { 3652 const IntPoint& point) const {
3658 IntPoint new_point = point; 3653 IntPoint new_point = point;
3659 new_point = FrameToContents(point); 3654 new_point = FrameToContents(point);
3660 new_point.MoveBy(-child->Location()); 3655 new_point.MoveBy(-child_location);
3661 return new_point; 3656 return new_point;
3662 } 3657 }
3663 3658
3664 IntRect FrameView::ConvertToContainingFrameViewBase( 3659 IntRect FrameView::ConvertToContainingFrameView(
3665 const IntRect& local_rect) const { 3660 const IntRect& local_rect) const {
3666 if (parent_) { 3661 if (parent_) {
3667 // Get our layoutObject in the parent view 3662 // Get our layoutObject in the parent view
3668 LayoutPartItem layout_item = frame_->OwnerLayoutItem(); 3663 LayoutPartItem layout_item = frame_->OwnerLayoutItem();
3669 if (layout_item.IsNull()) 3664 if (layout_item.IsNull())
3670 return local_rect; 3665 return local_rect;
3671 3666
3672 IntRect rect(local_rect); 3667 IntRect rect(local_rect);
3673 // Add borders and padding?? 3668 // Add borders and padding??
3674 rect.Move((layout_item.BorderLeft() + layout_item.PaddingLeft()).ToInt(), 3669 rect.Move((layout_item.BorderLeft() + layout_item.PaddingLeft()).ToInt(),
3675 (layout_item.BorderTop() + layout_item.PaddingTop()).ToInt()); 3670 (layout_item.BorderTop() + layout_item.PaddingTop()).ToInt());
3676 return parent_->ConvertFromLayoutItem(layout_item, rect); 3671 return parent_->ConvertFromLayoutItem(layout_item, rect);
3677 } 3672 }
3678 3673
3679 return local_rect; 3674 return local_rect;
3680 } 3675 }
3681 3676
3682 IntRect FrameView::ConvertFromContainingFrameViewBase( 3677 IntRect FrameView::ConvertFromContainingFrameView(
3683 const IntRect& parent_rect) const { 3678 const IntRect& parent_rect) const {
3684 if (parent_) { 3679 if (parent_) {
3685 IntRect local_rect = parent_rect; 3680 IntRect local_rect = parent_rect;
3686 local_rect.SetLocation( 3681 local_rect.SetLocation(
3687 parent_->ConvertSelfToChild(this, local_rect.Location())); 3682 parent_->ConvertSelfToChild(Location(), local_rect.Location()));
3688 return local_rect; 3683 return local_rect;
3689 } 3684 }
3690 3685
3691 return parent_rect; 3686 return parent_rect;
3692 } 3687 }
3693 3688
3694 IntPoint FrameView::ConvertToContainingFrameViewBase( 3689 IntPoint FrameView::ConvertToContainingFrameView(
3695 const IntPoint& local_point) const { 3690 const IntPoint& local_point) const {
3696 if (parent_) { 3691 if (parent_) {
3697 // Get our layoutObject in the parent view 3692 // Get our layoutObject in the parent view
3698 LayoutPartItem layout_item = frame_->OwnerLayoutItem(); 3693 LayoutPartItem layout_item = frame_->OwnerLayoutItem();
3699 if (layout_item.IsNull()) 3694 if (layout_item.IsNull())
3700 return local_point; 3695 return local_point;
3701 3696
3702 IntPoint point(local_point); 3697 IntPoint point(local_point);
3703 3698
3704 // Add borders and padding 3699 // Add borders and padding
3705 point.Move((layout_item.BorderLeft() + layout_item.PaddingLeft()).ToInt(), 3700 point.Move((layout_item.BorderLeft() + layout_item.PaddingLeft()).ToInt(),
3706 (layout_item.BorderTop() + layout_item.PaddingTop()).ToInt()); 3701 (layout_item.BorderTop() + layout_item.PaddingTop()).ToInt());
3707 return parent_->ConvertFromLayoutItem(layout_item, point); 3702 return parent_->ConvertFromLayoutItem(layout_item, point);
3708 } 3703 }
3709 3704
3710 return local_point; 3705 return local_point;
3711 } 3706 }
3712 3707
3713 IntPoint FrameView::ConvertFromContainingFrameViewBase( 3708 IntPoint FrameView::ConvertFromContainingFrameView(
3714 const IntPoint& parent_point) const { 3709 const IntPoint& parent_point) const {
3715 if (parent_) { 3710 if (parent_) {
3716 // Get our layoutObject in the parent view 3711 // Get our layoutObject in the parent view
3717 LayoutPartItem layout_item = frame_->OwnerLayoutItem(); 3712 LayoutPartItem layout_item = frame_->OwnerLayoutItem();
3718 if (layout_item.IsNull()) 3713 if (layout_item.IsNull())
3719 return parent_point; 3714 return parent_point;
3720 3715
3721 IntPoint point = parent_->ConvertToLayoutItem(layout_item, parent_point); 3716 IntPoint point = parent_->ConvertToLayoutItem(layout_item, parent_point);
3722 // Subtract borders and padding 3717 // Subtract borders and padding
3723 point.Move((-layout_item.BorderLeft() - layout_item.PaddingLeft()).ToInt(), 3718 point.Move((-layout_item.BorderLeft() - layout_item.PaddingLeft()).ToInt(),
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
3841 animating_scrollable_areas_ = new ScrollableAreaSet; 3836 animating_scrollable_areas_ = new ScrollableAreaSet;
3842 animating_scrollable_areas_->insert(scrollable_area); 3837 animating_scrollable_areas_->insert(scrollable_area);
3843 } 3838 }
3844 3839
3845 void FrameView::RemoveAnimatingScrollableArea(ScrollableArea* scrollable_area) { 3840 void FrameView::RemoveAnimatingScrollableArea(ScrollableArea* scrollable_area) {
3846 if (!animating_scrollable_areas_) 3841 if (!animating_scrollable_areas_)
3847 return; 3842 return;
3848 animating_scrollable_areas_->erase(scrollable_area); 3843 animating_scrollable_areas_->erase(scrollable_area);
3849 } 3844 }
3850 3845
3851 void FrameView::SetParent(FrameViewBase* parent_frame_view_base) { 3846 FrameView* FrameView::Root() const {
3852 FrameView* parent = ToFrameView(parent_frame_view_base); 3847 const FrameView* top = this;
3848 while (top->Parent())
3849 top = top->Parent();
3850 return const_cast<FrameView*>(top);
3851 }
3852
3853 void FrameView::SetParent(FrameView* parent) {
3853 if (parent == parent_) 3854 if (parent == parent_)
3854 return; 3855 return;
3855 3856
3856 DCHECK(!parent || !parent_); 3857 DCHECK(!parent || !parent_);
3857 if (!parent || !parent->IsVisible()) 3858 if (!parent || !parent->IsVisible())
3858 SetParentVisible(false); 3859 SetParentVisible(false);
3859 parent_ = parent; 3860 parent_ = parent;
3860 if (parent && parent->IsVisible()) 3861 if (parent && parent->IsVisible())
3861 SetParentVisible(true); 3862 SetParentVisible(true);
3862 3863
3863 UpdateParentScrollableAreaSet(); 3864 UpdateParentScrollableAreaSet();
3864 SetupRenderThrottling(); 3865 SetupRenderThrottling();
3865 3866
3866 if (ParentFrameView()) 3867 if (ParentFrameView())
3867 subtree_throttled_ = ParentFrameView()->CanThrottleRendering(); 3868 subtree_throttled_ = ParentFrameView()->CanThrottleRendering();
3868 } 3869 }
3869 3870
3870 void FrameView::RemoveChild(FrameViewBase* child) { 3871 void FrameView::AddChild(FrameOrPlugin* child) {
3872 DCHECK(child != this && !child->Parent());
3873 child->SetParent(this);
3874 children_.insert(child);
3875 }
3876
3877 void FrameView::RemoveChild(FrameOrPlugin* child) {
3871 DCHECK(child->Parent() == this); 3878 DCHECK(child->Parent() == this);
3872 3879
3873 if (child->IsFrameView() && 3880 if (child->IsFrameView() &&
3874 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 3881 !RuntimeEnabledFeatures::rootLayerScrollingEnabled())
3875 RemoveScrollableArea(ToFrameView(child)); 3882 RemoveScrollableArea(ToFrameView(child));
3876 3883
3877 child->SetParent(nullptr); 3884 child->SetParent(nullptr);
3878 children_.erase(child); 3885 children_.erase(child);
3879 } 3886 }
3880 3887
3881 void FrameView::RemovePlugin(PluginView* plugin) {
3882 DCHECK(plugin->Parent() == this);
3883 DCHECK(plugins_.Contains(plugin));
3884 plugin->SetParent(nullptr);
3885 plugins_.erase(plugin);
3886 }
3887
3888 void FrameView::AddPlugin(PluginView* plugin) {
3889 DCHECK(!plugin->Parent());
3890 DCHECK(!plugins_.Contains(plugin));
3891 plugin->SetParent(this);
3892 plugins_.insert(plugin);
3893 }
3894
3895 void FrameView::RemoveScrollbar(Scrollbar* scrollbar) { 3888 void FrameView::RemoveScrollbar(Scrollbar* scrollbar) {
3896 DCHECK(scrollbars_.Contains(scrollbar)); 3889 DCHECK(scrollbars_.Contains(scrollbar));
3897 scrollbar->SetParent(nullptr); 3890 scrollbar->SetParent(nullptr);
3898 scrollbars_.erase(scrollbar); 3891 scrollbars_.erase(scrollbar);
3899 } 3892 }
3900 3893
3901 void FrameView::AddScrollbar(Scrollbar* scrollbar) { 3894 void FrameView::AddScrollbar(Scrollbar* scrollbar) {
3902 DCHECK(!scrollbars_.Contains(scrollbar)); 3895 DCHECK(!scrollbars_.Contains(scrollbar));
3903 scrollbar->SetParent(this); 3896 scrollbar->SetParent(this);
3904 scrollbars_.insert(scrollbar); 3897 scrollbars_.insert(scrollbar);
(...skipping 28 matching lines...) Expand all
3933 page->GetChromeClient().SetCursor(cursor, frame_); 3926 page->GetChromeClient().SetCursor(cursor, frame_);
3934 } 3927 }
3935 3928
3936 void FrameView::FrameRectsChanged() { 3929 void FrameView::FrameRectsChanged() {
3937 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); 3930 TRACE_EVENT0("blink", "FrameView::frameRectsChanged");
3938 if (LayoutSizeFixedToFrameSize()) 3931 if (LayoutSizeFixedToFrameSize())
3939 SetLayoutSizeInternal(FrameRect().Size()); 3932 SetLayoutSizeInternal(FrameRect().Size());
3940 3933
3941 for (const auto& child : children_) 3934 for (const auto& child : children_)
3942 child->FrameRectsChanged(); 3935 child->FrameRectsChanged();
3943
3944 for (const auto& plugin : plugins_)
3945 plugin->FrameRectsChanged();
3946 } 3936 }
3947 3937
3948 void FrameView::SetLayoutSizeInternal(const IntSize& size) { 3938 void FrameView::SetLayoutSizeInternal(const IntSize& size) {
3949 if (layout_size_ == size) 3939 if (layout_size_ == size)
3950 return; 3940 return;
3951 3941
3952 layout_size_ = size; 3942 layout_size_ = size;
3953 ContentsResized(); 3943 ContentsResized();
3954 } 3944 }
3955 3945
(...skipping 29 matching lines...) Expand all
3985 TopDocumentRootScrollerController& controller = 3975 TopDocumentRootScrollerController& controller =
3986 page->GlobalRootScrollerController(); 3976 page->GlobalRootScrollerController();
3987 if (layout_viewport == controller.RootScrollerArea()) 3977 if (layout_viewport == controller.RootScrollerArea())
3988 visible_size = controller.RootScrollerVisibleArea(); 3978 visible_size = controller.RootScrollerVisibleArea();
3989 3979
3990 IntSize maximum_offset = 3980 IntSize maximum_offset =
3991 ToIntSize(-ScrollOrigin() + (content_bounds - visible_size)); 3981 ToIntSize(-ScrollOrigin() + (content_bounds - visible_size));
3992 return maximum_offset.ExpandedTo(MinimumScrollOffsetInt()); 3982 return maximum_offset.ExpandedTo(MinimumScrollOffsetInt());
3993 } 3983 }
3994 3984
3995 void FrameView::AddChild(FrameViewBase* child) {
3996 DCHECK(child != this && !child->Parent());
3997 child->SetParent(this);
3998 children_.insert(child);
3999 }
4000
4001 void FrameView::SetScrollbarModes(ScrollbarMode horizontal_mode, 3985 void FrameView::SetScrollbarModes(ScrollbarMode horizontal_mode,
4002 ScrollbarMode vertical_mode, 3986 ScrollbarMode vertical_mode,
4003 bool horizontal_lock, 3987 bool horizontal_lock,
4004 bool vertical_lock) { 3988 bool vertical_lock) {
4005 bool needs_update = false; 3989 bool needs_update = false;
4006 3990
4007 // If the page's overflow setting has disabled scrolling, do not allow 3991 // If the page's overflow setting has disabled scrolling, do not allow
4008 // anything to override that setting, http://crbug.com/426447 3992 // anything to override that setting, http://crbug.com/426447
4009 LayoutObject* viewport = ViewportLayoutObject(); 3993 LayoutObject* viewport = ViewportLayoutObject();
4010 if (viewport && !ShouldIgnoreOverflowHidden()) { 3994 if (viewport && !ShouldIgnoreOverflowHidden()) {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
4439 4423
4440 if (!ScrollContentsFastPath(-scroll_delta)) 4424 if (!ScrollContentsFastPath(-scroll_delta))
4441 ScrollContentsSlowPath(); 4425 ScrollContentsSlowPath();
4442 4426
4443 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && 4427 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
4444 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 4428 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
4445 // Need to update scroll translation property. 4429 // Need to update scroll translation property.
4446 SetNeedsPaintPropertyUpdate(); 4430 SetNeedsPaintPropertyUpdate();
4447 } 4431 }
4448 4432
4449 // This call will move children with native FrameViewBases (plugins) and 4433 // This call will move children with native FrameViews (plugins) and
4450 // invalidate them as well. 4434 // invalidate them as well.
4451 FrameRectsChanged(); 4435 FrameRectsChanged();
4452 } 4436 }
4453 4437
4454 IntPoint FrameView::ContentsToFrame( 4438 IntPoint FrameView::ContentsToFrame(
4455 const IntPoint& point_in_content_space) const { 4439 const IntPoint& point_in_content_space) const {
4456 return point_in_content_space - ScrollOffsetInt(); 4440 return point_in_content_space - ScrollOffsetInt();
4457 } 4441 }
4458 4442
4459 IntRect FrameView::ContentsToFrame(const IntRect& rect_in_content_space) const { 4443 IntRect FrameView::ContentsToFrame(const IntRect& rect_in_content_space) const {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
4741 } 4725 }
4742 4726
4743 bool FrameView::ScrollbarCornerPresent() const { 4727 bool FrameView::ScrollbarCornerPresent() const {
4744 return (HorizontalScrollbar() && 4728 return (HorizontalScrollbar() &&
4745 Width() - HorizontalScrollbar()->Width() > 0) || 4729 Width() - HorizontalScrollbar()->Width() > 0) ||
4746 (VerticalScrollbar() && Height() - VerticalScrollbar()->Height() > 0); 4730 (VerticalScrollbar() && Height() - VerticalScrollbar()->Height() > 0);
4747 } 4731 }
4748 4732
4749 IntRect FrameView::ConvertToRootFrame(const IntRect& local_rect) const { 4733 IntRect FrameView::ConvertToRootFrame(const IntRect& local_rect) const {
4750 if (parent_) { 4734 if (parent_) {
4751 IntRect parent_rect = ConvertToContainingFrameViewBase(local_rect); 4735 IntRect parent_rect = ConvertToContainingFrameView(local_rect);
4752 return parent_->ConvertToRootFrame(parent_rect); 4736 return parent_->ConvertToRootFrame(parent_rect);
4753 } 4737 }
4754 return local_rect; 4738 return local_rect;
4755 } 4739 }
4756 4740
4757 IntPoint FrameView::ConvertToRootFrame(const IntPoint& local_point) const { 4741 IntPoint FrameView::ConvertToRootFrame(const IntPoint& local_point) const {
4758 if (parent_) { 4742 if (parent_) {
4759 IntPoint parent_point = ConvertToContainingFrameViewBase(local_point); 4743 IntPoint parent_point = ConvertToContainingFrameView(local_point);
4760 return parent_->ConvertToRootFrame(parent_point); 4744 return parent_->ConvertToRootFrame(parent_point);
4761 } 4745 }
4762 return local_point; 4746 return local_point;
4763 } 4747 }
4764 4748
4765 IntPoint FrameView::ConvertFromContainingFrameViewBaseToScrollbar( 4749 IntPoint FrameView::ConvertFromContainingFrameViewToScrollbar(
4766 const Scrollbar& scrollbar, 4750 const Scrollbar& scrollbar,
4767 const IntPoint& parent_point) const { 4751 const IntPoint& parent_point) const {
4768 IntPoint new_point = parent_point; 4752 IntPoint new_point = parent_point;
4769 // Scrollbars won't be transformed within us 4753 // Scrollbars won't be transformed within us
4770 new_point.MoveBy(-scrollbar.Location()); 4754 new_point.MoveBy(-scrollbar.Location());
4771 return new_point; 4755 return new_point;
4772 } 4756 }
4773 4757
4774 static void SetNeedsCompositingUpdate(LayoutViewItem layout_view_item, 4758 static void SetNeedsCompositingUpdate(LayoutViewItem layout_view_item,
4775 CompositingUpdateType update_type) { 4759 CompositingUpdateType update_type) {
(...skipping 10 matching lines...) Expand all
4786 // and potentially child frame views. 4770 // and potentially child frame views.
4787 SetNeedsCompositingUpdate(GetLayoutViewItem(), kCompositingUpdateRebuildTree); 4771 SetNeedsCompositingUpdate(GetLayoutViewItem(), kCompositingUpdateRebuildTree);
4788 4772
4789 parent_visible_ = visible; 4773 parent_visible_ = visible;
4790 4774
4791 if (!IsSelfVisible()) 4775 if (!IsSelfVisible())
4792 return; 4776 return;
4793 4777
4794 for (const auto& child : children_) 4778 for (const auto& child : children_)
4795 child->SetParentVisible(visible); 4779 child->SetParentVisible(visible);
4796
4797 for (const auto& plugin : plugins_)
4798 plugin->SetParentVisible(visible);
4799 } 4780 }
4800 4781
4801 void FrameView::Show() { 4782 void FrameView::Show() {
4802 if (!IsSelfVisible()) { 4783 if (!IsSelfVisible()) {
4803 SetSelfVisible(true); 4784 SetSelfVisible(true);
4804 if (ScrollingCoordinator* scrolling_coordinator = 4785 if (ScrollingCoordinator* scrolling_coordinator =
4805 this->GetScrollingCoordinator()) 4786 this->GetScrollingCoordinator())
4806 scrolling_coordinator->FrameViewVisibilityDidChange(); 4787 scrolling_coordinator->FrameViewVisibilityDidChange();
4807 SetNeedsCompositingUpdate(GetLayoutViewItem(), 4788 SetNeedsCompositingUpdate(GetLayoutViewItem(),
4808 kCompositingUpdateRebuildTree); 4789 kCompositingUpdateRebuildTree);
4809 UpdateParentScrollableAreaSet(); 4790 UpdateParentScrollableAreaSet();
4810 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && 4791 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
4811 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 4792 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
4812 // The existance of scrolling properties depends on visibility through 4793 // The existance of scrolling properties depends on visibility through
4813 // isScrollable() so ensure properties are updated if visibility changes. 4794 // isScrollable() so ensure properties are updated if visibility changes.
4814 SetNeedsPaintPropertyUpdate(); 4795 SetNeedsPaintPropertyUpdate();
4815 } 4796 }
4816 if (IsParentVisible()) { 4797 if (IsParentVisible()) {
4817 for (const auto& child : children_) 4798 for (const auto& child : children_)
4818 child->SetParentVisible(true); 4799 child->SetParentVisible(true);
4819
4820 for (const auto& plugin : plugins_)
4821 plugin->SetParentVisible(true);
4822 } 4800 }
4823 } 4801 }
4824 } 4802 }
4825 4803
4826 void FrameView::Hide() { 4804 void FrameView::Hide() {
4827 if (IsSelfVisible()) { 4805 if (IsSelfVisible()) {
4828 if (IsParentVisible()) { 4806 if (IsParentVisible()) {
4829 for (const auto& child : children_) 4807 for (const auto& child : children_)
4830 child->SetParentVisible(false); 4808 child->SetParentVisible(false);
4831
4832 for (const auto& plugin : plugins_)
4833 plugin->SetParentVisible(false);
4834 } 4809 }
4835 SetSelfVisible(false); 4810 SetSelfVisible(false);
4836 if (ScrollingCoordinator* scrolling_coordinator = 4811 if (ScrollingCoordinator* scrolling_coordinator =
4837 this->GetScrollingCoordinator()) 4812 this->GetScrollingCoordinator())
4838 scrolling_coordinator->FrameViewVisibilityDidChange(); 4813 scrolling_coordinator->FrameViewVisibilityDidChange();
4839 SetNeedsCompositingUpdate(GetLayoutViewItem(), 4814 SetNeedsCompositingUpdate(GetLayoutViewItem(),
4840 kCompositingUpdateRebuildTree); 4815 kCompositingUpdateRebuildTree);
4841 UpdateParentScrollableAreaSet(); 4816 UpdateParentScrollableAreaSet();
4842 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && 4817 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
4843 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 4818 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4890 return; 4865 return;
4891 4866
4892 layout_object.AddAnnotatedRegions(regions); 4867 layout_object.AddAnnotatedRegions(regions);
4893 for (LayoutObject* curr = layout_object.SlowFirstChild(); curr; 4868 for (LayoutObject* curr = layout_object.SlowFirstChild(); curr;
4894 curr = curr->NextSibling()) 4869 curr = curr->NextSibling())
4895 CollectAnnotatedRegions(*curr, regions); 4870 CollectAnnotatedRegions(*curr, regions);
4896 } 4871 }
4897 4872
4898 void FrameView::UpdateViewportIntersectionsForSubtree( 4873 void FrameView::UpdateViewportIntersectionsForSubtree(
4899 DocumentLifecycle::LifecycleState target_state) { 4874 DocumentLifecycle::LifecycleState target_state) {
4900 // TODO(dcheng): Since FrameViewBase tree updates are deferred, FrameViews 4875 // TODO(dcheng): Since FrameView tree updates are deferred, FrameViews
4901 // might still be in the FrameViewBase hierarchy even though the associated 4876 // might still be in the FrameView hierarchy even though the associated
4902 // Document is already detached. Investigate if this check and a similar check 4877 // Document is already detached. Investigate if this check and a similar check
4903 // in lifecycle updates are still needed when there are no more deferred 4878 // in lifecycle updates are still needed when there are no more deferred
4904 // FrameViewBase updates: https://crbug.com/561683 4879 // FrameView updates: https://crbug.com/561683
4905 if (!GetFrame().GetDocument()->IsActive()) 4880 if (!GetFrame().GetDocument()->IsActive())
4906 return; 4881 return;
4907 4882
4908 if (target_state == DocumentLifecycle::kPaintClean) { 4883 if (target_state == DocumentLifecycle::kPaintClean) {
4909 RecordDeferredLoadingStats(); 4884 RecordDeferredLoadingStats();
4910 // Notify javascript IntersectionObservers 4885 // Notify javascript IntersectionObservers
4911 if (GetFrame().GetDocument()->GetIntersectionObserverController()) { 4886 if (GetFrame().GetDocument()->GetIntersectionObserverController()) {
4912 GetFrame() 4887 GetFrame()
4913 .GetDocument() 4888 .GetDocument()
4914 ->GetIntersectionObserverController() 4889 ->GetIntersectionObserverController()
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4970 4945
4971 // If this FrameView became unthrottled or throttled, we must make sure all 4946 // If this FrameView became unthrottled or throttled, we must make sure all
4972 // its children are notified synchronously. Otherwise we 1) might attempt to 4947 // its children are notified synchronously. Otherwise we 1) might attempt to
4973 // paint one of the children with an out-of-date layout before 4948 // paint one of the children with an out-of-date layout before
4974 // |updateRenderThrottlingStatus| has made it throttled or 2) fail to 4949 // |updateRenderThrottlingStatus| has made it throttled or 2) fail to
4975 // unthrottle a child whose parent is unthrottled by a later notification. 4950 // unthrottle a child whose parent is unthrottled by a later notification.
4976 if (notify_children_behavior == kNotifyChildren && 4951 if (notify_children_behavior == kNotifyChildren &&
4977 (was_throttled != is_throttled || 4952 (was_throttled != is_throttled ||
4978 force_throttling_invalidation_behavior == 4953 force_throttling_invalidation_behavior ==
4979 kForceThrottlingInvalidation)) { 4954 kForceThrottlingInvalidation)) {
4980 for (const Member<FrameViewBase>& child : *Children()) { 4955 for (const auto& child : children_) {
4981 if (child->IsFrameView()) { 4956 if (child->IsFrameView()) {
4982 FrameView* child_view = ToFrameView(child); 4957 ToFrameView(child)->UpdateRenderThrottlingStatus(
4983 child_view->UpdateRenderThrottlingStatus( 4958 ToFrameView(child)->hidden_for_throttling_, is_throttled);
4984 child_view->hidden_for_throttling_, is_throttled);
4985 } 4959 }
4986 } 4960 }
4987 } 4961 }
4988 4962
4989 ScrollingCoordinator* scrolling_coordinator = this->GetScrollingCoordinator(); 4963 ScrollingCoordinator* scrolling_coordinator = this->GetScrollingCoordinator();
4990 if (became_unthrottled || 4964 if (became_unthrottled ||
4991 force_throttling_invalidation_behavior == kForceThrottlingInvalidation) { 4965 force_throttling_invalidation_behavior == kForceThrottlingInvalidation) {
4992 // ScrollingCoordinator needs to update according to the new throttling 4966 // ScrollingCoordinator needs to update according to the new throttling
4993 // status. 4967 // status.
4994 if (scrolling_coordinator) 4968 if (scrolling_coordinator)
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
5386 void FrameView::SetAnimationHost( 5360 void FrameView::SetAnimationHost(
5387 std::unique_ptr<CompositorAnimationHost> host) { 5361 std::unique_ptr<CompositorAnimationHost> host) {
5388 animation_host_ = std::move(host); 5362 animation_host_ = std::move(host);
5389 } 5363 }
5390 5364
5391 LayoutUnit FrameView::CaretWidth() const { 5365 LayoutUnit FrameView::CaretWidth() const {
5392 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5366 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5393 } 5367 }
5394 5368
5395 } // namespace blink 5369 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698