зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1720792: Add MozNativevisitedhyperlinktext color, use it to style visited links r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D120657
This commit is contained in:
Родитель
48d950012e
Коммит
72570f3a98
|
@ -112,18 +112,29 @@ void PreferenceSheet::Prefs::Load(bool aIsChrome) {
|
|||
useStandins ? ColorID::Window : ColorID::WindowBackground, scheme,
|
||||
standins, mColors.mDefaultBackground);
|
||||
mColors.mLink = LookAndFeel::Color(ColorID::MozNativehyperlinktext, scheme,
|
||||
standins, mColors.mLink);
|
||||
standins, mColors.mLink);
|
||||
|
||||
if (auto color = LookAndFeel::GetColor(
|
||||
ColorID::MozNativevisitedhyperlinktext, scheme, standins)) {
|
||||
// If the system provides a visited link color, we should use it.
|
||||
mColors.mVisitedLink = *color;
|
||||
} else if (mUseAccessibilityTheme) {
|
||||
// The fallback visited link color on HCM (if the system doesn't provide
|
||||
// one) is produced by preserving the foreground's green and averaging the
|
||||
// foreground and background for the red and blue. This is how IE and
|
||||
// Edge do it too.
|
||||
mColors.mVisitedLink = NS_RGB(AVG2(NS_GET_R(mColors.mDefault),
|
||||
NS_GET_R(mColors.mDefaultBackground)),
|
||||
NS_GET_G(mColors.mDefault),
|
||||
AVG2(NS_GET_B(mColors.mDefault),
|
||||
NS_GET_B(mColors.mDefaultBackground)));
|
||||
} else {
|
||||
// Otherwise we keep the default visited link color
|
||||
}
|
||||
}
|
||||
|
||||
if (mUseAccessibilityTheme && !useStandins) {
|
||||
mColors.mActiveLink = mColors.mLink;
|
||||
// Visited link color is produced by preserving the foreground's green
|
||||
// and averaging the foreground and background for the red and blue.
|
||||
// This is how IE and Edge do it too.
|
||||
mColors.mVisitedLink = NS_RGB(
|
||||
AVG2(NS_GET_R(mColors.mDefault), NS_GET_R(mColors.mDefaultBackground)),
|
||||
NS_GET_G(mColors.mDefault),
|
||||
AVG2(NS_GET_B(mColors.mDefault), NS_GET_B(mColors.mDefaultBackground)));
|
||||
} else {
|
||||
GetColor("browser.active_color", mColors.mActiveLink);
|
||||
GetColor("browser.visited_color", mColors.mVisitedLink);
|
||||
|
|
|
@ -11,6 +11,7 @@ const NON_CONTENT_ACCESSIBLE_VALUES = {
|
|||
"-moz-colheadertext",
|
||||
"-moz-system-color(highlight, light)",
|
||||
"-moz-system-color(highlight, dark)",
|
||||
"-moz-nativevisitedhyperlinktext",
|
||||
"text-select-foreground",
|
||||
"text-select-background",
|
||||
"text-select-background-disabled",
|
||||
|
|
|
@ -362,6 +362,10 @@ pub enum SystemColor {
|
|||
/// colors.
|
||||
MozNativehyperlinktext,
|
||||
|
||||
/// As above, but visited link color.
|
||||
#[css(skip)]
|
||||
MozNativevisitedhyperlinktext,
|
||||
|
||||
#[parse(aliases = "-moz-hyperlinktext")]
|
||||
Linktext,
|
||||
#[parse(aliases = "-moz-activehyperlinktext")]
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
|
||||
using NSAppearanceName = NSString*;
|
||||
|
||||
@interface NSColor (NSColor10_13)
|
||||
// "Available in 10.10", but not present in any SDK less than 10.13
|
||||
@property(class, strong, readonly) NSColor* systemPurpleColor NS_AVAILABLE_MAC(10_10);
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(MAC_OS_X_VERSION_10_14) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_14
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "SDKDeclarations.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <AppKit/NSColor.h>
|
||||
|
||||
// This must be included last:
|
||||
#include "nsObjCExceptions.h"
|
||||
|
@ -337,6 +338,9 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
|
|||
case ColorID::MozNativehyperlinktext:
|
||||
color = GetColorFromNSColor(NSColor.linkColor);
|
||||
break;
|
||||
case ColorID::MozNativevisitedhyperlinktext:
|
||||
color = GetColorFromNSColor(NSColor.systemPurpleColor);
|
||||
break;
|
||||
// The following colors are supposed to be used as font-smoothing background
|
||||
// colors, in the chrome-only -moz-font-smoothing-background-color property.
|
||||
// This property is used for text on "vibrant" -moz-appearances.
|
||||
|
|
|
@ -303,6 +303,7 @@ static const char sColorPrefs[][41] = {
|
|||
"ui.-moz-win-mediatext",
|
||||
"ui.-moz-win-communicationstext",
|
||||
"ui.-moz-nativehyperlinktext",
|
||||
"ui.-moz-nativevisitedhyperlinktext",
|
||||
"ui.-moz-hyperlinktext",
|
||||
"ui.-moz-activehyperlinktext",
|
||||
"ui.-moz-visitedhyperlinktext",
|
||||
|
@ -579,6 +580,7 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID) {
|
|||
COLOR(MozWinMediatext, 0xFF, 0xFF, 0xFF)
|
||||
COLOR(MozWinCommunicationstext, 0xFF, 0xFF, 0xFF)
|
||||
COLOR(MozNativehyperlinktext, 0x00, 0x66, 0xCC)
|
||||
COLOR(MozNativevisitedhyperlinktext, 0x55, 0x1A, 0x8B)
|
||||
COLOR(MozComboboxtext, 0x00, 0x00, 0x00)
|
||||
COLOR(MozCombobox, 0xFF, 0xFF, 0xFF)
|
||||
default:
|
||||
|
|
|
@ -248,6 +248,11 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID, ColorScheme, nscolor& aResult) {
|
|||
// There appears to be no available system defined color. HARDCODING to the appropriate color.
|
||||
aResult = NS_RGB(0x14, 0x4F, 0xAE);
|
||||
break;
|
||||
case ColorID::MozNativevisitedhyperlinktext:
|
||||
// Safari defaults to the MacOS color implementation for visited links, which in turn uses
|
||||
// systemPurpleColor, so we do the same here.
|
||||
aResult = GetColorFromUIColor([UIColor systemPurpleColor]);
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Someone asked nsILookAndFeel for a color I don't know about");
|
||||
aResult = NS_RGB(0xff, 0xff, 0xff);
|
||||
|
|
Загрузка…
Ссылка в новой задаче