OLD | NEW |
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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 2304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 | 2315 |
2316 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { | 2316 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { |
2317 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); | 2317 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); |
2318 } | 2318 } |
2319 | 2319 |
2320 // Check blink::WebTouchAction and blink::WebTouchActionAuto is kept in sync | 2320 // Check blink::WebTouchAction and blink::WebTouchActionAuto is kept in sync |
2321 #define STATIC_ASSERT_WTI_ENUM_MATCH(a, b)
\ | 2321 #define STATIC_ASSERT_WTI_ENUM_MATCH(a, b)
\ |
2322 static_assert(int(blink::WebTouchAction##a) == int(TOUCH_ACTION_##b), \ | 2322 static_assert(int(blink::WebTouchAction##a) == int(TOUCH_ACTION_##b), \ |
2323 "mismatching enums: " #a) | 2323 "mismatching enums: " #a) |
2324 | 2324 |
| 2325 inline content::TouchAction& operator|=(content::TouchAction& a, |
| 2326 content::TouchAction b) { |
| 2327 a = static_cast<content::TouchAction>(static_cast<int>(a) | |
| 2328 static_cast<int>(b)); |
| 2329 return a; |
| 2330 } |
| 2331 |
2325 void RenderWidget::setTouchAction( | 2332 void RenderWidget::setTouchAction( |
2326 blink::WebTouchAction web_touch_action) { | 2333 blink::WebTouchAction web_touch_action) { |
2327 | 2334 |
2328 // Ignore setTouchAction calls that result from synthetic touch events (eg. | 2335 // Ignore setTouchAction calls that result from synthetic touch events (eg. |
2329 // when blink is emulating touch with mouse). | 2336 // when blink is emulating touch with mouse). |
2330 if (handling_event_type_ != WebInputEvent::TouchStart) | 2337 if (handling_event_type_ != WebInputEvent::TouchStart) |
2331 return; | 2338 return; |
2332 | 2339 |
2333 // Verify the same values are used by the types so we can cast between them. | 2340 // TODO(dtapuska): A dependant change needs to land in blink to change |
| 2341 // the blink::WebTouchAction enum; in the meantime don't do |
| 2342 // a static cast between the values. (http://crbug.com/476556) |
| 2343 #if 0 |
| 2344 // Verify the same values are used by the types so we can cast between them. |
2334 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO); | 2345 STATIC_ASSERT_WTI_ENUM_MATCH(Auto, AUTO); |
2335 STATIC_ASSERT_WTI_ENUM_MATCH(None, NONE); | 2346 STATIC_ASSERT_WTI_ENUM_MATCH(None, NONE); |
| 2347 STATIC_ASSERT_WTI_ENUM_MATCH(PanLeft, PAN_LEFT); |
| 2348 STATIC_ASSERT_WTI_ENUM_MATCH(PanRight, PAN_RIGHT); |
2336 STATIC_ASSERT_WTI_ENUM_MATCH(PanX, PAN_X); | 2349 STATIC_ASSERT_WTI_ENUM_MATCH(PanX, PAN_X); |
| 2350 STATIC_ASSERT_WTI_ENUM_MATCH(PanUp, PAN_UP); |
| 2351 STATIC_ASSERT_WTI_ENUM_MATCH(PanDown, PAN_DOWN); |
2337 STATIC_ASSERT_WTI_ENUM_MATCH(PanY, PAN_Y); | 2352 STATIC_ASSERT_WTI_ENUM_MATCH(PanY, PAN_Y); |
2338 STATIC_ASSERT_WTI_ENUM_MATCH(PinchZoom, PINCH_ZOOM); | 2353 STATIC_ASSERT_WTI_ENUM_MATCH(PinchZoom, PINCH_ZOOM); |
2339 | 2354 |
2340 content::TouchAction content_touch_action = | 2355 content::TouchAction content_touch_action = |
2341 static_cast<content::TouchAction>(web_touch_action); | 2356 static_cast<content::TouchAction>(web_touch_action); |
| 2357 #else |
| 2358 content::TouchAction content_touch_action = TOUCH_ACTION_AUTO; |
| 2359 if (web_touch_action & blink::WebTouchActionNone) |
| 2360 content_touch_action |= TOUCH_ACTION_NONE; |
| 2361 if (web_touch_action & blink::WebTouchActionPanX) |
| 2362 content_touch_action |= TOUCH_ACTION_PAN_X; |
| 2363 if (web_touch_action & blink::WebTouchActionPanY) |
| 2364 content_touch_action |= TOUCH_ACTION_PAN_Y; |
| 2365 if (web_touch_action & blink::WebTouchActionPinchZoom) |
| 2366 content_touch_action |= TOUCH_ACTION_PINCH_ZOOM; |
| 2367 |
| 2368 #endif |
2342 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); | 2369 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); |
2343 } | 2370 } |
2344 | 2371 |
2345 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { | 2372 void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() { |
2346 #if defined(OS_ANDROID) | 2373 #if defined(OS_ANDROID) |
2347 text_field_is_dirty_ = true; | 2374 text_field_is_dirty_ = true; |
2348 #endif | 2375 #endif |
2349 } | 2376 } |
2350 | 2377 |
2351 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2378 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2440 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2467 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2441 video_hole_frames_.AddObserver(frame); | 2468 video_hole_frames_.AddObserver(frame); |
2442 } | 2469 } |
2443 | 2470 |
2444 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2471 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2445 video_hole_frames_.RemoveObserver(frame); | 2472 video_hole_frames_.RemoveObserver(frame); |
2446 } | 2473 } |
2447 #endif // defined(VIDEO_HOLE) | 2474 #endif // defined(VIDEO_HOLE) |
2448 | 2475 |
2449 } // namespace content | 2476 } // namespace content |
OLD | NEW |