[webkit] Expose scroll by line

Wired up to uparrow and down to downarrow

Change-Id: I21d9380c68dcff73556518a0bca525a66d3ad5b7
diff --git a/Source/WebKit/fuchsia/WebView.cpp b/Source/WebKit/fuchsia/WebView.cpp
index 213fc6e..60039b8 100644
--- a/Source/WebKit/fuchsia/WebView.cpp
+++ b/Source/WebKit/fuchsia/WebView.cpp
@@ -194,6 +194,28 @@
     }
 }
 
+void WebView::scrollDownOneLine()
+{
+    if (m_page) {
+        Frame* frame = m_frameLoaderClient->frame();
+        if (frame) {
+            FrameView* view = frame->view();
+            view->scroll(ScrollDirection::ScrollDown, ScrollGranularity::ScrollByLine);
+        }
+    }
+}
+
+void WebView::scrollUpOneLine()
+{
+    if (m_page) {
+        Frame* frame = m_frameLoaderClient->frame();
+        if (frame) {
+            FrameView* view = frame->view();
+            view->scroll(ScrollDirection::ScrollUp, ScrollGranularity::ScrollByLine);
+        }
+    }
+}
+
 void WebView::layoutAndPaint()
 {
     Frame* frame = m_frameLoaderClient->frame();
@@ -252,7 +274,7 @@
     }
 }
 
-void WebView::handleKeyEvent(uint8_t keycode, uint8_t charValue, bool pressed)
+bool WebView::handleKeyEvent(uint8_t keycode, uint8_t charValue, bool pressed)
 {
     string identifier;
 
@@ -290,7 +312,7 @@
     WebCore::PlatformKeyboardEvent keyboardEvent(pressed ? WebCore::PlatformEvent::KeyDown : WebCore::PlatformEvent::KeyUp, charStr, charStr, identifier.c_str(),
         0, keycode, 0, false, false, false, (PlatformEvent::Modifiers)rawModifiers, timeSinceEpoch);
     auto& mainFrame = m_page->mainFrame();
-    mainFrame.eventHandler().keyEvent(keyboardEvent);
+    return mainFrame.eventHandler().keyEvent(keyboardEvent);
 }
 
 void WebView::iterateEventLoop()
diff --git a/Source/WebKit/fuchsia/WebView.h b/Source/WebKit/fuchsia/WebView.h
index a81dfa4..2961375 100644
--- a/Source/WebKit/fuchsia/WebView.h
+++ b/Source/WebKit/fuchsia/WebView.h
@@ -54,6 +54,9 @@
     void goBack();
     void goForward();
 
+    void scrollDownOneLine();
+    void scrollUpOneLine();
+
     void layoutAndPaint();
 
     void setFocused(bool);
@@ -61,7 +64,7 @@
     void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor);
 
     void handleMouseEvent(int x, int y, MouseEventKind eventType);
-    void handleKeyEvent(uint8_t keycode, uint8_t charValue, bool pressed);
+    bool handleKeyEvent(uint8_t keycode, uint8_t charValue, bool pressed);
 
     void iterateEventLoop();
 
diff --git a/Tools/MiniBrowser/fuchsia/main.cpp b/Tools/MiniBrowser/fuchsia/main.cpp
index 6c23faf..20c44d0 100644
--- a/Tools/MiniBrowser/fuchsia/main.cpp
+++ b/Tools/MiniBrowser/fuchsia/main.cpp
@@ -228,7 +228,14 @@
                     } else if (controlDown && keycode == HID_USAGE_KEY_RIGHTBRACE) {
                         webView.goForward();
                     } else {
-                        webView.handleKeyEvent(keycode, ch, pressed);
+                        bool handled = webView.handleKeyEvent(keycode, ch, pressed);
+                        if (!handled) {
+                            if (keycode == HID_USAGE_KEY_DOWN) {
+                                webView.scrollDownOneLine();
+                            } else if (keycode == HID_USAGE_KEY_UP) {
+                                webView.scrollUpOneLine();
+                            }
+                        }
                     }
                 }
             }