Diff
Modified: trunk/Source/WebKit2/ChangeLog (144669 => 144670)
--- trunk/Source/WebKit2/ChangeLog 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/ChangeLog 2013-03-04 21:54:52 UTC (rev 144670)
@@ -1,3 +1,81 @@
+2013-03-04 Tim Horton <timothy_hor...@apple.com>
+
+ PDFPlugin: Hook up Services
+ https://bugs.webkit.org/show_bug.cgi?id=111246
+ <rdar://problem/13062672>
+
+ Reviewed by Alexey Proskuryakov.
+
+ Make the Application->Services menu work when the focused selection is a PDFPlugin.
+
+ * Shared/EditorState.cpp:
+ (WebKit::EditorState::encode):
+ (WebKit::EditorState::decode):
+ * Shared/EditorState.h:
+ (WebKit::EditorState::EditorState):
+ (EditorState):
+ Add isInPlugin property to EditorState.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView validRequestorForSendType:returnType:]):
+ If the selection is currently in a Plugin, we only currently have the ability
+ to retrieve the selection as a plain-text string, so restrict sendType to NSStringPboardType.
+
+ * WebProcess/Plugins/PDF/SimplePDFPlugin.h:
+ * WebProcess/Plugins/Plugin.h:
+ * WebProcess/Plugins/PluginView.h:
+ * WebProcess/Plugins/PluginProxy.h:
+ * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+ Add getStringSelection.
+
+ * WebProcess/Plugins/PDF/PDFLayerControllerDetails.h:
+ Add pdfLayerController:didChangeSelection: delegate method.
+
+ * WebProcess/Plugins/PDF/PDFPlugin.h:
+ (PDFPlugin):
+ Add getStringSelection and notifySelectionChanged.
+
+ * WebProcess/Plugins/PDF/PDFPlugin.mm:
+ (-[WKPDFLayerControllerDelegate pdfLayerController:didChangeSelection:]):
+ Forward selection change notifications to our PDFPlugin.
+
+ (WebKit::PDFPlugin::notifySelectionChanged):
+ Forward selection change notifications to our WebPage.
+
+ (WebKit::PDFPlugin::getStringSelection):
+ Retrieve PDFLayerController's selection as a plain text string.
+
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::countFindMatches):
+ (WebKit::PluginView::findString):
+ Drive-bys, check for existance and initialization of the plugin before using it.
+
+ (WebKit::PluginView::getStringSelection): Added.
+
+ * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+ (WebKit::WebEditorClient::respondToChangedSelection):
+ Use didChangeSelection instead of sending the EditorStateChanged message directly.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::editorState):
+ If a plugin is focused and has a selection, return a EditorState that reflects that.
+ Since PDFs aren't editable (when editing annotations, the plugin doesn't have focus),
+ I'm not adding support for the editing-related properties when a plugin has focus.
+
+ (WebKit::WebPage::focusedPluginViewForFrame):
+ (WebKit::WebPage::pluginViewForFrame):
+ Make these class methods instead of static functions so we can use them from
+ WebPageMac too, instead of duplicating code there.
+
+ (WebKit::WebPage::didChangeSelection): Added.
+
+ * WebProcess/WebPage/WebPage.h:
+ Add didChangeSelection and [focused]PluginViewForFrame.
+
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::getStringSelectionForPasteboard):
+ Defer to the focused plugin (if it exists) when retrieving the plain-text selection.
+
2013-03-04 Mikhail Pozdnyakov <mikhail.pozdnya...@intel.com>
[WK2][EFL] Add callbacks to the WKViewClient to handle Web Process crash and relaunch
Modified: trunk/Source/WebKit2/Shared/EditorState.cpp (144669 => 144670)
--- trunk/Source/WebKit2/Shared/EditorState.cpp 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/Shared/EditorState.cpp 2013-03-04 21:54:52 UTC (rev 144670)
@@ -39,6 +39,7 @@
encoder << isContentEditable;
encoder << isContentRichlyEditable;
encoder << isInPasswordField;
+ encoder << isInPlugin;
encoder << hasComposition;
#if PLATFORM(QT)
@@ -76,6 +77,9 @@
if (!decoder.decode(result.isInPasswordField))
return false;
+ if (!decoder.decode(result.isInPlugin))
+ return false;
+
if (!decoder.decode(result.hasComposition))
return false;
Modified: trunk/Source/WebKit2/Shared/EditorState.h (144669 => 144670)
--- trunk/Source/WebKit2/Shared/EditorState.h 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/Shared/EditorState.h 2013-03-04 21:54:52 UTC (rev 144670)
@@ -41,6 +41,7 @@
, isContentEditable(false)
, isContentRichlyEditable(false)
, isInPasswordField(false)
+ , isInPlugin(false)
, hasComposition(false)
#if PLATFORM(QT)
, cursorPosition(0)
@@ -57,6 +58,7 @@
bool isContentEditable;
bool isContentRichlyEditable;
bool isInPasswordField;
+ bool isInPlugin;
bool hasComposition;
#if PLATFORM(QT)
// The anchor, cursor represent either the selection or composition, depending
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (144669 => 144670)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2013-03-04 21:54:52 UTC (rev 144670)
@@ -600,13 +600,22 @@
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
{
- BOOL isValidSendType = !sendType || ([PasteboardTypes::forSelection() containsObject:sendType] && !_data->_page->editorState().selectionIsNone);
+ EditorState editorState = _data->_page->editorState();
+ BOOL isValidSendType = NO;
+
+ if (sendType && !editorState.selectionIsNone) {
+ if (editorState.isInPlugin)
+ isValidSendType = [sendType isEqualToString:NSStringPboardType];
+ else
+ isValidSendType = [PasteboardTypes::forSelection() containsObject:sendType];
+ }
+
BOOL isValidReturnType = NO;
if (!returnType)
isValidReturnType = YES;
- else if ([PasteboardTypes::forEditing() containsObject:returnType] && _data->_page->editorState().isContentEditable) {
+ else if ([PasteboardTypes::forEditing() containsObject:returnType] && editorState.isContentEditable) {
// We can insert strings in any editable context. We can insert other types, like images, only in rich edit contexts.
- isValidReturnType = _data->_page->editorState().isContentRichlyEditable || [returnType isEqualToString:NSStringPboardType];
+ isValidReturnType = editorState.isContentRichlyEditable || [returnType isEqualToString:NSStringPboardType];
}
if (isValidSendType && isValidReturnType)
return self;
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h 2013-03-04 21:54:52 UTC (rev 144670)
@@ -252,6 +252,8 @@
virtual bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) OVERRIDE { return false; }
+ virtual String getSelectionString() const OVERRIDE { return String(); }
+
void updateNPNPrivateMode();
#if PLUGIN_ARCHITECTURE(WIN)
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h 2013-03-04 21:54:52 UTC (rev 144670)
@@ -38,6 +38,7 @@
- (void)pdfLayerController:(PDFLayerController *)pdfLayerController clickedLinkWithURL:(NSURL *)url;
- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeContentScaleFactor:(CGFloat)scaleFactor;
- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode;
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection;
@end
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h 2013-03-04 21:54:52 UTC (rev 144670)
@@ -72,6 +72,8 @@
void notifyContentScaleFactorChanged(CGFloat scaleFactor);
void notifyDisplayModeChanged(int);
+ void notifySelectionChanged(PDFSelection *);
+
void clickedLink(NSURL *);
void saveToPDF();
void openWithNativeApplication();
@@ -109,6 +111,7 @@
PDFSelection *nextMatchForString(const String& target, BOOL searchForward, BOOL caseSensitive, BOOL wrapSearch, PDFSelection *initialSelection, BOOL startInSelection);
virtual bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) OVERRIDE;
+ virtual String getSelectionString() const OVERRIDE;
// ScrollableArea functions.
virtual void setScrollOffset(const WebCore::IntPoint&) OVERRIDE;
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2013-03-04 21:54:52 UTC (rev 144670)
@@ -193,6 +193,11 @@
_pdfPlugin->notifyDisplayModeChanged(mode);
}
+- (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection
+{
+ _pdfPlugin->notifySelectionChanged(selection);
+}
+
@end
namespace WebKit {
@@ -960,6 +965,16 @@
[m_pdfLayerController.get() activateNextAnnotation:true];
}
+void PDFPlugin::notifySelectionChanged(PDFSelection *)
+{
+ webFrame()->page()->didChangeSelection();
+}
+
+String PDFPlugin::getSelectionString() const
+{
+ return [[m_pdfLayerController.get() currentSelection] string];
+}
+
} // namespace WebKit
#endif // ENABLE(PDFKIT_PLUGIN)
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h 2013-03-04 21:54:52 UTC (rev 144670)
@@ -180,6 +180,8 @@
virtual bool getResourceData(const unsigned char*& bytes, unsigned& length) const OVERRIDE;
virtual bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) OVERRIDE { return false; }
+ virtual String getSelectionString() const OVERRIDE { return String(); }
+
WebCore::IntSize m_scrollOffset;
private:
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h 2013-03-04 21:54:52 UTC (rev 144670)
@@ -267,6 +267,8 @@
virtual bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) = 0;
+ virtual String getSelectionString() const = 0;
+
protected:
Plugin();
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h 2013-03-04 21:54:52 UTC (rev 144670)
@@ -136,6 +136,8 @@
virtual bool getResourceData(const unsigned char*& /* bytes */, unsigned& /* length */) const OVERRIDE { return false; }
virtual bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) OVERRIDE { return false; }
+ virtual String getSelectionString() const OVERRIDE { return String(); }
+
float contentsScaleFactor();
bool needsBackingStore() const;
bool updateBackingStore();
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2013-03-04 21:54:52 UTC (rev 144670)
@@ -754,14 +754,28 @@
unsigned PluginView::countFindMatches(const String& target, WebCore::FindOptions options, unsigned maxMatchCount)
{
+ if (!m_isInitialized || !m_plugin)
+ return 0;
+
return m_plugin->countFindMatches(target, options, maxMatchCount);
}
bool PluginView::findString(const String& target, WebCore::FindOptions options, unsigned maxMatchCount)
{
+ if (!m_isInitialized || !m_plugin)
+ return false;
+
return m_plugin->findString(target, options, maxMatchCount);
}
+String PluginView::getSelectionString() const
+{
+ if (!m_isInitialized || !m_plugin)
+ return String();
+
+ return m_plugin->getSelectionString();
+}
+
PassOwnPtr<WebEvent> PluginView::createWebEvent(MouseEvent* event) const
{
WebEvent::Type type = WebEvent::NoType;
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h 2013-03-04 21:54:52 UTC (rev 144670)
@@ -97,6 +97,8 @@
unsigned countFindMatches(const String& target, WebCore::FindOptions, unsigned maxMatchCount);
bool findString(const String& target, WebCore::FindOptions, unsigned maxMatchCount);
+ String getSelectionString() const;
+
bool shouldAllowScripting();
bool getResourceData(const unsigned char*& bytes, unsigned& length) const;
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp 2013-03-04 21:54:52 UTC (rev 144670)
@@ -195,10 +195,8 @@
if (!frame)
return;
- EditorState state = m_page->editorState();
+ m_page->didChangeSelection();
- m_page->send(Messages::WebPageProxy::EditorStateChanged(state));
-
#if PLATFORM(GTK) || PLATFORM(QT)
updateGlobalSelection(frame);
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2013-03-04 21:54:52 UTC (rev 144670)
@@ -561,6 +561,16 @@
ASSERT(frame);
EditorState result;
+
+ if (PluginView* pluginView = focusedPluginViewForFrame(frame)) {
+ if (!pluginView->getSelectionString().isNull()) {
+ result.selectionIsNone = false;
+ result.selectionIsRange = true;
+ result.isInPlugin = true;
+ return result;
+ }
+ }
+
result.selectionIsNone = frame->selection()->isNone();
result.selectionIsRange = frame->selection()->isRange();
result.isContentEditable = frame->selection()->isContentEditable();
@@ -693,7 +703,7 @@
return ImmutableArray::adopt(vector);
}
-static PluginView* focusedPluginViewForFrame(Frame* frame)
+PluginView* WebPage::focusedPluginViewForFrame(Frame* frame)
{
if (!frame->document()->isPluginDocument())
return 0;
@@ -707,7 +717,7 @@
return pluginView;
}
-static PluginView* pluginViewForFrame(Frame* frame)
+PluginView* WebPage::pluginViewForFrame(Frame* frame)
{
if (!frame->document()->isPluginDocument())
return 0;
@@ -3766,6 +3776,11 @@
}
#endif
+void WebPage::didChangeSelection()
+{
+ send(Messages::WebPageProxy::EditorStateChanged(editorState()));
+}
+
void WebPage::setMainFrameInViewSourceMode(bool inViewSourceMode)
{
m_mainFrame->coreFrame()->setInViewSourceMode(inViewSourceMode);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2013-03-04 21:54:52 UTC (rev 144670)
@@ -433,6 +433,8 @@
void cancelComposition();
#endif
+ void didChangeSelection();
+
#if PLATFORM(MAC)
void registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elemenToken, const CoreIPC::DataReference& windowToken);
WKAccessibilityWebPageObject* accessibilityRemoteObject();
@@ -795,6 +797,9 @@
static bool platformCanHandleRequest(const WebCore::ResourceRequest&);
+ static PluginView* focusedPluginViewForFrame(WebCore::Frame*);
+ static PluginView* pluginViewForFrame(WebCore::Frame*);
+
OwnPtr<WebCore::Page> m_page;
RefPtr<WebFrame> m_mainFrame;
RefPtr<InjectedBundleBackForwardList> m_backForwardList;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (144669 => 144670)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2013-03-04 21:54:41 UTC (rev 144669)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2013-03-04 21:54:52 UTC (rev 144670)
@@ -473,10 +473,7 @@
if (!frame)
return;
- if (frame->document()->isPluginDocument()) {
- PluginDocument* pluginDocument = static_cast<PluginDocument*>(frame->document());
- PluginView* pluginView = static_cast<PluginView*>(pluginDocument->pluginWidget());
-
+ if (PluginView* pluginView = pluginViewForFrame(frame)) {
if (pluginView->performDictionaryLookupAtLocation(floatPoint))
return;
}
@@ -656,9 +653,21 @@
void WebPage::getStringSelectionForPasteboard(String& stringValue)
{
Frame* frame = m_page->focusController()->focusedOrMainFrame();
- if (!frame || frame->selection()->isNone())
+
+ if (!frame)
return;
+ if (PluginView* pluginView = focusedPluginViewForFrame(frame)) {
+ String selection = pluginView->getSelectionString();
+ if (!selection.isNull()) {
+ stringValue = selection;
+ return;
+ }
+ }
+
+ if (frame->selection()->isNone())
+ return;
+
stringValue = frame->editor()->stringSelectionForPasteboard();
}