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

Unified Diff: Source/core/editing/VisibleSelection.cpp

Issue 15017002: WebFrame::selectRange and moveCaret should behave like mouse selection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comment Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/VisibleSelection.h ('k') | Source/core/page/EventHandler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/VisibleSelection.cpp
diff --git a/Source/core/editing/VisibleSelection.cpp b/Source/core/editing/VisibleSelection.cpp
index 09b7ab7ef2b845fbdccc2a40e1b2b558cd176c04..c5e98849878b0a206d0566ebf0f30b0f16918987 100644
--- a/Source/core/editing/VisibleSelection.cpp
+++ b/Source/core/editing/VisibleSelection.cpp
@@ -34,6 +34,8 @@
#include "core/editing/VisiblePosition.h"
#include "core/editing/VisibleUnits.h"
#include "core/editing/htmlediting.h"
+#include "core/platform/graphics/LayoutPoint.h"
+#include "core/rendering/RenderObject.h"
#include <wtf/Assertions.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
@@ -624,6 +626,27 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
m_extent = m_baseIsFirst ? m_end : m_start;
}
+VisiblePosition VisibleSelection::visiblePositionRespectingEditingBoundary(const LayoutPoint& localPoint, Node* targetNode) const
+{
+ if (!targetNode->renderer())
+ return VisiblePosition();
+
+ LayoutPoint selectionEndPoint = localPoint;
+ Element* editableElement = rootEditableElement();
+
+ if (editableElement && !editableElement->contains(targetNode)) {
+ if (!editableElement->renderer())
+ return VisiblePosition();
+
+ FloatPoint absolutePoint = targetNode->renderer()->localToAbsolute(FloatPoint(selectionEndPoint));
+ selectionEndPoint = roundedLayoutPoint(editableElement->renderer()->absoluteToLocal(absolutePoint));
+ targetNode = editableElement;
+ }
+
+ return targetNode->renderer()->positionForPoint(selectionEndPoint);
+}
+
+
bool VisibleSelection::isContentEditable() const
{
return isEditablePosition(start());
« no previous file with comments | « Source/core/editing/VisibleSelection.h ('k') | Source/core/page/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698