Title: [111267] trunk
Revision
111267
Author
[email protected]
Date
2012-03-19 16:20:56 -0700 (Mon, 19 Mar 2012)

Log Message

<rdar://problem/10848575> and https://bugs.webkit.org/show_bug.cgi?id=81516
REGRESSION (r107435) URLs copied from WebKit apps aren't in the right pasteboard format

Reviewed by Enrica Casucci.

Source/WebCore:

r107435 started saving/restoring URLs as strings.
We need to go back to setting the URL on the pasteboard using AppKit URL pasteboard APIs.

WebKit API test: ContextMenuCanCopyURL
No WebKit2 API test possible at this time.

* platform/mac/PlatformPasteboardMac.mm:
(WebCore::PlatformPasteboard::setURL):

Tools:

Bring up a context menu on a link, copy the link, then verify the pasteboard contents
are in the correct format.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.html: Added.
* TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.mm: Added.
(-[ContextMenuCanCopyURLDelegate webView:didFinishLoadForFrame:]):
(TestWebKitAPI::contextMenuCopyLink):
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (111266 => 111267)


--- trunk/Source/WebCore/ChangeLog	2012-03-19 23:11:15 UTC (rev 111266)
+++ trunk/Source/WebCore/ChangeLog	2012-03-19 23:20:56 UTC (rev 111267)
@@ -1,3 +1,19 @@
+2012-03-19  Brady Eidson  <[email protected]>
+
+        <rdar://problem/10848575> and https://bugs.webkit.org/show_bug.cgi?id=81516
+        REGRESSION (r107435) URLs copied from WebKit apps aren't in the right pasteboard format
+
+        Reviewed by Enrica Casucci.
+
+        r107435 started saving/restoring URLs as strings.
+        We need to go back to setting the URL on the pasteboard using AppKit URL pasteboard APIs.
+
+        WebKit API test: ContextMenuCanCopyURL
+        No WebKit2 API test possible at this time.
+
+        * platform/mac/PlatformPasteboardMac.mm:
+        (WebCore::PlatformPasteboard::setURL):
+
 2012-03-19  Anders Carlsson  <[email protected]>
 
         Make the TileCache work with HiDPI again

Modified: trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm (111266 => 111267)


--- trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm	2012-03-19 23:11:15 UTC (rev 111266)
+++ trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm	2012-03-19 23:20:56 UTC (rev 111267)
@@ -146,7 +146,10 @@
 
 void PlatformPasteboard::setStringForType(const String& string, const String& pasteboardType)
 {
-    [m_pasteboard.get() setString:string forType:pasteboardType];
+    if (pasteboardType == String(NSURLPboardType))
+        [[NSURL URLWithString:string] writeToPasteboard:m_pasteboard.get()];
+    else
+        [m_pasteboard.get() setString:string forType:pasteboardType];
 }
 
 }

Modified: trunk/Tools/ChangeLog (111266 => 111267)


--- trunk/Tools/ChangeLog	2012-03-19 23:11:15 UTC (rev 111266)
+++ trunk/Tools/ChangeLog	2012-03-19 23:20:56 UTC (rev 111267)
@@ -1,3 +1,20 @@
+2012-03-19  Brady Eidson  <[email protected]>
+
+        <rdar://problem/10848575> and https://bugs.webkit.org/show_bug.cgi?id=81516
+        REGRESSION (r107435) URLs copied from WebKit apps aren't in the right pasteboard format
+
+        Reviewed by Enrica Casucci.
+
+        Bring up a context menu on a link, copy the link, then verify the pasteboard contents
+        are in the correct format.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.html: Added.
+        * TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.mm: Added.
+        (-[ContextMenuCanCopyURLDelegate webView:didFinishLoadForFrame:]):
+        (TestWebKitAPI::contextMenuCopyLink):
+        (TestWebKitAPI::TEST):
+
 2012-03-19  Ojan Vafai  <[email protected]>
 
         Make the selected item in the accordion a link to the flakiness dashboard

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (111266 => 111267)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2012-03-19 23:11:15 UTC (rev 111266)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2012-03-19 23:20:56 UTC (rev 111267)
@@ -38,6 +38,8 @@
 		440A1D3914A0103A008A66F2 /* KURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 440A1D3814A0103A008A66F2 /* KURL.cpp */; };
 		4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */; };
 		4BFDFFA9131477770061F24B /* HitTestResultNodeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA8131477770061F24B /* HitTestResultNodeHandle.cpp */; };
+		5142B2711517C88B00C32B19 /* ContextMenuCanCopyURL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5142B2701517C88B00C32B19 /* ContextMenuCanCopyURL.mm */; };
+		5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */; };
 		51FBBB4D1513D4E900822738 /* WebViewCanPasteURL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */; };
 		520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */; };
 		520BCF4D141EB09E00937EA8 /* WebArchive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 520BCF4B141EB09E00937EA8 /* WebArchive.cpp */; };
