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

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleSelection.cpp

Issue 2022723002: Move VisibleSelection::positionRespectingEditingBoundary() to EditingUtilities.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-05-30T17:10:26 Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 m_start = next.deepEquivalent(); 727 m_start = next.deepEquivalent();
728 } 728 }
729 } 729 }
730 730
731 // Correct the extent if necessary. 731 // Correct the extent if necessary.
732 if (baseEditableAncestor != lowestEditableAncestor(m_extent.computeContainer Node())) 732 if (baseEditableAncestor != lowestEditableAncestor(m_extent.computeContainer Node()))
733 m_extent = m_baseIsFirst ? m_end : m_start; 733 m_extent = m_baseIsFirst ? m_end : m_start;
734 } 734 }
735 735
736 template <typename Strategy> 736 template <typename Strategy>
737 VisiblePositionTemplate<Strategy> VisibleSelectionTemplate<Strategy>::visiblePos itionRespectingEditingBoundary(const LayoutPoint& localPoint, Node* targetNode) const
738 {
739 return createVisiblePosition(positionRespectingEditingBoundary(localPoint, t argetNode));
740 }
741
742 template <typename Strategy>
743 PositionWithAffinityTemplate<Strategy> VisibleSelectionTemplate<Strategy>::posit ionRespectingEditingBoundary(const LayoutPoint& localPoint, Node* targetNode) co nst
744 {
745 if (!targetNode->layoutObject())
746 return PositionWithAffinityTemplate<Strategy>();
747
748 LayoutPoint selectionEndPoint = localPoint;
749 Element* editableElement = rootEditableElement();
750
751 if (editableElement && !editableElement->contains(targetNode)) {
752 if (!editableElement->layoutObject())
753 return PositionWithAffinityTemplate<Strategy>();
754
755 FloatPoint absolutePoint = targetNode->layoutObject()->localToAbsolute(F loatPoint(selectionEndPoint));
756 selectionEndPoint = roundedLayoutPoint(editableElement->layoutObject()-> absoluteToLocal(absolutePoint));
757 targetNode = editableElement;
758 }
759
760 return fromPositionInDOMTree<Strategy>(targetNode->layoutObject()->positionF orPoint(selectionEndPoint));
761 }
762
763 template <typename Strategy>
764 bool VisibleSelectionTemplate<Strategy>::isContentEditable() const 737 bool VisibleSelectionTemplate<Strategy>::isContentEditable() const
765 { 738 {
766 return isEditablePosition(start()); 739 return isEditablePosition(start());
767 } 740 }
768 741
769 template <typename Strategy> 742 template <typename Strategy>
770 bool VisibleSelectionTemplate<Strategy>::hasEditableStyle() const 743 bool VisibleSelectionTemplate<Strategy>::hasEditableStyle() const
771 { 744 {
772 return isEditablePosition(start(), ContentIsEditable, DoNotUpdateStyle); 745 return isEditablePosition(start(), ContentIsEditable, DoNotUpdateStyle);
773 } 746 }
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 { 971 {
999 sel.showTreeForThis(); 972 sel.showTreeForThis();
1000 } 973 }
1001 974
1002 void showTree(const blink::VisibleSelectionInFlatTree* sel) 975 void showTree(const blink::VisibleSelectionInFlatTree* sel)
1003 { 976 {
1004 if (sel) 977 if (sel)
1005 sel->showTreeForThis(); 978 sel->showTreeForThis();
1006 } 979 }
1007 #endif 980 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleSelection.h ('k') | third_party/WebKit/Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698