diff options
| author | Leon Scroggins <scroggo@google.com> | 2010-10-12 14:01:13 -0400 |
|---|---|---|
| committer | Leon Scroggins <scroggo@google.com> | 2010-10-12 16:29:02 -0400 |
| commit | 390c2b5702d131f0875199fdca1c3ba5010d7659 (patch) | |
| tree | caccb3553d5521ec944f3244b57b64a1394256c3 /WebKit | |
| parent | 3f8366e53853027e7e11d4a40a1ad3f7a1ff5a65 (diff) | |
| download | external_webkit-390c2b5702d131f0875199fdca1c3ba5010d7659.zip external_webkit-390c2b5702d131f0875199fdca1c3ba5010d7659.tar.gz external_webkit-390c2b5702d131f0875199fdca1c3ba5010d7659.tar.bz2 | |
Provide padding + border values for textfields.
Bug:3085564
They are used by WebView.java to align the WebTextView's
text positioning with the page below. This allows the
selection and insertion arrow handlers to line up better
with the actual selection on the page.
Requires a change in frameworks/base:
https://android-git.corp.google.com/g/#change,73565
Change-Id: Ia100286016a780abd5f30e32975f8ad566a6ed74
Diffstat (limited to 'WebKit')
| -rw-r--r-- | WebKit/android/nav/CacheBuilder.cpp | 4 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedInput.cpp | 4 | ||||
| -rw-r--r-- | WebKit/android/nav/CachedInput.h | 16 | ||||
| -rw-r--r-- | WebKit/android/nav/WebView.cpp | 27 |
4 files changed, 44 insertions, 7 deletions
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index 214058c..f69b23d 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -1232,6 +1232,10 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, || style->textAlign() == WebCore::RIGHT || style->textAlign() == WebCore::WEBKIT_RIGHT); } + cachedInput.setPaddingLeft(renderText->paddingLeft() + renderText->borderLeft()); + cachedInput.setPaddingTop(renderText->paddingTop() + renderText->borderTop()); + cachedInput.setPaddingRight(renderText->paddingRight() + renderText->borderRight()); + cachedInput.setPaddingBottom(renderText->paddingBottom() + renderText->borderBottom()); } takesFocus = true; bounds = absBounds; diff --git a/WebKit/android/nav/CachedInput.cpp b/WebKit/android/nav/CachedInput.cpp index 924bbca..cba5820 100644 --- a/WebKit/android/nav/CachedInput.cpp +++ b/WebKit/android/nav/CachedInput.cpp @@ -59,6 +59,10 @@ void CachedInput::Debug::print() const DUMP_NAV_LOGD("// int mMaxLength=%d;\n", b->mMaxLength); DUMP_NAV_LOGD("// int mTextSize=%d;\n", b->mTextSize); DUMP_NAV_LOGD("// int mInputType=%d;\n", b->mInputType); + DUMP_NAV_LOGD("// int mPaddingLeft=%d;\n", b->mPaddingLeft); + DUMP_NAV_LOGD("// int mPaddingTop=%d;\n", b->mPaddingTop); + DUMP_NAV_LOGD("// int mPaddingRight=%d;\n", b->mPaddingRight); + DUMP_NAV_LOGD("// int mPaddingBottom=%d;\n", b->mPaddingBottom); DEBUG_PRINT_BOOL(mIsRtlText); DEBUG_PRINT_BOOL(mIsTextField); } diff --git a/WebKit/android/nav/CachedInput.h b/WebKit/android/nav/CachedInput.h index 42cadf1..01b40f9 100644 --- a/WebKit/android/nav/CachedInput.h +++ b/WebKit/android/nav/CachedInput.h @@ -48,20 +48,32 @@ public: bool isTextField() const { return mIsTextField; } int maxLength() const { return mMaxLength; }; const WebCore::String& name() const { return mName; } + int paddingBottom() const { return mPaddingBottom; } + int paddingLeft() const { return mPaddingLeft; } + int paddingRight() const { return mPaddingRight; } + int paddingTop() const { return mPaddingTop; } void setFormPointer(void* form) { mForm = form; } void setInputType(WebCore::HTMLInputElement::InputType type) { mInputType = type; } void setIsRtlText(bool isRtlText) { mIsRtlText = isRtlText; } void setIsTextField(bool isTextField) { mIsTextField = isTextField; } void setMaxLength(int maxLength) { mMaxLength = maxLength; } void setName(const WebCore::String& name) { mName = name; } + void setPaddingBottom(int bottom) { mPaddingBottom = bottom; } + void setPaddingLeft(int left) { mPaddingLeft = left; } + void setPaddingRight(int right) { mPaddingRight = right; } + void setPaddingTop(int top) { mPaddingTop = top; } void setTextSize(int textSize) { mTextSize = textSize; } int textSize() const { return mTextSize; } private: void* mForm; - WebCore::String mName; + WebCore::HTMLInputElement::InputType mInputType; int mMaxLength; + WebCore::String mName; + int mPaddingBottom; + int mPaddingLeft; + int mPaddingRight; + int mPaddingTop; int mTextSize; - WebCore::HTMLInputElement::InputType mInputType; bool mIsRtlText : 1; bool mIsTextField : 1; #if DUMP_NAV_CACHE diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 3dafaff..913c4ba 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -1501,17 +1501,32 @@ static jobject nativeFocusCandidateName(JNIEnv *env, jobject obj) return env->NewString((jchar*)name.characters(), name.length()); } +static jobject createJavaRect(JNIEnv* env, int x, int y, int right, int bottom) +{ + jclass rectClass = env->FindClass("android/graphics/Rect"); + jmethodID init = env->GetMethodID(rectClass, "<init>", "(IIII)V"); + jobject rect = env->NewObject(rectClass, init, x, y, right, bottom); + return rect; +} + static jobject nativeFocusCandidateNodeBounds(JNIEnv *env, jobject obj) { const CachedFrame* frame; const CachedNode* node = getFocusCandidate(env, obj, &frame); WebCore::IntRect bounds = node ? node->bounds(frame) : WebCore::IntRect(0, 0, 0, 0); - jclass rectClass = env->FindClass("android/graphics/Rect"); - jmethodID init = env->GetMethodID(rectClass, "<init>", "(IIII)V"); - jobject rect = env->NewObject(rectClass, init, bounds.x(), - bounds.y(), bounds.right(), bounds.bottom()); - return rect; + return createJavaRect(env, bounds.x(), bounds.y(), bounds.right(), bounds.bottom()); +} + +static jobject nativeFocusCandidatePaddingRect(JNIEnv *env, jobject obj) +{ + const CachedInput* input = getInputCandidate(env, obj); + if (!input) + return 0; + // Note that the Java Rect is being used to pass four integers, rather than + // being used as an actual rectangle. + return createJavaRect(env, input->paddingLeft(), input->paddingTop(), + input->paddingRight(), input->paddingBottom()); } static jint nativeFocusCandidatePointer(JNIEnv *env, jobject obj) @@ -2064,6 +2079,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeFocusCandidateName }, { "nativeFocusCandidateNodeBounds", "()Landroid/graphics/Rect;", (void*) nativeFocusCandidateNodeBounds }, + { "nativeFocusCandidatePaddingRect", "()Landroid/graphics/Rect;", + (void*) nativeFocusCandidatePaddingRect }, { "nativeFocusCandidatePointer", "()I", (void*) nativeFocusCandidatePointer }, { "nativeFocusCandidateText", "()Ljava/lang/String;", |
