FocusModel.h (1289B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef mozilla_FocusModel_h 6 #define mozilla_FocusModel_h 7 8 #include "mozilla/LookAndFeel.h" 9 #include "mozilla/StaticPrefs_accessibility.h" 10 #include "mozilla/TypedEnumBits.h" 11 12 namespace mozilla { 13 14 enum class IsFocusableFlags : uint8_t { 15 WithMouse = 1 << 0, 16 // Whether to treat an invisible frame as not focusable 17 IgnoreVisibility = 1 << 1, 18 }; 19 20 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(IsFocusableFlags); 21 22 enum class TabFocusableType : uint8_t { 23 TextControls = 1, // Textboxes and lists always tabbable 24 FormElements = 1 << 1, // Non-text form elements 25 Links = 1 << 2, // Links 26 Any = TextControls | FormElements | Links, 27 }; 28 29 class FocusModel final { 30 public: 31 static bool AppliesToXUL() { 32 return StaticPrefs::accessibility_tabfocus_applies_to_xul(); 33 } 34 35 static bool IsTabFocusable(TabFocusableType aType) { 36 if (StaticPrefs::accessibility_tabfocus() & int32_t(aType)) { 37 return true; 38 } 39 if (LookAndFeel::GetInt(LookAndFeel::IntID::FullKeyboardAccess)) { 40 return true; 41 } 42 return false; 43 } 44 }; 45 46 } // namespace mozilla 47 48 #endif