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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 #import <objc/runtime.h> 8 #import <objc/runtime.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 #include <QuartzCore/QuartzCore.h> 10 #include <QuartzCore/QuartzCore.h>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "ui/base/cocoa/animation_utils.h" 72 #include "ui/base/cocoa/animation_utils.h"
73 #import "ui/base/cocoa/appkit_utils.h" 73 #import "ui/base/cocoa/appkit_utils.h"
74 #include "ui/base/cocoa/cocoa_base_utils.h" 74 #include "ui/base/cocoa/cocoa_base_utils.h"
75 #import "ui/base/cocoa/fullscreen_window_manager.h" 75 #import "ui/base/cocoa/fullscreen_window_manager.h"
76 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" 76 #import "ui/base/cocoa/underlay_opengl_hosting_window.h"
77 #include "ui/base/layout.h" 77 #include "ui/base/layout.h"
78 #include "ui/compositor/compositor.h" 78 #include "ui/compositor/compositor.h"
79 #include "ui/compositor/layer.h" 79 #include "ui/compositor/layer.h"
80 #include "ui/display/display.h" 80 #include "ui/display/display.h"
81 #include "ui/display/screen.h" 81 #include "ui/display/screen.h"
82 #include "ui/events/base_event_utils.h"
82 #include "ui/events/event_utils.h" 83 #include "ui/events/event_utils.h"
83 #include "ui/events/keycodes/keyboard_codes.h" 84 #include "ui/events/keycodes/keyboard_codes.h"
84 #include "ui/gfx/geometry/dip_util.h" 85 #include "ui/gfx/geometry/dip_util.h"
85 #include "ui/gfx/geometry/point.h" 86 #include "ui/gfx/geometry/point.h"
86 #include "ui/gfx/geometry/rect_conversions.h" 87 #include "ui/gfx/geometry/rect_conversions.h"
87 #include "ui/gfx/geometry/size_conversions.h" 88 #include "ui/gfx/geometry/size_conversions.h"
88 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 89 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
89 #include "ui/gl/gl_switches.h" 90 #include "ui/gl/gl_switches.h"
90 91
91 using content::BrowserAccessibility; 92 using content::BrowserAccessibility;
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 location:location 1154 location:location
1154 modifierFlags:0 1155 modifierFlags:0
1155 timestamp:0 1156 timestamp:0
1156 windowNumber:window_number() 1157 windowNumber:window_number()
1157 context:nil 1158 context:nil
1158 eventNumber:0 1159 eventNumber:0
1159 clickCount:0 1160 clickCount:0
1160 pressure:0]; 1161 pressure:0];
1161 WebMouseEvent web_event = WebMouseEventBuilder::Build(event, cocoa_view_); 1162 WebMouseEvent web_event = WebMouseEventBuilder::Build(event, cocoa_view_);
1162 if (showing) 1163 if (showing)
1163 web_event.type = WebInputEvent::MouseLeave; 1164 web_event.setType(WebInputEvent::MouseLeave);
1164 ForwardMouseEvent(web_event); 1165 ForwardMouseEvent(web_event);
1165 } 1166 }
1166 1167
1167 bool RenderWidgetHostViewMac::IsPopup() const { 1168 bool RenderWidgetHostViewMac::IsPopup() const {
1168 return popup_type_ != blink::WebPopupTypeNone; 1169 return popup_type_ != blink::WebPopupTypeNone;
1169 } 1170 }
1170 1171
1171 void RenderWidgetHostViewMac::CopyFromCompositingSurface( 1172 void RenderWidgetHostViewMac::CopyFromCompositingSurface(
1172 const gfx::Rect& src_subrect, 1173 const gfx::Rect& src_subrect,
1173 const gfx::Size& dst_size, 1174 const gfx::Size& dst_size,
(...skipping 27 matching lines...) Expand all
1201 1202
1202 ui::AcceleratedWidgetMac* RenderWidgetHostViewMac::GetAcceleratedWidgetMac() 1203 ui::AcceleratedWidgetMac* RenderWidgetHostViewMac::GetAcceleratedWidgetMac()
1203 const { 1204 const {
1204 return browser_compositor_->GetAcceleratedWidgetMac(); 1205 return browser_compositor_->GetAcceleratedWidgetMac();
1205 } 1206 }
1206 1207
1207 void RenderWidgetHostViewMac::ForwardMouseEvent(const WebMouseEvent& event) { 1208 void RenderWidgetHostViewMac::ForwardMouseEvent(const WebMouseEvent& event) {
1208 if (render_widget_host_) 1209 if (render_widget_host_)
1209 render_widget_host_->ForwardMouseEvent(event); 1210 render_widget_host_->ForwardMouseEvent(event);
1210 1211
1211 if (event.type == WebInputEvent::MouseLeave) { 1212 if (event.type() == WebInputEvent::MouseLeave) {
1212 [cocoa_view_ setToolTipAtMousePoint:nil]; 1213 [cocoa_view_ setToolTipAtMousePoint:nil];
1213 tooltip_text_.clear(); 1214 tooltip_text_.clear();
1214 } 1215 }
1215 } 1216 }
1216 1217
1217 void RenderWidgetHostViewMac::SetNeedsBeginFrames(bool needs_begin_frames) { 1218 void RenderWidgetHostViewMac::SetNeedsBeginFrames(bool needs_begin_frames) {
1218 needs_begin_frames_ = needs_begin_frames; 1219 needs_begin_frames_ = needs_begin_frames;
1219 UpdateNeedsBeginFramesInternal(); 1220 UpdateNeedsBeginFramesInternal();
1220 } 1221 }
1221 1222
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 [NSCursor unhide]; 1477 [NSCursor unhide];
1477 1478
1478 if (render_widget_host_) 1479 if (render_widget_host_)
1479 render_widget_host_->LostMouseLock(); 1480 render_widget_host_->LostMouseLock();
1480 } 1481 }
1481 1482
1482 void RenderWidgetHostViewMac::GestureEventAck( 1483 void RenderWidgetHostViewMac::GestureEventAck(
1483 const blink::WebGestureEvent& event, 1484 const blink::WebGestureEvent& event,
1484 InputEventAckState ack_result) { 1485 InputEventAckState ack_result) {
1485 bool consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED; 1486 bool consumed = ack_result == INPUT_EVENT_ACK_STATE_CONSUMED;
1486 switch (event.type) { 1487 switch (event.type()) {
1487 case blink::WebInputEvent::GestureScrollBegin: 1488 case blink::WebInputEvent::GestureScrollBegin:
1488 case blink::WebInputEvent::GestureScrollUpdate: 1489 case blink::WebInputEvent::GestureScrollUpdate:
1489 case blink::WebInputEvent::GestureScrollEnd: 1490 case blink::WebInputEvent::GestureScrollEnd:
1490 [cocoa_view_ processedGestureScrollEvent:event consumed:consumed]; 1491 [cocoa_view_ processedGestureScrollEvent:event consumed:consumed];
1491 return; 1492 return;
1492 default: 1493 default:
1493 break; 1494 break;
1494 } 1495 }
1495 } 1496 }
1496 1497
(...skipping 29 matching lines...) Expand all
1526 if (!id.is_valid()) 1527 if (!id.is_valid())
1527 return GetFrameSinkId(); 1528 return GetFrameSinkId();
1528 return id.frame_sink_id(); 1529 return id.frame_sink_id();
1529 } 1530 }
1530 1531
1531 bool RenderWidgetHostViewMac::ShouldRouteEvent( 1532 bool RenderWidgetHostViewMac::ShouldRouteEvent(
1532 const WebInputEvent& event) const { 1533 const WebInputEvent& event) const {
1533 // See also RenderWidgetHostViewAura::ShouldRouteEvent. 1534 // See also RenderWidgetHostViewAura::ShouldRouteEvent.
1534 // TODO(wjmaclean): Update this function if RenderWidgetHostViewMac implements 1535 // TODO(wjmaclean): Update this function if RenderWidgetHostViewMac implements
1535 // OnTouchEvent(), to match what we are doing in RenderWidgetHostViewAura. 1536 // OnTouchEvent(), to match what we are doing in RenderWidgetHostViewAura.
1536 DCHECK(WebInputEvent::isMouseEventType(event.type) || 1537 DCHECK(WebInputEvent::isMouseEventType(event.type()) ||
1537 event.type == WebInputEvent::MouseWheel); 1538 event.type() == WebInputEvent::MouseWheel);
1538 return render_widget_host_->delegate() && 1539 return render_widget_host_->delegate() &&
1539 render_widget_host_->delegate()->GetInputEventRouter() && 1540 render_widget_host_->delegate()->GetInputEventRouter() &&
1540 SiteIsolationPolicy::AreCrossProcessFramesPossible(); 1541 SiteIsolationPolicy::AreCrossProcessFramesPossible();
1541 } 1542 }
1542 1543
1543 void RenderWidgetHostViewMac::ProcessMouseEvent( 1544 void RenderWidgetHostViewMac::ProcessMouseEvent(
1544 const blink::WebMouseEvent& event, 1545 const blink::WebMouseEvent& event,
1545 const ui::LatencyInfo& latency) { 1546 const ui::LatencyInfo& latency) {
1546 render_widget_host_->ForwardMouseEventWithLatencyInfo(event, latency); 1547 render_widget_host_->ForwardMouseEventWithLatencyInfo(event, latency);
1547 } 1548 }
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 [responderDelegate_ respondsToSelector:@selector(handleEvent:)]) { 1894 [responderDelegate_ respondsToSelector:@selector(handleEvent:)]) {
1894 BOOL handled = [responderDelegate_ handleEvent:theEvent]; 1895 BOOL handled = [responderDelegate_ handleEvent:theEvent];
1895 if (handled) 1896 if (handled)
1896 return; 1897 return;
1897 } 1898 }
1898 1899
1899 if ([self shouldIgnoreMouseEvent:theEvent]) { 1900 if ([self shouldIgnoreMouseEvent:theEvent]) {
1900 // If this is the first such event, send a mouse exit to the host view. 1901 // If this is the first such event, send a mouse exit to the host view.
1901 if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { 1902 if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) {
1902 WebMouseEvent exitEvent = WebMouseEventBuilder::Build(theEvent, self); 1903 WebMouseEvent exitEvent = WebMouseEventBuilder::Build(theEvent, self);
1903 exitEvent.type = WebInputEvent::MouseLeave; 1904 exitEvent.setType(WebInputEvent::MouseLeave);
1904 exitEvent.button = WebMouseEvent::Button::NoButton; 1905 exitEvent.button = WebMouseEvent::Button::NoButton;
1905 renderWidgetHostView_->ForwardMouseEvent(exitEvent); 1906 renderWidgetHostView_->ForwardMouseEvent(exitEvent);
1906 } 1907 }
1907 mouseEventWasIgnored_ = YES; 1908 mouseEventWasIgnored_ = YES;
1908 return; 1909 return;
1909 } 1910 }
1910 1911
1911 if (mouseEventWasIgnored_) { 1912 if (mouseEventWasIgnored_) {
1912 // If this is the first mouse event after a previous event that was ignored 1913 // If this is the first mouse event after a previous event that was ignored
1913 // due to the hitTest, send a mouse enter event to the host view. 1914 // due to the hitTest, send a mouse enter event to the host view.
1914 if (renderWidgetHostView_->render_widget_host_) { 1915 if (renderWidgetHostView_->render_widget_host_) {
1915 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self); 1916 WebMouseEvent enterEvent = WebMouseEventBuilder::Build(theEvent, self);
1916 enterEvent.type = WebInputEvent::MouseMove; 1917 enterEvent.setType(WebInputEvent::MouseMove);
1917 enterEvent.button = WebMouseEvent::Button::NoButton; 1918 enterEvent.button = WebMouseEvent::Button::NoButton;
1918 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER); 1919 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER);
1919 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 1920 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
1920 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) { 1921 if (renderWidgetHostView_->ShouldRouteEvent(enterEvent)) {
1921 renderWidgetHostView_->render_widget_host_->delegate() 1922 renderWidgetHostView_->render_widget_host_->delegate()
1922 ->GetInputEventRouter() 1923 ->GetInputEventRouter()
1923 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent, 1924 ->RouteMouseEvent(renderWidgetHostView_.get(), &enterEvent,
1924 latency_info); 1925 latency_info);
1925 } else { 1926 } else {
1926 renderWidgetHostView_->ProcessMouseEvent(enterEvent, latency_info); 1927 renderWidgetHostView_->ProcessMouseEvent(enterEvent, latency_info);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 // Don't cancel child popups; the key events are probably what's triggering 2053 // Don't cancel child popups; the key events are probably what's triggering
2053 // the popup in the first place. 2054 // the popup in the first place.
2054 2055
2055 RenderWidgetHostImpl* widgetHost = renderWidgetHostView_->render_widget_host_; 2056 RenderWidgetHostImpl* widgetHost = renderWidgetHostView_->render_widget_host_;
2056 DCHECK(widgetHost); 2057 DCHECK(widgetHost);
2057 2058
2058 NativeWebKeyboardEvent event(theEvent); 2059 NativeWebKeyboardEvent event(theEvent);
2059 2060
2060 // Force fullscreen windows to close on Escape so they won't keep the keyboard 2061 // Force fullscreen windows to close on Escape so they won't keep the keyboard
2061 // grabbed or be stuck onscreen if the renderer is hanging. 2062 // grabbed or be stuck onscreen if the renderer is hanging.
2062 if (event.type == NativeWebKeyboardEvent::RawKeyDown && 2063 if (event.type() == NativeWebKeyboardEvent::RawKeyDown &&
2063 event.windowsKeyCode == ui::VKEY_ESCAPE && 2064 event.windowsKeyCode == ui::VKEY_ESCAPE &&
2064 renderWidgetHostView_->pepper_fullscreen_window()) { 2065 renderWidgetHostView_->pepper_fullscreen_window()) {
2065 RenderWidgetHostViewMac* parent = 2066 RenderWidgetHostViewMac* parent =
2066 renderWidgetHostView_->fullscreen_parent_host_view(); 2067 renderWidgetHostView_->fullscreen_parent_host_view();
2067 if (parent) 2068 if (parent)
2068 parent->cocoa_view()->suppressNextEscapeKeyUp_ = YES; 2069 parent->cocoa_view()->suppressNextEscapeKeyUp_ = YES;
2069 widgetHost->ShutdownAndDestroyWidget(true); 2070 widgetHost->ShutdownAndDestroyWidget(true);
2070 return; 2071 return;
2071 } 2072 }
2072 2073
2073 // If there are multiple widgets on the page (such as when there are 2074 // If there are multiple widgets on the page (such as when there are
2074 // out-of-process iframes), pick the one that should process this event. 2075 // out-of-process iframes), pick the one that should process this event.
2075 if (widgetHost->delegate()) 2076 if (widgetHost->delegate())
2076 widgetHost = widgetHost->delegate()->GetFocusedRenderWidgetHost(widgetHost); 2077 widgetHost = widgetHost->delegate()->GetFocusedRenderWidgetHost(widgetHost);
2077 if (!widgetHost) 2078 if (!widgetHost)
2078 return; 2079 return;
2079 2080
2080 // Suppress the escape key up event if necessary. 2081 // Suppress the escape key up event if necessary.
2081 if (event.windowsKeyCode == ui::VKEY_ESCAPE && suppressNextEscapeKeyUp_) { 2082 if (event.windowsKeyCode == ui::VKEY_ESCAPE && suppressNextEscapeKeyUp_) {
2082 if (event.type == NativeWebKeyboardEvent::KeyUp) 2083 if (event.type() == NativeWebKeyboardEvent::KeyUp)
2083 suppressNextEscapeKeyUp_ = NO; 2084 suppressNextEscapeKeyUp_ = NO;
2084 return; 2085 return;
2085 } 2086 }
2086 2087
2087 // Do not forward key up events unless preceded by a matching key down, 2088 // Do not forward key up events unless preceded by a matching key down,
2088 // otherwise we might get an event from releasing the return key in the 2089 // otherwise we might get an event from releasing the return key in the
2089 // omnibox (http://crbug.com/338736). 2090 // omnibox (http://crbug.com/338736).
2090 if ([theEvent type] == NSKeyUp) { 2091 if ([theEvent type] == NSKeyUp) {
2091 auto numErased = keyDownCodes_.erase([theEvent keyCode]); 2092 auto numErased = keyDownCodes_.erase([theEvent keyCode]);
2092 if (numErased < 1) 2093 if (numErased < 1)
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 // edit commands, then we need to send the real key event and corresponding 2221 // edit commands, then we need to send the real key event and corresponding
2221 // edit commands here. This usually occurs when the input method wants to 2222 // edit commands here. This usually occurs when the input method wants to
2222 // finish current composition session but still wants the application to 2223 // finish current composition session but still wants the application to
2223 // handle the key event. See http://crbug.com/48161 for reference. 2224 // handle the key event. See http://crbug.com/48161 for reference.
2224 if (delayEventUntilAfterImeCompostion) { 2225 if (delayEventUntilAfterImeCompostion) {
2225 // If |delayEventUntilAfterImeCompostion| is YES, then a fake key down event 2226 // If |delayEventUntilAfterImeCompostion| is YES, then a fake key down event
2226 // with windowsKeyCode == 0xE5 has already been sent to webkit. 2227 // with windowsKeyCode == 0xE5 has already been sent to webkit.
2227 // So before sending the real key down event, we need to send a fake key up 2228 // So before sending the real key down event, we need to send a fake key up
2228 // event to balance it. 2229 // event to balance it.
2229 NativeWebKeyboardEvent fakeEvent = event; 2230 NativeWebKeyboardEvent fakeEvent = event;
2230 fakeEvent.type = blink::WebInputEvent::KeyUp; 2231 fakeEvent.setType(blink::WebInputEvent::KeyUp);
2231 fakeEvent.skip_in_browser = true; 2232 fakeEvent.skip_in_browser = true;
2232 widgetHost->ForwardKeyboardEvent(fakeEvent); 2233 widgetHost->ForwardKeyboardEvent(fakeEvent);
2233 // Not checking |renderWidgetHostView_->render_widget_host_| here because 2234 // Not checking |renderWidgetHostView_->render_widget_host_| here because
2234 // a key event with |skip_in_browser| == true won't be handled by browser, 2235 // a key event with |skip_in_browser| == true won't be handled by browser,
2235 // thus it won't destroy the widget. 2236 // thus it won't destroy the widget.
2236 2237
2237 if (!editCommands_.empty()) { 2238 if (!editCommands_.empty()) {
2238 widgetHost->Send(new InputMsg_SetEditCommandsForNextKeyEvent( 2239 widgetHost->Send(new InputMsg_SetEditCommandsForNextKeyEvent(
2239 widgetHost->GetRoutingID(), editCommands_)); 2240 widgetHost->GetRoutingID(), editCommands_));
2240 } 2241 }
2241 widgetHost->ForwardKeyboardEvent(event); 2242 widgetHost->ForwardKeyboardEvent(event);
2242 2243
2243 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the 2244 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the
2244 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will 2245 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will
2245 // be set to NULL. So we check it here and return immediately if it's NULL. 2246 // be set to NULL. So we check it here and return immediately if it's NULL.
2246 if (!renderWidgetHostView_->render_widget_host_) 2247 if (!renderWidgetHostView_->render_widget_host_)
2247 return; 2248 return;
2248 } 2249 }
2249 2250
2250 const NSUInteger kCtrlCmdKeyMask = NSControlKeyMask | NSCommandKeyMask; 2251 const NSUInteger kCtrlCmdKeyMask = NSControlKeyMask | NSCommandKeyMask;
2251 // Only send a corresponding key press event if there is no marked text. 2252 // Only send a corresponding key press event if there is no marked text.
2252 if (!hasMarkedText_) { 2253 if (!hasMarkedText_) {
2253 if (!textInserted && textToBeInserted_.length() == 1) { 2254 if (!textInserted && textToBeInserted_.length() == 1) {
2254 // If a single character was inserted, then we just send it as a keypress 2255 // If a single character was inserted, then we just send it as a keypress
2255 // event. 2256 // event.
2256 event.type = blink::WebInputEvent::Char; 2257 event.setType(blink::WebInputEvent::Char);
2257 event.text[0] = textToBeInserted_[0]; 2258 event.text[0] = textToBeInserted_[0];
2258 event.text[1] = 0; 2259 event.text[1] = 0;
2259 event.skip_in_browser = true; 2260 event.skip_in_browser = true;
2260 widgetHost->ForwardKeyboardEvent(event); 2261 widgetHost->ForwardKeyboardEvent(event);
2261 } else if ((!textInserted || delayEventUntilAfterImeCompostion) && 2262 } else if ((!textInserted || delayEventUntilAfterImeCompostion) &&
2262 event.text[0] != '\0' && 2263 event.text[0] != '\0' &&
2263 (([theEvent modifierFlags] & kCtrlCmdKeyMask) || 2264 (([theEvent modifierFlags] & kCtrlCmdKeyMask) ||
2264 (hasEditCommands_ && editCommands_.empty()))) { 2265 (hasEditCommands_ && editCommands_.empty()))) {
2265 // We don't get insertText: calls if ctrl or cmd is down, or the key event 2266 // We don't get insertText: calls if ctrl or cmd is down, or the key event
2266 // generates an insert command. So synthesize a keypress event for these 2267 // generates an insert command. So synthesize a keypress event for these
2267 // cases, unless the key event generated any other command. 2268 // cases, unless the key event generated any other command.
2268 event.type = blink::WebInputEvent::Char; 2269 event.setType(blink::WebInputEvent::Char);
2269 event.skip_in_browser = true; 2270 event.skip_in_browser = true;
2270 widgetHost->ForwardKeyboardEvent(event); 2271 widgetHost->ForwardKeyboardEvent(event);
2271 } 2272 }
2272 } 2273 }
2273 2274
2274 // Possibly autohide the cursor. 2275 // Possibly autohide the cursor.
2275 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent]) 2276 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent])
2276 [NSCursor setHiddenUntilMouseMoves:YES]; 2277 [NSCursor setHiddenUntilMouseMoves:YES];
2277 } 2278 }
2278 2279
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 2320
2320 - (void)endGestureWithEvent:(NSEvent*)event { 2321 - (void)endGestureWithEvent:(NSEvent*)event {
2321 [responderDelegate_ endGestureWithEvent:event]; 2322 [responderDelegate_ endGestureWithEvent:event];
2322 gestureBeginEvent_.reset(); 2323 gestureBeginEvent_.reset();
2323 2324
2324 if (!renderWidgetHostView_->render_widget_host_) 2325 if (!renderWidgetHostView_->render_widget_host_)
2325 return; 2326 return;
2326 2327
2327 if (gestureBeginPinchSent_) { 2328 if (gestureBeginPinchSent_) {
2328 WebGestureEvent endEvent(WebGestureEventBuilder::Build(event, self)); 2329 WebGestureEvent endEvent(WebGestureEventBuilder::Build(event, self));
2329 endEvent.type = WebInputEvent::GesturePinchEnd; 2330 endEvent.setType(WebInputEvent::GesturePinchEnd);
2330 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(endEvent); 2331 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(endEvent);
2331 gestureBeginPinchSent_ = NO; 2332 gestureBeginPinchSent_ = NO;
2332 } 2333 }
2333 } 2334 }
2334 2335
2335 - (void)touchesMovedWithEvent:(NSEvent*)event { 2336 - (void)touchesMovedWithEvent:(NSEvent*)event {
2336 [responderDelegate_ touchesMovedWithEvent:event]; 2337 [responderDelegate_ touchesMovedWithEvent:event];
2337 } 2338 }
2338 2339
2339 - (void)touchesBeganWithEvent:(NSEvent*)event { 2340 - (void)touchesBeganWithEvent:(NSEvent*)event {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2537 2538
2538 if (!pinchHasReachedZoomThreshold_) { 2539 if (!pinchHasReachedZoomThreshold_) {
2539 pinchUnusedAmount_ *= (1 + [event magnification]); 2540 pinchUnusedAmount_ *= (1 + [event magnification]);
2540 if (pinchUnusedAmount_ < 0.667 || pinchUnusedAmount_ > 1.5) 2541 if (pinchUnusedAmount_ < 0.667 || pinchUnusedAmount_ > 1.5)
2541 pinchHasReachedZoomThreshold_ = true; 2542 pinchHasReachedZoomThreshold_ = true;
2542 } 2543 }
2543 2544
2544 // Send a GesturePinchBegin event if none has been sent yet. 2545 // Send a GesturePinchBegin event if none has been sent yet.
2545 if (!gestureBeginPinchSent_) { 2546 if (!gestureBeginPinchSent_) {
2546 WebGestureEvent beginEvent(*gestureBeginEvent_); 2547 WebGestureEvent beginEvent(*gestureBeginEvent_);
2547 beginEvent.type = WebInputEvent::GesturePinchBegin; 2548 beginEvent.setType(WebInputEvent::GesturePinchBegin);
2548 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(beginEvent); 2549 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(beginEvent);
2549 gestureBeginPinchSent_ = YES; 2550 gestureBeginPinchSent_ = YES;
2550 } 2551 }
2551 2552
2552 // Send a GesturePinchUpdate event. 2553 // Send a GesturePinchUpdate event.
2553 WebGestureEvent updateEvent = WebGestureEventBuilder::Build(event, self); 2554 WebGestureEvent updateEvent = WebGestureEventBuilder::Build(event, self);
2554 updateEvent.data.pinchUpdate.zoomDisabled = !pinchHasReachedZoomThreshold_; 2555 updateEvent.data.pinchUpdate.zoomDisabled = !pinchHasReachedZoomThreshold_;
2555 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(updateEvent); 2556 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(updateEvent);
2556 } 2557 }
2557 2558
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 3259
3259 - (void)viewDidMoveToWindow { 3260 - (void)viewDidMoveToWindow {
3260 if ([self window]) 3261 if ([self window])
3261 [self updateScreenProperties]; 3262 [self updateScreenProperties];
3262 renderWidgetHostView_->browser_compositor_->SetNSViewAttachedToWindow( 3263 renderWidgetHostView_->browser_compositor_->SetNSViewAttachedToWindow(
3263 [self window]); 3264 [self window]);
3264 3265
3265 // If we switch windows (or are removed from the view hierarchy), cancel any 3266 // If we switch windows (or are removed from the view hierarchy), cancel any
3266 // open mouse-downs. 3267 // open mouse-downs.
3267 if (hasOpenMouseDown_) { 3268 if (hasOpenMouseDown_) {
3268 WebMouseEvent event; 3269 WebMouseEvent event(WebInputEvent::MouseUp, WebInputEvent::NoModifiers,
3269 event.type = WebInputEvent::MouseUp; 3270 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
3270 event.button = WebMouseEvent::Button::Left; 3271 event.button = WebMouseEvent::Button::Left;
3271 renderWidgetHostView_->ForwardMouseEvent(event); 3272 renderWidgetHostView_->ForwardMouseEvent(event);
3272 3273
3273 hasOpenMouseDown_ = NO; 3274 hasOpenMouseDown_ = NO;
3274 } 3275 }
3275 } 3276 }
3276 3277
3277 - (void)viewDidChangeBackingProperties { 3278 - (void)viewDidChangeBackingProperties {
3278 NSScreen* screen = [[self window] screen]; 3279 NSScreen* screen = [[self window] screen];
3279 if (screen) { 3280 if (screen) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
3452 3453
3453 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3454 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3454 // regions that are not draggable. (See ControlRegionView in 3455 // regions that are not draggable. (See ControlRegionView in
3455 // native_app_window_cocoa.mm). This requires the render host view to be 3456 // native_app_window_cocoa.mm). This requires the render host view to be
3456 // draggable by default. 3457 // draggable by default.
3457 - (BOOL)mouseDownCanMoveWindow { 3458 - (BOOL)mouseDownCanMoveWindow {
3458 return YES; 3459 return YES;
3459 } 3460 }
3460 3461
3461 @end 3462 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698