summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderSnapshottedPlugIn.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/RenderSnapshottedPlugIn.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp')
-rw-r--r--Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp72
1 files changed, 36 insertions, 36 deletions
diff --git a/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp b/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp
index 42eec430b..2afc0da0f 100644
--- a/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp
+++ b/Source/WebCore/rendering/RenderSnapshottedPlugIn.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,10 +27,10 @@
#include "RenderSnapshottedPlugIn.h"
#include "CachedImage.h"
-#include "Chrome.h"
-#include "ChromeClient.h"
#include "Cursor.h"
+#include "EventNames.h"
#include "Filter.h"
+#include "Frame.h"
#include "FrameLoaderClient.h"
#include "FrameView.h"
#include "Gradient.h"
@@ -41,28 +41,36 @@
#include "PaintInfo.h"
#include "Path.h"
#include "PlatformMouseEvent.h"
+#include "RenderImageResource.h"
+#include "RenderIterator.h"
#include "RenderView.h"
#include <wtf/StackStats.h>
namespace WebCore {
-RenderSnapshottedPlugIn::RenderSnapshottedPlugIn(HTMLPlugInImageElement& element, PassRef<RenderStyle> style)
- : RenderEmbeddedObject(element, std::move(style))
+RenderSnapshottedPlugIn::RenderSnapshottedPlugIn(HTMLPlugInImageElement& element, RenderStyle&& style)
+ : RenderEmbeddedObject(element, WTFMove(style))
, m_snapshotResource(std::make_unique<RenderImageResource>())
- , m_isPotentialMouseActivation(false)
{
m_snapshotResource->initialize(this);
}
RenderSnapshottedPlugIn::~RenderSnapshottedPlugIn()
{
+ // Do not add any code here. Add it to willBeDestroyed() instead.
+}
+
+void RenderSnapshottedPlugIn::willBeDestroyed()
+{
ASSERT(m_snapshotResource);
m_snapshotResource->shutdown();
+
+ RenderEmbeddedObject::willBeDestroyed();
}
HTMLPlugInImageElement& RenderSnapshottedPlugIn::plugInImageElement() const
{
- return toHTMLPlugInImageElement(RenderEmbeddedObject::frameOwnerElement());
+ return downcast<HTMLPlugInImageElement>(RenderEmbeddedObject::frameOwnerElement());
}
void RenderSnapshottedPlugIn::layout()
@@ -79,13 +87,13 @@ void RenderSnapshottedPlugIn::layout()
view().frameView().addEmbeddedObjectToUpdate(*this);
}
-void RenderSnapshottedPlugIn::updateSnapshot(PassRefPtr<Image> image)
+void RenderSnapshottedPlugIn::updateSnapshot(Image* image)
{
// Zero-size plugins will have no image.
if (!image)
return;
- m_snapshotResource->setCachedImage(new CachedImage(image.get()));
+ m_snapshotResource->setCachedImage(new CachedImage(image, page().sessionID()));
repaint();
}
@@ -102,10 +110,10 @@ void RenderSnapshottedPlugIn::paint(PaintInfo& paintInfo, const LayoutPoint& pai
paintInfoForChild.phase = newPhase;
paintInfoForChild.updateSubtreePaintRootForChildren(this);
- for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
- LayoutPoint childPoint = flipForWritingModeForChild(child, paintOffset);
- if (!child->hasSelfPaintingLayer() && !child->isFloating())
- child->paint(paintInfoForChild, childPoint);
+ for (auto& child : childrenOfType<RenderBox>(*this)) {
+ LayoutPoint childPoint = flipForWritingModeForChild(&child, paintOffset);
+ if (!child.hasSelfPaintingLayer() && !child.isFloating())
+ child.paint(paintInfoForChild, childPoint);
}
RenderEmbeddedObject::paint(paintInfo, paintOffset);
@@ -122,28 +130,20 @@ void RenderSnapshottedPlugIn::paintSnapshot(PaintInfo& paintInfo, const LayoutPo
if (!cWidth || !cHeight)
return;
- GraphicsContext* context = paintInfo.context;
-#if PLATFORM(MAC)
- if (style().highlight() != nullAtom && !context->paintingDisabled())
- paintCustomHighlight(toPoint(paintOffset - location()), style().highlight(), true);
-#endif
+ 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));
}
CursorDirective RenderSnapshottedPlugIn::getCursor(const LayoutPoint& point, Cursor& overrideCursor) const
@@ -155,12 +155,12 @@ CursorDirective RenderSnapshottedPlugIn::getCursor(const LayoutPoint& point, Cur
return RenderEmbeddedObject::getCursor(point, overrideCursor);
}
-void RenderSnapshottedPlugIn::handleEvent(Event* event)
+void RenderSnapshottedPlugIn::handleEvent(Event& event)
{
- if (!event->isMouseEvent())
+ if (!is<MouseEvent>(event))
return;
- MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
+ auto& mouseEvent = downcast<MouseEvent>(event);
// If we're a snapshotted plugin, we want to make sure we activate on
// clicks even if the page is preventing our default behaviour. Otherwise
@@ -170,20 +170,20 @@ void RenderSnapshottedPlugIn::handleEvent(Event* event)
// event. The code below is not completely foolproof, but the worst that
// could happen is that a snapshotted plugin restarts.
- if (event->type() == eventNames().mouseoutEvent)
+ if (mouseEvent.type() == eventNames().mouseoutEvent)
m_isPotentialMouseActivation = false;
- if (mouseEvent->button() != LeftButton)
+ if (mouseEvent.button() != LeftButton)
return;
- if (event->type() == eventNames().clickEvent || (m_isPotentialMouseActivation && event->type() == eventNames().mouseupEvent)) {
+ if (mouseEvent.type() == eventNames().clickEvent || (m_isPotentialMouseActivation && mouseEvent.type() == eventNames().mouseupEvent)) {
m_isPotentialMouseActivation = false;
- bool clickWasOnOverlay = plugInImageElement().partOfSnapshotOverlay(event->target()->toNode());
+ bool clickWasOnOverlay = plugInImageElement().partOfSnapshotOverlay(mouseEvent.target()->toNode());
plugInImageElement().userDidClickSnapshot(mouseEvent, !clickWasOnOverlay);
- event->setDefaultHandled();
- } else if (event->type() == eventNames().mousedownEvent) {
+ mouseEvent.setDefaultHandled();
+ } else if (mouseEvent.type() == eventNames().mousedownEvent) {
m_isPotentialMouseActivation = true;
- event->setDefaultHandled();
+ mouseEvent.setDefaultHandled();
}
}