зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1476524 - Don't require so much contrast for selection background-against-background checks. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D111794
This commit is contained in:
Родитель
85b254d181
Коммит
b7fda546dc
|
@ -15,6 +15,12 @@
|
|||
// "Techniques For Accessibility Evalution And Repair Tools".
|
||||
// See http://www.w3.org/TR/AERT#color-contrast
|
||||
#define NS_SUFFICIENT_LUMINOSITY_DIFFERENCE 125000
|
||||
// NS_SUFFICIENT_LUMINOSITY_DIFFERENCE is the a11y standard for text
|
||||
// on a background. Use 20% of that standard since we have a background
|
||||
// on top of another background
|
||||
#define NS_SUFFICIENT_LUMINOSITY_DIFFERENCE_BG \
|
||||
(NS_SUFFICIENT_LUMINOSITY_DIFFERENCE / 5)
|
||||
|
||||
#define NS_LUMINOSITY_DIFFERENCE(a, b) \
|
||||
int32_t(mozilla::Abs(NS_GetLuminosity(a | 0xff000000) - \
|
||||
NS_GetLuminosity(b | 0xff000000)))
|
||||
|
|
|
@ -3837,10 +3837,18 @@ bool nsTextPaintStyle::EnsureSufficientContrast(nscolor* aForeColor,
|
|||
InitCommonColors();
|
||||
|
||||
// If the combination of selection background color and frame background color
|
||||
// is sufficient contrast, don't exchange the selection colors.
|
||||
int32_t backLuminosityDifference =
|
||||
// has sufficient contrast, don't exchange the selection colors.
|
||||
//
|
||||
// Note we use a different threshold here: mSufficientContrast is for contrast
|
||||
// between text and background colors, but since we're diffing two
|
||||
// backgrounds, we don't need that much contrast. We match the heuristic from
|
||||
// NS_SUFFICIENT_LUMINOSITY_DIFFERENCE_BG and use 20% of mSufficientContrast.
|
||||
const int32_t minLuminosityDifferenceForBackground = mSufficientContrast / 5;
|
||||
const int32_t backLuminosityDifference =
|
||||
NS_LUMINOSITY_DIFFERENCE(*aBackColor, mFrameBackgroundColor);
|
||||
if (backLuminosityDifference >= mSufficientContrast) return false;
|
||||
if (backLuminosityDifference >= minLuminosityDifferenceForBackground) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, we should use the higher-contrast color for the selection
|
||||
// background color.
|
||||
|
@ -4023,7 +4031,9 @@ bool nsTextPaintStyle::GetSelectionUnderlineForPaint(int32_t aIndex,
|
|||
}
|
||||
|
||||
void nsTextPaintStyle::InitCommonColors() {
|
||||
if (mInitCommonColors) return;
|
||||
if (mInitCommonColors) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsIFrame* bgFrame = nsCSSRendering::FindNonTransparentBackgroundFrame(mFrame);
|
||||
NS_ASSERTION(bgFrame, "Cannot find NonTransparentBackgroundFrame.");
|
||||
|
|
|
@ -213,10 +213,7 @@ static bool GetBorderColors(GtkStyleContext* aContext, nscolor* aLightColor,
|
|||
// from both Highlight, used as focused+selected background, and the listbox
|
||||
// background which is assumed to be similar to -moz-field
|
||||
nsresult nsLookAndFeel::InitCellHighlightColors() {
|
||||
// NS_SUFFICIENT_LUMINOSITY_DIFFERENCE is the a11y standard for text
|
||||
// on a background. Use 20% of that standard since we have a background
|
||||
// on top of another background
|
||||
int32_t minLuminosityDifference = NS_SUFFICIENT_LUMINOSITY_DIFFERENCE / 5;
|
||||
int32_t minLuminosityDifference = NS_SUFFICIENT_LUMINOSITY_DIFFERENCE_BG;
|
||||
int32_t backLuminosityDifference =
|
||||
NS_LUMINOSITY_DIFFERENCE(mMozWindowBackground, mFieldBackground);
|
||||
if (backLuminosityDifference >= minLuminosityDifference) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче