diff options
author | George Mount <mount@google.com> | 2012-05-30 07:41:31 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-05-30 07:41:31 -0700 |
commit | e9802036468c20c710c9418d56e9de928d7298ab (patch) | |
tree | a4caa7516fb7cf8966130008ce060c4ba9f41943 | |
parent | cbfe85d221255eaee1424b1a2f79be6166523bc4 (diff) | |
parent | c83120b4d089eed50a8c819256f065457529b862 (diff) | |
download | external_webkit-e9802036468c20c710c9418d56e9de928d7298ab.zip external_webkit-e9802036468c20c710c9418d56e9de928d7298ab.tar.gz external_webkit-e9802036468c20c710c9418d56e9de928d7298ab.tar.bz2 |
am c83120b4: am 658c3ec9: Merge "Consider frame offset for text snap rectangle." into jb-dev
* commit 'c83120b4d089eed50a8c819256f065457529b862':
Consider frame offset for text snap rectangle.
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 30 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.h | 2 |
2 files changed, 13 insertions, 19 deletions
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 1e87b6e..161c0b2 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -1566,14 +1566,14 @@ void WebViewCore::layerToAbsoluteOffset(const LayerAndroid* layer, IntPoint& off void WebViewCore::setSelectionCaretInfo(SelectText* selectTextContainer, const WebCore::Position& pos, const IntPoint& frameOffset, - SelectText::HandleId handleId, int offset, EAffinity affinity) + SelectText::HandleId handleId, int caretRectOffset, EAffinity affinity) { Node* node = pos.anchorNode(); LayerAndroid* layer = 0; int layerId = platformLayerIdFromNode(node, &layer); selectTextContainer->setCaretLayerId(handleId, layerId); - IntPoint layerOffset; - layerToAbsoluteOffset(layer, layerOffset); + IntPoint offset = frameOffset; + layerToAbsoluteOffset(layer, offset); RenderObject* r = node->renderer(); RenderText* renderText = toRenderText(r); int caretOffset; @@ -1581,12 +1581,11 @@ void WebViewCore::setSelectionCaretInfo(SelectText* selectTextContainer, pos.getInlineBoxAndOffset(affinity, inlineBox, caretOffset); IntRect caretRect = renderText->localCaretRect(inlineBox, caretOffset); FloatPoint absoluteOffset = renderText->localToAbsolute(caretRect.location()); - caretRect.setX(absoluteOffset.x() - layerOffset.x() + offset); - caretRect.setY(absoluteOffset.y() - layerOffset.y()); - caretRect.move(-frameOffset.x(), -frameOffset.y()); + caretRect.setX(absoluteOffset.x() - offset.x() + caretRectOffset); + caretRect.setY(absoluteOffset.y() - offset.y()); selectTextContainer->setCaretRect(handleId, caretRect); selectTextContainer->setTextRect(handleId, - positionToTextRect(pos, affinity)); + positionToTextRect(pos, affinity, offset)); } bool WebViewCore::isLtr(const Position& position) @@ -1659,12 +1658,13 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection) return selectTextContainer; } -IntRect WebViewCore::positionToTextRect(const Position& position, EAffinity affinity) +IntRect WebViewCore::positionToTextRect(const Position& position, + EAffinity affinity, const WebCore::IntPoint& offset) { IntRect textRect; InlineBox* inlineBox; - int offset; - position.getInlineBoxAndOffset(affinity, inlineBox, offset); + int offsetIndex; + position.getInlineBoxAndOffset(affinity, inlineBox, offsetIndex); if (inlineBox && inlineBox->isInlineTextBox()) { InlineTextBox* box = static_cast<InlineTextBox*>(inlineBox); RootInlineBox* root = box->root(); @@ -1674,12 +1674,6 @@ IntRect WebViewCore::positionToTextRect(const Position& position, EAffinity affi int top = root->selectionTop(); int height = root->selectionHeight(); - Node* node = position.anchorNode(); - LayerAndroid* layer = 0; - int layerId = platformLayerIdFromNode(node, &layer); - IntPoint layerOffset; - layerToAbsoluteOffset(layer, layerOffset); - if (!renderText->style()->isHorizontalWritingMode()) { swap(left, top); swap(width, height); @@ -1687,9 +1681,9 @@ IntRect WebViewCore::positionToTextRect(const Position& position, EAffinity affi FloatPoint origin(left, top); FloatPoint absoluteOrigin = renderText->localToAbsolute(origin); - textRect.setX(absoluteOrigin.x() - layerOffset.x()); + textRect.setX(absoluteOrigin.x() - offset.x()); textRect.setWidth(width); - textRect.setY(absoluteOrigin.y() - layerOffset.y()); + textRect.setY(absoluteOrigin.y() - offset.y()); textRect.setHeight(height); } return textRect; diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index 221b012..7cc3fd6 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -736,7 +736,7 @@ namespace android { WebCore::IntRect absoluteContentRect(WebCore::Node* node, WebCore::LayerAndroid* layer); static WebCore::IntRect positionToTextRect(const WebCore::Position& position, - WebCore::EAffinity affinity); + WebCore::EAffinity affinity, const WebCore::IntPoint& offset); static bool isLtr(const WebCore::Position& position); static WebCore::Position trimSelectionPosition( const WebCore::Position& start, const WebCore::Position& stop); |