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

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

Issue 2845583002: Remove FrameViewBase as base class of RemoteFrameView. (Closed)
Patch Set: ConvertSelfToChild take FrameOrPlugin as arg 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
239 239
240 DEFINE_TRACE(FrameView) { 240 DEFINE_TRACE(FrameView) {
241 visitor->Trace(frame_); 241 visitor->Trace(frame_);
242 visitor->Trace(parent_); 242 visitor->Trace(parent_);
243 visitor->Trace(fragment_anchor_); 243 visitor->Trace(fragment_anchor_);
244 visitor->Trace(scrollable_areas_); 244 visitor->Trace(scrollable_areas_);
245 visitor->Trace(animating_scrollable_areas_); 245 visitor->Trace(animating_scrollable_areas_);
246 visitor->Trace(auto_size_info_); 246 visitor->Trace(auto_size_info_);
247 visitor->Trace(children_); 247 visitor->Trace(children_);
248 visitor->Trace(plugins_);
249 visitor->Trace(scrollbars_); 248 visitor->Trace(scrollbars_);
250 visitor->Trace(viewport_scrollable_area_); 249 visitor->Trace(viewport_scrollable_area_);
251 visitor->Trace(visibility_observer_); 250 visitor->Trace(visibility_observer_);
252 visitor->Trace(scroll_anchor_); 251 visitor->Trace(scroll_anchor_);
253 visitor->Trace(anchoring_adjustment_queue_); 252 visitor->Trace(anchoring_adjustment_queue_);
254 visitor->Trace(scrollbar_manager_); 253 visitor->Trace(scrollbar_manager_);
255 visitor->Trace(print_context_); 254 visitor->Trace(print_context_);
256 FrameViewBase::Trace(visitor);
257 ScrollableArea::Trace(visitor); 255 ScrollableArea::Trace(visitor);
258 } 256 }
259 257
260 void FrameView::Reset() { 258 void FrameView::Reset() {
261 // The compositor throttles the main frame using deferred commits, we can't 259 // The compositor throttles the main frame using deferred commits, we can't
262 // throttle it here or it seems the root compositor doesn't get setup 260 // throttle it here or it seems the root compositor doesn't get setup
263 // properly. 261 // properly.
264 if (RuntimeEnabledFeatures:: 262 if (RuntimeEnabledFeatures::
265 renderingPipelineThrottlingLoadingIframesEnabled()) 263 renderingPipelineThrottlingLoadingIframesEnabled())
266 lifecycle_updates_throttled_ = !GetFrame().IsMainFrame(); 264 lifecycle_updates_throttled_ = !GetFrame().IsMainFrame();
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // Destroy |m_autoSizeInfo| as early as possible, to avoid dereferencing 373 // Destroy |m_autoSizeInfo| as early as possible, to avoid dereferencing
376 // partially destroyed |this| via |m_autoSizeInfo->m_frameView|. 374 // partially destroyed |this| via |m_autoSizeInfo->m_frameView|.
377 auto_size_info_.Clear(); 375 auto_size_info_.Clear();
378 376
379 post_layout_tasks_timer_.Stop(); 377 post_layout_tasks_timer_.Stop();
380 did_scroll_timer_.Stop(); 378 did_scroll_timer_.Stop();
381 379
382 // FIXME: Do we need to do something here for OOPI? 380 // FIXME: Do we need to do something here for OOPI?
383 HTMLFrameOwnerElement* owner_element = frame_->DeprecatedLocalOwner(); 381 HTMLFrameOwnerElement* owner_element = frame_->DeprecatedLocalOwner();
384 // TODO(dcheng): It seems buggy that we can have an owner element that points 382 // TODO(dcheng): It seems buggy that we can have an owner element that points
385 // to another FrameViewBase. This can happen when a plugin element loads a 383 // to another FrameOrPlugin. This can happen when a plugin element loads a
386 // frame (FrameViewBase A of type FrameView) and then loads a plugin 384 // frame (FrameOrPlugin A of type FrameView) and then loads a plugin
387 // (FrameViewBase B of type WebPluginContainerImpl). In this case, the frame's 385 // (FrameOrPlugin B of type WebPluginContainerImpl). In this case, the frame's
388 // view is A and the frame element's owned FrameViewBase is B. See 386 // view is A and the frame element's OwnedWidget is B. See
389 // https://crbug.com/673170 for an example. 387 // https://crbug.com/673170 for an example.
390 if (owner_element && owner_element->OwnedWidget() == this) 388 if (owner_element && owner_element->OwnedWidget() == this)
391 owner_element->SetWidget(nullptr); 389 owner_element->SetWidget(nullptr);
392 390
393 ClearPrintContext(); 391 ClearPrintContext();
394 392
395 #if DCHECK_IS_ON() 393 #if DCHECK_IS_ON()
396 has_been_disposed_ = true; 394 has_been_disposed_ = true;
397 #endif 395 #endif
398 } 396 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 UpdateScrollbarGeometry(); 497 UpdateScrollbarGeometry();
500 UpdateScrollCorner(); 498 UpdateScrollCorner();
501 PositionScrollbarLayers(); 499 PositionScrollbarLayers();
502 } 500 }
503 } 501 }
504 502
505 void FrameView::InvalidateAllCustomScrollbarsOnActiveChanged() { 503 void FrameView::InvalidateAllCustomScrollbarsOnActiveChanged() {
506 bool uses_window_inactive_selector = 504 bool uses_window_inactive_selector =
507 frame_->GetDocument()->GetStyleEngine().UsesWindowInactiveSelector(); 505 frame_->GetDocument()->GetStyleEngine().UsesWindowInactiveSelector();
508 506
509 const ChildrenSet* view_children = Children(); 507 for (const auto& child : children_) {
510 for (const Member<FrameViewBase>& child : *view_children) { 508 if (child->IsFrameView())
511 FrameViewBase* frame_view_base = child.Get(); 509 ToFrameView(child)->InvalidateAllCustomScrollbarsOnActiveChanged();
512 if (frame_view_base->IsFrameView()) {
513 ToFrameView(frame_view_base)
514 ->InvalidateAllCustomScrollbarsOnActiveChanged();
515 }
516 } 510 }
517 511
518 for (const Member<Scrollbar>& scrollbar : *Scrollbars()) { 512 for (const auto& scrollbar : scrollbars_) {
519 if (uses_window_inactive_selector && scrollbar->IsCustomScrollbar()) 513 if (uses_window_inactive_selector && scrollbar->IsCustomScrollbar())
520 scrollbar->StyleChanged(); 514 scrollbar->StyleChanged();
521 } 515 }
522 516
523 if (uses_window_inactive_selector) 517 if (uses_window_inactive_selector)
524 RecalculateCustomScrollbarStyle(); 518 RecalculateCustomScrollbarStyle();
525 } 519 }
526 520
527 void FrameView::Clear() { 521 void FrameView::Clear() {
528 Reset(); 522 Reset();
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 if (!in_synchronous_post_layout_) { 1156 if (!in_synchronous_post_layout_) {
1163 in_synchronous_post_layout_ = true; 1157 in_synchronous_post_layout_ = true;
1164 // Calls resumeScheduledEvents() 1158 // Calls resumeScheduledEvents()
1165 PerformPostLayoutTasks(); 1159 PerformPostLayoutTasks();
1166 in_synchronous_post_layout_ = false; 1160 in_synchronous_post_layout_ = false;
1167 } 1161 }
1168 1162
1169 if (!post_layout_tasks_timer_.IsActive() && 1163 if (!post_layout_tasks_timer_.IsActive() &&
1170 (NeedsLayout() || in_synchronous_post_layout_)) { 1164 (NeedsLayout() || in_synchronous_post_layout_)) {
1171 // If we need layout or are already in a synchronous call to 1165 // If we need layout or are already in a synchronous call to
1172 // postLayoutTasks(), defer FrameViewBase updates and event dispatch until 1166 // postLayoutTasks(), defer FrameView updates and event dispatch until
1173 // after we return. postLayoutTasks() can make us need to update again, and 1167 // after we return. postLayoutTasks() can make us need to update again, and
1174 // we can get stuck in a nasty cycle unless we call it through the timer 1168 // we can get stuck in a nasty cycle unless we call it through the timer
1175 // here. 1169 // here.
1176 post_layout_tasks_timer_.StartOneShot(0, BLINK_FROM_HERE); 1170 post_layout_tasks_timer_.StartOneShot(0, BLINK_FROM_HERE);
1177 if (NeedsLayout()) 1171 if (NeedsLayout())
1178 UpdateLayout(); 1172 UpdateLayout();
1179 } 1173 }
1180 } 1174 }
1181 1175
1182 void FrameView::UpdateLayout() { 1176 void FrameView::UpdateLayout() {
1183 // We should never layout a Document which is not in a LocalFrame. 1177 // We should never layout a Document which is not in a LocalFrame.
1184 DCHECK(frame_); 1178 DCHECK(frame_);
1185 ASSERT(frame_->View() == this); 1179 DCHECK(frame_->View() == this);
1186 DCHECK(frame_->GetPage()); 1180 DCHECK(frame_->GetPage());
1187 1181
1188 ScriptForbiddenScope forbid_script; 1182 ScriptForbiddenScope forbid_script;
1189 1183
1190 if (IsInPerformLayout() || ShouldThrottleRendering() || 1184 if (IsInPerformLayout() || ShouldThrottleRendering() ||
1191 !frame_->GetDocument()->IsActive()) 1185 !frame_->GetDocument()->IsActive())
1192 return; 1186 return;
1193 1187
1194 TRACE_EVENT0("blink,benchmark", "FrameView::layout"); 1188 TRACE_EVENT0("blink,benchmark", "FrameView::layout");
1195 1189
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 frame_view->CheckDoesNotNeedLayout(); 1514 frame_view->CheckDoesNotNeedLayout();
1521 } else { 1515 } else {
1522 part->UpdateGeometry(); 1516 part->UpdateGeometry();
1523 } 1517 }
1524 } 1518 }
1525 } 1519 }
1526 } 1520 }
1527 1521
1528 void FrameView::AddPartToUpdate(LayoutEmbeddedObject& object) { 1522 void FrameView::AddPartToUpdate(LayoutEmbeddedObject& object) {
1529 DCHECK(IsInPerformLayout()); 1523 DCHECK(IsInPerformLayout());
1530 // Tell the DOM element that it needs a FrameViewBase update. 1524 // Tell the DOM element that it needs a Plugin update.
1531 Node* node = object.GetNode(); 1525 Node* node = object.GetNode();
1532 DCHECK(node); 1526 DCHECK(node);
1533 if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node)) 1527 if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node))
1534 ToHTMLPlugInElement(node)->SetNeedsPluginUpdate(true); 1528 ToHTMLPlugInElement(node)->SetNeedsPluginUpdate(true);
1535 1529
1536 part_update_set_.insert(&object); 1530 part_update_set_.insert(&object);
1537 } 1531 }
1538 1532
1539 void FrameView::SetDisplayMode(WebDisplayMode mode) { 1533 void FrameView::SetDisplayMode(WebDisplayMode mode) {
1540 if (mode == display_mode_) 1534 if (mode == display_mode_)
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 !constraints_map.at(layer).HasAncestorStickyElement()) { 2044 !constraints_map.at(layer).HasAncestorStickyElement()) {
2051 // TODO(skobes): Resolve circular dependency between scroll offset and 2045 // TODO(skobes): Resolve circular dependency between scroll offset and
2052 // compositing state, and remove this disabler. https://crbug.com/420741 2046 // compositing state, and remove this disabler. https://crbug.com/420741
2053 DisableCompositingQueryAsserts disabler; 2047 DisableCompositingQueryAsserts disabler;
2054 layer->UpdateLayerPositionsAfterOverflowScroll(); 2048 layer->UpdateLayerPositionsAfterOverflowScroll();
2055 layout_object->SetMayNeedPaintInvalidationSubtree(); 2049 layout_object->SetMayNeedPaintInvalidationSubtree();
2056 } 2050 }
2057 } 2051 }
2058 2052
2059 // If there fixed position elements, scrolling may cause compositing layers to 2053 // If there fixed position elements, scrolling may cause compositing layers to
2060 // change. Update FrameViewBase and layer positions after scrolling, but only 2054 // change. Update FrameView and layer positions after scrolling, but only
2061 // if we're not inside of layout. 2055 // if we're not inside of layout.
2062 if (!nested_layout_count_) { 2056 if (!nested_layout_count_) {
2063 UpdateGeometries(); 2057 UpdateGeometries();
2064 LayoutViewItem layout_view_item = this->GetLayoutViewItem(); 2058 LayoutViewItem layout_view_item = this->GetLayoutViewItem();
2065 if (!layout_view_item.IsNull()) 2059 if (!layout_view_item.IsNull())
2066 layout_view_item.Layer()->SetNeedsCompositingInputsUpdate(); 2060 layout_view_item.Layer()->SetNeedsCompositingInputsUpdate();
2067 } 2061 }
2068 } 2062 }
2069 2063
2070 bool FrameView::ComputeCompositedSelection(LocalFrame& frame, 2064 bool FrameView::ComputeCompositedSelection(LocalFrame& frame,
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 } 2472 }
2479 2473
2480 // The fragment anchor should only be maintained while the frame is still 2474 // The fragment anchor should only be maintained while the frame is still
2481 // loading. If the frame is done loading, clear the anchor now. Otherwise, 2475 // loading. If the frame is done loading, clear the anchor now. Otherwise,
2482 // restore it since it may have been cleared during scrollRectToVisible. 2476 // restore it since it may have been cleared during scrollRectToVisible.
2483 fragment_anchor_ = 2477 fragment_anchor_ =
2484 frame_->GetDocument()->IsLoadCompleted() ? nullptr : anchor_node; 2478 frame_->GetDocument()->IsLoadCompleted() ? nullptr : anchor_node;
2485 } 2479 }
2486 2480
2487 bool FrameView::UpdatePlugins() { 2481 bool FrameView::UpdatePlugins() {
2488 // This is always called from updatePluginsTimerFired. 2482 // This is always called from UpdatePluginsTimerFired.
2489 // m_updatePluginsTimer should only be scheduled if we have FrameViewBases to 2483 // update_plugins_timer should only be scheduled if we have FrameViews to
2490 // update. Thus I believe we can stop checking isEmpty here, and just ASSERT 2484 // update. Thus I believe we can stop checking isEmpty here, and just ASSERT
2491 // isEmpty: 2485 // isEmpty:
2492 // FIXME: This assert has been temporarily removed due to 2486 // FIXME: This assert has been temporarily removed due to
2493 // https://crbug.com/430344 2487 // https://crbug.com/430344
2494 if (nested_layout_count_ > 1 || part_update_set_.IsEmpty()) 2488 if (nested_layout_count_ > 1 || part_update_set_.IsEmpty())
2495 return true; 2489 return true;
2496 2490
2497 // Need to swap because script will run inside the below loop and invalidate 2491 // Need to swap because script will run inside the below loop and invalidate
2498 // the iterator. 2492 // the iterator.
2499 EmbeddedObjectSet objects; 2493 EmbeddedObjectSet objects;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 return kNotScrollableExplicitlyDisabled; 2742 return kNotScrollableExplicitlyDisabled;
2749 2743
2750 return kScrollable; 2744 return kScrollable;
2751 } 2745 }
2752 2746
2753 void FrameView::UpdateParentScrollableAreaSet() { 2747 void FrameView::UpdateParentScrollableAreaSet() {
2754 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 2748 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
2755 return; 2749 return;
2756 2750
2757 // That ensures that only inner frames are cached. 2751 // That ensures that only inner frames are cached.
2758 FrameView* parent_frame_view = this->ParentFrameView(); 2752 FrameView* parent_frame_view = ParentFrameView();
2759 if (!parent_frame_view) 2753 if (!parent_frame_view)
2760 return; 2754 return;
2761 2755
2762 if (!IsScrollable()) { 2756 if (!IsScrollable()) {
2763 parent_frame_view->RemoveScrollableArea(this); 2757 parent_frame_view->RemoveScrollableArea(this);
2764 return; 2758 return;
2765 } 2759 }
2766 2760
2767 parent_frame_view->AddScrollableArea(this); 2761 parent_frame_view->AddScrollableArea(this);
2768 } 2762 }
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 if (NeedsLayout()) 3384 if (NeedsLayout())
3391 UpdateLayout(); 3385 UpdateLayout();
3392 3386
3393 CheckDoesNotNeedLayout(); 3387 CheckDoesNotNeedLayout();
3394 3388
3395 // WebView plugins need to update regardless of whether the 3389 // WebView plugins need to update regardless of whether the
3396 // LayoutEmbeddedObject that owns them needed layout. 3390 // LayoutEmbeddedObject that owns them needed layout.
3397 // TODO(leviw): This currently runs the entire lifecycle on plugin WebViews. 3391 // TODO(leviw): This currently runs the entire lifecycle on plugin WebViews.
3398 // We should have a way to only run these other Documents to the same 3392 // We should have a way to only run these other Documents to the same
3399 // lifecycle stage as this frame. 3393 // lifecycle stage as this frame.
3400 for (const Member<PluginView>& plugin : *Plugins()) { 3394 for (const auto& child : children_) {
3401 plugin->UpdateAllLifecyclePhases(); 3395 if (child->IsPluginView())
3396 ToPluginView(child)->UpdateAllLifecyclePhases();
3402 } 3397 }
3403 CheckDoesNotNeedLayout(); 3398 CheckDoesNotNeedLayout();
3404 3399
3405 // FIXME: Calling layout() shouldn't trigger script execution or have any 3400 // FIXME: Calling layout() shouldn't trigger script execution or have any
3406 // observable effects on the frame tree but we're not quite there yet. 3401 // observable effects on the frame tree but we're not quite there yet.
3407 HeapVector<Member<FrameView>> frame_views; 3402 HeapVector<Member<FrameView>> frame_views;
3408 for (Frame* child = frame_->Tree().FirstChild(); child; 3403 for (Frame* child = frame_->Tree().FirstChild(); child;
3409 child = child->Tree().NextSibling()) { 3404 child = child->Tree().NextSibling()) {
3410 if (!child->IsLocalFrame()) 3405 if (!child->IsLocalFrame())
3411 continue; 3406 continue;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
3643 IntPoint FrameView::ConvertToLayoutItem(const LayoutItem& layout_item, 3638 IntPoint FrameView::ConvertToLayoutItem(const LayoutItem& layout_item,
3644 const IntPoint& frame_point) const { 3639 const IntPoint& frame_point) const {
3645 IntPoint point = frame_point; 3640 IntPoint point = frame_point;
3646 3641
3647 // Convert from FrameView coords into page ("absolute") coordinates. 3642 // Convert from FrameView coords into page ("absolute") coordinates.
3648 point += IntSize(ScrollX(), ScrollY()); 3643 point += IntSize(ScrollX(), ScrollY());
3649 3644
3650 return RoundedIntPoint(layout_item.AbsoluteToLocal(point, kUseTransforms)); 3645 return RoundedIntPoint(layout_item.AbsoluteToLocal(point, kUseTransforms));
3651 } 3646 }
3652 3647
3653 IntPoint FrameView::ConvertSelfToChild(const FrameViewBase* child, 3648 IntPoint FrameView::ConvertSelfToChild(const FrameOrPlugin& child,
3654 const IntPoint& point) const { 3649 const IntPoint& point) const {
3655 IntPoint new_point = point; 3650 IntPoint new_point = point;
3656 new_point = FrameToContents(point); 3651 new_point = FrameToContents(point);
3657 new_point.MoveBy(-child->Location()); 3652 new_point.MoveBy(child.FrameRect().Location());
3658 return new_point; 3653 return new_point;
3659 } 3654 }
3660 3655
3661 IntRect FrameView::ConvertToContainingFrameViewBase( 3656 IntRect FrameView::ConvertToContainingFrameViewBase(
3662 const IntRect& local_rect) const { 3657 const IntRect& local_rect) const {
3663 if (parent_) { 3658 if (parent_) {
3664 // Get our layoutObject in the parent view 3659 // Get our layoutObject in the parent view
3665 LayoutPartItem layout_item = frame_->OwnerLayoutItem(); 3660 LayoutPartItem layout_item = frame_->OwnerLayoutItem();
3666 if (layout_item.IsNull()) 3661 if (layout_item.IsNull())
3667 return local_rect; 3662 return local_rect;
3668 3663
3669 IntRect rect(local_rect); 3664 IntRect rect(local_rect);
3670 // Add borders and padding?? 3665 // Add borders and padding??
3671 rect.Move((layout_item.BorderLeft() + layout_item.PaddingLeft()).ToInt(), 3666 rect.Move((layout_item.BorderLeft() + layout_item.PaddingLeft()).ToInt(),
3672 (layout_item.BorderTop() + layout_item.PaddingTop()).ToInt()); 3667 (layout_item.BorderTop() + layout_item.PaddingTop()).ToInt());
3673 return parent_->ConvertFromLayoutItem(layout_item, rect); 3668 return parent_->ConvertFromLayoutItem(layout_item, rect);
3674 } 3669 }
3675 3670
3676 return local_rect; 3671 return local_rect;
3677 } 3672 }
3678 3673
3679 IntRect FrameView::ConvertFromContainingFrameViewBase( 3674 IntRect FrameView::ConvertFromContainingFrameViewBase(
3680 const IntRect& parent_rect) const { 3675 const IntRect& parent_rect) const {
3681 if (parent_) { 3676 if (parent_) {
3682 IntRect local_rect = parent_rect; 3677 IntRect local_rect = parent_rect;
3683 local_rect.SetLocation( 3678 local_rect.SetLocation(
3684 parent_->ConvertSelfToChild(this, local_rect.Location())); 3679 parent_->ConvertSelfToChild(*this, local_rect.Location()));
3685 return local_rect; 3680 return local_rect;
3686 } 3681 }
3687 3682
3688 return parent_rect; 3683 return parent_rect;
3689 } 3684 }
3690 3685
3691 IntPoint FrameView::ConvertToContainingFrameViewBase( 3686 IntPoint FrameView::ConvertToContainingFrameViewBase(
3692 const IntPoint& local_point) const { 3687 const IntPoint& local_point) const {
3693 if (parent_) { 3688 if (parent_) {
3694 // Get our layoutObject in the parent view 3689 // Get our layoutObject in the parent view
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
3838 animating_scrollable_areas_ = new ScrollableAreaSet; 3833 animating_scrollable_areas_ = new ScrollableAreaSet;
3839 animating_scrollable_areas_->insert(scrollable_area); 3834 animating_scrollable_areas_->insert(scrollable_area);
3840 } 3835 }
3841 3836
3842 void FrameView::RemoveAnimatingScrollableArea(ScrollableArea* scrollable_area) { 3837 void FrameView::RemoveAnimatingScrollableArea(ScrollableArea* scrollable_area) {
3843 if (!animating_scrollable_areas_) 3838 if (!animating_scrollable_areas_)
3844 return; 3839 return;
3845 animating_scrollable_areas_->erase(scrollable_area); 3840 animating_scrollable_areas_->erase(scrollable_area);
3846 } 3841 }
3847 3842
3848 void FrameView::SetParent(FrameViewBase* parent_frame_view_base) { 3843 void FrameView::SetParent(FrameView* parent) {
3849 FrameView* parent = ToFrameView(parent_frame_view_base);
3850 if (parent == parent_) 3844 if (parent == parent_)
3851 return; 3845 return;
3852 3846
3853 DCHECK(!parent || !parent_); 3847 DCHECK(!parent || !parent_);
3854 if (!parent || !parent->IsVisible()) 3848 if (!parent || !parent->IsVisible())
3855 SetParentVisible(false); 3849 SetParentVisible(false);
3856 parent_ = parent; 3850 parent_ = parent;
3857 if (parent && parent->IsVisible()) 3851 if (parent && parent->IsVisible())
3858 SetParentVisible(true); 3852 SetParentVisible(true);
3859 3853
3860 UpdateParentScrollableAreaSet(); 3854 UpdateParentScrollableAreaSet();
3861 SetupRenderThrottling(); 3855 SetupRenderThrottling();
3862 3856
3863 if (ParentFrameView()) 3857 if (ParentFrameView())
3864 subtree_throttled_ = ParentFrameView()->CanThrottleRendering(); 3858 subtree_throttled_ = ParentFrameView()->CanThrottleRendering();
3865 } 3859 }
3866 3860
3867 void FrameView::RemoveChild(FrameViewBase* child) { 3861 void FrameView::AddChild(FrameOrPlugin* child) {
3862 DCHECK(child != this && !child->Parent());
3863 child->SetParent(this);
3864 children_.insert(child);
3865 }
3866
3867 void FrameView::RemoveChild(FrameOrPlugin* child) {
3868 DCHECK(child->Parent() == this); 3868 DCHECK(child->Parent() == this);
3869 3869
3870 if (child->IsFrameView() && 3870 if (child->IsFrameView() &&
3871 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 3871 !RuntimeEnabledFeatures::rootLayerScrollingEnabled())
3872 RemoveScrollableArea(ToFrameView(child)); 3872 RemoveScrollableArea(ToFrameView(child));
3873 3873
3874 child->SetParent(nullptr); 3874 child->SetParent(nullptr);
3875 children_.erase(child); 3875 children_.erase(child);
3876 } 3876 }
3877 3877
3878 void FrameView::RemovePlugin(PluginView* plugin) {
3879 DCHECK(plugin->Parent() == this);
3880 DCHECK(plugins_.Contains(plugin));
3881 plugin->SetParent(nullptr);
3882 plugins_.erase(plugin);
3883 }
3884
3885 void FrameView::AddPlugin(PluginView* plugin) {
3886 DCHECK(!plugin->Parent());
3887 DCHECK(!plugins_.Contains(plugin));
3888 plugin->SetParent(this);
3889 plugins_.insert(plugin);
3890 }
3891
3892 void FrameView::RemoveScrollbar(Scrollbar* scrollbar) { 3878 void FrameView::RemoveScrollbar(Scrollbar* scrollbar) {
3893 DCHECK(scrollbars_.Contains(scrollbar)); 3879 DCHECK(scrollbars_.Contains(scrollbar));
3894 scrollbar->SetParent(nullptr); 3880 scrollbar->SetParent(nullptr);
3895 scrollbars_.erase(scrollbar); 3881 scrollbars_.erase(scrollbar);
3896 } 3882 }
3897 3883
3898 void FrameView::AddScrollbar(Scrollbar* scrollbar) { 3884 void FrameView::AddScrollbar(Scrollbar* scrollbar) {
3899 DCHECK(!scrollbars_.Contains(scrollbar)); 3885 DCHECK(!scrollbars_.Contains(scrollbar));
3900 scrollbar->SetParent(this); 3886 scrollbar->SetParent(this);
3901 scrollbars_.insert(scrollbar); 3887 scrollbars_.insert(scrollbar);
(...skipping 28 matching lines...) Expand all
3930 page->GetChromeClient().SetCursor(cursor, frame_); 3916 page->GetChromeClient().SetCursor(cursor, frame_);
3931 } 3917 }
3932 3918
3933 void FrameView::FrameRectsChanged() { 3919 void FrameView::FrameRectsChanged() {
3934 TRACE_EVENT0("blink", "FrameView::frameRectsChanged"); 3920 TRACE_EVENT0("blink", "FrameView::frameRectsChanged");
3935 if (LayoutSizeFixedToFrameSize()) 3921 if (LayoutSizeFixedToFrameSize())
3936 SetLayoutSizeInternal(FrameRect().Size()); 3922 SetLayoutSizeInternal(FrameRect().Size());
3937 3923
3938 for (const auto& child : children_) 3924 for (const auto& child : children_)
3939 child->FrameRectsChanged(); 3925 child->FrameRectsChanged();
3940
3941 for (const auto& plugin : plugins_)
3942 plugin->FrameRectsChanged();
3943 } 3926 }
3944 3927
3945 void FrameView::SetLayoutSizeInternal(const IntSize& size) { 3928 void FrameView::SetLayoutSizeInternal(const IntSize& size) {
3946 if (layout_size_ == size) 3929 if (layout_size_ == size)
3947 return; 3930 return;
3948 3931
3949 layout_size_ = size; 3932 layout_size_ = size;
3950 ContentsResized(); 3933 ContentsResized();
3951 } 3934 }
3952 3935
(...skipping 29 matching lines...) Expand all
3982 TopDocumentRootScrollerController& controller = 3965 TopDocumentRootScrollerController& controller =
3983 page->GlobalRootScrollerController(); 3966 page->GlobalRootScrollerController();
3984 if (layout_viewport == controller.RootScrollerArea()) 3967 if (layout_viewport == controller.RootScrollerArea())
3985 visible_size = controller.RootScrollerVisibleArea(); 3968 visible_size = controller.RootScrollerVisibleArea();
3986 3969
3987 IntSize maximum_offset = 3970 IntSize maximum_offset =
3988 ToIntSize(-ScrollOrigin() + (content_bounds - visible_size)); 3971 ToIntSize(-ScrollOrigin() + (content_bounds - visible_size));
3989 return maximum_offset.ExpandedTo(MinimumScrollOffsetInt()); 3972 return maximum_offset.ExpandedTo(MinimumScrollOffsetInt());
3990 } 3973 }
3991 3974
3992 void FrameView::AddChild(FrameViewBase* child) {
3993 DCHECK(child != this && !child->Parent());
3994 child->SetParent(this);
3995 children_.insert(child);
3996 }
3997
3998 void FrameView::SetScrollbarModes(ScrollbarMode horizontal_mode, 3975 void FrameView::SetScrollbarModes(ScrollbarMode horizontal_mode,
3999 ScrollbarMode vertical_mode, 3976 ScrollbarMode vertical_mode,
4000 bool horizontal_lock, 3977 bool horizontal_lock,
4001 bool vertical_lock) { 3978 bool vertical_lock) {
4002 bool needs_update = false; 3979 bool needs_update = false;
4003 3980
4004 // If the page's overflow setting has disabled scrolling, do not allow 3981 // If the page's overflow setting has disabled scrolling, do not allow
4005 // anything to override that setting, http://crbug.com/426447 3982 // anything to override that setting, http://crbug.com/426447
4006 LayoutObject* viewport = ViewportLayoutObject(); 3983 LayoutObject* viewport = ViewportLayoutObject();
4007 if (viewport && !ShouldIgnoreOverflowHidden()) { 3984 if (viewport && !ShouldIgnoreOverflowHidden()) {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
4436 4413
4437 if (!ScrollContentsFastPath(-scroll_delta)) 4414 if (!ScrollContentsFastPath(-scroll_delta))
4438 ScrollContentsSlowPath(); 4415 ScrollContentsSlowPath();
4439 4416
4440 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && 4417 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
4441 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 4418 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
4442 // Need to update scroll translation property. 4419 // Need to update scroll translation property.
4443 SetNeedsPaintPropertyUpdate(); 4420 SetNeedsPaintPropertyUpdate();
4444 } 4421 }
4445 4422
4446 // This call will move children with native FrameViewBases (plugins) and 4423 // This call will move children with native FrameViews (plugins) and
4447 // invalidate them as well. 4424 // invalidate them as well.
4448 FrameRectsChanged(); 4425 FrameRectsChanged();
4449 } 4426 }
4450 4427
4451 IntPoint FrameView::ContentsToFrame( 4428 IntPoint FrameView::ContentsToFrame(
4452 const IntPoint& point_in_content_space) const { 4429 const IntPoint& point_in_content_space) const {
4453 return point_in_content_space - ScrollOffsetInt(); 4430 return point_in_content_space - ScrollOffsetInt();
4454 } 4431 }
4455 4432
4456 IntRect FrameView::ContentsToFrame(const IntRect& rect_in_content_space) const { 4433 IntRect FrameView::ContentsToFrame(const IntRect& rect_in_content_space) const {
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
4783 // and potentially child frame views. 4760 // and potentially child frame views.
4784 SetNeedsCompositingUpdate(GetLayoutViewItem(), kCompositingUpdateRebuildTree); 4761 SetNeedsCompositingUpdate(GetLayoutViewItem(), kCompositingUpdateRebuildTree);
4785 4762
4786 parent_visible_ = visible; 4763 parent_visible_ = visible;
4787 4764
4788 if (!IsSelfVisible()) 4765 if (!IsSelfVisible())
4789 return; 4766 return;
4790 4767
4791 for (const auto& child : children_) 4768 for (const auto& child : children_)
4792 child->SetParentVisible(visible); 4769 child->SetParentVisible(visible);
4793
4794 for (const auto& plugin : plugins_)
4795 plugin->SetParentVisible(visible);
4796 } 4770 }
4797 4771
4798 void FrameView::Show() { 4772 void FrameView::Show() {
4799 if (!IsSelfVisible()) { 4773 if (!IsSelfVisible()) {
4800 SetSelfVisible(true); 4774 SetSelfVisible(true);
4801 if (ScrollingCoordinator* scrolling_coordinator = 4775 if (ScrollingCoordinator* scrolling_coordinator =
4802 this->GetScrollingCoordinator()) 4776 this->GetScrollingCoordinator())
4803 scrolling_coordinator->FrameViewVisibilityDidChange(); 4777 scrolling_coordinator->FrameViewVisibilityDidChange();
4804 SetNeedsCompositingUpdate(GetLayoutViewItem(), 4778 SetNeedsCompositingUpdate(GetLayoutViewItem(),
4805 kCompositingUpdateRebuildTree); 4779 kCompositingUpdateRebuildTree);
4806 UpdateParentScrollableAreaSet(); 4780 UpdateParentScrollableAreaSet();
4807 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && 4781 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
4808 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 4782 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
4809 // The existance of scrolling properties depends on visibility through 4783 // The existance of scrolling properties depends on visibility through
4810 // isScrollable() so ensure properties are updated if visibility changes. 4784 // isScrollable() so ensure properties are updated if visibility changes.
4811 SetNeedsPaintPropertyUpdate(); 4785 SetNeedsPaintPropertyUpdate();
4812 } 4786 }
4813 if (IsParentVisible()) { 4787 if (IsParentVisible()) {
4814 for (const auto& child : children_) 4788 for (const auto& child : children_)
4815 child->SetParentVisible(true); 4789 child->SetParentVisible(true);
4816
4817 for (const auto& plugin : plugins_)
4818 plugin->SetParentVisible(true);
4819 } 4790 }
4820 } 4791 }
4821 } 4792 }
4822 4793
4823 void FrameView::Hide() { 4794 void FrameView::Hide() {
4824 if (IsSelfVisible()) { 4795 if (IsSelfVisible()) {
4825 if (IsParentVisible()) { 4796 if (IsParentVisible()) {
4826 for (const auto& child : children_) 4797 for (const auto& child : children_)
4827 child->SetParentVisible(false); 4798 child->SetParentVisible(false);
4828
4829 for (const auto& plugin : plugins_)
4830 plugin->SetParentVisible(false);
4831 } 4799 }
4832 SetSelfVisible(false); 4800 SetSelfVisible(false);
4833 if (ScrollingCoordinator* scrolling_coordinator = 4801 if (ScrollingCoordinator* scrolling_coordinator =
4834 this->GetScrollingCoordinator()) 4802 this->GetScrollingCoordinator())
4835 scrolling_coordinator->FrameViewVisibilityDidChange(); 4803 scrolling_coordinator->FrameViewVisibilityDidChange();
4836 SetNeedsCompositingUpdate(GetLayoutViewItem(), 4804 SetNeedsCompositingUpdate(GetLayoutViewItem(),
4837 kCompositingUpdateRebuildTree); 4805 kCompositingUpdateRebuildTree);
4838 UpdateParentScrollableAreaSet(); 4806 UpdateParentScrollableAreaSet();
4839 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && 4807 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &&
4840 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 4808 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4887 return; 4855 return;
4888 4856
4889 layout_object.AddAnnotatedRegions(regions); 4857 layout_object.AddAnnotatedRegions(regions);
4890 for (LayoutObject* curr = layout_object.SlowFirstChild(); curr; 4858 for (LayoutObject* curr = layout_object.SlowFirstChild(); curr;
4891 curr = curr->NextSibling()) 4859 curr = curr->NextSibling())
4892 CollectAnnotatedRegions(*curr, regions); 4860 CollectAnnotatedRegions(*curr, regions);
4893 } 4861 }
4894 4862
4895 void FrameView::UpdateViewportIntersectionsForSubtree( 4863 void FrameView::UpdateViewportIntersectionsForSubtree(
4896 DocumentLifecycle::LifecycleState target_state) { 4864 DocumentLifecycle::LifecycleState target_state) {
4897 // TODO(dcheng): Since FrameViewBase tree updates are deferred, FrameViews 4865 // TODO(dcheng): Since FrameView tree updates are deferred, FrameViews
4898 // might still be in the FrameViewBase hierarchy even though the associated 4866 // might still be in the FrameView hierarchy even though the associated
4899 // Document is already detached. Investigate if this check and a similar check 4867 // Document is already detached. Investigate if this check and a similar check
4900 // in lifecycle updates are still needed when there are no more deferred 4868 // in lifecycle updates are still needed when there are no more deferred
4901 // FrameViewBase updates: https://crbug.com/561683 4869 // FrameView updates: https://crbug.com/561683
4902 if (!GetFrame().GetDocument()->IsActive()) 4870 if (!GetFrame().GetDocument()->IsActive())
4903 return; 4871 return;
4904 4872
4905 if (target_state == DocumentLifecycle::kPaintClean) { 4873 if (target_state == DocumentLifecycle::kPaintClean) {
4906 RecordDeferredLoadingStats(); 4874 RecordDeferredLoadingStats();
4907 if (!NeedsLayout()) { 4875 if (!NeedsLayout()) {
4908 // Notify javascript IntersectionObservers 4876 // Notify javascript IntersectionObservers
4909 if (GetFrame().GetDocument()->GetIntersectionObserverController()) { 4877 if (GetFrame().GetDocument()->GetIntersectionObserverController()) {
4910 GetFrame() 4878 GetFrame()
4911 .GetDocument() 4879 .GetDocument()
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4972 4940
4973 // If this FrameView became unthrottled or throttled, we must make sure all 4941 // If this FrameView became unthrottled or throttled, we must make sure all
4974 // its children are notified synchronously. Otherwise we 1) might attempt to 4942 // its children are notified synchronously. Otherwise we 1) might attempt to
4975 // paint one of the children with an out-of-date layout before 4943 // paint one of the children with an out-of-date layout before
4976 // |updateRenderThrottlingStatus| has made it throttled or 2) fail to 4944 // |updateRenderThrottlingStatus| has made it throttled or 2) fail to
4977 // unthrottle a child whose parent is unthrottled by a later notification. 4945 // unthrottle a child whose parent is unthrottled by a later notification.
4978 if (notify_children_behavior == kNotifyChildren && 4946 if (notify_children_behavior == kNotifyChildren &&
4979 (was_throttled != is_throttled || 4947 (was_throttled != is_throttled ||
4980 force_throttling_invalidation_behavior == 4948 force_throttling_invalidation_behavior ==
4981 kForceThrottlingInvalidation)) { 4949 kForceThrottlingInvalidation)) {
4982 for (const Member<FrameViewBase>& child : *Children()) { 4950 for (const auto& child : children_) {
4983 if (child->IsFrameView()) { 4951 if (child->IsFrameView()) {
4984 FrameView* child_view = ToFrameView(child); 4952 ToFrameView(child)->UpdateRenderThrottlingStatus(
4985 child_view->UpdateRenderThrottlingStatus( 4953 ToFrameView(child)->hidden_for_throttling_, is_throttled);
4986 child_view->hidden_for_throttling_, is_throttled);
4987 } 4954 }
4988 } 4955 }
4989 } 4956 }
4990 4957
4991 ScrollingCoordinator* scrolling_coordinator = this->GetScrollingCoordinator(); 4958 ScrollingCoordinator* scrolling_coordinator = this->GetScrollingCoordinator();
4992 if (became_unthrottled || 4959 if (became_unthrottled ||
4993 force_throttling_invalidation_behavior == kForceThrottlingInvalidation) { 4960 force_throttling_invalidation_behavior == kForceThrottlingInvalidation) {
4994 // ScrollingCoordinator needs to update according to the new throttling 4961 // ScrollingCoordinator needs to update according to the new throttling
4995 // status. 4962 // status.
4996 if (scrolling_coordinator) 4963 if (scrolling_coordinator)
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
5388 void FrameView::SetAnimationHost( 5355 void FrameView::SetAnimationHost(
5389 std::unique_ptr<CompositorAnimationHost> host) { 5356 std::unique_ptr<CompositorAnimationHost> host) {
5390 animation_host_ = std::move(host); 5357 animation_host_ = std::move(host);
5391 } 5358 }
5392 5359
5393 LayoutUnit FrameView::CaretWidth() const { 5360 LayoutUnit FrameView::CaretWidth() const {
5394 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1)); 5361 return LayoutUnit(GetChromeClient()->WindowToViewportScalar(1));
5395 } 5362 }
5396 5363
5397 } // namespace blink 5364 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698