| 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 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "platform/geometry/LayoutRect.h" | 30 #include "platform/geometry/LayoutRect.h" |
| 31 #include "platform/heap/Handle.h" | 31 #include "platform/heap/Handle.h" |
| 32 #include "public/platform/WebFocusType.h" | 32 #include "public/platform/WebFocusType.h" |
| 33 #include "wtf/Forward.h" | 33 #include "wtf/Forward.h" |
| 34 #include "wtf/Noncopyable.h" | 34 #include "wtf/Noncopyable.h" |
| 35 #include "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 struct FocusCandidate; | 39 struct FocusCandidate; |
| 40 struct FocusParams; |
| 40 class Element; | 41 class Element; |
| 41 class Frame; | 42 class Frame; |
| 42 class HTMLFrameOwnerElement; | 43 class HTMLFrameOwnerElement; |
| 43 class InputDeviceCapabilities; | 44 class InputDeviceCapabilities; |
| 44 class LocalFrame; | 45 class LocalFrame; |
| 45 class Node; | 46 class Node; |
| 46 class Page; | 47 class Page; |
| 47 | 48 |
| 48 class CORE_EXPORT FocusController final : public NoBaseWillBeGarbageCollectedFin
alized<FocusController> { | 49 class CORE_EXPORT FocusController final : public NoBaseWillBeGarbageCollectedFin
alized<FocusController> { |
| 49 WTF_MAKE_NONCOPYABLE(FocusController); USING_FAST_MALLOC_WILL_BE_REMOVED(Foc
usController); | 50 WTF_MAKE_NONCOPYABLE(FocusController); USING_FAST_MALLOC_WILL_BE_REMOVED(Foc
usController); |
| 50 public: | 51 public: |
| 51 static PassOwnPtrWillBeRawPtr<FocusController> create(Page*); | 52 static PassOwnPtrWillBeRawPtr<FocusController> create(Page*); |
| 52 | 53 |
| 53 void setFocusedFrame(PassRefPtrWillBeRawPtr<Frame>); | 54 void setFocusedFrame(PassRefPtrWillBeRawPtr<Frame>); |
| 54 void focusDocumentView(PassRefPtrWillBeRawPtr<Frame>); | 55 void focusDocumentView(PassRefPtrWillBeRawPtr<Frame>); |
| 55 LocalFrame* focusedFrame() const; | 56 LocalFrame* focusedFrame() const; |
| 56 Frame* focusedOrMainFrame() const; | 57 Frame* focusedOrMainFrame() const; |
| 57 | 58 |
| 58 // Finds the focused HTMLFrameOwnerElement, if any, in the provided frame. | 59 // Finds the focused HTMLFrameOwnerElement, if any, in the provided frame. |
| 59 // An HTMLFrameOwnerElement is considered focused if the frame it owns, or | 60 // An HTMLFrameOwnerElement is considered focused if the frame it owns, or |
| 60 // one of its descendant frames, is currently focused. | 61 // one of its descendant frames, is currently focused. |
| 61 HTMLFrameOwnerElement* focusedFrameOwnerElement(LocalFrame& currentFrame) co
nst; | 62 HTMLFrameOwnerElement* focusedFrameOwnerElement(LocalFrame& currentFrame) co
nst; |
| 62 | 63 |
| 63 bool setInitialFocus(WebFocusType); | 64 bool setInitialFocus(WebFocusType); |
| 64 bool advanceFocus(WebFocusType type, InputDeviceCapabilities* sourceCapabili
ties = nullptr) { return advanceFocus(type, false, sourceCapabilities); } | 65 bool advanceFocus(WebFocusType type, InputDeviceCapabilities* sourceCapabili
ties = nullptr) { return advanceFocus(type, false, sourceCapabilities); } |
| 65 Element* findFocusableElement(WebFocusType, Node&); | 66 Element* findFocusableElement(WebFocusType, Node&); |
| 66 | 67 |
| 67 bool setFocusedElement(Element*, PassRefPtrWillBeRawPtr<Frame>, WebFocusType
= WebFocusTypeNone, InputDeviceCapabilities* sourceCapabilities = nullptr); | 68 bool setFocusedElement(Element*, PassRefPtrWillBeRawPtr<Frame>, const FocusP
arams&); |
| 69 // |setFocusedElement| variant with SelectionBehaviorOnFocus::None, |
| 70 // |WebFocusTypeNone, and null InputDeviceCapabilities. |
| 71 bool setFocusedElement(Element*, PassRefPtrWillBeRawPtr<Frame>); |
| 68 | 72 |
| 69 void setActive(bool); | 73 void setActive(bool); |
| 70 bool isActive() const { return m_isActive; } | 74 bool isActive() const { return m_isActive; } |
| 71 | 75 |
| 72 void setFocused(bool); | 76 void setFocused(bool); |
| 73 bool isFocused() const { return m_isFocused; } | 77 bool isFocused() const { return m_isFocused; } |
| 74 | 78 |
| 75 DECLARE_TRACE(); | 79 DECLARE_TRACE(); |
| 76 | 80 |
| 77 private: | 81 private: |
| 78 explicit FocusController(Page*); | 82 explicit FocusController(Page*); |
| 79 | 83 |
| 80 bool advanceFocus(WebFocusType, bool initialFocus, InputDeviceCapabilities*
sourceCapabilities = nullptr); | 84 bool advanceFocus(WebFocusType, bool initialFocus, InputDeviceCapabilities*
sourceCapabilities = nullptr); |
| 81 bool advanceFocusDirectionally(WebFocusType); | 85 bool advanceFocusDirectionally(WebFocusType); |
| 82 bool advanceFocusInDocumentOrder(WebFocusType, bool initialFocus, InputDevic
eCapabilities* sourceCapabilities); | 86 bool advanceFocusInDocumentOrder(WebFocusType, bool initialFocus, InputDevic
eCapabilities* sourceCapabilities); |
| 83 | 87 |
| 84 bool advanceFocusDirectionallyInContainer(Node* container, const LayoutRect&
startingRect, WebFocusType); | 88 bool advanceFocusDirectionallyInContainer(Node* container, const LayoutRect&
startingRect, WebFocusType); |
| 85 void findFocusCandidateInContainer(Node& container, const LayoutRect& starti
ngRect, WebFocusType, FocusCandidate& closest); | 89 void findFocusCandidateInContainer(Node& container, const LayoutRect& starti
ngRect, WebFocusType, FocusCandidate& closest); |
| 86 | 90 |
| 87 RawPtrWillBeMember<Page> m_page; | 91 RawPtrWillBeMember<Page> m_page; |
| 88 RefPtrWillBeMember<Frame> m_focusedFrame; | 92 RefPtrWillBeMember<Frame> m_focusedFrame; |
| 89 bool m_isActive; | 93 bool m_isActive; |
| 90 bool m_isFocused; | 94 bool m_isFocused; |
| 91 bool m_isChangingFocusedFrame; | 95 bool m_isChangingFocusedFrame; |
| 92 }; | 96 }; |
| 93 | 97 |
| 94 } // namespace blink | 98 } // namespace blink |
| 95 | 99 |
| 96 #endif // FocusController_h | 100 #endif // FocusController_h |
| OLD | NEW |