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

Side by Side Diff: sky/engine/core/page/EventHandler.cpp

Issue 878303002: Remove more scrolling code from Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/core/page/EventHandler.h ('k') | sky/engine/core/page/FocusController.cpp » ('j') | 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) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 30 matching lines...) Expand all
41 #include "sky/engine/core/editing/htmlediting.h" 41 #include "sky/engine/core/editing/htmlediting.h"
42 #include "sky/engine/core/events/DOMWindowEventQueue.h" 42 #include "sky/engine/core/events/DOMWindowEventQueue.h"
43 #include "sky/engine/core/events/EventPath.h" 43 #include "sky/engine/core/events/EventPath.h"
44 #include "sky/engine/core/events/KeyboardEvent.h" 44 #include "sky/engine/core/events/KeyboardEvent.h"
45 #include "sky/engine/core/events/TextEvent.h" 45 #include "sky/engine/core/events/TextEvent.h"
46 #include "sky/engine/core/fetch/ImageResource.h" 46 #include "sky/engine/core/fetch/ImageResource.h"
47 #include "sky/engine/core/frame/FrameView.h" 47 #include "sky/engine/core/frame/FrameView.h"
48 #include "sky/engine/core/frame/LocalFrame.h" 48 #include "sky/engine/core/frame/LocalFrame.h"
49 #include "sky/engine/core/frame/Settings.h" 49 #include "sky/engine/core/frame/Settings.h"
50 #include "sky/engine/core/loader/FrameLoaderClient.h" 50 #include "sky/engine/core/loader/FrameLoaderClient.h"
51 #include "sky/engine/core/page/AutoscrollController.h"
52 #include "sky/engine/core/page/ChromeClient.h" 51 #include "sky/engine/core/page/ChromeClient.h"
53 #include "sky/engine/core/page/EditorClient.h" 52 #include "sky/engine/core/page/EditorClient.h"
54 #include "sky/engine/core/page/FocusController.h" 53 #include "sky/engine/core/page/FocusController.h"
55 #include "sky/engine/core/page/Page.h" 54 #include "sky/engine/core/page/Page.h"
56 #include "sky/engine/core/rendering/HitTestRequest.h" 55 #include "sky/engine/core/rendering/HitTestRequest.h"
57 #include "sky/engine/core/rendering/HitTestResult.h" 56 #include "sky/engine/core/rendering/HitTestResult.h"
58 #include "sky/engine/core/rendering/RenderLayer.h" 57 #include "sky/engine/core/rendering/RenderLayer.h"
59 #include "sky/engine/core/rendering/RenderView.h" 58 #include "sky/engine/core/rendering/RenderView.h"
60 #include "sky/engine/core/rendering/style/RenderStyle.h" 59 #include "sky/engine/core/rendering/style/RenderStyle.h"
61 #include "sky/engine/platform/TraceEvent.h" 60 #include "sky/engine/platform/TraceEvent.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 end.moveToOffset(markers[0]->endOffset()); 190 end.moveToOffset(markers[0]->endOffset());
192 newSelection = VisibleSelection(start, end); 191 newSelection = VisibleSelection(start, end);
193 } 192 }
194 } 193 }
195 194
196 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel ection.isRange()) 195 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel ection.isRange())
197 newSelection.appendTrailingWhitespace(); 196 newSelection.appendTrailingWhitespace();
198 } 197 }
199 } 198 }
200 199
201 AutoscrollController* EventHandler::autoscrollController() const
202 {
203 if (Page* page = m_frame->page())
204 return &page->autoscrollController();
205 return 0;
206 }
207
208 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding) 200 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe stRequest::HitTestRequestType hitType, const LayoutSize& padding)
209 { 201 {
210 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); 202 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint");
211 203
212 HitTestResult result(point, padding.height(), padding.width(), padding.heigh t(), padding.width()); 204 HitTestResult result(point, padding.height(), padding.width(), padding.heigh t(), padding.width());
213 205
214 // RenderView::hitTest causes a layout, and we don't want to hit that until the first 206 // RenderView::hitTest causes a layout, and we don't want to hit that until the first
215 // layout because until then, there is nothing shown on the screen - the use r can't 207 // layout because until then, there is nothing shown on the screen - the use r can't
216 // have intentionally clicked on something belonging to this page. Furthermo re, 208 // have intentionally clicked on something belonging to this page. Furthermo re,
217 // mousemove events before the first layout should not lead to a premature l ayout() 209 // mousemove events before the first layout should not lead to a premature l ayout()
218 // happening, which could show a flash of white. 210 // happening, which could show a flash of white.
219 // See also the similar code in Document::prepareMouseEvent. 211 // See also the similar code in Document::prepareMouseEvent.
220 if (!m_frame->contentRenderer() || !m_frame->view() || !m_frame->view()->did FirstLayout()) 212 if (!m_frame->contentRenderer() || !m_frame->view() || !m_frame->view()->did FirstLayout())
221 return result; 213 return result;
222 214
223 // hitTestResultAtPoint is specifically used to hitTest into all frames, thu s it always allows child frame content. 215 // hitTestResultAtPoint is specifically used to hitTest into all frames, thu s it always allows child frame content.
224 HitTestRequest request(hitType); 216 HitTestRequest request(hitType);
225 m_frame->contentRenderer()->hitTest(request, result); 217 m_frame->contentRenderer()->hitTest(request, result);
226 218
227 return result; 219 return result;
228 } 220 }
229 221
230 void EventHandler::stopAutoscroll()
231 {
232 if (AutoscrollController* controller = autoscrollController())
233 controller->stopAutoscroll();
234 }
235
236 bool EventHandler::scroll(ScrollDirection direction, ScrollGranularity granulari ty, Node* startNode, Node** stopNode, float delta, IntPoint absolutePoint)
237 {
238 if (!delta)
239 return false;
240
241 Node* node = startNode;
242
243 if (!node)
244 node = m_frame->document()->focusedElement();
245
246 if (!node || !node->renderer())
247 return false;
248
249 RenderBox* curBox = node->renderer()->enclosingBox();
250 while (curBox && !curBox->isRenderView()) {
251 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it
252 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode;
253 bool didScroll = curBox->scroll(direction, granularity, delta);
254
255 if (didScroll && stopNode)
256 *stopNode = curBox->node();
257
258 if (didScroll || shouldStopBubbling) {
259 return true;
260 }
261
262 curBox = curBox->containingBlock();
263 }
264
265 return false;
266 }
267
268 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode)
269 {
270 // The layout needs to be up to date to determine if we can scroll. We may b e
271 // here because of an onLoad event, in which case the final layout hasn't be en performed yet.
272 m_frame->document()->updateLayout();
273 if (scroll(direction, granularity, startingNode))
274 return true;
275 return false;
276 }
277
278 bool EventHandler::useHandCursor(Node* node, bool isOverLink) 222 bool EventHandler::useHandCursor(Node* node, bool isOverLink)
279 { 223 {
280 if (!node) 224 if (!node)
281 return false; 225 return false;
282 226
283 return isOverLink && !node->hasEditableStyle(); 227 return isOverLink && !node->hasEditableStyle();
284 } 228 }
285 229
286 void EventHandler::cursorUpdateTimerFired(Timer<EventHandler>*) 230 void EventHandler::cursorUpdateTimerFired(Timer<EventHandler>*)
287 { 231 {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // and exclude any prohibited actions. 521 // and exclude any prohibited actions.
578 TouchAction effectiveTouchAction = TouchActionAuto; 522 TouchAction effectiveTouchAction = TouchActionAuto;
579 for (const Node* curNode = &node; curNode; curNode = NodeRenderingTraversal: :parent(curNode)) { 523 for (const Node* curNode = &node; curNode; curNode = NodeRenderingTraversal: :parent(curNode)) {
580 if (RenderObject* renderer = curNode->renderer()) { 524 if (RenderObject* renderer = curNode->renderer()) {
581 if (renderer->supportsTouchAction()) { 525 if (renderer->supportsTouchAction()) {
582 TouchAction action = renderer->style()->touchAction(); 526 TouchAction action = renderer->style()->touchAction();
583 effectiveTouchAction = intersectTouchAction(action, effectiveTou chAction); 527 effectiveTouchAction = intersectTouchAction(action, effectiveTou chAction);
584 if (effectiveTouchAction == TouchActionNone) 528 if (effectiveTouchAction == TouchActionNone)
585 break; 529 break;
586 } 530 }
587
588 // If we've reached an ancestor that supports a touch action, search no further.
589 if (renderer->isBox() && toRenderBox(renderer)->scrollsOverflow())
590 break;
591 } 531 }
592 } 532 }
593 return effectiveTouchAction; 533 return effectiveTouchAction;
594 } 534 }
595 535
596 void EventHandler::focusDocumentView() 536 void EventHandler::focusDocumentView()
597 { 537 {
598 Page* page = m_frame->page(); 538 Page* page = m_frame->page();
599 if (!page) 539 if (!page)
600 return; 540 return;
601 page->focusController().focusDocumentView(m_frame); 541 page->focusController().focusDocumentView(m_frame);
602 } 542 }
603 543
604 } // namespace blink 544 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/page/EventHandler.h ('k') | sky/engine/core/page/FocusController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698