diff options
author | George Mount <mount@google.com> | 2012-06-14 09:59:34 -0700 |
---|---|---|
committer | George Mount <mount@google.com> | 2012-06-18 14:22:41 -0700 |
commit | 0f52bbcbd939dd6fcbb100e4e463456c5343a263 (patch) | |
tree | 6616b3b3487ac9bf3a2a08434659fa31b9b381e4 /Source/WebKit/android/jni | |
parent | 0634b6f6429e4e30beddf85239da061726861484 (diff) | |
download | external_webkit-0f52bbcbd939dd6fcbb100e4e463456c5343a263.zip external_webkit-0f52bbcbd939dd6fcbb100e4e463456c5343a263.tar.gz external_webkit-0f52bbcbd939dd6fcbb100e4e463456c5343a263.tar.bz2 |
Clip selected text within scrollable edit to the edit boundary.
Bug 6666415
Change-Id: Ie19e6bc3eedcbb5c9eb5791ac4b1f55149dcdb72
Diffstat (limited to 'Source/WebKit/android/jni')
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 885e730..679dd97 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -1596,6 +1596,20 @@ bool WebViewCore::isLtr(const Position& position) return isLtr; } +static Node* findInputParent(Node* node) +{ + Node* testNode = node; + while (testNode) { + RenderObject* renderer = testNode->renderer(); + if (renderer + && (renderer->isTextArea() || renderer->isTextControl())) { + return testNode; + } + testNode = testNode->parentOrHostNode(); + } + return node; +} + SelectText* WebViewCore::createSelectText(const VisibleSelection& selection) { bool isCaret = selection.isCaret(); @@ -1640,6 +1654,18 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection) ? SelectText::RightHandle : SelectText::LeftHandle; setSelectionCaretInfo(selectTextContainer, extent, frameOffset, SelectText::ExtentHandle, extentHandleType, extentOffset, affinity); + IntRect clipRect; + if (selection.isContentEditable()) { + Node* editable = findInputParent(base.anchorNode()); + RenderObject* render = editable->renderer(); + if (render && render->isBox() && !render->isBody()) { + RenderBox* renderBox = toRenderBox(render); + clipRect = renderBox->clientBoxRect(); + FloatPoint pos = renderBox->localToAbsolute(clipRect.location()); + clipRect.setX(pos.x()); + clipRect.setY(pos.y()); + } + } Node* stopNode = range->pastLastNode(); for (Node* node = range->firstNode(); node != stopNode; node = node->traverseNextNode()) { @@ -1653,7 +1679,8 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection) int layerId = platformLayerIdFromNode(node, &layer); Vector<IntRect> rects; renderText->absoluteRectsForRange(rects, startOffset, endOffset, true); - selectTextContainer->addHighlightRegion(layer, rects, frameOffset); + selectTextContainer->addHighlightRegion(layer, rects, frameOffset, + clipRect); } } selectTextContainer->setText(range->text()); |