OLD | NEW |
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // "Totally Aligned" elements are preferable candidates to move | 91 // "Totally Aligned" elements are preferable candidates to move |
92 // focus to over "Partially Aligned" ones, that on its turns are | 92 // focus to over "Partially Aligned" ones, that on its turns are |
93 // more preferable than "Not Aligned". | 93 // more preferable than "Not Aligned". |
94 enum RectsAlignment { | 94 enum RectsAlignment { |
95 None = 0, | 95 None = 0, |
96 Partial, | 96 Partial, |
97 Full | 97 Full |
98 }; | 98 }; |
99 | 99 |
100 struct FocusCandidate { | 100 struct FocusCandidate { |
| 101 STACK_ALLOCATED(); |
| 102 public: |
101 FocusCandidate() | 103 FocusCandidate() |
102 : visibleNode(0) | 104 : visibleNode(nullptr) |
103 , focusableNode(0) | 105 , focusableNode(nullptr) |
104 , enclosingScrollableBox(0) | 106 , enclosingScrollableBox(nullptr) |
105 , distance(maxDistance()) | 107 , distance(maxDistance()) |
106 , alignment(None) | 108 , alignment(None) |
107 , isOffscreen(true) | 109 , isOffscreen(true) |
108 , isOffscreenAfterScrolling(true) | 110 , isOffscreenAfterScrolling(true) |
109 { | 111 { |
110 } | 112 } |
111 | 113 |
112 FocusCandidate(Node*, FocusType); | 114 FocusCandidate(Node*, FocusType); |
113 explicit FocusCandidate(HTMLAreaElement*, FocusType); | 115 explicit FocusCandidate(HTMLAreaElement*, FocusType); |
114 bool isNull() const { return !visibleNode; } | 116 bool isNull() const { return !visibleNode; } |
115 bool inScrollableContainer() const { return visibleNode && enclosingScrollab
leBox; } | 117 bool inScrollableContainer() const { return visibleNode && enclosingScrollab
leBox; } |
116 bool isFrameOwnerElement() const { return visibleNode && visibleNode->isFram
eOwnerElement(); } | 118 bool isFrameOwnerElement() const { return visibleNode && visibleNode->isFram
eOwnerElement(); } |
117 Document* document() const { return visibleNode ? &visibleNode->document() :
0; } | 119 Document* document() const { return visibleNode ? &visibleNode->document() :
0; } |
118 | 120 |
119 // We handle differently visibleNode and FocusableNode to properly handle th
e areas of imagemaps, | 121 // We handle differently visibleNode and FocusableNode to properly handle th
e areas of imagemaps, |
120 // where visibleNode would represent the image element and focusableNode wou
ld represent the area element. | 122 // where visibleNode would represent the image element and focusableNode wou
ld represent the area element. |
121 // In all other cases, visibleNode and focusableNode are one and the same. | 123 // In all other cases, visibleNode and focusableNode are one and the same. |
122 Node* visibleNode; | 124 RawPtrWillBeMember<Node> visibleNode; |
123 Node* focusableNode; | 125 RawPtrWillBeMember<Node> focusableNode; |
124 Node* enclosingScrollableBox; | 126 RawPtrWillBeMember<Node> enclosingScrollableBox; |
125 long long distance; | 127 long long distance; |
126 RectsAlignment alignment; | 128 RectsAlignment alignment; |
127 LayoutRect rect; | 129 LayoutRect rect; |
128 bool isOffscreen; | 130 bool isOffscreen; |
129 bool isOffscreenAfterScrolling; | 131 bool isOffscreenAfterScrolling; |
130 }; | 132 }; |
131 | 133 |
132 bool hasOffscreenRect(Node*, FocusType = FocusTypeNone); | 134 bool hasOffscreenRect(Node*, FocusType = FocusTypeNone); |
133 bool scrollInDirection(LocalFrame*, FocusType); | 135 bool scrollInDirection(LocalFrame*, FocusType); |
134 bool scrollInDirection(Node* container, FocusType); | 136 bool scrollInDirection(Node* container, FocusType); |
135 bool canScrollInDirection(const Node* container, FocusType); | 137 bool canScrollInDirection(const Node* container, FocusType); |
136 bool canScrollInDirection(const LocalFrame*, FocusType); | 138 bool canScrollInDirection(const LocalFrame*, FocusType); |
137 bool canBeScrolledIntoView(FocusType, const FocusCandidate&); | 139 bool canBeScrolledIntoView(FocusType, const FocusCandidate&); |
138 bool areElementsOnSameLine(const FocusCandidate& firstCandidate, const FocusCand
idate& secondCandidate); | 140 bool areElementsOnSameLine(const FocusCandidate& firstCandidate, const FocusCand
idate& secondCandidate); |
139 void distanceDataForNode(FocusType, const FocusCandidate& current, FocusCandidat
e&); | 141 void distanceDataForNode(FocusType, const FocusCandidate& current, FocusCandidat
e&); |
140 Node* scrollableEnclosingBoxOrParentFrameForNodeInDirection(FocusType, Node*); | 142 Node* scrollableEnclosingBoxOrParentFrameForNodeInDirection(FocusType, Node*); |
141 LayoutRect nodeRectInAbsoluteCoordinates(Node*, bool ignoreBorder = false); | 143 LayoutRect nodeRectInAbsoluteCoordinates(Node*, bool ignoreBorder = false); |
142 LayoutRect frameRectInAbsoluteCoordinates(LocalFrame*); | 144 LayoutRect frameRectInAbsoluteCoordinates(LocalFrame*); |
143 LayoutRect virtualRectForDirection(FocusType, const LayoutRect& startingRect, La
youtUnit width = 0); | 145 LayoutRect virtualRectForDirection(FocusType, const LayoutRect& startingRect, La
youtUnit width = 0); |
144 LayoutRect virtualRectForAreaElementAndDirection(HTMLAreaElement&, FocusType); | 146 LayoutRect virtualRectForAreaElementAndDirection(HTMLAreaElement&, FocusType); |
145 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate&); | 147 HTMLFrameOwnerElement* frameOwnerElement(FocusCandidate&); |
146 | 148 |
147 } // namspace WebCore | 149 } // namspace WebCore |
148 | 150 |
149 #endif // SpatialNavigation_h | 151 #endif // SpatialNavigation_h |
OLD | NEW |