diff options
author | John Reck <jreck@google.com> | 2012-02-27 13:18:06 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-27 13:18:06 -0800 |
commit | 5015ffe477809860e6a9e05779afb1855aa994f2 (patch) | |
tree | fd73a65b78b8845d225d812bf71e5fd9e0ff516b /Source | |
parent | 9f6ce052a4112e9ffe56da94153c89e841219be4 (diff) | |
parent | 39b886463564843ebfd0557dd12b07bf38cb6d83 (diff) | |
download | external_webkit-5015ffe477809860e6a9e05779afb1855aa994f2.zip external_webkit-5015ffe477809860e6a9e05779afb1855aa994f2.tar.gz external_webkit-5015ffe477809860e6a9e05779afb1855aa994f2.tar.bz2 |
Merge "Delete CursorRing"
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebCore/Android.mk | 1 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/GLExtras.cpp | 33 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/GLExtras.h | 7 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/android_graphics.cpp | 185 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/android_graphics.h | 46 | ||||
-rw-r--r-- | Source/WebKit/android/nav/WebView.cpp | 124 |
6 files changed, 11 insertions, 385 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/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/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/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 9e3c094..162d6bd 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()), |