Skip to content

Commit

Permalink
Bug 1620467 - Part 9: Make appearance: textfield behave like auto e…
Browse files Browse the repository at this point in the history
…xcept on search and number inputs. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D83435
  • Loading branch information
heycam committed Jul 16, 2020
1 parent 557d031 commit 9f7843c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
34 changes: 29 additions & 5 deletions layout/style/nsStyleStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -1332,12 +1332,36 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
}

mozilla::StyleAppearance EffectiveAppearance() const {
if (mAppearance == mozilla::StyleAppearance::Auto ||
(mAppearance == mozilla::StyleAppearance::Button &&
mButtonAppearance == mozilla::StyleButtonAppearance::Disallow)) {
return mDefaultAppearance;
switch (mAppearance) {
case mozilla::StyleAppearance::Auto:
return mDefaultAppearance;
case mozilla::StyleAppearance::Textfield:
// `appearance: textfield` should behave like `auto` on all elements
// except <input type=search> elements, which we identify using the
// internal -moz-default-appearance property. (In the browser chrome
// we have some other elements that set `-moz-default-appearance:
// searchfield`, but not in content documents.)
if (mDefaultAppearance == mozilla::StyleAppearance::Searchfield) {
return mAppearance;
}
// We also need to support `appearance: textfield` on <input
// type=number>, since that is the only way in Gecko to disable the
// spinners.
if (mDefaultAppearance == mozilla::StyleAppearance::NumberInput) {
return mAppearance;
}
return mDefaultAppearance;
case mozilla::StyleAppearance::Button:
// `appearance: button` should behave like `auto` for a specific list
// of widget elements, and we encode that using the internal
// -moz-button-appearance property.
if (mButtonAppearance == mozilla::StyleButtonAppearance::Disallow) {
return mDefaultAppearance;
}
return mAppearance;
default:
return mAppearance;
}
return mAppearance;
}

static mozilla::StyleDisplayOutside DisplayOutside(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[appearance-textfield-001.html]
disabled:
if os == "win": https://bugzilla.mozilla.org/show_bug.cgi?id=1562932
expected: FAIL
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[webkit-appearance-textfield-001.html]
disabled:
if os == "win": https://bugzilla.mozilla.org/show_bug.cgi?id=1562932
expected: FAIL
3 changes: 2 additions & 1 deletion toolkit/themes/linux/global/search-textbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
/* ::::: search textbox ::::: */

:host {
appearance: textfield;
appearance: auto;
-moz-default-appearance: textfield;
cursor: text;
margin: 2px 4px; /* matches <input> global.css margin */
padding: 2px 2px 3px;
Expand Down
3 changes: 2 additions & 1 deletion toolkit/themes/windows/global/search-textbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
/* ::::: search textbox ::::: */

:host {
appearance: textfield;
appearance: auto;
-moz-default-appearance: textfield;
cursor: text;
margin: 2px 4px; /* matches <input> global.css margin */
padding: 2px 2px 3px;
Expand Down

0 comments on commit 9f7843c

Please sign in to comment.