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

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

Issue 925933004: Prune HitTestResult and stop special-casing links. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address review comments 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/rendering/HitTestResult.h » ('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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 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())
213 return result; 213 return result;
214 214
215 // 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.
216 HitTestRequest request(hitType); 216 HitTestRequest request(hitType);
217 m_frame->contentRenderer()->hitTest(request, result); 217 m_frame->contentRenderer()->hitTest(request, result);
218 218
219 return result; 219 return result;
220 } 220 }
221 221
222 bool EventHandler::useHandCursor(Node* node, bool isOverLink)
223 {
224 if (!node)
225 return false;
226
227 return isOverLink && !node->hasEditableStyle();
228 }
229
230 void EventHandler::cursorUpdateTimerFired(Timer<EventHandler>*) 222 void EventHandler::cursorUpdateTimerFired(Timer<EventHandler>*)
231 { 223 {
232 ASSERT(m_frame); 224 ASSERT(m_frame);
233 ASSERT(m_frame->document()); 225 ASSERT(m_frame->document());
234 226
235 updateCursor(); 227 updateCursor();
236 } 228 }
237 229
238 void EventHandler::updateCursor() 230 void EventHandler::updateCursor()
239 { 231 {
240 } 232 }
241 233
242 OptionalCursor EventHandler::selectCursor(const HitTestResult& result) 234 OptionalCursor EventHandler::selectCursor(const HitTestResult& result)
243 { 235 {
244 Page* page = m_frame->page(); 236 Page* page = m_frame->page();
245 if (!page) 237 if (!page)
246 return NoCursorChange; 238 return NoCursorChange;
247 239
248 Node* node = result.innerPossiblyPseudoNode(); 240 Node* node = result.innerPossiblyPseudoNode();
249 if (!node) 241 if (!node)
250 return selectAutoCursor(result, node, iBeamCursor()); 242 return selectAutoCursor(result, node);
251 243
252 RenderObject* renderer = node->renderer(); 244 RenderObject* renderer = node->renderer();
253 RenderStyle* style = renderer ? renderer->style() : 0; 245 RenderStyle* style = renderer ? renderer->style() : 0;
254 246
255 if (renderer) { 247 if (renderer) {
256 Cursor overrideCursor; 248 Cursor overrideCursor;
257 switch (renderer->getCursor(roundedIntPoint(result.localPoint()), overri deCursor)) { 249 switch (renderer->getCursor(roundedIntPoint(result.localPoint()), overri deCursor)) {
258 case SetCursorBasedOnStyle: 250 case SetCursorBasedOnStyle:
259 break; 251 break;
260 case SetCursor: 252 case SetCursor:
(...skipping 28 matching lines...) Expand all
289 Image* image = cachedImage->imageForRenderer(renderer); 281 Image* image = cachedImage->imageForRenderer(renderer);
290 // Ensure no overflow possible in calculations above. 282 // Ensure no overflow possible in calculations above.
291 if (scale < minimumCursorScale) 283 if (scale < minimumCursorScale)
292 continue; 284 continue;
293 return Cursor(image, hotSpot, scale); 285 return Cursor(image, hotSpot, scale);
294 } 286 }
295 } 287 }
296 288
297 switch (style ? style->cursor() : CURSOR_AUTO) { 289 switch (style ? style->cursor() : CURSOR_AUTO) {
298 case CURSOR_AUTO: { 290 case CURSOR_AUTO: {
299 const Cursor& iBeam = iBeamCursor(); 291 return selectAutoCursor(result, node);
300 return selectAutoCursor(result, node, iBeam);
301 } 292 }
302 case CURSOR_CROSS: 293 case CURSOR_CROSS:
303 return crossCursor(); 294 return crossCursor();
304 case CURSOR_POINTER: 295 case CURSOR_POINTER:
305 return handCursor(); 296 return handCursor();
306 case CURSOR_MOVE: 297 case CURSOR_MOVE:
307 return moveCursor(); 298 return moveCursor();
308 case CURSOR_ALL_SCROLL: 299 case CURSOR_ALL_SCROLL:
309 return moveCursor(); 300 return moveCursor();
310 case CURSOR_E_RESIZE: 301 case CURSOR_E_RESIZE:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 case CURSOR_ZOOM_OUT: 357 case CURSOR_ZOOM_OUT:
367 return zoomOutCursor(); 358 return zoomOutCursor();
368 case CURSOR_WEBKIT_GRAB: 359 case CURSOR_WEBKIT_GRAB:
369 return grabCursor(); 360 return grabCursor();
370 case CURSOR_WEBKIT_GRABBING: 361 case CURSOR_WEBKIT_GRABBING:
371 return grabbingCursor(); 362 return grabbingCursor();
372 } 363 }
373 return pointerCursor(); 364 return pointerCursor();
374 } 365 }
375 366
376 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, Node* node, const Cursor& iBeam) 367 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, Node* node)
377 { 368 {
378 bool editable = (node && node->hasEditableStyle());
379
380 if (useHandCursor(node, result.isOverLink()))
381 return handCursor();
382
383 RenderObject* renderer = node ? node->renderer() : 0; 369 RenderObject* renderer = node ? node->renderer() : 0;
384 if (editable || (renderer && renderer->isText() && node->canStartSelection() )) 370 if (!node || !renderer)
385 return iBeam; 371 return pointerCursor();
372 if (node->hasEditableStyle() || (renderer->isText() && node->canStartSelecti on()))
373 return iBeamCursor();
386 return pointerCursor(); 374 return pointerCursor();
387 } 375 }
388 376
389 void EventHandler::invalidateClick() 377 void EventHandler::invalidateClick()
390 { 378 {
391 m_clickCount = 0; 379 m_clickCount = 0;
392 m_clickNode = nullptr; 380 m_clickNode = nullptr;
393 } 381 }
394 382
395 void EventHandler::scheduleCursorUpdate() 383 void EventHandler::scheduleCursorUpdate()
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 523
536 void EventHandler::focusDocumentView() 524 void EventHandler::focusDocumentView()
537 { 525 {
538 Page* page = m_frame->page(); 526 Page* page = m_frame->page();
539 if (!page) 527 if (!page)
540 return; 528 return;
541 page->focusController().focusDocumentView(m_frame); 529 page->focusController().focusDocumentView(m_frame);
542 } 530 }
543 531
544 } // namespace blink 532 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/page/EventHandler.h ('k') | sky/engine/core/rendering/HitTestResult.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698