summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderEmbeddedObject.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderEmbeddedObject.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/RenderEmbeddedObject.cpp')
-rw-r--r--Source/WebCore/rendering/RenderEmbeddedObject.cpp230
1 files changed, 109 insertions, 121 deletions
diff --git a/Source/WebCore/rendering/RenderEmbeddedObject.cpp b/Source/WebCore/rendering/RenderEmbeddedObject.cpp
index da7e35c02..36260dc3b 100644
--- a/Source/WebCore/rendering/RenderEmbeddedObject.cpp
+++ b/Source/WebCore/rendering/RenderEmbeddedObject.cpp
@@ -29,21 +29,20 @@
#include "ChromeClient.h"
#include "Cursor.h"
#include "EventHandler.h"
-#include "Font.h"
+#include "EventNames.h"
+#include "FontCascade.h"
#include "FontSelector.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
#include "GraphicsContext.h"
#include "HTMLAppletElement.h"
#include "HTMLEmbedElement.h"
-#include "HTMLIFrameElement.h"
#include "HTMLNames.h"
#include "HTMLObjectElement.h"
#include "HTMLParamElement.h"
#include "HTMLPlugInElement.h"
#include "HitTestResult.h"
#include "LocalizedStrings.h"
-#include "MIMETypeRegistry.h"
#include "MouseEvent.h"
#include "Page.h"
#include "PaintInfo.h"
@@ -58,10 +57,6 @@
#include "TextRun.h"
#include <wtf/StackStats.h>
-#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
-#include "HTMLMediaElement.h"
-#endif
-
namespace WebCore {
using namespace HTMLNames;
@@ -78,32 +73,31 @@ static const float replacementArrowCirclePadding = 3;
static const Color& replacementTextRoundedRectPressedColor()
{
- static const Color pressed(105, 105, 105, 242);
+ static NeverDestroyed<Color> pressed(105, 105, 105, 242);
return pressed;
}
static const Color& replacementTextRoundedRectColor()
{
- static const Color standard(125, 125, 125, 242);
+ static NeverDestroyed<Color> standard(125, 125, 125, 242);
return standard;
}
static const Color& replacementTextColor()
{
- static const Color standard(240, 240, 240, 255);
+ static NeverDestroyed<Color> standard(240, 240, 240, 255);
return standard;
}
static const Color& unavailablePluginBorderColor()
{
- static const Color standard(255, 255, 255, 216);
+ static NeverDestroyed<Color> standard(255, 255, 255, 216);
return standard;
}
-RenderEmbeddedObject::RenderEmbeddedObject(HTMLFrameOwnerElement& element, PassRef<RenderStyle> style)
- : RenderWidget(element, std::move(style))
+RenderEmbeddedObject::RenderEmbeddedObject(HTMLFrameOwnerElement& element, RenderStyle&& style)
+ : RenderWidget(element, WTFMove(style))
, m_isPluginUnavailable(false)
- , m_isUnavailablePluginIndicatorHidden(false)
, m_unavailablePluginIndicatorIsPressed(false)
, m_mouseDownWasInUnavailablePluginIndicator(false)
{
@@ -113,17 +107,22 @@ RenderEmbeddedObject::RenderEmbeddedObject(HTMLFrameOwnerElement& element, PassR
RenderEmbeddedObject::~RenderEmbeddedObject()
{
+ // Do not add any code here. Add it to willBeDestroyed() instead.
+}
+
+void RenderEmbeddedObject::willBeDestroyed()
+{
view().frameView().removeEmbeddedObjectToUpdate(*this);
+ RenderWidget::willBeDestroyed();
}
-RenderPtr<RenderEmbeddedObject> RenderEmbeddedObject::createForApplet(HTMLAppletElement& applet, PassRef<RenderStyle> style)
+RenderPtr<RenderEmbeddedObject> RenderEmbeddedObject::createForApplet(HTMLAppletElement& applet, RenderStyle&& style)
{
- auto renderer = createRenderer<RenderEmbeddedObject>(applet, std::move(style));
+ auto renderer = createRenderer<RenderEmbeddedObject>(applet, WTFMove(style));
renderer->setInline(true);
return renderer;
}
-#if USE(ACCELERATED_COMPOSITING)
bool RenderEmbeddedObject::requiresLayer() const
{
if (RenderWidget::requiresLayer())
@@ -136,12 +135,11 @@ bool RenderEmbeddedObject::allowsAcceleratedCompositing() const
{
#if PLATFORM(IOS)
// The timing of layer creation is different on the phone, since the plugin can only be manipulated from the main thread.
- return widget() && widget()->isPluginViewBase() && toPluginViewBase(widget())->willProvidePluginLayer();
+ return is<PluginViewBase>(widget()) && downcast<PluginViewBase>(*widget()).willProvidePluginLayer();
#else
- return widget() && widget()->isPluginViewBase() && toPluginViewBase(widget())->platformLayer();
+ return is<PluginViewBase>(widget()) && downcast<PluginViewBase>(*widget()).platformLayer();
#endif
}
-#endif
#if !PLATFORM(IOS)
static String unavailablePluginReplacementText(RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason)
@@ -162,10 +160,9 @@ static String unavailablePluginReplacementText(RenderEmbeddedObject::PluginUnava
}
#endif
-static bool shouldUnavailablePluginMessageBeButton(Document& document, RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason)
+static bool shouldUnavailablePluginMessageBeButton(Page& page, RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason)
{
- Page* page = document.page();
- return page && page->chrome().client().shouldUnavailablePluginMessageBeButton(pluginUnavailabilityReason);
+ return page.chrome().client().shouldUnavailablePluginMessageBeButton(pluginUnavailabilityReason);
}
void RenderEmbeddedObject::setPluginUnavailabilityReason(PluginUnavailabilityReason pluginUnavailabilityReason)
@@ -198,42 +195,38 @@ void RenderEmbeddedObject::setUnavailablePluginIndicatorIsPressed(bool pressed)
{
if (m_unavailablePluginIndicatorIsPressed == pressed)
return;
-
m_unavailablePluginIndicatorIsPressed = pressed;
repaint();
}
-void RenderEmbeddedObject::paintSnapshotImage(PaintInfo& paintInfo, const LayoutPoint& paintOffset, Image* image)
+void RenderEmbeddedObject::paintSnapshotImage(PaintInfo& paintInfo, const LayoutPoint& paintOffset, Image& image)
{
LayoutUnit cWidth = contentWidth();
LayoutUnit cHeight = contentHeight();
if (!cWidth || !cHeight)
return;
- GraphicsContext* context = paintInfo.context;
+ GraphicsContext& context = paintInfo.context();
LayoutSize contentSize(cWidth, cHeight);
LayoutPoint contentLocation = location() + paintOffset;
contentLocation.move(borderLeft() + paddingLeft(), borderTop() + paddingTop());
LayoutRect rect(contentLocation, contentSize);
- IntRect alignedRect = pixelSnappedIntRect(rect);
+ IntRect alignedRect = snappedIntRect(rect);
if (alignedRect.width() <= 0 || alignedRect.height() <= 0)
return;
- bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, alignedRect.size());
- ImageOrientationDescription orientationDescription(shouldRespectImageOrientation());
-#if ENABLE(CSS_IMAGE_ORIENTATION)
- orientationDescription.setImageOrientationEnum(style().imageOrientation());
-#endif
- context->drawImage(image, style().colorSpace(), alignedRect, CompositeSourceOver, orientationDescription, useLowQualityScaling);
+ InterpolationQuality interpolation = chooseInterpolationQuality(context, image, &image, alignedRect.size());
+ ImageOrientationDescription orientationDescription(shouldRespectImageOrientation(), style().imageOrientation());
+ context.drawImage(image, alignedRect, ImagePaintingOptions(orientationDescription, interpolation));
}
void RenderEmbeddedObject::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- if (!frameOwnerElement().isPluginElement())
+ if (!is<HTMLPlugInElement>(frameOwnerElement()))
return;
- HTMLPlugInElement& plugInElement = toHTMLPlugInElement(frameOwnerElement());
+ HTMLPlugInElement& plugInElement = downcast<HTMLPlugInElement>(frameOwnerElement());
if (plugInElement.displayState() > HTMLPlugInElement::DisplayingSnapshot) {
RenderWidget::paintContents(paintInfo, paintOffset);
@@ -241,34 +234,34 @@ void RenderEmbeddedObject::paintContents(PaintInfo& paintInfo, const LayoutPoint
return;
}
- if (!plugInElement.isPlugInImageElement())
+ if (!is<HTMLPlugInImageElement>(plugInElement))
return;
- Image* snapshot = toHTMLPlugInImageElement(plugInElement).snapshotImage();
- if (snapshot)
- paintSnapshotImage(paintInfo, paintOffset, snapshot);
+ if (Image* snapshot = downcast<HTMLPlugInImageElement>(plugInElement).snapshotImage())
+ paintSnapshotImage(paintInfo, paintOffset, *snapshot);
}
void RenderEmbeddedObject::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- Page* page = frame().page();
+ // The relevant repainted object heuristic is not tuned for plugin documents.
+ bool countsTowardsRelevantObjects = !document().isPluginDocument() && paintInfo.phase == PaintPhaseForeground;
if (isPluginUnavailable()) {
- if (page && paintInfo.phase == PaintPhaseForeground)
- page->addRelevantUnpaintedObject(this, visualOverflowRect());
+ if (countsTowardsRelevantObjects)
+ page().addRelevantUnpaintedObject(this, visualOverflowRect());
RenderReplaced::paint(paintInfo, paintOffset);
return;
}
- if (page && paintInfo.phase == PaintPhaseForeground)
- page->addRelevantRepaintedObject(this, visualOverflowRect());
+ if (countsTowardsRelevantObjects)
+ page().addRelevantRepaintedObject(this, visualOverflowRect());
RenderWidget::paint(paintInfo, paintOffset);
}
-static void drawReplacementArrow(GraphicsContext* context, const FloatRect& insideRect)
+static void drawReplacementArrow(GraphicsContext& context, const FloatRect& insideRect)
{
- GraphicsContextStateSaver stateSaver(*context);
+ GraphicsContextStateSaver stateSaver(context);
FloatRect rect(insideRect);
rect.inflate(-replacementArrowPadding);
@@ -276,9 +269,9 @@ static void drawReplacementArrow(GraphicsContext* context, const FloatRect& insi
FloatPoint center(rect.center());
FloatPoint arrowTip(rect.maxX(), center.y());
- context->setStrokeThickness(2);
- context->setLineCap(RoundCap);
- context->setLineJoin(RoundJoin);
+ context.setStrokeThickness(2);
+ context.setLineCap(RoundCap);
+ context.setLineJoin(RoundJoin);
Path path;
path.moveTo(FloatPoint(rect.x(), center.y()));
@@ -286,7 +279,7 @@ static void drawReplacementArrow(GraphicsContext* context, const FloatRect& insi
path.addLineTo(FloatPoint(center.x(), rect.y()));
path.moveTo(arrowTip);
path.addLineTo(FloatPoint(center.x(), rect.maxY()));
- context->strokePath(path);
+ context.strokePath(path);
}
void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
@@ -297,16 +290,16 @@ void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint
if (paintInfo.phase == PaintPhaseSelection)
return;
- GraphicsContext* context = paintInfo.context;
- if (context->paintingDisabled())
+ GraphicsContext& context = paintInfo.context();
+ if (context.paintingDisabled())
return;
FloatRect contentRect;
FloatRect indicatorRect;
FloatRect replacementTextRect;
FloatRect arrowRect;
- Font font;
- TextRun run("");
+ FontCascade font;
+ TextRun run(emptyString());
float textWidth;
if (!getReplacementTextGeometry(paintOffset, contentRect, indicatorRect, replacementTextRect, arrowRect, font, run, textWidth))
return;
@@ -314,59 +307,61 @@ void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint
Path background;
background.addRoundedRect(indicatorRect, FloatSize(replacementTextRoundedRectRadius, replacementTextRoundedRectRadius));
- GraphicsContextStateSaver stateSaver(*context);
- context->clip(contentRect);
- context->setFillColor(m_unavailablePluginIndicatorIsPressed ? replacementTextRoundedRectPressedColor() : replacementTextRoundedRectColor(), style().colorSpace());
- context->fillPath(background);
+ GraphicsContextStateSaver stateSaver(context);
+ context.clip(contentRect);
+ context.setFillColor(m_unavailablePluginIndicatorIsPressed ? replacementTextRoundedRectPressedColor() : replacementTextRoundedRectColor());
+ context.fillPath(background);
Path strokePath;
FloatRect strokeRect(indicatorRect);
strokeRect.inflate(1);
strokePath.addRoundedRect(strokeRect, FloatSize(replacementTextRoundedRectRadius + 1, replacementTextRoundedRectRadius + 1));
- context->setStrokeColor(unavailablePluginBorderColor(), style().colorSpace());
- context->setStrokeThickness(2);
- context->strokePath(strokePath);
+ context.setStrokeColor(unavailablePluginBorderColor());
+ context.setStrokeThickness(2);
+ context.strokePath(strokePath);
const FontMetrics& fontMetrics = font.fontMetrics();
float labelX = roundf(replacementTextRect.location().x() + replacementTextRoundedRectLeftTextMargin);
float labelY = roundf(replacementTextRect.location().y() + (replacementTextRect.size().height() - fontMetrics.height()) / 2 + fontMetrics.ascent() + replacementTextRoundedRectTopTextMargin);
- context->setFillColor(replacementTextColor(), style().colorSpace());
- context->drawBidiText(font, run, FloatPoint(labelX, labelY));
+ context.setFillColor(replacementTextColor());
+ context.drawBidiText(font, run, FloatPoint(labelX, labelY));
- if (shouldUnavailablePluginMessageBeButton(document(), m_pluginUnavailabilityReason)) {
+ if (shouldUnavailablePluginMessageBeButton(page(), m_pluginUnavailabilityReason)) {
arrowRect.inflate(-replacementArrowCirclePadding);
- context->beginTransparencyLayer(1.0);
- context->setFillColor(replacementTextColor(), style().colorSpace());
- context->fillEllipse(arrowRect);
+ context.beginTransparencyLayer(1.0);
+ context.setFillColor(replacementTextColor());
+ context.fillEllipse(arrowRect);
- context->setCompositeOperation(CompositeClear);
+ context.setCompositeOperation(CompositeClear);
drawReplacementArrow(context, arrowRect);
- context->endTransparencyLayer();
+ context.endTransparencyLayer();
}
}
void RenderEmbeddedObject::setUnavailablePluginIndicatorIsHidden(bool hidden)
{
- m_isUnavailablePluginIndicatorHidden = hidden;
-
+ auto newState = hidden ? UnavailablePluginIndicatorState::Hidden : UnavailablePluginIndicatorState::Visible;
+ if (m_isUnavailablePluginIndicatorState == newState)
+ return;
+ m_isUnavailablePluginIndicatorState = newState;
repaint();
}
-bool RenderEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, FloatRect& indicatorRect, FloatRect& replacementTextRect, FloatRect& arrowRect, Font& font, TextRun& run, float& textWidth) const
+bool RenderEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, FloatRect& indicatorRect, FloatRect& replacementTextRect, FloatRect& arrowRect, FontCascade& font, TextRun& run, float& textWidth) const
{
- bool includesArrow = shouldUnavailablePluginMessageBeButton(document(), m_pluginUnavailabilityReason);
+ bool includesArrow = shouldUnavailablePluginMessageBeButton(page(), m_pluginUnavailabilityReason);
contentRect = contentBoxRect();
contentRect.moveBy(roundedIntPoint(accumulatedOffset));
- FontDescription fontDescription;
+ FontCascadeDescription fontDescription;
RenderTheme::defaultTheme()->systemFont(CSSValueWebkitSmallControl, fontDescription);
fontDescription.setWeight(FontWeightBold);
- fontDescription.setRenderingMode(frame().settings().fontRenderingMode());
+ fontDescription.setRenderingMode(settings().fontRenderingMode());
fontDescription.setComputedSize(12);
- font = Font(fontDescription, 0, 0);
+ font = FontCascade(fontDescription, 0, 0);
font.update(0);
run = TextRun(m_unavailablePluginReplacementText);
@@ -396,8 +391,8 @@ LayoutRect RenderEmbeddedObject::unavailablePluginIndicatorBounds(const LayoutPo
FloatRect indicatorRect;
FloatRect replacementTextRect;
FloatRect arrowRect;
- Font font;
- TextRun run("", 0);
+ FontCascade font;
+ TextRun run(emptyString());
float textWidth;
if (getReplacementTextGeometry(accumulatedOffset, contentRect, indicatorRect, replacementTextRect, arrowRect, font, run, textWidth))
return LayoutRect(indicatorRect);
@@ -429,12 +424,14 @@ bool RenderEmbeddedObject::isReplacementObscured() const
if (!rootRenderView)
return true;
- IntRect rootViewRect = view().frameView().convertToRootView(pixelSnappedIntRect(rect));
-
- HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::DisallowShadowContent | HitTestRequest::AllowChildFrameContent);
+ // We should always start hit testing a clean tree.
+ view().frameView().updateLayoutAndStyleIfNeededRecursive();
+
+ HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::IgnoreClipping | HitTestRequest::DisallowUserAgentShadowContent | HitTestRequest::AllowChildFrameContent);
HitTestResult result;
HitTestLocation location;
+ IntRect rootViewRect = view().frameView().convertToRootView(snappedIntRect(rect));
LayoutUnit x = rootViewRect.x();
LayoutUnit y = rootViewRect.y();
LayoutUnit width = rootViewRect.width();
@@ -500,8 +497,8 @@ void RenderEmbeddedObject::layout()
if (!wasMissingWidget && newSize.width() >= oldSize.width() && newSize.height() >= oldSize.height()) {
HTMLFrameOwnerElement& element = frameOwnerElement();
- if (element.isPluginElement() && toHTMLPlugInElement(element).isPlugInImageElement()) {
- HTMLPlugInImageElement& plugInImageElement = toHTMLPlugInImageElement(element);
+ if (is<HTMLPlugInImageElement>(element)) {
+ HTMLPlugInImageElement& plugInImageElement = downcast<HTMLPlugInImageElement>(element);
if (plugInImageElement.displayState() > HTMLPlugInElement::DisplayingSnapshot && plugInImageElement.snapshotDecision() == HTMLPlugInImageElement::MaySnapshotWhenResized) {
plugInImageElement.setNeedsCheckForSizeChange();
view().frameView().addEmbeddedObjectToUpdate(*this);
@@ -518,12 +515,9 @@ void RenderEmbeddedObject::layout()
if (!child)
return;
- RenderBox* childBox = toRenderBox(child);
+ auto& childBox = downcast<RenderBox>(*child);
- if (!childBox)
- return;
-
- if (newSize == oldSize && !childBox->needsLayout())
+ if (newSize == oldSize && !childBox.needsLayout())
return;
// When calling layout() on a child node, a parent must either push a LayoutStateMaintainter, or
@@ -531,11 +525,11 @@ void RenderEmbeddedObject::layout()
// and this method will be called many times per second during playback, use a LayoutStateMaintainer:
LayoutStateMaintainer statePusher(view(), *this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
- childBox->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop()));
- childBox->style().setHeight(Length(newSize.height(), Fixed));
- childBox->style().setWidth(Length(newSize.width(), Fixed));
- childBox->setNeedsLayout(MarkOnlyThis);
- childBox->layout();
+ childBox.setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop()));
+ childBox.mutableStyle().setHeight(Length(newSize.height(), Fixed));
+ childBox.mutableStyle().setWidth(Length(newSize.width(), Fixed));
+ childBox.setNeedsLayout(MarkOnlyThis);
+ childBox.layout();
clearChildNeedsLayout();
statePusher.pop();
@@ -546,20 +540,20 @@ bool RenderEmbeddedObject::nodeAtPoint(const HitTestRequest& request, HitTestRes
if (!RenderWidget::nodeAtPoint(request, result, locationInContainer, accumulatedOffset, hitTestAction))
return false;
- if (!widget() || !widget()->isPluginViewBase())
+ if (!is<PluginViewBase>(widget()))
return true;
- PluginViewBase* view = toPluginViewBase(widget());
+ PluginViewBase& view = downcast<PluginViewBase>(*widget());
IntPoint roundedPoint = locationInContainer.roundedPoint();
- if (Scrollbar* horizontalScrollbar = view->horizontalScrollbar()) {
+ if (Scrollbar* horizontalScrollbar = view.horizontalScrollbar()) {
if (horizontalScrollbar->shouldParticipateInHitTesting() && horizontalScrollbar->frameRect().contains(roundedPoint)) {
result.setScrollbar(horizontalScrollbar);
return true;
}
}
- if (Scrollbar* verticalScrollbar = view->verticalScrollbar()) {
+ if (Scrollbar* verticalScrollbar = view.verticalScrollbar()) {
if (verticalScrollbar->shouldParticipateInHitTesting() && verticalScrollbar->frameRect().contains(roundedPoint)) {
result.setScrollbar(verticalScrollbar);
return true;
@@ -571,10 +565,10 @@ bool RenderEmbeddedObject::nodeAtPoint(const HitTestRequest& request, HitTestRes
bool RenderEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity granularity, float, Element**, RenderBox*, const IntPoint&)
{
- if (!widget() || !widget()->isPluginViewBase())
+ if (!is<PluginViewBase>(widget()))
return false;
- return toPluginViewBase(widget())->scroll(direction, granularity);
+ return downcast<PluginViewBase>(*widget()).scroll(direction, granularity);
}
bool RenderEmbeddedObject::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Element** stopElement)
@@ -584,65 +578,64 @@ bool RenderEmbeddedObject::logicalScroll(ScrollLogicalDirection direction, Scrol
}
-bool RenderEmbeddedObject::isInUnavailablePluginIndicator(const LayoutPoint& point) const
+bool RenderEmbeddedObject::isInUnavailablePluginIndicator(const FloatPoint& point) const
{
FloatRect contentRect;
FloatRect indicatorRect;
FloatRect replacementTextRect;
FloatRect arrowRect;
- Font font;
- TextRun run("");
+ FontCascade font;
+ TextRun run(emptyString());
float textWidth;
return getReplacementTextGeometry(IntPoint(), contentRect, indicatorRect, replacementTextRect, arrowRect, font, run, textWidth)
&& indicatorRect.contains(point);
}
-bool RenderEmbeddedObject::isInUnavailablePluginIndicator(MouseEvent* event) const
+bool RenderEmbeddedObject::isInUnavailablePluginIndicator(const MouseEvent& event) const
{
- return isInUnavailablePluginIndicator(roundedLayoutPoint(absoluteToLocal(event->absoluteLocation(), UseTransforms)));
+ return isInUnavailablePluginIndicator(absoluteToLocal(event.absoluteLocation(), UseTransforms));
}
void RenderEmbeddedObject::handleUnavailablePluginIndicatorEvent(Event* event)
{
- if (!shouldUnavailablePluginMessageBeButton(document(), m_pluginUnavailabilityReason))
+ if (!shouldUnavailablePluginMessageBeButton(page(), m_pluginUnavailabilityReason))
return;
- if (!event->isMouseEvent())
+ if (!is<MouseEvent>(*event))
return;
- MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
- HTMLPlugInElement& element = toHTMLPlugInElement(frameOwnerElement());
- if (event->type() == eventNames().mousedownEvent && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+ MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
+ HTMLPlugInElement& element = downcast<HTMLPlugInElement>(frameOwnerElement());
+ if (mouseEvent.type() == eventNames().mousedownEvent && mouseEvent.button() == LeftButton) {
m_mouseDownWasInUnavailablePluginIndicator = isInUnavailablePluginIndicator(mouseEvent);
if (m_mouseDownWasInUnavailablePluginIndicator) {
frame().eventHandler().setCapturingMouseEventsElement(&element);
element.setIsCapturingMouseEvents(true);
setUnavailablePluginIndicatorIsPressed(true);
}
- event->setDefaultHandled();
+ mouseEvent.setDefaultHandled();
}
- if (event->type() == eventNames().mouseupEvent && static_cast<MouseEvent*>(event)->button() == LeftButton) {
+ if (mouseEvent.type() == eventNames().mouseupEvent && mouseEvent.button() == LeftButton) {
if (m_unavailablePluginIndicatorIsPressed) {
frame().eventHandler().setCapturingMouseEventsElement(nullptr);
element.setIsCapturingMouseEvents(false);
setUnavailablePluginIndicatorIsPressed(false);
}
if (m_mouseDownWasInUnavailablePluginIndicator && isInUnavailablePluginIndicator(mouseEvent)) {
- if (Page* page = document().page())
- page->chrome().client().unavailablePluginButtonClicked(&element, m_pluginUnavailabilityReason);
+ page().chrome().client().unavailablePluginButtonClicked(element, m_pluginUnavailabilityReason);
}
m_mouseDownWasInUnavailablePluginIndicator = false;
event->setDefaultHandled();
}
- if (event->type() == eventNames().mousemoveEvent) {
+ if (mouseEvent.type() == eventNames().mousemoveEvent) {
setUnavailablePluginIndicatorIsPressed(m_mouseDownWasInUnavailablePluginIndicator && isInUnavailablePluginIndicator(mouseEvent));
- event->setDefaultHandled();
+ mouseEvent.setDefaultHandled();
}
}
CursorDirective RenderEmbeddedObject::getCursor(const LayoutPoint& point, Cursor& cursor) const
{
- if (showsUnavailablePluginIndicator() && shouldUnavailablePluginMessageBeButton(document(), m_pluginUnavailabilityReason) && isInUnavailablePluginIndicator(point)) {
+ if (showsUnavailablePluginIndicator() && shouldUnavailablePluginMessageBeButton(page(), m_pluginUnavailabilityReason) && isInUnavailablePluginIndicator(point)) {
cursor = handCursor();
return SetCursor;
}
@@ -655,11 +648,6 @@ CursorDirective RenderEmbeddedObject::getCursor(const LayoutPoint& point, Cursor
bool RenderEmbeddedObject::canHaveChildren() const
{
-#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
- if (frameOwnerElement().isMediaElement())
- return true;
-#endif
-
if (isSnapshottedPlugIn())
return true;