OSDN Git Service

Fix issue where solid was drawn instead of ring
authorJohn Reck <jreck@google.com>
Thu, 5 May 2011 23:16:52 +0000 (16:16 -0700)
committerJohn Reck <jreck@google.com>
Fri, 6 May 2011 00:04:12 +0000 (17:04 -0700)
 Bug: 4283275

Change-Id: Ie05440e3618ffa36004af35fed3d350763f09d50

WebCore/platform/graphics/android/GLWebViewState.cpp
WebCore/platform/graphics/android/GLWebViewState.h
WebKit/android/nav/WebView.cpp

index 74f03f5..4acd563 100644 (file)
@@ -159,11 +159,12 @@ void GLWebViewState::setBaseLayer(BaseLayerAndroid* layer, const SkRegion& inval
     TilesManager::instance()->setShowVisualIndicator(showVisualIndicator);
 }
 
-void GLWebViewState::setRings(Vector<IntRect>& rings)
+void GLWebViewState::setRings(Vector<IntRect>& rings, bool isPressed)
 {
     android::Mutex::Autolock lock(m_baseLayerLock);
     m_displayRings = true;
     m_rings = rings;
+    m_ringsIsPressed = isPressed;
 }
 
 void GLWebViewState::invalRegion(const SkRegion& region)
@@ -241,16 +242,22 @@ void GLWebViewState::drawFocusRing(IntRect& srcRect)
 {
     // TODO: use a 9-patch texture to draw the focus ring
     // instead of plain colors
-    const int border = 1;
-    const int fuzzyBorder = border * 2;
-    const int padding = 4;
     const float alpha = 0.3;
-    const float borderAlpha = 0.40;
+    float borderAlpha = 0.40;
 
     const int r = 104;
     const int g = 153;
     const int b = 255;
 
+    int padding = 4;
+    int border = 1;
+    int fuzzyBorder = border * 2;
+    if (!m_ringsIsPressed) {
+        padding = 0;
+        border = 2;
+        fuzzyBorder = 3;
+        borderAlpha = 0.2;
+    }
     if (m_focusRingTexture == -1)
         m_focusRingTexture = GLUtils::createSampleColorTexture(r, g, b);
 
@@ -276,7 +283,24 @@ void GLWebViewState::drawFocusRing(IntRect& srcRect)
     TilesManager::instance()->shader()->drawQuad(rTop, m_focusRingTexture, borderAlpha);
     TilesManager::instance()->shader()->drawQuad(rRight, m_focusRingTexture, borderAlpha);
     TilesManager::instance()->shader()->drawQuad(rBottom, m_focusRingTexture, borderAlpha);
-    TilesManager::instance()->shader()->drawQuad(rOverlay, m_focusRingTexture, alpha);
+    if (m_ringsIsPressed) {
+        TilesManager::instance()->shader()->drawQuad(rOverlay, m_focusRingTexture, alpha);
+    } else {
+        rLeft.set(rect.x() - fuzzyBorder, rect.y(),
+                  rect.x(), rect.y() + rect.height());
+        rTop.set(rect.x() - fuzzyBorder, rect.y() - fuzzyBorder,
+                 rect.x() + rect.width() + fuzzyBorder, rect.y());
+        rRight.set(rect.x() + rect.width(), rect.y(),
+                   rect.x() + rect.width() + fuzzyBorder,
+                   rect.y() + rect.height());
+        rBottom.set(rect.x() - fuzzyBorder, rect.y() + rect.height(),
+                    rect.x() + rect.width() + fuzzyBorder,
+                    rect.y() + rect.height() + fuzzyBorder);
+        TilesManager::instance()->shader()->drawQuad(rLeft, m_focusRingTexture, alpha);
+        TilesManager::instance()->shader()->drawQuad(rTop, m_focusRingTexture, alpha);
+        TilesManager::instance()->shader()->drawQuad(rRight, m_focusRingTexture, alpha);
+        TilesManager::instance()->shader()->drawQuad(rBottom, m_focusRingTexture, alpha);
+    }
 }
 
 void GLWebViewState::paintExtras()
index 7892337..980dd3c 100644 (file)
@@ -181,7 +181,7 @@ public:
     void scheduleUpdate(const double& currentTime, const SkIRect& viewport, float scale);
     void paintExtras();
 
-    void setRings(Vector<IntRect>& rings);
+    void setRings(Vector<IntRect>& rings, bool isPressed);
     void resetRings();
     void drawFocusRing(IntRect& rect);
 
@@ -290,6 +290,7 @@ private:
 #endif
     bool m_displayRings;
     Vector<IntRect> m_rings;
+    bool m_ringsIsPressed;
     int m_focusRingTexture;
 };
 
index f4f8ce0..610a29d 100644 (file)
@@ -488,7 +488,7 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::In
     m_glWebViewState->resetRings();
     if (extra) {
         if (extra == &m_ring) {
-            m_glWebViewState->setRings(m_ring.rings());
+            m_glWebViewState->setRings(m_ring.rings(), m_ring.m_isPressed);
         } else {
             LayerAndroid mainPicture(m_navPictureUI);
             PictureSet* content = m_baseLayer->content();