Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement DOM selections #7492
Implement DOM selections #7492
Comments
|
What if we use a DOM range for the selection boundaries? |
|
Seems reasonable at first glance. |
|
#4409 is related and I can never find it. |
|
@iamrohit7 If you're interested in trying this, I will do my best to advise you! |
|
@jdm Thanks. I'll get back to you with questions. |
|
WPT custom-elements/reactions/Selection needs this. |
|
Most failures under dom/ranges are also this. |
|
Would implement DOM selections, up to a point that satisfies non-webdriver automated tests, be a productive thing to do in itself? I imagine they're not very useful without also having a UI to select things, but on the other hand that UI might be easier to write as its own piece on top of the already-working DOM part. |
|
That would be a useful starting point, indeed. |
|
Here's my understanding of what https://w3c.github.io/selection-api/ tells us to do. Section 2:
Section 3:
Section 4:
Section 5:
Could someone else give it a skim and let me know if there's anything I've left out here? |
|
The selectionchange event has no tests and some underspecification (w3c/selection-api#117) but I'll try to make some version of it work. Aside from that, I have a build that seems to be otherwise working, passing WPT tests that incidentally use getSelection, but I'm also getting some unexpected harness timeouts and I don't know how they relate to my changes yet. I'll push a draft of whatever I've got today, hopefully in a state where someone else could pick up the UI part. |
|
In response to your task source question, 7b3cf27#diff-a1afe92a339a20989be95f03c80740e5 is a nice example of adding a new task source. That being said, the DOM manipulation task source is generally a safe choice when a spec doesn't explicitly state one. |
Selection DOM interface (but not actual UI selections) This is work towards #7492. Things that aren't done here: - The spec doesn't describe what tests/wpt/metadata/selection/script-and-style-elements.html.ini wants, and what it wants seems to require some sort of layout query. - #25673 means I'm not sure about some tests being OK. - I haven't checked that the selectionchange event is actually working, and it has no WPT tests other than that the handler exists. - Actual UI interactions are not present at all; selection.rs has a few TODOs saying methods what I understand the UI should call for what actions, but there are a lot of fine points here that I don't know about.
Selection DOM interface (but not actual UI selections) This is work towards #7492. I put new tests in the mozilla-specific directory rather than the main tree because I'm not sure how upstreamable they are; I'd like opinions on that point. This adds a new exposed interface, which I understand from tests/mozilla/interfaces.html is something requiring specific approval from someone allowed to give that approval. Things that aren't done here: - The spec doesn't describe what selection/script-and-style-elements.html wants, and what it wants seems to require some sort of layout query. - Actual UI interactions are not present at all; selection.rs has a few TODOs saying which methods I believe the eventual UI code should call for what actions, but there are a lot of fine points here that I don't know about. - I haven't touched Node; you can ask if a node's in the Selection's Range the same way you'd ask about any other Range, but there's not a faster path just for selection layout.
|
The next big step here is figuring out how to convert a click into a range boundary, in the general case where we don't know in advance if it's going to be counting characters or counting child nodes. |
Selection DOM interface (but not actual UI selections) This is work towards #7492. I put new tests in the mozilla-specific directory rather than the main tree because I'm not sure how upstreamable they are; I'd like opinions on that point. This adds a new exposed interface, which I understand from tests/mozilla/interfaces.html is something requiring specific approval from someone allowed to give that approval. Things that aren't done here: - The spec doesn't describe what selection/script-and-style-elements.html wants, and what it wants seems to require some sort of layout query. - Actual UI interactions are not present at all; selection.rs has a few TODOs saying which methods I believe the eventual UI code should call for what actions, but there are a lot of fine points here that I don't know about. - I haven't touched Node; you can ask if a node's in the Selection's Range the same way you'd ask about any other Range, but there's not a faster path just for selection layout.
Selection DOM interface (but not actual UI selections) This is work towards #7492. I put new tests in the mozilla-specific directory rather than the main tree because I'm not sure how upstreamable they are; I'd like opinions on that point. This adds a new exposed interface, which I understand from tests/mozilla/interfaces.html is something requiring specific approval from someone allowed to give that approval. Things that aren't done here: - The spec doesn't describe what selection/script-and-style-elements.html wants, and what it wants seems to require some sort of layout query. - Actual UI interactions are not present at all; selection.rs has a few TODOs saying which methods I believe the eventual UI code should call for what actions, but there are a lot of fine points here that I don't know about. - I haven't touched Node; you can ask if a node's in the Selection's Range the same way you'd ask about any other Range, but there's not a faster path just for selection layout.
Selection DOM interface (but not actual UI selections) This is work towards #7492. I put new tests in the mozilla-specific directory rather than the main tree because I'm not sure how upstreamable they are; I'd like opinions on that point. This adds a new exposed interface, which I understand from tests/mozilla/interfaces.html is something requiring specific approval from someone allowed to give that approval. Things that aren't done here: - The spec doesn't describe what selection/script-and-style-elements.html wants, and what it wants seems to require some sort of layout query. - Actual UI interactions are not present at all; selection.rs has a few TODOs saying which methods I believe the eventual UI code should call for what actions, but there are a lot of fine points here that I don't know about. - I haven't touched Node; you can ask if a node's in the Selection's Range the same way you'd ask about any other Range, but there's not a faster path just for selection layout.
I propose that we store the bounds of our selection in
Documentusing a starting node, an ending node, a starting offset, and an ending offset. Additionally, we should store a vector of these to enable multiple simultaneous selections in the future, and send all of this data along with each script-initiated reflow request. When a node is part of a selection, it should have a flag set on it (c.f. NodeFlags); when a node with this flag is encountered, the layout code should check whether it's the starting or ending node; if it is not, we can go ahead and style the node entirely as selected. If it is, we need to deal with styling the node content in up to three separate parts (pre-selection, in selection, post-selection).cc @aweinstock314