summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/Plugins')
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h2
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFAnnotationTextWidgetDetails.h31
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h7
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm101
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm5
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Plugin.cpp7
-rw-r--r--Source/WebKit2/WebProcess/Plugins/Plugin.h3
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp5
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginProxy.h2
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginView.cpp89
-rw-r--r--Source/WebKit2/WebProcess/Plugins/PluginView.h5
11 files changed, 221 insertions, 36 deletions
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index 559aadab5..2063ccee6 100644
--- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -239,7 +239,7 @@ private:
bool supportsSnapshotting() const;
// Convert the given point from plug-in coordinates to root view coordinates.
- WebCore::IntPoint convertToRootView(const WebCore::IntPoint&) const;
+ virtual WebCore::IntPoint convertToRootView(const WebCore::IntPoint&) const OVERRIDE;
// Convert the given point from root view coordinates to plug-in coordinates. Returns false if the point can't be
// converted (if the transformation matrix isn't invertible).
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFAnnotationTextWidgetDetails.h b/Source/WebKit2/WebProcess/Plugins/PDF/PDFAnnotationTextWidgetDetails.h
new file mode 100644
index 000000000..8656ff466
--- /dev/null
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFAnnotationTextWidgetDetails.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <PDFKit/PDFKit.h>
+
+@interface PDFAnnotationTextWidget (Details)
+- (BOOL)isMultiline;
+- (BOOL)isReadOnly;
+@end
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h
index a1233fabe..132c28774 100644
--- a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h
@@ -94,11 +94,16 @@ private:
virtual void setScrollOffset(const WebCore::IntPoint&) OVERRIDE;
virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&) OVERRIDE;
virtual void invalidateScrollCornerRect(const WebCore::IntRect&) OVERRIDE;
+ virtual WebCore::IntPoint currentMousePosition() const { return m_lastMousePositionInPluginCoordinates; }
NSEvent *nsEventForWebMouseEvent(const WebMouseEvent&);
+ WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&) const;
+ WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&) const;
bool supportsForms();
+ void updatePageAndDeviceScaleFactors();
+
RetainPtr<CALayer> m_containerLayer;
RetainPtr<CALayer> m_contentLayer;
RetainPtr<CALayer> m_horizontalScrollbarLayer;
@@ -110,8 +115,8 @@ private:
RefPtr<WebCore::Element> m_annotationContainer;
WebCore::AffineTransform m_rootViewToPluginTransform;
- WebCore::IntPoint m_lastMousePoint;
WebMouseEvent m_lastMouseEvent;
+ WebCore::IntPoint m_lastMousePositionInPluginCoordinates;
RetainPtr<WKPDFLayerControllerDelegate> m_pdfLayerControllerDelegate;
};
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
index 716b24e15..f50fb8c0e 100644
--- a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
@@ -30,6 +30,7 @@
#import "ArgumentCoders.h"
#import "DataReference.h"
+#import "PDFAnnotationTextWidgetDetails.h"
#import "PDFKitImports.h"
#import "PDFLayerControllerDetails.h"
#import "PDFPluginAnnotation.h"
@@ -303,7 +304,7 @@ void PDFPlugin::pdfDocumentDidLoad()
[m_pdfLayerController.get() setFrameSize:size()];
m_pdfLayerController.get().document = document.get();
- [m_pdfLayerController.get() setDeviceScaleFactor:controller()->contentsScaleFactor()];
+ updatePageAndDeviceScaleFactors();
if (handlesPageScaleFactor())
pluginView()->setPageScaleFactor([m_pdfLayerController.get() contentScaleFactor], IntPoint());
@@ -316,9 +317,18 @@ void PDFPlugin::pdfDocumentDidLoad()
runScriptsInPDFDocument();
}
-void PDFPlugin::contentsScaleFactorChanged(float contentsScaleFactor)
+void PDFPlugin::updatePageAndDeviceScaleFactors()
{
- [m_pdfLayerController.get() setDeviceScaleFactor:contentsScaleFactor];
+ double newScaleFactor = controller()->contentsScaleFactor();
+ if (!handlesPageScaleFactor())
+ newScaleFactor *= webFrame()->page()->pageScaleFactor();
+
+ [m_pdfLayerController.get() setDeviceScaleFactor:newScaleFactor];
+}
+
+void PDFPlugin::contentsScaleFactorChanged(float)
+{
+ updatePageAndDeviceScaleFactors();
}
void PDFPlugin::calculateSizes()
@@ -405,6 +415,16 @@ PlatformLayer* PDFPlugin::pluginLayer()
return m_containerLayer.get();
}
+IntPoint PDFPlugin::convertFromRootViewToPlugin(const IntPoint& point) const
+{
+ return m_rootViewToPluginTransform.mapPoint(point);
+}
+
+IntPoint PDFPlugin::convertFromPluginToPDFView(const IntPoint& point) const
+{
+ return IntPoint(point.x(), size().height() - point.y());
+}
+
void PDFPlugin::geometryDidChange(const IntSize& pluginSize, const IntRect&, const AffineTransform& pluginToRootViewTransform)
{
if (size() == pluginSize && pluginView()->pageScaleFactor() == [m_pdfLayerController.get() contentScaleFactor])
@@ -422,10 +442,14 @@ void PDFPlugin::geometryDidChange(const IntSize& pluginSize, const IntRect&, con
if (handlesPageScaleFactor()) {
CGFloat magnification = pluginView()->pageScaleFactor() - [m_pdfLayerController.get() contentScaleFactor];
- // FIXME: Instead of m_lastMousePoint, we should use the zoom origin from PluginView::setPageScaleFactor.
+ // FIXME: Instead of m_lastMousePositionInPluginCoordinates, we should use the zoom origin from PluginView::setPageScaleFactor.
if (magnification)
- [m_pdfLayerController.get() magnifyWithMagnification:magnification atPoint:m_lastMousePoint immediately:NO];
- }
+ [m_pdfLayerController.get() magnifyWithMagnification:magnification atPoint:convertFromPluginToPDFView(m_lastMousePositionInPluginCoordinates) immediately:NO];
+ } else {
+ // If we don't handle page scale ourselves, we need to respect our parent page's
+ // scale, which may have changed.
+ updatePageAndDeviceScaleFactors();
+ }
calculateSizes();
updateScrollbars();
@@ -493,13 +517,9 @@ static NSEventType eventTypeFromWebEvent(const WebEvent& event)
NSEvent *PDFPlugin::nsEventForWebMouseEvent(const WebMouseEvent& event)
{
- IntPoint mousePosition = event.position();
+ m_lastMousePositionInPluginCoordinates = convertFromRootViewToPlugin(event.position());
- IntPoint positionInPDFView(mousePosition);
- positionInPDFView = m_rootViewToPluginTransform.mapPoint(positionInPDFView);
- positionInPDFView.setY(size().height() - positionInPDFView.y());
-
- m_lastMousePoint = positionInPDFView;
+ IntPoint positionInPDFViewCoordinates(convertFromPluginToPDFView(m_lastMousePositionInPluginCoordinates));
NSEventType eventType = eventTypeFromWebEvent(event);
@@ -508,27 +528,59 @@ NSEvent *PDFPlugin::nsEventForWebMouseEvent(const WebMouseEvent& event)
NSUInteger modifierFlags = modifierFlagsFromWebEvent(event);
- return [NSEvent mouseEventWithType:eventType location:positionInPDFView modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:event.clickCount() pressure:0];
+ return [NSEvent mouseEventWithType:eventType location:positionInPDFViewCoordinates modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:event.clickCount() pressure:0];
}
bool PDFPlugin::handleMouseEvent(const WebMouseEvent& event)
{
+ PlatformMouseEvent platformEvent = platform(event);
+ IntPoint mousePosition = convertFromRootViewToPlugin(event.position());
+
m_lastMouseEvent = event;
- IntPoint mousePosition = event.position();
+ RefPtr<Scrollbar> targetScrollbar;
+ RefPtr<Scrollbar> targetScrollbarForLastMousePosition;
- // FIXME: Forward mouse events to the appropriate scrollbar.
- if (IntRect(m_verticalScrollbarLayer.get().frame).contains(mousePosition)
- || IntRect(m_horizontalScrollbarLayer.get().frame).contains(mousePosition)
- || IntRect(m_scrollCornerLayer.get().frame).contains(mousePosition))
+ if (m_verticalScrollbarLayer) {
+ IntRect verticalScrollbarFrame(m_verticalScrollbarLayer.get().frame);
+ if (verticalScrollbarFrame.contains(mousePosition))
+ targetScrollbar = verticalScrollbar();
+ if (verticalScrollbarFrame.contains(m_lastMousePositionInPluginCoordinates))
+ targetScrollbarForLastMousePosition = verticalScrollbar();
+ }
+
+ if (m_horizontalScrollbarLayer) {
+ IntRect horizontalScrollbarFrame(m_horizontalScrollbarLayer.get().frame);
+ if (horizontalScrollbarFrame.contains(mousePosition))
+ targetScrollbar = horizontalScrollbar();
+ if (horizontalScrollbarFrame.contains(m_lastMousePositionInPluginCoordinates))
+ targetScrollbarForLastMousePosition = horizontalScrollbar();
+ }
+
+ if (m_scrollCornerLayer && IntRect(m_scrollCornerLayer.get().frame).contains(mousePosition))
return false;
+ // Right-clicks and Control-clicks always call handleContextMenuEvent as well.
+ if (event.button() == WebMouseEvent::RightButton || (event.button() == WebMouseEvent::LeftButton && event.controlKey()))
+ return true;
+
NSEvent *nsEvent = nsEventForWebMouseEvent(event);
switch (event.type()) {
case WebEvent::MouseMove:
mouseMovedInContentArea();
+ if (targetScrollbar) {
+ if (!targetScrollbarForLastMousePosition) {
+ targetScrollbar->mouseEntered();
+ return true;
+ }
+ return targetScrollbar->mouseMoved(platformEvent);
+ }
+
+ if (!targetScrollbar && targetScrollbarForLastMousePosition)
+ targetScrollbarForLastMousePosition->mouseExited();
+
switch (event.button()) {
case WebMouseEvent::LeftButton:
[m_pdfLayerController.get() mouseDragged:nsEvent];
@@ -543,6 +595,9 @@ bool PDFPlugin::handleMouseEvent(const WebMouseEvent& event)
case WebEvent::MouseDown:
switch (event.button()) {
case WebMouseEvent::LeftButton:
+ if (targetScrollbar)
+ return targetScrollbar->mouseDown(platformEvent);
+
[m_pdfLayerController.get() mouseDown:nsEvent];
return true;
case WebMouseEvent::RightButton:
@@ -555,6 +610,9 @@ bool PDFPlugin::handleMouseEvent(const WebMouseEvent& event)
case WebEvent::MouseUp:
switch (event.button()) {
case WebMouseEvent::LeftButton:
+ if (targetScrollbar)
+ return targetScrollbar->mouseUp(platformEvent);
+
[m_pdfLayerController.get() mouseUp:nsEvent];
return true;
case WebMouseEvent::RightButton:
@@ -574,7 +632,7 @@ bool PDFPlugin::handleContextMenuEvent(const WebMouseEvent& event)
NSMenu *nsMenu = [m_pdfLayerController.get() menuForEvent:nsEventForWebMouseEvent(event)];
FrameView* frameView = webFrame()->coreFrame()->view();
- IntPoint point = frameView->contentsToScreen(IntRect(event.position(), IntSize())).location();
+ IntPoint point = frameView->contentsToScreen(IntRect(frameView->windowToContents(event.position()), IntSize())).location();
if (nsMenu) {
WKPopupContextMenu(nsMenu, point);
return true;
@@ -672,6 +730,11 @@ void PDFPlugin::setActiveAnnotation(PDFAnnotation *annotation)
m_activeAnnotation->commit();
if (annotation) {
+ if ([annotation isKindOfClass:pdfAnnotationTextWidgetClass()] && static_cast<PDFAnnotationTextWidget *>(annotation).isReadOnly) {
+ m_activeAnnotation = 0;
+ return;
+ }
+
m_activeAnnotation = PDFPluginAnnotation::create(annotation, m_pdfLayerController.get(), this);
m_activeAnnotation->attach(m_annotationContainer.get());
} else
diff --git a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
index b5df3732d..f69a5d598 100644
--- a/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
+++ b/Source/WebKit2/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
@@ -28,6 +28,7 @@
#import "config.h"
#import "PDFPluginTextAnnotation.h"
+#import "PDFAnnotationTextWidgetDetails.h"
#import "PDFKitImports.h"
#import "PDFLayerControllerDetails.h"
#import <PDFKit/PDFKit.h>
@@ -40,10 +41,6 @@
#import <WebCore/HTMLTextAreaElement.h>
#import <WebCore/Page.h>
-@interface PDFAnnotationTextWidget (Details)
-- (BOOL)isMultiline;
-@end
-
using namespace WebCore;
namespace WebKit {
diff --git a/Source/WebKit2/WebProcess/Plugins/Plugin.cpp b/Source/WebKit2/WebProcess/Plugins/Plugin.cpp
index 12e0b3d31..f2c6af46c 100644
--- a/Source/WebKit2/WebProcess/Plugins/Plugin.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/Plugin.cpp
@@ -27,6 +27,7 @@
#include "Plugin.h"
#include "WebCoreArgumentCoders.h"
+#include <WebCore/IntPoint.h>
using namespace WebCore;
@@ -105,4 +106,10 @@ void Plugin::updateControlTints(GraphicsContext*)
{
}
+IntPoint Plugin::convertToRootView(const IntPoint&) const
+{
+ ASSERT_NOT_REACHED();
+ return IntPoint();
+}
+
} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/Plugins/Plugin.h b/Source/WebKit2/WebProcess/Plugins/Plugin.h
index 54f8b3ad8..d50a1764b 100644
--- a/Source/WebKit2/WebProcess/Plugins/Plugin.h
+++ b/Source/WebKit2/WebProcess/Plugins/Plugin.h
@@ -50,6 +50,7 @@ namespace CoreIPC {
namespace WebCore {
class AffineTransform;
class GraphicsContext;
+ class IntPoint;
class IntRect;
class IntSize;
class Scrollbar;
@@ -250,6 +251,8 @@ public:
virtual RetainPtr<PDFDocument> pdfDocumentForPrinting() const { return 0; }
#endif
+ virtual WebCore::IntPoint convertToRootView(const WebCore::IntPoint& pointInLocalCoordinates) const;
+
protected:
Plugin();
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp b/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
index a18834a6c..f7ead5664 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
@@ -665,6 +665,11 @@ void PluginProxy::update(const IntRect& paintedRect)
controller()->invalidate(paintedRect);
}
+IntPoint PluginProxy::convertToRootView(const IntPoint& point) const
+{
+ return m_pluginToRootViewTransform.mapPoint(point);
+}
+
} // namespace WebKit
#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProxy.h b/Source/WebKit2/WebProcess/Plugins/PluginProxy.h
index b1a893bdd..535c8c7fe 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginProxy.h
+++ b/Source/WebKit2/WebProcess/Plugins/PluginProxy.h
@@ -125,6 +125,8 @@ private:
virtual WebCore::Scrollbar* horizontalScrollbar();
virtual WebCore::Scrollbar* verticalScrollbar();
+ virtual WebCore::IntPoint convertToRootView(const WebCore::IntPoint&) const OVERRIDE;
+
float contentsScaleFactor();
bool needsBackingStore() const;
bool updateBackingStore();
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
index 44f575ad5..6c74f4633 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -68,7 +68,8 @@ using namespace WebCore;
namespace WebKit {
-static const double pluginSnapshotTimerDelay = 1;
+// This simulated mouse click delay in HTMLPlugInImageElement.cpp should generally be the same or shorter than this delay.
+static const double pluginSnapshotTimerDelay = 1.1;
class PluginView::URLRequest : public RefCounted<URLRequest> {
public:
@@ -554,13 +555,17 @@ void PluginView::didInitializePlugin()
redeliverManualStream();
#if PLATFORM(MAC)
- if (m_pluginElement->displayState() < HTMLPlugInElement::Playing)
+ if (m_pluginElement->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick)
m_pluginSnapshotTimer.restart();
- else if (m_plugin->pluginLayer()) {
- if (frame()) {
- frame()->view()->enterCompositingMode();
- m_pluginElement->setNeedsStyleRecalc(SyntheticStyleChange);
+ else {
+ if (m_plugin->pluginLayer()) {
+ if (frame()) {
+ frame()->view()->enterCompositingMode();
+ m_pluginElement->setNeedsStyleRecalc(SyntheticStyleChange);
+ }
}
+ if (m_pluginElement->displayState() < HTMLPlugInElement::Playing)
+ m_pluginElement->dispatchPendingMouseClick();
}
setWindowIsVisible(m_webPage->windowIsVisible());
@@ -686,7 +691,7 @@ void PluginView::setFrameRect(const WebCore::IntRect& rect)
void PluginView::paint(GraphicsContext* context, const IntRect& /*dirtyRect*/)
{
- if (!m_plugin || !m_isInitialized || m_pluginElement->displayState() < HTMLPlugInElement::Playing)
+ if (!m_plugin || !m_isInitialized || m_pluginElement->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick)
return;
if (context->paintingDisabled()) {
@@ -728,12 +733,62 @@ void PluginView::setParent(ScrollView* scrollView)
initializePlugin();
}
+PassOwnPtr<WebEvent> PluginView::createWebEvent(MouseEvent* event) const
+{
+ WebEvent::Type type = WebEvent::NoType;
+ unsigned clickCount = 1;
+ if (event->type() == eventNames().mousedownEvent)
+ type = WebEvent::MouseDown;
+ else if (event->type() == eventNames().mouseupEvent)
+ type = WebEvent::MouseUp;
+ else if (event->type() == eventNames().mouseoverEvent) {
+ type = WebEvent::MouseMove;
+ clickCount = 0;
+ } else if (event->type() == eventNames().clickEvent)
+ return nullptr;
+ else
+ ASSERT_NOT_REACHED();
+
+ WebMouseEvent::Button button = WebMouseEvent::NoButton;
+ switch (event->button()) {
+ case WebCore::LeftButton:
+ button = WebMouseEvent::LeftButton;
+ break;
+ case WebCore::MiddleButton:
+ button = WebMouseEvent::MiddleButton;
+ break;
+ case WebCore::RightButton:
+ button = WebMouseEvent::RightButton;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+
+ unsigned modifiers = 0;
+ if (event->shiftKey())
+ modifiers |= WebEvent::ShiftKey;
+ if (event->ctrlKey())
+ modifiers |= WebEvent::ControlKey;
+ if (event->altKey())
+ modifiers |= WebEvent::AltKey;
+ if (event->metaKey())
+ modifiers |= WebEvent::MetaKey;
+
+ return adoptPtr(new WebMouseEvent(type, button, m_plugin->convertToRootView(IntPoint(event->offsetX(), event->offsetY())), event->screenLocation(), 0, 0, 0, clickCount, static_cast<WebEvent::Modifiers>(modifiers), 0));
+}
+
void PluginView::handleEvent(Event* event)
{
if (!m_isInitialized || !m_plugin)
return;
const WebEvent* currentEvent = WebPage::currentEvent();
+ OwnPtr<WebEvent> simulatedWebEvent;
+ if (event->isMouseEvent() && toMouseEvent(event)->isSimulated()) {
+ simulatedWebEvent = createWebEvent(toMouseEvent(event));
+ currentEvent = simulatedWebEvent.get();
+ }
if (!currentEvent)
return;
@@ -776,16 +831,25 @@ void PluginView::handleEvent(Event* event)
bool PluginView::handleEditingCommand(const String& commandName, const String& argument)
{
+ if (!m_isInitialized || !m_plugin)
+ return false;
+
return m_plugin->handleEditingCommand(commandName, argument);
}
bool PluginView::isEditingCommandEnabled(const String& commandName)
{
+ if (!m_isInitialized || !m_plugin)
+ return false;
+
return m_plugin->isEditingCommandEnabled(commandName);
}
bool PluginView::shouldAllowScripting()
{
+ if (!m_isInitialized || !m_plugin)
+ return false;
+
return m_plugin->shouldAllowScripting();
}
@@ -950,7 +1014,10 @@ void PluginView::performFrameLoadURLRequest(URLRequest* request)
Frame* targetFrame = frame->loader()->findFrameForNavigation(request->target());
if (!targetFrame) {
// We did not find a target frame. Ask our frame to load the page. This may or may not create a popup window.
- frame->loader()->load(request->request(), request->target(), false);
+ FrameLoadRequest frameRequest(frame, request->request());
+ frameRequest.setFrameName(request->target());
+ frameRequest.setShouldCheckNewWindowPolicy(true);
+ frame->loader()->load(frameRequest);
// FIXME: We don't know whether the window was successfully created here so we just assume that it worked.
// It's better than not telling the plug-in anything.
@@ -959,7 +1026,7 @@ void PluginView::performFrameLoadURLRequest(URLRequest* request)
}
// Now ask the frame to load the request.
- targetFrame->loader()->load(request->request(), false);
+ targetFrame->loader()->load(FrameLoadRequest(targetFrame, request->request()));
WebFrame* targetWebFrame = static_cast<WebFrameLoaderClient*>(targetFrame->loader()->client())->webFrame();
if (WebFrame::LoadListener* loadListener = targetWebFrame->loadListener()) {
@@ -1079,7 +1146,7 @@ void PluginView::invalidateRect(const IntRect& dirtyRect)
return;
#endif
- if (m_pluginElement->displayState() < HTMLPlugInElement::Playing)
+ if (m_pluginElement->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick)
return;
RenderBoxModelObject* renderer = toRenderBoxModelObject(m_pluginElement->renderer());
@@ -1237,7 +1304,7 @@ bool PluginView::isAcceleratedCompositingEnabled()
if (!settings)
return false;
- if (m_pluginElement->displayState() < HTMLPlugInElement::Playing)
+ if (m_pluginElement->displayState() < HTMLPlugInElement::PlayingWithPendingMouseClick)
return false;
return settings->acceleratedCompositingEnabled();
}
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.h b/Source/WebKit2/WebProcess/Plugins/PluginView.h
index 59f0f8403..cd9e35b95 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginView.h
+++ b/Source/WebKit2/WebProcess/Plugins/PluginView.h
@@ -44,11 +44,14 @@
namespace WebCore {
class Frame;
class HTMLPlugInElement;
+class MouseEvent;
class RenderBoxModelObject;
}
namespace WebKit {
+class WebEvent;
+
class PluginView : public WebCore::PluginViewBase, public PluginController, private WebCore::MediaCanStartListener, private WebFrame::LoadListener {
public:
static PassRefPtr<PluginView> create(PassRefPtr<WebCore::HTMLPlugInElement>, PassRefPtr<Plugin>, const Plugin::Parameters&);
@@ -201,6 +204,8 @@ private:
virtual void didFinishLoad(WebFrame*);
virtual void didFailLoad(WebFrame*, bool wasCancelled);
+ PassOwnPtr<WebEvent> createWebEvent(WebCore::MouseEvent*) const;
+
RefPtr<WebCore::HTMLPlugInElement> m_pluginElement;
RefPtr<Plugin> m_plugin;
WebPage* m_webPage;