Skip to content

Commit

Permalink
Backed out changeset 282b96702ce9 (bug 1687682) for causing multiple …
Browse files Browse the repository at this point in the history
…mochitest failures.
  • Loading branch information
Iulian Moraru committed Sep 11, 2021
1 parent e53d061 commit 1121a4a
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 86 deletions.
20 changes: 0 additions & 20 deletions layout/style/res/forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -999,26 +999,6 @@ input:autofill {
filter: grayscale(21%) brightness(88%) contrast(161%) invert(10%) sepia(40%) saturate(206%);
}

@supports -moz-bool-pref("layout.css.autofill.background") {
/* We find a few pages where using `filter` causes issues because it
* changes the z-order (see bug 1687682, bug 1727950).
*
* The idea behind using background-image instead of plain background-color,
* is that it's less likely to be overridden by the page.
*
* The color is chosen so that you get the same final color on a white
* background as the filter above (#fffcc8), but with some alpha so as to
* prevent fully illegible text.
*
* NOTE(emilio): Keep the color in sync with kAutofillColor in
* nsNativeBasicTheme!
*/
input:autofill {
filter: none;
background-image: linear-gradient(rgba(255, 249, 145, 0.5), rgba(255, 249, 145, 0.5));
}
}

input:-moz-autofill-preview {
color: GrayText;
}
6 changes: 0 additions & 6 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6742,12 +6742,6 @@
mirror: always
rust: true

# Whether to use background-image to style autofill controls.
- name: layout.css.autofill.background
type: bool
value: true
mirror: always

