From feca943a276356e17b6a7442996ce6a6d8cff4bd Mon Sep 17 00:00:00 2001 From: Manish R Gurnaney Date: Tue, 25 Jun 2013 20:00:27 +0530 Subject: [PATCH] Whole block area is highlighted instead of only Selected option. [Title] Whole block area is highlighted instead of only Selected option. [Issue#] P130612-3611, P130612-3538, P130615-1146, WEB-3182 [Problem] Header element is shown as Focused element [Cause] Header element has been regisetered with click-event listener in the page content. [Solution] We will be checking two conditions here If the FocusRect is too big then we don't show focus ring. Second to see focused parent should not have any child which is focusable. Change-Id: I8e690bb817c160698ecd498d094b810591aec3f3 --- .../WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp | 66 +++++++++++++++++----- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp b/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp index 37b51cd..f74b956 100755 --- a/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp +++ b/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp @@ -900,6 +900,33 @@ static IntRect getNodeRect(Node* node, Node* focusableNode, bool isImage) #if ENABLE(TIZEN_WEBKIT2_HIT_TEST) #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING) #if ENABLE(TOUCH_ADJUSTMENT) +static bool isClickableOrFocusable(Node* focusableNode) +{ + + if (!focusableNode) + return false; + if (focusableNode->disabled()) + return false; + if (!focusableNode->inDocument()) + return false; + if (!focusableNode->renderer() || focusableNode->renderer()->style()->visibility() != VISIBLE) + return false; + if (focusableNode->isFocusable()) { + if (focusableNode->isLink() + || focusableNode->hasTagName(HTMLNames::inputTag) + || focusableNode->hasTagName(HTMLNames::selectTag) + || focusableNode->hasTagName(HTMLNames::buttonTag)) + return true; + } + if (focusableNode->supportsFocus() + || focusableNode->hasEventListeners(eventNames().clickEvent) + || focusableNode->hasEventListeners(eventNames().mousedownEvent) + || focusableNode->hasEventListeners(eventNames().mouseupEvent)) { + return true; + } + return false; +} + static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page, const IntPoint& point, const IntSize& area) #else static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page) @@ -910,7 +937,8 @@ static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page) Node* adjustedNode = 0; IntPoint adustedPoint; Frame* mainFrame = page->mainFrame(); - mainFrame->eventHandler()->bestClickableNodeForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), adustedPoint, adjustedNode); + if (!isClickableOrFocusable(node)) + mainFrame->eventHandler()->bestClickableNodeForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), adustedPoint, adjustedNode); if (adjustedNode) node = adjustedNode; @@ -925,19 +953,7 @@ static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page) if (renderer && (renderer->isBody() || renderer->isRenderView() || renderer->isRoot())) break; - if (focusableNode->isFocusable()) { - if (focusableNode->isLink() - || focusableNode->hasTagName(HTMLNames::inputTag) - || focusableNode->hasTagName(HTMLNames::selectTag) - || focusableNode->hasTagName(HTMLNames::buttonTag)) - isFocusRingDrawable = true; - break; - } - - if (focusableNode->supportsFocus() - || focusableNode->hasEventListeners(eventNames().clickEvent) - || focusableNode->hasEventListeners(eventNames().mousedownEvent) - || focusableNode->hasEventListeners(eventNames().mouseupEvent)) { + if (isClickableOrFocusable(focusableNode)) { isFocusRingDrawable = true; break; } @@ -945,6 +961,20 @@ static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page) focusableNode = focusableNode->parentNode(); } + // Don't draw focus ring if child is focusable or has trigger + if (focusableNode && focusableNode->isContainerNode() && !focusableNode->isLink()) { + WebCore::Node *child = static_cast(focusableNode)->firstChild(); + while(child) { + if( child->supportsFocus() + || child->hasEventListeners(eventNames().clickEvent) + || child->hasEventListeners(eventNames().mousedownEvent) + || child->hasEventListeners(eventNames().mouseupEvent)) { + return IntRect(); + } + child = child->traverseNextNode(focusableNode); + } + } + if (!isFocusRingDrawable) { if (node->hasTagName(HTMLNames::imgTag)) return getNodeRect(node, node, !hitTestResult.absoluteImageURL().isEmpty()); @@ -1002,6 +1032,14 @@ void WebPage::hitTestResultAtPoint(const IntPoint& point, int hitTestMode, WebHi #else hitTestResultData.focusedRect = getFocusedRect(hitTestResult, m_page.get()); #endif + + // Don't display FocusRect if the size is too big.. + IntRect framerect = frameView->visibleContentRect(true); + if (hitTestResultData.focusedRect.width() > (0.8 * framerect.width()) + && hitTestResultData.focusedRect.height() > (0.8 * framerect.height())) { + hitTestResultData.focusedRect = IntRect(); + } + if (hitTestResult.innerNode() && hitTestResult.innerNode()->renderer() && hitTestResult.innerNode()->renderer()->style()) { hitTestResultData.focusedColor = hitTestResult.innerNode()->renderer()->style()->tapHighlightColor(); if (!hitTestResultData.focusedColor.hasAlpha()) -- 2.7.4