diff options
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | Source/WebCore/page/FrameView.cpp | 5 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/BaseTile.cpp | 10 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/BaseTile.h | 6 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/FontAndroid.cpp | 43 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/PaintTileOperation.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/PaintTileOperation.h | 4 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/TiledPage.cpp | 4 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/TiledTexture.cpp | 2 | ||||
-rw-r--r-- | Source/WebCore/rendering/RenderFrame.cpp | 16 | ||||
-rw-r--r-- | Source/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp | 18 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 139 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.h | 9 |
13 files changed, 187 insertions, 72 deletions
@@ -285,6 +285,7 @@ LOCAL_SHARED_LIBRARIES := \ libicuuc \ libicui18n \ libmedia \ + libmedia_native \ libnativehelper \ libskia \ libsqlite \ diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp index f332074..8f2958c 100644 --- a/Source/WebCore/page/FrameView.cpp +++ b/Source/WebCore/page/FrameView.cpp @@ -1745,6 +1745,11 @@ void FrameView::scheduleRelayout() m_frame->ownerRenderer()->setNeedsLayout(true, true); } +#ifdef ANDROID_FLATTEN_FRAMESET + if (m_frame->ownerRenderer() && m_frame->ownerElement()->hasTagName(frameTag)) + m_frame->ownerRenderer()->setNeedsLayoutAndPrefWidthsRecalc(); +#endif + int delay = m_frame->document()->minimumLayoutDelay(); if (m_layoutTimer.isActive() && m_delayedLayout && !delay) unscheduleRelayout(); diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp index b5c0f0a..d15feeb 100644 --- a/Source/WebCore/platform/graphics/android/BaseTile.cpp +++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp @@ -48,7 +48,6 @@ namespace WebCore { BaseTile::BaseTile(bool isLayerTile) : m_glWebViewState(0) - , m_painter(0) , m_x(-1) , m_y(-1) , m_page(0) @@ -85,11 +84,10 @@ BaseTile::~BaseTile() // All the following functions must be called from the main GL thread. -void BaseTile::setContents(TilePainter* painter, int x, int y, float scale) +void BaseTile::setContents(int x, int y, float scale) { // TODO: investigate whether below check/discard is necessary - if (!painter - || (m_x != x) + if ((m_x != x) || (m_y != y) || (m_scale != scale)) { // neither texture is relevant @@ -97,7 +95,6 @@ void BaseTile::setContents(TilePainter* painter, int x, int y, float scale) } android::AutoMutex lock(m_atomicSync); - m_painter = painter; m_x = x; m_y = y; m_scale = scale; @@ -288,7 +285,7 @@ bool BaseTile::isTileVisible(const IntRect& viewTileBounds) } // This is called from the texture generation thread -void BaseTile::paintBitmap() +void BaseTile::paintBitmap(TilePainter* painter) { // We acquire the values below atomically. This ensures that we are reading // values correctly across cores. Further, once we have these values they @@ -300,7 +297,6 @@ void BaseTile::paintBitmap() float scale = m_scale; const int x = m_x; const int y = m_y; - TilePainter* painter = m_painter; if (!dirty || !texture) { m_atomicSync.unlock(); diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h index f02386b..ab16dc9 100644 --- a/Source/WebCore/platform/graphics/android/BaseTile.h +++ b/Source/WebCore/platform/graphics/android/BaseTile.h @@ -94,7 +94,7 @@ public: bool isLayerTile() { return m_isLayerTile; } - void setContents(TilePainter* painter, int x, int y, float scale); + void setContents(int x, int y, float scale); void setPage(TiledPage* page) { m_page = page; } void reserveTexture(); @@ -105,7 +105,7 @@ public: const TransformationMatrix* transform); // the only thread-safe function called by the background thread - void paintBitmap(); + void paintBitmap(TilePainter* painter); bool intersectWithRect(int x, int y, int tileWidth, int tileHeight, float scale, const SkRect& dirtyRect, @@ -138,14 +138,12 @@ public: virtual bool removeTexture(BaseTileTexture* texture); virtual TiledPage* page() { return m_page; } virtual GLWebViewState* state() { return m_glWebViewState; } - TilePainter* painter() { return m_painter; } private: void validatePaint(); GLWebViewState* m_glWebViewState; - TilePainter* m_painter; int m_x; int m_y; diff --git a/Source/WebCore/platform/graphics/android/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/FontAndroid.cpp index ef7740c..c8b9488 100644 --- a/Source/WebCore/platform/graphics/android/FontAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/FontAndroid.cpp @@ -88,6 +88,8 @@ static bool setupForText(SkPaint* paint, GraphicsContext* gc, if (!mode) return false; + paint->setVerticalText(font->platformData().orientation() == Vertical); + FloatSize shadowOffset; float shadowBlur; Color shadowColor; @@ -193,8 +195,6 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, const GlyphBufferAdvance* adv = glyphBuffer.advances(from); SkAutoSTMalloc<32, SkPoint> storage(numGlyphs), storage2(numGlyphs), storage3(numGlyphs); SkPoint* pos = storage.get(); - SkPoint* vPosBegin = storage2.get(); - SkPoint* vPosEnd = storage3.get(); SkCanvas* canvas = gc->platformContext()->mCanvas; @@ -202,6 +202,9 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, point.xy + [width, height, width, height, ...], so we have to convert */ + if (font->platformData().orientation() == Vertical) + y += SkFloatToScalar(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent()); + if (EmojiFont::IsAvailable()) { // set filtering, to make scaled images look nice(r) paint.setFilterBitmap(true); @@ -231,27 +234,25 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, localCount * sizeof(uint16_t), &pos[localIndex], paint); } else { - bool isVertical = font->platformData().orientation() == Vertical; for (int i = 0; i < numGlyphs; i++) { pos[i].set(x, y); y += SkFloatToScalar(adv[i].height()); - if (isVertical) { - SkScalar myWidth = SkFloatToScalar(adv[i].width()); - vPosBegin[i].set(x + myWidth, y); - vPosEnd[i].set(x + myWidth, y - myWidth); - x += myWidth; - - SkPath path; - path.reset(); - path.moveTo(vPosBegin[i]); - path.lineTo(vPosEnd[i]); - canvas->drawTextOnPath(glyphs + i, 2, path, 0, paint); - } - else - x += SkFloatToScalar(adv[i].width()); + x += SkFloatToScalar(adv[i].width()); } - if (!isVertical) - canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint); + + if (font->platformData().orientation() == Vertical) { + canvas->save(); + canvas->rotate(-90); + SkMatrix rotator; + rotator.reset(); + rotator.setRotate(90); + rotator.mapPoints(pos, numGlyphs); + } + + canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint); + + if (font->platformData().orientation() == Vertical) + canvas->restore(); } } @@ -1003,14 +1004,14 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run, int glyph = walker.logClusters()[from]; fromX = base + walker.positions()[glyph].x(); fromAdvance = walker.advances()[glyph]; - } else + } else if (!walker.rtl()) from -= numCodePoints; if (toX == -1 && to < numCodePoints) { int glyph = walker.logClusters()[to]; toX = base + walker.positions()[glyph].x(); toAdvance = walker.advances()[glyph]; - } else + } else if (!walker.rtl()) to -= numCodePoints; if (!walker.rtl()) diff --git a/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp b/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp index a79298c..1fcb765 100644 --- a/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp +++ b/Source/WebCore/platform/graphics/android/PaintTileOperation.cpp @@ -67,7 +67,7 @@ bool PaintTileOperation::operator==(const QueuedOperation* operation) void PaintTileOperation::run() { if (m_tile) { - m_tile->paintBitmap(); + m_tile->paintBitmap(m_painter); m_tile->setRepaintPending(false); m_tile = 0; } diff --git a/Source/WebCore/platform/graphics/android/PaintTileOperation.h b/Source/WebCore/platform/graphics/android/PaintTileOperation.h index 4e98287..05825e2 100644 --- a/Source/WebCore/platform/graphics/android/PaintTileOperation.h +++ b/Source/WebCore/platform/graphics/android/PaintTileOperation.h @@ -38,13 +38,13 @@ class ImageTexture; class PaintTileOperation : public QueuedOperation { public: - PaintTileOperation(BaseTile* tile, TilePainter* painter = 0); + PaintTileOperation(BaseTile* tile, TilePainter* painter); virtual ~PaintTileOperation(); virtual bool operator==(const QueuedOperation* operation); virtual void run(); // returns a rendering priority for m_tile, lower values are processed faster virtual int priority(); - TilePainter* painter() { return m_tile->painter(); } + TilePainter* painter() { return m_painter; } float scale() { return m_tile->scale(); } private: diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index df740e7..afa2014 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -171,7 +171,7 @@ void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y currentTile->setGLWebViewState(m_glWebViewState); currentTile->setPage(this); - currentTile->setContents(this, x, y, m_scale); + currentTile->setContents(x, y, m_scale); // TODO: move below (which is largely the same for layers / tiled // page) into prepare() function @@ -183,7 +183,7 @@ void TiledPage::prepareRow(bool goingLeft, int tilesInRow, int firstTileX, int y if (currentTile->backTexture() && currentTile->isDirty() && !currentTile->isRepaintPending()) { - PaintTileOperation *operation = new PaintTileOperation(currentTile); + PaintTileOperation *operation = new PaintTileOperation(currentTile, this); TilesManager::instance()->scheduleOperation(operation); } } diff --git a/Source/WebCore/platform/graphics/android/TiledTexture.cpp b/Source/WebCore/platform/graphics/android/TiledTexture.cpp index 9ce6f6d..039e28c 100644 --- a/Source/WebCore/platform/graphics/android/TiledTexture.cpp +++ b/Source/WebCore/platform/graphics/android/TiledTexture.cpp @@ -168,7 +168,7 @@ void TiledTexture::prepareTile(int x, int y, TilePainter* painter) } ALOGV("preparing tile %p at %d, %d, painter is %p", tile, x, y, painter); - tile->setContents(painter, x, y, m_scale); + tile->setContents(x, y, m_scale); // TODO: move below (which is largely the same for layers / tiled page) into // prepareGL() function diff --git a/Source/WebCore/rendering/RenderFrame.cpp b/Source/WebCore/rendering/RenderFrame.cpp index 4b1444b..0ae6eda 100644 --- a/Source/WebCore/rendering/RenderFrame.cpp +++ b/Source/WebCore/rendering/RenderFrame.cpp @@ -64,7 +64,12 @@ void RenderFrame::layout() { FrameView* view = static_cast<FrameView*>(widget()); RenderView* root = view ? view->frame()->contentRenderer() : 0; + + // Do not expand frames which has zero width or height if (!width() || !height() || !root) { + updateWidgetPosition(); + if (view) + view->layout(); setNeedsLayout(false); return; } @@ -75,14 +80,17 @@ void RenderFrame::layout() return; } - int layoutWidth = width(); + // Update the dimensions to get the correct width and height + updateWidgetPosition(); + if (root->preferredLogicalWidthsDirty()) + root->computePreferredLogicalWidths(); + // Expand the frame by setting frame height = content height setWidth(max(view->contentsWidth() + borderAndPaddingWidth(), width())); setHeight(max(view->contentsHeight() + borderAndPaddingHeight(), height())); - // Trigger a layout of the FrameView which will schedule a relayout of this RenderFrame. - if (layoutWidth < width()) - view->layout(); + // Update one more time + updateWidgetPosition(); setNeedsLayout(false); } diff --git a/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp index 785f0a8..042c227 100644 --- a/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/EditorClientAndroid.cpp @@ -228,8 +228,22 @@ void EditorClientAndroid::checkGrammarOfString(unsigned short const*, int, WTF:: void EditorClientAndroid::checkSpellingOfString(unsigned short const*, int, int*, int*) {} String EditorClientAndroid::getAutoCorrectSuggestionForMisspelledWord(const String&) { return String(); } void EditorClientAndroid::textFieldDidEndEditing(Element*) {} -void EditorClientAndroid::textDidChangeInTextArea(Element*) {} -void EditorClientAndroid::textDidChangeInTextField(Element*) {} +void EditorClientAndroid::textDidChangeInTextArea(Element* element) +{ + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame || !frame->view()) + return; + WebViewCore* webViewCore = WebViewCore::getWebViewCore(frame->view()); + webViewCore->updateTextSizeAndScroll(element); +} +void EditorClientAndroid::textDidChangeInTextField(Element* element) +{ + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + if (!frame || !frame->view()) + return; + WebViewCore* webViewCore = WebViewCore::getWebViewCore(frame->view()); + webViewCore->updateTextSizeAndScroll(element); +} void EditorClientAndroid::textFieldDidBeginEditing(Element*) {} void EditorClientAndroid::ignoreWordInSpellDocument(String const&) {} diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 14077eb..9aaec25 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -337,6 +337,7 @@ struct WebViewCore::JavaGlue { jmethodID m_sendViewInvalidate; jmethodID m_updateTextfield; jmethodID m_updateTextSelection; + jmethodID m_updateTextSizeAndScroll; jmethodID m_clearTextEntry; jmethodID m_restoreScale; jmethodID m_needTouchEvents; @@ -384,6 +385,23 @@ struct WebViewCore::JavaGlue { } }; +struct WebViewCore::TextFieldInitDataGlue { + jmethodID m_constructor; + jfieldID m_fieldPointer; + jfieldID m_text; + jfieldID m_type; + jfieldID m_isSpellCheckEnabled; + jfieldID m_isTextFieldNext; + jfieldID m_isTextFieldPrev; + jfieldID m_isAutoCompleteEnabled; + jfieldID m_name; + jfieldID m_label; + jfieldID m_maxLength; + jfieldID m_nodeBounds; + jfieldID m_nodeLayerId; + jfieldID m_contentRect; +}; + /* * WebViewCore Implementation */ @@ -399,6 +417,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m : m_touchGeneration(0) , m_lastGeneration(0) , m_javaGlue(new JavaGlue) + , m_textFieldInitDataGlue(new TextFieldInitDataGlue) , m_mainFrame(mainframe) , m_popupReply(0) , m_blurringNodePointer(0) @@ -453,6 +472,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_sendViewInvalidate = GetJMethod(env, clazz, "sendViewInvalidate", "(IIII)V"); m_javaGlue->m_updateTextfield = GetJMethod(env, clazz, "updateTextfield", "(IZLjava/lang/String;I)V"); m_javaGlue->m_updateTextSelection = GetJMethod(env, clazz, "updateTextSelection", "(IIIII)V"); + m_javaGlue->m_updateTextSizeAndScroll = GetJMethod(env, clazz, "updateTextSizeAndScroll", "(IIIII)V"); m_javaGlue->m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V"); m_javaGlue->m_restoreScale = GetJMethod(env, clazz, "restoreScale", "(FF)V"); m_javaGlue->m_needTouchEvents = GetJMethod(env, clazz, "needTouchEvents", "(Z)V"); @@ -486,7 +506,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m #endif m_javaGlue->m_setWebTextViewAutoFillable = GetJMethod(env, clazz, "setWebTextViewAutoFillable", "(ILjava/lang/String;)V"); m_javaGlue->m_selectAt = GetJMethod(env, clazz, "selectAt", "(II)V"); - m_javaGlue->m_initEditField = GetJMethod(env, clazz, "initEditField", "(ILjava/lang/String;IZZZZLjava/lang/String;Ljava/lang/String;IIIILandroid/graphics/Rect;I)V"); + m_javaGlue->m_initEditField = GetJMethod(env, clazz, "initEditField", "(IIILandroid/webkit/WebViewCore$TextFieldInitData;)V"); m_javaGlue->m_updateMatchCount = GetJMethod(env, clazz, "updateMatchCount", "(IILjava/lang/String;)V"); m_javaGlue->m_chromeCanTakeFocus = GetJMethod(env, clazz, "chromeCanTakeFocus", "(I)Z"); m_javaGlue->m_chromeTakeFocus = GetJMethod(env, clazz, "chromeTakeFocus", "(I)V"); @@ -494,6 +514,23 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this); + jclass tfidClazz = env->FindClass("android/webkit/WebViewCore$TextFieldInitData"); + m_textFieldInitDataGlue->m_fieldPointer = env->GetFieldID(tfidClazz, "mFieldPointer", "I"); + m_textFieldInitDataGlue->m_text = env->GetFieldID(tfidClazz, "mText", "Ljava/lang/String;"); + m_textFieldInitDataGlue->m_type = env->GetFieldID(tfidClazz, "mType", "I"); + m_textFieldInitDataGlue->m_isSpellCheckEnabled = env->GetFieldID(tfidClazz, "mIsSpellCheckEnabled", "Z"); + m_textFieldInitDataGlue->m_isTextFieldNext = env->GetFieldID(tfidClazz, "mIsTextFieldNext", "Z"); + m_textFieldInitDataGlue->m_isTextFieldPrev = env->GetFieldID(tfidClazz, "mIsTextFieldPrev", "Z"); + m_textFieldInitDataGlue->m_isAutoCompleteEnabled = env->GetFieldID(tfidClazz, "mIsAutoCompleteEnabled", "Z"); + 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_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"); + env->DeleteLocalRef(tfidClazz); + PageGroup::setShouldTrackVisitedLinks(true); clearContent(); @@ -2864,6 +2901,7 @@ void WebViewCore::scrollFocusedTextInput(float xPercent, int y) renderText->clientWidth())); renderText->setScrollLeft(x); renderText->setScrollTop(y); + focus->document()->frame()->selection()->recomputeCaretRect(); } void WebViewCore::setFocusControllerActive(bool active) @@ -3311,40 +3349,66 @@ WebCore::IntRect WebViewCore::boundingRect(WebCore::Node* node, return boundingRect; } -void WebViewCore::initEditField(Node* node) +jobject WebViewCore::createTextFieldInitData(Node* node) { - String text = getInputText(node); - int start = 0; - int end = 0; - getSelectionOffsets(node, start, end); JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject javaObject = m_javaGlue->object(env); - if (!javaObject.get()) - return; - m_textGeneration = 0; - InputType inputType = getInputType(node); + TextFieldInitDataGlue* classDef = m_textFieldInitDataGlue; + jclass clazz = env->FindClass("android/webkit/WebViewCore$TextFieldInitData"); + jobject initData = env->NewObject(clazz, classDef->m_constructor); + env->SetIntField(initData, classDef->m_fieldPointer, + reinterpret_cast<int>(node)); + env->SetObjectField(initData, classDef->m_text, + wtfStringToJstring(env, getInputText(node), true)); + env->SetIntField(initData, classDef->m_type, getInputType(node)); + env->SetBooleanField(initData, classDef->m_isSpellCheckEnabled, + isSpellCheckEnabled(node)); Document* document = node->document(); PlatformKeyboardEvent tab(AKEYCODE_TAB, 0, 0, false, false, false, false); PassRefPtr<KeyboardEvent> tabEvent = KeyboardEvent::create(tab, document->defaultView()); - bool isNextText = isTextInput(document->nextFocusableNode(node, tabEvent.get())); - bool isPrevText = isTextInput(document->previousFocusableNode(node, tabEvent.get())); - bool spellCheckEnabled = isSpellCheckEnabled(node); - int maxLength = getMaxLength(node); - String label = requestLabel(document->frame(), node); - bool autoComplete = isAutoCompleteEnabled(node); - jstring name = wtfStringToJstring(env, getFieldName(node), false); - jstring fieldText = wtfStringToJstring(env, text, true); - jstring labelText = wtfStringToJstring(env, text, false); + env->SetBooleanField(initData, classDef->m_isTextFieldNext, + isTextInput(document->nextFocusableNode(node, tabEvent.get()))); + env->SetBooleanField(initData, classDef->m_isTextFieldPrev, + isTextInput(document->previousFocusableNode(node, tabEvent.get()))); + env->SetBooleanField(initData, classDef->m_isAutoCompleteEnabled, + isAutoCompleteEnabled(node)); + env->SetObjectField(initData, classDef->m_name, + wtfStringToJstring(env, getFieldName(node), false)); + env->SetObjectField(initData, classDef->m_name, + wtfStringToJstring(env, requestLabel(document->frame(), node), false)); + env->SetIntField(initData, classDef->m_maxLength, getMaxLength(node)); LayerAndroid* layer = 0; int layerId = platformLayerIdFromNode(node, &layer); - jobject nodeBounds = intRectToRect(env, boundingRect(node, layer)); + IntRect bounds = boundingRect(node, layer); + env->SetObjectField(initData, classDef->m_nodeBounds, + intRectToRect(env, bounds)); + env->SetIntField(initData, classDef->m_nodeLayerId, layerId); + IntRect contentRect; + RenderTextControl* rtc = toRenderTextControl(node); + if (rtc) { + contentRect.setWidth(rtc->scrollWidth()); + contentRect.setHeight(rtc->scrollHeight()); + contentRect.move(-rtc->scrollLeft(), -rtc->scrollTop()); + } + env->SetObjectField(initData, classDef->m_contentRect, + intRectToRect(env, contentRect)); + return initData; +} + +void WebViewCore::initEditField(Node* node) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject javaObject = m_javaGlue->object(env); + if (!javaObject.get()) + return; + m_textGeneration = 0; + int start = 0; + int end = 0; + getSelectionOffsets(node, start, end); SelectText* selectText = createSelectText(focusedFrame()->selection()->selection()); env->CallVoidMethod(javaObject.get(), m_javaGlue->m_initEditField, - reinterpret_cast<int>(node), fieldText, inputType, - spellCheckEnabled, autoComplete, isNextText, isPrevText, name, - labelText, start, end, reinterpret_cast<int>(selectText), maxLength, - nodeBounds, layerId); + start, end, reinterpret_cast<int>(selectText), + createTextFieldInitData(node)); checkException(env); } @@ -3740,6 +3804,24 @@ void WebViewCore::updateTextSelection() checkException(env); } +void WebViewCore::updateTextSizeAndScroll(WebCore::Node* node) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject javaObject = m_javaGlue->object(env); + if (!javaObject.get()) + return; + RenderTextControl* rtc = toRenderTextControl(node); + if (!rtc) + return; + int width = rtc->scrollWidth(); + int height = rtc->contentHeight(); + int scrollX = rtc->scrollLeft(); + int scrollY = rtc->scrollTop(); + env->CallVoidMethod(javaObject.get(), m_javaGlue->m_updateTextSizeAndScroll, + reinterpret_cast<int>(node), width, height, scrollX, scrollY); + checkException(env); +} + void WebViewCore::updateTextfield(WebCore::Node* ptr, bool changeToPassword, const WTF::String& text) { @@ -4150,13 +4232,14 @@ int WebViewCore::findTextOnPage(const WTF::String &text) frame->document()->markers()->removeMarkers(DocumentMarker::TextMatch); m_matchCount += frame->editor()->countMatchesForText(text, findOptions, 0, true); - updateMatchCount(); frame->editor()->setMarkedTextMatchesAreHighlighted(true); frame = frame->tree()->traverseNextWithWrap(false); } while (frame); - m_activeMatchIndex = m_matchCount - 1; // prime first findNext - findNextOnPage(true); + if (!m_matchCount) // send at least one update, even if no hits + updateMatchCount(); + else + findNextOnPage(true); return m_matchCount; } diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index d905556..6850111 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -229,6 +229,12 @@ namespace android { */ void updateTextSelection(); + /** + * Updates the java side with the node's content size and scroll + * position. + */ + void updateTextSizeAndScroll(WebCore::Node* node); + void clearTextEntry(); // JavaScript support void jsAlert(const WTF::String& url, const WTF::String& text); @@ -670,6 +676,7 @@ namespace android { void advanceAnchorNode(DOMSelection* selection, int direction, String& markup, bool ignoreFirstNode, ExceptionCode& ec); Node* getNextAnchorNode(Node* anchorNode, bool skipFirstHack, int direction); Node* getImplicitBoundaryNode(Node* node, unsigned offset, int direction); + jobject createTextFieldInitData(Node* node); /** * Calls into java to reset the text edit field with the * current contents and selection. @@ -740,6 +747,8 @@ namespace android { friend class ListBoxReply; struct JavaGlue; struct JavaGlue* m_javaGlue; + struct TextFieldInitDataGlue; + struct TextFieldInitDataGlue* m_textFieldInitDataGlue; WebCore::Frame* m_mainFrame; WebCoreReply* m_popupReply; int m_blurringNodePointer; |