diff options
author | Leon Scroggins <scroggo@google.com> | 2010-11-18 13:58:43 -0500 |
---|---|---|
committer | Leon Scroggins <scroggo@google.com> | 2010-11-22 09:37:50 -0500 |
commit | d8fcffded6ee266e903e4e191ed95a07007fac74 (patch) | |
tree | a7a201216f4a8ba715cf2e126e30cf96543a3fe6 /WebKit | |
parent | 0c918ae77b5edfe59b726ff40a7c86dbc4a94307 (diff) | |
download | external_webkit-d8fcffded6ee266e903e4e191ed95a07007fac74.zip external_webkit-d8fcffded6ee266e903e4e191ed95a07007fac74.tar.gz external_webkit-d8fcffded6ee266e903e4e191ed95a07007fac74.tar.bz2 |
Provide the line spacing attribute for textareas.
Bug:3085564
In order to line up the WebTextView text with the page's text,
we need to know the line spacing attribute stored in the DOM.
Requires a change in frameworks/base:
https://android-git.corp.google.com/g/#change,80646
Change-Id: I539454df318826233496ffcd140ba1d6e396a4a0
Diffstat (limited to 'WebKit')
-rw-r--r-- | WebKit/android/nav/CacheBuilder.cpp | 9 | ||||
-rw-r--r-- | WebKit/android/nav/CachedInput.cpp | 1 | ||||
-rw-r--r-- | WebKit/android/nav/CachedInput.h | 5 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 8 |
4 files changed, 21 insertions, 2 deletions
diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index 47c7c70..c631cd4 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -1303,11 +1303,18 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, static_cast<RenderTextControl*>(nodeRenderer); if (isFocus) cachedRoot->setSelection(renderText->selectionStart(), renderText->selectionEnd()); - // FIXME: Would it be better to use (float) size()? // FIXME: Are we sure there will always be a style and font, and it's correct? RenderStyle* style = nodeRenderer->style(); if (style) { isUnclipped |= !style->hasAppearance(); + int lineHeight = -1; + Length lineHeightLength = style->lineHeight(); + // If the lineHeight is negative, WebTextView will calculate it + // based on the text size, using the Paint. + // See RenderStyle.computedLineHeight. + if (lineHeightLength.isPositive()) + lineHeight = style->computedLineHeight(); + cachedInput.setLineHeight(lineHeight); cachedInput.setTextSize(style->font().size()); cachedInput.setIsRtlText(style->direction() == RTL || style->textAlign() == WebCore::RIGHT diff --git a/WebKit/android/nav/CachedInput.cpp b/WebKit/android/nav/CachedInput.cpp index 03a2fba..716abfd 100644 --- a/WebKit/android/nav/CachedInput.cpp +++ b/WebKit/android/nav/CachedInput.cpp @@ -87,6 +87,7 @@ void CachedInput::Debug::print() const DUMP_NAV_LOGD("// int mPaddingRight=%d;\n", b->mPaddingRight); DUMP_NAV_LOGD("// int mPaddingBottom=%d;\n", b->mPaddingBottom); DUMP_NAV_LOGD("// float mTextSize=%f;\n", b->mTextSize); + DUMP_NAV_LOGD("// int mLineHeight=%d;\n", b->mLineHeight); DUMP_NAV_LOGD("// Type mType=%d;\n", b->mType); DEBUG_PRINT_BOOL(mIsRtlText); DEBUG_PRINT_BOOL(mIsTextField); diff --git a/WebKit/android/nav/CachedInput.h b/WebKit/android/nav/CachedInput.h index 4f8777c..8369195 100644 --- a/WebKit/android/nav/CachedInput.h +++ b/WebKit/android/nav/CachedInput.h @@ -58,6 +58,7 @@ public: bool isRtlText() const { return mIsRtlText; } bool isTextField() const { return mIsTextField; } bool isTextArea() const { return mIsTextArea; } + int lineHeight() const { return mLineHeight; } int maxLength() const { return mMaxLength; }; const WTF::String& name() const { return mName; } int paddingBottom() const { return mPaddingBottom; } @@ -68,6 +69,7 @@ public: void setIsRtlText(bool isRtlText) { mIsRtlText = isRtlText; } void setIsTextField(bool isTextField) { mIsTextField = isTextField; } void setIsTextArea(bool isTextArea) { mIsTextArea = isTextArea; } + void setLineHeight(int height) { mLineHeight = height; } void setMaxLength(int maxLength) { mMaxLength = maxLength; } void setName(const WTF::String& name) { mName = name; } void setPaddingBottom(int bottom) { mPaddingBottom = bottom; } @@ -80,8 +82,9 @@ public: private: void* mForm; - WTF::String mName; + int mLineHeight; int mMaxLength; + WTF::String mName; int mPaddingBottom; int mPaddingLeft; int mPaddingRight; diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 8984755..56a1be9 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -1713,6 +1713,12 @@ static jobject nativeFocusCandidateText(JNIEnv *env, jobject obj) return WtfStringToJstring(env, value); } +static int nativeFocusCandidateLineHeight(JNIEnv *env, jobject obj) +{ + const CachedInput* input = getInputCandidate(env, obj); + return input ? input->lineHeight() : 0; +} + static jfloat nativeFocusCandidateTextSize(JNIEnv *env, jobject obj) { const CachedInput* input = getInputCandidate(env, obj); @@ -2264,6 +2270,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeFocusCandidateIsRtlText }, { "nativeFocusCandidateIsTextInput", "()Z", (void*) nativeFocusCandidateIsTextInput }, + { "nativeFocusCandidateLineHeight", "()I", + (void*) nativeFocusCandidateLineHeight }, { "nativeFocusCandidateMaxLength", "()I", (void*) nativeFocusCandidateMaxLength }, { "nativeFocusCandidateName", "()Ljava/lang/String;", |