aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-08-23 02:31:48 -0500
committerGitHub <noreply@github.com>2016-08-23 02:31:48 -0500
commitfe09cb5504ebc24c903eae525ffad5c376a12b2b (patch)
tree4d467a58bba304da3ad039b168fafc8e415eab20 /components/script/dom
parentf99929bee305c8e3d86b06386e77486b62725157 (diff)
parenta48cf1d215eb0f2bd593827b1dafe591480dd2db (diff)
downloadservo-fe09cb5504ebc24c903eae525ffad5c376a12b2b.tar.gz
servo-fe09cb5504ebc24c903eae525ffad5c376a12b2b.zip
Auto merge of #12921 - paulrouget:imgOnError, r=nox
Trigger image.onerror --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #12885 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/12921) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/htmlimageelement.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index cb0f65d0b2b..f03e43d9f2e 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -86,14 +86,14 @@ impl Runnable for ImageResponseHandlerRunnable {
// Update the image field
let element = self.element.root();
let element_ref = element.r();
- let (image, metadata, trigger_image_load) = match self.image {
+ let (image, metadata, trigger_image_load, trigger_image_error) = match self.image {
ImageResponse::Loaded(image) | ImageResponse::PlaceholderLoaded(image) => {
- (Some(image.clone()), Some(ImageMetadata { height: image.height, width: image.width } ), true)
+ (Some(image.clone()), Some(ImageMetadata { height: image.height, width: image.width } ), true, false)
}
ImageResponse::MetadataLoaded(meta) => {
- (None, Some(meta), false)
+ (None, Some(meta), false, false)
}
- ImageResponse::None => (None, None, true)
+ ImageResponse::None => (None, None, false, true)
};
element_ref.current_request.borrow_mut().image = image;
element_ref.current_request.borrow_mut().metadata = metadata;
@@ -107,6 +107,11 @@ impl Runnable for ImageResponseHandlerRunnable {
element.upcast::<EventTarget>().fire_simple_event("load");
}
+ // Fire image.onerror
+ if trigger_image_error {
+ element.upcast::<EventTarget>().fire_simple_event("error");
+ }
+
// Trigger reflow
let window = window_from_node(document.r());
window.add_pending_reflow();