1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "HeadlessLookAndFeel.h"
8 #include "mozilla/FontPropertyTypes.h"
9 #include "nsIContent.h"
11 namespace mozilla::widget
{
13 static const char16_t UNICODE_BULLET
= 0x2022;
15 HeadlessLookAndFeel::HeadlessLookAndFeel() = default;
17 HeadlessLookAndFeel::~HeadlessLookAndFeel() = default;
19 nsresult
HeadlessLookAndFeel::NativeGetColor(ColorID aID
, ColorScheme aScheme
,
21 aResult
= GetStandinForNativeColor(aID
, aScheme
);
25 nsresult
HeadlessLookAndFeel::NativeGetInt(IntID aID
, int32_t& aResult
) {
27 // These values should be sane defaults for headless mode under GTK.
29 case IntID::CaretBlinkTime
:
32 case IntID::CaretWidth
:
35 case IntID::ShowCaretDuringSelection
:
38 case IntID::SelectTextfieldsOnKeyFocus
:
41 case IntID::SubmenuDelay
:
44 case IntID::MenusCanOverlapOSBar
:
47 case IntID::UseOverlayScrollbars
:
50 case IntID::AllowOverlayScrollbarsOverlap
:
53 case IntID::SkipNavigatingDisabledMenuItem
:
56 case IntID::DragThresholdX
:
57 case IntID::DragThresholdY
:
60 case IntID::UseAccessibilityTheme
:
63 case IntID::ScrollArrowStyle
:
64 aResult
= eScrollArrow_None
;
66 case IntID::ScrollButtonLeftMouseButtonAction
:
69 case IntID::ScrollButtonMiddleMouseButtonAction
:
72 case IntID::ScrollButtonRightMouseButtonAction
:
75 case IntID::TreeOpenDelay
:
78 case IntID::TreeCloseDelay
:
81 case IntID::TreeLazyScrollDelay
:
84 case IntID::TreeScrollDelay
:
87 case IntID::TreeScrollLinesMax
:
90 case IntID::TabFocusModel
:
91 aResult
= nsIContent::eTabFocus_textControlsMask
;
93 case IntID::ChosenMenuItemsShouldBlink
:
96 case IntID::WindowsAccentColorInTitlebar
:
98 res
= NS_ERROR_NOT_IMPLEMENTED
;
100 case IntID::AlertNotificationOrigin
:
101 aResult
= NS_ALERT_TOP
;
103 case IntID::ScrollToClick
:
106 case IntID::IMERawInputUnderlineStyle
:
107 case IntID::IMESelectedRawTextUnderlineStyle
:
108 case IntID::IMEConvertedTextUnderlineStyle
:
109 case IntID::IMESelectedConvertedTextUnderline
:
110 aResult
= static_cast<int32_t>(StyleTextDecorationStyle::Solid
);
112 case IntID::SpellCheckerUnderlineStyle
:
113 aResult
= static_cast<int32_t>(StyleTextDecorationStyle::Dotted
);
115 case IntID::MenuBarDrag
:
118 case IntID::ScrollbarButtonAutoRepeatBehavior
:
121 case IntID::TooltipDelay
:
124 case IntID::SwipeAnimationEnabled
:
127 case IntID::ScrollbarDisplayOnMouseMove
:
130 case IntID::ScrollbarFadeBeginDelay
:
133 case IntID::ScrollbarFadeDuration
:
136 case IntID::ContextMenuOffsetVertical
:
139 case IntID::ContextMenuOffsetHorizontal
:
142 case IntID::GTKCSDAvailable
:
145 case IntID::GTKCSDMinimizeButton
:
148 case IntID::GTKCSDMaximizeButton
:
151 case IntID::GTKCSDCloseButton
:
154 case IntID::GTKCSDReversedPlacement
:
157 case IntID::SystemUsesDarkTheme
:
160 case IntID::PrefersReducedMotion
:
161 case IntID::PrefersReducedTransparency
:
164 case IntID::InvertedColors
:
167 case IntID::PrimaryPointerCapabilities
:
170 case IntID::AllPointerCapabilities
:
175 res
= NS_ERROR_FAILURE
;
181 nsresult
HeadlessLookAndFeel::NativeGetFloat(FloatID aID
, float& aResult
) {
182 nsresult res
= NS_OK
;
184 // Hardcoded values for GTK.
186 case FloatID::IMEUnderlineRelativeSize
:
189 case FloatID::SpellCheckerUnderlineRelativeSize
:
192 case FloatID::CaretAspectRatio
:
193 // Intentionally failing to quietly indicate lack of support.
195 res
= NS_ERROR_FAILURE
;
199 res
= NS_ERROR_FAILURE
;
206 bool HeadlessLookAndFeel::NativeGetFont(FontID aID
, nsString
& aFontName
,
207 gfxFontStyle
& aFontStyle
) {
208 // Default to san-serif for everything.
209 aFontStyle
.style
= FontSlantStyle::NORMAL
;
210 aFontStyle
.weight
= FontWeight::NORMAL
;
211 aFontStyle
.stretch
= FontStretch::NORMAL
;
212 aFontStyle
.size
= 14;
213 aFontStyle
.systemFont
= true;
215 aFontName
.AssignLiteral("sans-serif");
219 char16_t
HeadlessLookAndFeel::GetPasswordCharacterImpl() {
220 return UNICODE_BULLET
;
223 } // namespace mozilla::widget