2017-07-06 05:41:21 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "HeadlessLookAndFeel.h"
|
2018-04-13 22:34:37 +03:00
|
|
|
#include "mozilla/FontPropertyTypes.h"
|
2017-07-06 05:41:21 +03:00
|
|
|
#include "nsIContent.h"
|
|
|
|
|
2021-03-31 01:58:22 +03:00
|
|
|
namespace mozilla::widget {
|
2017-07-06 05:41:21 +03:00
|
|
|
|
|
|
|
static const char16_t UNICODE_BULLET = 0x2022;
|
|
|
|
|
2021-11-17 04:24:20 +03:00
|
|
|
HeadlessLookAndFeel::HeadlessLookAndFeel() = default;
|
2017-07-06 05:41:21 +03:00
|
|
|
|
2020-03-16 13:56:57 +03:00
|
|
|
HeadlessLookAndFeel::~HeadlessLookAndFeel() = default;
|
2017-07-06 05:41:21 +03:00
|
|
|
|
2021-09-29 13:20:56 +03:00
|
|
|
nsresult HeadlessLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme,
|
2021-11-17 04:24:20 +03:00
|
|
|
nscolor& aResult) {
|
|
|
|
aResult = GetStandinForNativeColor(aID, aScheme);
|
|
|
|
return NS_OK;
|
2017-07-06 05:41:21 +03:00
|
|
|
}
|
|
|
|
|
2020-11-21 02:52:47 +03:00
|
|
|
nsresult HeadlessLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
|
|
|
|
nsresult res = NS_OK;
|
2017-07-06 05:41:21 +03:00
|
|
|
// These values should be sane defaults for headless mode under GTK.
|
|
|
|
switch (aID) {
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::CaretBlinkTime:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 567;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::CaretWidth:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 1;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ShowCaretDuringSelection:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::SelectTextfieldsOnKeyFocus:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 1;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::SubmenuDelay:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 200;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::MenusCanOverlapOSBar:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::UseOverlayScrollbars:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::AllowOverlayScrollbarsOverlap:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::SkipNavigatingDisabledMenuItem:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 1;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::DragThresholdX:
|
|
|
|
case IntID::DragThresholdY:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 4;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::UseAccessibilityTheme:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollArrowStyle:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = eScrollArrow_None;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollSliderStyle:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = eScrollThumbStyle_Proportional;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollButtonLeftMouseButtonAction:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
return NS_OK;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollButtonMiddleMouseButtonAction:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 3;
|
|
|
|
return NS_OK;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollButtonRightMouseButtonAction:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 3;
|
|
|
|
return NS_OK;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::TreeOpenDelay:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 1000;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::TreeCloseDelay:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 1000;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::TreeLazyScrollDelay:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 150;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::TreeScrollDelay:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 100;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::TreeScrollLinesMax:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 3;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::TabFocusModel:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = nsIContent::eTabFocus_textControlsMask;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ChosenMenuItemsShouldBlink:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 1;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::WindowsAccentColorInTitlebar:
|
|
|
|
case IntID::WindowsDefaultTheme:
|
|
|
|
case IntID::DWMCompositor:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::WindowsClassic:
|
|
|
|
case IntID::WindowsGlass:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::AlertNotificationOrigin:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = NS_ALERT_TOP;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollToClick:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::IMERawInputUnderlineStyle:
|
|
|
|
case IntID::IMESelectedRawTextUnderlineStyle:
|
|
|
|
case IntID::IMEConvertedTextUnderlineStyle:
|
|
|
|
case IntID::IMESelectedConvertedTextUnderline:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::SpellCheckerUnderlineStyle:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = NS_STYLE_TEXT_DECORATION_STYLE_DOTTED;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::MenuBarDrag:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::OperatingSystemVersionIdentifier:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
res = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollbarButtonAutoRepeatBehavior:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::TooltipDelay:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 500;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::SwipeAnimationEnabled:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollbarDisplayOnMouseMove:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollbarFadeBeginDelay:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ScrollbarFadeDuration:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ContextMenuOffsetVertical:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = -6;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::ContextMenuOffsetHorizontal:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 1;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::GTKCSDAvailable:
|
2018-01-12 21:10:41 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::GTKCSDMinimizeButton:
|
2018-01-12 21:10:41 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::GTKCSDMaximizeButton:
|
2018-01-12 21:10:41 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::GTKCSDCloseButton:
|
2018-01-12 21:10:41 +03:00
|
|
|
aResult = 1;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::GTKCSDReversedPlacement:
|
2019-01-18 16:52:29 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::SystemUsesDarkTheme:
|
2019-11-11 14:04:31 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::PrefersReducedMotion:
|
2019-11-11 14:04:31 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::PrimaryPointerCapabilities:
|
2019-11-11 14:04:31 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case IntID::AllPointerCapabilities:
|
2019-11-11 14:04:31 +03:00
|
|
|
aResult = 0;
|
|
|
|
break;
|
2017-07-06 05:41:21 +03:00
|
|
|
default:
|
|
|
|
aResult = 0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2020-11-21 02:52:47 +03:00
|
|
|
nsresult HeadlessLookAndFeel::NativeGetFloat(FloatID aID, float& aResult) {
|
|
|
|
nsresult res = NS_OK;
|
2017-07-06 05:41:21 +03:00
|
|
|
|
|
|
|
// Hardcoded values for GTK.
|
|
|
|
switch (aID) {
|
2020-06-11 14:27:43 +03:00
|
|
|
case FloatID::IMEUnderlineRelativeSize:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 1.0f;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case FloatID::SpellCheckerUnderlineRelativeSize:
|
2017-07-06 05:41:21 +03:00
|
|
|
aResult = 1.0f;
|
|
|
|
break;
|
2020-06-11 14:27:43 +03:00
|
|
|
case FloatID::CaretAspectRatio:
|
2017-07-06 05:41:21 +03:00
|
|
|
// Intentionally failing to quietly indicate lack of support.
|
|
|
|
aResult = -1.0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aResult = -1.0;
|
|
|
|
res = NS_ERROR_FAILURE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2020-11-21 02:52:47 +03:00
|
|
|
bool HeadlessLookAndFeel::NativeGetFont(FontID aID, nsString& aFontName,
|
|
|
|
gfxFontStyle& aFontStyle) {
|
2017-09-21 21:57:09 +03:00
|
|
|
// Default to san-serif for everything.
|
2018-04-23 17:52:20 +03:00
|
|
|
aFontStyle.style = FontSlantStyle::Normal();
|
2018-04-13 22:34:37 +03:00
|
|
|
aFontStyle.weight = FontWeight::Normal();
|
2018-04-23 17:52:20 +03:00
|
|
|
aFontStyle.stretch = FontStretch::Normal();
|
2019-02-08 16:22:11 +03:00
|
|
|
aFontStyle.size = 14;
|
2017-09-21 21:57:09 +03:00
|
|
|
aFontStyle.systemFont = true;
|
2017-07-06 05:41:21 +03:00
|
|
|
|
2017-09-21 21:57:09 +03:00
|
|
|
aFontName.AssignLiteral("sans-serif");
|
2017-07-06 05:41:21 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
char16_t HeadlessLookAndFeel::GetPasswordCharacterImpl() {
|
|
|
|
return UNICODE_BULLET;
|
|
|
|
}
|
|
|
|
|
2021-03-31 01:58:22 +03:00
|
|
|
} // namespace mozilla::widget
|