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

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

Issue 2814643003: Remove FrameViewBase as base class of PluginView. (Closed)
Patch Set: Merge after dependency CL 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
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 * 22 *
23 */ 23 */
24 24
25 #include "core/layout/LayoutPart.h" 25 #include "core/layout/LayoutPart.h"
26 26
27 #include "core/dom/AXObjectCache.h" 27 #include "core/dom/AXObjectCache.h"
28 #include "core/frame/FrameOrPlugin.h"
28 #include "core/frame/FrameView.h" 29 #include "core/frame/FrameView.h"
29 #include "core/frame/LocalFrame.h" 30 #include "core/frame/LocalFrame.h"
31 #include "core/frame/RemoteFrameView.h"
30 #include "core/html/HTMLFrameElementBase.h" 32 #include "core/html/HTMLFrameElementBase.h"
31 #include "core/html/HTMLPlugInElement.h" 33 #include "core/html/HTMLPlugInElement.h"
32 #include "core/layout/HitTestResult.h" 34 #include "core/layout/HitTestResult.h"
33 #include "core/layout/LayoutAnalyzer.h" 35 #include "core/layout/LayoutAnalyzer.h"
34 #include "core/layout/LayoutView.h" 36 #include "core/layout/LayoutView.h"
35 #include "core/layout/api/LayoutAPIShim.h" 37 #include "core/layout/api/LayoutAPIShim.h"
36 #include "core/layout/api/LayoutViewItem.h" 38 #include "core/layout/api/LayoutViewItem.h"
37 #include "core/paint/PartPainter.h" 39 #include "core/paint/PartPainter.h"
38 #include "core/plugins/PluginView.h" 40 #include "core/plugins/PluginView.h"
39 41
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return nullptr; 103 return nullptr;
102 } 104 }
103 105
104 PluginView* LayoutPart::Plugin() const { 106 PluginView* LayoutPart::Plugin() const {
105 // Plugins are stored in HTMLPlugInElement node. 107 // Plugins are stored in HTMLPlugInElement node.
106 Node* node = GetNode(); 108 Node* node = GetNode();
107 return node && IsHTMLPlugInElement(node) ? ToHTMLPlugInElement(node)->Plugin() 109 return node && IsHTMLPlugInElement(node) ? ToHTMLPlugInElement(node)->Plugin()
108 : nullptr; 110 : nullptr;
109 } 111 }
110 112
111 FrameViewBase* LayoutPart::PluginOrFrame() const { 113 FrameOrPlugin* LayoutPart::GetFrameOrPlugin() const {
112 FrameViewBase* result = nullptr;
113 Node* node = GetNode(); 114 Node* node = GetNode();
114 if (node && node->IsFrameOwnerElement()) 115 if (node && node->IsFrameOwnerElement()) {
115 result = ToHTMLFrameOwnerElement(node)->OwnedWidget(); 116 FrameViewBase* frame_view_base =
116 if (!result) 117 ToHTMLFrameOwnerElement(node)->OwnedWidget();
117 result = Plugin(); 118 if (frame_view_base) {
118 return result; 119 if (frame_view_base->IsFrameView())
120 return ToFrameView(frame_view_base);
121 if (frame_view_base->IsRemoteFrameView())
122 return ToRemoteFrameView(frame_view_base);
dcheng 2017/04/17 21:09:05 This is another example of something that would be
joelhockey 2017/04/18 00:42:41 That is true, but it will be even better when Fram
123 // Must be either FrameView or RemoteFrameView.
124 NOTREACHED();
125 }
126 }
127 return Plugin();
119 } 128 }
120 129
121 PaintLayerType LayoutPart::LayerTypeRequired() const { 130 PaintLayerType LayoutPart::LayerTypeRequired() const {
122 PaintLayerType type = LayoutReplaced::LayerTypeRequired(); 131 PaintLayerType type = LayoutReplaced::LayerTypeRequired();
123 if (type != kNoPaintLayer) 132 if (type != kNoPaintLayer)
124 return type; 133 return type;
125 return kForcedPaintLayer; 134 return kForcedPaintLayer;
126 } 135 }
127 136
128 bool LayoutPart::RequiresAcceleratedCompositing() const { 137 bool LayoutPart::RequiresAcceleratedCompositing() const {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 261
253 CompositingReasons LayoutPart::AdditionalCompositingReasons() const { 262 CompositingReasons LayoutPart::AdditionalCompositingReasons() const {
254 if (RequiresAcceleratedCompositing()) 263 if (RequiresAcceleratedCompositing())
255 return kCompositingReasonIFrame; 264 return kCompositingReasonIFrame;
256 return kCompositingReasonNone; 265 return kCompositingReasonNone;
257 } 266 }
258 267
259 void LayoutPart::StyleDidChange(StyleDifference diff, 268 void LayoutPart::StyleDidChange(StyleDifference diff,
260 const ComputedStyle* old_style) { 269 const ComputedStyle* old_style) {
261 LayoutReplaced::StyleDidChange(diff, old_style); 270 LayoutReplaced::StyleDidChange(diff, old_style);
262 FrameViewBase* frame_view_base = this->PluginOrFrame(); 271 FrameOrPlugin* frame_or_plugin = GetFrameOrPlugin();
263 if (!frame_view_base) 272 if (!frame_or_plugin)
264 return; 273 return;
265 274
266 // If the iframe has custom scrollbars, recalculate their style. 275 // If the iframe has custom scrollbars, recalculate their style.
267 if (frame_view_base->IsFrameView()) 276 if (FrameView* frame_view = ChildFrameView())
268 ToFrameView(frame_view_base)->RecalculateCustomScrollbarStyle(); 277 frame_view->RecalculateCustomScrollbarStyle();
269 278
270 if (Style()->Visibility() != EVisibility::kVisible) { 279 if (Style()->Visibility() != EVisibility::kVisible) {
271 frame_view_base->Hide(); 280 frame_or_plugin->Hide();
272 } else { 281 } else {
273 frame_view_base->Show(); 282 frame_or_plugin->Show();
274 } 283 }
275 } 284 }
276 285
277 void LayoutPart::UpdateLayout() { 286 void LayoutPart::UpdateLayout() {
278 DCHECK(NeedsLayout()); 287 DCHECK(NeedsLayout());
279 LayoutAnalyzer::Scope analyzer(*this); 288 LayoutAnalyzer::Scope analyzer(*this);
280 ClearNeedsLayout(); 289 ClearNeedsLayout();
281 } 290 }
282 291
283 void LayoutPart::Paint(const PaintInfo& paint_info, 292 void LayoutPart::Paint(const PaintInfo& paint_info,
(...skipping 21 matching lines...) Expand all
305 // rect is snapped at the document boundary, and sub-pixel movement could 314 // rect is snapped at the document boundary, and sub-pixel movement could
306 // cause the sub-frame to layout due to the 1px snap difference. In order to 315 // cause the sub-frame to layout due to the 1px snap difference. In order to
307 // avoid that, the size of sub-frame is rounded in advance. 316 // avoid that, the size of sub-frame is rounded in advance.
308 LayoutRect size_rounded_rect = ContentBoxRect(); 317 LayoutRect size_rounded_rect = ContentBoxRect();
309 size_rounded_rect.SetSize( 318 size_rounded_rect.SetSize(
310 LayoutSize(RoundedIntSize(size_rounded_rect.Size()))); 319 LayoutSize(RoundedIntSize(size_rounded_rect.Size())));
311 return size_rounded_rect; 320 return size_rounded_rect;
312 } 321 }
313 322
314 void LayoutPart::UpdateOnWidgetChange() { 323 void LayoutPart::UpdateOnWidgetChange() {
315 FrameViewBase* frame_view_base = this->PluginOrFrame(); 324 FrameOrPlugin* frame_or_plugin = GetFrameOrPlugin();
316 if (!frame_view_base) 325 if (!frame_or_plugin)
317 return; 326 return;
318 327
319 if (!Style()) 328 if (!Style())
320 return; 329 return;
321 330
322 if (!NeedsLayout()) 331 if (!NeedsLayout())
323 UpdateGeometryInternal(*frame_view_base); 332 UpdateGeometryInternal(*frame_or_plugin);
324 333
325 if (Style()->Visibility() != EVisibility::kVisible) { 334 if (Style()->Visibility() != EVisibility::kVisible) {
326 frame_view_base->Hide(); 335 frame_or_plugin->Hide();
327 } else { 336 } else {
328 frame_view_base->Show(); 337 frame_or_plugin->Show();
329 // FIXME: Why do we issue a full paint invalidation in this case, but not 338 // FIXME: Why do we issue a full paint invalidation in this case, but not
330 // the other? 339 // the other?
331 SetShouldDoFullPaintInvalidation(); 340 SetShouldDoFullPaintInvalidation();
332 } 341 }
333 } 342 }
334 343
335 void LayoutPart::UpdateGeometry() { 344 void LayoutPart::UpdateGeometry() {
336 FrameViewBase* frame_view_base = this->PluginOrFrame(); 345 FrameOrPlugin* frame_or_plugin = GetFrameOrPlugin();
337 if (!frame_view_base || 346 if (!frame_or_plugin)
338 !GetNode()) // Check the node in case destroy() has been called.
339 return; 347 return;
340 348
341 LayoutRect new_frame = ReplacedContentRect(); 349 LayoutRect new_frame = ReplacedContentRect();
342 DCHECK(new_frame.Size() == RoundedIntSize(new_frame.Size())); 350 DCHECK(new_frame.Size() == RoundedIntSize(new_frame.Size()));
343 bool bounds_will_change = 351 bool bounds_will_change =
344 LayoutSize(frame_view_base->FrameRect().Size()) != new_frame.Size(); 352 LayoutSize(frame_or_plugin->FrameRect().Size()) != new_frame.Size();
345
346 FrameView* frame_view =
347 frame_view_base->IsFrameView() ? ToFrameView(frame_view_base) : nullptr;
348 353
349 // If frame bounds are changing mark the view for layout. Also check the 354 // If frame bounds are changing mark the view for layout. Also check the
350 // frame's page to make sure that the frame isn't in the process of being 355 // frame's page to make sure that the frame isn't in the process of being
351 // destroyed. If iframe scrollbars needs reconstruction from native to custom 356 // destroyed. If iframe scrollbars needs reconstruction from native to custom
352 // scrollbar, then also we need to layout the frameview. 357 // scrollbar, then also we need to layout the frameview.
358 FrameView* frame_view = ChildFrameView();
353 if (frame_view && frame_view->GetFrame().GetPage() && 359 if (frame_view && frame_view->GetFrame().GetPage() &&
354 (bounds_will_change || frame_view->NeedsScrollbarReconstruction())) 360 (bounds_will_change || frame_view->NeedsScrollbarReconstruction()))
355 frame_view->SetNeedsLayout(); 361 frame_view->SetNeedsLayout();
356 362
357 UpdateGeometryInternal(*frame_view_base); 363 UpdateGeometryInternal(*frame_or_plugin);
358 364
359 // If view needs layout, either because bounds have changed or possibly 365 // If view needs layout, either because bounds have changed or possibly
360 // indicating content size is wrong, we have to do a layout to set the right 366 // indicating content size is wrong, we have to do a layout to set the right
361 // FrameViewBase size. 367 // FrameView size.
362 if (frame_view && frame_view->NeedsLayout() && 368 if (frame_view && frame_view->NeedsLayout() &&
363 frame_view->GetFrame().GetPage()) 369 frame_view->GetFrame().GetPage())
364 frame_view->UpdateLayout(); 370 frame_view->UpdateLayout();
365 371
366 frame_view_base->GeometryMayHaveChanged(); 372 if (PluginView* plugin = Plugin())
373 plugin->GeometryMayHaveChanged();
367 } 374 }
368 375
369 void LayoutPart::UpdateGeometryInternal(FrameViewBase& frame_view_base) { 376 void LayoutPart::UpdateGeometryInternal(FrameOrPlugin& frame_or_plugin) {
370 // Ignore transform here, as we only care about the sub-pixel accumulation. 377 // Ignore transform here, as we only care about the sub-pixel accumulation.
371 // TODO(trchen): What about multicol? Need a LayoutBox function to query 378 // TODO(trchen): What about multicol? Need a LayoutBox function to query
372 // sub-pixel accumulation. 379 // sub-pixel accumulation.
373 LayoutPoint absolute_location(LocalToAbsolute(FloatPoint())); 380 LayoutPoint absolute_location(LocalToAbsolute(FloatPoint()));
374 LayoutRect absolute_replaced_rect = ReplacedContentRect(); 381 LayoutRect absolute_replaced_rect = ReplacedContentRect();
375 absolute_replaced_rect.MoveBy(absolute_location); 382 absolute_replaced_rect.MoveBy(absolute_location);
376 383
377 IntRect frame_rect(IntPoint(), 384 IntRect frame_rect(IntPoint(),
378 PixelSnappedIntRect(absolute_replaced_rect).Size()); 385 PixelSnappedIntRect(absolute_replaced_rect).Size());
379 // Normally the location of the frame rect is ignored by the painter, but 386 // Normally the location of the frame rect is ignored by the painter, but
380 // currently it is still used by a family of coordinate conversion function in 387 // currently it is still used by a family of coordinate conversion function in
381 // FrameViewBase/FrameView. This is incorrect because coordinate conversion 388 // FrameView. This is incorrect because coordinate conversion
382 // needs to take transform and into account. A few callers still use the 389 // needs to take transform and into account. A few callers still use the
383 // family of conversion function, including but not exhaustive: 390 // family of conversion function, including but not exhaustive:
384 // FrameView::updateViewportIntersectionIfNeeded() 391 // FrameView::updateViewportIntersectionIfNeeded()
385 // RemoteFrameView::frameRectsChanged(). 392 // RemoteFrameView::frameRectsChanged().
386 // WebPluginContainerImpl::reportGeometry() 393 // WebPluginContainerImpl::reportGeometry()
387 // TODO(trchen): Remove this hack once we fixed all callers. 394 // TODO(trchen): Remove this hack once we fixed all callers.
388 FloatRect absolute_bounding_box = 395 FloatRect absolute_bounding_box =
389 LocalToAbsoluteQuad(FloatRect(ReplacedContentRect())).BoundingBox(); 396 LocalToAbsoluteQuad(FloatRect(ReplacedContentRect())).BoundingBox();
390 frame_rect.SetLocation(RoundedIntPoint(absolute_bounding_box.Location())); 397 frame_rect.SetLocation(RoundedIntPoint(absolute_bounding_box.Location()));
391 398
392 // Why is the protector needed? 399 // Why is the protector needed?
393 RefPtr<LayoutPart> protector(this); 400 RefPtr<LayoutPart> protector(this);
394 frame_view_base.SetFrameRect(frame_rect); 401 frame_or_plugin.SetFrameRect(frame_rect);
395 } 402 }
396 403
397 void LayoutPart::InvalidatePaintOfSubtreesIfNeeded( 404 void LayoutPart::InvalidatePaintOfSubtreesIfNeeded(
398 const PaintInvalidationState& paint_invalidation_state) { 405 const PaintInvalidationState& paint_invalidation_state) {
399 FrameView* frame_view = ChildFrameView(); 406 FrameView* frame_view = ChildFrameView();
400 if (frame_view && !IsThrottledFrameView()) { 407 if (frame_view && !IsThrottledFrameView()) {
401 // |childFrameView| is in another document, which could be 408 // |childFrameView| is in another document, which could be
402 // missing its LayoutView. TODO(jchaffraix): Ideally we should 409 // missing its LayoutView. TODO(jchaffraix): Ideally we should
403 // not need this code. 410 // not need this code.
404 if (LayoutView* child_layout_view = ToLayoutView( 411 if (LayoutView* child_layout_view = ToLayoutView(
405 LayoutAPIShim::LayoutObjectFrom(frame_view->GetLayoutViewItem()))) { 412 LayoutAPIShim::LayoutObjectFrom(frame_view->GetLayoutViewItem()))) {
406 PaintInvalidationState child_view_paint_invalidation_state( 413 PaintInvalidationState child_view_paint_invalidation_state(
407 paint_invalidation_state, *child_layout_view); 414 paint_invalidation_state, *child_layout_view);
408 frame_view->InvalidateTreeIfNeeded(child_view_paint_invalidation_state); 415 frame_view->InvalidateTreeIfNeeded(child_view_paint_invalidation_state);
409 } 416 }
410 } 417 }
411 418
412 LayoutReplaced::InvalidatePaintOfSubtreesIfNeeded(paint_invalidation_state); 419 LayoutReplaced::InvalidatePaintOfSubtreesIfNeeded(paint_invalidation_state);
413 } 420 }
414 421
415 bool LayoutPart::IsThrottledFrameView() const { 422 bool LayoutPart::IsThrottledFrameView() const {
416 if (FrameView* frame_view = ChildFrameView()) 423 if (FrameView* frame_view = ChildFrameView())
417 return frame_view->ShouldThrottleRendering(); 424 return frame_view->ShouldThrottleRendering();
418 return false; 425 return false;
419 } 426 }
420 427
421 } // namespace blink 428 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698