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 "update the image data" #16238
Conversation
highfive
commented
Apr 3, 2017
highfive
commented
Apr 3, 2017
|
Wonderful! Thanks for tackling this! |
|
Note: there's no need to include any implementation related to srcset/sizes/other responsive image things, as that's going to be a student project starting this summer. |
|
@jdm great, glad to hear that! That would include concepts like selecting and image source and updating the source set, correct? Currently I have left those at the bare minimum, essentially just grabbing the |
|
Yep, that sounds great. |
|
r? @jdm |
a71c9bc
to
f25ce3d
|
@jdm here is this weekend's harvest:
Re 3, the previous code would always just use Re 4, I had to decide how to have If you have time this week, I think the PR is good for a more comprehensive review at this stage... |
80d3bd9
to
f3ff232
|
@jdm I'm reading through the spec again and I see I missed some key concepts regarding current and pending requests in step 12 and 14 of the specs, so that's certainly something I will still need to implement, feedback in the meantime welcome off course... |
|
Re: "The final task queued that is queued", see whatwg/html#1055. |
|
@jdm thanks, so that means we can keep that test as it was before, and with a Re pending/current request, here is the work I intend to still do, next weekend:
I guess some of the stuff I currently do with So it's mainly looking at step 12 and 14 in more details.... I'll also undo the changes I made to the tests, and keep that "final task" one on |
|
Great work so far! I found these changes to be quite readable in general, although it might be nice to follow the spec text about aborting a particular request or creating a new request, rather than what is (presumably) equivalent. |
| @@ -113,7 +116,8 @@ impl Runnable for ImageResponseHandlerRunnable { | |||
| let element = self.element.root(); | |||
| // Ignore any image response for a previous request that has been discarded. | |||
| if element.generation.get() == self.generation { | |||
| element.process_image_response(self.image); | |||
| let url = self.url.clone(); | |||
| element.process_image_response(self.image, &url); | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
gterzian
Apr 15, 2017
Author
Member
yes indeed, and I also had to use &self.image to prevent use of moved value: self
| let _ = task_source.queue_with_wrapper(box runnable, &wrapper); | ||
| }); | ||
|
|
||
| image_cache.add_listener(id, ImageResponder::new(responder_sender, id)); | ||
| } | ||
|
|
This comment has been minimized.
This comment has been minimized.
| if trigger_image_load { | ||
| self.upcast::<EventTarget>().fire_event(atom!("load")); | ||
| self.upcast::<EventTarget>().fire_event(atom!("loadend")); | ||
| } | ||
|
|
||
| // Fire image.onerror | ||
| if trigger_image_error { | ||
| self.upcast::<EventTarget>().fire_event(atom!("error")); |
This comment has been minimized.
This comment has been minimized.
jdm
Apr 11, 2017
Member
We should be firing loadend after error as well according to the steps in https://html.spec.whatwg.org/multipage/embedded-content.html#updating-the-image-data .
This comment has been minimized.
This comment has been minimized.
| fn has_parent_image(&self) -> bool { | ||
| let node = self.upcast::<Node>(); | ||
| if let Some(ref parent) = node.GetParentNode() { | ||
| if parent.is::<HTMLImageElement>() { |
This comment has been minimized.
This comment has been minimized.
jdm
Apr 11, 2017
Member
This looks like it's implementing https://html.spec.whatwg.org/multipage/embedded-content.html#use-srcset-or-picture incorrectly .
| current_request.state = State::CompletelyAvailable; | ||
| current_request.parsed_url = Some(img_url); | ||
| current_request.source_url = Some(src); | ||
| self.upcast::<EventTarget>().fire_event(atom!("load")); |
This comment has been minimized.
This comment has been minimized.
| let mut image_request = self.request_for_url(url); | ||
| image_request.state = State::Broken; | ||
| image_request.image = None; | ||
| image_request.metadata = None; |
This comment has been minimized.
This comment has been minimized.
jdm
Apr 11, 2017
Member
This looks like it's missing some steps from the relevant "Otherwise" branches.
| }; | ||
| self.current_request.borrow_mut().image = image; | ||
| self.current_request.borrow_mut().metadata = metadata; | ||
|
|
||
| // Mark the node dirty | ||
| self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); |
This comment has been minimized.
This comment has been minimized.
| document.getElementById("imgTestTag3").src = '3.jpg?nocache=' + Math.random(); | ||
| document.getElementById("imgTestTag3").onload = t.step_func(function(){ | ||
| assert_true(document.getElementById("imgTestTag3").complete); | ||
| assert_equals(document.getElementById("imgTestTag3").src.split("/").pop().split('?')[0], "3.jpg"); |
This comment has been minimized.
This comment has been minimized.
| if (imageInstance.complete === true) break; | ||
| } | ||
| t.done(); | ||
| setTimeout(function(){ |
This comment has been minimized.
This comment has been minimized.
| // NOTE: this is an attempt to comply with: | ||
| // "(return true if)The final task that is queued by the networking task source, | ||
| // once the resource has been fetched, has been queued" | ||
| return request.parsed_url.is_some() |
This comment has been minimized.
This comment has been minimized.
|
@jdm thanks for the review, I'll look at it in more details over the weekend... |
|
@jdm OK I have addressed most of your comments, I just had a question re "We should store the selected source and pass it as an argument here instead" and "Don't we need to initialize the image request's state here?", and I have also made further attempt to implement the concepts of pending and current requests in a more spec compliant way. Please take a look when you have a chance... |
f5f94b6
to
0f630f5
|
@jdm OK, fixed the double borrowing crash through scoping... |
|
@jdm This one might be ready for another test run. The previous run I think confirmed that the timeouts where simply due to my machine being too slow, and the only code change that would require additional review is where the current request is set to Unavailable at the beginning of the algorithm, this allows an additional test to pass. The crashes from the previous run where due to the fact that I hadn't scoped that part, so the current_request was doubly borrowed(this wasn't apparent from running the img specific tests, since the images are not cached, and the double borrowing occured in the "we found a cached image" part). |
|
@bors-servo: try |
Implement "update the image data" <!-- Please describe your changes on the following line: --> Spec compliant implementation of the [update the image data algorithm](https://html.spec.whatwg.org/multipage/embedded-content.html#update-the-image-data). Currently still a work in progress, the ['async src complete test`](https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/html/semantics/embedded-content/the-img-element/img.complete.html#L33) is still passing as it was before, even though I switched to the new code, so I guess that's something. @jdm I will be picking this up next weekend, I left a bunch of TODO and NOTES in the code, if you or someone else have time this week I would appreciate an initial scan and feedback. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #11517 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> <!-- 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/16238) <!-- Reviewable:end -->
|
|
|
@bors-servo: r+ |
|
|
Implement "update the image data" <!-- Please describe your changes on the following line: --> Spec compliant implementation of the [update the image data algorithm](https://html.spec.whatwg.org/multipage/embedded-content.html#update-the-image-data). Currently still a work in progress, the ['async src complete test`](https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/html/semantics/embedded-content/the-img-element/img.complete.html#L33) is still passing as it was before, even though I switched to the new code, so I guess that's something. @jdm I will be picking this up next weekend, I left a bunch of TODO and NOTES in the code, if you or someone else have time this week I would appreciate an initial scan and feedback. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #11517 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> <!-- 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/16238) <!-- Reviewable:end -->
|
|
|
@bors-servo: retry |
Implement "update the image data" <!-- Please describe your changes on the following line: --> Spec compliant implementation of the [update the image data algorithm](https://html.spec.whatwg.org/multipage/embedded-content.html#update-the-image-data). Currently still a work in progress, the ['async src complete test`](https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/html/semantics/embedded-content/the-img-element/img.complete.html#L33) is still passing as it was before, even though I switched to the new code, so I guess that's something. @jdm I will be picking this up next weekend, I left a bunch of TODO and NOTES in the code, if you or someone else have time this week I would appreciate an initial scan and feedback. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #11517 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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. --> <!-- 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/16238) <!-- Reviewable:end -->
|
|
|
@jdm that was a big one, thanks for the efforts you put into reviewing this! |
Upstreamed from servo/servo#16238 [ci skip]
gterzian commentedApr 3, 2017
•
edited
Spec compliant implementation of the update the image data algorithm.
Currently still a work in progress, the 'async src complete test` is still passing as it was before, even though I switched to the new code, so I guess that's something.
@jdm I will be picking this up next weekend, I left a bunch of TODO and NOTES in the code, if you or someone else have time this week I would appreciate an initial scan and feedback.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is