Changeset 153704 in webkit


Ignore:
Timestamp:
Aug 5, 2013 6:09:19 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Spatial Navigation should avoid unwanted calculation while deciding focus candidate.
https://bugs.webkit.org/show_bug.cgi?id=117265

Patch by Abhijeet Kandalkar <abhijeet.k@samsung.com> on 2013-08-05
Reviewed by Antonio Gomes.

Source/WebCore:

Spatial Navigation should consider only those nodes as candidate which are exactly in the focus-direction.
e.g. If we are moving down then the nodes that are above CURRENT focused node should be considered as invalid.
Added isValidCandidate() which checks whether node is exactly in the focus-direction.

Test: fast/spatial-navigation/snav-search-optimization.html

  • page/FocusController.cpp:

(WebCore::FocusController::findFocusCandidateInContainer):
(WebCore::FocusController::advanceFocusDirectionally):

  • page/Page.cpp:

(WebCore::Page::Page):

  • page/Page.h:

(WebCore::Page::setLastSpatialNavigationCandidateCount):
(WebCore::Page::lastSpatialNavigationCandidateCount):

  • page/SpatialNavigation.cpp:

(WebCore::isValidCandidate):

  • page/SpatialNavigation.h:
  • testing/Internals.cpp:

(WebCore::Internals::lastSpatialNavigationCandidateCount):

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

