Change all the selectionrange/start/end stuff in editor state and text control frame to use uint32_t

RESOLVED FIXED in Firefox 55

Status

()

enhancement
P3
normal
RESOLVED FIXED
2 years ago
4 months ago

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Tracking

Trunk
mozilla55
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox55 fixed)

Details

Attachments

(1 attachment)

Spec says all that stuff is unsigned.  We currently use int32_t...
Priority: -- → P3
MozReview-Commit-ID: 15tqFjexx4q
Attachment #8845225 - Flags: review?(michael)
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Comment on attachment 8845225 [details] [diff] [review]
Propagate uint32_t deeper into the editor state and text control frame code

Review of attachment 8845225 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/html/nsTextEditorState.cpp
@@ +1850,5 @@
>  void
>  nsTextEditorState::SetRangeText(const nsAString& aReplacement, uint32_t aStart,
>                                  uint32_t aEnd, SelectionMode aSelectMode,
> +                                ErrorResult& aRv,
> +                                Maybe<uint32_t> aSelectionStart,

This won't pass the static analysis :).

Maybe<T> contains an `alignas(T)` member, and thus isn't safe to pass by parameter, due to ABI not being required to respect alignas(T) fields. Right now it is marked as MOZ_NON_PARAM, and once bug 1339537 lands it will also be rejected due to the alignas member. (See bug 1287006 comment 26 for a more detailed explanation).

Try passing these fields by const reference instead :).

::: dom/html/nsTextEditorState.h
@@ +338,5 @@
>    // otherwise they're the start and end of our selection range.
>    void SetRangeText(const nsAString& aReplacement, uint32_t aStart,
>                      uint32_t aEnd, mozilla::dom::SelectionMode aSelectMode,
> +                    mozilla::ErrorResult& aRv,
> +                    mozilla::Maybe<uint32_t> aSelectionStart = mozilla::Nothing(),

Again, pass by const reference here.

::: testing/web-platform/tests/html/semantics/forms/textfieldselection/textfieldselection-setSelectionRange.html
@@ +143,5 @@
> +    input.setSelectionRange(Math.pow(2,32) - 2, Math.pow(2,32) - 1);
> +    assert_equals(input.selectionStart, input.value.length,
> +                 "element.selectionStart should be value.length");
> +    assert_equals(input.selectionEnd, input.value.length,
> +                  "element.selectionStart should be value.length");

typo: selectionEnd

@@ +151,5 @@
> +    input.setSelectionRange(Math.pow(2,31), Math.pow(2,32) - 1);
> +    assert_equals(input.selectionStart, input.value.length,
> +                 "element.selectionStart should be value.length");
> +    assert_equals(input.selectionEnd, input.value.length,
> +                  "element.selectionStart should be value.length");

typo: selectionEnd

@@ +278,5 @@
> +    textarea.setSelectionRange(Math.pow(2,32) - 2, Math.pow(2,32) - 1);
> +    assert_equals(textarea.selectionStart, textarea.value.length,
> +                 "element.selectionStart should be value.length");
> +    assert_equals(textarea.selectionEnd, textarea.value.length,
> +                  "element.selectionStart should be value.length");

Typo: selectionEnd

@@ +286,5 @@
> +    textarea.setSelectionRange(Math.pow(2,31), Math.pow(2,32) - 1);
> +    assert_equals(textarea.selectionStart, textarea.value.length,
> +                 "element.selectionStart should be value.length");
> +    assert_equals(textarea.selectionEnd, textarea.value.length,
> +                  "element.selectionStart should be value.length");

typo: selectionEnd
Attachment #8845225 - Flags: review?(michael) → review+
> This won't pass the static analysis :).

Gah.  I wish we'd just run that on try automatically instead of it being a separate platform.  :(

Thanks for catching this!

> typo: selectionEnd

mmm, copy/paste.  Fixed.
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/ea659450b0da
Propagate uint32_t deeper into the editor state and text control frame code.  r=mystor
The issue is the patches for bug 1343037.
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/f8c3eb6aa697
Propagate uint32_t deeper into the editor state and text control frame code.  r=mystor
Flags: needinfo?(bzbarsky)
https://hg.mozilla.org/mozilla-central/rev/f8c3eb6aa697
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.