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

Side by Side Diff: third_party/WebKit/Source/core/page/FocusController.h

Issue 2678683002: Delay instantiating InputDeviceCapabilities until accessed. (Closed)
Patch Set: rebased Created 3 years, 10 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
OLDNEW
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/CoreExport.h" 29 #include "core/CoreExport.h"
30 #include "core/input/InputDeviceCapabilities.h"
30 #include "platform/geometry/LayoutRect.h" 31 #include "platform/geometry/LayoutRect.h"
31 #include "platform/heap/Handle.h" 32 #include "platform/heap/Handle.h"
32 #include "public/platform/WebFocusType.h" 33 #include "public/platform/WebFocusType.h"
33 #include "wtf/Forward.h" 34 #include "wtf/Forward.h"
34 #include "wtf/Noncopyable.h" 35 #include "wtf/Noncopyable.h"
35 #include "wtf/RefPtr.h" 36 #include "wtf/RefPtr.h"
36 37
37 namespace blink { 38 namespace blink {
38 39
39 struct FocusCandidate; 40 struct FocusCandidate;
40 struct FocusParams; 41 struct FocusParams;
41 class Document; 42 class Document;
42 class Element; 43 class Element;
43 class FocusChangedObserver; 44 class FocusChangedObserver;
44 class Frame; 45 class Frame;
45 class HTMLFrameOwnerElement; 46 class HTMLFrameOwnerElement;
46 class InputDeviceCapabilities;
47 class LocalFrame; 47 class LocalFrame;
48 class Node; 48 class Node;
49 class Page; 49 class Page;
50 class RemoteFrame; 50 class RemoteFrame;
51 51
52 class CORE_EXPORT FocusController final 52 class CORE_EXPORT FocusController final
53 : public GarbageCollected<FocusController> { 53 : public GarbageCollected<FocusController> {
54 WTF_MAKE_NONCOPYABLE(FocusController); 54 WTF_MAKE_NONCOPYABLE(FocusController);
55 55
56 public: 56 public:
57 static FocusController* create(Page*); 57 static FocusController* create(Page*);
58 58
59 void setFocusedFrame(Frame*, bool notifyEmbedder = true); 59 void setFocusedFrame(Frame*, bool notifyEmbedder = true);
60 void focusDocumentView(Frame*, bool notifyEmbedder = true); 60 void focusDocumentView(Frame*, bool notifyEmbedder = true);
61 LocalFrame* focusedFrame() const; 61 LocalFrame* focusedFrame() const;
62 Frame* focusedOrMainFrame() const; 62 Frame* focusedOrMainFrame() const;
63 63
64 // Finds the focused HTMLFrameOwnerElement, if any, in the provided frame. 64 // Finds the focused HTMLFrameOwnerElement, if any, in the provided frame.
65 // An HTMLFrameOwnerElement is considered focused if the frame it owns, or 65 // An HTMLFrameOwnerElement is considered focused if the frame it owns, or
66 // one of its descendant frames, is currently focused. 66 // one of its descendant frames, is currently focused.
67 HTMLFrameOwnerElement* focusedFrameOwnerElement( 67 HTMLFrameOwnerElement* focusedFrameOwnerElement(
68 LocalFrame& currentFrame) const; 68 LocalFrame& currentFrame) const;
69 69
70 // Determines whether the provided Document has focus according to 70 // Determines whether the provided Document has focus according to
71 // http://www.w3.org/TR/html5/editing.html#dom-document-hasfocus 71 // http://www.w3.org/TR/html5/editing.html#dom-document-hasfocus
72 bool isDocumentFocused(const Document&) const; 72 bool isDocumentFocused(const Document&) const;
73 73
74 bool setInitialFocus(WebFocusType); 74 bool setInitialFocus(WebFocusType);
75 bool advanceFocus(WebFocusType type, 75 bool advanceFocus(WebFocusType type,
76 InputDeviceCapabilities* sourceCapabilities = nullptr) { 76 const InputDeviceCapabilitiesValue& sourceCapabilities =
77 InputDeviceCapabilitiesValue()) {
77 return advanceFocus(type, false, sourceCapabilities); 78 return advanceFocus(type, false, sourceCapabilities);
78 } 79 }
79 bool advanceFocusAcrossFrames( 80 bool advanceFocusAcrossFrames(
80 WebFocusType, 81 WebFocusType,
81 RemoteFrame* from, 82 RemoteFrame* from,
82 LocalFrame* to, 83 LocalFrame* to,
83 InputDeviceCapabilities* sourceCapabilities = nullptr); 84 const InputDeviceCapabilitiesValue& sourceCapabilities);
84 Element* findFocusableElementInShadowHost(const Element& shadowHost); 85 Element* findFocusableElementInShadowHost(const Element& shadowHost);
85 86
86 bool setFocusedElement(Element*, Frame*, const FocusParams&); 87 bool setFocusedElement(Element*, Frame*, const FocusParams&);
87 // |setFocusedElement| variant with SelectionBehaviorOnFocus::None, 88 // |setFocusedElement| variant with SelectionBehaviorOnFocus::None,
88 // |WebFocusTypeNone, and null InputDeviceCapabilities. 89 // |WebFocusTypeNone, and null InputDeviceCapabilities.
89 bool setFocusedElement(Element*, Frame*); 90 bool setFocusedElement(Element*, Frame*);
90 91
91 void setActive(bool); 92 void setActive(bool);
92 bool isActive() const { return m_isActive; } 93 bool isActive() const { return m_isActive; }
93 94
94 void setFocused(bool); 95 void setFocused(bool);
95 bool isFocused() const { return m_isFocused; } 96 bool isFocused() const { return m_isFocused; }
96 97
97 void registerFocusChangedObserver(FocusChangedObserver*); 98 void registerFocusChangedObserver(FocusChangedObserver*);
98 99
99 DECLARE_TRACE(); 100 DECLARE_TRACE();
100 101
101 private: 102 private:
102 explicit FocusController(Page*); 103 explicit FocusController(Page*);
103 104
104 Element* findFocusableElement(WebFocusType, Element&); 105 Element* findFocusableElement(WebFocusType, Element&);
105 106
106 bool advanceFocus(WebFocusType, 107 bool advanceFocus(WebFocusType,
107 bool initialFocus, 108 bool initialFocus,
108 InputDeviceCapabilities* sourceCapabilities = nullptr); 109 const InputDeviceCapabilitiesValue&);
109 bool advanceFocusDirectionally(WebFocusType); 110 bool advanceFocusDirectionally(WebFocusType);
110 bool advanceFocusInDocumentOrder(LocalFrame*, 111 bool advanceFocusInDocumentOrder(LocalFrame*,
111 Element* start, 112 Element* start,
112 WebFocusType, 113 WebFocusType,
113 bool initialFocus, 114 bool initialFocus,
114 InputDeviceCapabilities* sourceCapabilities); 115 const InputDeviceCapabilitiesValue&);
115 116
116 bool advanceFocusDirectionallyInContainer(Node* container, 117 bool advanceFocusDirectionallyInContainer(Node* container,
117 const LayoutRect& startingRect, 118 const LayoutRect& startingRect,
118 WebFocusType); 119 WebFocusType);
119 void findFocusCandidateInContainer(Node& container, 120 void findFocusCandidateInContainer(Node& container,
120 const LayoutRect& startingRect, 121 const LayoutRect& startingRect,
121 WebFocusType, 122 WebFocusType,
122 FocusCandidate& closest); 123 FocusCandidate& closest);
123 124
124 void notifyFocusChangedObservers() const; 125 void notifyFocusChangedObservers() const;
125 126
126 Member<Page> m_page; 127 Member<Page> m_page;
127 Member<Frame> m_focusedFrame; 128 Member<Frame> m_focusedFrame;
128 bool m_isActive; 129 bool m_isActive;
129 bool m_isFocused; 130 bool m_isFocused;
130 bool m_isChangingFocusedFrame; 131 bool m_isChangingFocusedFrame;
131 HeapHashSet<WeakMember<FocusChangedObserver>> m_focusChangedObservers; 132 HeapHashSet<WeakMember<FocusChangedObserver>> m_focusChangedObservers;
132 }; 133 };
133 134
134 } // namespace blink 135 } // namespace blink
135 136
136 #endif // FocusController_h 137 #endif // FocusController_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/MouseEventManager.cpp ('k') | third_party/WebKit/Source/core/page/FocusController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698