diff options
author | George Mount <mount@google.com> | 2012-06-12 08:33:02 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-06-12 08:33:02 -0700 |
commit | 85bb7725195ca6b94ee97d0a95af9eed6d7ceaa5 (patch) | |
tree | 5aede662479028a9f310d81ed356ff0415d1593f /Source/WebKit/android/jni/WebViewCore.cpp | |
parent | 5d164098aea1c9b5e1d993eac2e92b3be3dd5832 (diff) | |
parent | 2f25be4556024e8272a7a22e5b9a5c9b2caf2d65 (diff) | |
download | external_webkit-85bb7725195ca6b94ee97d0a95af9eed6d7ceaa5.zip external_webkit-85bb7725195ca6b94ee97d0a95af9eed6d7ceaa5.tar.gz external_webkit-85bb7725195ca6b94ee97d0a95af9eed6d7ceaa5.tar.bz2 |
Merge "Fix edit text capturing selection."
Diffstat (limited to 'Source/WebKit/android/jni/WebViewCore.cpp')
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 550c95d..31d5535 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -1707,25 +1707,25 @@ IntPoint WebViewCore::convertGlobalContentToFrameContent(const IntPoint& point, return IntPoint(point.x() + frameOffset.x(), point.y() + frameOffset.y()); } -Position WebViewCore::trimSelectionPosition(const Position &start, const Position& stop) +VisiblePosition WebViewCore::trimSelectionPosition(const VisiblePosition &start, + const VisiblePosition& stop) { int direction = comparePositions(start, stop); if (direction == 0) return start; bool forward = direction < 0; - EAffinity affinity = forward ? DOWNSTREAM : UPSTREAM; bool move; - Position pos = start; + VisiblePosition pos = start; bool movedTooFar = false; do { move = true; - Node* node = pos.anchorNode(); + Node* node = pos.deepEquivalent().anchorNode(); if (node && node->isTextNode() && node->renderer()) { RenderText *textRenderer = toRenderText(node->renderer()); move = !textRenderer->textLength(); } if (move) { - Position nextPos = forward ? pos.next() : pos.previous(); + VisiblePosition nextPos = forward ? pos.next() : pos.previous(); movedTooFar = nextPos.isNull() || pos == nextPos || ((comparePositions(nextPos, stop) < 0) != forward); pos = nextPos; @@ -1761,37 +1761,37 @@ void WebViewCore::selectText(SelectText::HandleId handleId, int x, int y) bool draggingStart = (baseIsStart == draggingBase); if (draggingStart) { - startPosition = endPosition.honorEditableBoundaryAtOrAfter(startPosition); - if (startPosition.isNull()) - return; - if (selection.isCaret()) - start = end = startPosition.deepEquivalent(); - else { + if (selection.isRange()) { + startPosition = trimSelectionPosition(startPosition, endPosition); if ((startPosition != endPosition) && isEndOfBlock(startPosition)) { // Ensure startPosition is not at end of block VisiblePosition nextStartPosition(startPosition.next()); if (nextStartPosition.isNotNull()) startPosition = nextStartPosition; } - start = startPosition.deepEquivalent(); - start = trimSelectionPosition(start, end); } - } else { - endPosition = startPosition.honorEditableBoundaryAtOrAfter(endPosition); - if (endPosition.isNull()) + startPosition = endPosition.honorEditableBoundaryAtOrAfter(startPosition); + if (startPosition.isNull()) return; + start = startPosition.deepEquivalent(); if (selection.isCaret()) - start = end = endPosition.deepEquivalent(); - else { - if ((startPosition != endPosition) && isStartOfBlock(endPosition)) { + end = start; + } else { + if (selection.isRange()) { + endPosition = trimSelectionPosition(endPosition, startPosition); + if ((start != end) && isStartOfBlock(endPosition)) { // Ensure endPosition is not at start of block VisiblePosition prevEndPosition(endPosition.previous()); if (!prevEndPosition.isNull()) endPosition = prevEndPosition; } - end = endPosition.deepEquivalent(); - end = trimSelectionPosition(end, start); } + endPosition = startPosition.honorEditableBoundaryAtOrAfter(endPosition); + if (endPosition.isNull()) + return; + end = endPosition.deepEquivalent(); + if (selection.isCaret()) + start = end; } selection = VisibleSelection(base, extent); |