OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef FocusController_h | 26 #ifndef FocusController_h |
27 #define FocusController_h | 27 #define FocusController_h |
28 | 28 |
29 #include "core/page/FocusType.h" | |
30 #include "platform/geometry/LayoutRect.h" | 29 #include "platform/geometry/LayoutRect.h" |
31 #include "platform/heap/Handle.h" | 30 #include "platform/heap/Handle.h" |
| 31 #include "public/platform/WebFocusType.h" |
32 #include "wtf/Forward.h" | 32 #include "wtf/Forward.h" |
33 #include "wtf/Noncopyable.h" | 33 #include "wtf/Noncopyable.h" |
34 #include "wtf/RefPtr.h" | 34 #include "wtf/RefPtr.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 struct FocusCandidate; | 38 struct FocusCandidate; |
39 class Element; | 39 class Element; |
40 class FocusNavigationScope; | 40 class FocusNavigationScope; |
41 class Frame; | 41 class Frame; |
42 class HTMLFrameOwnerElement; | 42 class HTMLFrameOwnerElement; |
43 class HTMLShadowElement; | 43 class HTMLShadowElement; |
44 class Node; | 44 class Node; |
45 class Page; | 45 class Page; |
46 class TreeScope; | 46 class TreeScope; |
47 | 47 |
48 class FocusController final : public NoBaseWillBeGarbageCollectedFinalized<Focus
Controller> { | 48 class FocusController final : public NoBaseWillBeGarbageCollectedFinalized<Focus
Controller> { |
49 WTF_MAKE_NONCOPYABLE(FocusController); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOV
ED; | 49 WTF_MAKE_NONCOPYABLE(FocusController); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOV
ED; |
50 public: | 50 public: |
51 static PassOwnPtrWillBeRawPtr<FocusController> create(Page*); | 51 static PassOwnPtrWillBeRawPtr<FocusController> create(Page*); |
52 | 52 |
53 void setFocusedFrame(PassRefPtrWillBeRawPtr<Frame>); | 53 void setFocusedFrame(PassRefPtrWillBeRawPtr<Frame>); |
54 void focusDocumentView(PassRefPtrWillBeRawPtr<Frame>); | 54 void focusDocumentView(PassRefPtrWillBeRawPtr<Frame>); |
55 Frame* focusedFrame() const { return m_focusedFrame.get(); } | 55 Frame* focusedFrame() const { return m_focusedFrame.get(); } |
56 Frame* focusedOrMainFrame() const; | 56 Frame* focusedOrMainFrame() const; |
57 | 57 |
58 bool setInitialFocus(FocusType); | 58 bool setInitialFocus(WebFocusType); |
59 bool advanceFocus(FocusType type) { return advanceFocus(type, false); } | 59 bool advanceFocus(WebFocusType type) { return advanceFocus(type, false); } |
60 | 60 |
61 bool setFocusedElement(Element*, PassRefPtrWillBeRawPtr<Frame>, FocusType =
FocusTypeNone); | 61 bool setFocusedElement(Element*, PassRefPtrWillBeRawPtr<Frame>, WebFocusType
= WebFocusTypeNone); |
62 | 62 |
63 void setActive(bool); | 63 void setActive(bool); |
64 bool isActive() const { return m_isActive; } | 64 bool isActive() const { return m_isActive; } |
65 | 65 |
66 void setFocused(bool); | 66 void setFocused(bool); |
67 bool isFocused() const { return m_isFocused; } | 67 bool isFocused() const { return m_isFocused; } |
68 | 68 |
69 void trace(Visitor*); | 69 void trace(Visitor*); |
70 | 70 |
71 private: | 71 private: |
72 explicit FocusController(Page*); | 72 explicit FocusController(Page*); |
73 | 73 |
74 bool advanceFocus(FocusType, bool initialFocus); | 74 bool advanceFocus(WebFocusType, bool initialFocus); |
75 bool advanceFocusDirectionally(FocusType); | 75 bool advanceFocusDirectionally(WebFocusType); |
76 bool advanceFocusInDocumentOrder(FocusType, bool initialFocus); | 76 bool advanceFocusInDocumentOrder(WebFocusType, bool initialFocus); |
77 | 77 |
78 Node* findFocusableNodeAcrossFocusScope(FocusType, const FocusNavigationScop
e&, Node*); | 78 Node* findFocusableNodeAcrossFocusScope(WebFocusType, const FocusNavigationS
cope&, Node*); |
79 Node* findFocusableNodeRecursively(FocusType, const FocusNavigationScope&, N
ode*); | 79 Node* findFocusableNodeRecursively(WebFocusType, const FocusNavigationScope&
, Node*); |
80 Node* findFocusableNodeDecendingDownIntoFrameDocument(FocusType, Node*); | 80 Node* findFocusableNodeDecendingDownIntoFrameDocument(WebFocusType, Node*); |
81 | 81 |
82 // Searches through the given tree scope, starting from start node, for the
next/previous selectable element that comes after/before start node. | 82 // Searches through the given tree scope, starting from start node, for the
next/previous selectable element that comes after/before start node. |
83 // The order followed is as specified in section 17.11.1 of the HTML4 spec,
which is elements with tab indexes | 83 // The order followed is as specified in section 17.11.1 of the HTML4 spec,
which is elements with tab indexes |
84 // first (from lowest to highest), and then elements without tab indexes (in
document order). | 84 // first (from lowest to highest), and then elements without tab indexes (in
document order). |
85 // | 85 // |
86 // @param start The node from which to start searching. The node after this
will be focused. May be null. | 86 // @param start The node from which to start searching. The node after this
will be focused. May be null. |
87 // | 87 // |
88 // @return The focus node that comes after/before start node. | 88 // @return The focus node that comes after/before start node. |
89 // | 89 // |
90 // See http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1 | 90 // See http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1 |
91 inline Node* findFocusableNode(FocusType, const FocusNavigationScope&, Node*
start); | 91 inline Node* findFocusableNode(WebFocusType, const FocusNavigationScope&, No
de* start); |
92 | 92 |
93 Node* nextFocusableNode(const FocusNavigationScope&, Node* start); | 93 Node* nextFocusableNode(const FocusNavigationScope&, Node* start); |
94 Node* previousFocusableNode(const FocusNavigationScope&, Node* start); | 94 Node* previousFocusableNode(const FocusNavigationScope&, Node* start); |
95 | 95 |
96 Node* findNodeWithExactTabIndex(Node* start, int tabIndex, FocusType); | 96 Node* findNodeWithExactTabIndex(Node* start, int tabIndex, WebFocusType); |
97 | 97 |
98 bool advanceFocusDirectionallyInContainer(Node* container, const LayoutRect&
startingRect, FocusType); | 98 bool advanceFocusDirectionallyInContainer(Node* container, const LayoutRect&
startingRect, WebFocusType); |
99 void findFocusCandidateInContainer(Node& container, const LayoutRect& starti
ngRect, FocusType, FocusCandidate& closest); | 99 void findFocusCandidateInContainer(Node& container, const LayoutRect& starti
ngRect, WebFocusType, FocusCandidate& closest); |
100 | 100 |
101 RawPtrWillBeMember<Page> m_page; | 101 RawPtrWillBeMember<Page> m_page; |
102 RefPtrWillBeMember<Frame> m_focusedFrame; | 102 RefPtrWillBeMember<Frame> m_focusedFrame; |
103 bool m_isActive; | 103 bool m_isActive; |
104 bool m_isFocused; | 104 bool m_isFocused; |
105 bool m_isChangingFocusedFrame; | 105 bool m_isChangingFocusedFrame; |
106 }; | 106 }; |
107 | 107 |
108 } // namespace blink | 108 } // namespace blink |
109 | 109 |
110 #endif // FocusController_h | 110 #endif // FocusController_h |
OLD | NEW |