[webkit] Add horizontal arrow key scrolling
Also support key repeat.
Change-Id: I303b406e52a04593226247516cb30d81b854071c
diff --git a/Source/WebKit/fuchsia/WebView.cpp b/Source/WebKit/fuchsia/WebView.cpp
index e51a004..cc4e5c7 100644
--- a/Source/WebKit/fuchsia/WebView.cpp
+++ b/Source/WebKit/fuchsia/WebView.cpp
@@ -205,22 +205,31 @@
void WebView::scrollDownOneLine()
{
- if (m_page) {
- Frame* frame = m_frameLoaderClient->frame();
- if (frame) {
- FrameView* view = frame->view();
- view->scroll(ScrollDirection::ScrollDown, ScrollGranularity::ScrollByLine);
- }
- }
+ scrollInternal(ScrollDirection::ScrollDown, ScrollGranularity::ScrollByLine);
}
void WebView::scrollUpOneLine()
{
+ scrollInternal(ScrollDirection::ScrollUp, ScrollGranularity::ScrollByLine);
+}
+
+void WebView::scrollLeftOneLine()
+{
+ scrollInternal(ScrollDirection::ScrollLeft, ScrollGranularity::ScrollByLine);
+}
+
+void WebView::scrollRightOneLine()
+{
+ scrollInternal(ScrollDirection::ScrollRight, ScrollGranularity::ScrollByLine);
+}
+
+void WebView::scrollInternal(uint8_t direction, uint8_t granularity)
+{
if (m_page) {
Frame* frame = m_frameLoaderClient->frame();
if (frame) {
FrameView* view = frame->view();
- view->scroll(ScrollDirection::ScrollUp, ScrollGranularity::ScrollByLine);
+ view->scroll((ScrollDirection)direction, (ScrollGranularity)granularity);
}
}
}
@@ -283,7 +292,7 @@
}
}
-bool WebView::handleKeyEvent(uint8_t keycode, uint8_t charValue, bool pressed)
+bool WebView::handleKeyEvent(uint8_t keycode, uint8_t charValue, bool pressed, bool repeat)
{
string identifier;
@@ -319,7 +328,7 @@
auto now = std::chrono::steady_clock::now().time_since_epoch();
auto timeSinceEpoch = std::chrono::duration_cast<std::chrono::milliseconds>(now).count();
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);
+ 0, keycode, 0, repeat, false, false, (PlatformEvent::Modifiers)rawModifiers, timeSinceEpoch);
auto& mainFrame = m_page->mainFrame();
return mainFrame.eventHandler().keyEvent(keyboardEvent);
}
diff --git a/Source/WebKit/fuchsia/WebView.h b/Source/WebKit/fuchsia/WebView.h
index d5d25d7..79aa0dd 100644
--- a/Source/WebKit/fuchsia/WebView.h
+++ b/Source/WebKit/fuchsia/WebView.h
@@ -57,6 +57,8 @@
void scrollDownOneLine();
void scrollUpOneLine();
+ void scrollLeftOneLine();
+ void scrollRightOneLine();
void layoutAndPaint();
@@ -65,7 +67,7 @@
void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor);
void handleMouseEvent(int x, int y, MouseEventKind eventType);
- bool handleKeyEvent(uint8_t keycode, uint8_t charValue, bool pressed);
+ bool handleKeyEvent(uint8_t keycode, uint8_t charValue, bool pressed, bool repeat);
void iterateEventLoop();
@@ -76,6 +78,7 @@
private:
void setURLInternal(const WebCore::URL& url);
+ void scrollInternal(uint8_t direction, uint8_t granularity);
WebCore::Page* m_page = { nullptr };
cairo_t* m_cairoContext = { nullptr };
diff --git a/Tools/MiniBrowser/fuchsia/main.cpp b/Tools/MiniBrowser/fuchsia/main.cpp
index 20c44d0..8c82560 100644
--- a/Tools/MiniBrowser/fuchsia/main.cpp
+++ b/Tools/MiniBrowser/fuchsia/main.cpp
@@ -228,7 +228,7 @@
} else if (controlDown && keycode == HID_USAGE_KEY_RIGHTBRACE) {
webView.goForward();
} else {
- bool handled = webView.handleKeyEvent(keycode, ch, pressed);
+ bool handled = webView.handleKeyEvent(keycode, ch, pressed, false);
if (!handled) {
if (keycode == HID_USAGE_KEY_DOWN) {
webView.scrollDownOneLine();