Added testcases to count how many target nodes were tested before choosing a final target.

  • fast/spatial-navigation/snav-search-optimization-expected.txt: Added.
  • fast/spatial-navigation/snav-search-optimization.html: Added.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r153702 r153704  
     12013-08-05  Abhijeet Kandalkar  <abhijeet.k@samsung.com>
     2
     3        Spatial Navigation should avoid unwanted calculation while deciding focus candidate.
     4        https://bugs.webkit.org/show_bug.cgi?id=117265
     5
     6        Reviewed by Antonio Gomes.
     7
     8        Added testcases to count how many target nodes were tested before choosing a final target.
     9
     10        * fast/spatial-navigation/snav-search-optimization-expected.txt: Added.
     11        * fast/spatial-navigation/snav-search-optimization.html: Added.
     12
    1132013-08-05  Mihai Tica  <mitica@adobe.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r153702 r153704  
     12013-08-05  Abhijeet Kandalkar  <abhijeet.k@samsung.com>
     2
     3        Spatial Navigation should avoid unwanted calculation while deciding focus candidate.
     4        https://bugs.webkit.org/show_bug.cgi?id=117265
     5
     6        Reviewed by Antonio Gomes.
     7
     8        Spatial Navigation should consider only those nodes as candidate which are exactly in the focus-direction.
     9        e.g. If we are moving down then the nodes that are above CURRENT focused node should be considered as invalid.
     10        Added isValidCandidate() which checks whether node is exactly in the focus-direction.
     11
     12        Test: fast/spatial-navigation/snav-search-optimization.html
     13
     14        * page/FocusController.cpp:
     15        (WebCore::FocusController::findFocusCandidateInContainer):
     16        (WebCore::FocusController::advanceFocusDirectionally):
     17        * page/Page.cpp:
     18        (WebCore::Page::Page):
     19        * page/Page.h:
     20        (WebCore::Page::setLastSpatialNavigationCandidateCount):
     21        (WebCore::Page::lastSpatialNavigationCandidateCount):
     22        * page/SpatialNavigation.cpp:
     23        (WebCore::isValidCandidate):
     24        * page/SpatialNavigation.h:
     25        * testing/Internals.cpp:
     26        (WebCore::Internals::lastSpatialNavigationCandidateCount):
     27        * testing/Internals.h:
     28        * testing/Internals.idl:
     29
    1302013-08-05  Mihai Tica  <mitica@adobe.com>
    231
  • trunk/Source/WebCore/page/FocusController.cpp

    r152218 r153704  
    767767    current.visibleNode = focusedNode;
    768768
     769    unsigned candidateCount = 0;
    769770    for (; element; element = (element->isFrameOwnerElement() || canScrollInDirection(element, direction))
    770771        ? ElementTraversal::nextSkippingChildren(element, container)
     
    780781            continue;
    781782
     783        if (!isValidCandidate(direction, current, candidate))
     784            continue;
     785
     786        candidateCount++;
    782787        candidate.enclosingScrollableBox = container;
    783788        updateFocusCandidateIfNeeded(direction, current, candidate, closest);
     789    }
     790
     791    // The variable 'candidateCount' keeps track of the number of nodes traversed in a given container.
     792    // If we have more than one container in a page then the total number of nodes traversed is equal to the sum of nodes traversed in each container.
     793    if (focusedFrame() && focusedFrame()->document()) {
     794        candidateCount += focusedFrame()->document()->page()->lastSpatialNavigationCandidateCount();
     795        focusedFrame()->document()->page()->setLastSpatialNavigationCandidateCount(candidateCount);
    784796    }
    785797}
     
    869881    if (container->isDocumentNode())
    870882        toDocument(container)->updateLayoutIgnorePendingStylesheets();
    871        
     883
    872884    // Figure out the starting rect.
    873885    LayoutRect startingRect;
     
    883895    }
    884896
     897    if (focusedFrame() && focusedFrame()->document())
     898        focusedDocument->page()->setLastSpatialNavigationCandidateCount(0);
     899
    885900    bool consumed = false;
    886901    do {
  • trunk/Source/WebCore/page/Page.cpp

    r153451 r153704  
    188188    , m_pageThrottler(PageThrottler::create(this))
    189189    , m_console(PageConsole::create(this))
     190    , m_lastSpatialNavigationCandidatesCount(0) // NOTE: Only called from Internals for Spatial Navigation testing.
    190191    , m_framesHandlingBeforeUnloadEvent(0)
    191192{
  • trunk/Source/WebCore/page/Page.h

    r152941 r153704  
    410410    void decrementFrameHandlingBeforeUnloadEventCount();
    411411    bool isAnyFrameHandlingBeforeUnloadEvent();
     412    void setLastSpatialNavigationCandidateCount(unsigned count) { m_lastSpatialNavigationCandidatesCount = count; }
     413    unsigned lastSpatialNavigationCandidateCount() const { return m_lastSpatialNavigationCandidatesCount; }
    412414
    413415private:
     
    547549    HashSet<String> m_seenPlugins;
    548550    HashSet<String> m_seenMediaEngines;
    549    
     551
     552    unsigned m_lastSpatialNavigationCandidatesCount;
    550553    unsigned m_framesHandlingBeforeUnloadEvent;
    551554};
  • trunk/Source/WebCore/page/SpatialNavigation.cpp

    r153469 r153704  
    621621}
    622622
     623// Consider only those nodes as candidate which are exactly in the focus-direction.
     624// e.g. If we are moving down then the nodes that are above current focused node should be considered as invalid.
     625bool isValidCandidate(FocusDirection direction, const FocusCandidate& current, FocusCandidate& candidate)
     626{
     627    LayoutRect currentRect = current.rect;
     628    LayoutRect candidateRect = candidate.rect;
     629
     630    switch (direction) {
     631    case FocusDirectionLeft:
     632        return candidateRect.x() < currentRect.maxX();
     633    case FocusDirectionUp:
     634        return candidateRect.y() < currentRect.maxY();
     635    case FocusDirectionRight:
     636        return candidateRect.maxX() > currentRect.x();
     637    case FocusDirectionDown:
     638        return candidateRect.maxY() > currentRect.y();
     639    default:
     640        ASSERT_NOT_REACHED();
     641    }
     642    return false;
     643}
     644
    623645void distanceDataForNode(FocusDirection direction, const FocusCandidate& current, FocusCandidate& candidate)
    624646{
  • trunk/Source/WebCore/page/SpatialNavigation.h

    r153469 r153704  
    137137bool canBeScrolledIntoView(FocusDirection, const FocusCandidate&);
    138138bool areElementsOnSameLine(const FocusCandidate& firstCandidate, const FocusCandidate& secondCandidate);
     139bool isValidCandidate(FocusDirection, const FocusCandidate&, FocusCandidate&);
    139140void distanceDataForNode(FocusDirection, const FocusCandidate& current, FocusCandidate& candidate);
    140141Node* scrollableEnclosingBoxOrParentFrameForNodeInDirection(FocusDirection, Node*);
  • trunk/Source/WebCore/testing/Internals.cpp

    r153054 r153704  
    394394}
    395395
     396unsigned Internals::lastSpatialNavigationCandidateCount(ExceptionCode& ec) const
     397{
     398    if (!contextDocument() || !contextDocument()->page()) {
     399        ec = INVALID_ACCESS_ERR;
     400        return 0;
     401    }
     402
     403    return contextDocument()->page()->lastSpatialNavigationCandidateCount();
     404}
     405
    396406unsigned Internals::numberOfActiveAnimations() const
    397407{
  • trunk/Source/WebCore/testing/Internals.h

    r153054 r153704  
    9595    void setShadowPseudoId(Element*, const String&, ExceptionCode&);
    9696
     97    // Spatial Navigation testing.
     98    unsigned lastSpatialNavigationCandidateCount(ExceptionCode&) const;
     99
    97100    // CSS Animation testing.
    98101    unsigned numberOfActiveAnimations() const;
  • trunk/Source/WebCore/testing/Internals.idl

    r153054 r153704  
    5555    [RaisesException] Node parentTreeScope(Node node);
    5656
     57    // Spatial Navigation testing
     58    [RaisesException] unsigned long lastSpatialNavigationCandidateCount();
     59
    5760    // CSS Animation testing.
    5861    unsigned long numberOfActiveAnimations();
Note: See TracChangeset for help on using the changeset viewer.