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..0eb57dc9d2fe4add9667de844a15d0cfd910f378 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,13 @@ 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; |
+} |
+ |
PaintLayerType LayoutPart::layerTypeRequired() const { |
PaintLayerType type = LayoutReplaced::layerTypeRequired(); |
if (type != NoPaintLayer) |
@@ -110,8 +118,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()) |
@@ -247,6 +255,7 @@ void LayoutPart::styleDidChange(StyleDifference diff, |
if (frameViewBase && frameViewBase->isFrameView()) |
toFrameView(frameViewBase)->recalculateCustomScrollbarStyle(); |
+ // TODO(joelhockey): Does this need separate code for plugins? |
if (style()->visibility() != EVisibility::kVisible) { |
frameViewBase->hide(); |
} else { |
@@ -272,7 +281,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 +300,12 @@ LayoutRect LayoutPart::replacedContentRect() const { |
} |
void LayoutPart::updateOnWidgetChange() { |
- FrameViewBase* frameViewBase = this->frameViewBase(); |
+ // Check if this is a plugin or frame. |
+ // TODO(joelhockey): When plugin no longer inherits from FrameViewBase, make |
+ // separate versions of this function for plugins and frames. |
+ FrameViewBase* frameViewBase = this->plugin(); |
+ if (!frameViewBase) |
+ frameViewBase = this->frameViewBase(); |
if (!frameViewBase) |
return; |
@@ -299,8 +313,9 @@ void LayoutPart::updateOnWidgetChange() { |
return; |
if (!needsLayout()) |
- updateGeometryInternal(); |
+ updateGeometryInternal(*frameViewBase); |
+ // TODO(joelhockey): Does this need special handling for plugin? |
if (style()->visibility() != EVisibility::kVisible) { |
frameViewBase->hide(); |
} else { |
@@ -312,13 +327,19 @@ void LayoutPart::updateOnWidgetChange() { |
} |
void LayoutPart::updateGeometry() { |
- FrameViewBase* frameViewBase = this->frameViewBase(); |
+ // Check if this is a plugin or frame. |
+ // TODO(joelhockey): When plugin no longer inherits from FrameViewBase, make |
+ // separate versions of this function for plugins and frames. |
+ FrameViewBase* frameViewBase = this->plugin(); |
+ if (!frameViewBase) |
+ frameViewBase = this->frameViewBase(); |
if (!frameViewBase || |
!node()) // Check the node in case destroy() has been called. |
return; |
LayoutRect newFrame = replacedContentRect(); |
DCHECK(newFrame.size() == roundedIntSize(newFrame.size())); |
+ // TODO(joelhockey): Does this need special handling for plugin? |
bool boundsWillChange = |
LayoutSize(frameViewBase->frameRect().size()) != newFrame.size(); |
@@ -333,7 +354,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 +365,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 +390,8 @@ void LayoutPart::updateGeometryInternal() { |
// Why is the protector needed? |
RefPtr<LayoutPart> protector(this); |
- frameViewBase->setFrameRect(frameRect); |
+ // TODO(joelhockey): Does this need special handling for plugin? |
+ frameViewBase.setFrameRect(frameRect); |
} |
void LayoutPart::invalidatePaintOfSubtreesIfNeeded( |