@@ -158,6 +160,7 @@
 			dstPath = TestWebKitAPI.resources;
 			dstSubfolderSpec = 7;
 			files = (
+				5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */,
 				379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
 				33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */,
 				1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */,
@@ -214,6 +217,8 @@
 		44A622C114A0E2B60048515B /* WTFStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFStringUtilities.h; sourceTree = "<group>"; };
 		4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestResultNodeHandle_Bundle.cpp; sourceTree = "<group>"; };
 		4BFDFFA8131477770061F24B /* HitTestResultNodeHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestResultNodeHandle.cpp; sourceTree = "<group>"; };
+		5142B2701517C88B00C32B19 /* ContextMenuCanCopyURL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuCanCopyURL.mm; sourceTree = "<group>"; };
+		5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContextMenuCanCopyURL.html; sourceTree = "<group>"; };
 		51FBBB4C1513D4E900822738 /* WebViewCanPasteURL.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewCanPasteURL.mm; sourceTree = "<group>"; };
 		520BCF4A141EB09E00937EA8 /* WebArchive_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebArchive_Bundle.cpp; sourceTree = "<group>"; };
 		520BCF4B141EB09E00937EA8 /* WebArchive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebArchive.cpp; sourceTree = "<group>"; };
@@ -588,6 +593,7 @@
 			children = (
 				C07E6CB013FD737C0038B22B /* Resources */,
 				379028B514FABD92007E6B43 /* AcceptsFirstMouse.mm */,
+				5142B2701517C88B00C32B19 /* ContextMenuCanCopyURL.mm */,
 				37DC678B140D7C5000ABCCDB /* DOMRangeOfString.mm */,
 				C07E6CAE13FD67650038B22B /* DynamicDeviceScaleFactor.mm */,
 				3776BC62150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm */,
@@ -606,8 +612,9 @@
 			isa = PBXGroup;
 			children = (
 				379028B814FABE49007E6B43 /* acceptsFirstMouse.html */,
+				5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */,
+				37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */,
 				C07E6CB113FD738A0038B22B /* devicePixelRatio.html */,
-				37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */,
 			);
 			name = Resources;
 			sourceTree = "<group>";
@@ -803,6 +810,7 @@
 				379028B614FABD92007E6B43 /* AcceptsFirstMouse.mm in Sources */,
 				3776BC63150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm in Sources */,
 				51FBBB4D1513D4E900822738 /* WebViewCanPasteURL.mm in Sources */,
+				5142B2711517C88B00C32B19 /* ContextMenuCanCopyURL.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.html (0 => 111267)


--- trunk/Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.html	2012-03-19 23:20:56 UTC (rev 111267)
@@ -0,0 +1 @@
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<a href=''>Click me</a>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\ No newline at end of file

Added: trunk/Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.mm (0 => 111267)


--- trunk/Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/ContextMenuCanCopyURL.mm	2012-03-19 23:20:56 UTC (rev 111267)
@@ -0,0 +1,107 @@
+/*
+ * 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 "config.h"
+#import "PlatformUtilities.h"
+#import "PlatformWebView.h"
+#import "WTFStringUtilities.h"
+
+#import <WebKit/WebViewPrivate.h>
+#import <WebKit/DOM.h>
+#import <Carbon/Carbon.h>
+#import <wtf/RetainPtr.h>
+
+
+@interface ContextMenuCanCopyURLDelegate : NSObject {
+}
+@end
+
+static bool didFinishLoad;
+
+@implementation ContextMenuCanCopyURLDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    didFinishLoad = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+static void contextMenuCopyLink(WebView* webView)
+{
+    [[[[webView mainFrame] frameView] documentView] layout];
+    
+    DOMDocument *document = [[webView mainFrame] DOMDocument];
+    DOMElement *documentElement = [document documentElement];
+    DOMHTMLAnchorElement *anchor = (DOMHTMLAnchorElement *)[documentElement querySelector:@"a"];
+
+    NSWindow *window = [webView window];
+    NSEvent *event = [NSEvent mouseEventWithType:NSRightMouseDown
+                                        location:NSMakePoint(anchor.offsetLeft + anchor.offsetWidth / 2, window.frame.size.height - (anchor.offsetTop + anchor.offsetHeight / 2))
+                                   modifierFlags:0
+                                       timestamp:GetCurrentEventTime()
+                                    windowNumber:[window windowNumber]
+                                         context:[NSGraphicsContext currentContext] 
+                                     eventNumber:0
+                                      clickCount:0
+                                        pressure:0.0];
+
+    NSView *subView = [webView hitTest:[event locationInWindow]];
+    if (!subView)
+        return;
+
+    NSMenu* menu = [subView menuForEvent:event];
+    for (int i = 0; i < [menu numberOfItems]; ++i) {
+        NSMenuItem* menuItem = [menu itemAtIndex:i];
+        if ([menuItem tag] != WebMenuItemTagCopyLinkToClipboard)
+            continue;
+            
+        [menu performActionForItemAtIndex:i];
+    }
+}
+
+
+TEST(WebKit1, ContextMenuCanCopyURL)
+{
+    RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0,0,800,600) frameName:nil groupName:nil]);
+    RetainPtr<NSWindow> window(AdoptNS, [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 100, 800, 600) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+    RetainPtr<ContextMenuCanCopyURLDelegate> delegate(AdoptNS, [[ContextMenuCanCopyURLDelegate alloc] init]);
+
+    [window.get().contentView addSubview:webView.get()];
+    webView.get().frameLoadDelegate = delegate.get();
+
+    [webView.get().mainFrame loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"ContextMenuCanCopyURL" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
+    
+    Util::run(&didFinishLoad);
+
+    contextMenuCopyLink(webView.get());
+    
+    NSURL *url = "" URLFromPasteboard:[NSPasteboard generalPasteboard]];
+    EXPECT_EQ(String("http://www.webkit.org/"), String([url absoluteString]));
+}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to