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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutPart.cpp

Issue 2810873007: Replace LayoutPart::GetFrameViewBase with GetNodeFrameView (Closed)
Patch Set: Created 3 years, 8 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Simon Hausmann <hausmann@kde.org> 3 * (C) 2000 Simon Hausmann <hausmann@kde.org>
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // object points too is invalid, so we have to clear the node so we make sure 82 // object points too is invalid, so we have to clear the node so we make sure
83 // we don't access it in the future. 83 // we don't access it in the future.
84 ClearNode(); 84 ClearNode();
85 Deref(); 85 Deref();
86 } 86 }
87 87
88 LayoutPart::~LayoutPart() { 88 LayoutPart::~LayoutPart() {
89 DCHECK_LE(ref_count_, 0); 89 DCHECK_LE(ref_count_, 0);
90 } 90 }
91 91
92 FrameViewBase* LayoutPart::GetFrameViewBase() const { 92 FrameView* LayoutPart::GetNodeFrameView() const {
93 // Plugin FrameViewBases are stored in their DOM node. 93 // FrameViews are stored in HTMLFrameOwnerElement node.
94 Element* element = ToElement(GetNode()); 94 Node* node = GetNode();
95 95 if (node && node->IsFrameOwnerElement()) {
96 if (element && element->IsFrameOwnerElement()) 96 FrameViewBase* frame_view_base =
97 return ToHTMLFrameOwnerElement(element)->OwnedWidget(); 97 ToHTMLFrameOwnerElement(node)->OwnedWidget();
98 98 if (frame_view_base && frame_view_base->IsFrameView())
99 return ToFrameView(frame_view_base);
100 }
99 return nullptr; 101 return nullptr;
100 } 102 }
101 103
102 PluginView* LayoutPart::Plugin() const { 104 PluginView* LayoutPart::Plugin() const {
103 // Plugins are stored in their DOM node. 105 // Plugins are stored in HTMLPlugInElement node.
104 return GetNode() && IsHTMLPlugInElement(GetNode()) 106 Node* node = GetNode();
105 ? ToHTMLPlugInElement(GetNode())->Plugin() 107 return node && IsHTMLPlugInElement(node) ? ToHTMLPlugInElement(node)->Plugin()
106 : nullptr; 108 : nullptr;
107 } 109 }
108 110
109 FrameViewBase* LayoutPart::PluginOrFrame() const { 111 FrameViewBase* LayoutPart::PluginOrFrame() const {
110 FrameViewBase* result = GetFrameViewBase(); 112 FrameViewBase* result = nullptr;
113 Node* node = GetNode();
114 if (node && node->IsFrameOwnerElement())
115 result = ToHTMLFrameOwnerElement(node)->OwnedWidget();
111 if (!result) 116 if (!result)
112 result = Plugin(); 117 result = Plugin();
113 return result; 118 return result;
114 } 119 }
115 120
116 PaintLayerType LayoutPart::LayerTypeRequired() const { 121 PaintLayerType LayoutPart::LayerTypeRequired() const {
117 PaintLayerType type = LayoutReplaced::LayerTypeRequired(); 122 PaintLayerType type = LayoutReplaced::LayerTypeRequired();
118 if (type != kNoPaintLayer) 123 if (type != kNoPaintLayer)
119 return type; 124 return type;
120 return kForcedPaintLayer; 125 return kForcedPaintLayer;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 result.SetIsOverFrameViewBase( 172 result.SetIsOverFrameViewBase(
168 ContentBoxRect().Contains(result.LocalPoint())); 173 ContentBoxRect().Contains(result.LocalPoint()));
169 } 174 }
170 return inside; 175 return inside;
171 } 176 }
172 177
173 bool LayoutPart::NodeAtPoint(HitTestResult& result, 178 bool LayoutPart::NodeAtPoint(HitTestResult& result,
174 const HitTestLocation& location_in_container, 179 const HitTestLocation& location_in_container,
175 const LayoutPoint& accumulated_offset, 180 const LayoutPoint& accumulated_offset,
176 HitTestAction action) { 181 HitTestAction action) {
177 if (!GetFrameViewBase() || !GetFrameViewBase()->IsFrameView() || 182 FrameView* frame_view = GetNodeFrameView();
178 !result.GetHitTestRequest().AllowsChildFrameContent()) { 183 if (!frame_view || !result.GetHitTestRequest().AllowsChildFrameContent()) {
179 return NodeAtPointOverFrameViewBase(result, location_in_container, 184 return NodeAtPointOverFrameViewBase(result, location_in_container,
180 accumulated_offset, action); 185 accumulated_offset, action);
181 } 186 }
182 187
183 // A hit test can never hit an off-screen element; only off-screen iframes are 188 // A hit test can never hit an off-screen element; only off-screen iframes are
184 // throttled; therefore, hit tests can skip descending into throttled iframes. 189 // throttled; therefore, hit tests can skip descending into throttled iframes.
185 if (ToFrameView(GetFrameViewBase())->ShouldThrottleRendering()) { 190 if (frame_view->ShouldThrottleRendering()) {
186 return NodeAtPointOverFrameViewBase(result, location_in_container, 191 return NodeAtPointOverFrameViewBase(result, location_in_container,
187 accumulated_offset, action); 192 accumulated_offset, action);
188 } 193 }
189 194
190 DCHECK_GE(GetDocument().Lifecycle().GetState(), 195 DCHECK_GE(GetDocument().Lifecycle().GetState(),
191 DocumentLifecycle::kCompositingClean); 196 DocumentLifecycle::kCompositingClean);
192 197
193 if (action == kHitTestForeground) { 198 if (action == kHitTestForeground) {
194 FrameView* child_frame_view = ToFrameView(GetFrameViewBase()); 199 FrameView* child_frame_view = GetNodeFrameView();
dcheng 2017/04/12 23:44:37 Can we just use frame_view directly here? It seems
joelhockey 2017/04/13 00:37:01 Yes, I can't see how this value could change, so n
195 LayoutViewItem child_root_item = child_frame_view->GetLayoutViewItem(); 200 LayoutViewItem child_root_item = child_frame_view->GetLayoutViewItem();
196 201
197 if (VisibleToHitTestRequest(result.GetHitTestRequest()) && 202 if (VisibleToHitTestRequest(result.GetHitTestRequest()) &&
198 !child_root_item.IsNull()) { 203 !child_root_item.IsNull()) {
199 LayoutPoint adjusted_location = accumulated_offset + Location(); 204 LayoutPoint adjusted_location = accumulated_offset + Location();
200 LayoutPoint content_offset = 205 LayoutPoint content_offset =
201 LayoutPoint(BorderLeft() + PaddingLeft(), 206 LayoutPoint(BorderLeft() + PaddingLeft(),
202 BorderTop() + PaddingTop()) - 207 BorderTop() + PaddingTop()) -
203 LayoutSize(child_frame_view->ScrollOffsetInt()); 208 LayoutSize(child_frame_view->ScrollOffsetInt());
204 HitTestLocation new_hit_test_location( 209 HitTestLocation new_hit_test_location(
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 LocalToAbsoluteQuad(FloatRect(ReplacedContentRect())).BoundingBox(); 391 LocalToAbsoluteQuad(FloatRect(ReplacedContentRect())).BoundingBox();
387 frame_rect.SetLocation(RoundedIntPoint(absolute_bounding_box.Location())); 392 frame_rect.SetLocation(RoundedIntPoint(absolute_bounding_box.Location()));
388 393
389 // Why is the protector needed? 394 // Why is the protector needed?
390 RefPtr<LayoutPart> protector(this); 395 RefPtr<LayoutPart> protector(this);
391 frame_view_base.SetFrameRect(frame_rect); 396 frame_view_base.SetFrameRect(frame_rect);
392 } 397 }
393 398
394 void LayoutPart::InvalidatePaintOfSubtreesIfNeeded( 399 void LayoutPart::InvalidatePaintOfSubtreesIfNeeded(
395 const PaintInvalidationState& paint_invalidation_state) { 400 const PaintInvalidationState& paint_invalidation_state) {
396 if (GetFrameViewBase() && GetFrameViewBase()->IsFrameView() && 401 FrameView* child_frame_view = GetNodeFrameView();
397 !IsThrottledFrameView()) { 402 if (child_frame_view && !IsThrottledFrameView()) {
398 FrameView* child_frame_view = ToFrameView(GetFrameViewBase());
399 // |childFrameView| is in another document, which could be 403 // |childFrameView| is in another document, which could be
400 // missing its LayoutView. TODO(jchaffraix): Ideally we should 404 // missing its LayoutView. TODO(jchaffraix): Ideally we should
401 // not need this code. 405 // not need this code.
402 if (LayoutView* child_layout_view = 406 if (LayoutView* child_layout_view =
403 ToLayoutView(LayoutAPIShim::LayoutObjectFrom( 407 ToLayoutView(LayoutAPIShim::LayoutObjectFrom(
404 child_frame_view->GetLayoutViewItem()))) { 408 child_frame_view->GetLayoutViewItem()))) {
405 PaintInvalidationState child_view_paint_invalidation_state( 409 PaintInvalidationState child_view_paint_invalidation_state(
406 paint_invalidation_state, *child_layout_view); 410 paint_invalidation_state, *child_layout_view);
407 child_frame_view->InvalidateTreeIfNeeded( 411 child_frame_view->InvalidateTreeIfNeeded(
408 child_view_paint_invalidation_state); 412 child_view_paint_invalidation_state);
409 } 413 }
410 } 414 }
411 415
412 LayoutReplaced::InvalidatePaintOfSubtreesIfNeeded(paint_invalidation_state); 416 LayoutReplaced::InvalidatePaintOfSubtreesIfNeeded(paint_invalidation_state);
413 } 417 }
414 418
415 bool LayoutPart::IsThrottledFrameView() const { 419 bool LayoutPart::IsThrottledFrameView() const {
416 if (!GetFrameViewBase() || !GetFrameViewBase()->IsFrameView()) 420 if (FrameView* frame_view = GetNodeFrameView())
417 return false; 421 return frame_view->ShouldThrottleRendering();
418 const FrameView* frame_view = ToFrameView(GetFrameViewBase()); 422 return false;
419 return frame_view->ShouldThrottleRendering();
420 } 423 }
421 424
422 } // namespace blink 425 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698