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

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

Issue 20681004: Make first-letter style to work with editing Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-08-01T17:57:42 Created 7 years, 4 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
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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 413 }
414 414
415 m_frame->selection()->setNonDirectionalSelectionIfNeeded(selection, granular ity); 415 m_frame->selection()->setNonDirectionalSelectionIfNeeded(selection, granular ity);
416 416
417 return true; 417 return true;
418 } 418 }
419 419
420 void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& resul t, AppendTrailingWhitespace appendTrailingWhitespace) 420 void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& resul t, AppendTrailingWhitespace appendTrailingWhitespace)
421 { 421 {
422 Node* innerNode = result.targetNode(); 422 Node* innerNode = result.targetNode();
423 RenderObject* renderer = result.renderer();
423 VisibleSelection newSelection; 424 VisibleSelection newSelection;
424 425
425 if (innerNode && innerNode->renderer()) { 426 if (innerNode && renderer) {
426 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point())); 427 VisiblePosition pos(renderer->positionForPoint(result.localPoint()));
427 if (pos.isNotNull()) { 428 if (pos.isNotNull()) {
428 newSelection = VisibleSelection(pos); 429 newSelection = VisibleSelection(pos);
429 newSelection.expandUsingGranularity(WordGranularity); 430 newSelection.expandUsingGranularity(WordGranularity);
430 } 431 }
431 432
432 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel ection.isRange()) 433 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel ection.isRange())
433 newSelection.appendTrailingWhitespace(); 434 newSelection.appendTrailingWhitespace();
434 435
435 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity); 436 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity);
436 } 437 }
437 } 438 }
438 439
439 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult & result, AppendTrailingWhitespace appendTrailingWhitespace) 440 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult & result, AppendTrailingWhitespace appendTrailingWhitespace)
440 { 441 {
441 Node* innerNode = result.targetNode(); 442 Node* innerNode = result.targetNode();
443 RenderObject* renderer = result.renderer();
442 VisibleSelection newSelection; 444 VisibleSelection newSelection;
443 445
444 if (innerNode && innerNode->renderer()) { 446 if (innerNode && renderer) {
445 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point())); 447 VisiblePosition pos(renderer->positionForPoint(result.localPoint()));
446 Position start = pos.deepEquivalent(); 448 Position start = pos.deepEquivalent();
447 Position end = pos.deepEquivalent(); 449 Position end = pos.deepEquivalent();
448 if (pos.isNotNull()) { 450 if (pos.isNotNull()) {
449 Vector<DocumentMarker*> markers = innerNode->document()->markers()-> markersInRange( 451 Vector<DocumentMarker*> markers = innerNode->document()->markers()-> markersInRange(
450 makeRange(pos, pos).get(), DocumentMarker::Spelling | DocumentMa rker::Grammar); 452 makeRange(pos, pos).get(), DocumentMarker::Spelling | DocumentMa rker::Grammar);
451 if (markers.size() == 1) { 453 if (markers.size() == 1) {
452 start.moveToOffset(markers[0]->startOffset()); 454 start.moveToOffset(markers[0]->startOffset());
453 end.moveToOffset(markers[0]->endOffset()); 455 end.moveToOffset(markers[0]->endOffset());
454 newSelection = VisibleSelection(start, end); 456 newSelection = VisibleSelection(start, end);
455 } 457 }
(...skipping 21 matching lines...) Expand all
477 (result.event().clickCount() == 2 && m_frame->editor()->isSelectTrai lingWhitespaceEnabled()) ? ShouldAppendTrailingWhitespace : DontAppendTrailingWh itespace); 479 (result.event().clickCount() == 2 && m_frame->editor()->isSelectTrai lingWhitespaceEnabled()) ? ShouldAppendTrailingWhitespace : DontAppendTrailingWh itespace);
478 } 480 }
479 } 481 }
480 482
481 void EventHandler::selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHit TestResults& result) 483 void EventHandler::selectClosestWordOrLinkFromMouseEvent(const MouseEventWithHit TestResults& result)
482 { 484 {
483 if (!result.hitTestResult().isLiveLink()) 485 if (!result.hitTestResult().isLiveLink())
484 return selectClosestWordFromMouseEvent(result); 486 return selectClosestWordFromMouseEvent(result);
485 487
486 Node* innerNode = result.targetNode(); 488 Node* innerNode = result.targetNode();
489 RenderObject* renderer = result.hitTestResult().renderer();
487 490
488 if (innerNode && innerNode->renderer() && m_mouseDownMayStartSelect) { 491 if (innerNode && renderer && m_mouseDownMayStartSelect) {
489 VisibleSelection newSelection; 492 VisibleSelection newSelection;
490 Element* URLElement = result.hitTestResult().URLElement(); 493 Element* URLElement = result.hitTestResult().URLElement();
491 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local Point())); 494 VisiblePosition pos(renderer->positionForPoint(result.localPoint()));
492 if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescenda ntOf(URLElement)) 495 if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescenda ntOf(URLElement))
493 newSelection = VisibleSelection::selectionFromContentsOfNode(URLElem ent); 496 newSelection = VisibleSelection::selectionFromContentsOfNode(URLElem ent);
494 497
495 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity); 498 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelec tionToRespectUserSelectAll(innerNode, newSelection), WordGranularity);
496 } 499 }
497 } 500 }
498 501
499 bool EventHandler::handleMousePressEventDoubleClick(const MouseEventWithHitTestR esults& event) 502 bool EventHandler::handleMousePressEventDoubleClick(const MouseEventWithHitTestR esults& event)
500 { 503 {
501 if (event.event().button() != LeftButton) 504 if (event.event().button() != LeftButton)
(...skipping 11 matching lines...) Expand all
513 516
514 return true; 517 return true;
515 } 518 }
516 519
517 bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR esults& event) 520 bool EventHandler::handleMousePressEventTripleClick(const MouseEventWithHitTestR esults& event)
518 { 521 {
519 if (event.event().button() != LeftButton) 522 if (event.event().button() != LeftButton)
520 return false; 523 return false;
521 524
522 Node* innerNode = event.targetNode(); 525 Node* innerNode = event.targetNode();
523 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) 526 RenderObject* renderer = event.hitTestResult().renderer();
527 if (!(innerNode && renderer && m_mouseDownMayStartSelect))
524 return false; 528 return false;
525 529
526 VisibleSelection newSelection; 530 VisibleSelection newSelection;
527 VisiblePosition pos(innerNode->renderer()->positionForPoint(event.localPoint ())); 531 VisiblePosition pos(renderer->positionForPoint(event.localPoint()));
528 if (pos.isNotNull()) { 532 if (pos.isNotNull()) {
529 newSelection = VisibleSelection(pos); 533 newSelection = VisibleSelection(pos);
530 newSelection.expandUsingGranularity(ParagraphGranularity); 534 newSelection.expandUsingGranularity(ParagraphGranularity);
531 } 535 }
532 536
533 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity); 537 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity);
534 } 538 }
535 539
536 static int textDistance(const Position& start, const Position& end) 540 static int textDistance(const Position& start, const Position& end)
537 { 541 {
538 RefPtr<Range> range = Range::create(start.anchorNode()->document(), start, end); 542 RefPtr<Range> range = Range::create(start.anchorNode()->document(), start, end);
539 return TextIterator::rangeLength(range.get(), true); 543 return TextIterator::rangeLength(range.get(), true);
540 } 544 }
541 545
542 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR esults& event) 546 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR esults& event)
543 { 547 {
544 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 548 m_frame->document()->updateLayoutIgnorePendingStylesheets();
545 Node* innerNode = event.targetNode(); 549 Node* innerNode = event.targetNode();
546 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) 550 RenderObject* renderer = event.hitTestResult().renderer();
551 if (!(innerNode && renderer && m_mouseDownMayStartSelect))
547 return false; 552 return false;
548 553
549 // Extend the selection if the Shift key is down, unless the click is in a l ink. 554 // Extend the selection if the Shift key is down, unless the click is in a l ink.
550 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); 555 bool extendSelection = event.event().shiftKey() && !event.isOverLink();
551 556
552 // Don't restart the selection when the mouse is pressed on an 557 // Don't restart the selection when the mouse is pressed on an
553 // existing selection so we can allow for text dragging. 558 // existing selection so we can allow for text dragging.
554 if (FrameView* view = m_frame->view()) { 559 if (FrameView* view = m_frame->view()) {
555 LayoutPoint vPoint = view->windowToContents(event.event().position()); 560 LayoutPoint vPoint = view->windowToContents(event.event().position());
556 if (!extendSelection && m_frame->selection()->contains(vPoint)) { 561 if (!extendSelection && m_frame->selection()->contains(vPoint)) {
557 m_mouseDownWasSingleClickInSelection = true; 562 m_mouseDownWasSingleClickInSelection = true;
558 return false; 563 return false;
559 } 564 }
560 } 565 }
561 566
562 VisiblePosition visiblePos(innerNode->renderer()->positionForPoint(event.loc alPoint())); 567 VisiblePosition visiblePos(renderer->positionForPoint(event.localPoint()));
563 if (visiblePos.isNull()) 568 if (visiblePos.isNull())
564 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW NSTREAM); 569 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW NSTREAM);
565 Position pos = visiblePos.deepEquivalent(); 570 Position pos = visiblePos.deepEquivalent();
566 571
567 VisibleSelection newSelection = m_frame->selection()->selection(); 572 VisibleSelection newSelection = m_frame->selection()->selection();
568 TextGranularity granularity = CharacterGranularity; 573 TextGranularity granularity = CharacterGranularity;
569 574
570 if (extendSelection && newSelection.isCaretOrRange()) { 575 if (extendSelection && newSelection.isCaretOrRange()) {
571 VisibleSelection selectionInUserSelectAll = expandSelectionToRespectUser SelectAll(innerNode, VisibleSelection(pos)); 576 VisibleSelection selectionInUserSelectAll = expandSelectionToRespectUser SelectAll(innerNode, VisibleSelection(pos));
572 if (selectionInUserSelectAll.isRange()) { 577 if (selectionInUserSelectAll.isRange()) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 if (!m_mousePressed) 687 if (!m_mousePressed)
683 return false; 688 return false;
684 689
685 if (handleDrag(event, ShouldCheckDragHysteresis)) 690 if (handleDrag(event, ShouldCheckDragHysteresis))
686 return true; 691 return true;
687 692
688 Node* targetNode = event.targetNode(); 693 Node* targetNode = event.targetNode();
689 if (event.event().button() != LeftButton || !targetNode) 694 if (event.event().button() != LeftButton || !targetNode)
690 return false; 695 return false;
691 696
692 RenderObject* renderer = targetNode->renderer(); 697 RenderObject* renderer = event.hitTestResult().renderer();
693 if (!renderer) { 698 if (!renderer) {
694 Node* parent = EventPathWalker::parent(targetNode); 699 Node* parent = EventPathWalker::parent(targetNode);
695 if (!parent) 700 if (!parent)
696 return false; 701 return false;
697 702
698 renderer = parent->renderer(); 703 renderer = parent->renderer();
699 if (!renderer || !renderer->isListBox()) 704 if (!renderer || !renderer->isListBox())
700 return false; 705 return false;
701 } 706 }
702 707
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 742
738 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul t) 743 void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResul t)
739 { 744 {
740 if (!m_mouseDownMayStartSelect) 745 if (!m_mouseDownMayStartSelect)
741 return; 746 return;
742 747
743 Node* target = hitTestResult.targetNode(); 748 Node* target = hitTestResult.targetNode();
744 if (!target) 749 if (!target)
745 return; 750 return;
746 751
752 RenderObject* targetRenderer = hitTestResult.renderer();
747 VisiblePosition targetPosition = m_frame->selection()->selection().visiblePo sitionRespectingEditingBoundary(hitTestResult.localPoint(), target); 753 VisiblePosition targetPosition = m_frame->selection()->selection().visiblePo sitionRespectingEditingBoundary(hitTestResult.localPoint(), target);
748 // Don't modify the selection if we're not on a node. 754 // Don't modify the selection if we're not on a node.
749 if (targetPosition.isNull()) 755 if (targetPosition.isNull())
750 return; 756 return;
751 757
752 // Restart the selection if this is the first mouse move. This work is usual ly 758 // Restart the selection if this is the first mouse move. This work is usual ly
753 // done in handleMousePressEvent, but not if the mouse press was on an exist ing selection. 759 // done in handleMousePressEvent, but not if the mouse press was on an exist ing selection.
754 VisibleSelection newSelection = m_frame->selection()->selection(); 760 VisibleSelection newSelection = m_frame->selection()->selection();
755 761
756 // Special case to limit selection to the containing block for SVG text. 762 // Special case to limit selection to the containing block for SVG text.
757 // FIXME: Isn't there a better non-SVG-specific way to do this? 763 // FIXME: Isn't there a better non-SVG-specific way to do this?
758 if (Node* selectionBaseNode = newSelection.base().deprecatedNode()) 764 if (Node* selectionBaseNode = newSelection.base().deprecatedNode())
759 if (RenderObject* selectionBaseRenderer = selectionBaseNode->renderer()) 765 if (RenderObject* selectionBaseRenderer = selectionBaseNode->renderer())
760 if (selectionBaseRenderer->isSVGText()) 766 if (selectionBaseRenderer->isSVGText())
761 if (target->renderer()->containingBlock() != selectionBaseRender er->containingBlock()) 767 if (targetRenderer->containingBlock() != selectionBaseRenderer-> containingBlock())
762 return; 768 return;
763 769
764 if (m_selectionInitiationState == HaveNotStartedSelection && !dispatchSelect Start(target)) 770 if (m_selectionInitiationState == HaveNotStartedSelection && !dispatchSelect Start(target))
765 return; 771 return;
766 772
767 if (m_selectionInitiationState != ExtendedSelection) { 773 if (m_selectionInitiationState != ExtendedSelection) {
768 // Always extend selection here because it's caused by a mouse drag 774 // Always extend selection here because it's caused by a mouse drag
769 m_selectionInitiationState = ExtendedSelection; 775 m_selectionInitiationState = ExtendedSelection;
770 newSelection = VisibleSelection(targetPosition); 776 newSelection = VisibleSelection(targetPosition);
771 } 777 }
772 778
773 #if ENABLE(USERSELECT_ALL) 779 #if ENABLE(USERSELECT_ALL)
774 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllForNod e(m_mousePressNode.get()); 780 Node* rootUserSelectAllForMousePressNode = Position::rootUserSelectAllForNod e(m_mousePressNode.get());
775 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePressNode == Position::rootUserSelectAllForNode(target)) { 781 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePressNode == Position::rootUserSelectAllForNode(target)) {
776 newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePressNo de).upstream(CanCrossEditingBoundary)); 782 newSelection.setBase(positionBeforeNode(rootUserSelectAllForMousePressNo de).upstream(CanCrossEditingBoundary));
777 newSelection.setExtent(positionAfterNode(rootUserSelectAllForMousePressN ode).downstream(CanCrossEditingBoundary)); 783 newSelection.setExtent(positionAfterNode(rootUserSelectAllForMousePressN ode).downstream(CanCrossEditingBoundary));
778 } else { 784 } else {
779 // Reset base for user select all when base is inside user-select-all ar ea and extent < base. 785 // Reset base for user select all when base is inside user-select-all ar ea and extent < base.
780 if (rootUserSelectAllForMousePressNode && comparePositions(target->rende rer()->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->renderer( )->positionForPoint(m_dragStartPos)) < 0) 786 if (rootUserSelectAllForMousePressNode && comparePositions(targetRendere r->positionForPoint(hitTestResult.localPoint()), m_mousePressNode->renderer()->p ositionForPoint(m_dragStartPos)) < 0)
781 newSelection.setBase(positionAfterNode(rootUserSelectAllForMousePres sNode).downstream(CanCrossEditingBoundary)); 787 newSelection.setBase(positionAfterNode(rootUserSelectAllForMousePres sNode).downstream(CanCrossEditingBoundary));
782 788
783 Node* rootUserSelectAllForTarget = Position::rootUserSelectAllForNode(ta rget); 789 Node* rootUserSelectAllForTarget = Position::rootUserSelectAllForNode(ta rget);
784 if (rootUserSelectAllForTarget && m_mousePressNode->renderer() && compar ePositions(target->renderer()->positionForPoint(hitTestResult.localPoint()), m_m ousePressNode->renderer()->positionForPoint(m_dragStartPos)) < 0) 790 if (rootUserSelectAllForTarget && m_mousePressNode->renderer() && compar ePositions(targetRenderer->positionForPoint(hitTestResult.localPoint()), m_mouse PressNode->renderer()->positionForPoint(m_dragStartPos)) < 0)
785 newSelection.setExtent(positionBeforeNode(rootUserSelectAllForTarget ).upstream(CanCrossEditingBoundary)); 791 newSelection.setExtent(positionBeforeNode(rootUserSelectAllForTarget ).upstream(CanCrossEditingBoundary));
786 else if (rootUserSelectAllForTarget && m_mousePressNode->renderer()) 792 else if (rootUserSelectAllForTarget && m_mousePressNode->renderer())
787 newSelection.setExtent(positionAfterNode(rootUserSelectAllForTarget) .downstream(CanCrossEditingBoundary)); 793 newSelection.setExtent(positionAfterNode(rootUserSelectAllForTarget) .downstream(CanCrossEditingBoundary));
788 else 794 else
789 newSelection.setExtent(targetPosition); 795 newSelection.setExtent(targetPosition);
790 } 796 }
791 #else 797 #else
792 newSelection.setExtent(targetPosition); 798 newSelection.setExtent(targetPosition);
793 #endif 799 #endif
794 800
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 // Clear the selection if the mouse didn't move after the last mouse 843 // Clear the selection if the mouse didn't move after the last mouse
838 // press and it's not a context menu click. We do this so when clicking 844 // press and it's not a context menu click. We do this so when clicking
839 // on the selection, the selection goes away. However, if we are 845 // on the selection, the selection goes away. However, if we are
840 // editing, place the caret. 846 // editing, place the caret.
841 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection 847 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection
842 && m_dragStartPos == event.event().position() 848 && m_dragStartPos == event.event().position()
843 && m_frame->selection()->isRange() 849 && m_frame->selection()->isRange()
844 && event.event().button() != RightButton) { 850 && event.event().button() != RightButton) {
845 VisibleSelection newSelection; 851 VisibleSelection newSelection;
846 Node* node = event.targetNode(); 852 Node* node = event.targetNode();
853 RenderObject* renderer = event.hitTestResult().renderer();
847 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr owsingEnabled(); 854 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr owsingEnabled();
848 if (node && (caretBrowsing || node->rendererIsEditable()) && node->rende rer()) { 855 if (node && (caretBrowsing || node->rendererIsEditable()) && renderer)
849 VisiblePosition pos = VisiblePosition(node->renderer()->positionForP oint(event.localPoint())); 856 newSelection = VisibleSelection(VisiblePosition(renderer->positionFo rPoint(event.localPoint())));
850 newSelection = VisibleSelection(pos);
851 }
852 857
853 setSelectionIfNeeded(m_frame->selection(), newSelection); 858 setSelectionIfNeeded(m_frame->selection(), newSelection);
854 859
855 handled = true; 860 handled = true;
856 } 861 }
857 862
858 m_frame->selection()->notifyRendererOfSelectionChange(UserTriggered); 863 m_frame->selection()->notifyRendererOfSelectionChange(UserTriggered);
859 864
860 m_frame->selection()->selectFrameElementInParentIfFullySelected(); 865 m_frame->selection()->selectFrameElementInParentIfFullySelected();
861 866
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 1114
1110 Page* page = m_frame->page(); 1115 Page* page = m_frame->page();
1111 if (!page) 1116 if (!page)
1112 return NoCursorChange; 1117 return NoCursorChange;
1113 #if OS(WINDOWS) 1118 #if OS(WINDOWS)
1114 if (panScrollInProgress()) 1119 if (panScrollInProgress())
1115 return NoCursorChange; 1120 return NoCursorChange;
1116 #endif 1121 #endif
1117 1122
1118 Node* node = event.targetNode(); 1123 Node* node = event.targetNode();
1119 RenderObject* renderer = node ? node->renderer() : 0; 1124 RenderObject* renderer = event.hitTestResult().renderer();
1120 RenderStyle* style = renderer ? renderer->style() : 0; 1125 RenderStyle* style = renderer ? renderer->style() : 0;
1121 bool horizontalText = !style || style->isHorizontalWritingMode(); 1126 bool horizontalText = !style || style->isHorizontalWritingMode();
1122 const Cursor& iBeam = horizontalText ? iBeamCursor() : verticalTextCursor(); 1127 const Cursor& iBeam = horizontalText ? iBeamCursor() : verticalTextCursor();
1123 1128
1124 // During selection, use an I-beam no matter what we're over. 1129 // During selection, use an I-beam no matter what we're over.
1125 // If a drag may be starting or we're capturing mouse events for a particula r node, don't treat this as a selection. 1130 // If a drag may be starting or we're capturing mouse events for a particula r node, don't treat this as a selection.
1126 if (m_mousePressed && m_mouseDownMayStartSelect 1131 if (m_mousePressed && m_mouseDownMayStartSelect
1127 && !m_mouseDownMayStartDrag 1132 && !m_mouseDownMayStartDrag
1128 && m_frame->selection()->isCaretOrRange() && !m_capturingMouseEventsNode ) 1133 && m_frame->selection()->isCaretOrRange() && !m_capturingMouseEventsNode )
1129 return iBeam; 1134 return iBeam;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 if (isPanScrollInProgress) { 1341 if (isPanScrollInProgress) {
1337 // We invalidate the click when exiting pan scrolling so that we don't i nadvertently navigate 1342 // We invalidate the click when exiting pan scrolling so that we don't i nadvertently navigate
1338 // away from the current page (e.g. the click was on a hyperlink). See < rdar://problem/6095023>. 1343 // away from the current page (e.g. the click was on a hyperlink). See < rdar://problem/6095023>.
1339 invalidateClick(); 1344 invalidateClick();
1340 return true; 1345 return true;
1341 } 1346 }
1342 #endif 1347 #endif
1343 1348
1344 m_clickCount = mouseEvent.clickCount(); 1349 m_clickCount = mouseEvent.clickCount();
1345 m_clickNode = mev.targetNode(); 1350 m_clickNode = mev.targetNode();
1351 RenderObject* clickRenderer = mev.hitTestResult().renderer();
1346 1352
1347 if (FrameView* view = m_frame->view()) { 1353 if (FrameView* view = m_frame->view()) {
1348 RenderLayer* layer = m_clickNode->renderer() ? m_clickNode->renderer()-> enclosingLayer() : 0; 1354 RenderLayer* layer = clickRenderer ? clickRenderer->enclosingLayer() : 0 ;
1349 IntPoint p = view->windowToContents(mouseEvent.position()); 1355 IntPoint p = view->windowToContents(mouseEvent.position());
1350 if (layer && layer->isPointInResizeControl(p, RenderLayer::ResizerForPoi nter)) { 1356 if (layer && layer->isPointInResizeControl(p, RenderLayer::ResizerForPoi nter)) {
1351 layer->setInResizeMode(true); 1357 layer->setInResizeMode(true);
1352 m_resizeLayer = layer; 1358 m_resizeLayer = layer;
1353 m_offsetFromResizeCorner = layer->offsetFromResizeCorner(p); 1359 m_offsetFromResizeCorner = layer->offsetFromResizeCorner(p);
1354 invalidateClick(); 1360 invalidateClick();
1355 return true; 1361 return true;
1356 } 1362 }
1357 } 1363 }
1358 1364
(...skipping 2451 matching lines...) Expand 10 before | Expand all | Expand 10 after
3810 // the event via an EventTargetNode dispatch when this returns false. 3816 // the event via an EventTargetNode dispatch when this returns false.
3811 if (!widget->isFrameView()) 3817 if (!widget->isFrameView())
3812 return false; 3818 return false;
3813 3819
3814 return toFrameView(widget)->frame()->eventHandler()->handleWheelEvent(wheelE vent); 3820 return toFrameView(widget)->frame()->eventHandler()->handleWheelEvent(wheelE vent);
3815 } 3821 }
3816 3822
3817 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR esults& event) 3823 bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestR esults& event)
3818 { 3824 {
3819 // Figure out which view to send the event to. 3825 // Figure out which view to send the event to.
3820 if (!event.targetNode() || !event.targetNode()->renderer() || !event.targetN ode()->renderer()->isWidget()) 3826 if (!event.targetNode() || !event.hitTestResult().renderer() || !event.hitTe stResult().renderer()->isWidget())
3821 return false; 3827 return false;
3822 return false; 3828 return false;
3823 } 3829 }
3824 3830
3825 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const 3831 PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
3826 { 3832 {
3827 RefPtr<ChromiumDataObject> dataObject = ChromiumDataObject::create(); 3833 RefPtr<ChromiumDataObject> dataObject = ChromiumDataObject::create();
3828 return ClipboardChromium::create(Clipboard::DragAndDrop, dataObject.get(), C lipboardWritable, m_frame); 3834 return ClipboardChromium::create(Clipboard::DragAndDrop, dataObject.get(), C lipboardWritable, m_frame);
3829 } 3835 }
3830 3836
3831 void EventHandler::focusDocumentView() 3837 void EventHandler::focusDocumentView()
3832 { 3838 {
3833 Page* page = m_frame->page(); 3839 Page* page = m_frame->page();
3834 if (!page) 3840 if (!page)
3835 return; 3841 return;
3836 page->focusController()->setFocusedFrame(m_frame); 3842 page->focusController()->setFocusedFrame(m_frame);
3837 } 3843 }
3838 3844
3839 unsigned EventHandler::accessKeyModifiers() 3845 unsigned EventHandler::accessKeyModifiers()
3840 { 3846 {
3841 #if OS(DARWIN) 3847 #if OS(DARWIN)
3842 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3848 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3843 #else 3849 #else
3844 return PlatformEvent::AltKey; 3850 return PlatformEvent::AltKey;
3845 #endif 3851 #endif
3846 } 3852 }
3847 3853
3848 } // namespace WebCore 3854 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698