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

Side by Side Diff: Source/core/frame/LocalFrame.cpp

Issue 1310323004: Introduce positionForPoint() in LocalFrame class as replacement of visiblePositionForPoint() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-25T15:15:43 Created 5 years, 3 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 | « Source/core/frame/LocalFrame.h ('k') | Source/core/page/DragController.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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 String LocalFrame::selectedText() const 665 String LocalFrame::selectedText() const
666 { 666 {
667 return selection().selectedText(); 667 return selection().selectedText();
668 } 668 }
669 669
670 String LocalFrame::selectedTextForClipboard() const 670 String LocalFrame::selectedTextForClipboard() const
671 { 671 {
672 return selection().selectedTextForClipboard(); 672 return selection().selectedTextForClipboard();
673 } 673 }
674 674
675 VisiblePosition LocalFrame::visiblePositionForPoint(const IntPoint& framePoint) 675 PositionWithAffinity LocalFrame::positionForPoint(const IntPoint& framePoint)
676 { 676 {
677 HitTestResult result = eventHandler().hitTestResultAtPoint(framePoint); 677 HitTestResult result = eventHandler().hitTestResultAtPoint(framePoint);
678 Node* node = result.innerNodeOrImageMapImage(); 678 Node* node = result.innerNodeOrImageMapImage();
679 if (!node) 679 if (!node)
680 return VisiblePosition(); 680 return PositionWithAffinity();
681 LayoutObject* layoutObject = node->layoutObject(); 681 LayoutObject* layoutObject = node->layoutObject();
682 if (!layoutObject) 682 if (!layoutObject)
683 return VisiblePosition(); 683 return PositionWithAffinity();
684 VisiblePosition visiblePos = VisiblePosition(layoutObject->positionForPoint( result.localPoint())); 684 const PositionWithAffinity position = layoutObject->positionForPoint(result. localPoint());
685 if (visiblePos.isNull()) 685 if (position.isNull())
686 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(node)); 686 return PositionWithAffinity(firstPositionInOrBeforeNode(node));
687 return visiblePos; 687 return position;
688 } 688 }
689 689
690 Document* LocalFrame::documentAtPoint(const IntPoint& pointInRootFrame) 690 Document* LocalFrame::documentAtPoint(const IntPoint& pointInRootFrame)
691 { 691 {
692 if (!view()) 692 if (!view())
693 return nullptr; 693 return nullptr;
694 694
695 IntPoint pt = view()->rootFrameToContents(pointInRootFrame); 695 IntPoint pt = view()->rootFrameToContents(pointInRootFrame);
696 696
697 if (!contentLayoutObject()) 697 if (!contentLayoutObject())
698 return nullptr; 698 return nullptr;
699 HitTestResult result = eventHandler().hitTestResultAtPoint(pt, HitTestReques t::ReadOnly | HitTestRequest::Active); 699 HitTestResult result = eventHandler().hitTestResultAtPoint(pt, HitTestReques t::ReadOnly | HitTestRequest::Active);
700 return result.innerNode() ? &result.innerNode()->document() : nullptr; 700 return result.innerNode() ? &result.innerNode()->document() : nullptr;
701 } 701 }
702 702
703 EphemeralRange LocalFrame::rangeForPoint(const IntPoint& framePoint) 703 EphemeralRange LocalFrame::rangeForPoint(const IntPoint& framePoint)
704 { 704 {
705 VisiblePosition position = visiblePositionForPoint(framePoint); 705 const PositionWithAffinity positionWithAffinity = positionForPoint(framePoin t);
706 if (position.isNull()) 706 if (positionWithAffinity.isNull())
707 return EphemeralRange(); 707 return EphemeralRange();
708 708
709 VisiblePosition position(positionWithAffinity);
709 VisiblePosition previous = position.previous(); 710 VisiblePosition previous = position.previous();
710 if (previous.isNotNull()) { 711 if (previous.isNotNull()) {
711 const EphemeralRange previousCharacterRange = makeRange(previous, positi on); 712 const EphemeralRange previousCharacterRange = makeRange(previous, positi on);
712 IntRect rect = editor().firstRectForRange(previousCharacterRange); 713 IntRect rect = editor().firstRectForRange(previousCharacterRange);
713 if (rect.contains(framePoint)) 714 if (rect.contains(framePoint))
714 return EphemeralRange(previousCharacterRange); 715 return EphemeralRange(previousCharacterRange);
715 } 716 }
716 717
717 VisiblePosition next = position.next(); 718 VisiblePosition next = position.next();
718 const EphemeralRange nextCharacterRange = makeRange(position, next); 719 const EphemeralRange nextCharacterRange = makeRange(position, next);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 { 853 {
853 if (isLocalRoot()) 854 if (isLocalRoot())
854 m_instrumentingAgents = InstrumentingAgents::create(); 855 m_instrumentingAgents = InstrumentingAgents::create();
855 else 856 else
856 m_instrumentingAgents = localFrameRoot()->m_instrumentingAgents; 857 m_instrumentingAgents = localFrameRoot()->m_instrumentingAgents;
857 } 858 }
858 859
859 DEFINE_WEAK_IDENTIFIER_MAP(LocalFrame); 860 DEFINE_WEAK_IDENTIFIER_MAP(LocalFrame);
860 861
861 } // namespace blink 862 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/LocalFrame.h ('k') | Source/core/page/DragController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698