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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutPart.cpp

Issue 2764313002: Move plugins to be stored in HTMLPlugInElement. (Closed)
Patch Set: Rebase and merge 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutPart.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutPart.cpp b/third_party/WebKit/Source/core/layout/LayoutPart.cpp
index 9078c43ead331db2c248178d7033e6bdbb811f39..cfdf3384d6a010c7db39c11137dee240b1ce5c5e 100644
--- a/third_party/WebKit/Source/core/layout/LayoutPart.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutPart.cpp
@@ -28,6 +28,7 @@
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLFrameElementBase.h"
+#include "core/html/HTMLPlugInElement.h"
#include "core/layout/HitTestResult.h"
#include "core/layout/LayoutAnalyzer.h"
#include "core/layout/LayoutView.h"
@@ -98,6 +99,20 @@ FrameViewBase* LayoutPart::frameViewBase() const {
return nullptr;
}
+PluginView* LayoutPart::plugin() const {
+ // Plugins are stored in their DOM node.
+ return node() && isHTMLPlugInElement(node())
+ ? toHTMLPlugInElement(node())->plugin()
+ : nullptr;
+}
+
+FrameViewBase* LayoutPart::pluginOrFrame() const {
+ FrameViewBase* result = plugin();
dcheng 2017/04/04 07:20:12 Nit: I would personally invert the order here (as
joelhockey 2017/04/04 23:39:05 Good point. Done
+ if (!result)
+ result = frameViewBase();
+ return result;
+}
+
PaintLayerType LayoutPart::layerTypeRequired() const {
PaintLayerType type = LayoutReplaced::layerTypeRequired();
if (type != NoPaintLayer)
@@ -110,8 +125,8 @@ bool LayoutPart::requiresAcceleratedCompositing() const {
// a plugin LayoutObject and the plugin has a layer, then we need a layer.
// Second, if this is a LayoutObject with a contentDocument and that document
// needs a layer, then we need a layer.
- if (frameViewBase() && frameViewBase()->isPluginView() &&
- toPluginView(frameViewBase())->platformLayer())
+ PluginView* pluginView = plugin();
+ if (pluginView && pluginView->platformLayer())
return true;
if (!node() || !node()->isFrameOwnerElement())
@@ -238,13 +253,12 @@ CompositingReasons LayoutPart::additionalCompositingReasons() const {
void LayoutPart::styleDidChange(StyleDifference diff,
const ComputedStyle* oldStyle) {
LayoutReplaced::styleDidChange(diff, oldStyle);
- FrameViewBase* frameViewBase = this->frameViewBase();
-
+ FrameViewBase* frameViewBase = this->pluginOrFrame();
if (!frameViewBase)
return;
// If the iframe has custom scrollbars, recalculate their style.
- if (frameViewBase && frameViewBase->isFrameView())
+ if (frameViewBase->isFrameView())
toFrameView(frameViewBase)->recalculateCustomScrollbarStyle();
if (style()->visibility() != EVisibility::kVisible) {
@@ -272,7 +286,7 @@ void LayoutPart::paintContents(const PaintInfo& paintInfo,
CursorDirective LayoutPart::getCursor(const LayoutPoint& point,
Cursor& cursor) const {
- if (frameViewBase() && frameViewBase()->isPluginView()) {
+ if (plugin()) {
// A plugin is responsible for setting the cursor when the pointer is over
// it.
return DoNotSetCursor;
@@ -291,7 +305,9 @@ LayoutRect LayoutPart::replacedContentRect() const {
}
void LayoutPart::updateOnWidgetChange() {
- FrameViewBase* frameViewBase = this->frameViewBase();
+ // TODO(joelhockey): When plugin no longer inherits from FrameViewBase, maybe
+ // make separate versions of this function for plugins and frames.
+ FrameViewBase* frameViewBase = this->pluginOrFrame();
if (!frameViewBase)
return;
@@ -299,7 +315,7 @@ void LayoutPart::updateOnWidgetChange() {
return;
if (!needsLayout())
- updateGeometryInternal();
+ updateGeometryInternal(*frameViewBase);
if (style()->visibility() != EVisibility::kVisible) {
frameViewBase->hide();
@@ -312,7 +328,9 @@ void LayoutPart::updateOnWidgetChange() {
}
void LayoutPart::updateGeometry() {
- FrameViewBase* frameViewBase = this->frameViewBase();
+ // TODO(joelhockey): When plugin no longer inherits from FrameViewBase, maybe
+ // make separate versions of this function for plugins and frames.
dcheng 2017/04/04 07:20:12 For line 308 and here, I have a bit of concern abo
joelhockey 2017/04/04 23:39:05 I've deleted these comments. I expect right now t
+ FrameViewBase* frameViewBase = this->pluginOrFrame();
if (!frameViewBase ||
!node()) // Check the node in case destroy() has been called.
return;
@@ -333,7 +351,7 @@ void LayoutPart::updateGeometry() {
(boundsWillChange || frameView->needsScrollbarReconstruction()))
frameView->setNeedsLayout();
- updateGeometryInternal();
+ updateGeometryInternal(*frameViewBase);
// If view needs layout, either because bounds have changed or possibly
// indicating content size is wrong, we have to do a layout to set the right
@@ -344,10 +362,7 @@ void LayoutPart::updateGeometry() {
frameViewBase->geometryMayHaveChanged();
}
-void LayoutPart::updateGeometryInternal() {
- FrameViewBase* frameViewBase = this->frameViewBase();
- DCHECK(frameViewBase);
-
+void LayoutPart::updateGeometryInternal(FrameViewBase& frameViewBase) {
// Ignore transform here, as we only care about the sub-pixel accumulation.
// TODO(trchen): What about multicol? Need a LayoutBox function to query
// sub-pixel accumulation.
@@ -372,7 +387,7 @@ void LayoutPart::updateGeometryInternal() {
// Why is the protector needed?
RefPtr<LayoutPart> protector(this);
- frameViewBase->setFrameRect(frameRect);
+ frameViewBase.setFrameRect(frameRect);
}
void LayoutPart::invalidatePaintOfSubtreesIfNeeded(

Powered by Google App Engine
This is Rietveld 408576698