Skip to content

Instantly share code, notes, and snippets.

@kenchris
Created January 6, 2012 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenchris/1571164 to your computer and use it in GitHub Desktop.
Save kenchris/1571164 to your computer and use it in GitHub Desktop.
2242 case PlatformEvent::GestureTap: {
2243 // FIXME: Refactor this code to not hit test multiple times once hit testing has been corrected as suggested above.
2244 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globalPosition(), NoButton, PlatformEvent::MouseMoved, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
2245 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, PlatformEvent::MousePressed, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
2246 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalPosition(), LeftButton, PlatformEvent::MouseReleased, /* clickCount */ 1, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp());
2247 mouseMoved(fakeMouseMove);
2248
2249 // Input methods which act as primary input device (AKA virtual keyboards) appear and
2250 // disappear when something gains or looses focus. As this can happen multiple times
2251 // during the fake mouse events, we have to postpone the state changes here.
2252
2253 // Elements can loose focus on mousedownEvent but get focused via for instance
2254 // the DOM during clickEvent. To not hide and reshow the input method editor, we
2255 // disable it until after all event processing.
2256 if (m_frame->page()->editorClient()->inputMethodIsPrimaryInputDevice()) {
2257 m_frame->page()->editorClient()->willSetInputMethodState();
2258 m_frame->page()->focusController()->setPostponeInputMethodStateChanges(true);
2259 }
2260
2261 handleMousePressEvent(fakeMouseDown);
2262 handleMouseReleaseEvent(fakeMouseUp);
2263
2264 // Reenable the input method, which will reset the state and show the input method iff:
2265 // a) an editable element received mousedownEvent and got focused.
2266 // b) an editable element received focus via JavaScript focus() as a result of a clickEvent.
2267 // c) an editable element received focus as a result of a clickEvent on a <label for=name>.
2268 if (m_frame->page()->editorClient()->inputMethodIsPrimaryInputDevice()) {
2269 m_frame->page()->focusController()->setPostponeInputMethodStateChanges(false);
2270 m_frame->page()->focusController()->inputMethodStateDidChange(m_frame->document()->focusedNode(), FocusController::TapStateChangeReason);
2271 }
2272 return true;
2273 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment