diff options
author | Victoria Lease <violets@google.com> | 2012-01-12 16:08:51 -0800 |
---|---|---|
committer | Victoria Lease <violets@google.com> | 2012-01-13 13:36:45 -0800 |
commit | 5ce1aad01a972e0d333ad599a2117a2cdf981221 (patch) | |
tree | 29b6d144f5f33f1b0b8881a34faafe0c28a3368b /Source/WebCore/platform/graphics/android | |
parent | ba81e047f713341871d6c084845963bfdc1d4aa2 (diff) | |
download | external_webkit-5ce1aad01a972e0d333ad599a2117a2cdf981221.zip external_webkit-5ce1aad01a972e0d333ad599a2117a2cdf981221.tar.gz external_webkit-5ce1aad01a972e0d333ad599a2117a2cdf981221.tar.bz2 |
Only draw cursor rings once.
Bug: 5853891
Drawing GLExtras for each layer might have fixed MatchInfo positions, but has
had the side-effect of causing cursor rings to be drawn once per layer,
resulting in multiple cursor rings being drawn when links are clicked. Oops!
Making certain that cursor rings are only drawn when GLExtras are rendering
the correct layer addresses this issue.
This has a side-effect of rendering cursor rings in the correct position when
layers have been scrolled, which was not hapening before this change. Bonus!
Change-Id: Ie55e132dddd5b420b1738aa6049229996083008a
Diffstat (limited to 'Source/WebCore/platform/graphics/android')
3 files changed, 29 insertions, 2 deletions
diff --git a/Source/WebCore/platform/graphics/android/GLExtras.cpp b/Source/WebCore/platform/graphics/android/GLExtras.cpp index bf489c9..9ad369a 100644 --- a/Source/WebCore/platform/graphics/android/GLExtras.cpp +++ b/Source/WebCore/platform/graphics/android/GLExtras.cpp @@ -165,6 +165,10 @@ void GLExtras::drawRegion(const SkRegion& region, bool fill, 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); diff --git a/Source/WebCore/platform/graphics/android/android_graphics.cpp b/Source/WebCore/platform/graphics/android/android_graphics.cpp index e88c65d..57f1b41 100644 --- a/Source/WebCore/platform/graphics/android/android_graphics.cpp +++ b/Source/WebCore/platform/graphics/android/android_graphics.cpp @@ -37,6 +37,12 @@ namespace android { +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 @@ -116,12 +122,27 @@ void CursorRing::setIsButton(const CachedNode* node) bool CursorRing::setup() { - m_node->cursorRings(m_frame, &m_rings); + 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); diff --git a/Source/WebCore/platform/graphics/android/android_graphics.h b/Source/WebCore/platform/graphics/android/android_graphics.h index 60ac115..bd08a6e 100644 --- a/Source/WebCore/platform/graphics/android/android_graphics.h +++ b/Source/WebCore/platform/graphics/android/android_graphics.h @@ -52,12 +52,13 @@ class WebViewCore; class CursorRing : public DrawExtra { public: - CursorRing(WebViewCore* core) : m_viewImpl(core) {} + CursorRing(WebViewCore* core); virtual ~CursorRing() {} virtual void draw(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; @@ -71,6 +72,7 @@ private: const CachedNode* m_node; bool m_isButton; bool m_isPressed; + int m_layerId; }; } |