diff options
Diffstat (limited to 'Source')
17 files changed, 142 insertions, 411 deletions
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk index d6c899e..af56e7e 100644 --- a/Source/WebCore/Android.mk +++ b/Source/WebCore/Android.mk @@ -686,7 +686,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/graphics/android/VideoLayerAndroid.cpp \ platform/graphics/android/VideoLayerManager.cpp \ platform/graphics/android/ZoomManager.cpp \ - platform/graphics/android/android_graphics.cpp \ ifeq ($(ENABLE_SVG), true) LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ diff --git a/Source/WebCore/platform/ScrollView.cpp b/Source/WebCore/platform/ScrollView.cpp index e79f049..58a1fbf 100644 --- a/Source/WebCore/platform/ScrollView.cpp +++ b/Source/WebCore/platform/ScrollView.cpp @@ -27,6 +27,9 @@ #include "ScrollView.h" #include "AXObjectCache.h" +#if PLATFORM(ANDROID) +#include "FrameView.h" +#endif #include "GraphicsContext.h" #include "GraphicsLayer.h" #include "HostWindow.h" @@ -328,6 +331,14 @@ int ScrollView::actualScrollY() const return platformActualScrollY(); return scrollY(); } + +FrameView* ScrollView::frameView() { + if (this->isFrameView()) { + FrameView* frameView = reinterpret_cast<FrameView*>(this); + return frameView; + } + return 0; +} #endif IntPoint ScrollView::maximumScrollPosition() const diff --git a/Source/WebCore/platform/ScrollView.h b/Source/WebCore/platform/ScrollView.h index 558aee2..3228870 100644 --- a/Source/WebCore/platform/ScrollView.h +++ b/Source/WebCore/platform/ScrollView.h @@ -53,6 +53,10 @@ namespace WebCore { class HostWindow; class Scrollbar; +#if PLATFORM(ANDROID) +class FrameView; +#endif + class ScrollView : public Widget, public ScrollableArea { public: ~ScrollView(); @@ -172,6 +176,7 @@ public: int actualHeight() const; int actualScrollX() const; int actualScrollY() const; + FrameView* frameView(); #endif // Functions for querying the current scrolled position (both as a point, a size, or as individual X and Y values). diff --git a/Source/WebCore/platform/android/ScrollViewAndroid.cpp b/Source/WebCore/platform/android/ScrollViewAndroid.cpp index f29e998..8df0c2f 100644 --- a/Source/WebCore/platform/android/ScrollViewAndroid.cpp +++ b/Source/WebCore/platform/android/ScrollViewAndroid.cpp @@ -98,8 +98,6 @@ int ScrollView::platformActualScrollY() const void ScrollView::platformSetScrollPosition(const WebCore::IntPoint& pt) { - if (parent()) // don't attempt to scroll subframes; they're fully visible - return; PlatformBridge::setScrollPosition(this, m_scrollOrigin.x() + pt.x(), m_scrollOrigin.y() + pt.y()); } diff --git a/Source/WebCore/platform/graphics/android/GLExtras.cpp b/Source/WebCore/platform/graphics/android/GLExtras.cpp index 8a1d2fa..dc983a6 100644 --- a/Source/WebCore/platform/graphics/android/GLExtras.cpp +++ b/Source/WebCore/platform/graphics/android/GLExtras.cpp @@ -51,14 +51,9 @@ // Touch ring border width. This is doubled if the ring is not pressed #define RING_BORDER_WIDTH 1 -// Put a cap on the number of matches to draw. If the current page has more -// matches than this, only draw the focused match. This both prevents clutter -// on the page and keeps the performance happy -#define MAX_NUMBER_OF_MATCHES_TO_DRAW 101 GLExtras::GLExtras() - : m_ring(0) - , m_drawExtra(0) + : m_drawExtra(0) , m_viewport() { } @@ -150,30 +145,8 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill, bool drawBorder, } } -void GLExtras::drawCursorRings(const LayerAndroid* layer) -{ - int layerId = layer ? layer->uniqueId() : -1; - if (layerId != m_ring->layerId()) - return; - - SkRegion region; - for (size_t i = 0; i < m_ring->rings().size(); i++) { - IntRect rect = m_ring->rings().at(i); - if (i == 0) - region.setRect(rect); - else - region.op(rect, SkRegion::kUnion_Op); - } - drawRegion(region, m_ring->m_isPressed, !m_ring->m_isButton, - layer ? layer->drawTransform() : 0); -} - void GLExtras::drawGL(const LayerAndroid* layer) { - if (m_drawExtra) { - if (m_drawExtra == m_ring) - drawCursorRings(layer); - else - m_drawExtra->drawGL(this, layer); - } + if (m_drawExtra) + m_drawExtra->drawGL(this, layer); } diff --git a/Source/WebCore/platform/graphics/android/GLExtras.h b/Source/WebCore/platform/graphics/android/GLExtras.h index 72ee41c..59a7c3c 100644 --- a/Source/WebCore/platform/graphics/android/GLExtras.h +++ b/Source/WebCore/platform/graphics/android/GLExtras.h @@ -31,10 +31,6 @@ #include "SkRect.h" #include "SkRegion.h" -namespace android { - class CursorRing; -} - namespace WebCore { class LayerAndroid; @@ -46,7 +42,6 @@ public: virtual ~GLExtras(); void drawGL(const LayerAndroid* layer); - void setCursorRingExtra(android::CursorRing* ring) { m_ring = ring; } void setDrawExtra(android::DrawExtra* extra) { m_drawExtra = extra; } void setViewport(const SkRect & viewport) { m_viewport = viewport; } @@ -55,9 +50,7 @@ public: private: void drawRing(SkRect& srcRect, Color color, const TransformationMatrix* drawMat); - void drawCursorRings(const LayerAndroid* layer); - android::CursorRing* m_ring; android::DrawExtra* m_drawExtra; SkRect m_viewport; }; diff --git a/Source/WebCore/platform/graphics/android/GLUtils.cpp b/Source/WebCore/platform/graphics/android/GLUtils.cpp index 39d8755..3024d28 100644 --- a/Source/WebCore/platform/graphics/android/GLUtils.cpp +++ b/Source/WebCore/platform/graphics/android/GLUtils.cpp @@ -36,9 +36,6 @@ #include <wtf/CurrentTime.h> #include <wtf/text/CString.h> -#include <cutils/log.h> -#include <wtf/text/CString.h> - #undef XLOGC #define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "GLUtils", __VA_ARGS__) @@ -54,6 +51,11 @@ #endif // DEBUG +// We will limit GL error logging for LOG_VOLUME_PER_CYCLE times every +// LOG_VOLUME_PER_CYCLE seconds. +#define LOG_CYCLE 30.0 +#define LOG_VOLUME_PER_CYCLE 20 + struct ANativeWindowBuffer; namespace WebCore { @@ -118,10 +120,35 @@ void GLUtils::setOrthographicMatrix(TransformationMatrix& ortho, float left, flo // GL & EGL error checks ///////////////////////////////////////////////////////////////////////////////////////// -static void crashIfOOM(GLint errorCode) { +double GLUtils::m_previousLogTime = 0; +int GLUtils::m_currentLogCounter = 0; + +bool GLUtils::allowGLLog() +{ + if (m_currentLogCounter < LOG_VOLUME_PER_CYCLE) { + m_currentLogCounter++; + return true; + } + + // when we are in Log cycle and over the log limit, just return false + double currentTime = WTF::currentTime(); + double delta = currentTime - m_previousLogTime; + bool inLogCycle = (delta <= LOG_CYCLE) && (delta > 0); + if (inLogCycle) + return false; + + // When we are out of Log Cycle and over the log limit, we need to reset + // the counter and timer. + m_previousLogTime = currentTime; + m_currentLogCounter = 0; + return false; +} + +static void crashIfOOM(GLint errorCode) +{ const GLint OOM_ERROR_CODE = 0x505; if (errorCode == OOM_ERROR_CODE) { - XLOG("Fatal OOM detected."); + XLOGC("ERROR: Fatal OOM detected."); CRASH(); } } @@ -129,11 +156,17 @@ static void crashIfOOM(GLint errorCode) { void GLUtils::checkEglError(const char* op, EGLBoolean returnVal) { if (returnVal != EGL_TRUE) { - XLOG("EGL ERROR - %s() returned %d\n", op, returnVal); +#ifndef DEBUG + if (allowGLLog()) +#endif + XLOGC("EGL ERROR - %s() returned %d\n", op, returnVal); } for (EGLint error = eglGetError(); error != EGL_SUCCESS; error = eglGetError()) { - XLOG("after %s() eglError (0x%x)\n", op, error); +#ifndef DEBUG + if (allowGLLog()) +#endif + XLOGC("after %s() eglError (0x%x)\n", op, error); crashIfOOM(error); } } @@ -142,7 +175,10 @@ bool GLUtils::checkGlError(const char* op) { bool ret = false; for (GLint error = glGetError(); error; error = glGetError()) { - XLOG("GL ERROR - after %s() glError (0x%x)\n", op, error); +#ifndef DEBUG + if (allowGLLog()) +#endif + XLOGC("GL ERROR - after %s() glError (0x%x)\n", op, error); crashIfOOM(error); ret = true; } @@ -153,7 +189,10 @@ bool GLUtils::checkGlErrorOn(void* p, const char* op) { bool ret = false; for (GLint error = glGetError(); error; error = glGetError()) { - XLOG("GL ERROR on %x - after %s() glError (0x%x)\n", p, op, error); +#ifndef DEBUG + if (allowGLLog()) +#endif + XLOGC("GL ERROR on %x - after %s() glError (0x%x)\n", p, op, error); crashIfOOM(error); ret = true; } @@ -163,7 +202,10 @@ bool GLUtils::checkGlErrorOn(void* p, const char* op) void GLUtils::checkSurfaceTextureError(const char* functionName, int status) { if (status != NO_ERROR) { - XLOG("ERROR at calling %s status is (%d)", functionName, status); +#ifndef DEBUG + if (allowGLLog()) +#endif + XLOGC("ERROR at calling %s status is (%d)", functionName, status); } } ///////////////////////////////////////////////////////////////////////////////////////// @@ -315,7 +357,8 @@ void GLUtils::deleteTexture(GLuint* texture) *texture = 0; } -GLuint GLUtils::createSampleColorTexture(int r, int g, int b) { +GLuint GLUtils::createSampleColorTexture(int r, int g, int b) +{ GLuint texture; glGenTextures(1, &texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -501,7 +544,10 @@ void GLUtils::createTextureWithBitmap(GLuint texture, const SkBitmap& bitmap, GL 0, internalformat, type, bitmap.getPixels()); bitmap.unlockPixels(); if (GLUtils::checkGlError("glTexImage2D")) { - XLOG("GL ERROR: glTexImage2D parameters are : bitmap.width() %d, bitmap.height() %d," +#ifndef DEBUG + if (allowGLLog()) +#endif + XLOGC("GL ERROR: glTexImage2D parameters are : bitmap.width() %d, bitmap.height() %d," " internalformat 0x%x, type 0x%x, bitmap.getPixels() %p", bitmap.width(), bitmap.height(), internalformat, type, bitmap.getPixels()); } @@ -538,7 +584,10 @@ void GLUtils::updateTextureWithBitmap(GLuint texture, const SkBitmap& bitmap, } bitmap.unlockPixels(); if (GLUtils::checkGlError("glTexSubImage2D")) { - XLOG("GL ERROR: glTexSubImage2D parameters are : bitmap.width() %d, bitmap.height() %d," +#ifndef DEBUG + if (allowGLLog()) +#endif + XLOGC("GL ERROR: glTexSubImage2D parameters are : bitmap.width() %d, bitmap.height() %d," " internalformat 0x%x, type 0x%x, bitmap.getPixels() %p", bitmap.width(), bitmap.height(), internalformat, type, bitmap.getPixels()); } diff --git a/Source/WebCore/platform/graphics/android/GLUtils.h b/Source/WebCore/platform/graphics/android/GLUtils.h index b198d35..e001aee 100644 --- a/Source/WebCore/platform/graphics/android/GLUtils.h +++ b/Source/WebCore/platform/graphics/android/GLUtils.h @@ -85,6 +85,9 @@ public: static bool isPureColorBitmap(const SkBitmap& bitmap, Color& pureColor); static bool skipTransferForPureColor(const TileRenderInfo* renderInfo, const SkBitmap& bitmap); + static bool allowGLLog(); + static double m_previousLogTime; + static int m_currentLogCounter; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 779eb36..bb17784 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -557,10 +557,13 @@ void GraphicsLayerAndroid::updateScrollingLayers() void GraphicsLayerAndroid::updateScrollOffset() { RenderLayer* layer = renderLayerFromClient(m_client); - if (!layer || !m_foregroundLayer) + if (!layer || !(m_foregroundLayer || m_contentLayer->contentIsScrollable())) return; IntSize scroll = layer->scrolledContentOffset(); - m_foregroundLayer->setScrollOffset(IntPoint(scroll.width(), scroll.height())); + if (m_foregroundLayer) + m_foregroundLayer->setScrollOffset(IntPoint(scroll.width(), scroll.height())); + else if (m_contentLayer->contentIsScrollable()) + static_cast<ScrollableLayerAndroid*>(m_contentLayer)->scrollTo(scroll.width(), scroll.height()); askForSync(); } @@ -637,10 +640,17 @@ bool GraphicsLayerAndroid::repaint() m_foregroundLayer->markAsDirty(region); m_foregroundLayer->needsRepaint(); } else { + // Paint at 0,0. + IntSize scroll = layer->scrolledContentOffset(); + layer->scrollToOffset(0, 0); // If there is no contents clip, we can draw everything into one // picture. - if (!paintContext(m_contentLayer->recordContext(), layerBounds)) + bool painting = paintContext(m_contentLayer->recordContext(), layerBounds); + // Move back to the scroll offset + layer->scrollToOffset(scroll.width(), scroll.height()); + if (!painting) return false; + // We painted new content m_contentLayer->checkForPictureOptimizations(); // Check for a scrollable iframe and report the scrolling // limits based on the view size. @@ -648,6 +658,9 @@ bool GraphicsLayerAndroid::repaint() FrameView* view = layer->renderer()->frame()->view(); static_cast<ScrollableLayerAndroid*>(m_contentLayer)->setScrollLimits( m_position.x(), m_position.y(), view->layoutWidth(), view->layoutHeight()); + LOG("setScrollLimits(%.2f, %.2f, w: %d h: %d) layer %d, frame scroll position is %d, %d (%d, %d)", + m_position.x(), m_position.y(), view->layoutWidth(), view->layoutHeight(), + m_contentLayer->uniqueId(), view->scrollX(), view->scrollY(), view->actualScrollX(), view->actualScrollY()); } } diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp index 55692be..27a7df5 100644 --- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp @@ -29,7 +29,6 @@ void ScrollableLayerAndroid::getScrollBounds(IntRect* out) const out->setY(m_scrollLimits.fTop - pos.fY); out->setWidth(getSize().width() - m_scrollLimits.width()); out->setHeight(getSize().height() - m_scrollLimits.height()); - } void ScrollableLayerAndroid::getScrollRect(SkIRect* out) const diff --git a/Source/WebCore/platform/graphics/android/android_graphics.cpp b/Source/WebCore/platform/graphics/android/android_graphics.cpp deleted file mode 100644 index d76d581..0000000 --- a/Source/WebCore/platform/graphics/android/android_graphics.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2007, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "CachedPrefix.h" -#include "android_graphics.h" -#include "CachedRoot.h" -#include "IntRect.h" -#include "LayerAndroid.h" -#include "SkCanvas.h" -#include "SkCornerPathEffect.h" -#include "SkPath.h" -#include "SkRegion.h" -#include "WebViewCore.h" - -namespace android { - -#define RING_OUTSET 3 -#define RING_RADIUS 1 -#define RING_INNER_WIDTH 16 -#define RING_OUTER_WIDTH 16 - -static const RGBA32 ringFill = 0x666699FF; -static const RGBA32 ringPressedInner = 0x006699FF; -static const RGBA32 ringPressedOuter = 0x336699FF; -static const RGBA32 ringSelectedInner = 0xAA6699FF; -static const RGBA32 ringSelectedOuter = 0x336699FF; - - -CursorRing::CursorRing(WebViewCore* core) - : m_viewImpl(core) - , m_layerId(-1) -{ -} - -// The CSS values for the inner and outer widths may be specified as fractions -#define WIDTH_SCALE 0.0625f // 1/16, to offset the scale in CSSStyleSelector - -void CursorRing::drawLegacy(SkCanvas* canvas, LayerAndroid* layer, IntRect* inval) -{ - if (!m_lastBounds.isEmpty()) { - *inval = m_lastBounds; - m_lastBounds = IntRect(0, 0, 0, 0); - } -#if USE(ACCELERATED_COMPOSITING) - int layerId = m_node->isInLayer() ? m_frame->layer(m_node)->uniqueId() : -1; - int drawingLayerId = layer ? layer->uniqueId() : -1; - if (drawingLayerId != layerId) - return; -#endif - if (canvas->quickReject(m_bounds, SkCanvas::kAA_EdgeType)) { - DBG_NAV_LOGD("canvas->quickReject cursorNode=%d (nodePointer=%p)" - " bounds=(%d,%d,w=%d,h=%d)", m_node->index(), m_node->nodePointer(), - m_bounds.x(), m_bounds.y(), m_bounds.width(), m_bounds.height()); - return; - } - unsigned rectCount = m_rings.size(); - SkRegion rgn; - SkPath path; - for (unsigned i = 0; i < rectCount; i++) - { - SkRect r(m_rings[i]); - SkIRect ir; - - r.round(&ir); - ir.inset(-RING_OUTSET, -RING_OUTSET); - rgn.op(ir, SkRegion::kUnion_Op); - } - rgn.getBoundaryPath(&path); - - SkPaint paint; - paint.setAntiAlias(true); - paint.setPathEffect(new SkCornerPathEffect( - SkIntToScalar(RING_RADIUS)))->unref(); - SkColor outer; - SkColor inner; - if (m_isPressed) { - SkColor pressed; - pressed = ringFill; - paint.setColor(pressed); - canvas->drawPath(path, paint); - outer = ringPressedInner; - inner = ringPressedOuter; - } else { - outer = ringSelectedOuter; - inner = ringSelectedInner; - } - paint.setStyle(SkPaint::kStroke_Style); - paint.setStrokeWidth(RING_OUTER_WIDTH * WIDTH_SCALE); - paint.setColor(outer); - canvas->drawPath(path, paint); - paint.setStrokeWidth(RING_INNER_WIDTH * WIDTH_SCALE); - paint.setColor(inner); - canvas->drawPath(path, paint); - SkRect localBounds, globalBounds; - localBounds = path.getBounds(); - float width = std::max(RING_INNER_WIDTH, RING_OUTER_WIDTH); - width *= WIDTH_SCALE; - localBounds.inset(-width, -width); - const SkMatrix& matrix = canvas->getTotalMatrix(); - matrix.mapRect(&globalBounds, localBounds); - SkIRect globalIBounds; - globalBounds.round(&globalIBounds); - m_lastBounds = globalIBounds; - inval->unite(m_lastBounds); -} - -void CursorRing::setIsButton(const CachedNode* node) -{ - m_isButton = false; -} - -bool CursorRing::setup() -{ - m_layerId = -1; - if (m_frame && m_root) { - const CachedLayer* cachedLayer = m_frame->layer(m_node); - if (cachedLayer) { - const WebCore::LayerAndroid* rootLayer = m_root->rootLayer(); - const LayerAndroid* aLayer = cachedLayer->layer(rootLayer); - if (aLayer) - m_layerId = aLayer->uniqueId(); - } - } - if (m_layerId == -1) - m_node->cursorRings(m_frame, &m_rings); - else - m_node->localCursorRings(m_frame, &m_rings); - - if (!m_rings.size()) { - DBG_NAV_LOG("!rings.size()"); - m_viewImpl->m_hasCursorBounds = false; - return false; - } - - setIsButton(m_node); - m_bounds = m_node->bounds(m_frame); - m_viewImpl->updateCursorBounds(m_root, m_frame, m_node); - - bool useHitBounds = m_node->useHitBounds(); - if (useHitBounds) - m_bounds = m_node->hitBounds(m_frame); - if (useHitBounds || m_node->useBounds()) { - m_rings.clear(); - m_rings.append(m_bounds); - } - m_absBounds = m_node->bounds(m_frame); - m_bounds.inflate(SkScalarCeil(RING_OUTER_WIDTH)); - m_absBounds.inflate(SkScalarCeil(RING_OUTER_WIDTH)); - if (!m_node->hasCursorRing() || (m_node->isPlugin() && m_node->isFocus())) - return false; -#if DEBUG_NAV_UI - const WebCore::IntRect& ring = m_rings[0]; - DBG_NAV_LOGD("cursorNode=%d (nodePointer=%p) pressed=%s rings=%d" - " (%d, %d, %d, %d) isPlugin=%s", - m_node->index(), m_node->nodePointer(), - m_isPressed ? "true" : "false", - m_rings.size(), ring.x(), ring.y(), ring.width(), ring.height(), - m_node->isPlugin() ? "true" : "false"); -#endif - return true; -} - -} diff --git a/Source/WebCore/platform/graphics/android/android_graphics.h b/Source/WebCore/platform/graphics/android/android_graphics.h index 68207d7..7faa781 100644 --- a/Source/WebCore/platform/graphics/android/android_graphics.h +++ b/Source/WebCore/platform/graphics/android/android_graphics.h @@ -26,55 +26,17 @@ #ifndef android_graphics_DEFINED #define android_graphics_DEFINED -#include "DrawExtra.h" -#include "IntRect.h" -#include "SkTypes.h" -#include "wtf/Vector.h" - namespace WebCore { class GraphicsContext; - class GLExtras; } +class SkCanvas; -SkCanvas* android_gc2canvas(GraphicsContext* gc); - -namespace android { - -class CachedFrame; -class CachedNode; -class CachedRoot; -class WebViewCore; - -// Data and methods for cursor rings +// TODO: Move this somewhere else. The implementation for this is actually in +// GraphicsContextAndroid.cpp, but this is used by a handful of other files +SkCanvas* android_gc2canvas(WebCore::GraphicsContext* gc); // used to inflate node cache entry #define CURSOR_RING_HIT_TEST_RADIUS 5 -class CursorRing : public DrawExtra { -public: - CursorRing(WebViewCore* core); - virtual ~CursorRing() {} - virtual void drawLegacy(SkCanvas* , LayerAndroid* , IntRect* ); - void setIsButton(const CachedNode* ); - bool setup(); - WTF::Vector<IntRect>& rings() { return m_rings; } - int layerId() const { return m_layerId; } -private: - friend class WebView; - friend class WebCore::GLExtras; - WebViewCore* m_viewImpl; // copy for convenience - WTF::Vector<IntRect> m_rings; - IntRect m_bounds; - IntRect m_absBounds; - IntRect m_lastBounds; - const CachedRoot* m_root; - const CachedFrame* m_frame; - const CachedNode* m_node; - bool m_isButton; - bool m_isPressed; - int m_layerId; -}; - -} #endif diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp index 0932224..66aab18 100644 --- a/Source/WebCore/rendering/RenderLayer.cpp +++ b/Source/WebCore/rendering/RenderLayer.cpp @@ -1390,11 +1390,27 @@ void RenderLayer::scrollTo(int x, int y) view->updateWidgetPositions(); } +#if PLATFORM(ANDROID) + GraphicsLayerAndroid* backingLayer = 0; + bool scrollableContent = false; +#endif + #if USE(ACCELERATED_COMPOSITING) if (compositor()->inCompositingMode()) { // Our stacking context is guaranteed to contain all of our descendants that may need // repositioning, so update compositing layers from there. +#if ENABLE(ANDROID_OVERFLOW_SCROLL) + if (view && backing() && backing()->graphicsLayer()) { + backingLayer = static_cast<GraphicsLayerAndroid*>(backing()->graphicsLayer()); + scrollableContent = backingLayer->contentLayer() + && backingLayer->contentLayer()->contentIsScrollable(); + } + // If we have a scrollable content, no need to do this + RenderLayer* compositingAncestor = enclosingCompositingLayer(); + if (!scrollableContent && compositingAncestor) { +#else if (RenderLayer* compositingAncestor = stackingContext()->enclosingCompositingLayer()) { +#endif if (compositor()->compositingConsultsOverlap()) compositor()->updateCompositingLayers(CompositingUpdateOnScroll, compositingAncestor); else { @@ -1423,10 +1439,10 @@ void RenderLayer::scrollTo(int x, int y) #if ENABLE(ANDROID_OVERFLOW_SCROLL) // On android, scrollable areas are put on composited layers, so we // do not need to repaint simply because we are scrolling - if (view && !hasOverflowScroll()) + if (view && !(hasOverflowScroll() || scrollableContent)) renderer()->repaintUsingContainer(repaintContainer, rectForRepaint); - if (view && hasOverflowScroll() && backing() && backing()->graphicsLayer()) - static_cast<GraphicsLayerAndroid*>(backing()->graphicsLayer())->updateScrollOffset(); + if (backingLayer && (hasOverflowScroll() || scrollableContent)) + backingLayer->updateScrollOffset(); #else if (view) renderer()->repaintUsingContainer(repaintContainer, rectForRepaint); diff --git a/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp index 8eb379a..b684a1a 100644 --- a/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -35,13 +35,15 @@ #include "KeyGeneratorClient.h" #include "MemoryUsage.h" #include "PluginView.h" +#include "RenderLayer.h" +#include "RenderView.h" #include "Settings.h" #include "WebCookieJar.h" #include "WebRequestContext.h" #include "WebViewCore.h" #include "npruntime.h" -#include <surfaceflinger/SurfaceComposerClient.h> +#include <gui/SurfaceComposerClient.h> #include <ui/DisplayInfo.h> #include <ui/PixelFormat.h> #include <wtf/android/AndroidThreading.h> @@ -171,6 +173,16 @@ void PlatformBridge::setScrollPosition(ScrollView* scrollView, int x, int y) { android::WebViewCore *webViewCore = android::WebViewCore::getWebViewCore(scrollView); if (webViewCore->mainFrame()->view() == scrollView) webViewCore->scrollTo(x, y); + else { + FrameView* frameView = scrollView->frameView(); + if (frameView) { + RenderView* renderer = frameView->frame()->contentRenderer(); + if (renderer) { + RenderLayer* layer = renderer->layer(); + layer->scrollToOffset(x, y); + } + } + } } int PlatformBridge::lowMemoryUsageMB() diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 31e8506..b9a21de 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -4161,8 +4161,7 @@ void WebViewCore::scrollRenderLayer(int layer, const SkRect& rect) if (!owner) return; - if (owner->stackingContext()) - owner->scrollToOffset(rect.fLeft, rect.fTop); + owner->scrollToOffset(rect.fLeft, rect.fTop); #endif } diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 7919fdd..3abdd26 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -144,9 +144,8 @@ struct JavaGlue { } m_javaGlue; WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir, - bool isHighEndGfx) : - m_ring((WebViewCore*) viewImpl) - , m_isHighEndGfx(isHighEndGfx) + bool isHighEndGfx) + : m_isHighEndGfx(isHighEndGfx) { memset(m_extras, 0, DRAW_EXTRAS_SIZE * sizeof(DrawExtra*)); jclass clazz = env->FindClass("android/webkit/WebView"); @@ -193,7 +192,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir, m_heightCanMeasure = false; m_lastDx = 0; m_lastDxTime = 0; - m_ringAnimationEnd = 0; m_baseLayer = 0; m_glDrawFunctor = 0; m_isDrawingPaused = false; @@ -230,33 +228,6 @@ DrawExtra* getDrawExtra(DrawExtras extras) return m_extras[extras - 1]; } -DrawExtra* getDrawExtraLegacy(DrawExtras extras) -{ - CachedRoot* root = getFrameCache(AllowNewer); - if (!root) { - DBG_NAV_LOG("!root"); - if (extras == DrawExtrasCursorRing) - resetCursorRing(); - } - DrawExtra* extra = getDrawExtra(extras); - if (!extra) { - switch (extras) { - case DrawExtrasCursorRing: - if (drawCursorPreamble(root) && m_ring.setup()) { - if (m_ring.m_isPressed || m_ringAnimationEnd == UINT_MAX) - extra = &m_ring; - drawCursorPostamble(); - } - break; - // Just to prevent compiler warnings - case DrawExtrasSelection: - case DrawExtrasNone: - break; - } - } - return extra; -} - void stopGL() { #if USE(ACCELERATED_COMPOSITING) @@ -335,60 +306,6 @@ void scrollRectOnScreen(const IntRect& rect) viewInvalidate(); } -void resetCursorRing() -{ - m_ringAnimationEnd = 0; - m_viewImpl->m_hasCursorBounds = false; -} - -bool drawCursorPreamble(CachedRoot* root) -{ - if (!root) return false; - const CachedFrame* frame; - const CachedNode* node = root->currentCursor(&frame); - if (!node) { - DBG_NAV_LOGV("%s", "!node"); - resetCursorRing(); - return false; - } - m_ring.setIsButton(node); - if (node->isHidden()) { - DBG_NAV_LOG("node->isHidden()"); - m_viewImpl->m_hasCursorBounds = false; - return false; - } -#if USE(ACCELERATED_COMPOSITING) - if (node->isInLayer() && root->rootLayer()) { - LayerAndroid* layer = root->rootLayer(); - layer->updateFixedLayersPositions(m_visibleRect); - layer->updatePositions(); - } -#endif - setVisibleRect(root); - m_ring.m_root = root; - m_ring.m_frame = frame; - m_ring.m_node = node; - SkMSec time = SkTime::GetMSecs(); - m_ring.m_isPressed = time < m_ringAnimationEnd - && m_ringAnimationEnd != UINT_MAX; - return true; -} - -void drawCursorPostamble() -{ - if (m_ringAnimationEnd == UINT_MAX) - return; - SkMSec time = SkTime::GetMSecs(); - if (time < m_ringAnimationEnd) { - // views assume that inval bounds coordinates are non-negative - WebCore::IntRect invalBounds(0, 0, INT_MAX, INT_MAX); - invalBounds.intersect(m_ring.m_absBounds); - postInvalidateDelayed(m_ringAnimationEnd - time, invalBounds); - } else { - hideCursor(const_cast<CachedRoot*>(m_ring.m_root)); - } -} - bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::IntRect& webViewRect, int titleBarHeight, WebCore::IntRect& clip, float scale, int extras) @@ -400,7 +317,6 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, if (!m_glWebViewState) { TilesManager::instance()->setHighEndGfx(m_isHighEndGfx); m_glWebViewState = new GLWebViewState(); - m_glWebViewState->glExtras()->setCursorRingExtra(&m_ring); if (m_baseLayer->content()) { SkRegion region; SkIRect rect; @@ -411,7 +327,7 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, } } - DrawExtra* extra = getDrawExtraLegacy((DrawExtras) extras); + DrawExtra* extra = getDrawExtra((DrawExtras) extras); unsigned int pic = m_glWebViewState->currentPictureCounter(); m_glWebViewState->glExtras()->setDrawExtra(extra); @@ -459,7 +375,7 @@ PictureSet* draw(SkCanvas* canvas, SkColor bgColor, DrawExtras extras, bool spli if (content->draw(canvas)) ret = split ? new PictureSet(*content) : 0; - DrawExtra* extra = getDrawExtraLegacy(extras); + DrawExtra* extra = getDrawExtra(extras); if (extra) extra->draw(canvas, 0); @@ -778,7 +694,6 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll) } bool result = false; if (cachedNode) { - showCursorUntimed(); m_viewImpl->updateCursorBounds(root, cachedFrame, cachedNode); root->setCursor(const_cast<CachedFrame*>(cachedFrame), const_cast<CachedNode*>(cachedNode)); @@ -860,7 +775,6 @@ void selectBestAt(const WebCore::IntRect& rect) WebCore::IntRect bounds = node->bounds(frame); root->rootHistory()->setMouseBounds(bounds); m_viewImpl->updateCursorBounds(root, frame, node); - showCursorTimed(); root->setCursor(const_cast<CachedFrame*>(frame), const_cast<CachedNode*>(node)); } @@ -921,11 +835,6 @@ bool motionUp(int x, int y, int slop) (WebCore::Frame*) frame->framePointer(), (WebCore::Node*) result->nodePointer(), rx, ry); } - if (result->isTextInput() || result->isSelect() - || result->isContentEditable()) { - showCursorUntimed(); - } else - showCursorTimed(); return pageScrolled; } @@ -1012,21 +921,6 @@ void setFindIsUp(bool up) m_viewImpl->m_findIsUp = up; } -void showCursorTimed() -{ - DBG_NAV_LOG(""); - m_ringAnimationEnd = SkTime::GetMSecs() + PRESSED_STATE_DURATION; - viewInvalidate(); -} - -void showCursorUntimed() -{ - DBG_NAV_LOG(""); - m_ring.m_isPressed = false; - m_ringAnimationEnd = UINT_MAX; - viewInvalidate(); -} - void setHeightCanMeasure(bool measure) { m_heightCanMeasure = measure; @@ -1324,12 +1218,10 @@ private: // local state for WebView CachedRoot* m_frameCacheUI; // navigation data ready for use WebViewCore* m_viewImpl; int m_generation; // associate unique ID with sent kit focus to match with ui - SkMSec m_ringAnimationEnd; // Corresponds to the same-named boolean on the java side. bool m_heightCanMeasure; int m_lastDx; SkMSec m_lastDxTime; - CursorRing m_ring; DrawExtra* m_extras[DRAW_EXTRAS_SIZE]; BaseLayerAndroid* m_baseLayer; Functor* m_glDrawFunctor; @@ -1943,12 +1835,6 @@ static void nativeSelectBestAt(JNIEnv *env, jobject obj, jobject jrect) static void nativeSelectAt(JNIEnv *env, jobject obj, jint x, jint y) { - WebView* view = GET_NATIVE_VIEW(env, obj); - ALOG_ASSERT(view, "view not set in %s", __FUNCTION__); - WebCore::IntRect rect = IntRect(x, y , 1, 1); - view->selectBestAt(rect); - if (view->hasCursorNode()) - view->showCursorUntimed(); } static jobject nativeLayerBounds(JNIEnv* env, jobject obj, jint jlayer) @@ -2039,7 +1925,6 @@ static void nativeSetFindIsUp(JNIEnv *env, jobject obj, jboolean isUp) static void nativeShowCursorTimed(JNIEnv *env, jobject obj) { - GET_NATIVE_VIEW(env, obj)->showCursorTimed(); } static void nativeSetHeightCanMeasure(JNIEnv *env, jobject obj, bool measure) @@ -2122,7 +2007,6 @@ static bool nativeMoveCursorToNextTextInput(JNIEnv *env, jobject obj) const WebCore::IntRect& bounds = next->bounds(frame); root->rootHistory()->setMouseBounds(bounds); view->getWebViewCore()->updateCursorBounds(root, frame, next); - view->showCursorUntimed(); root->setCursor(const_cast<CachedFrame*>(frame), const_cast<CachedNode*>(next)); view->sendMoveFocus(static_cast<WebCore::Frame*>(frame->framePointer()), diff --git a/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp b/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp index 4b99b31..513d251 100644 --- a/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp +++ b/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp @@ -32,7 +32,7 @@ #include "SkANP.h" #include "android_graphics.h" #include <JNIUtility.h> -#include <surfaceflinger/Surface.h> +#include <gui/Surface.h> #include <ui/Rect.h> #include <ui/Region.h> #include <utils/RefBase.h> |