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::ChosenMenuItemsShouldBlink
:
90 case IntID::WindowsAccentColorInTitlebar
:
92 res
= NS_ERROR_NOT_IMPLEMENTED
;
94 case IntID::AlertNotificationOrigin
:
95 aResult
= NS_ALERT_TOP
;
97 case IntID::ScrollToClick
:
100 case IntID::IMERawInputUnderlineStyle
:
101 case IntID::IMESelectedRawTextUnderlineStyle
:
102 case IntID::IMEConvertedTextUnderlineStyle
:
103 case IntID::IMESelectedConvertedTextUnderline
:
104 aResult
= static_cast<int32_t>(StyleTextDecorationStyle::Solid
);
106 case IntID::SpellCheckerUnderlineStyle
:
107 aResult
= static_cast<int32_t>(StyleTextDecorationStyle::Dotted
);
109 case IntID::MenuBarDrag
:
112 case IntID::ScrollbarButtonAutoRepeatBehavior
:
115 case IntID::SwipeAnimationEnabled
:
118 case IntID::ScrollbarDisplayOnMouseMove
:
121 case IntID::ScrollbarFadeBeginDelay
:
124 case IntID::ScrollbarFadeDuration
:
127 case IntID::ContextMenuOffsetVertical
:
130 case IntID::ContextMenuOffsetHorizontal
:
133 case IntID::GTKCSDAvailable
:
136 case IntID::GTKCSDMinimizeButton
:
139 case IntID::GTKCSDMaximizeButton
:
142 case IntID::GTKCSDCloseButton
:
145 case IntID::GTKCSDReversedPlacement
:
148 case IntID::SystemUsesDarkTheme
:
151 case IntID::PrefersReducedMotion
:
152 case IntID::PrefersReducedTransparency
:
155 case IntID::InvertedColors
:
158 case IntID::PrimaryPointerCapabilities
:
161 case IntID::AllPointerCapabilities
:
166 res
= NS_ERROR_FAILURE
;
172 nsresult
HeadlessLookAndFeel::NativeGetFloat(FloatID aID
, float& aResult
) {
173 nsresult res
= NS_OK
;
175 // Hardcoded values for GTK.
177 case FloatID::IMEUnderlineRelativeSize
:
180 case FloatID::SpellCheckerUnderlineRelativeSize
:
183 case FloatID::CaretAspectRatio
:
184 // Intentionally failing to quietly indicate lack of support.
186 res
= NS_ERROR_FAILURE
;
190 res
= NS_ERROR_FAILURE
;
197 bool HeadlessLookAndFeel::NativeGetFont(FontID aID
, nsString
& aFontName
,
198 gfxFontStyle
& aFontStyle
) {
199 // Default to san-serif for everything.
200 aFontStyle
.style
= FontSlantStyle::NORMAL
;
201 aFontStyle
.weight
= FontWeight::NORMAL
;
202 aFontStyle
.stretch
= FontStretch::NORMAL
;
203 aFontStyle
.size
= 14;
204 aFontStyle
.systemFont
= true;
206 aFontName
.AssignLiteral("sans-serif");
210 char16_t
HeadlessLookAndFeel::GetPasswordCharacterImpl() {
211 return UNICODE_BULLET
;
214 } // namespace mozilla::widget