Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/FrameView.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp |
| index 5e8e7341e02c6ab8a2594ca484eea4a8b104ed0b..949239200fbfd984711f032480abda3384ebc675 100644 |
| --- a/third_party/WebKit/Source/core/frame/FrameView.cpp |
| +++ b/third_party/WebKit/Source/core/frame/FrameView.cpp |
| @@ -243,7 +243,6 @@ DEFINE_TRACE(FrameView) { |
| visitor->Trace(animating_scrollable_areas_); |
| visitor->Trace(auto_size_info_); |
| visitor->Trace(children_); |
| - visitor->Trace(plugins_); |
| visitor->Trace(scrollbars_); |
| visitor->Trace(viewport_scrollable_area_); |
| visitor->Trace(visibility_observer_); |
| @@ -251,7 +250,6 @@ DEFINE_TRACE(FrameView) { |
| visitor->Trace(anchoring_adjustment_queue_); |
| visitor->Trace(scrollbar_manager_); |
| visitor->Trace(print_context_); |
| - FrameViewBase::Trace(visitor); |
| ScrollableArea::Trace(visitor); |
| } |
| @@ -380,10 +378,10 @@ void FrameView::Dispose() { |
| // FIXME: Do we need to do something here for OOPI? |
| HTMLFrameOwnerElement* owner_element = frame_->DeprecatedLocalOwner(); |
| // TODO(dcheng): It seems buggy that we can have an owner element that points |
| - // to another FrameViewBase. This can happen when a plugin element loads a |
| - // frame (FrameViewBase A of type FrameView) and then loads a plugin |
| - // (FrameViewBase B of type WebPluginContainerImpl). In this case, the frame's |
| - // view is A and the frame element's owned FrameViewBase is B. See |
| + // to another FrameOrPlugin. This can happen when a plugin element loads a |
| + // frame (FrameOrPlugin A of type FrameView) and then loads a plugin |
| + // (FrameOrPlugin B of type WebPluginContainerImpl). In this case, the frame's |
| + // view is A and the frame element's OwnedWidget is B. See |
| // https://crbug.com/673170 for an example. |
| if (owner_element && owner_element->OwnedWidget() == this) |
| owner_element->SetWidget(nullptr); |
| @@ -504,16 +502,12 @@ void FrameView::InvalidateAllCustomScrollbarsOnActiveChanged() { |
| bool uses_window_inactive_selector = |
| frame_->GetDocument()->GetStyleEngine().UsesWindowInactiveSelector(); |
| - const ChildrenSet* view_children = Children(); |
| - for (const Member<FrameViewBase>& child : *view_children) { |
| - FrameViewBase* frame_view_base = child.Get(); |
| - if (frame_view_base->IsFrameView()) { |
| - ToFrameView(frame_view_base) |
| - ->InvalidateAllCustomScrollbarsOnActiveChanged(); |
| - } |
| + for (const auto& child : children_) { |
| + if (child->IsFrameView()) |
| + ToFrameView(child)->InvalidateAllCustomScrollbarsOnActiveChanged(); |
| } |
| - for (const Member<Scrollbar>& scrollbar : *Scrollbars()) { |
| + for (const auto& scrollbar : scrollbars_) { |
| if (uses_window_inactive_selector && scrollbar->IsCustomScrollbar()) |
| scrollbar->StyleChanged(); |
| } |
| @@ -1167,7 +1161,7 @@ void FrameView::ScheduleOrPerformPostLayoutTasks() { |
| if (!post_layout_tasks_timer_.IsActive() && |
| (NeedsLayout() || in_synchronous_post_layout_)) { |
| // If we need layout or are already in a synchronous call to |
| - // postLayoutTasks(), defer FrameViewBase updates and event dispatch until |
| + // postLayoutTasks(), defer FrameView updates and event dispatch until |
| // after we return. postLayoutTasks() can make us need to update again, and |
| // we can get stuck in a nasty cycle unless we call it through the timer |
| // here. |
| @@ -1525,7 +1519,7 @@ void FrameView::UpdateGeometries() { |
| void FrameView::AddPartToUpdate(LayoutEmbeddedObject& object) { |
| ASSERT(IsInPerformLayout()); |
| - // Tell the DOM element that it needs a FrameViewBase update. |
| + // 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
|
| Node* node = object.GetNode(); |
| ASSERT(node); |
| if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node)) |
| @@ -2055,7 +2049,7 @@ void FrameView::UpdateLayersAndCompositingAfterScrollIfNeeded() { |
| } |
| // If there fixed position elements, scrolling may cause compositing layers to |
| - // change. Update FrameViewBase and layer positions after scrolling, but only |
| + // change. Update FrameView and layer positions after scrolling, but only |
| // if we're not inside of layout. |
| if (!nested_layout_count_) { |
| UpdateGeometries(); |
| @@ -2483,8 +2477,8 @@ void FrameView::ScrollToFragmentAnchor() { |
| } |
| bool FrameView::UpdatePlugins() { |
| - // This is always called from updatePluginsTimerFired. |
| - // m_updatePluginsTimer should only be scheduled if we have FrameViewBases to |
| + // This is always called from UpdatePluginsTimerFired. |
| + // update_plugins_timer should only be scheduled if we have FrameViews to |
| // update. Thus I believe we can stop checking isEmpty here, and just ASSERT |
| // isEmpty: |
| // FIXME: This assert has been temporarily removed due to |
| @@ -3400,8 +3394,9 @@ void FrameView::UpdateStyleAndLayoutIfNeededRecursiveInternal() { |
| // TODO(leviw): This currently runs the entire lifecycle on plugin WebViews. |
| // We should have a way to only run these other Documents to the same |
| // lifecycle stage as this frame. |
| - for (const Member<PluginView>& plugin : *Plugins()) { |
| - plugin->UpdateAllLifecyclePhases(); |
| + for (const auto& child : children_) { |
| + if (child->IsPluginView()) |
| + ToPluginView(child)->UpdateAllLifecyclePhases(); |
| } |
| CheckDoesNotNeedLayout(); |
| @@ -3653,15 +3648,15 @@ IntPoint FrameView::ConvertToLayoutItem(const LayoutItem& layout_item, |
| return RoundedIntPoint(layout_item.AbsoluteToLocal(point, kUseTransforms)); |
| } |
| -IntPoint FrameView::ConvertSelfToChild(const FrameViewBase* child, |
| +IntPoint FrameView::ConvertSelfToChild(const IntPoint& child_location, |
| const IntPoint& point) const { |
| IntPoint new_point = point; |
| new_point = FrameToContents(point); |
| - new_point.MoveBy(-child->Location()); |
| + new_point.MoveBy(-child_location); |
| return new_point; |
| } |
| -IntRect FrameView::ConvertToContainingFrameViewBase( |
| +IntRect FrameView::ConvertToContainingFrameView( |
| const IntRect& local_rect) const { |
| if (parent_) { |
| // Get our layoutObject in the parent view |
| @@ -3679,19 +3674,19 @@ IntRect FrameView::ConvertToContainingFrameViewBase( |
| return local_rect; |
| } |
| -IntRect FrameView::ConvertFromContainingFrameViewBase( |
| +IntRect FrameView::ConvertFromContainingFrameView( |
| const IntRect& parent_rect) const { |
| if (parent_) { |
| IntRect local_rect = parent_rect; |
| local_rect.SetLocation( |
| - parent_->ConvertSelfToChild(this, local_rect.Location())); |
| + parent_->ConvertSelfToChild(Location(), local_rect.Location())); |
| return local_rect; |
| } |
| return parent_rect; |
| } |
| -IntPoint FrameView::ConvertToContainingFrameViewBase( |
| +IntPoint FrameView::ConvertToContainingFrameView( |
| const IntPoint& local_point) const { |
| if (parent_) { |
| // Get our layoutObject in the parent view |
| @@ -3710,7 +3705,7 @@ IntPoint FrameView::ConvertToContainingFrameViewBase( |
| return local_point; |
| } |
| -IntPoint FrameView::ConvertFromContainingFrameViewBase( |
| +IntPoint FrameView::ConvertFromContainingFrameView( |
| const IntPoint& parent_point) const { |
| if (parent_) { |
| // Get our layoutObject in the parent view |
| @@ -3848,8 +3843,14 @@ void FrameView::RemoveAnimatingScrollableArea(ScrollableArea* scrollable_area) { |
| animating_scrollable_areas_->erase(scrollable_area); |
| } |
| -void FrameView::SetParent(FrameViewBase* parent_frame_view_base) { |
| - FrameView* parent = ToFrameView(parent_frame_view_base); |
| +FrameView* FrameView::Root() const { |
| + const FrameView* top = this; |
| + while (top->Parent()) |
| + top = top->Parent(); |
| + return const_cast<FrameView*>(top); |
| +} |
| + |
| +void FrameView::SetParent(FrameView* parent) { |
| if (parent == parent_) |
| return; |
| @@ -3867,7 +3868,13 @@ void FrameView::SetParent(FrameViewBase* parent_frame_view_base) { |
| subtree_throttled_ = ParentFrameView()->CanThrottleRendering(); |
| } |
| -void FrameView::RemoveChild(FrameViewBase* child) { |
| +void FrameView::AddChild(FrameOrPlugin* child) { |
| + DCHECK(child != this && !child->Parent()); |
| + child->SetParent(this); |
| + children_.insert(child); |
| +} |
| + |
| +void FrameView::RemoveChild(FrameOrPlugin* child) { |
| DCHECK(child->Parent() == this); |
| if (child->IsFrameView() && |
| @@ -3878,20 +3885,6 @@ void FrameView::RemoveChild(FrameViewBase* child) { |
| children_.erase(child); |
| } |
| -void FrameView::RemovePlugin(PluginView* plugin) { |
| - DCHECK(plugin->Parent() == this); |
| - DCHECK(plugins_.Contains(plugin)); |
| - plugin->SetParent(nullptr); |
| - plugins_.erase(plugin); |
| -} |
| - |
| -void FrameView::AddPlugin(PluginView* plugin) { |
| - DCHECK(!plugin->Parent()); |
| - DCHECK(!plugins_.Contains(plugin)); |
| - plugin->SetParent(this); |
| - plugins_.insert(plugin); |
| -} |
| - |
| void FrameView::RemoveScrollbar(Scrollbar* scrollbar) { |
| DCHECK(scrollbars_.Contains(scrollbar)); |
| scrollbar->SetParent(nullptr); |
| @@ -3940,9 +3933,6 @@ void FrameView::FrameRectsChanged() { |
| for (const auto& child : children_) |
| child->FrameRectsChanged(); |
| - |
| - for (const auto& plugin : plugins_) |
| - plugin->FrameRectsChanged(); |
| } |
| void FrameView::SetLayoutSizeInternal(const IntSize& size) { |
| @@ -3992,12 +3982,6 @@ IntSize FrameView::MaximumScrollOffsetInt() const { |
| return maximum_offset.ExpandedTo(MinimumScrollOffsetInt()); |
| } |
| -void FrameView::AddChild(FrameViewBase* child) { |
| - DCHECK(child != this && !child->Parent()); |
| - child->SetParent(this); |
| - children_.insert(child); |
| -} |
| - |
| void FrameView::SetScrollbarModes(ScrollbarMode horizontal_mode, |
| ScrollbarMode vertical_mode, |
| bool horizontal_lock, |
| @@ -4446,7 +4430,7 @@ void FrameView::ScrollContents(const IntSize& scroll_delta) { |
| SetNeedsPaintPropertyUpdate(); |
| } |
| - // This call will move children with native FrameViewBases (plugins) and |
| + // This call will move children with native FrameViews (plugins) and |
| // invalidate them as well. |
| FrameRectsChanged(); |
| } |
| @@ -4748,7 +4732,7 @@ bool FrameView::ScrollbarCornerPresent() const { |
| IntRect FrameView::ConvertToRootFrame(const IntRect& local_rect) const { |
| if (parent_) { |
| - IntRect parent_rect = ConvertToContainingFrameViewBase(local_rect); |
| + IntRect parent_rect = ConvertToContainingFrameView(local_rect); |
| return parent_->ConvertToRootFrame(parent_rect); |
| } |
| return local_rect; |
| @@ -4756,13 +4740,13 @@ IntRect FrameView::ConvertToRootFrame(const IntRect& local_rect) const { |
| IntPoint FrameView::ConvertToRootFrame(const IntPoint& local_point) const { |
| if (parent_) { |
| - IntPoint parent_point = ConvertToContainingFrameViewBase(local_point); |
| + IntPoint parent_point = ConvertToContainingFrameView(local_point); |
| return parent_->ConvertToRootFrame(parent_point); |
| } |
| return local_point; |
| } |
| -IntPoint FrameView::ConvertFromContainingFrameViewBaseToScrollbar( |
| +IntPoint FrameView::ConvertFromContainingFrameViewToScrollbar( |
| const Scrollbar& scrollbar, |
| const IntPoint& parent_point) const { |
| IntPoint new_point = parent_point; |
| @@ -4793,9 +4777,6 @@ void FrameView::SetParentVisible(bool visible) { |
| for (const auto& child : children_) |
| child->SetParentVisible(visible); |
| - |
| - for (const auto& plugin : plugins_) |
| - plugin->SetParentVisible(visible); |
| } |
| void FrameView::Show() { |
| @@ -4816,9 +4797,6 @@ void FrameView::Show() { |
| if (IsParentVisible()) { |
| for (const auto& child : children_) |
| child->SetParentVisible(true); |
| - |
| - for (const auto& plugin : plugins_) |
| - plugin->SetParentVisible(true); |
| } |
| } |
| } |
| @@ -4828,9 +4806,6 @@ void FrameView::Hide() { |
| if (IsParentVisible()) { |
| for (const auto& child : children_) |
| child->SetParentVisible(false); |
| - |
| - for (const auto& plugin : plugins_) |
| - plugin->SetParentVisible(false); |
| } |
| SetSelfVisible(false); |
| if (ScrollingCoordinator* scrolling_coordinator = |
| @@ -4897,11 +4872,11 @@ void FrameView::CollectAnnotatedRegions( |
| void FrameView::UpdateViewportIntersectionsForSubtree( |
| DocumentLifecycle::LifecycleState target_state) { |
| - // TODO(dcheng): Since FrameViewBase tree updates are deferred, FrameViews |
| - // might still be in the FrameViewBase hierarchy even though the associated |
| + // TODO(dcheng): Since FrameView tree updates are deferred, FrameViews |
| + // might still be in the FrameView hierarchy even though the associated |
| // Document is already detached. Investigate if this check and a similar check |
| // in lifecycle updates are still needed when there are no more deferred |
| - // FrameViewBase updates: https://crbug.com/561683 |
| + // FrameView updates: https://crbug.com/561683 |
| if (!GetFrame().GetDocument()->IsActive()) |
| return; |
| @@ -4977,11 +4952,10 @@ void FrameView::UpdateRenderThrottlingStatus( |
| (was_throttled != is_throttled || |
| force_throttling_invalidation_behavior == |
| kForceThrottlingInvalidation)) { |
| - for (const Member<FrameViewBase>& child : *Children()) { |
| + for (const auto& child : children_) { |
| if (child->IsFrameView()) { |
| - FrameView* child_view = ToFrameView(child); |
| - child_view->UpdateRenderThrottlingStatus( |
| - child_view->hidden_for_throttling_, is_throttled); |
| + ToFrameView(child)->UpdateRenderThrottlingStatus( |
| + ToFrameView(child)->hidden_for_throttling_, is_throttled); |
| } |
| } |
| } |