diff options
Diffstat (limited to 'Source')
6 files changed, 64 insertions, 63 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index 99eb1c6..1b0513b 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -132,10 +132,10 @@ void GLWebViewState::setViewport(const SkRect& viewport, float scale) int viewMaxTileX = static_cast<int>(ceilf((viewport.width()-1) * invTileContentWidth)) + 1; int viewMaxTileY = static_cast<int>(ceilf((viewport.height()-1) * invTileContentHeight)) + 1; - TilesManager* manager = TilesManager::instance(); - int maxTextureCount = viewMaxTileX * viewMaxTileY * (manager->highEndGfx() ? 4 : 2); + TilesManager* tilesManager = TilesManager::instance(); + int maxTextureCount = viewMaxTileX * viewMaxTileY * (tilesManager->highEndGfx() ? 4 : 2); - manager->setMaxTextureCount(maxTextureCount); + tilesManager->setMaxTextureCount(maxTextureCount); // TODO: investigate whether we can move this return earlier. if ((m_viewport == viewport) diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp index 8fb4d4b..91335c7 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceCollectionManager.cpp @@ -205,9 +205,17 @@ int SurfaceCollectionManager::drawGL(double currentTime, IntRect& viewRect, returnFlags |= uirenderer::DrawGlInfo::kStatusInvoke; if (!shouldDraw) { - if (didCollectionSwap) { + if (didCollectionSwap + || (!m_paintingCollection + && m_drawingCollection + && m_drawingCollection->isReady())) { + // either a swap just occurred, or there is no more work to be done: do a full draw m_drawingCollection->swapTiles(); returnFlags |= uirenderer::DrawGlInfo::kStatusDraw; + } else { + // current collection not ready - invoke functor in process mode + // until either drawing or painting collection is ready + returnFlags |= uirenderer::DrawGlInfo::kStatusInvoke; } return returnFlags; diff --git a/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp b/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp index 0e900a9..63f73aa 100644 --- a/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/TileGrid.cpp @@ -153,8 +153,9 @@ void TileGrid::prepareGL(GLWebViewState* state, float scale, bool goingDown = m_prevTileY < m_area.y(); m_prevTileY = m_area.y(); + TilesManager* tilesManager = TilesManager::instance(); if (scale != m_scale) - TilesManager::instance()->removeOperationsForFilter(new ScaleFilter(painter, m_scale)); + tilesManager->removeOperationsForFilter(new ScaleFilter(painter, m_scale)); m_scale = scale; @@ -164,11 +165,11 @@ void TileGrid::prepareGL(GLWebViewState* state, float scale, m_tiles[i]->markAsDirty(m_dirtyRegion); // log inval region for the base surface - if (m_isBaseSurface && TilesManager::instance()->getProfiler()->enabled()) { + if (m_isBaseSurface && tilesManager->getProfiler()->enabled()) { SkRegion::Iterator iterator(m_dirtyRegion); while (!iterator.done()) { SkIRect r = iterator.rect(); - TilesManager::instance()->getProfiler()->nextInval(r, scale); + tilesManager->getProfiler()->nextInval(r, scale); iterator.next(); } } @@ -192,10 +193,13 @@ void TileGrid::prepareGL(GLWebViewState* state, float scale, if (useExpandPrefetch) { IntRect fullArea = computeTilesArea(unclippedArea, scale); IntRect expandedArea = m_area; - expandedArea.inflate(EXPANDED_BOUNDS_INFLATE); + + // on systems reporting highEndGfx=true and useMinimalMemory not set, use expanded bounds + if (tilesManager->highEndGfx() && !tilesManager->useMinimalMemory()) + expandedArea.inflate(EXPANDED_BOUNDS_INFLATE); if (isLowResPrefetch) - expandedArea.inflate(EXPANDED_PREFETCH_BOUNDS_Y_INFLATE); + expandedArea.inflateY(EXPANDED_PREFETCH_BOUNDS_Y_INFLATE); // clip painting area to content expandedArea.intersect(fullArea); diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 6270c63..558f424 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -371,7 +371,6 @@ struct WebViewCore::JavaGlue { jmethodID m_setWebTextViewAutoFillable; jmethodID m_selectAt; jmethodID m_initEditField; - jmethodID m_updateMatchCount; jmethodID m_chromeCanTakeFocus; jmethodID m_chromeTakeFocus; AutoJObject object(JNIEnv* env) { @@ -398,7 +397,7 @@ struct WebViewCore::TextFieldInitDataGlue { jfieldID m_name; jfieldID m_label; jfieldID m_maxLength; - jfieldID m_nodeBounds; + jfieldID m_contentBounds; jfieldID m_nodeLayerId; jfieldID m_contentRect; }; @@ -507,7 +506,6 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m 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", "(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"); env->DeleteLocalRef(clazz); @@ -525,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_nodeBounds = env->GetFieldID(tfidClazz, "mNodeBounds", "Landroid/graphics/Rect;"); + m_textFieldInitDataGlue->m_contentBounds = env->GetFieldID(tfidClazz, "mContentBounds", "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"); @@ -1651,7 +1649,7 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection) RenderText* renderText = toRenderText(r); int caretOffset; InlineBox* inlineBox; - start.getInlineBoxAndOffset(DOWNSTREAM, inlineBox, caretOffset); + start.getInlineBoxAndOffset(selection.affinity(), inlineBox, caretOffset); startHandle = renderText->localCaretRect(inlineBox, caretOffset); FloatPoint absoluteOffset = renderText->localToAbsolute(startHandle.location()); startHandle.setX(absoluteOffset.x() - layerOffset.x()); @@ -1700,19 +1698,19 @@ SelectText* WebViewCore::createSelectText(const VisibleSelection& selection) selectTextContainer->setText(range->text()); selectTextContainer->setTextRect(SelectText::StartHandle, - positionToTextRect(selection.start())); + positionToTextRect(selection.start(), selection.affinity())); selectTextContainer->setTextRect(SelectText::EndHandle, - positionToTextRect(selection.end())); + positionToTextRect(selection.end(), selection.affinity())); return selectTextContainer; } -IntRect WebViewCore::positionToTextRect(const Position& position) +IntRect WebViewCore::positionToTextRect(const Position& position, EAffinity affinity) { IntRect textRect; InlineBox* inlineBox; int offset; - position.getInlineBoxAndOffset(VP_DEFAULT_AFFINITY, inlineBox, offset); + position.getInlineBoxAndOffset(affinity, inlineBox, offset); if (inlineBox && inlineBox->isInlineTextBox()) { InlineTextBox* box = static_cast<InlineTextBox*>(inlineBox); RootInlineBox* root = box->root(); @@ -2962,17 +2960,17 @@ void WebViewCore::passToJs(int generation, const WTF::String& current, updateTextSelection(); } -void WebViewCore::scrollFocusedTextInput(float xPercent, int y) +WebCore::IntRect WebViewCore::scrollFocusedTextInput(float xPercent, int y) { WebCore::Node* focus = currentFocus(); if (!focus) { clearTextEntry(); - return; + return WebCore::IntRect(); } WebCore::RenderTextControl* renderText = toRenderTextControl(focus); if (!renderText) { clearTextEntry(); - return; + return WebCore::IntRect(); } int x = (int) (xPercent * (renderText->scrollWidth() - @@ -2980,6 +2978,9 @@ void 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) @@ -3409,22 +3410,23 @@ bool WebViewCore::isAutoCompleteEnabled(Node* node) return isEnabled; } -WebCore::IntRect WebViewCore::boundingRect(WebCore::Node* node, +WebCore::IntRect WebViewCore::absoluteContentRect(WebCore::Node* node, LayerAndroid* layer) { - // Caret selection - IntRect boundingRect; + IntRect contentRect; if (node) { RenderObject* render = node->renderer(); - if (render && !render->isBody()) { + if (render && render->isBox() && !render->isBody()) { IntPoint offset = convertGlobalContentToFrameContent(IntPoint(), node->document()->frame()); WebViewCore::layerToAbsoluteOffset(layer, offset); - boundingRect = render->absoluteBoundingBoxRect(true); - boundingRect.move(-offset.x(), -offset.y()); + + RenderBox* renderBox = toRenderBox(render); + contentRect = renderBox->absoluteContentBox(); + contentRect.move(-offset.x(), -offset.y()); } } - return boundingRect; + return contentRect; } jobject WebViewCore::createTextFieldInitData(Node* node) @@ -3457,8 +3459,8 @@ jobject WebViewCore::createTextFieldInitData(Node* node) env->SetIntField(initData, classDef->m_maxLength, getMaxLength(node)); LayerAndroid* layer = 0; int layerId = platformLayerIdFromNode(node, &layer); - IntRect bounds = boundingRect(node, layer); - env->SetObjectField(initData, classDef->m_nodeBounds, + IntRect bounds = absoluteContentRect(node, layer); + env->SetObjectField(initData, classDef->m_contentBounds, intRectToRect(env, bounds)); env->SetIntField(initData, classDef->m_nodeLayerId, layerId); IntRect contentRect; @@ -4302,19 +4304,15 @@ int WebViewCore::findTextOnPage(const WTF::String &text) frame = frame->tree()->traverseNextWithWrap(false); } while (frame); m_activeMatchIndex = m_matchCount - 1; // prime first findNext - if (!m_matchCount) // send at least one update, even if no hits - updateMatchCount(); - else - findNextOnPage(true); return m_matchCount; } -void WebViewCore::findNextOnPage(bool forward) +int WebViewCore::findNextOnPage(bool forward) { if (!m_mainFrame) - return; + return -1; if (!m_matchCount) - return; + return -1; EditorClientAndroid* client = static_cast<EditorClientAndroid*>( m_mainFrame->editor()->client()); @@ -4361,24 +4359,12 @@ void WebViewCore::findNextOnPage(bool forward) m_mainFrame->selection()->revealSelection( ScrollAlignment::alignCenterIfNeeded, true); } - updateMatchCount(); } // Clear selection so it doesn't display. m_mainFrame->selection()->clear(); client->setUiGeneratedSelectionChange(false); -} - -void WebViewCore::updateMatchCount() const -{ - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject javaObject = m_javaGlue->object(env); - if (!javaObject.get()) - return; - jstring javaText = wtfStringToJstring(env, m_searchText, true); - env->CallVoidMethod(javaObject.get(), m_javaGlue->m_updateMatchCount, - m_activeMatchIndex, m_matchCount, javaText); - checkException(env); + return m_activeMatchIndex; } String WebViewCore::getText(int startX, int startY, int endX, int endY) @@ -4556,10 +4542,12 @@ static void PassToJs(JNIEnv* env, jobject obj, jint nativeClass, } static void ScrollFocusedTextInput(JNIEnv* env, jobject obj, jint nativeClass, - jfloat xPercent, jint y) + jfloat xPercent, jint y, jobject contentBounds) { WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass); - viewImpl->scrollFocusedTextInput(xPercent, y); + IntRect bounds = viewImpl->scrollFocusedTextInput(xPercent, y); + if (contentBounds) + GraphicsJNI::irect_to_jrect(bounds, env, contentBounds); } static void SetFocusControllerActive(JNIEnv* env, jobject obj, jint nativeClass, @@ -5070,11 +5058,11 @@ static int FindAll(JNIEnv* env, jobject obj, jint nativeClass, return viewImpl->findTextOnPage(wtfText); } -static void FindNext(JNIEnv* env, jobject obj, jint nativeClass, +static int FindNext(JNIEnv* env, jobject obj, jint nativeClass, jboolean forward) { WebViewCore* viewImpl = reinterpret_cast<WebViewCore*>(nativeClass); - viewImpl->findNextOnPage(forward); + return viewImpl->findNextOnPage(forward); } // ---------------------------------------------------------------------------- @@ -5115,7 +5103,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) MoveMouse }, { "passToJs", "(IILjava/lang/String;IIZZZZ)V", (void*) PassToJs }, - { "nativeScrollFocusedTextInput", "(IFI)V", + { "nativeScrollFocusedTextInput", "(IFILandroid/graphics/Rect;)V", (void*) ScrollFocusedTextInput }, { "nativeSetFocusControllerActive", "(IZ)V", (void*) SetFocusControllerActive }, @@ -5197,7 +5185,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) nativeCertTrustChanged }, { "nativeFindAll", "(ILjava/lang/String;)I", (void*) FindAll }, - { "nativeFindNext", "(IZ)V", + { "nativeFindNext", "(IZ)I", (void*) FindNext }, }; diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index 99a13f3..d3f0e18 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 */ - void scrollFocusedTextInput(float x, int y); + WebCore::IntRect scrollFocusedTextInput(float x, int y); /** * Set the FocusController's active and focused states, so that * the caret will draw (true) or not. @@ -552,7 +552,7 @@ namespace android { // find on page void resetFindOnPage(); int findTextOnPage(const WTF::String &text); - void findNextOnPage(bool forward); + int findNextOnPage(bool forward); void updateMatchCount() const; #if ENABLE(VIDEO) @@ -748,9 +748,10 @@ namespace android { static int getMaxLength(WebCore::Node* node); static WTF::String getFieldName(WebCore::Node* node); static bool isAutoCompleteEnabled(WebCore::Node* node); - WebCore::IntRect boundingRect(WebCore::Node* node, - WebCore::LayerAndroid* layer); - static WebCore::IntRect positionToTextRect(const WebCore::Position& position); + WebCore::IntRect absoluteContentRect(WebCore::Node* node, + WebCore::LayerAndroid* layer); + static WebCore::IntRect positionToTextRect(const WebCore::Position& position, + WebCore::EAffinity affinity); // 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 a4381e6..3bd0bdc 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(textRect.height() - 1); - textRect.setWidth(textRect.width() - 1); + textRect.setHeight(std::max(1, textRect.height() - 1)); + textRect.setWidth(std::max(1, textRect.width() - 1)); textBounds = FloatQuad(textRect); if (layerId != -1) { |
