Diff
Modified: trunk/Source/WebCore/ChangeLog (167673 => 167674)
--- trunk/Source/WebCore/ChangeLog 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebCore/ChangeLog 2014-04-22 19:22:28 UTC (rev 167674)
@@ -1,3 +1,21 @@
+2014-04-22 Brady Eidson <beid...@apple.com>
+
+ Change Image Controls replacement to use selection and paste
+ <rdar://problem/16302722> and https://bugs.webkit.org/show_bug.cgi?id=131992
+
+ Reviewed by Tim Horton.
+
+ * WebCore.exp.in: Remove deleted symbol.
+
+ * html/shadow/mac/ImageControlsButtonElementMac.cpp:
+ (WebCore::ImageControlsButtonElementMac::defaultEventHandler):
+
+ * page/ContextMenuController.cpp:
+ (WebCore::ContextMenuController::showImageControlsMenu): Select the image element
+ before showing the menu.
+ (WebCore::ContextMenuController::replaceControlledImage): Deleted.
+ * page/ContextMenuController.h:
+
2014-04-22 David Hyatt <hy...@apple.com>
REGRESSION: Hitting asserts in new flow thread selection code.
Modified: trunk/Source/WebCore/WebCore.exp.in (167673 => 167674)
--- trunk/Source/WebCore/WebCore.exp.in 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebCore/WebCore.exp.in 2014-04-22 19:22:28 UTC (rev 167674)
@@ -2987,10 +2987,6 @@
__ZNK7WebCore12IconDatabase9isEnabledEv
#endif
-#if ENABLE(IMAGE_CONTROLS)
-__ZN7WebCore21ContextMenuController22replaceControlledImageEN3WTF10PassRefPtrINS_5ImageEEE
-#endif
-
#if ENABLE(INDEXED_DATABASE)
__ZN7WebCore10IDBKeyData14setNumberValueEd
__ZN7WebCore10IDBKeyData6decodeERNS_12KeyedDecoderERS0_
Modified: trunk/Source/WebCore/html/shadow/mac/ImageControlsButtonElementMac.cpp (167673 => 167674)
--- trunk/Source/WebCore/html/shadow/mac/ImageControlsButtonElementMac.cpp 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebCore/html/shadow/mac/ImageControlsButtonElementMac.cpp 2014-04-22 19:22:28 UTC (rev 167674)
@@ -30,11 +30,15 @@
#include "ContextMenuController.h"
#include "Event.h"
+#include "Frame.h"
+#include "FrameSelection.h"
#include "HTMLDivElement.h"
#include "Page.h"
+#include "Range.h"
#include "RenderBlockFlow.h"
#include "RenderStyle.h"
#include "RenderTheme.h"
+#include "ShadowRoot.h"
namespace WebCore {
@@ -99,8 +103,33 @@
void ImageControlsButtonElementMac::defaultEventHandler(Event* event)
{
if (event->type() == eventNames().clickEvent) {
- if (Page* page = document().page())
- page->contextMenuController().showImageControlsMenu(event);
+ // Before showing the menu, change the current selection to the represented Image element.
+ ContainerNode* parent = parentNode();
+ Element* hostElement = nullptr;
+ while (parent) {
+ if (parent->isShadowRoot()) {
+ hostElement = static_cast<ShadowRoot*>(parent)->hostElement();
+ break;
+ }
+ parent = parent->parentNode();
+ }
+
+ if (!hostElement)
+ return;
+ ASSERT(isHTMLImageElement(hostElement));
+
+ Frame* frame = document().frame();
+ if (!frame)
+ return;
+
+ Page* page = document().page();
+ if (!page)
+ return;
+
+ RefPtr<Range> range = Range::create(document(), Position(hostElement, Position::PositionIsBeforeAnchor), Position(hostElement, Position::PositionIsAfterAnchor));
+ frame->selection().setSelection(VisibleSelection(range.get()));
+
+ page->contextMenuController().showImageControlsMenu(event);
event->setDefaultHandled();
return;
}
Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (167673 => 167674)
--- trunk/Source/WebCore/page/ContextMenuController.cpp 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp 2014-04-22 19:22:28 UTC (rev 167674)
@@ -1452,24 +1452,6 @@
handleContextMenuEvent(event);
m_client.showContextMenu();
}
-
-void ContextMenuController::replaceControlledImage(PassRefPtr<Image> newImage)
-{
- Node* node = m_context.hitTestResult().innerNonSharedNode();
- if (!node)
- return;
-
- Frame* frame = node->document().frame();
- if (!frame)
- return;
-
- RenderObject* renderer = node->renderer();
- if (!renderer || !renderer->isRenderImage())
- return;
-
- CachedResourceHandle<CachedImage> replacedImage = new CachedImage(URL::fakeURLWithRelativePart("image"), newImage.get(), frame->page()->sessionID());
- toRenderImage(renderer)->imageResource().setCachedImage(replacedImage.get());
-}
#endif
} // namespace WebCore
Modified: trunk/Source/WebCore/page/ContextMenuController.h (167673 => 167674)
--- trunk/Source/WebCore/page/ContextMenuController.h 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebCore/page/ContextMenuController.h 2014-04-22 19:22:28 UTC (rev 167674)
@@ -71,7 +71,6 @@
#if ENABLE(IMAGE_CONTROLS)
void showImageControlsMenu(Event*);
- void replaceControlledImage(PassRefPtr<Image>);
#endif
private:
Modified: trunk/Source/WebKit/mac/ChangeLog (167673 => 167674)
--- trunk/Source/WebKit/mac/ChangeLog 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit/mac/ChangeLog 2014-04-22 19:22:28 UTC (rev 167674)
@@ -1,3 +1,15 @@
+2014-04-22 Brady Eidson <beid...@apple.com>
+
+ Change Image Controls replacement to use selection and paste
+ <rdar://problem/16302722> and https://bugs.webkit.org/show_bug.cgi?id=131992
+
+ Reviewed by Tim Horton.
+
+ * Misc/WebSharingServicePickerController.mm:
+ (-[WebSharingServicePickerController sharingService:didShareItems:]): Write the
+ replacement data to a special pasteboard, then replace the current selection from
+ that pasteboard.
+
2014-04-21 Eric Carlson <eric.carl...@apple.com>
[Mac] implement WebKitDataCue
Modified: trunk/Source/WebKit/mac/Misc/WebSharingServicePickerController.mm (167673 => 167674)
--- trunk/Source/WebKit/mac/Misc/WebSharingServicePickerController.mm 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit/mac/Misc/WebSharingServicePickerController.mm 2014-04-22 19:22:28 UTC (rev 167674)
@@ -31,6 +31,10 @@
#import "WebViewInternal.h"
#import <AppKit/NSSharingService.h>
#import <WebCore/BitmapImage.h>
+#import <WebCore/Editor.h>
+#import <WebCore/FocusController.h>
+#import <WebCore/Frame.h>
+#import <WebCore/FrameSelection.h>
#import <WebCore/ContextMenuController.h>
#import <WebCore/Page.h>
@@ -48,6 +52,8 @@
#endif
+static NSString *imageControlPasteboardName = @"WebKitImageControlsPasteboard";
+
using namespace WebCore;
@implementation WebSharingServicePickerController
@@ -119,14 +125,22 @@
RetainPtr<CGImageSourceRef> source = adoptCF(CGImageSourceCreateWithData((CFDataRef)[items objectAtIndex:0], NULL));
RetainPtr<CGImageRef> cgImage = adoptCF(CGImageSourceCreateImageAtIndex(source.get(), 0, NULL));
- RefPtr<Image> image = BitmapImage::create(cgImage.get());
+ if (!cgImage)
+ return;
+
Page* page = [_menuClient->webView() page];
if (!page)
return;
- page->contextMenuController().replaceControlledImage(image.get());
+ NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:imageControlPasteboardName];
+ [pasteboard declareTypes:@[ NSPasteboardTypeTIFF ] owner:nil];
+ [pasteboard setData:[items objectAtIndex:0] forType:NSPasteboardTypeTIFF];
+ Frame& frame = page->focusController().focusedOrMainFrame();
+ if (!frame.selection().isNone())
+ frame.editor().readSelectionFromPasteboard(imageControlPasteboardName);
+
[self clear];
}
Modified: trunk/Source/WebKit2/ChangeLog (167673 => 167674)
--- trunk/Source/WebKit2/ChangeLog 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit2/ChangeLog 2014-04-22 19:22:28 UTC (rev 167674)
@@ -1,3 +1,30 @@
+2014-04-22 Brady Eidson <beid...@apple.com>
+
+ Change Image Controls replacement to use selection and paste
+ <rdar://problem/16302722> and https://bugs.webkit.org/show_bug.cgi?id=131992
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/mac/WebContextMenuProxyMac.mm:
+ (-[WKSharingServicePickerDelegate sharingService:didShareItems:]): Write the
+ replacement data to a special pasteboard, then replace the current selection from
+ that pasteboard.
+
+ Remove all other code used to support the old replacement mechanism:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::replaceControlledImage): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/mac/WebContextMenuProxyMac.h:
+ (WebKit::WebContextMenuProxyMac::page):
+ (WebKit::WebContextMenuProxyMac::replaceControlledImage): Deleted.
+ * WebProcess/WebPage/WebContextMenu.cpp:
+ (WebKit::WebContextMenu::replaceControlledImage): Deleted.
+ * WebProcess/WebPage/WebContextMenu.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::replaceControlledImage): Deleted.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
2014-04-22 Eunmi Lee <eunmi15....@samsung.com>
[EFL][WK2] Remove duplicated code to set size to the DrawingArea.
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (167673 => 167674)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-04-22 19:22:28 UTC (rev 167674)
@@ -3445,16 +3445,6 @@
m_contextMenuClient.contextMenuDismissed(this);
}
-#if ENABLE(IMAGE_CONTROLS)
-void WebPageProxy::replaceControlledImage(PassRefPtr<ShareableBitmap> newBitmap)
-{
- RefPtr<ShareableBitmap> bitmap = newBitmap;
- ShareableBitmap::Handle bitmapHandle;
- bitmap->createHandle(bitmapHandle);
- m_process->send(Messages::WebPage::ReplaceControlledImage(bitmapHandle), m_pageID);
-}
-#endif
-
void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
{
// Application custom items don't need to round-trip through to WebCore in the WebProcess.
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (167673 => 167674)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2014-04-22 19:22:28 UTC (rev 167674)
@@ -1059,10 +1059,6 @@
void takeSnapshot(WebCore::IntRect, WebCore::IntSize bitmapSize, SnapshotOptions, ImageCallback::CallbackFunction);
-#if ENABLE(IMAGE_CONTROLS)
- void replaceControlledImage(PassRefPtr<ShareableBitmap>);
-#endif
-
private:
WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, const WebPageConfiguration&);
void platformInitialize();
Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h (167673 => 167674)
--- trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h 2014-04-22 19:22:28 UTC (rev 167674)
@@ -55,9 +55,9 @@
#if ENABLE(IMAGE_CONTROLS)
void clearImageServicesMenu();
- void replaceControlledImage(CGImageRef newImage);
#endif
+ WebPageProxy& page() const { return *m_page; }
NSWindow *window() const;
private:
Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm (167673 => 167674)
--- trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm 2014-04-22 19:22:28 UTC (rev 167674)
@@ -56,8 +56,11 @@
@property NSSharingServicePickerStyle style;
- (NSMenu *)menu;
@end
-#endif
+static NSString *imageControlPasteboardName = @"WebKitImageControlsPasteboard";
+
+#endif // ENABLE(IMAGE_CONTROLS)
+
using namespace WebCore;
@interface WKUserDataWrapper : NSObject {
@@ -231,7 +234,15 @@
{
RetainPtr<CGImageSourceRef> source = adoptCF(CGImageSourceCreateWithData((CFDataRef)[items objectAtIndex:0], NULL));
RetainPtr<CGImageRef> image = adoptCF(CGImageSourceCreateImageAtIndex(source.get(), 0, NULL));
- _menuProxy->replaceControlledImage(image.get());
+
+ if (!image)
+ return;
+
+ NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:imageControlPasteboardName];
+ [pasteboard declareTypes:@[ NSPasteboardTypeTIFF ] owner:nil];
+ [pasteboard setData:[items objectAtIndex:0] forType:NSPasteboardTypeTIFF];
+
+ _menuProxy->page().readSelectionFromPasteboard(imageControlPasteboardName);
}
- (NSWindow *)sharingService:(NSSharingService *)sharingService sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope
@@ -249,6 +260,7 @@
: m_webView(webView)
, m_page(page)
{
+ ASSERT(m_page);
}
WebContextMenuProxyMac::~WebContextMenuProxyMac()
@@ -433,17 +445,6 @@
return [m_webView window];
}
-#if ENABLE(IMAGE_CONTROLS)
-void WebContextMenuProxyMac::replaceControlledImage(CGImageRef newImage)
-{
- FloatSize newImageSize(CGImageGetWidth(newImage), CGImageGetHeight(newImage));
- RefPtr<ShareableBitmap> newBitmap = ShareableBitmap::createShareable(expandedIntSize(newImageSize), ShareableBitmap::SupportsAlpha);
- newBitmap->createGraphicsContext()->drawNativeImage(newImage, newImageSize, ColorSpaceDeviceRGB, FloatRect(FloatPoint(), newImageSize), FloatRect(FloatPoint(), newImageSize));
-
- m_page->replaceControlledImage(newBitmap.release());
-}
-#endif
-
} // namespace WebKit
#endif // PLATFORM(MAC)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp (167673 => 167674)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebContextMenu.cpp 2014-04-22 19:22:28 UTC (rev 167674)
@@ -77,13 +77,6 @@
m_page->corePage()->contextMenuController().contextMenuItemSelected(&coreItem);
}
-#if ENABLE(IMAGE_CONTROLS)
-void WebContextMenu::replaceControlledImage(PassRefPtr<Image> newImage)
-{
- m_page->corePage()->contextMenuController().replaceControlledImage(newImage);
-}
-#endif
-
void WebContextMenu::menuItemsWithUserData(Vector<WebContextMenuItemData> &menuItems, RefPtr<API::Object>& userData) const
{
ContextMenuController& controller = m_page->corePage()->contextMenuController();
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebContextMenu.h (167673 => 167674)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebContextMenu.h 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebContextMenu.h 2014-04-22 19:22:28 UTC (rev 167674)
@@ -50,10 +50,6 @@
void itemSelected(const WebContextMenuItemData&);
Vector<WebContextMenuItemData> items() const;
-#if ENABLE(IMAGE_CONTROLS)
- void replaceControlledImage(PassRefPtr<WebCore::Image>);
-#endif
-
private:
WebContextMenu(WebPage*);
void menuItemsWithUserData(Vector<WebContextMenuItemData>&, RefPtr<API::Object>&) const;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (167673 => 167674)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2014-04-22 19:22:28 UTC (rev 167674)
@@ -3114,15 +3114,6 @@
}
#endif
-#if ENABLE(IMAGE_CONTROLS)
-void WebPage::replaceControlledImage(const ShareableBitmap::Handle& bitmapHandle)
-{
- RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(bitmapHandle);
- if (bitmap)
- m_contextMenu->replaceControlledImage(bitmap->createImage());
-}
-#endif
-
void WebPage::replaceSelectionWithText(Frame* frame, const String& text)
{
bool selectReplacement = true;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (167673 => 167674)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2014-04-22 19:22:28 UTC (rev 167674)
@@ -771,10 +771,6 @@
PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(WebCore::Frame&, const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
void getBytecodeProfile(uint64_t callbackID);
-
-#if ENABLE(IMAGE_CONTROLS)
- void replaceControlledImage(const ShareableBitmap::Handle&);
-#endif
// Some platforms require accessibility-enabled processes to spin the run loop so that the WebProcess doesn't hang.
// While this is not ideal, it does not have to be applied to every platform at the moment.
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (167673 => 167674)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2014-04-22 19:00:06 UTC (rev 167673)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2014-04-22 19:22:28 UTC (rev 167674)
@@ -362,8 +362,4 @@
GetBytecodeProfile(uint64_t callbackID)
TakeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options, uint64_t callbackID)
-
-#if ENABLE(IMAGE_CONTROLS)
- ReplaceControlledImage(WebKit::ShareableBitmap::Handle newBitmapHandle)
-#endif
}