Changeset 140282 in webkit


Ignore:
Timestamp:
Jan 20, 2013 2:55:50 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] Improve Fatfinger phase.
https://bugs.webkit.org/show_bug.cgi?id=107403

Patch by Tiancheng Jiang <tijiang@rim.com> on 2013-01-20
Reviewed by Rob Buis.

RIM PR 219489
Internally reviewd by Mike Fenton & Gen Mak.

Treat ClickableByDefault and MadeClickableByTheWebpage elements as
same category. Avoid unnecessary nodes check step.

  • WebKitSupport/FatFingers.cpp:

(BlackBerry::WebKit::FatFingers::isElementClickable):
(BlackBerry::WebKit::FatFingers::FatFingers):
(BlackBerry::WebKit::FatFingers::findBestPoint):
(BlackBerry::WebKit::FatFingers::getNodesFromRect):

  • WebKitSupport/FatFingers.h:
Location:
trunk/Source/WebKit/blackberry
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/ChangeLog

    r140191 r140282  
     12013-01-20  Tiancheng Jiang  <tijiang@rim.com>
     2
     3        [BlackBerry] Improve Fatfinger phase.
     4        https://bugs.webkit.org/show_bug.cgi?id=107403
     5
     6        Reviewed by Rob Buis.
     7
     8        RIM PR 219489
     9        Internally reviewd by Mike Fenton & Gen Mak.
     10
     11        Treat ClickableByDefault and MadeClickableByTheWebpage elements as
     12        same category. Avoid unnecessary nodes check step.
     13
     14        * WebKitSupport/FatFingers.cpp:
     15        (BlackBerry::WebKit::FatFingers::isElementClickable):
     16        (BlackBerry::WebKit::FatFingers::FatFingers):
     17        (BlackBerry::WebKit::FatFingers::findBestPoint):
     18        (BlackBerry::WebKit::FatFingers::getNodesFromRect):
     19        * WebKitSupport/FatFingers.h:
     20
    1212013-01-18  Andrew Lo  <anlo@rim.com>
    2 
    322        [BlackBerry] When acquiring/releasing backing store memory, allow web page client control suspend/resuming of backing store
    423        https://bugs.webkit.org/show_bug.cgi?id=107307
  • trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.cpp

    r137991 r140282  
    8383{
    8484    ASSERT(element);
    85     ASSERT(m_matchingApproach != Done);
    8685    ASSERT(m_targetType == ClickableElement);
    8786
    88     switch (m_matchingApproach) {
    89     case ClickableByDefault: {
    90         ExceptionCode ec = 0;
    91         return element->webkitMatchesSelector("a[href],*:link,*:visited,*[role=button],button,input,select,label[for],area[href],textarea,embed,object", ec)
    92             || element->isMediaControlElement()
    93             || element->isContentEditable();
    94 
    95     }
    96     case MadeClickableByTheWebpage:
    97 
    98         // Elements within a shadow DOM can not be 'made clickable by the webpage', since
    99         // they are not accessible.
    100         if (element->isInShadowTree())
    101             return false;
    102 
    103         // FIXME: We fall back to checking for the presence of CSS style "cursor: pointer" to indicate whether the element A
    104         // can be clicked when A neither registers mouse events handlers nor is a hyperlink or form control. This workaround
    105         // ensures that we don't break various Google web apps, including <http://maps.google.com>. Ideally, we should walk
    106         // up the DOM hierarchy to determine the first parent element that accepts mouse events.
    107         // Consider the HTML snippet: <div id="A" onclick="..."><div id="B">Example</div></div>
    108         // Notice, B is not a hyperlink, or form control, and does not register any mouse event handler. Then B cannot
    109         // be clicked. Suppose B specified the CSS property "cursor: pointer". Then, B will be considered as clickable.
    110         return hasMousePressListener(element)
    111             || CSSComputedStyleDeclaration::create(element)->getPropertyValue(cssPropertyID("cursor")) == "pointer";
    112     default:
    113         ASSERT_NOT_REACHED();
    114     }
    115 
    116     return false;
     87    ExceptionCode ec = 0;
     88
     89    if (element->webkitMatchesSelector("a[href],*:link,*:visited,*[role=button],button,input,select,label[for],area[href],textarea,embed,object", ec)
     90        || element->isMediaControlElement()
     91        || element->isContentEditable())
     92        return true;
     93
     94    if (element->isInShadowTree())
     95        return false;
     96
     97    return hasMousePressListener(element)
     98        || CSSComputedStyleDeclaration::create(element)->getPropertyValue(cssPropertyID("cursor")) == "pointer";
    11799}
    118100
     
    151133    , m_contentPos(contentPos)
    152134    , m_targetType(targetType)
    153     , m_matchingApproach(Done)
    154135{
    155136    ASSERT(webPage);
     
    174155
    175156    FatFingersResult result(m_contentPos);
    176     m_matchingApproach = ClickableByDefault;
    177157
    178158    // Lets set nodeUnderFatFinger to the result of a point based hit test here. If something
     
    209189
    210190    bool foundOne = findIntersectingRegions(m_webPage->m_mainFrame->document(), intersectingRegions, remainingFingerRegion);
    211     if (!foundOne) {
    212         m_matchingApproach = MadeClickableByTheWebpage;
    213         remainingFingerRegion = IntRectRegion(fingerRectForPoint(m_contentPos));
    214         foundOne = findIntersectingRegions(m_webPage->m_mainFrame->document(), intersectingRegions, remainingFingerRegion);
    215     }
    216 
    217     m_matchingApproach = Done;
     191
    218192    m_cachedRectHitTestResults.clear();
    219193
     
    465439}
    466440
    467 FatFingers::CachedResultsStrategy FatFingers::cachingStrategy() const
    468 {
    469     switch (m_matchingApproach) {
    470     case ClickableByDefault:
    471         return GetFromRenderTree;
    472     case MadeClickableByTheWebpage:
    473         return GetFromCache;
    474     case Done:
    475     default:
    476         ASSERT_NOT_REACHED();
    477         return GetFromRenderTree;
    478     }
    479 }
    480 
    481441void FatFingers::getNodesFromRect(Document* document, const IntPoint& contentPos, ListHashSet<RefPtr<Node> >& intersectedNodes)
    482442{
    483     FatFingers::CachedResultsStrategy cacheResolvingStrategy = cachingStrategy();
    484 
    485     if (cacheResolvingStrategy == GetFromCache) {
    486         ASSERT(m_cachedRectHitTestResults.contains(document));
    487         intersectedNodes = m_cachedRectHitTestResults.get(document);
    488         return;
    489     }
    490 
    491     ASSERT(cacheResolvingStrategy == GetFromRenderTree);
    492 
    493443    unsigned topPadding, rightPadding, bottomPadding, leftPadding;
    494444    getPaddings(topPadding, rightPadding, bottomPadding, leftPadding);
  • trunk/Source/WebKit/blackberry/WebKitSupport/FatFingers.h

    r133902 r140282  
    7474
    7575    enum CachedResultsStrategy { GetFromRenderTree = 0, GetFromCache };
    76     CachedResultsStrategy cachingStrategy() const;
    7776    typedef HashMap<RefPtr<WebCore::Document>, ListHashSet<RefPtr<WebCore::Node> > > CachedRectHitTestResults;
    7877
     
    110109    WebCore::IntPoint m_contentPos;
    111110    TargetType m_targetType;
    112     MatchingApproachForClickable m_matchingApproach;
    113111    CachedRectHitTestResults m_cachedRectHitTestResults;
    114112};
Note: See TracChangeset for help on using the changeset viewer.