This reverts commit 1f42551042.
This change led to a decrease in Speedometer performance and needs to be
reworked to avoid that.
Testing: This is just a revert.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This change makes it so that selection changes driven by user input
events also fire the `select` event and not just selection changes from
script. In addition the change eliminate the `SelectionState` data
structure instead opting to store the `SelectionDirection` in the
`SharedSelection`. That way there is a centralized place that selection
changes are handled.
Testing: This change adds a Servo-specific WPT test. This is
Servo-specific as
it relies on engine-specific text selection behavior.
Fixes: #41308.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
`TextInput` internally stores a rope of text content, one segment for
each line. This change separates out the rope into a separate `Rope`
data structure that can be shared with other parts of Servo.
`TextInput` needs to move through text content in a variety of ways,
depending on the keys pressed when interacting with a text area. This
change provides a unified movement API in both `Rope` and in
`TextInput` ensuring that selection is handled consistently (apart from
a few minor quirks [^1]). This simplifies the code an improves
interactive behavior.
[^1]: One of these quirks is that the edit point will move to
directional end of the motion when collapsing a selection, but only when
moving by grapheme or word (and not by line). These quirks existed in an
undocumented way previously and they are preserved with code comments.
Testing: This is covered by existing unit tests (updated for the new
API) and
the WPT suite.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This moves the Unicode offset types to the `base` crate and makes them
generally more usable throughout the Servo codebase. In addition, they
are renamed to use Rust naming and to be a bit more consistent:
- `UTF8Bytes` -> `Utf8CodeUnitLength`
- `UTF16CodeUnits` -> `Utf16CodeUnitLength`
There is also a bit more documentation explaining their use.
This is preparation for fixing issues with UTF-16 offsets in editable
text fields.
Testing: This does not change behavior so existing WPT tests should
suffice.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Servo currently completely ignores `<meta charset>` tags. When we find
one with an encoding that is incompatible to the current one, then we
should reload the page and start over with the new encoding. A common
optimization that has even made its way into the specification is to
wait for a few bytes to arrive and inspect them for `meta` tags, so the
browser is able to use the correct encoding from the very beginng.
In practice, I've run into problems with our WPT harness when reloading
the page after `meta` tags. Therefore, this change implement the
optimization first, so we never have to reload when running WPT. I've
implemented prescanning in a way where we wait for 1024 bytes to arrive
or for one second to pass, whichever one happens first.
This causes a large number of web platform tests to flip around. I've
looked at most of the new failures and I believe they're reasonable.
Testing: New tests start to pass.
Part of https://github.com/servo/servo/issues/6414
---------
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Changed some allow to expects and removed the unfulfilled expectations.
Testing: Refactor
Part of: #40383
Signed-off-by: anonmiraj <nabilmalek48@gmail.com>
This shows up sometimes in code reviews, so it makes sense that tidy
enforces it. `rustfmt` supports this via comment normalization, but it
does many other things and is still an unstable feature (with bugs).
Testing: There are new tidy tests for this change.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This includes removing an implementation of normalize for `ByteString`,
because it is effectively duplicated in net under
`trim_http_whitespace`. This is part of an attempt to cleanup and
centralize code for header parsing and manipulation.
Testing: Covered by existing WPT tests
Signed-off-by: Sebastian C <sebsebmc@gmail.com>
Parse sizes attribute values
Squashed version of #17808.
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix (partially) #11416
- [x] There are tests for these changes
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18714)
<!-- Reviewable:end -->
I don't want to do such a gratuitous rename, but with all the other types
now having "Dom" as part of their name, and especially with "DomOnceCell",
I feel like the other cell type that we already have should also follow
the convention. That argument loses weight though when we realise there
is still DOMString and other things.
This allows us to have ensure_data() and clear_data() functions on the TElement
trait, instead of hacking around it adding methods in random traits.
This also allows us to do some further cleanup, which I'd rather do in a
followup.