Fixed focus ring is wrong.
authorYuni Jeong <yhnet.jung@samsung.com>
Thu, 12 Sep 2013 13:01:05 +0000 (22:01 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Fri, 13 Sep 2013 05:00:32 +0000 (05:00 +0000)
[Title] Fixed focus ring is wrong.
[Issue#] P130911-00115
[Problem] Focus ring is wrong.
[Cause] Area to display focus ring is not correct.
[Solution] changed area to display focus ring.

Change-Id: Ie4abe2621bf718ef85f6a0edc513df47761b4e80

Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/tizen/FocusRing.cpp
Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp

index 571773f..97bf48a 100755 (executable)
@@ -414,18 +414,17 @@ static Eina_Bool _ewk_view_smart_gesture_start(Ewk_View_Smart_Data* smartData, c
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
     FocusRing* focusRing = impl->focusRing();
     if (focusRing) {
-        if (event->type == EWK_GESTURE_TAP && event->count == 1) {
-            focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
+        if (event->type == EWK_GESTURE_TAP) {
+            if (event->count == 1)
+                focusRing->requestToShow(IntPoint(event->position.x, event->position.y));
         } else if (event->type == EWK_GESTURE_PAN) {
             if (impl->exceedTouchMoveThreshold)
                 focusRing->requestToHide();
-        } else {
-            if (event->type != EWK_GESTURE_LONG_PRESS) {
+        } else if (event->type != EWK_GESTURE_LONG_PRESS) {
 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
-                if (!impl->pageClient->isContextMenuVisible())
+            if (!impl->pageClient->isContextMenuVisible())
 #endif
-                    focusRing->requestToHide();
-            }
+                focusRing->requestToHide();
         }
     }
 #endif
index abed805..31daf1f 100755 (executable)
@@ -93,7 +93,8 @@ void FocusRing::requestToShow(const IntPoint& position, bool immediately)
         if (m_showTimer) {
             ecore_timer_del(m_showTimer);
             m_showTimer = 0;
-        }
+        } else
+            return;
 
         m_position = position;
 
index abee5f5..0468bdb 100755 (executable)
@@ -1781,37 +1781,43 @@ void WebPage::calcFocusedRects(Node* node, Vector<IntRect>& rects) const
 
     RenderObject* renderer = node->renderer();
     FrameView* view = node->document()->frame()->view();
-
-    IntPoint absolutePoint;
-    absolutePoint = view->convertToContainingWindow(view->convertFromRenderer(renderer, absolutePoint));
-    renderer->addFocusRingRects(rects, absolutePoint);
-
-    if (!rects.isEmpty())
-        return;
-
     LayoutRect rect;
+
     if (node->hasTagName(HTMLNames::areaTag)) {
         HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node);
         HTMLImageElement* image = area->imageElement();
-        if (!image || !image->renderer())
-            return;
-
-        rect = rectToAbsoluteCoordinates(area->document()->frame(), area->computeRect(area->imageElement()->renderer()));
+        if (image && image->renderer())
+            rect = rectToAbsoluteCoordinates(area->document()->frame(), area->computeRect(area->imageElement()->renderer()));
     } else if (node->renderer()) {
         if (node->isDocumentNode())
             rect = rectToAbsoluteCoordinates(static_cast<Document*>(node)->frame(), static_cast<Document*>(node)->frame()->view()->visibleContentRect());
-        else {
-            rect = node->getRect();
-            rect.intersect(node->renderer()->absoluteClippedOverflowRect());
-            rect = rectToAbsoluteCoordinates(node->document()->frame(), rect);
+        else
+            rect = rectToAbsoluteCoordinates(node->document()->frame(), node->renderer()->absoluteClippedOverflowRect());
+    }
 
-            rect.move(node->renderer()->style()->borderLeftWidth(), node->renderer()->style()->borderTopWidth());
-            rect.setWidth(rect.width() - node->renderer()->style()->borderLeftWidth() - node->renderer()->style()->borderRightWidth());
-            rect.setHeight(rect.height() - node->renderer()->style()->borderTopWidth() - node->renderer()->style()->borderBottomWidth());
-        }
+    if (rect.pixelSnappedX() < 0)
+        rect.shiftXEdgeTo(0);
+    if (rect.pixelSnappedY() < 0)
+        rect.shiftYEdgeTo(0);
+
+    if (rect.isEmpty())
+        return;
+
+    IntRect focusedNodeRect(pixelSnappedIntRect(rect));
+    IntPoint absolutePoint;
+    absolutePoint = view->convertToContainingWindow(view->convertFromRenderer(renderer, absolutePoint));
+    Vector<IntRect> candidateRects;
+    renderer->addFocusRingRects(candidateRects, absolutePoint);
+
+    for (size_t i = 0; i < candidateRects.size(); ++i) {
+        IntRect candidate(candidateRects[i]);
+        candidate.intersect(focusedNodeRect);
+        if (!candidate.isEmpty())
+            rects.append(candidate);
     }
 
-    rects.append(pixelSnappedIntRect(rect));
+    if (rects.isEmpty())
+        rects.append(focusedNodeRect);
 }
 #endif