Closed Bug 1764679 Opened 2 years ago Closed 2 years ago

`Selection::(Get|Set)InterlinePosition` should work with `enum class`

Categories

(Core :: DOM: Selection, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
101 Branch
Tracking Status
firefox101 --- fixed

People

(Reporter: masayuki, Assigned: masayuki)

References

Details

Attachments

(1 file)

The bool meaning of Selection::(Get|Set)InterlinePosition is really hard to remember. Therefore, around the API users, comment appears to explain what they do. I think that they should work with a new enum class like:

  enum class InterlinePosition {
    // Caret should be put at end of line (i.e., before the line break)
    EndOfLine,
    // Caret should be put at start of next line (i.e., after the line break)
    StartOfNextLine,
    // Undefined means only what is not EndOfLine nor StartOfNextLine.
    // `SetInterlinePosition` should never be called with this value, and
    // if `GetInterlinePosition` returns this, it means that the instance has
    // not been initialized or cleared by the cycle collector or something.
    // If a method needs to consider whther to call `SetInterlinePosition` or
    // not call, this value can be used for the latter.
    Undefined,
  };

It's hard to remember what the bool value of them means. Therefore, there
are a lot of comment around the API users to explain what they do. For making
it clearer and reducing the risk of specifying opposite value, they should work
with an enum class.

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/31ae7489d1df
Make `GetInterlinePosition` and `SetInterlinePosition` work with new `enum class` r=smaug
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: