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

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

Issue 2764313002: Move plugins to be stored in HTMLPlugInElement. (Closed)
Patch Set: Created 3 years, 9 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 10 matching lines...) Expand all
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/FrameView.h" 28 #include "core/frame/FrameView.h"
29 #include "core/frame/LocalFrame.h" 29 #include "core/frame/LocalFrame.h"
30 #include "core/html/HTMLFrameElementBase.h" 30 #include "core/html/HTMLFrameElementBase.h"
31 #include "core/html/HTMLPlugInElement.h"
31 #include "core/layout/HitTestResult.h" 32 #include "core/layout/HitTestResult.h"
32 #include "core/layout/LayoutAnalyzer.h" 33 #include "core/layout/LayoutAnalyzer.h"
33 #include "core/layout/LayoutView.h" 34 #include "core/layout/LayoutView.h"
34 #include "core/layout/api/LayoutAPIShim.h" 35 #include "core/layout/api/LayoutAPIShim.h"
35 #include "core/layout/api/LayoutViewItem.h" 36 #include "core/layout/api/LayoutViewItem.h"
36 #include "core/paint/PartPainter.h" 37 #include "core/paint/PartPainter.h"
37 #include "core/plugins/PluginView.h" 38 #include "core/plugins/PluginView.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 FrameViewBase* LayoutPart::frameViewBase() const { 92 FrameViewBase* LayoutPart::frameViewBase() const {
92 // Plugin FrameViewBases are stored in their DOM node. 93 // Plugin FrameViewBases are stored in their DOM node.
93 Element* element = toElement(node()); 94 Element* element = toElement(node());
94 95
95 if (element && element->isFrameOwnerElement()) 96 if (element && element->isFrameOwnerElement())
96 return toHTMLFrameOwnerElement(element)->ownedWidget(); 97 return toHTMLFrameOwnerElement(element)->ownedWidget();
97 98
98 return nullptr; 99 return nullptr;
99 } 100 }
100 101
102 PluginView* LayoutPart::plugin() const {
103 // Plugins are stored in their DOM node.
104 return node() && isHTMLPlugInElement(node())
105 ? toHTMLPlugInElement(node())->plugin()
106 : nullptr;
107 }
108
101 PaintLayerType LayoutPart::layerTypeRequired() const { 109 PaintLayerType LayoutPart::layerTypeRequired() const {
102 PaintLayerType type = LayoutReplaced::layerTypeRequired(); 110 PaintLayerType type = LayoutReplaced::layerTypeRequired();
103 if (type != NoPaintLayer) 111 if (type != NoPaintLayer)
104 return type; 112 return type;
105 return ForcedPaintLayer; 113 return ForcedPaintLayer;
106 } 114 }
107 115
108 bool LayoutPart::requiresAcceleratedCompositing() const { 116 bool LayoutPart::requiresAcceleratedCompositing() const {
109 // There are two general cases in which we can return true. First, if this is 117 // There are two general cases in which we can return true. First, if this is
110 // a plugin LayoutObject and the plugin has a layer, then we need a layer. 118 // a plugin LayoutObject and the plugin has a layer, then we need a layer.
111 // Second, if this is a LayoutObject with a contentDocument and that document 119 // Second, if this is a LayoutObject with a contentDocument and that document
112 // needs a layer, then we need a layer. 120 // needs a layer, then we need a layer.
113 if (frameViewBase() && frameViewBase()->isPluginView() && 121 PluginView* pluginView = plugin();
114 toPluginView(frameViewBase())->platformLayer()) 122 if (pluginView && pluginView->platformLayer())
115 return true; 123 return true;
116 124
117 if (!node() || !node()->isFrameOwnerElement()) 125 if (!node() || !node()->isFrameOwnerElement())
118 return false; 126 return false;
119 127
120 HTMLFrameOwnerElement* element = toHTMLFrameOwnerElement(node()); 128 HTMLFrameOwnerElement* element = toHTMLFrameOwnerElement(node());
121 if (element->contentFrame() && element->contentFrame()->isRemoteFrame()) 129 if (element->contentFrame() && element->contentFrame()->isRemoteFrame())
122 return true; 130 return true;
123 131
124 if (Document* contentDocument = element->contentDocument()) { 132 if (Document* contentDocument = element->contentDocument()) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 LayoutReplaced::styleDidChange(diff, oldStyle); 248 LayoutReplaced::styleDidChange(diff, oldStyle);
241 FrameViewBase* frameViewBase = this->frameViewBase(); 249 FrameViewBase* frameViewBase = this->frameViewBase();
242 250
243 if (!frameViewBase) 251 if (!frameViewBase)
244 return; 252 return;
245 253
246 // If the iframe has custom scrollbars, recalculate their style. 254 // If the iframe has custom scrollbars, recalculate their style.
247 if (frameViewBase && frameViewBase->isFrameView()) 255 if (frameViewBase && frameViewBase->isFrameView())
248 toFrameView(frameViewBase)->recalculateCustomScrollbarStyle(); 256 toFrameView(frameViewBase)->recalculateCustomScrollbarStyle();
249 257
258 // TODO(joelhockey): Does this need separate code for plugins?
haraken 2017/03/22 15:32:33 I guess yes. Can you add CHECK(!(node() && isHTML
joelhockey 2017/03/27 06:42:21 Thanks, that is a helpful approach. It showed tha
250 if (style()->visibility() != EVisibility::kVisible) { 259 if (style()->visibility() != EVisibility::kVisible) {
251 frameViewBase->hide(); 260 frameViewBase->hide();
haraken 2017/03/22 15:32:33 One way to handle both the FrameViewBase case and
joelhockey 2017/03/27 06:42:21 This function will be ok to take FrameViewBase as
haraken 2017/03/28 07:39:41 However, you're planning to remove the inheritance
joelhockey 2017/03/28 22:56:23 Yes, I will remove the inheritance from FrameView
haraken 2017/03/29 11:04:46 Sounds like a nice plan.
252 } else { 261 } else {
253 frameViewBase->show(); 262 frameViewBase->show();
254 } 263 }
255 } 264 }
256 265
257 void LayoutPart::layout() { 266 void LayoutPart::layout() {
258 ASSERT(needsLayout()); 267 ASSERT(needsLayout());
259 LayoutAnalyzer::Scope analyzer(*this); 268 LayoutAnalyzer::Scope analyzer(*this);
260 clearNeedsLayout(); 269 clearNeedsLayout();
261 } 270 }
262 271
263 void LayoutPart::paint(const PaintInfo& paintInfo, 272 void LayoutPart::paint(const PaintInfo& paintInfo,
264 const LayoutPoint& paintOffset) const { 273 const LayoutPoint& paintOffset) const {
265 PartPainter(*this).paint(paintInfo, paintOffset); 274 PartPainter(*this).paint(paintInfo, paintOffset);
266 } 275 }
267 276
268 void LayoutPart::paintContents(const PaintInfo& paintInfo, 277 void LayoutPart::paintContents(const PaintInfo& paintInfo,
269 const LayoutPoint& paintOffset) const { 278 const LayoutPoint& paintOffset) const {
270 PartPainter(*this).paintContents(paintInfo, paintOffset); 279 PartPainter(*this).paintContents(paintInfo, paintOffset);
271 } 280 }
272 281
273 CursorDirective LayoutPart::getCursor(const LayoutPoint& point, 282 CursorDirective LayoutPart::getCursor(const LayoutPoint& point,
274 Cursor& cursor) const { 283 Cursor& cursor) const {
275 if (frameViewBase() && frameViewBase()->isPluginView()) { 284 if (plugin()) {
276 // A plugin is responsible for setting the cursor when the pointer is over 285 // A plugin is responsible for setting the cursor when the pointer is over
277 // it. 286 // it.
278 return DoNotSetCursor; 287 return DoNotSetCursor;
279 } 288 }
280 return LayoutReplaced::getCursor(point, cursor); 289 return LayoutReplaced::getCursor(point, cursor);
281 } 290 }
282 291
283 LayoutRect LayoutPart::replacedContentRect() const { 292 LayoutRect LayoutPart::replacedContentRect() const {
284 // We don't propagate sub-pixel into sub-frame layout, in other words, the 293 // We don't propagate sub-pixel into sub-frame layout, in other words, the
285 // rect is snapped at the document boundary, and sub-pixel movement could 294 // rect is snapped at the document boundary, and sub-pixel movement could
286 // cause the sub-frame to layout due to the 1px snap difference. In order to 295 // cause the sub-frame to layout due to the 1px snap difference. In order to
287 // avoid that, the size of sub-frame is rounded in advance. 296 // avoid that, the size of sub-frame is rounded in advance.
288 LayoutRect sizeRoundedRect = contentBoxRect(); 297 LayoutRect sizeRoundedRect = contentBoxRect();
289 sizeRoundedRect.setSize(LayoutSize(roundedIntSize(sizeRoundedRect.size()))); 298 sizeRoundedRect.setSize(LayoutSize(roundedIntSize(sizeRoundedRect.size())));
290 return sizeRoundedRect; 299 return sizeRoundedRect;
291 } 300 }
292 301
293 void LayoutPart::updateOnWidgetChange() { 302 void LayoutPart::updateOnWidgetChange() {
294 FrameViewBase* frameViewBase = this->frameViewBase(); 303 FrameViewBase* frameViewBase = this->frameViewBase();
295 if (!frameViewBase) 304 if (!frameViewBase)
296 return; 305 return;
297 306
298 if (!style()) 307 if (!style())
299 return; 308 return;
300 309
301 if (!needsLayout()) 310 if (!needsLayout())
302 updateGeometryInternal(); 311 updateGeometryInternal();
303 312
313 // TODO(joelhockey): Does this need special handling for plugin?
dcheng 2017/03/23 07:21:42 I think this also needs to be handled: the main su
joelhockey 2017/03/27 06:42:21 Thanks. I just noticed how the impl forwards the
304 if (style()->visibility() != EVisibility::kVisible) { 314 if (style()->visibility() != EVisibility::kVisible) {
305 frameViewBase->hide(); 315 frameViewBase->hide();
306 } else { 316 } else {
307 frameViewBase->show(); 317 frameViewBase->show();
308 // FIXME: Why do we issue a full paint invalidation in this case, but not 318 // FIXME: Why do we issue a full paint invalidation in this case, but not
309 // the other? 319 // the other?
310 setShouldDoFullPaintInvalidation(); 320 setShouldDoFullPaintInvalidation();
311 } 321 }
312 } 322 }
313 323
314 void LayoutPart::updateGeometry() { 324 void LayoutPart::updateGeometry() {
315 FrameViewBase* frameViewBase = this->frameViewBase(); 325 FrameViewBase* frameViewBase = this->frameViewBase();
316 if (!frameViewBase || 326 if (!frameViewBase ||
317 !node()) // Check the node in case destroy() has been called. 327 !node()) // Check the node in case destroy() has been called.
318 return; 328 return;
319 329
320 LayoutRect newFrame = replacedContentRect(); 330 LayoutRect newFrame = replacedContentRect();
321 DCHECK(newFrame.size() == roundedIntSize(newFrame.size())); 331 DCHECK(newFrame.size() == roundedIntSize(newFrame.size()));
332 // TODO(joelhockey): Does this need special handling for plugin?
322 bool boundsWillChange = 333 bool boundsWillChange =
323 LayoutSize(frameViewBase->frameRect().size()) != newFrame.size(); 334 LayoutSize(frameViewBase->frameRect().size()) != newFrame.size();
324 335
325 FrameView* frameView = 336 FrameView* frameView =
326 frameViewBase->isFrameView() ? toFrameView(frameViewBase) : nullptr; 337 frameViewBase->isFrameView() ? toFrameView(frameViewBase) : nullptr;
327 338
328 // If frame bounds are changing mark the view for layout. Also check the 339 // If frame bounds are changing mark the view for layout. Also check the
329 // frame's page to make sure that the frame isn't in the process of being 340 // frame's page to make sure that the frame isn't in the process of being
330 // destroyed. If iframe scrollbars needs reconstruction from native to custom 341 // destroyed. If iframe scrollbars needs reconstruction from native to custom
331 // scrollbar, then also we need to layout the frameview. 342 // scrollbar, then also we need to layout the frameview.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // FrameView::updateViewportIntersectionIfNeeded() 376 // FrameView::updateViewportIntersectionIfNeeded()
366 // RemoteFrameView::frameRectsChanged(). 377 // RemoteFrameView::frameRectsChanged().
367 // WebPluginContainerImpl::reportGeometry() 378 // WebPluginContainerImpl::reportGeometry()
368 // TODO(trchen): Remove this hack once we fixed all callers. 379 // TODO(trchen): Remove this hack once we fixed all callers.
369 FloatRect absoluteBoundingBox = 380 FloatRect absoluteBoundingBox =
370 localToAbsoluteQuad(FloatRect(replacedContentRect())).boundingBox(); 381 localToAbsoluteQuad(FloatRect(replacedContentRect())).boundingBox();
371 frameRect.setLocation(roundedIntPoint(absoluteBoundingBox.location())); 382 frameRect.setLocation(roundedIntPoint(absoluteBoundingBox.location()));
372 383
373 // Why is the protector needed? 384 // Why is the protector needed?
374 RefPtr<LayoutPart> protector(this); 385 RefPtr<LayoutPart> protector(this);
386 // TODO(joelhockey): Does this need special handling for plugin?
375 frameViewBase->setFrameRect(frameRect); 387 frameViewBase->setFrameRect(frameRect);
376 } 388 }
377 389
378 void LayoutPart::invalidatePaintOfSubtreesIfNeeded( 390 void LayoutPart::invalidatePaintOfSubtreesIfNeeded(
379 const PaintInvalidationState& paintInvalidationState) { 391 const PaintInvalidationState& paintInvalidationState) {
380 if (frameViewBase() && frameViewBase()->isFrameView() && 392 if (frameViewBase() && frameViewBase()->isFrameView() &&
381 !isThrottledFrameView()) { 393 !isThrottledFrameView()) {
382 FrameView* childFrameView = toFrameView(frameViewBase()); 394 FrameView* childFrameView = toFrameView(frameViewBase());
383 // |childFrameView| is in another document, which could be 395 // |childFrameView| is in another document, which could be
384 // missing its LayoutView. TODO(jchaffraix): Ideally we should 396 // missing its LayoutView. TODO(jchaffraix): Ideally we should
(...skipping 11 matching lines...) Expand all
396 } 408 }
397 409
398 bool LayoutPart::isThrottledFrameView() const { 410 bool LayoutPart::isThrottledFrameView() const {
399 if (!frameViewBase() || !frameViewBase()->isFrameView()) 411 if (!frameViewBase() || !frameViewBase()->isFrameView())
400 return false; 412 return false;
401 const FrameView* frameView = toFrameView(frameViewBase()); 413 const FrameView* frameView = toFrameView(frameViewBase());
402 return frameView->shouldThrottleRendering(); 414 return frameView->shouldThrottleRendering();
403 } 415 }
404 416
405 } // namespace blink 417 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698