-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement StaticRange #25376
Comments
I would like to work on this if that's not a problem. |
Not a problem! You will need to follow the steps at https://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface for the new AbstractRange and StaticRange interfaces that come from https://dom.spec.whatwg.org/#interface-abstractrange and https://dom.spec.whatwg.org/#ref-for-abstractrange%E2%91%A1 respectively. You can test the effects of your changes with |
I've noticed that there are two Extended Attributes in the IDL code in I also couldn't find them at https://heycam.github.io/webidl/. Are they specific to Servo? How will I know when to use them? I've noticed that the |
Information about Mozilla-specific WebIDL annotations can be found here: https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings |
To summarize, and to translate from that page's C++ perspective to Rust: [Throws] means you're returning a Fallible or ErrorResult, which allows you to cover in Rust cases where the spec says to throw a Javascript exception. [Pure] is used by the Javascript compiler for optimizations; it means getting and setting the attribute is effectively "side-effect-free" in certain senses. Direct links to those sections: |
Alright, I'll keep those in mind. Thanks! |
I have added the AbstractRange DOM interface on my fork. But I'm facing a problem. In the In the |
My reading of the spec might be wrong, but it looks to me like StaticRange holds strong refs to its start and end nodes and holds no weak refs, so there's no need for AbstractRange to have any interaction with weak refs. |
I stashed my changes regarding StaticRange, so I could test the AbstractRange and Range interfaces. However, all of my tests crashed. All of them with the same error. This error is produced below.
From what I can gather, the GL function GetString is missing. I also ran other tests to ensure that the crash wasn't caused due to my changes. Specifically, I ran the tests I'm working on a 64-bit Windows 10 machine if that is relevant. Any ideas on what went wrong? |
Oh, that happens because we don't support running headless Servo on Windows yet. You can work around it by running each test in the directory individually, rather than passing the directory as the argument to the test-wpt command. Sorry :/ |
The tests work fine now. Thanks a lot. I was implementing the Constructor for StaticRange and I noticed that the WebIDL for the Attr interface in our code has a mistake. In the spec, Attr derives from Node. But the WebIDL in our code seems to have missed that.
The DOM struct for Attr does not hold a Node value either like inherited DOM interfaces should. I need to check whether a given node is an Attr node while constructing the StaticRange, so this needs to be fixed before I can write its constructor. Is there a particular reason for this? If not, I'll try and make it match the spec. |
That's #25310. |
I have added the StaticRange DOM interface on my local machine as well. Since #25310 hasn't been merged into master yet, I have chosen not to add the check for the Attr Node yet. Hence, it doesn't completely match the spec yet. When #25310 gets merged, I'll add the check for the Attr Node as well. As far as WPT tests are concerned, all the Range-related WPT tests are giving expected results. In the case of the The
When I disabled the 2nd debug_assert and compiled, the StaticRange-constructor.html test worked. It gave UNEXPECTED-PASS to 16 of the 17 tests, and FAIL on the one test that depends upon Attr being a Node. In order to find the problem, I diffed the tests in our repository and https://github.com/web-platform-tests/wpt. But there was no difference between them. So I decided to look through the test. I'm most likely reading this incorrectly, but I think the problem is with the test itself.
The I've never worked with WPT tests before, so I'm most likely making a mistake here. Any suggestions where I should look next to fix the assertion failure? |
I'm not 100% sure, but I think it may be the case that a StaticRange is allowed to hold invalid data, unlike a real Range, so the debug_assert shouldn't apply to it. |
Yes, it's totally possible to pass incorrect data to the constructor. |
I see. In that case, I'll move that assert out of Boundary point and into the Range Constructor. Are there any other tests that I need to satisfy or would this be sufficient for a PR? |
As far as I know that's the only test for it. |
Implement StaticRange This PR creates the AbstractRange and StaticRange DOM interfaces. It also refactors the Range DOM interface so that it inherits from the Abstract Range DOM interface. All the tests in `tests\wpt\web-platform-tests\dom\ranges` are now passing, including the `StaticRange-constructor.html` test. Since the result of the StaticRange-constructor.html test has changed, this PR also removes its corresponding .ini file. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #25376 - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Implement StaticRange This PR creates the AbstractRange and StaticRange DOM interfaces. It also refactors the Range DOM interface so that it inherits from the Abstract Range DOM interface. All the tests in `tests\wpt\web-platform-tests\dom\ranges` are now passing, including the `StaticRange-constructor.html` test. Since the result of the StaticRange-constructor.html test has changed, this PR also removes its corresponding .ini file. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #25376 - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Implement StaticRange This PR creates the AbstractRange and StaticRange DOM interfaces. It also refactors the Range DOM interface so that it inherits from the Abstract Range DOM interface. All the tests in `tests\wpt\web-platform-tests\dom\ranges` are now passing, including the `StaticRange-constructor.html` test. Since the result of the StaticRange-constructor.html test has changed, this PR also removes its corresponding .ini file. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #25376 - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
StaticRange seems to be a "lightweight" range that just has a pointer-to-start and pointer-to-end, and no idea about its contents between those two pointers; the idea seems to be that if those are all your script needs, it can run a lot faster than a real Range that needs to stay aware of its actual contents. Since we already have real Ranges, implementing it is mostly boilerplate. Some code Servo has in Range now belongs in https://dom.spec.whatwg.org/#interface-abstractrange, and then StaticRange is a very simple interface that derives from AbstractRange by just holding cells for its readonly members and exposing the getters. Maybe this would make a good first step for someone who wants to start working with Servo's IDLs!
There are WPT tests in dom/ranges/StaticRange-constructor.html, but it's not a fully cross-browser API yet: https://wpt.fyi/results/dom/ranges/StaticRange-constructor.html?label=master&label=experimental&aligned
The text was updated successfully, but these errors were encountered: