diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/page/FocusController.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/page/FocusController.h')
-rw-r--r-- | Source/WebCore/page/FocusController.h | 99 |
1 files changed, 52 insertions, 47 deletions
diff --git a/Source/WebCore/page/FocusController.h b/Source/WebCore/page/FocusController.h index b991130ae..c6dcf2220 100644 --- a/Source/WebCore/page/FocusController.h +++ b/Source/WebCore/page/FocusController.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -23,21 +23,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FocusController_h -#define FocusController_h +#pragma once +#include "ActivityState.h" #include "FocusDirection.h" #include "LayoutRect.h" +#include "Timer.h" #include <wtf/Forward.h> -#include <wtf/Noncopyable.h> #include <wtf/RefPtr.h> namespace WebCore { -struct FocusCandidate; class ContainerNode; class Document; class Element; +class FocusNavigationScope; class Frame; class HTMLFrameOwnerElement; class IntRect; @@ -46,52 +46,54 @@ class Node; class Page; class TreeScope; -class FocusNavigationScope { -public: - ContainerNode* rootNode() const; - Element* owner() const; - static FocusNavigationScope focusNavigationScopeOf(Node*); - static FocusNavigationScope focusNavigationScopeOwnedByShadowHost(Node*); - static FocusNavigationScope focusNavigationScopeOwnedByIFrame(HTMLFrameOwnerElement*); - -private: - explicit FocusNavigationScope(TreeScope*); - TreeScope* m_rootTreeScope; -}; +struct FocusCandidate; class FocusController { - WTF_MAKE_NONCOPYABLE(FocusController); WTF_MAKE_FAST_ALLOCATED; + WTF_MAKE_FAST_ALLOCATED; public: - explicit FocusController(Page&); + explicit FocusController(Page&, ActivityState::Flags); - void setFocusedFrame(PassRefPtr<Frame>); + WEBCORE_EXPORT void setFocusedFrame(Frame*); Frame* focusedFrame() const { return m_focusedFrame.get(); } - Frame& focusedOrMainFrame() const; + WEBCORE_EXPORT Frame& focusedOrMainFrame() const; + + WEBCORE_EXPORT bool setInitialFocus(FocusDirection, KeyboardEvent*); + bool advanceFocus(FocusDirection, KeyboardEvent&, bool initialFocus = false); - bool setInitialFocus(FocusDirection, KeyboardEvent*); - bool advanceFocus(FocusDirection, KeyboardEvent*, bool initialFocus = false); + WEBCORE_EXPORT bool setFocusedElement(Element*, Frame&, FocusDirection = FocusDirectionNone); - bool setFocusedElement(Element*, PassRefPtr<Frame>, FocusDirection = FocusDirectionNone); + void setActivityState(ActivityState::Flags); - void setActive(bool); - bool isActive() const { return m_isActive; } + WEBCORE_EXPORT void setActive(bool); + bool isActive() const { return m_activityState & ActivityState::WindowIsActive; } - void setFocused(bool); - bool isFocused() const { return m_isFocused; } + WEBCORE_EXPORT void setFocused(bool); + bool isFocused() const { return m_activityState & ActivityState::IsFocused; } - void setContentIsVisible(bool); + bool contentIsVisible() const { return m_activityState & ActivityState::IsVisible; } // These methods are used in WebCore/bindings/objc/DOM.mm. - Element* nextFocusableElement(FocusNavigationScope, Node* start, KeyboardEvent*); - Element* previousFocusableElement(FocusNavigationScope, Node* start, KeyboardEvent*); + WEBCORE_EXPORT Element* nextFocusableElement(Node&); + WEBCORE_EXPORT Element* previousFocusableElement(Node&); + + void setFocusedElementNeedsRepaint(); + double timeSinceFocusWasSet() const; private: - bool advanceFocusDirectionally(FocusDirection, KeyboardEvent*); - bool advanceFocusInDocumentOrder(FocusDirection, KeyboardEvent*, bool initialFocus); + void setActiveInternal(bool); + void setFocusedInternal(bool); + void setIsVisibleAndActiveInternal(bool); + + bool advanceFocusDirectionally(FocusDirection, KeyboardEvent&); + bool advanceFocusInDocumentOrder(FocusDirection, KeyboardEvent&, bool initialFocus); + + Element* findFocusableElementAcrossFocusScope(FocusDirection, const FocusNavigationScope& startScope, Node* start, KeyboardEvent&); + + Element* findFocusableElementWithinScope(FocusDirection, const FocusNavigationScope&, Node* start, KeyboardEvent&); + Element* nextFocusableElementWithinScope(const FocusNavigationScope&, Node* start, KeyboardEvent&); + Element* previousFocusableElementWithinScope(const FocusNavigationScope&, Node* start, KeyboardEvent&); - Element* findFocusableElementAcrossFocusScope(FocusDirection, FocusNavigationScope startScope, Node* start, KeyboardEvent*); - Element* findFocusableElementRecursively(FocusDirection, FocusNavigationScope, Node* start, KeyboardEvent*); - Element* findFocusableElementDescendingDownIntoFrameDocument(FocusDirection, Element*, KeyboardEvent*); + Element* findFocusableElementDescendingDownIntoFrameDocument(FocusDirection, Element*, KeyboardEvent&); // Searches through the given tree scope, starting from start node, for the next/previous selectable element that comes after/before start node. // The order followed is as specified in section 17.11.1 of the HTML4 spec, which is elements with tab indexes @@ -102,22 +104,25 @@ private: // @return The focus node that comes after/before start node. // // See http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1 - Element* findFocusableElement(FocusDirection, FocusNavigationScope, Node* start, KeyboardEvent*); + Element* findFocusableElementOrScopeOwner(FocusDirection, const FocusNavigationScope&, Node* start, KeyboardEvent&); - Element* findElementWithExactTabIndex(Node* start, int tabIndex, KeyboardEvent*, FocusDirection); + Element* findElementWithExactTabIndex(const FocusNavigationScope&, Node* start, int tabIndex, KeyboardEvent&, FocusDirection); + + Element* nextFocusableElementOrScopeOwner(const FocusNavigationScope&, Node* start, KeyboardEvent&); + Element* previousFocusableElementOrScopeOwner(const FocusNavigationScope&, Node* start, KeyboardEvent&); + + bool advanceFocusDirectionallyInContainer(Node* container, const LayoutRect& startingRect, FocusDirection, KeyboardEvent&); + void findFocusCandidateInContainer(Node& container, const LayoutRect& startingRect, FocusDirection, KeyboardEvent&, FocusCandidate& closest); - bool advanceFocusDirectionallyInContainer(Node* container, const LayoutRect& startingRect, FocusDirection, KeyboardEvent*); - void findFocusCandidateInContainer(Node* container, const LayoutRect& startingRect, FocusDirection, KeyboardEvent*, FocusCandidate& closest); + void focusRepaintTimerFired(); Page& m_page; RefPtr<Frame> m_focusedFrame; - bool m_isActive; - bool m_isFocused; bool m_isChangingFocusedFrame; - bool m_contentIsVisible; + ActivityState::Flags m_activityState; + Timer m_focusRepaintTimer; + double m_focusSetTime; }; } // namespace WebCore - -#endif // FocusController_h |