From c405a6ab26351e92c830bb398bfa91ded7878a13 Mon Sep 17 00:00:00 2001 From: Butkovits Atila Date: Tue, 8 Dec 2020 14:46:48 +0200 Subject: [PATCH] Backed out changeset 29bbd5887d66 (bug 1680951) for failure on browser_blockingCookies.js. CLOSED TREE --- dom/html/HTMLInputElement.cpp | 6 +-- dom/html/TextControlState.cpp | 10 ++--- dom/html/TextControlState.h | 11 +++-- .../forms/textfieldselection/selection.html | 44 +------------------ 4 files changed, 13 insertions(+), 58 deletions(-) diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 7b3a7ae8b197..3dae7574180c 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -3050,9 +3050,9 @@ void HTMLInputElement::Select() { // HTMLInputElement::SetSelectionRange only applies to fewer types // TODO(krosylight): This should pass eNone per the spec, but we don't support // it yet. See bug 1541454. - state->SetSelectionRange(0, UINT32_MAX, Optional(), - IgnoredErrorResult(), - TextControlState::ScrollAfterSelection::No); + state->SetSelectionRange(0, UINT32_MAX, + nsITextControlFrame::SelectionDirection::eForward, + IgnoredErrorResult()); } void HTMLInputElement::DispatchSelectEvent(nsPresContext* aPresContext) { diff --git a/dom/html/TextControlState.cpp b/dom/html/TextControlState.cpp index 649d2fe41aa2..8bb547b225e0 100644 --- a/dom/html/TextControlState.cpp +++ b/dom/html/TextControlState.cpp @@ -2055,8 +2055,7 @@ nsITextControlFrame::SelectionDirection TextControlState::GetSelectionDirection( void TextControlState::SetSelectionRange( uint32_t aStart, uint32_t aEnd, - nsITextControlFrame::SelectionDirection aDirection, ErrorResult& aRv, - ScrollAfterSelection aScroll) { + nsITextControlFrame::SelectionDirection aDirection, ErrorResult& aRv) { MOZ_ASSERT(IsSelectionCached() || mBoundFrame, "How can we have a non-cached selection but no frame?"); @@ -2083,7 +2082,7 @@ void TextControlState::SetSelectionRange( handlingSetSelectionRange.IsTextControlStateDestroyed()) { return; } - if (aScroll == ScrollAfterSelection::Yes) { + if (mBoundFrame) { mBoundFrame->ScrollSelectionIntoViewAsync(); } // Press on to firing the event even if that failed, like our old code did. @@ -2225,12 +2224,11 @@ DirectionStringToSelectionDirection(const Optional& aDirection) { void TextControlState::SetSelectionRange(uint32_t aSelectionStart, uint32_t aSelectionEnd, const Optional& aDirection, - ErrorResult& aRv, - ScrollAfterSelection aScroll) { + ErrorResult& aRv) { nsITextControlFrame::SelectionDirection dir = DirectionStringToSelectionDirection(aDirection); - SetSelectionRange(aSelectionStart, aSelectionEnd, dir, aRv, aScroll); + SetSelectionRange(aSelectionStart, aSelectionEnd, dir, aRv); // The instance may have already been deleted here. } diff --git a/dom/html/TextControlState.h b/dom/html/TextControlState.h index 01373a354319..242d281f335f 100644 --- a/dom/html/TextControlState.h +++ b/dom/html/TextControlState.h @@ -334,8 +334,6 @@ class TextControlState final : public SupportsWeakPtr { nsITextControlFrame::SelectionDirection GetSelectionDirection( ErrorResult& aRv); - enum class ScrollAfterSelection { No, Yes }; - // Set the selection range (start, end, direction). aEnd is allowed to be // smaller than aStart; in that case aStart will be reset to the same value as // aEnd. This basically implements @@ -345,18 +343,19 @@ class TextControlState final : public SupportsWeakPtr { // SelectionDirection. // // If we have a frame, this method will scroll the selection into view. + // + // XXXbz This should really take uint32_t, but none of our guts (either the + // frame or our cached selection state) work with uint32_t at the moment... MOZ_CAN_RUN_SCRIPT void SetSelectionRange( uint32_t aStart, uint32_t aEnd, - nsITextControlFrame::SelectionDirection aDirection, ErrorResult& aRv, - ScrollAfterSelection aScroll = ScrollAfterSelection::Yes); + nsITextControlFrame::SelectionDirection aDirection, ErrorResult& aRv); // Set the selection range, but with an optional string for the direction. // This will convert aDirection to an nsITextControlFrame::SelectionDirection // and then call our other SetSelectionRange overload. MOZ_CAN_RUN_SCRIPT void SetSelectionRange( uint32_t aSelectionStart, uint32_t aSelectionEnd, - const dom::Optional& aDirection, ErrorResult& aRv, - ScrollAfterSelection aScroll = ScrollAfterSelection::Yes); + const dom::Optional& aDirection, ErrorResult& aRv); // Set the selection start. This basically implements the // https://html.spec.whatwg.org/multipage/forms.html#dom-textarea/input-selectionstart diff --git a/testing/web-platform/tests/html/semantics/forms/textfieldselection/selection.html b/testing/web-platform/tests/html/semantics/forms/textfieldselection/selection.html index 04ab7298e35a..e216d953cef5 100644 --- a/testing/web-platform/tests/html/semantics/forms/textfieldselection/selection.html +++ b/testing/web-platform/tests/html/semantics/forms/textfieldselection/selection.html @@ -155,52 +155,10 @@ test(function() { - var el = createTextareaElement(sampleText); + var el = createInputElement(sampleText); assert_in_array(el.selectionDirection, dirs, "SelectionDirection"); el.select(); assert_in_array(el.selectionDirection, dirs, "SelectionDirection"); el.parentNode.removeChild(el); }, "test SelectionDirection for textarea"); - - promise_test(async () => { - // cause a layout overflow - const el = createInputElement(sampleText.repeat(100)); - el.selectionEnd = 0; - await new Promise(requestAnimationFrame); - assert_equals(el.scrollLeft, 0); - - el.select(); - await new Promise(requestAnimationFrame); - assert_equals(el.scrollLeft, 0); - el.remove(); - }, `test scrollLeft for input`); - - promise_test(async () => { - // cause a layout overflow - const el = createInputElement(sampleText.repeat(100)); - el.scrollLeft = 33; - - el.select(); - await new Promise(requestAnimationFrame); - assert_equals(el.scrollLeft, 33); - el.remove(); - }, `test scrollLeft preservation for input`); - - for (const localName of ["input", "textarea"]) { - promise_test(async () => { - const container = document.createElement("div"); - container.style.height = "100px"; - container.style.overflow = "scroll"; - const element = document.createElement(localName); - element.style.marginTop = "120px"; - container.append(element); - document.body.append(container); - - element.select(); - await new Promise(requestAnimationFrame); - assert_equals(container.scrollTop, 0); - - container.remove(); - }, `test container.scrollTop for ${localName}`); - }