Title: [103302] trunk
Revision
103302
Author
wei...@apple.com
Date
2011-12-19 21:10:02 -0800 (Mon, 19 Dec 2011)

Log Message

Add support for scrollLineDown: and scrollLineUp: NSResponder selectors
https://bugs.webkit.org/show_bug.cgi?id=74907

Reviewed by Dan Bernstein.

Source/WebCore:

Added API test: WebKit2.ScrollByLineCommands

* editing/EditorCommand.cpp:
(WebCore::executeScrollLineUp):
(WebCore::executeScrollLineDown):
(WebCore::createCommandMap):
Add implementations for scrollLineUp/Down. Do not expose
these to execCommand.

Source/WebKit2:

* UIProcess/API/mac/WKView.mm:
Add implementations for scrollLineDown: and scrollLineUp: using our
fun macros.

Tools:

Add ScrollByLineCommands API test.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/mac/EditorCommands.mm: Added.
* TestWebKitAPI/Tests/WebKit2/simple-tall.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (103301 => 103302)


--- trunk/Source/WebCore/ChangeLog	2011-12-20 05:01:09 UTC (rev 103301)
+++ trunk/Source/WebCore/ChangeLog	2011-12-20 05:10:02 UTC (rev 103302)
@@ -1,3 +1,19 @@
+2011-12-19  Sam Weinig  <s...@webkit.org>
+
+        Add support for scrollLineDown: and scrollLineUp: NSResponder selectors
+        https://bugs.webkit.org/show_bug.cgi?id=74907
+
+        Reviewed by Dan Bernstein.
+
+        Added API test: WebKit2.ScrollByLineCommands
+
+        * editing/EditorCommand.cpp:
+        (WebCore::executeScrollLineUp):
+        (WebCore::executeScrollLineDown):
+        (WebCore::createCommandMap):
+        Add implementations for scrollLineUp/Down. Do not expose
+        these to execCommand
+
 2011-12-19  Huang Dongsung  <luxte...@company100.net>
 
         [QT] WebGL can not make the frame buffer with the stencil buffer.

Modified: trunk/Source/WebCore/editing/EditorCommand.cpp (103301 => 103302)


--- trunk/Source/WebCore/editing/EditorCommand.cpp	2011-12-20 05:01:09 UTC (rev 103301)
+++ trunk/Source/WebCore/editing/EditorCommand.cpp	2011-12-20 05:10:02 UTC (rev 103302)
@@ -955,6 +955,16 @@
     return frame->eventHandler()->logicalScrollRecursively(ScrollBlockDirectionForward, ScrollByPage);
 }
 
