Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: sky/engine/web/WebViewImpl.cpp

Issue 871683002: Remove a number of unused features from WebViewImpl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/web/WebViewImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "sky/engine/platform/Cursor.h" 63 #include "sky/engine/platform/Cursor.h"
64 #include "sky/engine/platform/KeyboardCodes.h" 64 #include "sky/engine/platform/KeyboardCodes.h"
65 #include "sky/engine/platform/Logging.h" 65 #include "sky/engine/platform/Logging.h"
66 #include "sky/engine/platform/NotImplemented.h" 66 #include "sky/engine/platform/NotImplemented.h"
67 #include "sky/engine/platform/PlatformGestureEvent.h" 67 #include "sky/engine/platform/PlatformGestureEvent.h"
68 #include "sky/engine/platform/PlatformKeyboardEvent.h" 68 #include "sky/engine/platform/PlatformKeyboardEvent.h"
69 #include "sky/engine/platform/PlatformMouseEvent.h" 69 #include "sky/engine/platform/PlatformMouseEvent.h"
70 #include "sky/engine/platform/PlatformWheelEvent.h" 70 #include "sky/engine/platform/PlatformWheelEvent.h"
71 #include "sky/engine/platform/TraceEvent.h" 71 #include "sky/engine/platform/TraceEvent.h"
72 #include "sky/engine/platform/UserGestureIndicator.h" 72 #include "sky/engine/platform/UserGestureIndicator.h"
73 #include "sky/engine/platform/exported/WebActiveGestureAnimation.h"
74 #include "sky/engine/platform/fonts/FontCache.h" 73 #include "sky/engine/platform/fonts/FontCache.h"
75 #include "sky/engine/platform/graphics/Color.h" 74 #include "sky/engine/platform/graphics/Color.h"
76 #include "sky/engine/platform/graphics/Image.h" 75 #include "sky/engine/platform/graphics/Image.h"
77 #include "sky/engine/platform/graphics/ImageBuffer.h" 76 #include "sky/engine/platform/graphics/ImageBuffer.h"
78 #include "sky/engine/platform/scroll/Scrollbar.h" 77 #include "sky/engine/platform/scroll/Scrollbar.h"
79 #include "sky/engine/public/platform/Platform.h" 78 #include "sky/engine/public/platform/Platform.h"
80 #include "sky/engine/public/platform/WebFloatPoint.h" 79 #include "sky/engine/public/platform/WebFloatPoint.h"
81 #include "sky/engine/public/platform/WebGestureCurve.h"
82 #include "sky/engine/public/platform/WebImage.h" 80 #include "sky/engine/public/platform/WebImage.h"
83 #include "sky/engine/public/platform/WebLayerTreeView.h" 81 #include "sky/engine/public/platform/WebLayerTreeView.h"
84 #include "sky/engine/public/platform/WebURLRequest.h" 82 #include "sky/engine/public/platform/WebURLRequest.h"
85 #include "sky/engine/public/platform/WebVector.h" 83 #include "sky/engine/public/platform/WebVector.h"
86 #include "sky/engine/public/web/WebActiveWheelFlingParameters.h" 84 #include "sky/engine/public/web/WebActiveWheelFlingParameters.h"
87 #include "sky/engine/public/web/WebBeginFrameArgs.h" 85 #include "sky/engine/public/web/WebBeginFrameArgs.h"
88 #include "sky/engine/public/web/WebFrameClient.h" 86 #include "sky/engine/public/web/WebFrameClient.h"
89 #include "sky/engine/public/web/WebHitTestResult.h" 87 #include "sky/engine/public/web/WebHitTestResult.h"
90 #include "sky/engine/public/web/WebNode.h" 88 #include "sky/engine/public/web/WebNode.h"
91 #include "sky/engine/public/web/WebRange.h" 89 #include "sky/engine/public/web/WebRange.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 , m_rootLayerScale(1) 139 , m_rootLayerScale(1)
142 , m_suppressNextKeypressEvent(false) 140 , m_suppressNextKeypressEvent(false)
143 , m_imeAcceptEvents(true) 141 , m_imeAcceptEvents(true)
144 , m_isTransparent(false) 142 , m_isTransparent(false)
145 , m_tabsToLinks(false) 143 , m_tabsToLinks(false)
146 , m_rootLayer(0) 144 , m_rootLayer(0)
147 , m_matchesHeuristicsForGpuRasterization(false) 145 , m_matchesHeuristicsForGpuRasterization(false)
148 , m_recreatingGraphicsContext(false) 146 , m_recreatingGraphicsContext(false)
149 , m_flingModifier(0) 147 , m_flingModifier(0)
150 , m_flingSourceDevice(false) 148 , m_flingSourceDevice(false)
151 , m_showFPSCounter(false)
152 , m_showPaintRects(false) 149 , m_showPaintRects(false)
153 , m_showDebugBorders(false) 150 , m_showDebugBorders(false)
154 , m_continuousPaintingEnabled(false) 151 , m_continuousPaintingEnabled(false)
155 , m_showScrollBottleneckRects(false) 152 , m_showScrollBottleneckRects(false)
156 , m_baseBackgroundColor(Color::white) 153 , m_baseBackgroundColor(Color::white)
157 , m_backgroundColorOverride(Color::transparent) 154 , m_backgroundColorOverride(Color::transparent)
158 , m_userGestureObserved(false) 155 , m_userGestureObserved(false)
159 { 156 {
160 Page::PageClients pageClients; 157 Page::PageClients pageClients;
161 pageClients.chromeClient = &m_chromeClientImpl; 158 pageClients.chromeClient = &m_chromeClientImpl;
(...skipping 11 matching lines...) Expand all
173 WebViewImpl::~WebViewImpl() 170 WebViewImpl::~WebViewImpl()
174 { 171 {
175 ASSERT(!m_page); 172 ASSERT(!m_page);
176 } 173 }
177 174
178 WebLocalFrameImpl* WebViewImpl::mainFrameImpl() 175 WebLocalFrameImpl* WebViewImpl::mainFrameImpl()
179 { 176 {
180 return m_page ? WebLocalFrameImpl::fromFrame(m_page->mainFrame()) : 0; 177 return m_page ? WebLocalFrameImpl::fromFrame(m_page->mainFrame()) : 0;
181 } 178 }
182 179
183 bool WebViewImpl::tabKeyCyclesThroughElements() const
184 {
185 ASSERT(m_page);
186 return m_page->tabKeyCyclesThroughElements();
187 }
188
189 void WebViewImpl::setTabKeyCyclesThroughElements(bool value)
190 {
191 if (m_page)
192 m_page->setTabKeyCyclesThroughElements(value);
193 }
194
195 void WebViewImpl::handleMouseLeave(LocalFrame& mainFrame, const WebMouseEvent& e vent) 180 void WebViewImpl::handleMouseLeave(LocalFrame& mainFrame, const WebMouseEvent& e vent)
196 { 181 {
197 m_client->setMouseOverURL(WebURL()); 182 m_client->setMouseOverURL(WebURL());
198 PageWidgetEventHandler::handleMouseLeave(mainFrame, event); 183 PageWidgetEventHandler::handleMouseLeave(mainFrame, event);
199 } 184 }
200 185
201 void WebViewImpl::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& ev ent) 186 void WebViewImpl::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& ev ent)
202 { 187 {
203 PageWidgetEventHandler::handleMouseDown(mainFrame, event); 188 PageWidgetEventHandler::handleMouseDown(mainFrame, event);
204 189
205 if (event.button == WebMouseEvent::ButtonLeft && m_mouseCaptureNode) 190 if (event.button == WebMouseEvent::ButtonLeft && m_mouseCaptureNode)
206 m_mouseCaptureGestureToken = mainFrame.eventHandler().takeLastMouseDownG estureToken(); 191 m_mouseCaptureGestureToken = mainFrame.eventHandler().takeLastMouseDownG estureToken();
207 } 192 }
208 193
209 void WebViewImpl::handleMouseUp(LocalFrame& mainFrame, const WebMouseEvent& even t) 194 void WebViewImpl::handleMouseUp(LocalFrame& mainFrame, const WebMouseEvent& even t)
210 { 195 {
211 PageWidgetEventHandler::handleMouseUp(mainFrame, event); 196 PageWidgetEventHandler::handleMouseUp(mainFrame, event);
212 } 197 }
213 198
214 bool WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const WebMouseWheelEve nt& event) 199 bool WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const WebMouseWheelEve nt& event)
215 { 200 {
216 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); 201 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event);
217 } 202 }
218 203
219 // FIXME(sky): This appears to be unused.
220 bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci ty)
221 {
222 if (m_flingSourceDevice == WebGestureDeviceTouchpad) {
223 WebMouseWheelEvent syntheticWheel;
224 const float tickDivisor = WheelEvent::TickMultiplier;
225
226 syntheticWheel.deltaX = delta.width;
227 syntheticWheel.deltaY = delta.height;
228 syntheticWheel.wheelTicksX = delta.width / tickDivisor;
229 syntheticWheel.wheelTicksY = delta.height / tickDivisor;
230 syntheticWheel.hasPreciseScrollingDeltas = true;
231 syntheticWheel.x = m_positionOnFlingStart.x;
232 syntheticWheel.y = m_positionOnFlingStart.y;
233 syntheticWheel.globalX = m_globalPositionOnFlingStart.x;
234 syntheticWheel.globalY = m_globalPositionOnFlingStart.y;
235 syntheticWheel.modifiers = m_flingModifier;
236
237 if (m_page && m_page->mainFrame() && m_page->mainFrame()->view())
238 return handleMouseWheel(*m_page->mainFrame(), syntheticWheel);
239 } else {
240 WebGestureEvent syntheticGestureEvent;
241
242 syntheticGestureEvent.type = WebInputEvent::GestureScrollUpdateWithoutPr opagation;
243 syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width;
244 syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height;
245 syntheticGestureEvent.x = m_positionOnFlingStart.x;
246 syntheticGestureEvent.y = m_positionOnFlingStart.y;
247 syntheticGestureEvent.globalX = m_globalPositionOnFlingStart.x;
248 syntheticGestureEvent.globalY = m_globalPositionOnFlingStart.y;
249 syntheticGestureEvent.modifiers = m_flingModifier;
250 syntheticGestureEvent.sourceDevice = WebGestureDeviceTouchscreen;
251
252 if (m_page && m_page->mainFrame() && m_page->mainFrame()->view())
253 return handleGestureEvent(syntheticGestureEvent);
254 }
255 return false;
256 }
257
258 bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event) 204 bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
259 { 205 {
260 bool eventSwallowed = false; 206 bool eventSwallowed = false;
261 bool eventCancelled = false; // for disambiguation 207 bool eventCancelled = false; // for disambiguation
262 208
263 // Special handling for slow-path fling gestures.
264 switch (event.type) {
265 case WebInputEvent::GestureFlingStart: {
266 if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures ())
267 break;
268 m_client->cancelScheduledContentIntents();
269 m_positionOnFlingStart = WebPoint(event.x, event.y);
270 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);
271 m_flingModifier = event.modifiers;
272 m_flingSourceDevice = event.sourceDevice;
273 OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->creat eFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.vel ocityX, event.data.flingStart.velocityY), WebSize()));
274 ASSERT(flingCurve);
275 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(f lingCurve.release(), this);
276 scheduleAnimation();
277 eventSwallowed = true;
278
279 m_client->didHandleGestureEvent(event, eventCancelled);
280 return eventSwallowed;
281 }
282 case WebInputEvent::GestureFlingCancel:
283 if (endActiveFlingAnimation())
284 eventSwallowed = true;
285
286 m_client->didHandleGestureEvent(event, eventCancelled);
287 return eventSwallowed;
288 default:
289 break;
290 }
291
292 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t); 209 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), even t);
293 210
294 // FIXME: Remove redundant hit tests by pushing the call to EventHandler::ta rgetGestureEvent 211 // FIXME: Remove redundant hit tests by pushing the call to EventHandler::ta rgetGestureEvent
295 // up to this point and pass GestureEventWithHitTestResults around. 212 // up to this point and pass GestureEventWithHitTestResults around.
296 213
297 switch (event.type) { 214 switch (event.type) {
298 case WebInputEvent::GestureTap: { 215 case WebInputEvent::GestureTap: {
299 m_client->cancelScheduledContentIntents(); 216 m_client->cancelScheduledContentIntents();
300 if (detectContentOnTouch(platformEvent.position())) { 217 if (detectContentOnTouch(platformEvent.position())) {
301 eventSwallowed = true; 218 eventSwallowed = true;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent); 257 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureE vent(platformEvent);
341 break; 258 break;
342 } 259 }
343 default: 260 default:
344 ASSERT_NOT_REACHED(); 261 ASSERT_NOT_REACHED();
345 } 262 }
346 m_client->didHandleGestureEvent(event, eventCancelled); 263 m_client->didHandleGestureEvent(event, eventCancelled);
347 return eventSwallowed; 264 return eventSwallowed;
348 } 265 }
349 266
350 void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingPar ameters& parameters)
351 {
352 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation");
353 ASSERT(!m_gestureAnimation);
354 m_positionOnFlingStart = parameters.point;
355 m_globalPositionOnFlingStart = parameters.globalPoint;
356 m_flingModifier = parameters.modifiers;
357 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters .cumulativeScroll));
358 ASSERT(curve);
359 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r elease(), this, parameters.startTime);
360 scheduleAnimation();
361 }
362
363 bool WebViewImpl::endActiveFlingAnimation()
364 {
365 if (m_gestureAnimation) {
366 m_gestureAnimation.clear();
367 return true;
368 }
369 return false;
370 }
371
372 void WebViewImpl::setShowFPSCounter(bool show)
373 {
374 m_showFPSCounter = show;
375 }
376
377 void WebViewImpl::setShowPaintRects(bool show) 267 void WebViewImpl::setShowPaintRects(bool show)
378 { 268 {
379 m_showPaintRects = show; 269 m_showPaintRects = show;
380 } 270 }
381 271
382 void WebViewImpl::setShowDebugBorders(bool show) 272 void WebViewImpl::setShowDebugBorders(bool show)
383 { 273 {
384 m_showDebugBorders = show; 274 m_showDebugBorders = show;
385 } 275 }
386 276
(...skipping 15 matching lines...) Expand all
402 292
403 page()->acceptLanguagesChanged(); 293 page()->acceptLanguagesChanged();
404 } 294 }
405 295
406 bool WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) 296 bool WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event)
407 { 297 {
408 ASSERT((event.type == WebInputEvent::RawKeyDown) 298 ASSERT((event.type == WebInputEvent::RawKeyDown)
409 || (event.type == WebInputEvent::KeyDown) 299 || (event.type == WebInputEvent::KeyDown)
410 || (event.type == WebInputEvent::KeyUp)); 300 || (event.type == WebInputEvent::KeyUp));
411 301
412 // Halt an in-progress fling on a key event.
413 endActiveFlingAnimation();
414
415 // Please refer to the comments explaining the m_suppressNextKeypressEvent 302 // Please refer to the comments explaining the m_suppressNextKeypressEvent
416 // member. 303 // member.
417 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by 304 // The m_suppressNextKeypressEvent is set if the KeyDown is handled by
418 // Webkit. A keyDown event is typically associated with a keyPress(char) 305 // Webkit. A keyDown event is typically associated with a keyPress(char)
419 // event and a keyUp event. We reset this flag here as this is a new keyDown 306 // event and a keyUp event. We reset this flag here as this is a new keyDown
420 // event. 307 // event.
421 m_suppressNextKeypressEvent = false; 308 m_suppressNextKeypressEvent = false;
422 309
423 RefPtr<LocalFrame> focusedFrame = focusedCoreFrame(); 310 RefPtr<LocalFrame> focusedFrame = focusedCoreFrame();
424 if (!focusedFrame) 311 if (!focusedFrame)
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 } 521 }
635 522
636 void WebViewImpl::beginFrame(const WebBeginFrameArgs& frameTime) 523 void WebViewImpl::beginFrame(const WebBeginFrameArgs& frameTime)
637 { 524 {
638 TRACE_EVENT0("blink", "WebViewImpl::beginFrame"); 525 TRACE_EVENT0("blink", "WebViewImpl::beginFrame");
639 526
640 WebBeginFrameArgs validFrameTime(frameTime); 527 WebBeginFrameArgs validFrameTime(frameTime);
641 if (!validFrameTime.lastFrameTimeMonotonic) 528 if (!validFrameTime.lastFrameTimeMonotonic)
642 validFrameTime.lastFrameTimeMonotonic = monotonicallyIncreasingTime(); 529 validFrameTime.lastFrameTimeMonotonic = monotonicallyIncreasingTime();
643 530
644 // Create synthetic wheel events as necessary for fling.
645 if (m_gestureAnimation) {
646 if (m_gestureAnimation->animate(validFrameTime.lastFrameTimeMonotonic))
647 scheduleAnimation();
648 else {
649 endActiveFlingAnimation();
650
651 PlatformGestureEvent endScrollEvent(PlatformEvent::GestureScrollEnd,
652 m_positionOnFlingStart, m_globalPositionOnFlingStart,
653 IntSize(), 0, false, false, false, false,
654 0, 0, 0, 0);
655
656 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEnd(endS crollEvent);
657 }
658 }
659
660 WTF_LOG(ScriptedAnimationController, "WebViewImpl::beginFrame: page = %d", ! m_page ? 0 : 1); 531 WTF_LOG(ScriptedAnimationController, "WebViewImpl::beginFrame: page = %d", ! m_page ? 0 : 1);
661 if (!m_page) 532 if (!m_page)
662 return; 533 return;
663 534
664 PageWidgetDelegate::animate(m_page.get(), validFrameTime.lastFrameTimeMonoto nic); 535 PageWidgetDelegate::animate(m_page.get(), validFrameTime.lastFrameTimeMonoto nic);
665 536
666 if (m_continuousPaintingEnabled) 537 if (m_continuousPaintingEnabled)
667 m_client->scheduleAnimation(); 538 m_client->scheduleAnimation();
668 } 539 }
669 540
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 page()->focusController().setActive(active); 1193 page()->focusController().setActive(active);
1323 } 1194 }
1324 1195
1325 bool WebViewImpl::isActive() const 1196 bool WebViewImpl::isActive() const
1326 { 1197 {
1327 return page() ? page()->focusController().isActive() : false; 1198 return page() ? page()->focusController().isActive() : false;
1328 } 1199 }
1329 1200
1330 void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag e) 1201 void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag e)
1331 { 1202 {
1332 endActiveFlingAnimation();
1333 m_userGestureObserved = false; 1203 m_userGestureObserved = false;
1334 if (!isNavigationWithinPage) 1204 if (!isNavigationWithinPage)
1335 UserGestureIndicator::clearProcessedUserGestureSinceLoad(); 1205 UserGestureIndicator::clearProcessedUserGestureSinceLoad();
1336 } 1206 }
1337 1207
1338 void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe) 1208 void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe)
1339 { 1209 {
1340 if (!m_client) 1210 if (!m_client)
1341 return; 1211 return;
1342 m_client->didUpdateLayout(); 1212 m_client->didUpdateLayout();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, 1286 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState,
1417 bool isInitialState) { 1287 bool isInitialState) {
1418 if (!page()) 1288 if (!page())
1419 return; 1289 return;
1420 1290
1421 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState = = WebPageVisibilityStateHidden); 1291 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState = = WebPageVisibilityStateHidden);
1422 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int> (visibilityState)), isInitialState); 1292 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int> (visibilityState)), isInitialState);
1423 } 1293 }
1424 1294
1425 } // namespace blink 1295 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698