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::SelectTextfieldsOnKeyFocus
:
38 case IntID::SubmenuDelay
:
41 case IntID::MenusCanOverlapOSBar
:
44 case IntID::UseOverlayScrollbars
:
47 case IntID::AllowOverlayScrollbarsOverlap
:
50 case IntID::SkipNavigatingDisabledMenuItem
:
53 case IntID::DragThresholdX
:
54 case IntID::DragThresholdY
:
57 case IntID::UseAccessibilityTheme
:
60 case IntID::ScrollArrowStyle
:
61 aResult
= eScrollArrow_None
;
63 case IntID::ScrollButtonLeftMouseButtonAction
:
66 case IntID::ScrollButtonMiddleMouseButtonAction
:
69 case IntID::ScrollButtonRightMouseButtonAction
:
72 case IntID::TreeOpenDelay
:
75 case IntID::TreeCloseDelay
:
78 case IntID::TreeLazyScrollDelay
:
81 case IntID::TreeScrollDelay
:
84 case IntID::TreeScrollLinesMax
:
87 case IntID::TabFocusModel
:
88 aResult
= nsIContent::eTabFocus_textControlsMask
;
90 case IntID::ChosenMenuItemsShouldBlink
:
93 case IntID::WindowsAccentColorInTitlebar
:
95 res
= NS_ERROR_NOT_IMPLEMENTED
;
97 case IntID::AlertNotificationOrigin
:
98 aResult
= NS_ALERT_TOP
;
100 case IntID::ScrollToClick
:
103 case IntID::IMERawInputUnderlineStyle
:
104 case IntID::IMESelectedRawTextUnderlineStyle
:
105 case IntID::IMEConvertedTextUnderlineStyle
:
106 case IntID::IMESelectedConvertedTextUnderline
:
107 aResult
= static_cast<int32_t>(StyleTextDecorationStyle::Solid
);
109 case IntID::SpellCheckerUnderlineStyle
:
110 aResult
= static_cast<int32_t>(StyleTextDecorationStyle::Dotted
);
112 case IntID::MenuBarDrag
:
115 case IntID::ScrollbarButtonAutoRepeatBehavior
:
118 case IntID::SwipeAnimationEnabled
:
121 case IntID::ScrollbarDisplayOnMouseMove
:
124 case IntID::ScrollbarFadeBeginDelay
:
127 case IntID::ScrollbarFadeDuration
:
130 case IntID::ContextMenuOffsetVertical
:
133 case IntID::ContextMenuOffsetHorizontal
:
136 case IntID::GTKCSDAvailable
:
139 case IntID::GTKCSDMinimizeButton
:
142 case IntID::GTKCSDMaximizeButton
:
145 case IntID::GTKCSDCloseButton
:
148 case IntID::GTKCSDReversedPlacement
:
151 case IntID::SystemUsesDarkTheme
:
154 case IntID::PrefersReducedMotion
:
155 case IntID::PrefersReducedTransparency
:
158 case IntID::InvertedColors
:
161 case IntID::PrimaryPointerCapabilities
:
164 case IntID::AllPointerCapabilities
:
169 res
= NS_ERROR_FAILURE
;
175 nsresult
HeadlessLookAndFeel::NativeGetFloat(FloatID aID
, float& aResult
) {
176 nsresult res
= NS_OK
;
178 // Hardcoded values for GTK.
180 case FloatID::IMEUnderlineRelativeSize
:
183 case FloatID::SpellCheckerUnderlineRelativeSize
:
186 case FloatID::CaretAspectRatio
:
187 // Intentionally failing to quietly indicate lack of support.
189 res
= NS_ERROR_FAILURE
;
193 res
= NS_ERROR_FAILURE
;
200 bool HeadlessLookAndFeel::NativeGetFont(FontID aID
, nsString
& aFontName
,
201 gfxFontStyle
& aFontStyle
) {
202 // Default to san-serif for everything.
203 aFontStyle
.style
= FontSlantStyle::NORMAL
;
204 aFontStyle
.weight
= FontWeight::NORMAL
;
205 aFontStyle
.stretch
= FontStretch::NORMAL
;
206 aFontStyle
.size
= 14;
207 aFontStyle
.systemFont
= true;
209 aFontName
.AssignLiteral("sans-serif");
213 char16_t
HeadlessLookAndFeel::GetPasswordCharacterImpl() {
214 return UNICODE_BULLET
;
217 } // namespace mozilla::widget