+static bool executeScrollLineUp(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+    return frame->eventHandler()->scrollRecursively(ScrollUp, ScrollByLine);
+}
+
+static bool executeScrollLineDown(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+    return frame->eventHandler()->scrollRecursively(ScrollDown, ScrollByLine);
+}
+
 static bool executeScrollToBeginningOfDocument(Frame* frame, Event*, EditorCommandSource, const String&)
 {
     return frame->eventHandler()->logicalScrollRecursively(ScrollBlockDirectionBackward, ScrollByDocument);
@@ -1514,6 +1524,8 @@
         { "RemoveFormat", { executeRemoveFormat, supported, enabledRangeInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "ScrollPageBackward", { executeScrollPageBackward, supportedFromMenuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "ScrollPageForward", { executeScrollPageForward, supportedFromMenuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
+        { "ScrollLineUp", { executeScrollLineUp, supportedFromMenuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
+        { "ScrollLineDown", { executeScrollLineDown, supportedFromMenuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "ScrollToBeginningOfDocument", { executeScrollToBeginningOfDocument, supportedFromMenuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "ScrollToEndOfDocument", { executeScrollToEndOfDocument, supportedFromMenuOrKeyBinding, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "SelectAll", { executeSelectAll, supported, enabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },

Modified: trunk/Source/WebKit2/ChangeLog (103301 => 103302)


--- trunk/Source/WebKit2/ChangeLog	2011-12-20 05:01:09 UTC (rev 103301)
+++ trunk/Source/WebKit2/ChangeLog	2011-12-20 05:10:02 UTC (rev 103302)
@@ -1,5 +1,16 @@
 2011-12-19  Sam Weinig  <s...@webkit.org>
 
+        Add support for scrollLineDown: and scrollLineUp: NSResponder selectors
+        https://bugs.webkit.org/show_bug.cgi?id=74907
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/API/mac/WKView.mm:
+        Add implementations for scrollLineDown: and scrollLineUp: using our
+        fun macros.
+
+2011-12-19  Sam Weinig  <s...@webkit.org>
+
         More PlatformEvent cleanup
         https://bugs.webkit.org/show_bug.cgi?id=74831
 

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (103301 => 103302)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2011-12-20 05:01:09 UTC (rev 103301)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2011-12-20 05:10:02 UTC (rev 103302)
@@ -486,6 +486,8 @@
 WEBCORE_COMMAND(pasteAsPlainText)
 WEBCORE_COMMAND(scrollPageDown)
 WEBCORE_COMMAND(scrollPageUp)
+WEBCORE_COMMAND(scrollLineDown)
+WEBCORE_COMMAND(scrollLineUp)
 WEBCORE_COMMAND(scrollToBeginningOfDocument)
 WEBCORE_COMMAND(scrollToEndOfDocument)
 WEBCORE_COMMAND(selectAll)

Modified: trunk/Tools/ChangeLog (103301 => 103302)


--- trunk/Tools/ChangeLog	2011-12-20 05:01:09 UTC (rev 103301)
+++ trunk/Tools/ChangeLog	2011-12-20 05:10:02 UTC (rev 103302)
@@ -1,3 +1,16 @@
+2011-12-19  Sam Weinig  <s...@webkit.org>
+
+        Add support for scrollLineDown: and scrollLineUp: NSResponder selectors
+        https://bugs.webkit.org/show_bug.cgi?id=74907
+
+        Reviewed by Dan Bernstein.
+
+        Add ScrollByLineCommands API test.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/mac/EditorCommands.mm: Added.
+        * TestWebKitAPI/Tests/WebKit2/simple-tall.html: Added.
+
 2011-12-19  Dirk Pranke  <dpra...@chromium.org>
 
         webkitpy: remove port.executive, port.filesystem, port.user properties

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (103301 => 103302)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2011-12-20 05:01:09 UTC (rev 103301)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2011-12-20 05:10:02 UTC (rev 103302)
@@ -73,6 +73,8 @@
 		BC90995E12567BC100083756 /* WKString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC90995D12567BC100083756 /* WKString.cpp */; };
 		BC9099941256ACF100083756 /* WKStringJSString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC9099931256ACF100083756 /* WKStringJSString.cpp */; };
 		BCA61DB511700EFD00460D1E /* WebKit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCA61DB411700EFD00460D1E /* WebKit2.framework */; };
+		BCAA485614A0444C0088FAC4 /* simple-tall.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = BCAA485514A021640088FAC4 /* simple-tall.html */; };
+		BCAA485814A044D40088FAC4 /* EditorCommands.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCAA485714A044D40088FAC4 /* EditorCommands.mm */; };
 		BCB68040126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB6803F126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp */; };
 		BCB68042126FBFF100642A61 /* DocumentStartUserScriptAlertCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB68041126FBFF100642A61 /* DocumentStartUserScriptAlertCrash_Bundle.cpp */; };
 		BCB9E9F111235BDE00A137E0 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCB9E9F011235BDE00A137E0 /* Cocoa.framework */; };
@@ -142,6 +144,7 @@
 				1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */,
 				BC909784125571CF00083756 /* simple.html in Copy Resources */,
 				C0ADBE9612FCA79B00D2C129 /* simple-form.html in Copy Resources */,
+				BCAA485614A0444C0088FAC4 /* simple-tall.html in Copy Resources */,
 				C01A23F21266156700C9ED55 /* spacebar-scrolling.html in Copy Resources */,
 				BC2D006412AA04CE00E732A3 /* file-with-anchor.html in Copy Resources */,
 				37DC6791140D7D7600ABCCDB /* DOMRangeOfString.html in Copy Resources */,
@@ -225,6 +228,8 @@
 		BC90995D12567BC100083756 /* WKString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKString.cpp; sourceTree = "<group>"; };
 		BC9099931256ACF100083756 /* WKStringJSString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKStringJSString.cpp; sourceTree = "<group>"; };
 		BCA61DB411700EFD00460D1E /* WebKit2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		BCAA485514A021640088FAC4 /* simple-tall.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-tall.html"; sourceTree = "<group>"; };
+		BCAA485714A044D40088FAC4 /* EditorCommands.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EditorCommands.mm; sourceTree = "<group>"; };
 		BCB6803F126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentStartUserScriptAlertCrash.cpp; sourceTree = "<group>"; };
 		BCB68041126FBFF100642A61 /* DocumentStartUserScriptAlertCrash_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentStartUserScriptAlertCrash_Bundle.cpp; sourceTree = "<group>"; };
 		BCB9E7C711234E3A00A137E0 /* TestsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestsController.h; sourceTree = "<group>"; };
@@ -464,6 +469,7 @@
 				1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */,
 				C0ADBE8412FCA6B600D2C129 /* simple-form.html */,
 				33DC890E1419539300747EF7 /* simple-iframe.html */,
+				BCAA485514A021640088FAC4 /* simple-tall.html */,
 				BC909778125571AB00083756 /* simple.html */,
 				C02B7882126615410026BF0F /* spacebar-scrolling.html */,
 			);
@@ -554,6 +560,7 @@
 			children = (
 				C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */,
 				C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */,
+				BCAA485714A044D40088FAC4 /* EditorCommands.mm */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -699,6 +706,7 @@
 				BC029B1C1486B25900817DA9 /* RetainPtr.mm in Sources */,
 				BC901E241492ADCE0074A667 /* WKConnection.cpp in Sources */,
 				1AA9E55914980A9900001A8A /* Functional.cpp in Sources */,
+				BCAA485814A044D40088FAC4 /* EditorCommands.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/EditorCommands.mm (0 => 103302)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/EditorCommands.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/EditorCommands.mm	2011-12-20 05:10:02 UTC (rev 103302)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "_javascript_Test.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include <WebKit2/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+static bool didFinishLoad;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
+{
+    didFinishLoad = true;
+}
+
+TEST(WebKit2, ScrollByLineCommands)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextWithInjectedBundle());
+    PlatformWebView webView(context.get());
+
+    WKPageLoaderClient loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+    loaderClient.version = 0;
+    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+    WKPageSetPageLoaderClient(webView.page(), &loaderClient);
+
+    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple-tall", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+    Util::run(&didFinishLoad);
+
+    EXPECT_JS_EQ(webView.page(), "window.scrollY", "0");
+
+    ASSERT_TRUE([webView.platformView() respondsToSelector:@selector(scrollLineDown:)]);
+    [webView.platformView() scrollLineDown:nil];
+
+    EXPECT_JS_EQ(webView.page(), "window.scrollY", "40");
+
+    ASSERT_TRUE([webView.platformView() respondsToSelector:@selector(scrollLineUp:)]);
+    [webView.platformView() scrollLineUp:nil];
+
+    EXPECT_JS_EQ(webView.page(), "window.scrollY", "0");
+}
+
+} // namespace TestWebKitAPI

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple-tall.html (0 => 103302)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple-tall.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/simple-tall.html	2011-12-20 05:10:02 UTC (rev 103302)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+  Simple and tall HTML file.
+  <div style="height: 3000px;"></div>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to