summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/WebCoreSupport/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/WebProcess/WebCoreSupport/gtk')
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp23
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp114
-rw-r--r--Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebErrorsGtk.cpp9
3 files changed, 45 insertions, 101 deletions
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
index 697dd8fe6..0398dca2e 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
@@ -32,8 +32,8 @@
#include "ShareableBitmap.h"
#include "WebPage.h"
#include "WebPageProxyMessages.h"
-#include <WebCore/Clipboard.h>
-#include <WebCore/DataObjectGtk.h>
+#include "WebSelectionData.h"
+#include <WebCore/DataTransfer.h>
#include <WebCore/DragData.h>
#include <WebCore/GraphicsContext.h>
#include <WebCore/Pasteboard.h>
@@ -43,31 +43,32 @@ using namespace WebCore;
namespace WebKit {
-static PassRefPtr<ShareableBitmap> convertCairoSurfaceToShareableBitmap(cairo_surface_t* surface)
+static RefPtr<ShareableBitmap> convertCairoSurfaceToShareableBitmap(cairo_surface_t* surface)
{
if (!surface)
- return 0;
+ return nullptr;
IntSize imageSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface));
RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(imageSize, ShareableBitmap::SupportsAlpha);
auto graphicsContext = bitmap->createGraphicsContext();
- graphicsContext->platformContext()->drawSurfaceToContext(surface, IntRect(IntPoint(), imageSize), IntRect(IntPoint(), imageSize), graphicsContext.get());
- return bitmap.release();
+ graphicsContext->platformContext()->drawSurfaceToContext(surface, IntRect(IntPoint(), imageSize), IntRect(IntPoint(), imageSize), *graphicsContext);
+ return bitmap;
}
-void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& clientPosition, const IntPoint& globalPosition, Clipboard& clipboard, Frame&, bool)
+void WebDragClient::startDrag(DragImage dragImage, const IntPoint& clientPosition, const IntPoint& globalPosition, const FloatPoint&, DataTransfer& dataTransfer, Frame&, DragSourceAction)
{
- RefPtr<ShareableBitmap> bitmap = convertCairoSurfaceToShareableBitmap(dragImage);
+ RefPtr<ShareableBitmap> bitmap = convertCairoSurfaceToShareableBitmap(dragImage.get().get());
ShareableBitmap::Handle handle;
// If we have a bitmap, but cannot create a handle to it, we fail early.
if (bitmap && !bitmap->createHandle(handle))
return;
- RefPtr<DataObjectGtk> dataObject = clipboard.pasteboard().dataObject();
- DragData dragData(dataObject.get(), clientPosition, globalPosition, clipboard.sourceOperation());
- m_page->send(Messages::WebPageProxy::StartDrag(dragData, handle));
+ m_page->willStartDrag();
+
+ WebSelectionData selection(dataTransfer.pasteboard().selectionData());
+ m_page->send(Messages::WebPageProxy::StartDrag(selection, dataTransfer.sourceOperation(), handle));
}
}; // namespace WebKit.
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
index 08cf200bd..1505c883f 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
@@ -20,41 +20,29 @@
#include "config.h"
#include "WebEditorClient.h"
-#include "Frame.h"
-#include "FrameDestructionObserver.h"
#include "PlatformKeyboardEvent.h"
-#include "WebPage.h"
-#include "WebPageProxyMessages.h"
-#include "WebProcess.h"
-#include <WebCore/DataObjectGtk.h>
+#include <WebCore/Document.h>
+#include <WebCore/Editor.h>
+#include <WebCore/EventNames.h>
+#include <WebCore/Frame.h>
#include <WebCore/KeyboardEvent.h>
-#include <WebCore/PasteboardHelper.h>
-#include <WebCore/WindowsKeyboardCodes.h>
+#include <WebCore/Pasteboard.h>
+#include <WebCore/markup.h>
+#include <wtf/glib/GRefPtr.h>
using namespace WebCore;
namespace WebKit {
-void WebEditorClient::getEditorCommandsForKeyEvent(const KeyboardEvent* event, Vector<WTF::String>& pendingEditorCommands)
-{
- ASSERT(event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent);
-
- /* First try to interpret the command in the UI and get the commands.
- UI needs to receive event type because only knows current NativeWebKeyboardEvent.*/
- WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::GetEditorCommandsForKeyEvent(event->type()),
- Messages::WebPageProxy::GetEditorCommandsForKeyEvent::Reply(pendingEditorCommands),
- m_page->pageID(), std::chrono::milliseconds::max());
-}
-
bool WebEditorClient::executePendingEditorCommands(Frame* frame, const Vector<WTF::String>& pendingEditorCommands, bool allowTextInsertion)
{
Vector<Editor::Command> commands;
for (auto& commandString : pendingEditorCommands) {
- Editor::Command command = frame->editor().command(commandString.utf8().data());
+ Editor::Command command = frame->editor().command(commandString);
if (command.isTextInsertion() && !allowTextInsertion)
return false;
- commands.append(std::move(command));
+ commands.append(WTFMove(command));
}
for (auto& command : commands) {
@@ -67,21 +55,20 @@ bool WebEditorClient::executePendingEditorCommands(Frame* frame, const Vector<WT
void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
{
- Node* node = event->target()->toNode();
- ASSERT(node);
- Frame* frame = node->document().frame();
- ASSERT(frame);
-
const PlatformKeyboardEvent* platformEvent = event->keyEvent();
if (!platformEvent)
return;
// If this was an IME event don't do anything.
- if (platformEvent->windowsVirtualKeyCode() == VK_PROCESSKEY)
+ if (platformEvent->handledByInputMethod())
return;
- Vector<WTF::String> pendingEditorCommands;
- getEditorCommandsForKeyEvent(event, pendingEditorCommands);
+ Node* node = event->target()->toNode();
+ ASSERT(node);
+ Frame* frame = node->document().frame();
+ ASSERT(frame);
+
+ const Vector<String> pendingEditorCommands = platformEvent->commands();
if (!pendingEditorCommands.isEmpty()) {
// During RawKeyDown events if an editor command will insert text, defer
@@ -126,72 +113,23 @@ void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event)
void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event)
{
const PlatformKeyboardEvent* platformEvent = event->keyEvent();
- if (platformEvent && platformEvent->windowsVirtualKeyCode() == VK_PROCESSKEY)
- event->preventDefault();
-}
-
-#if PLATFORM(X11)
-class EditorClientFrameDestructionObserver : FrameDestructionObserver {
-public:
- EditorClientFrameDestructionObserver(Frame* frame, GClosure* closure)
- : FrameDestructionObserver(frame)
- , m_closure(closure)
- {
- g_closure_add_finalize_notifier(m_closure, this, destroyOnClosureFinalization);
- }
-
- void frameDestroyed()
- {
- g_closure_invalidate(m_closure);
- FrameDestructionObserver::frameDestroyed();
- }
-private:
- GClosure* m_closure;
-
- static void destroyOnClosureFinalization(gpointer data, GClosure* closure)
- {
- // Calling delete void* will free the memory but won't invoke
- // the destructor, something that is a must for us.
- EditorClientFrameDestructionObserver* observer = static_cast<EditorClientFrameDestructionObserver*>(data);
- delete observer;
- }
-};
-
-static Frame* frameSettingClipboard;
-
-static void collapseSelection(GtkClipboard* clipboard, Frame* frame)
-{
- if (frameSettingClipboard && frameSettingClipboard == frame)
- return;
-
- // Collapse the selection without clearing it.
- ASSERT(frame);
- frame->selection().setBase(frame->selection().extent(), frame->selection().affinity());
+ if (platformEvent && platformEvent->handledByInputMethod())
+ event->setDefaultHandled();
}
-#endif
void WebEditorClient::updateGlobalSelection(Frame* frame)
{
-#if PLATFORM(X11)
- GtkClipboard* clipboard = PasteboardHelper::defaultPasteboardHelper()->getPrimarySelectionClipboard(frame);
- DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
-
if (!frame->selection().isRange())
return;
+ RefPtr<Range> range = frame->selection().toNormalizedRange();
+ if (!range)
+ return;
- dataObject->clearAll();
- dataObject->setRange(frame->selection().toNormalizedRange());
-
- frameSettingClipboard = frame;
- GClosure* callback = g_cclosure_new(G_CALLBACK(collapseSelection), frame, 0);
- // This observer will be self-destroyed on closure finalization,
- // that will happen either after closure execution or after
- // closure invalidation.
- new EditorClientFrameDestructionObserver(frame, callback);
- g_closure_set_marshal(callback, g_cclosure_marshal_VOID__VOID);
- PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(clipboard, PasteboardHelper::DoNotIncludeSmartPaste, callback);
- frameSettingClipboard = 0;
-#endif
+ PasteboardWebContent pasteboardContent;
+ pasteboardContent.canSmartCopyOrDelete = false;
+ pasteboardContent.text = range->text();
+ pasteboardContent.markup = createMarkup(*range, nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
+ Pasteboard::createForGlobalSelection()->write(pasteboardContent);
}
bool WebEditorClient::shouldShowUnicodeMenu()
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebErrorsGtk.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebErrorsGtk.cpp
index 7d05108a3..e9d1d4c2b 100644
--- a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebErrorsGtk.cpp
+++ b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebErrorsGtk.cpp
@@ -33,7 +33,7 @@
#include <WebCore/ResourceError.h>
#include <WebCore/ResourceRequest.h>
#include <WebCore/ResourceResponse.h>
-#include <WebKit2/WKError.h>
+#include <WebKit/WKErrorRef.h>
#include <glib/gi18n-lib.h>
using namespace WebCore;
@@ -50,6 +50,11 @@ ResourceError blockedError(const ResourceRequest& request)
return WebCore::blockedError(request);
}
+ResourceError blockedByContentBlockerError(const ResourceRequest& request)
+{
+ return WebCore::blockedByContentBlockerError(request);
+}
+
ResourceError cannotShowURLError(const ResourceRequest& request)
{
return WebCore::cannotShowURLError(request);
@@ -77,7 +82,7 @@ ResourceError pluginWillHandleLoadError(const ResourceResponse& response)
WebCore::ResourceError internalError(const WebCore::URL& url)
{
- return ResourceError(API::Error::webKitErrorDomain(), kWKErrorInternal, url.string(), _("Internal error"));
+ return ResourceError(API::Error::webKitErrorDomain(), kWKErrorInternal, url, _("Internal error"));
}
} // namespace WebKit