Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1881 WebPointerProperties::Button::kNoButton, /* clickCount */ 0, | 1881 WebPointerProperties::Button::kNoButton, /* clickCount */ 0, |
| 1882 WebInputEvent::kNoModifiers, TimeTicks::Now().InSeconds()); | 1882 WebInputEvent::kNoModifiers, TimeTicks::Now().InSeconds()); |
| 1883 | 1883 |
| 1884 // TODO(dtapuska): Transition the mouseEvent to be created really in viewport | 1884 // TODO(dtapuska): Transition the mouseEvent to be created really in viewport |
| 1885 // coordinates instead of root frame coordinates. | 1885 // coordinates instead of root frame coordinates. |
| 1886 mouse_event.SetFrameScale(1); | 1886 mouse_event.SetFrameScale(1); |
| 1887 | 1887 |
| 1888 return SendContextMenuEvent(mouse_event, override_target_element); | 1888 return SendContextMenuEvent(mouse_event, override_target_element); |
| 1889 } | 1889 } |
| 1890 | 1890 |
| 1891 WebInputEventResult EventHandler::SendContextMenuEventForTouchSelection() { | |
| 1892 // TODO(editing-dev): The use of UpdateStyleAndLayoutIgnorePendingStylesheets | |
| 1893 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 1894 frame_->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets(); | |
| 1895 FrameSelection& selection = frame_->Selection(); | |
| 1896 if (!(selection.IsAvailable() && selection.IsHandleVisible() && | |
| 1897 selection.ComputeVisibleSelectionInFlatTree().IsRange())) | |
| 1898 return WebInputEventResult::kNotHandled; | |
| 1899 | |
| 1900 FrameView* view = frame_->View(); | |
| 1901 if (!view) | |
| 1902 return WebInputEventResult::kNotHandled; | |
| 1903 | |
| 1904 Document* doc = frame_->GetDocument(); | |
| 1905 if (!doc) | |
| 1906 return WebInputEventResult::kNotHandled; | |
| 1907 | |
| 1908 IntPoint location_in_root_frame; | |
| 1909 | |
| 1910 VisualViewport& visual_viewport = frame_->GetPage()->GetVisualViewport(); | |
| 1911 | |
| 1912 // TODO(xiaochengh): The use of UpdateStyleAndLayoutIgnorePendingStylesheets | |
| 1913 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 1914 doc->UpdateStyleAndLayoutIgnorePendingStylesheets(); | |
| 1915 | |
| 1916 IntRect first_rect = frame_->GetEditor().FirstRectForRange( | |
| 1917 selection.ComputeVisibleSelectionInDOMTree() | |
| 1918 .ToNormalizedEphemeralRange()); | |
| 1919 | |
| 1920 location_in_root_frame = view->ContentsToRootFrame(first_rect.Center()); | |
| 1921 | |
| 1922 IntPoint location_in_viewport = | |
| 1923 visual_viewport.RootFrameToViewport(location_in_root_frame); | |
| 1924 IntPoint global_position = | |
|
aelias_OOO_until_Jul13
2017/04/21 21:42:19
Could you refactor the code that's duplicated-ish
| |
| 1925 view->GetChromeClient() | |
| 1926 ->ViewportToScreen(IntRect(location_in_viewport, IntSize()), | |
| 1927 frame_->View()) | |
| 1928 .Location(); | |
| 1929 | |
| 1930 WebMouseEvent mouse_event( | |
| 1931 WebInputEvent::kMouseDown, | |
| 1932 WebFloatPoint(location_in_root_frame.X(), location_in_root_frame.Y()), | |
| 1933 WebFloatPoint(global_position.X(), global_position.Y()), | |
| 1934 WebPointerProperties::Button::kNoButton, /* clickCount */ 0, | |
| 1935 static_cast<WebInputEvent::Modifiers>( | |
| 1936 WebInputEvent::Modifiers::kRightButtonDown | | |
| 1937 WebInputEvent::kIsCompatibilityEventForTouch), | |
| 1938 TimeTicks::Now().InSeconds()); | |
| 1939 | |
| 1940 // TODO(dtapuska): Transition the mouseEvent to be created really in viewport | |
| 1941 // coordinates instead of root frame coordinates. | |
| 1942 mouse_event.SetFrameScale(1); | |
| 1943 | |
| 1944 return SendContextMenuEvent(mouse_event); | |
| 1945 } | |
| 1946 | |
| 1891 void EventHandler::ScheduleHoverStateUpdate() { | 1947 void EventHandler::ScheduleHoverStateUpdate() { |
| 1892 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. | 1948 // TODO(https://crbug.com/668758): Use a normal BeginFrame update for this. |
| 1893 if (!hover_timer_.IsActive() && | 1949 if (!hover_timer_.IsActive() && |
| 1894 !mouse_event_manager_->IsMousePositionUnknown()) | 1950 !mouse_event_manager_->IsMousePositionUnknown()) |
| 1895 hover_timer_.StartOneShot(0, BLINK_FROM_HERE); | 1951 hover_timer_.StartOneShot(0, BLINK_FROM_HERE); |
| 1896 } | 1952 } |
| 1897 | 1953 |
| 1898 void EventHandler::ScheduleCursorUpdate() { | 1954 void EventHandler::ScheduleCursorUpdate() { |
| 1899 // We only want one timer for the page, rather than each frame having it's own | 1955 // We only want one timer for the page, rather than each frame having it's own |
| 1900 // timer competing which eachother (since there's only one mouse cursor). | 1956 // timer competing which eachother (since there's only one mouse cursor). |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2109 MouseEventWithHitTestResults& mev, | 2165 MouseEventWithHitTestResults& mev, |
| 2110 LocalFrame* subframe) { | 2166 LocalFrame* subframe) { |
| 2111 WebInputEventResult result = | 2167 WebInputEventResult result = |
| 2112 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event()); | 2168 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event()); |
| 2113 if (result != WebInputEventResult::kNotHandled) | 2169 if (result != WebInputEventResult::kNotHandled) |
| 2114 return result; | 2170 return result; |
| 2115 return WebInputEventResult::kHandledSystem; | 2171 return WebInputEventResult::kHandledSystem; |
| 2116 } | 2172 } |
| 2117 | 2173 |
| 2118 } // namespace blink | 2174 } // namespace blink |
| OLD | NEW |