summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2012-04-10 13:14:40 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-04-10 13:14:40 -0700
commiteb4152454774fa6e38c8be1a2810bc893d494de3 (patch)
tree55aaa0e459cd11b62736ca07d0453c742227c166 /Source
parent76a09fb547aa97b2f0e9cbb1e4a800d61b30a477 (diff)
downloadexternal_webkit-eb4152454774fa6e38c8be1a2810bc893d494de3.zip
external_webkit-eb4152454774fa6e38c8be1a2810bc893d494de3.tar.gz
external_webkit-eb4152454774fa6e38c8be1a2810bc893d494de3.tar.bz2
Revert "Keep selection handles in edit fields."
This reverts commit 76a09fb547aa97b2f0e9cbb1e4a800d61b30a477
Diffstat (limited to 'Source')
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp50
-rw-r--r--Source/WebKit/android/jni/WebViewCore.h9
-rw-r--r--Source/WebKit/android/nav/WebView.cpp4
3 files changed, 28 insertions, 35 deletions
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 558f424..a4cd94f 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -397,7 +397,7 @@ struct WebViewCore::TextFieldInitDataGlue {
jfieldID m_name;
jfieldID m_label;
jfieldID m_maxLength;
- jfieldID m_contentBounds;
+ jfieldID m_nodeBounds;
jfieldID m_nodeLayerId;
jfieldID m_contentRect;
};
@@ -523,7 +523,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_textFieldInitDataGlue->m_name = env->GetFieldID(tfidClazz, "mName", "Ljava/lang/String;");
m_textFieldInitDataGlue->m_label = env->GetFieldID(tfidClazz, "mLabel", "Ljava/lang/String;");
m_textFieldInitDataGlue->m_maxLength = env->GetFieldID(tfidClazz, "mMaxLength", "I");
- m_textFieldInitDataGlue->m_contentBounds = env->GetFieldID(tfidClazz, "mContentBounds", "Landroid/graphics/Rect;");
+ m_textFieldInitDataGlue->m_nodeBounds = env->GetFieldID(tfidClazz, "mNodeBounds", "Landroid/graphics/Rect;");
m_textFieldInitDataGlue->m_nodeLayerId = env->GetFieldID(tfidClazz, "mNodeLayerId", "I");
m_textFieldInitDataGlue->m_contentRect = env->GetFieldID(tfidClazz, "mContentRect", "Landroid/graphics/Rect;");
m_textFieldInitDataGlue->m_constructor = GetJMethod(env, tfidClazz, "<init>", "()V");
@@ -1649,7 +1649,7 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection)
RenderText* renderText = toRenderText(r);
int caretOffset;
InlineBox* inlineBox;
- start.getInlineBoxAndOffset(selection.affinity(), inlineBox, caretOffset);
+ start.getInlineBoxAndOffset(DOWNSTREAM, inlineBox, caretOffset);
startHandle = renderText->localCaretRect(inlineBox, caretOffset);
FloatPoint absoluteOffset = renderText->localToAbsolute(startHandle.location());
startHandle.setX(absoluteOffset.x() - layerOffset.x());
@@ -1698,19 +1698,19 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection)
selectTextContainer->setText(range->text());
selectTextContainer->setTextRect(SelectText::StartHandle,
- positionToTextRect(selection.start(), selection.affinity()));
+ positionToTextRect(selection.start()));
selectTextContainer->setTextRect(SelectText::EndHandle,
- positionToTextRect(selection.end(), selection.affinity()));
+ positionToTextRect(selection.end()));
return selectTextContainer;
}
-IntRect WebViewCore::positionToTextRect(const Position& position, EAffinity affinity)
+IntRect WebViewCore::positionToTextRect(const Position& position)
{
IntRect textRect;
InlineBox* inlineBox;
int offset;
- position.getInlineBoxAndOffset(affinity, inlineBox, offset);
+ position.getInlineBoxAndOffset(VP_DEFAULT_AFFINITY, inlineBox, offset);
if (inlineBox && inlineBox->isInlineTextBox()) {
InlineTextBox* box = static_cast<InlineTextBox*>(inlineBox);
RootInlineBox* root = box->root();
@@ -2960,17 +2960,17 @@ void WebViewCore::passToJs(int generation, const WTF::String& current,
updateTextSelection();
}
-WebCore::IntRect WebViewCore::scrollFocusedTextInput(float xPercent, int y)
+void WebViewCore::scrollFocusedTextInput(float xPercent, int y)
{
WebCore::Node* focus = currentFocus();
if (!focus) {
clearTextEntry();
- return WebCore::IntRect();
+ return;
}
WebCore::RenderTextControl* renderText = toRenderTextControl(focus);
if (!renderText) {
clearTextEntry();
- return WebCore::IntRect();
+ return;
}
int x = (int) (xPercent * (renderText->scrollWidth() -
@@ -2978,9 +2978,6 @@ WebCore::IntRect WebViewCore::scrollFocusedTextInput(float xPercent, int y)
renderText->setScrollLeft(x);
renderText->setScrollTop(y);
focus->document()->frame()->selection()->recomputeCaretRect();
- LayerAndroid* layer = 0;
- platformLayerIdFromNode(focus, &layer);
- return absoluteContentRect(focus, layer);
}
void WebViewCore::setFocusControllerActive(bool active)
@@ -3410,23 +3407,22 @@ bool WebViewCore::isAutoCompleteEnabled(Node* node)
return isEnabled;
}
-WebCore::IntRect WebViewCore::absoluteContentRect(WebCore::Node* node,
+WebCore::IntRect WebViewCore::boundingRect(WebCore::Node* node,
LayerAndroid* layer)
{
- IntRect contentRect;
+ // Caret selection
+ IntRect boundingRect;
if (node) {
RenderObject* render = node->renderer();
- if (render && render->isBox() && !render->isBody()) {
+ if (render && !render->isBody()) {
IntPoint offset = convertGlobalContentToFrameContent(IntPoint(),
node->document()->frame());
WebViewCore::layerToAbsoluteOffset(layer, offset);
-
- RenderBox* renderBox = toRenderBox(render);
- contentRect = renderBox->absoluteContentBox();
- contentRect.move(-offset.x(), -offset.y());
+ boundingRect = render->absoluteBoundingBoxRect(true);
+ boundingRect.move(-offset.x(), -offset.y());
}
}
- return contentRect;
+ return boundingRect;
}
jobject WebViewCore::createTextFieldInitData(Node* node)
@@ -3459,8 +3455,8 @@ jobject WebViewCore::createTextFieldInitData(Node* node)
env->SetIntField(initData, classDef->m_maxLength, getMaxLength(node));
LayerAndroid* layer = 0;
int layerId = platformLayerIdFromNode(node, &layer);
- IntRect bounds = absoluteContentRect(node, layer);
- env->SetObjectField(initData, classDef->m_contentBounds,
+ IntRect bounds = boundingRect(node, layer);
+ env->SetObjectField(initData, classDef->m_nodeBounds,
intRectToRect(env, bounds));
env->SetIntField(initData, classDef->m_nodeLayerId, layerId);
IntRect contentRect;
@@ -4542,12 +4538,10 @@ static void PassToJs(JNIEnv* env, jobject obj, jint nativeClass,
}
static void ScrollFocusedTextInput(JNIEnv* env, jobject obj, jint nativeClass,
- jfloat xPercent, jint y, jobject contentBounds)
+ jfloat xPercent, jint y)
{
WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass);
- IntRect bounds = viewImpl->scrollFocusedTextInput(xPercent, y);
- if (contentBounds)
- GraphicsJNI::irect_to_jrect(bounds, env, contentBounds);
+ viewImpl->scrollFocusedTextInput(xPercent, y);
}
static void SetFocusControllerActive(JNIEnv* env, jobject obj, jint nativeClass,
@@ -5103,7 +5097,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
(void*) MoveMouse },
{ "passToJs", "(IILjava/lang/String;IIZZZZ)V",
(void*) PassToJs },
- { "nativeScrollFocusedTextInput", "(IFILandroid/graphics/Rect;)V",
+ { "nativeScrollFocusedTextInput", "(IFI)V",
(void*) ScrollFocusedTextInput },
{ "nativeSetFocusControllerActive", "(IZ)V",
(void*) SetFocusControllerActive },
diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h
index d3f0e18..5e2bafb 100644
--- a/Source/WebKit/android/jni/WebViewCore.h
+++ b/Source/WebKit/android/jni/WebViewCore.h
@@ -410,7 +410,7 @@ namespace android {
/**
* Scroll the focused textfield to (x, y) in document space
*/
- WebCore::IntRect scrollFocusedTextInput(float x, int y);
+ void scrollFocusedTextInput(float x, int y);
/**
* Set the FocusController's active and focused states, so that
* the caret will draw (true) or not.
@@ -748,10 +748,9 @@ namespace android {
static int getMaxLength(WebCore::Node* node);
static WTF::String getFieldName(WebCore::Node* node);
static bool isAutoCompleteEnabled(WebCore::Node* node);
- WebCore::IntRect absoluteContentRect(WebCore::Node* node,
- WebCore::LayerAndroid* layer);
- static WebCore::IntRect positionToTextRect(const WebCore::Position& position,
- WebCore::EAffinity affinity);
+ WebCore::IntRect boundingRect(WebCore::Node* node,
+ WebCore::LayerAndroid* layer);
+ static WebCore::IntRect positionToTextRect(const WebCore::Position& position);
// called from constructor, to add this to a global list
static void addInstance(WebViewCore*);
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index 3bd0bdc..a4381e6 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -602,8 +602,8 @@ int getHandleLayerId(SelectText::HandleId handleId, SkIPoint& cursorPoint,
IntRect textRect = selectText->textRect(handleId);
// Rects exclude the last pixel on right/bottom. We want only included pixels.
cursorPoint.set(cursorRect.x(), cursorRect.maxY() - 1);
- textRect.setHeight(std::max(1, textRect.height() - 1));
- textRect.setWidth(std::max(1, textRect.width() - 1));
+ textRect.setHeight(textRect.height() - 1);
+ textRect.setWidth(textRect.width() - 1);
textBounds = FloatQuad(textRect);
if (layerId != -1) {