aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-11-13 19:19:59 -0500
committerGitHub <noreply@github.com>2019-11-13 19:19:59 -0500
commitf65cb94b9e417bdaab6fd8d699bf213ae55cd740 (patch)
tree0ee138e04603c972c53fab5ca9ebce4e876e29c7
parenteb05af27d2bc8597bb7ce54b4b545e5ec99dd84f (diff)
parent411890e27bceb65504009a477a57d2711e22c6d6 (diff)
downloadservo-f65cb94b9e417bdaab6fd8d699bf213ae55cd740.tar.gz
servo-f65cb94b9e417bdaab6fd8d699bf213ae55cd740.zip
Auto merge of #24674 - servo:jdm-patch-34, r=nox
Correct inverted logic for available image checks. From https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data: Step 3 says to initialize selected source to null. Step 4 says to set the selected source to the image element's src value if it's not using responsive images and it has a non-empty src value. Step 6 performs some steps if selected source is not null. The existing code tried to do the step 6 check in a roundabout way which caused us to always check for an available image when using responsive images, which is incorrect. The new code is easier to read and matches the specification text. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because it's not worth writing a test to verify that an image cache check that would always fail does not happen.
-rw-r--r--components/script/dom/htmlimageelement.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index 525f35d3e95..698e21517a8 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -927,10 +927,7 @@ impl HTMLImageElement {
*self.last_selected_source.borrow_mut() = selected_source.clone();
// Step 6, check the list of available images
- if !selected_source
- .as_ref()
- .map_or(false, |source| source.is_empty())
- {
+ if let Some(src) = selected_source {
if let Ok(img_url) = base_url.join(&src) {
let image_cache = window.image_cache();
let response = image_cache.find_image_or_metadata(