# Whether the `:-moz-submit-invalid` pseudo-class is exposed to content.
- name: layout.css.moz-submit-invalid.enabled
type: RelaxedAtomicBool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ add_task(async function fill_generated_password_empty_field() {
function checkInitialFieldValue(inputSelector) {
const input = content.document.querySelector(inputSelector);
is(input.value.length, 0, "Password field is empty");
ok(
!input.matches(":autofill"),
is(
content.getComputedStyle(input).filter,
"none",
"Password field should not be highlighted"
);
}
Expand All @@ -164,8 +165,9 @@ add_task(async function fill_generated_password_empty_field() {
LTU.generation.LENGTH,
"Password field was filled with generated password"
);
ok(
input.matches(":autofill"),
isnot(
content.getComputedStyle(input).filter,
"none",
"Password field should be highlighted"
);
LTU.loginField.checkPasswordMasked(input, false, "after fill");
Expand Down Expand Up @@ -208,8 +210,9 @@ add_task(async function fill_generated_password_nonempty_field() {
[[passwordInputSelector]],
function checkInitialFieldValue(inputSelector) {
const input = content.document.querySelector(inputSelector);
ok(
!input.matches(":autofill"),
is(
content.getComputedStyle(input).filter,
"none",
"Password field should not be highlighted"
);
}
Expand All @@ -232,8 +235,9 @@ add_task(async function fill_generated_password_nonempty_field() {
LTU.generation.LENGTH,
"Password field was filled with generated password"
);
ok(
input.matches(":autofill"),
isnot(
content.getComputedStyle(input).filter,
"none",
"Password field should be highlighted"
);
LTU.loginField.checkPasswordMasked(input, false, "after fill");
Expand Down Expand Up @@ -299,8 +303,9 @@ add_task(async function fill_generated_password_with_matching_logins() {
LTU.generation.LENGTH,
"Password field was filled with generated password"
);
ok(
input.matches(":autofill"),
isnot(
content.getComputedStyle(input).filter,
"none",
"Password field should be highlighted"
);
LTU.loginField.checkPasswordMasked(input, false, "after fill");
Expand Down Expand Up @@ -391,8 +396,9 @@ add_task(async function test_edited_generated_password_in_new_tab() {
function checkInitialFieldValue(inputSelector) {
const input = content.document.querySelector(inputSelector);
is(input.value.length, 0, "Password field is empty");
ok(
!input.matches(":autofill"),
is(
content.getComputedStyle(input).filter,
"none",
"Password field should not be highlighted"
);
}
Expand All @@ -415,8 +421,9 @@ add_task(async function test_edited_generated_password_in_new_tab() {
LTU.generation.LENGTH,
"Password field was filled with generated password"
);
ok(
input.matches(":autofill"),
isnot(
content.getComputedStyle(input).filter,
"none",
"Password field should be highlighted"
);
LTU.loginField.checkPasswordMasked(input, false, "after fill");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@
await synthesizeKey("KEY_Enter");

await ContentTaskUtils.waitForCondition(() => {
return username.matches(":autofill")
return document.defaultView.getComputedStyle(username).getPropertyValue("filter") !== "none";
}, "Highlight was successfully applied to the username field on username autocomplete");

ok(password.matches(":autofill"),
"Highlight was successfully applied to the password field on username autocomplete");
isnot(document.defaultView.getComputedStyle(password).getPropertyValue("filter"), "none",
"Highlight was successfully applied to the password field on username autocomplete");

// Clear existing highlight on login fields. We check by pressing the tab key after backspace
// (by shifting focus to the next element) because the tab key was known to cause a bug where the
// highlight is applied once again. See Bug 1526522.
username.focus();
synthesizeKey("KEY_Backspace");
synthesizeKey("KEY_Tab");
ok(!username.matches(":autofill"),
is(document.defaultView.getComputedStyle(username).getPropertyValue("filter"), "none",
"Highlight was successfully removed on the username field");

synthesizeKey("KEY_Backspace");
synthesizeKey("KEY_Tab");
ok(!password.matches(":autofill"),
is(document.defaultView.getComputedStyle(password).getPropertyValue("filter"), "none",
"Highlight was successfully removed on the password field");

// Clear login fields.
Expand All @@ -82,7 +82,7 @@
synthesizeKey("KEY_Enter");

await ContentTaskUtils.waitForCondition(() => {
return password.matches(":autofill");
return document.defaultView.getComputedStyle(password).getPropertyValue("filter") !== "none";
}, "Highlight was successfully applied to the password field on password autocomplete");

// Clear existing highlight on the password field. We check by pressing the tab key after backspace
Expand All @@ -91,7 +91,7 @@
synthesizeKey("KEY_Backspace");
synthesizeKey("KEY_Tab");

ok(!password.matches(":autofill"),
is(document.defaultView.getComputedStyle(password).getPropertyValue("filter"), "none",
"Highlight was successfully removed on the password field");

// Clear login fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
await synthesizeKey("KEY_Enter");

await ContentTaskUtils.waitForCondition(() => {
return username.matches(":autofill");
return document.defaultView.getComputedStyle(username).getPropertyValue("filter") !== "none";
}, "Highlight was successfully applied to the username field on username autocomplete");

// Clear existing highlight on login fields. We check by pressing the tab key after backspace
Expand All @@ -56,7 +56,7 @@
username.focus();
synthesizeKey("KEY_Backspace");
synthesizeKey("KEY_Tab");
ok(!username.matches(":autofill"),
is(document.defaultView.getComputedStyle(username).getPropertyValue("filter"), "none",
"Highlight was successfully removed on the username field");

// Clear login fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@
// check field filling & highlights
if (expectedFilled.includes(input.name)) {
await ContentTaskUtils.waitForCondition(() => {
return input.matches(":autofill");
return document.defaultView.getComputedStyle(input).getPropertyValue("filter") !== "none";
}, `Highlight was successfully applied to the (${input.name}) field`);

is(input.value, generatedPW, `Field (${input.name}) has the generated password value`);
} else {
await ContentTaskUtils.waitForCondition(() => {
return !input.matches(":autofill");
return document.defaultView.getComputedStyle(input).getPropertyValue("filter") == "none";
}, `Highlight was not applied to field (${input.name})`);

let expectedValue = (input.name in expectedNonDefaultValues) ? expectedNonDefaultValues[input.name] : input.defaultValue;
Expand Down Expand Up @@ -222,7 +222,7 @@
synthesizeKey("KEY_Backspace");
await TestUtils.waitForTick();
await ContentTaskUtils.waitForCondition(() => {
return !pword2.matches(":autofill");
return document.defaultView.getComputedStyle(pword2).getPropertyValue("filter") == "none";
}, "Highlight was successfully cleared from the confirm-password field");

// if it got originally masked (i.e. was a password field) verify the focused confirm field now masks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
let doc = this.content.document;
let username = doc.getElementById("uname");
let password = doc.getElementById("pword");
ok(username.matches(":autofill"),
"Highlight was successfully applied to the username field on page load autofill");
ok(password.matches(":autofill"),
"Highlight was successfully applied to the password field on page load autofill");
isnot(doc.defaultView.getComputedStyle(username).getPropertyValue("filter"), "none",
"Highlight was successfully applied to the username field on page load autofill");
isnot(doc.defaultView.getComputedStyle(password).getPropertyValue("filter"), "none",
"Highlight was successfully applied to the password field on page load autofill");

// Test that initiating a change on the input value will remove the highlight. We check by pressing
// the tab key after backspace(by shifting focus to the next element) because the tab key is known to
Expand All @@ -47,11 +47,13 @@
await EventUtils.synthesizeKey("KEY_Backspace", {}, this.content);
await EventUtils.synthesizeKey("KEY_Tab", {}, this.content);

ok(!username.matches(":autofill"), "Highlight was successfully removed on change in value of username input element");
let computedStyle = doc.defaultView.getComputedStyle(username);
is(computedStyle.getPropertyValue("filter"), "none", "Highlight was successfully removed on change in value of username input element");

await EventUtils.synthesizeKey("KEY_Backspace", {}, this.content);
await EventUtils.synthesizeKey("KEY_Tab", {}, this.content);
ok(!password.matches(":autofill"), "Highlight was successfully removed on change in value of password input element");
computedStyle = doc.defaultView.getComputedStyle(password);
is(computedStyle.getPropertyValue("filter"), "none", "Highlight was successfully removed on change in value of password input element");
});
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
let doc = this.content.document;
let username = doc.getElementById("uname");
let password = doc.getElementById("pword");
ok(!username.matches(":autofill"),
is(doc.defaultView.getComputedStyle(username).getPropertyValue("filter"), "none",
"Highlight was not applied to the username field on page load autofill");
ok(password.matches(":autofill"),
isnot(doc.defaultView.getComputedStyle(password).getPropertyValue("filter"), "none",
"Highlight was successfully applied to the password field on page load autofill");

// Test that initiating a change on the input value will remove the highlight. We check by pressing
Expand All @@ -47,11 +47,13 @@
await EventUtils.synthesizeKey("U", {}, this.content);
await EventUtils.synthesizeKey("KEY_Tab", {}, this.content);

ok(!username.matches(":autofill"), "Highlight is still not present on username element");
let computedStyle = doc.defaultView.getComputedStyle(username);
is(computedStyle.getPropertyValue("filter"), "none", "Highlight is still not present on username element");

await EventUtils.synthesizeKey("KEY_Backspace", {}, this.content);
await EventUtils.synthesizeKey("KEY_Tab", {}, this.content);
ok(!password.matches(":autofill"), "Highlight was successfully removed on change in value of password input element");
computedStyle = doc.defaultView.getComputedStyle(password);
is(computedStyle.getPropertyValue("filter"), "none", "Highlight was successfully removed on change in value of password input element");
});
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
let EventUtils = ContentTaskUtils.getEventUtils(this.content);
let doc = this.content.document;
let username = doc.getElementById("uname");
ok(username.matches(":autofill"),
isnot(doc.defaultView.getComputedStyle(username).getPropertyValue("filter"), "none",
"Highlight was successfully applied to the username field on page load autofill");

// Test that initiating a change on the input value will remove the highlight. We check by pressing
Expand All @@ -43,7 +43,8 @@
await EventUtils.synthesizeKey("KEY_Backspace", {}, this.content);
await EventUtils.synthesizeKey("KEY_Tab", {}, this.content);

ok(!username.matches(":autofill"), "Highlight was successfully removed on change in value of username input element");
let computedStyle = doc.defaultView.getComputedStyle(username);
is(computedStyle.getPropertyValue("filter"), "none", "Highlight was successfully removed on change in value of username input element");
});
});
</script>
Expand Down
30 changes: 8 additions & 22 deletions widget/nsNativeBasicTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,11 @@ static bool IsScrollbarWidthThin(nsIFrame* aFrame) {
return scrollbarWidth == StyleScrollbarWidth::Thin;
}

static nscolor SystemNsColor(StyleSystemColor aColor) {
static sRGBColor SystemColor(StyleSystemColor aColor) {
// TODO(emilio): We could not hardcode light appearance here with a bit of
// work, but doesn't matter for now.
return LookAndFeel::Color(aColor, LookAndFeel::ColorScheme::Light,
LookAndFeel::UseStandins::No);
}

static sRGBColor SystemColor(StyleSystemColor aColor) {
return sRGBColor::FromABGR(SystemNsColor(aColor));
return sRGBColor::FromABGR(LookAndFeel::Color(
aColor, LookAndFeel::ColorScheme::Light, LookAndFeel::UseStandins::No));
}

template <typename Compute>
Expand Down Expand Up @@ -530,29 +526,19 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeButtonColors(
return std::make_pair(backgroundColor, borderColor);
}

// NOTE: This should be kept in sync with forms.css, see the comment in the
// input:autofill rule.
constexpr nscolor kAutofillColor = NS_RGBA(255, 249, 145, 128);

std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeTextfieldColors(
const EventStates& aState, UseSystemColors aUseSystemColors) {
nscolor backgroundColor = [&] {
const sRGBColor backgroundColor = [&] {
if (bool(aUseSystemColors)) {
return SystemNsColor(StyleSystemColor::Field);
return SystemColor(StyleSystemColor::TextBackground);
}
if (aState.HasState(NS_EVENT_STATE_DISABLED)) {
return NS_RGBA(0xff, 0xff, 0xff, 128);
return sColorWhiteAlpha50;
}
return NS_RGB(0xff, 0xff, 0xff);
return sColorWhite;
}();

if (aState.HasState(NS_EVENT_STATE_AUTOFILL) &&
StaticPrefs::layout_css_autofill_background()) {
backgroundColor = NS_ComposeColors(backgroundColor, kAutofillColor);
}

const sRGBColor borderColor = ComputeBorderColor(aState, aUseSystemColors);
return std::make_pair(sRGBColor::FromABGR(backgroundColor), borderColor);
return std::make_pair(backgroundColor, borderColor);
}

std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeRangeProgressColors(
Expand Down

0 comments on commit 1121a4a

Please sign in to comment.