diff options
Diffstat (limited to 'Source/WebKit/android')
-rw-r--r-- | Source/WebKit/android/RenderSkinMediaButton.cpp | 2 | ||||
-rw-r--r-- | Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp | 8 | ||||
-rw-r--r-- | Source/WebKit/android/jni/JavaSharedClient.cpp | 4 | ||||
-rw-r--r-- | Source/WebKit/android/jni/PictureSet.cpp | 21 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 17 | ||||
-rw-r--r-- | Source/WebKit/android/nav/FindCanvas.cpp | 9 | ||||
-rw-r--r-- | Source/WebKit/android/nav/FindCanvas.h | 7 | ||||
-rw-r--r-- | Source/WebKit/android/nav/WebView.cpp | 64 |
8 files changed, 85 insertions, 47 deletions
diff --git a/Source/WebKit/android/RenderSkinMediaButton.cpp b/Source/WebKit/android/RenderSkinMediaButton.cpp index 294dec5..ef4b313 100644 --- a/Source/WebKit/android/RenderSkinMediaButton.cpp +++ b/Source/WebKit/android/RenderSkinMediaButton.cpp @@ -62,7 +62,7 @@ static const PatchData gFiles[] = { "ic_media_video_poster.png", 0, 0 }, // VIDEO { "btn_media_player_disabled.9.png", 0, 0 }, // BACKGROUND_SLIDER { "scrubber_track_holo_dark.9.png", 0, 0 }, // SLIDER_TRACK - { "scrubber_control_holo.png", 0, 0 } // SLIDER_THUMB + { "scrubber_control_normal_holo.png", 0, 0 } // SLIDER_THUMB }; static SkBitmap gButton[sizeof(gFiles)/sizeof(gFiles[0])]; diff --git a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index 9de6c09..31eed62 100644 --- a/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -373,10 +373,16 @@ void FrameLoaderClientAndroid::dispatchDidFailProvisionalLoad(const ResourceErro url.append(buf, res); } } + // Vector sets up its data buffer lazilly, so if failingUrl is the empty + // string, the data buffer will be null. This will result in sanitizedUrl + // being null, and the string substitution below will be a no-op. + // FIXME: Ideally we'd always have a non-empty URL, or at least improve the + // wording of the error page in this case. See http://b/5293782. + String sanitizedUrl = url.data() ? String(url.data(), url.size()) : ""; // Replace all occurances of %s with the failing url. String s = UTF8Encoding().decode((const char*)a->getBuffer(false), a->getLength()); - s = s.replace("%s", String(url.data(), url.size())); + s = s.replace("%s", sanitizedUrl); // Replace all occurances of %e with the error text s = s.replace("%e", error.localizedDescription()); diff --git a/Source/WebKit/android/jni/JavaSharedClient.cpp b/Source/WebKit/android/jni/JavaSharedClient.cpp index e884c99..4f40355 100644 --- a/Source/WebKit/android/jni/JavaSharedClient.cpp +++ b/Source/WebKit/android/jni/JavaSharedClient.cpp @@ -117,7 +117,7 @@ namespace android { void (*proc)(void*) = 0; void* payload = 0; const FuncPtrRec* rec; - + // we have to copy the proc/payload (if present). we do this so we // don't call the proc inside the mutex (possible deadlock!) gFuncPtrQMutex.acquire(); @@ -128,7 +128,7 @@ namespace android { gFuncPtrQ.pop_front(); } gFuncPtrQMutex.release(); - + if (!rec) break; proc(payload); diff --git a/Source/WebKit/android/jni/PictureSet.cpp b/Source/WebKit/android/jni/PictureSet.cpp index e6a9ed5..f61e0f1 100644 --- a/Source/WebKit/android/jni/PictureSet.cpp +++ b/Source/WebKit/android/jni/PictureSet.cpp @@ -356,23 +356,10 @@ void PictureSet::splitAdd(const SkIRect& rect) SkIRect newRect; int deltaX = i * maxSize; int deltaY = j * maxSize; - int left, top, right, bottom; - if (i == firstTileX) - left = rect.fLeft; - else - left = 0; - if (j == firstTileY) - top = rect.fTop; - else - top = 0; - if (i == lastTileX) - right = rect.fRight % maxSize; - else - right = maxSize; - if (j == lastTileY) - bottom = rect.fBottom % maxSize; - else - bottom = maxSize; + int left = (i == firstTileX) ? rect.fLeft - deltaX : 0; + int top = (j == firstTileY) ? rect.fTop - deltaY : 0; + int right = (i == lastTileX) ? rect.fRight % maxSize : maxSize; + int bottom = (j == lastTileY) ? rect.fBottom % maxSize : maxSize; newRect.set(left, top, right, bottom); addToBucket(bucket, deltaX, deltaY, newRect); diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 9b5a6fa..24266f6 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -1729,7 +1729,7 @@ Vector<IntRect> WebViewCore::getTouchHighlightRects(int x, int y, int slop) Node* eventNode = it->get(); while (eventNode) { RenderObject* render = eventNode->renderer(); - if (render->isBody() || render->isRenderView()) + if (render && (render->isBody() || render->isRenderView())) break; if (eventNode->supportsFocus() || eventNode->hasEventListeners(eventNames().clickEvent) @@ -1755,7 +1755,7 @@ Vector<IntRect> WebViewCore::getTouchHighlightRects(int x, int y, int slop) // If the fat point touches everyone, the order in the list should be "b", "d", "c" // and "a". When we search for the event node for "b", we really don't want "a" as // in the z-order it is behind everything else. - if (!render->style()->hasAutoZIndex()) + if (render && !render->style()->hasAutoZIndex()) break; eventNode = eventNode->parentNode(); } @@ -2189,6 +2189,11 @@ void WebViewCore::setSelection(int start, int end) String WebViewCore::modifySelection(const int direction, const int axis) { DOMSelection* selection = m_mainFrame->domWindow()->getSelection(); + ASSERT(selection); + // We've seen crashes where selection is null, but we don't know why + // See http://b/5244036 + if (!selection) + return String(); if (selection->rangeCount() > 1) selection->removeAllRanges(); switch (axis) { @@ -2219,12 +2224,16 @@ void WebViewCore::scrollNodeIntoView(Frame* frame, Node* node) if (!node->isElementNode()) { HTMLElement* body = frame->document()->body(); do { - if (!node || node == body) + if (node == body) return; node = node->parentNode(); - } while (!node->isElementNode() && !isVisible(node)); + } while (node && !node->isElementNode() && !isVisible(node)); } + // Couldn't find a visible predecessor. + if (!node) + return; + elementNode = static_cast<Element*>(node); elementNode->scrollIntoViewIfNeeded(true); } diff --git a/Source/WebKit/android/nav/FindCanvas.cpp b/Source/WebKit/android/nav/FindCanvas.cpp index 2d310b3..ca3cfba 100644 --- a/Source/WebKit/android/nav/FindCanvas.cpp +++ b/Source/WebKit/android/nav/FindCanvas.cpp @@ -532,9 +532,6 @@ IntRect FindOnPage::currentMatchBounds() const { if (!m_matches || !m_matches->size()) return noBounds; MatchInfo& info = (*m_matches)[m_findIndex]; - // FIXME: this should test if the match in the layer is visible - if (info.isInLayer()) - return noBounds; return info.getLocation().getBounds(); } @@ -545,6 +542,10 @@ bool FindOnPage::currentMatchIsInLayer() const { return info.isInLayer(); } +int FindOnPage::currentMatchLayerId() const { + return (*m_matches)[m_findIndex].layerId(); +} + // This function is only used by findNext and setMatches. In it, we store // upper left corner of the match specified by m_findIndex in // m_currentMatchLocation. @@ -597,7 +598,7 @@ void FindOnPage::draw(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval) { unsigned numberOfMatches = m_matches->size(); if (numberOfMatches > 1 && numberOfMatches < MAX_NUMBER_OF_MATCHES_TO_DRAW) { - for(unsigned i = 0; i < numberOfMatches; i++) { + for (unsigned i = 0; i < numberOfMatches; i++) { // The current match has already been drawn if (i == m_findIndex) continue; diff --git a/Source/WebKit/android/nav/FindCanvas.h b/Source/WebKit/android/nav/FindCanvas.h index 76ee1e2..994ff17 100644 --- a/Source/WebKit/android/nav/FindCanvas.h +++ b/Source/WebKit/android/nav/FindCanvas.h @@ -54,9 +54,9 @@ public: SkPicture* getPicture() const { return m_picture; } // This will make a copy of the region, and increase the ref count on the // SkPicture. If this MatchInfo already had one, unref it. + void set(const SkRegion& region, SkPicture* pic, int layerId); bool isInLayer() const { return m_layerId >= 0; } int layerId() const { return m_layerId; } - void set(const SkRegion& region, SkPicture* pic, int layerId); private: MatchInfo& operator=(MatchInfo& src); SkRegion m_location; @@ -141,7 +141,7 @@ public: const SkPaint& paint) { } - void drawLayers(LayerAndroid* ); + void drawLayers(LayerAndroid*); int found() const { return mNumFound; } void setLayerId(int layerId) { mLayerId = layerId; } @@ -227,6 +227,9 @@ public: IntRect currentMatchBounds() const; int currentMatchIndex() const { return m_findIndex; } bool currentMatchIsInLayer() const; + // This requires the current match to be in a layer. See + // currentMatchIsInLayer(). + int currentMatchLayerId() const; virtual void draw(SkCanvas* , LayerAndroid* , IntRect* ); void findNext(bool forward); bool isCurrentLocationValid() { return m_hasCurrentLocation; } diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index a528e9a..101e206 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -105,8 +105,7 @@ class WebView public: enum FrameCachePermission { DontAllowNewer, - AllowNewer, - AllowNewest + AllowNewer }; enum DrawExtras { // keep this in sync with WebView.java @@ -332,8 +331,32 @@ void nativeRecordButtons(bool hasFocus, bool pressed, bool invalidate) } } -// The caller has already determined that the desired document rect corresponds -// to the main picture, and not a layer +void scrollToCurrentMatch() +{ + if (!m_findOnPage.currentMatchIsInLayer()) { + scrollRectOnScreen(m_findOnPage.currentMatchBounds()); + return; + } + + SkRect matchBounds = m_findOnPage.currentMatchBounds(); + const LayerAndroid* rootLayer = getFrameCache(DontAllowNewer)->rootLayer(); + const Layer* layerContainingMatch = rootLayer->findById(m_findOnPage.currentMatchLayerId()); + ASSERT(layerContainingMatch); + + // FIXME: If the match is in a scrollable layer or a child of such a layer, + // we may need to scroll these layers to make sure the match is visible. + // See http://b/5262656. + + // Convert matchBounds to the global space so we can scroll the main page. + SkMatrix transform; + layerContainingMatch->localToGlobal(&transform); + SkRect transformedMatchBounds; + transform.mapRect(&transformedMatchBounds, matchBounds); + SkIRect roundedTransformedMatchBounds; + transformedMatchBounds.roundOut(&roundedTransformedMatchBounds); + scrollRectOnScreen(roundedTransformedMatchBounds); +} + void scrollRectOnScreen(const IntRect& rect) { if (rect.isEmpty()) @@ -489,8 +512,23 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::In m_glWebViewState->resetRings(); if (extra) { if (extra == &m_ring) { + WTF::Vector<IntRect> rings; if (root == m_ring.m_frame) - m_glWebViewState->setRings(m_ring.rings(), m_ring.m_isPressed); + rings = m_ring.rings(); + else { + // TODO: Fix the navcache to work with layers correctly + // In the meantime, this works around the bug. However, the rings + // it produces are not as nice for some reason, thus we use + // m_ring.rings() above for the base layer instead of the below + for (size_t i = 0; i < m_ring.m_node->rings().size(); i++) { + IntRect rect = m_ring.m_node->rings().at(i); + rect = m_ring.m_frame->adjustBounds(m_ring.m_node, rect); + rect.inflate(4); + rings.append(rect); + } + } + m_glWebViewState->setRings(rings, m_ring.m_isPressed); + extra = 0; } else { LayerAndroid mainPicture(m_navPictureUI); PictureSet* content = m_baseLayer->content(); @@ -1290,8 +1328,7 @@ void sendMotionUp(WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int y void findNext(bool forward) { m_findOnPage.findNext(forward); - if (!m_findOnPage.currentMatchIsInLayer()) - scrollRectOnScreen(m_findOnPage.currentMatchBounds()); + scrollToCurrentMatch(); viewInvalidate(); } @@ -1303,21 +1340,16 @@ void setMatches(WTF::Vector<MatchInfo>* matches, jboolean sameAsLastSearch) // location to determine whether to scroll. If the same word is found // in the same place, then do not scroll. IntRect oldLocation; - bool checkAgainstOldLocation; + bool checkAgainstOldLocation = false; if (sameAsLastSearch && m_findOnPage.isCurrentLocationValid()) { oldLocation = m_findOnPage.currentMatchBounds(); checkAgainstOldLocation = true; - } else - checkAgainstOldLocation = false; + } m_findOnPage.setMatches(matches); - if (!checkAgainstOldLocation - || oldLocation != m_findOnPage.currentMatchBounds()) { - // FIXME: Need to scroll if the match is in a layer. - if (!m_findOnPage.currentMatchIsInLayer()) - scrollRectOnScreen(m_findOnPage.currentMatchBounds()); - } + if (!checkAgainstOldLocation || oldLocation != m_findOnPage.currentMatchBounds()) + scrollToCurrentMatch(); viewInvalidate(); } |