OLD | NEW |
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 Loading... |
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::ChildFrameView() 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 Loading... |
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 = ChildFrameView(); |
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 LayoutViewItem child_root_item = frame_view->GetLayoutViewItem(); |
195 LayoutViewItem child_root_item = child_frame_view->GetLayoutViewItem(); | |
196 | 200 |
197 if (VisibleToHitTestRequest(result.GetHitTestRequest()) && | 201 if (VisibleToHitTestRequest(result.GetHitTestRequest()) && |
198 !child_root_item.IsNull()) { | 202 !child_root_item.IsNull()) { |
199 LayoutPoint adjusted_location = accumulated_offset + Location(); | 203 LayoutPoint adjusted_location = accumulated_offset + Location(); |
200 LayoutPoint content_offset = | 204 LayoutPoint content_offset = LayoutPoint(BorderLeft() + PaddingLeft(), |
201 LayoutPoint(BorderLeft() + PaddingLeft(), | 205 BorderTop() + PaddingTop()) - |
202 BorderTop() + PaddingTop()) - | 206 LayoutSize(frame_view->ScrollOffsetInt()); |
203 LayoutSize(child_frame_view->ScrollOffsetInt()); | |
204 HitTestLocation new_hit_test_location( | 207 HitTestLocation new_hit_test_location( |
205 location_in_container, -adjusted_location - content_offset); | 208 location_in_container, -adjusted_location - content_offset); |
206 HitTestRequest new_hit_test_request(result.GetHitTestRequest().GetType() | | 209 HitTestRequest new_hit_test_request(result.GetHitTestRequest().GetType() | |
207 HitTestRequest::kChildFrameHitTest); | 210 HitTestRequest::kChildFrameHitTest); |
208 HitTestResult child_frame_result(new_hit_test_request, | 211 HitTestResult child_frame_result(new_hit_test_request, |
209 new_hit_test_location); | 212 new_hit_test_location); |
210 | 213 |
211 // The frame's layout and style must be up to date if we reach here. | 214 // The frame's layout and style must be up to date if we reach here. |
212 bool is_inside_child_frame = | 215 bool is_inside_child_frame = |
213 child_root_item.HitTestNoLifecycleUpdate(child_frame_result); | 216 child_root_item.HitTestNoLifecycleUpdate(child_frame_result); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 LocalToAbsoluteQuad(FloatRect(ReplacedContentRect())).BoundingBox(); | 389 LocalToAbsoluteQuad(FloatRect(ReplacedContentRect())).BoundingBox(); |
387 frame_rect.SetLocation(RoundedIntPoint(absolute_bounding_box.Location())); | 390 frame_rect.SetLocation(RoundedIntPoint(absolute_bounding_box.Location())); |
388 | 391 |
389 // Why is the protector needed? | 392 // Why is the protector needed? |
390 RefPtr<LayoutPart> protector(this); | 393 RefPtr<LayoutPart> protector(this); |
391 frame_view_base.SetFrameRect(frame_rect); | 394 frame_view_base.SetFrameRect(frame_rect); |
392 } | 395 } |
393 | 396 |
394 void LayoutPart::InvalidatePaintOfSubtreesIfNeeded( | 397 void LayoutPart::InvalidatePaintOfSubtreesIfNeeded( |
395 const PaintInvalidationState& paint_invalidation_state) { | 398 const PaintInvalidationState& paint_invalidation_state) { |
396 if (GetFrameViewBase() && GetFrameViewBase()->IsFrameView() && | 399 FrameView* frame_view = ChildFrameView(); |
397 !IsThrottledFrameView()) { | 400 if (frame_view && !IsThrottledFrameView()) { |
398 FrameView* child_frame_view = ToFrameView(GetFrameViewBase()); | |
399 // |childFrameView| is in another document, which could be | 401 // |childFrameView| is in another document, which could be |
400 // missing its LayoutView. TODO(jchaffraix): Ideally we should | 402 // missing its LayoutView. TODO(jchaffraix): Ideally we should |
401 // not need this code. | 403 // not need this code. |
402 if (LayoutView* child_layout_view = | 404 if (LayoutView* child_layout_view = ToLayoutView( |
403 ToLayoutView(LayoutAPIShim::LayoutObjectFrom( | 405 LayoutAPIShim::LayoutObjectFrom(frame_view->GetLayoutViewItem()))) { |
404 child_frame_view->GetLayoutViewItem()))) { | |
405 PaintInvalidationState child_view_paint_invalidation_state( | 406 PaintInvalidationState child_view_paint_invalidation_state( |
406 paint_invalidation_state, *child_layout_view); | 407 paint_invalidation_state, *child_layout_view); |
407 child_frame_view->InvalidateTreeIfNeeded( | 408 frame_view->InvalidateTreeIfNeeded(child_view_paint_invalidation_state); |
408 child_view_paint_invalidation_state); | |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 LayoutReplaced::InvalidatePaintOfSubtreesIfNeeded(paint_invalidation_state); | 412 LayoutReplaced::InvalidatePaintOfSubtreesIfNeeded(paint_invalidation_state); |
413 } | 413 } |
414 | 414 |
415 bool LayoutPart::IsThrottledFrameView() const { | 415 bool LayoutPart::IsThrottledFrameView() const { |
416 if (!GetFrameViewBase() || !GetFrameViewBase()->IsFrameView()) | 416 if (FrameView* frame_view = ChildFrameView()) |
417 return false; | 417 return frame_view->ShouldThrottleRendering(); |
418 const FrameView* frame_view = ToFrameView(GetFrameViewBase()); | 418 return false; |
419 return frame_view->ShouldThrottleRendering(); | |
420 } | 419 } |
421 | 420 |
422 } // namespace blink | 421 } // namespace blink |
OLD | NEW |