Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Emit WebGestureEvent attributes for scroll-touch-edge event
Browse files Browse the repository at this point in the history
Auditors: @bridiver, @bbondy
  • Loading branch information
darkdh committed Sep 2, 2018
1 parent 5cfec9e commit b9cec60
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
10 changes: 8 additions & 2 deletions atom/browser/api/atom_api_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
Expand Down Expand Up @@ -274,8 +275,13 @@ void Window::OnWindowScrollTouchEnd() {
Emit("scroll-touch-end");
}

void Window::OnWindowScrollTouchEdge() {
Emit("scroll-touch-edge");
void Window::OnWindowScrollTouchEdge(const blink::WebGestureEvent& event) {
base::DictionaryValue dict;
dict.SetDouble("deltaX", event.data.scroll_update.delta_x);
dict.SetDouble("deltaY", event.data.scroll_update.delta_y);
dict.SetDouble("velocityX", event.data.scroll_update.velocity_x);
dict.SetDouble("velocityY", event.data.scroll_update.velocity_y);
Emit("scroll-touch-edge", dict);
}

void Window::OnWindowSwipe(const std::string& direction) {
Expand Down
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Window : public mate::TrackableObject<Window>,
void OnWindowMoved() override;
void OnWindowScrollTouchBegin() override;
void OnWindowScrollTouchEnd() override;
void OnWindowScrollTouchEdge() override;
void OnWindowScrollTouchEdge(const blink::WebGestureEvent&) override;
void OnWindowSwipe(const std::string& direction) override;
void OnWindowEnterFullScreen() override;
void OnWindowLeaveFullScreen() override;
Expand Down
5 changes: 3 additions & 2 deletions atom/browser/native_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,10 @@ void NativeWindow::NotifyWindowScrollTouchEnd() {
observer.OnWindowScrollTouchEnd();
}

void NativeWindow::NotifyWindowScrollTouchEdge() {
void NativeWindow::NotifyWindowScrollTouchEdge(
const blink::WebGestureEvent& event) {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowScrollTouchEdge();
observer.OnWindowScrollTouchEdge(event);
}

void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
Expand Down
3 changes: 2 additions & 1 deletion atom/browser/native_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "extensions/browser/app_window/size_constraints.h"
#include "third_party/blink/public/platform/web_gesture_event.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
Expand Down Expand Up @@ -219,7 +220,7 @@ class NativeWindow : public base::SupportsUserData,
void NotifyWindowMoved();
void NotifyWindowScrollTouchBegin();
void NotifyWindowScrollTouchEnd();
void NotifyWindowScrollTouchEdge();
void NotifyWindowScrollTouchEdge(const blink::WebGestureEvent&);
void NotifyWindowSwipe(const std::string& direction);
void NotifyWindowEnterFullScreen();
void NotifyWindowLeaveFullScreen();
Expand Down
10 changes: 6 additions & 4 deletions atom/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1205,11 +1205,13 @@ void ClearControlRegions(NSView* view) {

void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
switch (event.GetType()) {
case blink::WebInputEvent::kGestureScrollBegin:
case blink::WebInputEvent::kGestureScrollUpdate:
case blink::WebInputEvent::kGestureScrollEnd:
this->NotifyWindowScrollTouchEdge();
break;
{
const blink::WebGestureEvent& gesture_event =
static_cast<const blink::WebGestureEvent&>(event);
this->NotifyWindowScrollTouchEdge(gesture_event);
break;
}
default:
break;
}
Expand Down
6 changes: 5 additions & 1 deletion atom/browser/native_window_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <windows.h>
#endif

namespace blink {
class WebGestureEvent;
}

namespace atom {

class NativeWindowObserver {
Expand Down Expand Up @@ -64,7 +68,7 @@ class NativeWindowObserver {
virtual void OnWindowMoved() {}
virtual void OnWindowScrollTouchBegin() {}
virtual void OnWindowScrollTouchEnd() {}
virtual void OnWindowScrollTouchEdge() {}
virtual void OnWindowScrollTouchEdge(const blink::WebGestureEvent&) {}
virtual void OnWindowSwipe(const std::string& direction) {}
virtual void OnWindowEnterFullScreen() {}
virtual void OnWindowLeaveFullScreen() {}
Expand Down

0 comments on commit b9cec60

Please sign in to comment.