Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Side by Side Diff: Source/core/page/SpatialNavigation.h

Issue 810493003: Introduce "navigation target classification" for spatial navigation Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) 2 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
3 * Copyright (C) 2009 Antonio Gomes <tonikitoo@webkit.org> 3 * Copyright (C) 2009 Antonio Gomes <tonikitoo@webkit.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // 87 //
88 // "Totally Aligned" elements are preferable candidates to move 88 // "Totally Aligned" elements are preferable candidates to move
89 // focus to over "Partially Aligned" ones, that on its turns are 89 // focus to over "Partially Aligned" ones, that on its turns are
90 // more preferable than "Not Aligned". 90 // more preferable than "Not Aligned".
91 enum RectsAlignment { 91 enum RectsAlignment {
92 None = 0, 92 None = 0,
93 Partial, 93 Partial,
94 Full 94 Full
95 }; 95 };
96 96
97 // Classification of a focus candidate, ie. why a candidate is considered
98 // "interesting" as a navigation target.
99 enum NavigationClass {
100 NavigationClassNone,
101 NavigationClassFocusable,
102 NavigationClassFrameOwner,
103 NavigationClassScrollable,
104 NavigationClassEventHandler,
105 };
106
97 struct FocusCandidate { 107 struct FocusCandidate {
98 STACK_ALLOCATED(); 108 STACK_ALLOCATED();
99 public: 109 public:
100 FocusCandidate() 110 FocusCandidate()
101 : visibleNode(nullptr) 111 : visibleNode(nullptr)
102 , focusableNode(nullptr) 112 , focusableNode(nullptr)
103 , enclosingScrollableBox(nullptr) 113 , enclosingScrollableBox(nullptr)
104 , distance(maxDistance()) 114 , distance(maxDistance())
105 , alignment(None) 115 , alignment(None)
106 , isOffscreen(true) 116 , isOffscreen(true)
107 , isOffscreenAfterScrolling(true) 117 , isOffscreenAfterScrolling(true)
118 , targetClass(NavigationClassNone)
108 { 119 {
109 } 120 }
110 121
111 FocusCandidate(Node*, FocusType); 122 FocusCandidate(Node*, FocusType, NavigationClass);
112 explicit FocusCandidate(HTMLAreaElement*, FocusType);
113 bool isNull() const { return !visibleNode; } 123 bool isNull() const { return !visibleNode; }
114 bool inScrollableContainer() const { return visibleNode && enclosingScrollab leBox; } 124 bool inScrollableContainer() const { return visibleNode && enclosingScrollab leBox; }
115 bool isFrameOwnerElement() const { return visibleNode && visibleNode->isFram eOwnerElement(); } 125 bool isFrameOwnerElement() const { return visibleNode && visibleNode->isFram eOwnerElement(); }
116 Document* document() const { return visibleNode ? &visibleNode->document() : nullptr; } 126 Document* document() const { return visibleNode ? &visibleNode->document() : nullptr; }
117 127
118 // We handle differently visibleNode and FocusableNode to properly handle th e areas of imagemaps, 128 // We handle differently visibleNode and FocusableNode to properly handle th e areas of imagemaps,
119 // where visibleNode would represent the image element and focusableNode wou ld represent the area element. 129 // where visibleNode would represent the image element and focusableNode wou ld represent the area element.
120 // In all other cases, visibleNode and focusableNode are one and the same. 130 // In all other cases, visibleNode and focusableNode are one and the same.
121 RawPtrWillBeMember<Node> visibleNode; 131 RawPtrWillBeMember<Node> visibleNode;
122 RawPtrWillBeMember<Node> focusableNode; 132 RawPtrWillBeMember<Node> focusableNode;
123 RawPtrWillBeMember<Node> enclosingScrollableBox; 133 RawPtrWillBeMember<Node> enclosingScrollableBox;
124 double distance; 134 double distance;
125 RectsAlignment alignment; 135 RectsAlignment alignment;
126 LayoutRect rect; 136 LayoutRect rect;
127 bool isOffscreen; 137 bool isOffscreen;
128 bool isOffscreenAfterScrolling; 138 bool isOffscreenAfterScrolling;
139 NavigationClass targetClass;
129 }; 140 };
130 141
131 bool hasOffscreenRect(Node*, FocusType = FocusTypeNone); 142 bool hasOffscreenRect(Node*, FocusType = FocusTypeNone);
132 bool scrollInDirection(LocalFrame*, FocusType); 143 bool scrollInDirection(LocalFrame*, FocusType);
133 bool scrollInDirection(Node* container, FocusType); 144 bool scrollInDirection(Node* container, FocusType);
134 bool canScrollInDirection(const Node* container, FocusType); 145 bool canScrollInDirection(const Node* container, FocusType);
135 bool canScrollInDirection(const LocalFrame*, FocusType); 146 bool canScrollInDirection(const LocalFrame*, FocusType);
136 bool canBeScrolledIntoView(FocusType, const FocusCandidate&); 147 bool canBeScrolledIntoView(FocusType, const FocusCandidate&);
137 bool areElementsOnSameLine(const FocusCandidate& firstCandidate, const FocusCand idate& secondCandidate); 148 bool areElementsOnSameLine(const FocusCandidate& firstCandidate, const FocusCand idate& secondCandidate);
138 void distanceDataForNode(FocusType, const FocusCandidate& current, FocusCandidat e&); 149 void distanceDataForNode(FocusType, const FocusCandidate& current, FocusCandidat e&);
139 Node* scrollableEnclosingBoxOrParentFrameForNodeInDirection(FocusType, Node*); 150 Node* scrollableEnclosingBoxOrParentFrameForNodeInDirection(FocusType, Node*);
140 LayoutRect nodeRectInAbsoluteCoordinates(Node*, bool ignoreBorder = false); 151 LayoutRect nodeRectInAbsoluteCoordinates(Node*, bool ignoreBorder = false);
141 LayoutRect frameRectInAbsoluteCoordinates(LocalFrame*); 152 LayoutRect frameRectInAbsoluteCoordinates(LocalFrame*);
142 LayoutRect virtualRectForDirection(FocusType, const LayoutRect& startingRect, La youtUnit width = 0); 153 LayoutRect virtualRectForDirection(FocusType, const LayoutRect& startingRect, La youtUnit width = 0);
143 LayoutRect virtualRectForAreaElementAndDirection(HTMLAreaElement&, FocusType); 154 LayoutRect virtualRectForAreaElementAndDirection(HTMLAreaElement&, FocusType);
144 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate&); 155 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate&);
145 156
146 } // namespace blink 157 } // namespace blink
147 158
148 #endif // SpatialNavigation_h 159 #endif // SpatialNavigation_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698