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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 40 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
41 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 41 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h" |
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPagePopup.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPagePopup.h" |
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" |
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h" | 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h" |
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" | 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
49 #include "third_party/skia/include/core/SkShader.h" | 49 #include "third_party/skia/include/core/SkShader.h" |
50 #include "ui/base/keycodes/keyboard_codes.h" | |
50 #include "ui/base/ui_base_switches.h" | 51 #include "ui/base/ui_base_switches.h" |
51 #include "ui/gfx/rect_conversions.h" | 52 #include "ui/gfx/rect_conversions.h" |
52 #include "ui/gfx/size_conversions.h" | 53 #include "ui/gfx/size_conversions.h" |
53 #include "ui/gfx/skia_util.h" | 54 #include "ui/gfx/skia_util.h" |
54 #include "ui/gl/gl_switches.h" | 55 #include "ui/gl/gl_switches.h" |
55 #include "ui/surface/transport_dib.h" | 56 #include "ui/surface/transport_dib.h" |
56 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" | 57 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" |
57 #include "webkit/glue/webkit_glue.h" | 58 #include "webkit/glue/webkit_glue.h" |
58 #include "webkit/plugins/npapi/webplugin.h" | 59 #include "webkit/plugins/npapi/webplugin.h" |
59 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 60 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
60 | 61 |
61 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
62 #include "content/renderer/android/synchronous_compositor_output_surface.h" | 63 #include "content/renderer/android/synchronous_compositor_output_surface.h" |
63 #endif | 64 #endif |
64 | 65 |
65 #if defined(OS_POSIX) | 66 #if defined(OS_POSIX) |
66 #include "ipc/ipc_channel_posix.h" | 67 #include "ipc/ipc_channel_posix.h" |
67 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 68 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
68 #include "third_party/skia/include/core/SkPixelRef.h" | 69 #include "third_party/skia/include/core/SkPixelRef.h" |
69 #endif // defined(OS_POSIX) | 70 #endif // defined(OS_POSIX) |
70 | 71 |
71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" | 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" |
72 | 73 |
73 using WebKit::WebCompositionUnderline; | 74 using WebKit::WebCompositionUnderline; |
74 using WebKit::WebCursorInfo; | 75 using WebKit::WebCursorInfo; |
75 using WebKit::WebGestureEvent; | 76 using WebKit::WebGestureEvent; |
76 using WebKit::WebInputEvent; | 77 using WebKit::WebInputEvent; |
78 using WebKit::WebKeyboardEvent; | |
77 using WebKit::WebMouseEvent; | 79 using WebKit::WebMouseEvent; |
78 using WebKit::WebNavigationPolicy; | 80 using WebKit::WebNavigationPolicy; |
79 using WebKit::WebPagePopup; | 81 using WebKit::WebPagePopup; |
80 using WebKit::WebPoint; | 82 using WebKit::WebPoint; |
81 using WebKit::WebPopupMenu; | 83 using WebKit::WebPopupMenu; |
82 using WebKit::WebPopupMenuInfo; | 84 using WebKit::WebPopupMenuInfo; |
83 using WebKit::WebPopupType; | 85 using WebKit::WebPopupType; |
84 using WebKit::WebRange; | 86 using WebKit::WebRange; |
85 using WebKit::WebRect; | 87 using WebKit::WebRect; |
86 using WebKit::WebScreenInfo; | 88 using WebKit::WebScreenInfo; |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 prevent_default = prevent_default || WillHandleGestureEvent(gesture_event); | 749 prevent_default = prevent_default || WillHandleGestureEvent(gesture_event); |
748 } | 750 } |
749 | 751 |
750 if (input_event->type == WebInputEvent::GestureTap || | 752 if (input_event->type == WebInputEvent::GestureTap || |
751 input_event->type == WebInputEvent::GestureLongPress) | 753 input_event->type == WebInputEvent::GestureLongPress) |
752 resetInputMethod(); | 754 resetInputMethod(); |
753 | 755 |
754 bool processed = prevent_default; | 756 bool processed = prevent_default; |
755 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { | 757 if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { |
756 suppress_next_char_events_ = false; | 758 suppress_next_char_events_ = false; |
759 if (!processed) | |
760 processed = MaybeScrollTopControls(input_event); | |
757 if (!processed && webwidget_) | 761 if (!processed && webwidget_) |
758 processed = webwidget_->handleInputEvent(*input_event); | 762 processed = webwidget_->handleInputEvent(*input_event); |
759 } | 763 } |
760 | 764 |
761 // If this RawKeyDown event corresponds to a browser keyboard shortcut and | 765 // If this RawKeyDown event corresponds to a browser keyboard shortcut and |
762 // it's not processed by webkit, then we need to suppress the upcoming Char | 766 // it's not processed by webkit, then we need to suppress the upcoming Char |
763 // events. | 767 // events. |
764 if (!processed && is_keyboard_shortcut) | 768 if (!processed && is_keyboard_shortcut) |
765 suppress_next_char_events_ = true; | 769 suppress_next_char_events_ = true; |
766 | 770 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
818 if (!prevent_default) { | 822 if (!prevent_default) { |
819 if (WebInputEvent::isKeyboardEventType(input_event->type)) | 823 if (WebInputEvent::isKeyboardEventType(input_event->type)) |
820 DidHandleKeyEvent(); | 824 DidHandleKeyEvent(); |
821 if (WebInputEvent::isMouseEventType(input_event->type)) | 825 if (WebInputEvent::isMouseEventType(input_event->type)) |
822 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); | 826 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); |
823 if (WebInputEvent::isTouchEventType(input_event->type)) | 827 if (WebInputEvent::isTouchEventType(input_event->type)) |
824 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event))); | 828 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event))); |
825 } | 829 } |
826 } | 830 } |
827 | 831 |
832 bool RenderWidget::MaybeScrollTopControls(const WebInputEvent* event) { | |
833 if (event->type != WebInputEvent::RawKeyDown) | |
834 return false; | |
835 const WebKeyboardEvent* key_event = | |
836 static_cast<const WebKeyboardEvent *>(event); | |
837 if (key_event->isSystemKey) | |
838 return false; | |
839 int key = key_event->windowsKeyCode; | |
840 bool shift_pressed = key_event->modifiers & WebInputEvent::ShiftKey; | |
841 bool processed = false; | |
842 if (compositor_->GetTopControlsOffset() < 0.f) { | |
843 // Shows top controls upon scrolling up: Shift-space, up, pgup, home | |
844 if (shift_pressed) { | |
845 if (key == ui::VKEY_SPACE) processed = true; | |
846 } else { | |
847 if (key == ui::VKEY_UP || key == ui::VKEY_PRIOR || key == ui::VKEY_HOME) | |
aelias_OOO_until_Jul13
2013/05/21 05:51:41
This is pretty complex and you're likely to miss s
Jinsuk Kim
2013/05/24 09:57:13
Done. Created a new CL on WebKit side for that htt
| |
848 processed = true; | |
849 } | |
850 if (processed) | |
851 compositor_->ShowTopControls(true); | |
852 } else { | |
853 // Hides top controls upon scrolling down: down, space, pgdn, end | |
854 if (!shift_pressed && | |
855 (key == ui::VKEY_DOWN || key == ui::VKEY_SPACE || | |
856 key == ui::VKEY_NEXT || key == ui::VKEY_END)) { | |
857 compositor_->ShowTopControls(false); | |
858 processed = true; | |
859 } | |
860 } | |
861 return processed; | |
862 } | |
863 | |
828 void RenderWidget::OnCursorVisibilityChange(bool is_visible) { | 864 void RenderWidget::OnCursorVisibilityChange(bool is_visible) { |
829 if (webwidget_) | 865 if (webwidget_) |
830 webwidget_->setCursorVisibilityState(is_visible); | 866 webwidget_->setCursorVisibilityState(is_visible); |
831 } | 867 } |
832 | 868 |
833 void RenderWidget::OnMouseCaptureLost() { | 869 void RenderWidget::OnMouseCaptureLost() { |
834 if (webwidget_) | 870 if (webwidget_) |
835 webwidget_->mouseCaptureLost(); | 871 webwidget_->mouseCaptureLost(); |
836 } | 872 } |
837 | 873 |
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2346 | 2382 |
2347 if (!context->Initialize( | 2383 if (!context->Initialize( |
2348 attributes, | 2384 attributes, |
2349 false /* bind generates resources */, | 2385 false /* bind generates resources */, |
2350 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) | 2386 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) |
2351 return NULL; | 2387 return NULL; |
2352 return context.release(); | 2388 return context.release(); |
2353 } | 2389 } |
2354 | 2390 |
2355 } // namespace content | 2391 } // namespace content |
OLD | NEW |