Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: ui/events/cocoa/events_mac.mm

Issue 2226933004: Mac: Share kScrollbarPixelsPerCocoaTick between ui:: and blink:: events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unconsolidate! NSApp sendEvent is too magical Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/event_utils.h" 5 #include "ui/events/event_utils.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 return 0; 134 return 0;
135 } 135 }
136 136
137 PointerDetails GetMousePointerDetailsFromNative( 137 PointerDetails GetMousePointerDetailsFromNative(
138 const base::NativeEvent& native_event) { 138 const base::NativeEvent& native_event) {
139 return PointerDetails(EventPointerType::POINTER_TYPE_MOUSE); 139 return PointerDetails(EventPointerType::POINTER_TYPE_MOUSE);
140 } 140 }
141 141
142 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& event) { 142 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& event) {
143 if ([event respondsToSelector:@selector(hasPreciseScrollingDeltas)] && 143 if ([event hasPreciseScrollingDeltas]) {
144 [event hasPreciseScrollingDeltas]) {
Avi (use Gerrit) 2016/08/10 15:17:29 Yay 10.7!
145 // Handle continuous scrolling devices such as a Magic Mouse or a trackpad. 144 // Handle continuous scrolling devices such as a Magic Mouse or a trackpad.
146 // -scrollingDelta{X|Y} have float return types but they return values that 145 // -scrollingDelta{X|Y} have float return types but they return values that
147 // are already rounded to integers. 146 // are already rounded to integers.
148 // The values are the same as the values returned from calling 147 // The values are the same as the values returned from calling
149 // CGEventGetIntegerValueField(kCGScrollWheelEventPointDeltaAxis{1|2}). 148 // CGEventGetIntegerValueField(kCGScrollWheelEventPointDeltaAxis{1|2}).
150 return gfx::Vector2d([event scrollingDeltaX], [event scrollingDeltaY]); 149 return gfx::Vector2d([event scrollingDeltaX], [event scrollingDeltaY]);
151 } else { 150 } else {
152 // Empirically, a value of 0.1 is typical for one mousewheel click. Positive 151 // Empirically, a value of 0.1 is typical for one mousewheel click. Positive
153 // values when scrolling up or to the left. Scrolling quickly results in a 152 // values when scrolling up or to the left. Scrolling quickly results in a
154 // higher delta per click, up to about 15.0. (Quartz documentation suggests 153 // higher delta per click, up to about 15.0. (Quartz documentation suggests
155 // +/-10). 154 // +/-10).
156 // Multiply by 1000 to vaguely approximate WHEEL_DELTA on Windows (120). 155 // Use the same multiplier as content::WebMouseWheelEventBuilder. Note this
157 const CGFloat kWheelDeltaMultiplier = 1000; 156 // differs from the value returned by CGEventSourceGetPixelsPerLine(), which
158 return gfx::Vector2d(kWheelDeltaMultiplier * [event deltaX], 157 // is typically 10.
159 kWheelDeltaMultiplier * [event deltaY]); 158 return gfx::Vector2d(kScrollbarPixelsPerCocoaTick * [event deltaX],
159 kScrollbarPixelsPerCocoaTick * [event deltaY]);
160 } 160 }
161 } 161 }
162 162
163 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) { 163 base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) {
164 return [event copy]; 164 return [event copy];
165 } 165 }
166 166
167 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) { 167 void ReleaseCopiedNativeEvent(const base::NativeEvent& event) {
168 [event release]; 168 [event release];
169 } 169 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 uint16_t return_value; 261 uint16_t return_value;
262 [text getCharacters:&return_value]; 262 [text getCharacters:&return_value];
263 return return_value; 263 return return_value;
264 } 264 }
265 265
266 bool IsCharFromNative(const base::NativeEvent& native_event) { 266 bool IsCharFromNative(const base::NativeEvent& native_event) {
267 return false; 267 return false;
268 } 268 }
269 269
270 } // namespace ui 270 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698