-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 document.write #3704
Comments
Blocks #5398. |
Blocks #5864. |
Aside from preserving unpaired surrogates (see #6564), I believe that html5ever at this point supports everything needed for |
I'm not certain that's true - for example, I don't see any evidence of an insertion point in html5ever, so there's no way to ensure that we're feeding tokens into the tokenizer immediately rather than appending them to an existing queue. In particular, under "An end tag whose tag name is script", it says "Let the old insertion point have the same value as the current insertion point. Let the insertion point be just before the next input character." We'll need to add this functionality (querying and setting the insertion point) to html5ever, along with the ability to make the parser consume a single character and return control to the caller, then add the following to the HTML parsing code in libscript:
Finally we can implement a subset of the steps for document.write leaving stubs for the bits related to document unloading and when there's no active parser (ie. when we should call document.open). |
I played with this for a few hours and sketched out what I think this should look like in https://github.com/jdm/servo/tree/documentwrite and https://github.com/jdm/html5ever/tree/write . The actual implementation of insertion points in html5ever is completely missing, but I believe the DOM bits are relatively complete. |
I now see why @jgraham kept mentioning document.write and script scheduling in the same breath. This stuff is hella complex to parse out of the spec. |
Is there any way the implementation could be split up into more reasonable chunks instead of an all-at-once ordeal? I understand there are downsides to this strategy, but would be nice to get the ball rolling on this. |
I don't see how. It's fundamentally about interacting with the parser, and the parser APIs aren't present yet. |
It might be easier to implement the special case of |
Yeah, but what do we do for the non-easy case if we do that? |
Umm, throw out the "easy" implementation and put in a correct one? I see what you mean. :( But at least we'd have an implementation of |
I think I agree that |
|
AFAIK, the first needed step is to make h5e not own the input buffer at all. So my first intuition was to feed chunks one by one, but that doesn't fix the issue that h5e needs to give back the input it was fed in the case it encounters a blocking script. |
AFAICT, your branch would never work, and would panic there because the parser is already borrowed mutably, right? |
Maybe! You've clearly put thought into it more recently than I have. |
@jdm Is there a high-level description of our parsing entry point and how it interacts with the data coming from the network? I understand how h5e works when fed data, but I don't have yet a clear picture of how it is started, how it is owned, etc. Would be great if you or someone else could detail that, I think that would help me for this. |
When the HTTP headers are received, |
This is a bit crude because of some missing utility methods on BufferQueue.
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
This is a bit crude because of some missing utility methods on BufferQueue.
This is a bit crude because of some missing utility methods on BufferQueue.
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
This is a bit crude because of some missing utility methods on BufferQueue.
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
This is a bit crude because of some missing utility methods on BufferQueue.
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
This is a bit crude because of some missing utility methods on BufferQueue.
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
This is a bit crude because of some missing utility methods on BufferQueue.
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
This is a bit crude because of some missing utility methods on BufferQueue.
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
Implement document.write (fixes #3704) <!-- 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/14361) <!-- Reviewable:end -->
Part of #1879. See servo/html5ever#6.
https://html.spec.whatwg.org/multipage/#document.write()
The text was updated successfully, but these errors were encountered: