servo/tests/unit/script
Jon Leighton 02883a6f54 Fix selection{Start,End} when selectionDirection is "backward"
Per the spec, selectionStart and selectionEnd should return the same
values regardless of the selectionDirection. (That is, selectionStart is
always less than or equal to selectionEnd; the direction then implies
which of selectionStart or selectionEnd is the cursor position.)

There was no explicit WPT test for this, so I added one.

This bug was initially quite hard to wrap my head around, and I think
part of the problem is the code in TextInput. Therefore, in the process
of fixing it I have refactored the implementation of TextInput:

* Rename selection_begin to selection_origin. This value doesn't
  necessarily correspond directly to the selectionStart DOM value - in
  the case of a backward selection, it corresponds to selectionEnd.
  I feel that "origin" doesn't imply a specific ordering as strongly as
  "begin" (or "start" for that matter) does.

* In various other cases where "begin" is used as a synonym for "start",
  just use "start" for consistency.

* Implement selection_start() and selection_end() methods (and their
  _offset() variants) which directly correspond to their DOM
  equivalents.

* Rename other related methods to make them less wordy and more
  consistent / intention-revealing.

* Add assertions to assert_ok_selection() to ensure that our assumptions
  about the ordering of selection_origin and edit_point are met. This
  then revealed a bug in adjust_selection_for_horizontal_change() where
  the value of selection_direction was not maintained correctly (causing
  a unit test failure when the new assertion failed).
2018-01-26 19:50:50 +01:00
..
Cargo.toml Update euclid, azure, skia, offscreen_gl_context, plane-split, webrender 2017-12-08 14:32:28 +01:00
headers.rs Introduce a script::test module to expose the APIs needed for unit tests. 2016-12-22 15:58:53 +01:00
htmlareaelement.rs Refactor HTMLImageElement::handle_event to be idiomatic 2017-07-07 21:07:12 +04:00
htmlimageelement.rs Parse srcset attribute 2017-10-03 13:18:01 +02:00
lib.rs Replace compiletest suite by doc-tests with compile_fail 2017-11-22 16:25:17 +01:00
origin.rs Add ImmutableOrigin to allow for serializing origins 2017-02-22 11:11:59 -06:00
size_of.rs Track custom element state 2017-08-09 14:36:22 -06:00
textinput.rs Fix selection{Start,End} when selectionDirection is "backward" 2018-01-26 19:50:50 +01:00