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

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/page/DragController.cpp ('k') | Source/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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 328 }
329 329
330 static void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelecti on& newSelection) 330 static void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelecti on& newSelection)
331 { 331 {
332 if (selection.selection() != newSelection) 332 if (selection.selection() != newSelection)
333 selection.setSelection(newSelection); 333 selection.setSelection(newSelection);
334 } 334 }
335 335
336 static inline bool dispatchSelectStart(Node* node) 336 static inline bool dispatchSelectStart(Node* node)
337 { 337 {
338 if (!node || !node->renderer()) 338 if (!node || !node->layoutObject())
339 return true; 339 return true;
340 340
341 return node->dispatchEvent(Event::createCancelableBubble(EventTypeNames::sel ectstart)); 341 return node->dispatchEvent(Event::createCancelableBubble(EventTypeNames::sel ectstart));
342 } 342 }
343 343
344 static VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode, const VisibleSelection& selection) 344 static VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode, const VisibleSelection& selection)
345 { 345 {
346 Node* rootUserSelectAll = Position::rootUserSelectAllForNode(targetNode); 346 Node* rootUserSelectAll = Position::rootUserSelectAllForNode(targetNode);
347 if (!rootUserSelectAll) 347 if (!rootUserSelectAll)
348 return selection; 348 return selection;
(...skipping 23 matching lines...) Expand all
372 m_frame->selection().setNonDirectionalSelectionIfNeeded(selection, granulari ty); 372 m_frame->selection().setNonDirectionalSelectionIfNeeded(selection, granulari ty);
373 373
374 return true; 374 return true;
375 } 375 }
376 376
377 void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& resul t, AppendTrailingWhitespace appendTrailingWhitespace) 377 void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& resul t, AppendTrailingWhitespace appendTrailingWhitespace)
378 { 378 {
379 Node* innerNode = result.innerNode(); 379 Node* innerNode = result.innerNode();
380 VisibleSelection newSelection; 380 VisibleSelection newSelection;
381 381
382 if (innerNode && innerNode->renderer()) { 382 if (innerNode && innerNode->layoutObject()) {
383 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point())); 383 VisiblePosition pos(innerNode->layoutObject()->positionForPoint(result.l ocalPoint()));
384 if (pos.isNotNull()) { 384 if (pos.isNotNull()) {
385 newSelection = VisibleSelection(pos); 385 newSelection = VisibleSelection(pos);
386 newSelection.expandUsingGranularity(WordGranularity); 386 newSelection.expandUsingGranularity(WordGranularity);
387 } 387 }
388 388
389 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel ection.isRange()) 389 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel ection.isRange())
390 newSelection.appendTrailingWhitespace(); 390 newSelection.appendTrailingWhitespace();
391 391
392 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity); 392 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity);
393 } 393 }
394 } 394 }
395 395
396 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult & result, AppendTrailingWhitespace appendTrailingWhitespace) 396 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult & result, AppendTrailingWhitespace appendTrailingWhitespace)
397 { 397 {
398 Node* innerNode = result.innerNode(); 398 Node* innerNode = result.innerNode();
399 VisibleSelection newSelection; 399 VisibleSelection newSelection;
400 400
401 if (innerNode && innerNode->renderer()) { 401 if (innerNode && innerNode->layoutObject()) {
402 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point())); 402 VisiblePosition pos(innerNode->layoutObject()->positionForPoint(result.l ocalPoint()));
403 Position start = pos.deepEquivalent(); 403 Position start = pos.deepEquivalent();
404 Position end = pos.deepEquivalent(); 404 Position end = pos.deepEquivalent();
405 if (pos.isNotNull()) { 405 if (pos.isNotNull()) {
406 DocumentMarkerVector markers = innerNode->document().markers().marke rsInRange(makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers()); 406 DocumentMarkerVector markers = innerNode->document().markers().marke rsInRange(makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers());
407 if (markers.size() == 1) { 407 if (markers.size() == 1) {
408 start.moveToOffset(markers[0]->startOffset()); 408 start.moveToOffset(markers[0]->startOffset());
409 end.moveToOffset(markers[0]->endOffset()); 409 end.moveToOffset(markers[0]->endOffset());
410 newSelection = VisibleSelection(start, end); 410 newSelection = VisibleSelection(start, end);
411 } 411 }
412 } 412 }
(...skipping 21 matching lines...) Expand all
434 } 434 }
435 } 435 }
436 436
437 void EventHandler::selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHit TestResults& result) 437 void EventHandler::selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHit TestResults& result)
438 { 438 {
439 if (!result.hitTestResult().isLiveLink()) 439 if (!result.hitTestResult().isLiveLink())
440 return selectClosestWordFromMouseEvent(result); 440 return selectClosestWordFromMouseEvent(result);
441 441
442 Node* innerNode = result.innerNode(); 442 Node* innerNode = result.innerNode();
443 443
444 if (innerNode && innerNode->renderer() && m_mouseDownMayStartSelect) { 444 if (innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect) {
445 VisibleSelection newSelection; 445 VisibleSelection newSelection;
446 Element* URLElement = result.hitTestResult().URLElement(); 446 Element* URLElement = result.hitTestResult().URLElement();
447 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point())); 447 VisiblePosition pos(innerNode->layoutObject()->positionForPoint(result.l ocalPoint()));
448 if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescenda ntOf(URLElement)) 448 if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescenda ntOf(URLElement))
449 newSelection = VisibleSelection::selectionFromContentsOfNode(URLElem ent); 449 newSelection = VisibleSelection::selectionFromContentsOfNode(URLElem ent);
450 450
451 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity); 451 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity);
452 } 452 }
453 } 453 }
454 454
455 bool EventHandler::handleMousePressEventDoubleClick(const MouseEventWithHitTestR esults& event) 455 bool EventHandler::handleMousePressEventDoubleClick(const MouseEventWithHitTestR esults& event)
456 { 456 {
457 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventDoubleClick"); 457 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventDoubleClick");
(...skipping 15 matching lines...) Expand all
473 } 473 }
474 474
475 bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR esults& event) 475 bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR esults& event)
476 { 476 {
477 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventTripleClick"); 477 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventTripleClick");
478 478
479 if (event.event().button() != LeftButton) 479 if (event.event().button() != LeftButton)
480 return false; 480 return false;
481 481
482 Node* innerNode = event.innerNode(); 482 Node* innerNode = event.innerNode();
483 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) 483 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect))
484 return false; 484 return false;
485 485
486 VisibleSelection newSelection; 486 VisibleSelection newSelection;
487 VisiblePosition pos(innerNode->renderer()->positionForPoint(event.localPoint ())); 487 VisiblePosition pos(innerNode->layoutObject()->positionForPoint(event.localP oint()));
488 if (pos.isNotNull()) { 488 if (pos.isNotNull()) {
489 newSelection = VisibleSelection(pos); 489 newSelection = VisibleSelection(pos);
490 newSelection.expandUsingGranularity(ParagraphGranularity); 490 newSelection.expandUsingGranularity(ParagraphGranularity);
491 } 491 }
492 492
493 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity); 493 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity);
494 } 494 }
495 495
496 static int textDistance(const Position& start, const Position& end) 496 static int textDistance(const Position& start, const Position& end)
497 { 497 {
498 RefPtrWillBeRawPtr<Range> range = Range::create(*start.document(), start, en d); 498 RefPtrWillBeRawPtr<Range> range = Range::create(*start.document(), start, en d);
499 return TextIterator::rangeLength(range.get(), true); 499 return TextIterator::rangeLength(range.get(), true);
500 } 500 }
501 501
502 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR esults& event) 502 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR esults& event)
503 { 503 {
504 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventSingleClick"); 504 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventSingleClick");
505 505
506 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 506 m_frame->document()->updateLayoutIgnorePendingStylesheets();
507 Node* innerNode = event.innerNode(); 507 Node* innerNode = event.innerNode();
508 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) 508 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect))
509 return false; 509 return false;
510 510
511 // Extend the selection if the Shift key is down, unless the click is in a l ink. 511 // Extend the selection if the Shift key is down, unless the click is in a l ink.
512 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); 512 bool extendSelection = event.event().shiftKey() && !event.isOverLink();
513 513
514 // Don't restart the selection when the mouse is pressed on an 514 // Don't restart the selection when the mouse is pressed on an
515 // existing selection so we can allow for text dragging. 515 // existing selection so we can allow for text dragging.
516 if (FrameView* view = m_frame->view()) { 516 if (FrameView* view = m_frame->view()) {
517 LayoutPoint vPoint = view->windowToContents(event.event().position()); 517 LayoutPoint vPoint = view->windowToContents(event.event().position());
518 if (!extendSelection && m_frame->selection().contains(vPoint)) { 518 if (!extendSelection && m_frame->selection().contains(vPoint)) {
519 m_mouseDownWasSingleClickInSelection = true; 519 m_mouseDownWasSingleClickInSelection = true;
520 return false; 520 return false;
521 } 521 }
522 } 522 }
523 523
524 VisiblePosition visiblePos(innerNode->renderer()->positionForPoint(event.loc alPoint())); 524 VisiblePosition visiblePos(innerNode->layoutObject()->positionForPoint(event .localPoint()));
525 if (visiblePos.isNull()) 525 if (visiblePos.isNull())
526 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW NSTREAM); 526 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW NSTREAM);
527 Position pos = visiblePos.deepEquivalent(); 527 Position pos = visiblePos.deepEquivalent();
528 528
529 VisibleSelection newSelection = m_frame->selection().selection(); 529 VisibleSelection newSelection = m_frame->selection().selection();
530 TextGranularity granularity = CharacterGranularity; 530 TextGranularity granularity = CharacterGranularity;
531 531
532 if (extendSelection && newSelection.isCaretOrRange()) { 532 if (extendSelection && newSelection.isCaretOrRange()) {
533 VisibleSelection selectionInUserSelectAll(expandSelectionToRespectUserSe lectAll(innerNode, VisibleSelection(VisiblePosition(pos)))); 533 VisibleSelection selectionInUserSelectAll(expandSelectionToRespectUserSe lectAll(innerNode, VisibleSelection(VisiblePosition(pos))));
534 if (selectionInUserSelectAll.isRange()) { 534 if (selectionInUserSelectAll.isRange()) {
(...skipping 27 matching lines...) Expand all
562 newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleS election(visiblePos)); 562 newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleS election(visiblePos));
563 } 563 }
564 564
565 // Updating the selection is considered side-effect of the event and so it d oesn't impact the handled state. 565 // Updating the selection is considered side-effect of the event and so it d oesn't impact the handled state.
566 updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, g ranularity); 566 updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, g ranularity);
567 return false; 567 return false;
568 } 568 }
569 569
570 static inline bool canMouseDownStartSelect(Node* node) 570 static inline bool canMouseDownStartSelect(Node* node)
571 { 571 {
572 if (!node || !node->renderer()) 572 if (!node || !node->layoutObject())
573 return true; 573 return true;
574 574
575 if (!node->canStartSelection()) 575 if (!node->canStartSelection())
576 return false; 576 return false;
577 577
578 return true; 578 return true;
579 } 579 }
580 580
581 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve nt) 581 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve nt)
582 { 582 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 if (!m_mousePressed) 665 if (!m_mousePressed)
666 return false; 666 return false;
667 667
668 if (handleDrag(event, DragInitiator::Mouse)) 668 if (handleDrag(event, DragInitiator::Mouse))
669 return true; 669 return true;
670 670
671 Node* targetNode = event.innerNode(); 671 Node* targetNode = event.innerNode();
672 if (!targetNode) 672 if (!targetNode)
673 return false; 673 return false;
674 674
675 LayoutObject* renderer = targetNode->renderer(); 675 LayoutObject* renderer = targetNode->layoutObject();
676 if (!renderer) { 676 if (!renderer) {
677 Node* parent = NodeRenderingTraversal::parent(*targetNode); 677 Node* parent = NodeRenderingTraversal::parent(*targetNode);
678 if (!parent) 678 if (!parent)
679 return false; 679 return false;
680 680
681 renderer = parent->renderer(); 681 renderer = parent->layoutObject();
682 if (!renderer || !renderer->isListBox()) 682 if (!renderer || !renderer->isListBox())
683 return false; 683 return false;
684 } 684 }
685 685
686 m_mouseDownMayStartDrag = false; 686 m_mouseDownMayStartDrag = false;
687 687
688 if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) { 688 if (m_mouseDownMayStartAutoscroll && !panScrollInProgress()) {
689 if (AutoscrollController* controller = autoscrollController()) { 689 if (AutoscrollController* controller = autoscrollController()) {
690 controller->startAutoscrollForSelection(renderer); 690 controller->startAutoscrollForSelection(renderer);
691 m_mouseDownMayStartAutoscroll = false; 691 m_mouseDownMayStartAutoscroll = false;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 if (targetPosition.isNull()) 732 if (targetPosition.isNull())
733 return; 733 return;
734 734
735 // Restart the selection if this is the first mouse move. This work is usual ly 735 // Restart the selection if this is the first mouse move. This work is usual ly
736 // done in handleMousePressEvent, but not if the mouse press was on an exist ing selection. 736 // done in handleMousePressEvent, but not if the mouse press was on an exist ing selection.
737 VisibleSelection newSelection = m_frame->selection().selection(); 737 VisibleSelection newSelection = m_frame->selection().selection();
738 738
739 // Special case to limit selection to the containing block for SVG text. 739 // Special case to limit selection to the containing block for SVG text.
740 // FIXME: Isn't there a better non-SVG-specific way to do this? 740 // FIXME: Isn't there a better non-SVG-specific way to do this?
741 if (Node* selectionBaseNode = newSelection.base().deprecatedNode()) 741 if (Node* selectionBaseNode = newSelection.base().deprecatedNode())
742 if (LayoutObject* selectionBaseRenderer = selectionBaseNode->renderer()) 742 if (LayoutObject* selectionBaseRenderer = selectionBaseNode->layoutObjec t())
743 if (selectionBaseRenderer->isSVGText()) 743 if (selectionBaseRenderer->isSVGText())
744 if (target->renderer()->containingBlock() != selectionBaseRender er->containingBlock()) 744 if (target->layoutObject()->containingBlock() != selectionBaseRe nderer->containingBlock())
745 return; 745 return;
746 746
747 if (m_selectionInitiationState == HaveNotStartedSelection && !dispatchSelect Start(target)) 747 if (m_selectionInitiationState == HaveNotStartedSelection && !dispatchSelect Start(target))
748 return; 748 return;
749 749
750 if (m_selectionInitiationState != ExtendedSelection) { 750 if (m_selectionInitiationState != ExtendedSelection) {
751 // Always extend selection here because it's caused by a mouse drag 751 // Always extend selection here because it's caused by a mouse drag
752 m_selectionInitiationState = ExtendedSelection; 752 m_selectionInitiationState = ExtendedSelection;
753 newSelection = VisibleSelection(targetPosition); 753 newSelection = VisibleSelection(targetPosition);
754 } 754 }
755 755
756 if (RuntimeEnabledFeatures::userSelectAllEnabled()) { 756 if (RuntimeEnabledFeatures::userSelectAllEnabled()) {
757 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllFo rNode(m_mousePressNode.get()); 757 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllFo rNode(m_mousePressNode.get());
758 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePress Node == Position::rootUserSelectAllForNode(target)) { 758 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePress Node == Position::rootUserSelectAllForNode(target)) {
759 newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePre ssNode).upstream(CanCrossEditingBoundary)); 759 newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePre ssNode).upstream(CanCrossEditingBoundary));
760 newSelection.setExtent(positionAfterNode(rootUserSelectAllForMousePr essNode).downstream(CanCrossEditingBoundary)); 760 newSelection.setExtent(positionAfterNode(rootUserSelectAllForMousePr essNode).downstream(CanCrossEditingBoundary));
761 } else { 761 } else {
762 // Reset base for user select all when base is inside user-select-al l area and extent < base. 762 // Reset base for user select all when base is inside user-select-al l area and extent < base.
763 if (rootUserSelectAllForMousePressNode && comparePositions(target->r enderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->rende rer()->positionForPoint(m_dragStartPos)) < 0) 763 if (rootUserSelectAllForMousePressNode && comparePositions(target->l ayoutObject()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->l ayoutObject()->positionForPoint(m_dragStartPos)) < 0)
764 newSelection.setBase(positionAfterNode(rootUserSelectAllForMouse PressNode).downstream(CanCrossEditingBoundary)); 764 newSelection.setBase(positionAfterNode(rootUserSelectAllForMouse PressNode).downstream(CanCrossEditingBoundary));
765 765
766 Node* rootUserSelectAllForTarget = Position::rootUserSelectAllForNod e(target); 766 Node* rootUserSelectAllForTarget = Position::rootUserSelectAllForNod e(target);
767 if (rootUserSelectAllForTarget && m_mousePressNode->renderer() && co mparePositions(target->renderer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->renderer()->positionForPoint(m_dragStartPos)) < 0) 767 if (rootUserSelectAllForTarget && m_mousePressNode->layoutObject() & & comparePositions(target->layoutObject()->positionForPoint(hitTestResult.localP oint()), m_mousePressNode->layoutObject()->positionForPoint(m_dragStartPos)) < 0 )
768 newSelection.setExtent(positionBeforeNode(rootUserSelectAllForTa rget).upstream(CanCrossEditingBoundary)); 768 newSelection.setExtent(positionBeforeNode(rootUserSelectAllForTa rget).upstream(CanCrossEditingBoundary));
769 else if (rootUserSelectAllForTarget && m_mousePressNode->renderer()) 769 else if (rootUserSelectAllForTarget && m_mousePressNode->layoutObjec t())
770 newSelection.setExtent(positionAfterNode(rootUserSelectAllForTar get).downstream(CanCrossEditingBoundary)); 770 newSelection.setExtent(positionAfterNode(rootUserSelectAllForTar get).downstream(CanCrossEditingBoundary));
771 else 771 else
772 newSelection.setExtent(targetPosition); 772 newSelection.setExtent(targetPosition);
773 } 773 }
774 } else { 774 } else {
775 newSelection.setExtent(targetPosition); 775 newSelection.setExtent(targetPosition);
776 } 776 }
777 777
778 if (m_frame->selection().granularity() != CharacterGranularity) 778 if (m_frame->selection().granularity() != CharacterGranularity)
779 newSelection.expandUsingGranularity(m_frame->selection().granularity()); 779 newSelection.expandUsingGranularity(m_frame->selection().granularity());
(...skipping 22 matching lines...) Expand all
802 // press and it's not a context menu click. We do this so when clicking 802 // press and it's not a context menu click. We do this so when clicking
803 // on the selection, the selection goes away. However, if we are 803 // on the selection, the selection goes away. However, if we are
804 // editing, place the caret. 804 // editing, place the caret.
805 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection 805 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection
806 && m_dragStartPos == event.event().position() 806 && m_dragStartPos == event.event().position()
807 && m_frame->selection().isRange() 807 && m_frame->selection().isRange()
808 && event.event().button() != RightButton) { 808 && event.event().button() != RightButton) {
809 VisibleSelection newSelection; 809 VisibleSelection newSelection;
810 Node* node = event.innerNode(); 810 Node* node = event.innerNode();
811 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr owsingEnabled(); 811 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr owsingEnabled();
812 if (node && node->renderer() && (caretBrowsing || node->hasEditableStyle ())) { 812 if (node && node->layoutObject() && (caretBrowsing || node->hasEditableS tyle())) {
813 VisiblePosition pos = VisiblePosition(node->renderer()->positionForP oint(event.localPoint())); 813 VisiblePosition pos = VisiblePosition(node->layoutObject()->position ForPoint(event.localPoint()));
814 newSelection = VisibleSelection(pos); 814 newSelection = VisibleSelection(pos);
815 } 815 }
816 816
817 setSelectionIfNeeded(m_frame->selection(), newSelection); 817 setSelectionIfNeeded(m_frame->selection(), newSelection);
818 818
819 handled = true; 819 handled = true;
820 } 820 }
821 821
822 m_frame->selection().notifyRendererOfSelectionChange(UserTriggered); 822 m_frame->selection().notifyRendererOfSelectionChange(UserTriggered);
823 823
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 return false; 910 return false;
911 911
912 Node* node = startNode; 912 Node* node = startNode;
913 913
914 if (!node) 914 if (!node)
915 node = m_frame->document()->focusedElement(); 915 node = m_frame->document()->focusedElement();
916 916
917 if (!node) 917 if (!node)
918 node = m_mousePressNode.get(); 918 node = m_mousePressNode.get();
919 919
920 if (!node || !node->renderer()) 920 if (!node || !node->layoutObject())
921 return false; 921 return false;
922 922
923 bool rootLayerScrolls = m_frame->settings() && m_frame->settings()->rootLaye rScrolls(); 923 bool rootLayerScrolls = m_frame->settings() && m_frame->settings()->rootLaye rScrolls();
924 LayoutBox* curBox = node->renderer()->enclosingBox(); 924 LayoutBox* curBox = node->layoutObject()->enclosingBox();
925 while (curBox && (rootLayerScrolls || !curBox->isLayoutView())) { 925 while (curBox && (rootLayerScrolls || !curBox->isLayoutView())) {
926 ScrollDirection physicalDirection = toPhysicalDirection( 926 ScrollDirection physicalDirection = toPhysicalDirection(
927 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode()); 927 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode());
928 928
929 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it 929 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it
930 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode; 930 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode;
931 bool didScroll = curBox->scroll(physicalDirection, granularity, delta); 931 bool didScroll = curBox->scroll(physicalDirection, granularity, delta);
932 932
933 if (didScroll && stopNode) 933 if (didScroll && stopNode)
934 *stopNode = curBox->node(); 934 *stopNode = curBox->node();
(...skipping 30 matching lines...) Expand all
965 IntPoint EventHandler::lastKnownMousePosition() const 965 IntPoint EventHandler::lastKnownMousePosition() const
966 { 966 {
967 return m_lastKnownMousePosition; 967 return m_lastKnownMousePosition;
968 } 968 }
969 969
970 static LocalFrame* subframeForTargetNode(Node* node) 970 static LocalFrame* subframeForTargetNode(Node* node)
971 { 971 {
972 if (!node) 972 if (!node)
973 return nullptr; 973 return nullptr;
974 974
975 LayoutObject* renderer = node->renderer(); 975 LayoutObject* renderer = node->layoutObject();
976 if (!renderer || !renderer->isLayoutPart()) 976 if (!renderer || !renderer->isLayoutPart())
977 return nullptr; 977 return nullptr;
978 978
979 Widget* widget = toLayoutPart(renderer)->widget(); 979 Widget* widget = toLayoutPart(renderer)->widget();
980 if (!widget || !widget->isFrameView()) 980 if (!widget || !widget->isFrameView())
981 return nullptr; 981 return nullptr;
982 982
983 return &toFrameView(widget)->frame(); 983 return &toFrameView(widget)->frame();
984 } 984 }
985 985
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 return NoCursorChange; 1047 return NoCursorChange;
1048 #if OS(WIN) 1048 #if OS(WIN)
1049 if (panScrollInProgress()) 1049 if (panScrollInProgress())
1050 return NoCursorChange; 1050 return NoCursorChange;
1051 #endif 1051 #endif
1052 1052
1053 Node* node = result.innerPossiblyPseudoNode(); 1053 Node* node = result.innerPossiblyPseudoNode();
1054 if (!node) 1054 if (!node)
1055 return selectAutoCursor(result, node, iBeamCursor()); 1055 return selectAutoCursor(result, node, iBeamCursor());
1056 1056
1057 LayoutObject* renderer = node->renderer(); 1057 LayoutObject* renderer = node->layoutObject();
1058 LayoutStyle* style = renderer ? renderer->style() : nullptr; 1058 LayoutStyle* style = renderer ? renderer->style() : nullptr;
1059 1059
1060 if (renderer) { 1060 if (renderer) {
1061 Cursor overrideCursor; 1061 Cursor overrideCursor;
1062 switch (renderer->getCursor(roundedIntPoint(result.localPoint()), overri deCursor)) { 1062 switch (renderer->getCursor(roundedIntPoint(result.localPoint()), overri deCursor)) {
1063 case SetCursorBasedOnStyle: 1063 case SetCursorBasedOnStyle:
1064 break; 1064 break;
1065 case SetCursor: 1065 case SetCursor:
1066 return overrideCursor; 1066 return overrideCursor;
1067 case DoNotSetCursor: 1067 case DoNotSetCursor:
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 } 1181 }
1182 1182
1183 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, Node* node, const Cursor& iBeam) 1183 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, Node* node, const Cursor& iBeam)
1184 { 1184 {
1185 bool editable = (node && node->hasEditableStyle()); 1185 bool editable = (node && node->hasEditableStyle());
1186 1186
1187 if (useHandCursor(node, result.isOverLink())) 1187 if (useHandCursor(node, result.isOverLink()))
1188 return handCursor(); 1188 return handCursor();
1189 1189
1190 bool inResizer = false; 1190 bool inResizer = false;
1191 LayoutObject* renderer = node ? node->renderer() : nullptr; 1191 LayoutObject* renderer = node ? node->layoutObject() : nullptr;
1192 if (renderer && m_frame->view()) { 1192 if (renderer && m_frame->view()) {
1193 Layer* layer = renderer->enclosingLayer(); 1193 Layer* layer = renderer->enclosingLayer();
1194 inResizer = layer->scrollableArea() && layer->scrollableArea()->isPointI nResizeControl(result.roundedPointInMainFrame(), ResizerForPointer); 1194 inResizer = layer->scrollableArea() && layer->scrollableArea()->isPointI nResizeControl(result.roundedPointInMainFrame(), ResizerForPointer);
1195 } 1195 }
1196 1196
1197 // During selection, use an I-beam no matter what we're over. 1197 // During selection, use an I-beam no matter what we're over.
1198 // If a drag may be starting or we're capturing mouse events for a particula r node, don't treat this as a selection. 1198 // If a drag may be starting or we're capturing mouse events for a particula r node, don't treat this as a selection.
1199 if (m_mousePressed && m_mouseDownMayStartSelect 1199 if (m_mousePressed && m_mouseDownMayStartSelect
1200 && !m_mouseDownMayStartDrag 1200 && !m_mouseDownMayStartDrag
1201 && m_frame->selection().isCaretOrRange() 1201 && m_frame->selection().isCaretOrRange()
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 // away from the current page (e.g. the click was on a hyperlink). See < rdar://problem/6095023>. 1278 // away from the current page (e.g. the click was on a hyperlink). See < rdar://problem/6095023>.
1279 invalidateClick(); 1279 invalidateClick();
1280 return true; 1280 return true;
1281 } 1281 }
1282 #endif 1282 #endif
1283 1283
1284 m_clickCount = mouseEvent.clickCount(); 1284 m_clickCount = mouseEvent.clickCount();
1285 m_clickNode = mev.innerNode()->isTextNode() ? NodeRenderingTraversal::paren t(*mev.innerNode()) : mev.innerNode(); 1285 m_clickNode = mev.innerNode()->isTextNode() ? NodeRenderingTraversal::paren t(*mev.innerNode()) : mev.innerNode();
1286 1286
1287 if (FrameView* view = m_frame->view()) { 1287 if (FrameView* view = m_frame->view()) {
1288 Layer* layer = mev.innerNode()->renderer() ? mev.innerNode()->renderer() ->enclosingLayer() : nullptr; 1288 Layer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->layout Object()->enclosingLayer() : nullptr;
1289 IntPoint p = view->windowToContents(mouseEvent.position()); 1289 IntPoint p = view->windowToContents(mouseEvent.position());
1290 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint InResizeControl(p, ResizerForPointer)) { 1290 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint InResizeControl(p, ResizerForPointer)) {
1291 m_resizeScrollableArea = layer->scrollableArea(); 1291 m_resizeScrollableArea = layer->scrollableArea();
1292 m_resizeScrollableArea->setInResizeMode(true); 1292 m_resizeScrollableArea->setInResizeMode(true);
1293 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); 1293 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p));
1294 invalidateClick(); 1294 invalidateClick();
1295 return true; 1295 return true;
1296 } 1296 }
1297 } 1297 }
1298 1298
(...skipping 30 matching lines...) Expand all
1329 } 1329 }
1330 1330
1331 return swallowEvent; 1331 return swallowEvent;
1332 } 1332 }
1333 1333
1334 static Layer* layerForNode(Node* node) 1334 static Layer* layerForNode(Node* node)
1335 { 1335 {
1336 if (!node) 1336 if (!node)
1337 return nullptr; 1337 return nullptr;
1338 1338
1339 LayoutObject* renderer = node->renderer(); 1339 LayoutObject* renderer = node->layoutObject();
1340 if (!renderer) 1340 if (!renderer)
1341 return nullptr; 1341 return nullptr;
1342 1342
1343 Layer* layer = renderer->enclosingLayer(); 1343 Layer* layer = renderer->enclosingLayer();
1344 if (!layer) 1344 if (!layer)
1345 return nullptr; 1345 return nullptr;
1346 1346
1347 return layer; 1347 return layer;
1348 } 1348 }
1349 1349
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 if (m_latchedWheelEventNode) 2006 if (m_latchedWheelEventNode)
2007 m_latchedWheelEventNode = nullptr; 2007 m_latchedWheelEventNode = nullptr;
2008 if (m_previousWheelScrolledNode) 2008 if (m_previousWheelScrolledNode)
2009 m_previousWheelScrolledNode = nullptr; 2009 m_previousWheelScrolledNode = nullptr;
2010 2010
2011 isOverWidget = result.isOverWidget(); 2011 isOverWidget = result.isOverWidget();
2012 } 2012 }
2013 2013
2014 if (node) { 2014 if (node) {
2015 // Figure out which view to send the event to. 2015 // Figure out which view to send the event to.
2016 LayoutObject* target = node->renderer(); 2016 LayoutObject* target = node->layoutObject();
2017 2017
2018 if (isOverWidget && target && target->isLayoutPart()) { 2018 if (isOverWidget && target && target->isLayoutPart()) {
2019 Widget* widget = toLayoutPart(target)->widget(); 2019 Widget* widget = toLayoutPart(target)->widget();
2020 if (widget && passWheelEventToWidget(event, *widget)) 2020 if (widget && passWheelEventToWidget(event, *widget))
2021 RETURN_WHEEL_EVENT_HANDLED(); 2021 RETURN_WHEEL_EVENT_HANDLED();
2022 } 2022 }
2023 2023
2024 if (node && !node->dispatchWheelEvent(event)) 2024 if (node && !node->dispatchWheelEvent(event))
2025 RETURN_WHEEL_EVENT_HANDLED(); 2025 RETURN_WHEEL_EVENT_HANDLED();
2026 } 2026 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 if (m_longTapShouldInvokeContextMenu) { 2397 if (m_longTapShouldInvokeContextMenu) {
2398 m_longTapShouldInvokeContextMenu = false; 2398 m_longTapShouldInvokeContextMenu = false;
2399 return sendContextMenuEventForGesture(targetedEvent); 2399 return sendContextMenuEventForGesture(targetedEvent);
2400 } 2400 }
2401 #endif 2401 #endif
2402 return false; 2402 return false;
2403 } 2403 }
2404 2404
2405 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor mGestureEvent& gestureEvent) { 2405 bool EventHandler::handleScrollGestureOnResizer(Node* eventTarget, const Platfor mGestureEvent& gestureEvent) {
2406 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) { 2406 if (gestureEvent.type() == PlatformEvent::GestureScrollBegin) {
2407 Layer* layer = eventTarget->renderer() ? eventTarget->renderer()->enclos ingLayer() : nullptr; 2407 Layer* layer = eventTarget->layoutObject() ? eventTarget->layoutObject() ->enclosingLayer() : nullptr;
2408 IntPoint p = m_frame->view()->windowToContents(gestureEvent.position()); 2408 IntPoint p = m_frame->view()->windowToContents(gestureEvent.position());
2409 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint InResizeControl(p, ResizerForTouch)) { 2409 if (layer && layer->scrollableArea() && layer->scrollableArea()->isPoint InResizeControl(p, ResizerForTouch)) {
2410 m_resizeScrollableArea = layer->scrollableArea(); 2410 m_resizeScrollableArea = layer->scrollableArea();
2411 m_resizeScrollableArea->setInResizeMode(true); 2411 m_resizeScrollableArea->setInResizeMode(true);
2412 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); 2412 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p));
2413 return true; 2413 return true;
2414 } 2414 }
2415 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate) { 2415 } else if (gestureEvent.type() == PlatformEvent::GestureScrollUpdate) {
2416 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) { 2416 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) {
2417 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne r); 2417 m_resizeScrollableArea->resize(gestureEvent, m_offsetFromResizeCorne r);
(...skipping 26 matching lines...) Expand all
2444 return false; 2444 return false;
2445 2445
2446 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent); 2446 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent);
2447 } 2447 }
2448 2448
2449 bool EventHandler::handleGestureScrollEnd(const PlatformGestureEvent& gestureEve nt) { 2449 bool EventHandler::handleGestureScrollEnd(const PlatformGestureEvent& gestureEve nt) {
2450 RefPtrWillBeRawPtr<Node> node = m_scrollGestureHandlingNode; 2450 RefPtrWillBeRawPtr<Node> node = m_scrollGestureHandlingNode;
2451 clearGestureScrollNodes(); 2451 clearGestureScrollNodes();
2452 2452
2453 if (node) 2453 if (node)
2454 passScrollGestureEventToWidget(gestureEvent, node->renderer()); 2454 passScrollGestureEventToWidget(gestureEvent, node->layoutObject());
2455 2455
2456 return false; 2456 return false;
2457 } 2457 }
2458 2458
2459 bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE vent) 2459 bool EventHandler::handleGestureScrollBegin(const PlatformGestureEvent& gestureE vent)
2460 { 2460 {
2461 Document* document = m_frame->document(); 2461 Document* document = m_frame->document();
2462 if (!document->layoutView()) 2462 if (!document->layoutView())
2463 return false; 2463 return false;
2464 2464
2465 FrameView* view = m_frame->view(); 2465 FrameView* view = m_frame->view();
2466 if (!view) 2466 if (!view)
2467 return false; 2467 return false;
2468 2468
2469 // If there's no renderer on the node, send the event to the nearest ancesto r with a renderer. 2469 // If there's no renderer on the node, send the event to the nearest ancesto r with a renderer.
2470 // Needed for <option> and <optgroup> elements so we can touch scroll <selec t>s 2470 // Needed for <option> and <optgroup> elements so we can touch scroll <selec t>s
2471 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->renderer ()) 2471 while (m_scrollGestureHandlingNode && !m_scrollGestureHandlingNode->layoutOb ject())
2472 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado wHostNode(); 2472 m_scrollGestureHandlingNode = m_scrollGestureHandlingNode->parentOrShado wHostNode();
2473 2473
2474 if (!m_scrollGestureHandlingNode) 2474 if (!m_scrollGestureHandlingNode)
2475 return false; 2475 return false;
2476 2476
2477 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->re nderer()); 2477 passScrollGestureEventToWidget(gestureEvent, m_scrollGestureHandlingNode->la youtObject());
2478 2478
2479 if (m_frame->isMainFrame()) 2479 if (m_frame->isMainFrame())
2480 m_frame->host()->topControls().scrollBegin(); 2480 m_frame->host()->topControls().scrollBegin();
2481 2481
2482 return true; 2482 return true;
2483 } 2483 }
2484 2484
2485 static bool scrollAreaOnBothAxes(const FloatSize& delta, ScrollableArea& view) 2485 static bool scrollAreaOnBothAxes(const FloatSize& delta, ScrollableArea& view)
2486 { 2486 {
2487 bool scrolledHorizontal = view.scroll(ScrollLeft, ScrollByPrecisePixel, delt a.width()); 2487 bool scrolledHorizontal = view.scroll(ScrollLeft, ScrollByPrecisePixel, delt a.width());
2488 bool scrolledVertical = view.scroll(ScrollUp, ScrollByPrecisePixel, delta.he ight()); 2488 bool scrolledVertical = view.scroll(ScrollUp, ScrollByPrecisePixel, delta.he ight());
2489 return scrolledHorizontal || scrolledVertical; 2489 return scrolledHorizontal || scrolledVertical;
2490 } 2490 }
2491 2491
2492 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event) 2492 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event)
2493 { 2493 {
2494 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); 2494 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate);
2495 2495
2496 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); 2496 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY());
2497 if (delta.isZero()) 2497 if (delta.isZero())
2498 return false; 2498 return false;
2499 2499
2500 Node* node = m_scrollGestureHandlingNode.get(); 2500 Node* node = m_scrollGestureHandlingNode.get();
2501 if (node) { 2501 if (node) {
2502 LayoutObject* renderer = node->renderer(); 2502 LayoutObject* renderer = node->layoutObject();
2503 if (!renderer) 2503 if (!renderer)
2504 return false; 2504 return false;
2505 2505
2506 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); 2506 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view());
2507 2507
2508 Node* stopNode = nullptr; 2508 Node* stopNode = nullptr;
2509 2509
2510 // Try to send the event to the correct view. 2510 // Try to send the event to the correct view.
2511 if (passScrollGestureEventToWidget(gestureEvent, renderer)) { 2511 if (passScrollGestureEventToWidget(gestureEvent, renderer)) {
2512 if (gestureEvent.preventPropagation()) 2512 if (gestureEvent.preventPropagation())
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
3310 { 3310 {
3311 // The DataTransfer would only be non-empty if we missed a dragEnd. 3311 // The DataTransfer would only be non-empty if we missed a dragEnd.
3312 // Clear it anyway, just to make sure it gets numbified. 3312 // Clear it anyway, just to make sure it gets numbified.
3313 clearDragDataTransfer(); 3313 clearDragDataTransfer();
3314 3314
3315 dragState().m_dragDataTransfer = createDraggingDataTransfer(); 3315 dragState().m_dragDataTransfer = createDraggingDataTransfer();
3316 3316
3317 // Check to see if this a DOM based drag, if it is get the DOM specified dra g 3317 // Check to see if this a DOM based drag, if it is get the DOM specified dra g
3318 // image and offset 3318 // image and offset
3319 if (dragState().m_dragType == DragSourceActionDHTML) { 3319 if (dragState().m_dragType == DragSourceActionDHTML) {
3320 if (LayoutObject* renderer = dragState().m_dragSrc->renderer()) { 3320 if (LayoutObject* renderer = dragState().m_dragSrc->layoutObject()) {
3321 FloatPoint absPos = renderer->localToAbsolute(FloatPoint(), UseTrans forms); 3321 FloatPoint absPos = renderer->localToAbsolute(FloatPoint(), UseTrans forms);
3322 IntSize delta = m_mouseDownPos - roundedIntPoint(absPos); 3322 IntSize delta = m_mouseDownPos - roundedIntPoint(absPos);
3323 dragState().m_dragDataTransfer->setDragImageElement(dragState().m_dr agSrc.get(), IntPoint(delta)); 3323 dragState().m_dragDataTransfer->setDragImageElement(dragState().m_dr agSrc.get(), IntPoint(delta));
3324 } else { 3324 } else {
3325 // The renderer has disappeared, this can happen if the onStartDrag handler has hidden 3325 // The renderer has disappeared, this can happen if the onStartDrag handler has hidden
3326 // the element in some way. In this case we just kill the drag. 3326 // the element in some way. In this case we just kill the drag.
3327 return false; 3327 return false;
3328 } 3328 }
3329 } 3329 }
3330 3330
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
3477 3477
3478 void EventHandler::defaultEscapeEventHandler(KeyboardEvent* event) 3478 void EventHandler::defaultEscapeEventHandler(KeyboardEvent* event)
3479 { 3479 {
3480 if (HTMLDialogElement* dialog = m_frame->document()->activeModalDialog()) 3480 if (HTMLDialogElement* dialog = m_frame->document()->activeModalDialog())
3481 dialog->dispatchEvent(Event::createCancelable(EventTypeNames::cancel)); 3481 dialog->dispatchEvent(Event::createCancelable(EventTypeNames::cancel));
3482 } 3482 }
3483 3483
3484 void EventHandler::capsLockStateMayHaveChanged() 3484 void EventHandler::capsLockStateMayHaveChanged()
3485 { 3485 {
3486 if (Element* element = m_frame->document()->focusedElement()) { 3486 if (Element* element = m_frame->document()->focusedElement()) {
3487 if (LayoutObject* r = element->renderer()) { 3487 if (LayoutObject* r = element->layoutObject()) {
3488 if (r->isTextField()) 3488 if (r->isTextField())
3489 toLayoutTextControlSingleLine(r)->capsLockStateMayHaveChanged(); 3489 toLayoutTextControlSingleLine(r)->capsLockStateMayHaveChanged();
3490 } 3490 }
3491 } 3491 }
3492 } 3492 }
3493 3493
3494 void EventHandler::setFrameWasScrolledByUser() 3494 void EventHandler::setFrameWasScrolledByUser()
3495 { 3495 {
3496 if (FrameView* view = m_frame->view()) 3496 if (FrameView* view = m_frame->view())
3497 view->setWasScrolledByUser(true); 3497 view->setWasScrolledByUser(true);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
3817 return action1 & action2; 3817 return action1 & action2;
3818 } 3818 }
3819 3819
3820 TouchAction EventHandler::computeEffectiveTouchAction(const Node& node) 3820 TouchAction EventHandler::computeEffectiveTouchAction(const Node& node)
3821 { 3821 {
3822 // Start by permitting all actions, then walk the elements supporting 3822 // Start by permitting all actions, then walk the elements supporting
3823 // touch-action from the target node up to the nearest scrollable ancestor 3823 // touch-action from the target node up to the nearest scrollable ancestor
3824 // and exclude any prohibited actions. 3824 // and exclude any prohibited actions.
3825 TouchAction effectiveTouchAction = TouchActionAuto; 3825 TouchAction effectiveTouchAction = TouchActionAuto;
3826 for (const Node* curNode = &node; curNode; curNode = NodeRenderingTraversal: :parent(*curNode)) { 3826 for (const Node* curNode = &node; curNode; curNode = NodeRenderingTraversal: :parent(*curNode)) {
3827 if (LayoutObject* renderer = curNode->renderer()) { 3827 if (LayoutObject* renderer = curNode->layoutObject()) {
3828 if (renderer->supportsTouchAction()) { 3828 if (renderer->supportsTouchAction()) {
3829 TouchAction action = renderer->style()->touchAction(); 3829 TouchAction action = renderer->style()->touchAction();
3830 effectiveTouchAction = intersectTouchAction(action, effectiveTou chAction); 3830 effectiveTouchAction = intersectTouchAction(action, effectiveTou chAction);
3831 if (effectiveTouchAction == TouchActionNone) 3831 if (effectiveTouchAction == TouchActionNone)
3832 break; 3832 break;
3833 } 3833 }
3834 3834
3835 // If we've reached an ancestor that supports a touch action, search no further. 3835 // If we've reached an ancestor that supports a touch action, search no further.
3836 if (renderer->isBox() && toLayoutBox(renderer)->scrollsOverflow()) 3836 if (renderer->isBox() && toLayoutBox(renderer)->scrollsOverflow())
3837 break; 3837 break;
(...skipping 11 matching lines...) Expand all
3849 3849
3850 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m ev, LocalFrame* subframe) 3850 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m ev, LocalFrame* subframe)
3851 { 3851 {
3852 // If we're clicking into a frame that is selected, the frame will appear 3852 // If we're clicking into a frame that is selected, the frame will appear
3853 // greyed out even though we're clicking on the selection. This looks 3853 // greyed out even though we're clicking on the selection. This looks
3854 // really strange (having the whole frame be greyed out), so we deselect the 3854 // really strange (having the whole frame be greyed out), so we deselect the
3855 // selection. 3855 // selection.
3856 IntPoint p = m_frame->view()->windowToContents(mev.event().position()); 3856 IntPoint p = m_frame->view()->windowToContents(mev.event().position());
3857 if (m_frame->selection().contains(p)) { 3857 if (m_frame->selection().contains(p)) {
3858 VisiblePosition visiblePos( 3858 VisiblePosition visiblePos(
3859 mev.innerNode()->renderer()->positionForPoint(mev.localPoint())); 3859 mev.innerNode()->layoutObject()->positionForPoint(mev.localPoint())) ;
3860 VisibleSelection newSelection(visiblePos); 3860 VisibleSelection newSelection(visiblePos);
3861 m_frame->selection().setSelection(newSelection); 3861 m_frame->selection().setSelection(newSelection);
3862 } 3862 }
3863 3863
3864 subframe->eventHandler().handleMousePressEvent(mev.event()); 3864 subframe->eventHandler().handleMousePressEvent(mev.event());
3865 return true; 3865 return true;
3866 } 3866 }
3867 3867
3868 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& me v, LocalFrame* subframe, HitTestResult* hoveredNode) 3868 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& me v, LocalFrame* subframe, HitTestResult* hoveredNode)
3869 { 3869 {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3919 3919
3920 // If it's in the direction to hide the top controls, only consume when the frame can also scroll. 3920 // If it's in the direction to hide the top controls, only consume when the frame can also scroll.
3921 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo sition().y()) 3921 if (m_frame->view()->scrollPosition().y() < m_frame->view()->maximumScrollPo sition().y())
3922 return true; 3922 return true;
3923 3923
3924 return false; 3924 return false;
3925 } 3925 }
3926 3926
3927 3927
3928 } // namespace blink 3928 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/page/DragController.cpp ('k') | Source/core/page/FocusController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698