Repository navigation
Further changes in relation to #19171 - #19272
Conversation
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @asajeffrey (or someone else) soon. |
|
Heads up! This PR modifies the following files:
|
|
r? @KiChjang |
|
I don't know if this |
|
This is a larger change than I expected, and I'm not comfortable reviewing this. r? @jdm |
jdm
left a comment
There was a problem hiding this comment.
This seems like a sensible solution. The only other abstraction I came up with is free functions that accept the textinput as an argument, rather than putting them all in a trait, but I don't see a compelling reason to use that design instead.
| }, "Sanity check for testValue length; if this fails, variou absolute offsets in the test below need to be adjusted to be less than testValue.length"); | ||
|
|
||
| for (let prop of ["selectionStart", "selectionEnd"]) { | ||
| test(function() { |
There was a problem hiding this comment.
Thanks. I thought that maybe it was a bad idea to call createTestElements outside of a test, but perhaps it doesn't actually matter.
|
Also |
|
|
||
| // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart | ||
| fn dom_selection_start(&self) -> u32 { | ||
| self.textinput().borrow().get_selection_start() |
There was a problem hiding this comment.
When I mentioned that whether the selection{Start, End, Range} functions matches the spec, I meant whether they are following the steps as defined in the spec. This function in particular does not seem to have included step 1 and 2.
|
Also, may I ask why this abstraction is necessary? It seems to me that the intent is to generalize the textinput stuff across HTMLInputElement and HTMLTextAreaElement, but I may be wrong on that. |
Out of curiosity, can you point me to anything which describes what is meant by a "free function"? (I'm not very familiar with Rust yet...)
I'll look into that.
Yeah, I'm not done yet but I thought it was worth submitting this PR to get feedback before I make further changes. For now, the implementation of
Yes, that's the intent. The spec of the selection API is identical for both |
|
A free function is a function that isn't inside an impl block, i.e. it exists at the top level of a module. |
94551bb to
65a4483
Compare
Move assertions about the initial value of selection{Start,End} to their
own tests. This ensures that when one of these assertions fails, it
doesn't prevent other tests from being defined. Thus we have a clearer
view of which tests are passing or failing, since all tests get defined
regardless of which assertions fail.
The API for text control selection is the same for both <input> and <textarea>: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#textFieldSelection Before this change, they had similar but not identical implementations with duplicate code. Now there is a common TextControl trait which contains the implementation used by both. As a result, some previously failing tests now pass.
65a4483 to
6beda3c
Compare
|
Also ran |
|
So I thought a bit about this, and was wondering whether the trait abstraction is necessary. It's true that HTMLInputElement and HTMLTextAreaElement don't share the selection code, but they both do have a |
|
Yeah, I thought about that too. The reason I didn't go down that path is that |
|
I think it's actually doable to include DOM-related stuff as parameters to functions defined in |
|
@bors-servo: r+ |
|
📌 Commit 6beda3c has been approved by |
Further changes in relation to #19171 <!-- 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/19272) <!-- Reviewable:end -->
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Move assertions about the initial value of selection{Start,End} to their
own tests. This ensures that when one of these assertions fails, it
doesn't prevent other tests from being defined. Thus we have a clearer
view of which tests are passing or failing, since all tests get defined
regardless of which assertions fail.
Upstreamed from servo/servo#19272 [ci skip]
This change is