OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "core/rendering/compositing/RenderLayerCompositor.h" | 40 #include "core/rendering/compositing/RenderLayerCompositor.h" |
41 #include "platform/Logging.h" | 41 #include "platform/Logging.h" |
42 #include "platform/graphics/GraphicsContext.h" | 42 #include "platform/graphics/GraphicsContext.h" |
43 #include "public/web/WebInputEvent.h" | 43 #include "public/web/WebInputEvent.h" |
44 #include "web/PageOverlayList.h" | 44 #include "web/PageOverlayList.h" |
45 #include "web/WebInputEventConversion.h" | 45 #include "web/WebInputEventConversion.h" |
46 #include "wtf/CurrentTime.h" | 46 #include "wtf/CurrentTime.h" |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 | 49 |
50 static inline FrameView* rootFrameView(Page* page, LocalFrame* rootFrame) | 50 void PageWidgetDelegate::animate(Page* page, double monotonicFrameBeginTime, Loc
alFrame* root) |
51 { | 51 { |
52 if (rootFrame) | 52 RefPtr<FrameView> view = root->view(); |
53 return rootFrame->view(); | |
54 if (!page) | |
55 return 0; | |
56 if (!page->mainFrame()->isLocalFrame()) | |
57 return 0; | |
58 return toLocalFrame(page->mainFrame())->view(); | |
59 } | |
60 | |
61 void PageWidgetDelegate::animate(Page* page, double monotonicFrameBeginTime, Loc
alFrame* rootFrame) | |
62 { | |
63 RefPtr<FrameView> view = rootFrameView(page, rootFrame); | |
64 if (!view) | 53 if (!view) |
65 return; | 54 return; |
66 page->autoscrollController().animate(monotonicFrameBeginTime); | 55 page->autoscrollController().animate(monotonicFrameBeginTime); |
67 page->animator().serviceScriptedAnimations(monotonicFrameBeginTime); | 56 page->animator().serviceScriptedAnimations(monotonicFrameBeginTime); |
68 } | 57 } |
69 | 58 |
70 void PageWidgetDelegate::layout(Page* page, LocalFrame* rootFrame) | 59 void PageWidgetDelegate::layout(Page* page, LocalFrame* root) |
71 { | 60 { |
72 if (!page) | 61 if (!page) |
73 return; | 62 return; |
74 | 63 |
75 if (!rootFrame) { | 64 page->animator().updateLayoutAndStyleForPainting(root); |
76 if (!page->mainFrame() || !page->mainFrame()->isLocalFrame()) | |
77 return; | |
78 rootFrame = toLocalFrame(page->mainFrame()); | |
79 } | |
80 | |
81 page->animator().updateLayoutAndStyleForPainting(rootFrame); | |
82 } | 65 } |
83 | 66 |
84 void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas*
canvas, const WebRect& rect, CanvasBackground background, LocalFrame* rootFrame
) | 67 void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas*
canvas, const WebRect& rect, CanvasBackground background, LocalFrame* root) |
85 { | 68 { |
86 if (rect.isEmpty()) | 69 if (rect.isEmpty()) |
87 return; | 70 return; |
88 GraphicsContext gc(canvas); | 71 GraphicsContext gc(canvas); |
89 gc.setCertainlyOpaque(background == Opaque); | 72 gc.setCertainlyOpaque(background == Opaque); |
90 gc.applyDeviceScaleFactor(page->deviceScaleFactor()); | 73 gc.applyDeviceScaleFactor(page->deviceScaleFactor()); |
91 gc.setDeviceScaleFactor(page->deviceScaleFactor()); | 74 gc.setDeviceScaleFactor(page->deviceScaleFactor()); |
92 IntRect dirtyRect(rect); | 75 IntRect dirtyRect(rect); |
93 gc.save(); // Needed to save the canvas, not the GraphicsContext. | 76 gc.save(); // Needed to save the canvas, not the GraphicsContext. |
94 FrameView* view = rootFrameView(page, rootFrame); | 77 FrameView* view = root->view(); |
95 if (view) { | 78 if (view) { |
96 gc.clip(dirtyRect); | 79 gc.clip(dirtyRect); |
97 view->paint(&gc, dirtyRect); | 80 view->paint(&gc, dirtyRect); |
98 if (overlays) | 81 if (overlays) |
99 overlays->paintWebFrame(gc); | 82 overlays->paintWebFrame(gc); |
100 } else { | 83 } else { |
101 gc.fillRect(dirtyRect, Color::white); | 84 gc.fillRect(dirtyRect, Color::white); |
102 } | 85 } |
103 gc.restore(); | 86 gc.restore(); |
104 } | 87 } |
105 | 88 |
106 bool PageWidgetDelegate::handleInputEvent(Page* page, PageWidgetEventHandler& ha
ndler, const WebInputEvent& event, LocalFrame* rootFrame) | 89 bool PageWidgetDelegate::handleInputEvent(Page* page, PageWidgetEventHandler& ha
ndler, const WebInputEvent& event, LocalFrame* root) |
107 { | 90 { |
108 LocalFrame* frame = rootFrame; | |
109 if (!frame) | |
110 frame = page && page->mainFrame()->isLocalFrame() ? toLocalFrame(page->m
ainFrame()) : 0; | |
111 switch (event.type) { | 91 switch (event.type) { |
112 | 92 |
113 // FIXME: WebKit seems to always return false on mouse events processing | 93 // FIXME: WebKit seems to always return false on mouse events processing |
114 // methods. For now we'll assume it has processed them (as we are only | 94 // methods. For now we'll assume it has processed them (as we are only |
115 // interested in whether keyboard events are processed). | 95 // interested in whether keyboard events are processed). |
| 96 // FIXME: Why do we return true when there is no root or the root is |
| 97 // detached? |
116 case WebInputEvent::MouseMove: | 98 case WebInputEvent::MouseMove: |
117 if (!frame || !frame->view()) | 99 if (!root || !root->view()) |
118 return true; | 100 return true; |
119 handler.handleMouseMove(*frame, static_cast<const WebMouseEvent&>(event)
); | 101 handler.handleMouseMove(*root, static_cast<const WebMouseEvent&>(event))
; |
120 return true; | 102 return true; |
121 case WebInputEvent::MouseLeave: | 103 case WebInputEvent::MouseLeave: |
122 if (!frame || !frame->view()) | 104 if (!root || !root->view()) |
123 return true; | 105 return true; |
124 handler.handleMouseLeave(*frame, static_cast<const WebMouseEvent&>(event
)); | 106 handler.handleMouseLeave(*root, static_cast<const WebMouseEvent&>(event)
); |
125 return true; | 107 return true; |
126 case WebInputEvent::MouseDown: | 108 case WebInputEvent::MouseDown: |
127 if (!frame || !frame->view()) | 109 if (!root || !root->view()) |
128 return true; | 110 return true; |
129 handler.handleMouseDown(*frame, static_cast<const WebMouseEvent&>(event)
); | 111 handler.handleMouseDown(*root, static_cast<const WebMouseEvent&>(event))
; |
130 return true; | 112 return true; |
131 case WebInputEvent::MouseUp: | 113 case WebInputEvent::MouseUp: |
132 if (!frame || !frame->view()) | 114 if (!root || !root->view()) |
133 return true; | 115 return true; |
134 handler.handleMouseUp(*frame, static_cast<const WebMouseEvent&>(event)); | 116 handler.handleMouseUp(*root, static_cast<const WebMouseEvent&>(event)); |
135 return true; | 117 return true; |
136 | 118 |
137 case WebInputEvent::MouseWheel: | 119 case WebInputEvent::MouseWheel: |
138 if (!frame || !frame->view()) | 120 if (!root || !root->view()) |
139 return false; | 121 return false; |
140 return handler.handleMouseWheel(*frame, static_cast<const WebMouseWheelE
vent&>(event)); | 122 return handler.handleMouseWheel(*root, static_cast<const WebMouseWheelEv
ent&>(event)); |
141 | 123 |
142 case WebInputEvent::RawKeyDown: | 124 case WebInputEvent::RawKeyDown: |
143 case WebInputEvent::KeyDown: | 125 case WebInputEvent::KeyDown: |
144 case WebInputEvent::KeyUp: | 126 case WebInputEvent::KeyUp: |
145 return handler.handleKeyEvent(static_cast<const WebKeyboardEvent&>(event
)); | 127 return handler.handleKeyEvent(static_cast<const WebKeyboardEvent&>(event
)); |
146 | 128 |
147 case WebInputEvent::Char: | 129 case WebInputEvent::Char: |
148 return handler.handleCharEvent(static_cast<const WebKeyboardEvent&>(even
t)); | 130 return handler.handleCharEvent(static_cast<const WebKeyboardEvent&>(even
t)); |
149 case WebInputEvent::GestureScrollBegin: | 131 case WebInputEvent::GestureScrollBegin: |
150 case WebInputEvent::GestureScrollEnd: | 132 case WebInputEvent::GestureScrollEnd: |
151 case WebInputEvent::GestureScrollUpdate: | 133 case WebInputEvent::GestureScrollUpdate: |
152 case WebInputEvent::GestureScrollUpdateWithoutPropagation: | 134 case WebInputEvent::GestureScrollUpdateWithoutPropagation: |
153 case WebInputEvent::GestureFlingStart: | 135 case WebInputEvent::GestureFlingStart: |
154 case WebInputEvent::GestureFlingCancel: | 136 case WebInputEvent::GestureFlingCancel: |
155 case WebInputEvent::GestureTap: | 137 case WebInputEvent::GestureTap: |
156 case WebInputEvent::GestureTapUnconfirmed: | 138 case WebInputEvent::GestureTapUnconfirmed: |
157 case WebInputEvent::GestureTapDown: | 139 case WebInputEvent::GestureTapDown: |
158 case WebInputEvent::GestureShowPress: | 140 case WebInputEvent::GestureShowPress: |
159 case WebInputEvent::GestureTapCancel: | 141 case WebInputEvent::GestureTapCancel: |
160 case WebInputEvent::GestureDoubleTap: | 142 case WebInputEvent::GestureDoubleTap: |
161 case WebInputEvent::GestureTwoFingerTap: | 143 case WebInputEvent::GestureTwoFingerTap: |
162 case WebInputEvent::GestureLongPress: | 144 case WebInputEvent::GestureLongPress: |
163 case WebInputEvent::GestureLongTap: | 145 case WebInputEvent::GestureLongTap: |
164 return handler.handleGestureEvent(static_cast<const WebGestureEvent&>(ev
ent)); | 146 return handler.handleGestureEvent(static_cast<const WebGestureEvent&>(ev
ent)); |
165 | 147 |
166 case WebInputEvent::TouchStart: | 148 case WebInputEvent::TouchStart: |
167 case WebInputEvent::TouchMove: | 149 case WebInputEvent::TouchMove: |
168 case WebInputEvent::TouchEnd: | 150 case WebInputEvent::TouchEnd: |
169 case WebInputEvent::TouchCancel: | 151 case WebInputEvent::TouchCancel: |
170 if (!frame || !frame->view()) | 152 if (!root || !root->view()) |
171 return false; | 153 return false; |
172 return handler.handleTouchEvent(*frame, static_cast<const WebTouchEvent&
>(event)); | 154 return handler.handleTouchEvent(*root, static_cast<const WebTouchEvent&>
(event)); |
173 | 155 |
174 case WebInputEvent::GesturePinchBegin: | 156 case WebInputEvent::GesturePinchBegin: |
175 case WebInputEvent::GesturePinchEnd: | 157 case WebInputEvent::GesturePinchEnd: |
176 case WebInputEvent::GesturePinchUpdate: | 158 case WebInputEvent::GesturePinchUpdate: |
177 // FIXME: Once PlatformGestureEvent is updated to support pinch, this | 159 // FIXME: Once PlatformGestureEvent is updated to support pinch, this |
178 // should call handleGestureEvent, just like it currently does for | 160 // should call handleGestureEvent, just like it currently does for |
179 // gesture scroll. | 161 // gesture scroll. |
180 return false; | 162 return false; |
181 | 163 |
182 default: | 164 default: |
(...skipping 28 matching lines...) Expand all Loading... |
211 { | 193 { |
212 return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(m
ainFrame.view(), event)); | 194 return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(m
ainFrame.view(), event)); |
213 } | 195 } |
214 | 196 |
215 bool PageWidgetEventHandler::handleTouchEvent(LocalFrame& mainFrame, const WebTo
uchEvent& event) | 197 bool PageWidgetEventHandler::handleTouchEvent(LocalFrame& mainFrame, const WebTo
uchEvent& event) |
216 { | 198 { |
217 return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(m
ainFrame.view(), event)); | 199 return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(m
ainFrame.view(), event)); |
218 } | 200 } |
219 | 201 |
220 } // namespace blink | 202 } // namespace blink |
OLD | NEW |