Bug 1698821 - Fix GetNumberControlFrameForSpinButton. r=dholbert

It broke with bug 1698043 because we removed one wrapper.

Differential Revision: https://phabricator.services.mozilla.com/D108654
This commit is contained in:
Emilio Cobos Álvarez 2021-03-16 21:53:20 +00:00
Родитель e65533e909
Коммит 3df7550e39
4 изменённых файлов: 31 добавлений и 16 удалений

Просмотреть файл

@ -111,24 +111,20 @@ nsNumberControlFrame* nsNumberControlFrame::GetNumberControlFrameForTextField(
nsNumberControlFrame* nsNumberControlFrame::GetNumberControlFrameForSpinButton(
nsIFrame* aFrame) {
// If aFrame is a spin button for an <input type=number> then we expect the
// frame of its mContent's great-grandparent to be that input's frame. We
// have to check for this via the content tree because we don't know whether
// extra frames will be wrapped around any of the elements between aFrame and
// the nsNumberControlFrame that we're looking for (e.g. flex wrappers).
// frame of the NAC root parent to be that input's frame. We have to check for
// this via the content tree because we don't know whether extra frames will
// be wrapped around any of the elements between aFrame and the
// nsNumberControlFrame that we're looking for (e.g. flex wrappers).
nsIContent* content = aFrame->GetContent();
if (content->IsInNativeAnonymousSubtree() && content->GetParent() &&
content->GetParent()->GetParent() &&
content->GetParent()->GetParent()->GetParent()) {
nsIContent* greatgrandparent =
content->GetParent()->GetParent()->GetParent();
if (greatgrandparent->IsHTMLElement(nsGkAtoms::input) &&
greatgrandparent->AsElement()->AttrValueIs(
kNameSpaceID_None, nsGkAtoms::type, nsGkAtoms::number,
eCaseMatters)) {
return do_QueryFrame(greatgrandparent->GetPrimaryFrame());
}
auto* nacHost = content->GetClosestNativeAnonymousSubtreeRootParent();
if (!nacHost) {
return nullptr;
}
return nullptr;
auto* input = HTMLInputElement::FromNode(nacHost);
if (!input || input->ControlType() != NS_FORM_INPUT_NUMBER) {
return nullptr;
}
return do_QueryFrame(input->GetPrimaryFrame());
}
int32_t nsNumberControlFrame::GetSpinButtonForPointerEvent(

Просмотреть файл

@ -0,0 +1,9 @@
<!doctype html>
<style>
input {
border: none;
background: white;
color: black;
}
</style>
<input type=number>

Просмотреть файл

@ -0,0 +1,9 @@
<!doctype html>
<style>
input {
border: none;
background: white;
color: black;
}
</style>
<input type=number disabled>

Просмотреть файл

@ -17,6 +17,7 @@ fuzzy-if(skiaContent,0-2,0-13) == show-value.html show-value-ref.html
# disabled
== number-disabled.html number-disabled-ref.html
!= number-spinbox-disabled.html number-spinbox-disabled-notref.html
# auto width:
== number-auto-width-1.html number-auto-width-1-ref.html