Skip to content
Permalink
Browse files

Support CORS attributes for image elements.

  • Loading branch information...
jdm committed Oct 3, 2019
1 parent 583536c commit 1df8d57dc6adcf56c22b45053b3d2eca904d17d3
Showing with 278 additions and 364 deletions.
  1. +1 −0 components/layout/context.rs
  2. +47 −15 components/net/image_cache.rs
  3. +2 −0 components/net_traits/image_cache.rs
  4. +10 −2 components/net_traits/request.rs
  5. +39 −9 components/script/dom/canvasrenderingcontext2d.rs
  6. +10 −2 components/script/dom/element.rs
  7. +10 −14 components/script/dom/eventsource.rs
  8. +2 −6 components/script/dom/htmlanchorelement.rs
  9. +7 −1 components/script/dom/htmlcanvaselement.rs
  10. +33 −5 components/script/dom/htmlimageelement.rs
  11. +4 −11 components/script/dom/htmlmediaelement.rs
  12. +3 −17 components/script/dom/htmlscriptelement.rs
  13. +1 −0 components/script/dom/htmlvideoelement.rs
  14. +19 −4 components/script/dom/servoparser/prefetch.rs
  15. +10 −7 components/script/dom/webglrenderingcontext.rs
  16. +30 −1 components/script/fetch.rs
  17. +4 −17 components/script/stylesheet_loader.rs
  18. +3 −0 tests/wpt/metadata/FileAPI/url/url-with-fetch.any.js.ini
  19. +10 −0 tests/wpt/metadata/MANIFEST.json
  20. +0 −2 tests/wpt/metadata/css/CSS2/floats/floats-in-table-caption-001.html.ini
  21. +0 −4 tests/wpt/metadata/css/CSS2/linebox/inline-negative-margin-001.html.ini
  22. +1 −1 tests/wpt/metadata/css/CSS2/positioning/abspos-float-with-inline-container.html.ini
  23. +2 −0 tests/wpt/metadata/css/CSS2/text/white-space-002.xht.ini
  24. +2 −0 tests/wpt/metadata/css/CSS2/text/white-space-003.xht.ini
  25. +2 −0 tests/wpt/metadata/css/CSS2/visudet/line-height-204.html.ini
  26. +2 −0 tests/wpt/metadata/css/compositing/mix-blend-mode/mix-blend-mode-paragraph.html.ini
  27. +2 −0 tests/wpt/metadata/css/css-backgrounds/background-repeat/background-repeat-round-roundup.xht.ini
  28. +0 −3 tests/wpt/metadata/css/css-fonts/variations/at-font-face-font-matching.html.ini
  29. +0 −2 tests/wpt/metadata/css/css-text/line-break/line-break-normal-018.xht.ini
  30. +0 −2 tests/wpt/metadata/css/css-text/line-break/line-break-strict-018.xht.ini
  31. +0 −2 tests/wpt/metadata/css/css-text/text-transform/text-transform-full-size-kana-001.html.ini
  32. +0 −2 tests/wpt/metadata/css/css-text/text-transform/text-transform-full-size-kana-002.html.ini
  33. +0 −2 tests/wpt/metadata/css/css-text/text-transform/text-transform-full-size-kana-003.html.ini
  34. +0 −2 tests/wpt/metadata/css/css-text/text-transform/text-transform-full-size-kana-004.html.ini
  35. +0 −2 tests/wpt/metadata/css/css-text/white-space/trailing-ideographic-space-004.html.ini
  36. +2 −0 tests/wpt/metadata/css/css-text/word-break/word-break-break-all-007.html.ini
  37. +2 −0 tests/wpt/metadata/css/css-text/word-break/word-break-keep-all-006.html.ini
  38. +0 −1 tests/wpt/metadata/css/css-transforms/animation/perspective-interpolation.html.ini
  39. +2 −0 tests/wpt/metadata/css/css-transforms/css-transforms-3d-on-anonymous-block-001.html.ini
  40. +0 −14 tests/wpt/metadata/custom-elements/reactions/HTMLMediaElement.html.ini
  41. +0 −2 tests/wpt/metadata/dom/nodes/Document-contentType/contentType/contenttype_html.html.ini
  42. +0 −2 tests/wpt/metadata/dom/nodes/Document-contentType/contentType/contenttype_txt.html.ini
  43. +0 −2 tests/wpt/metadata/dom/nodes/Document-contentType/contentType/contenttype_xml.html.ini
  44. +0 −4 tests/wpt/metadata/html/browsers/history/the-history-interface/traverse_the_history_2.html.ini
  45. +0 −4 tests/wpt/metadata/html/semantics/forms/form-submission-0/form-submission-algorithm.html.ini
  46. +0 −3 ...ata/html/semantics/links/links-created-by-a-and-area-elements/htmlanchorelement_noopener.html.ini
  47. +5 −0 ...cripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-iframe.html.ini
  48. +5 −0 ...ripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-onerror.html.ini
  49. +0 −4 ...pt/metadata/referrer-policy/gen/req.attr/no-referrer/img-tag/cross-http.keep-origin.http.html.ini
  50. +0 −4 ...pt/metadata/referrer-policy/gen/req.attr/no-referrer/img-tag/cross-http.no-redirect.http.html.ini
  51. +0 −4 ...t/metadata/referrer-policy/gen/req.attr/no-referrer/img-tag/cross-https.keep-origin.http.html.ini
  52. +0 −4 ...t/metadata/referrer-policy/gen/req.attr/no-referrer/img-tag/cross-https.no-redirect.http.html.ini
  53. +0 −4 ...t/metadata/referrer-policy/gen/req.attr/no-referrer/img-tag/cross-https.swap-origin.http.html.ini
  54. +0 −4 ...wpt/metadata/referrer-policy/gen/req.attr/no-referrer/img-tag/same-http.swap-origin.http.html.ini
  55. +0 −4 ...pt/metadata/referrer-policy/gen/req.attr/no-referrer/img-tag/same-https.keep-origin.http.html.ini
  56. +0 −4 ...pt/metadata/referrer-policy/gen/req.attr/no-referrer/img-tag/same-https.no-redirect.http.html.ini
  57. +0 −4 ...pt/metadata/referrer-policy/gen/req.attr/no-referrer/img-tag/same-https.swap-origin.http.html.ini
  58. +0 −4 ...pt/metadata/referrer-policy/gen/req.attr/same-origin/img-tag/cross-http.keep-origin.http.html.ini
  59. +0 −4 ...pt/metadata/referrer-policy/gen/req.attr/same-origin/img-tag/cross-http.no-redirect.http.html.ini
  60. +0 −4 ...t/metadata/referrer-policy/gen/req.attr/same-origin/img-tag/cross-https.keep-origin.http.html.ini
  61. +0 −4 ...t/metadata/referrer-policy/gen/req.attr/same-origin/img-tag/cross-https.no-redirect.http.html.ini
  62. +0 −4 ...t/metadata/referrer-policy/gen/req.attr/same-origin/img-tag/cross-https.swap-origin.http.html.ini
  63. +0 −4 ...wpt/metadata/referrer-policy/gen/req.attr/same-origin/img-tag/same-http.swap-origin.http.html.ini
  64. +0 −4 ...pt/metadata/referrer-policy/gen/req.attr/same-origin/img-tag/same-https.swap-origin.http.html.ini
  65. +0 −4 ...metadata/referrer-policy/gen/top.http-rp/no-referrer/img-tag/cross-http.keep-origin.http.html.ini
  66. +0 −4 ...metadata/referrer-policy/gen/top.http-rp/no-referrer/img-tag/cross-http.no-redirect.http.html.ini
  67. +0 −4 ...etadata/referrer-policy/gen/top.http-rp/no-referrer/img-tag/cross-https.keep-origin.http.html.ini
  68. +0 −4 ...etadata/referrer-policy/gen/top.http-rp/no-referrer/img-tag/cross-https.no-redirect.http.html.ini
  69. +0 −4 ...etadata/referrer-policy/gen/top.http-rp/no-referrer/img-tag/cross-https.swap-origin.http.html.ini
  70. +0 −4 .../metadata/referrer-policy/gen/top.http-rp/no-referrer/img-tag/same-http.swap-origin.http.html.ini
  71. +0 −4 ...metadata/referrer-policy/gen/top.http-rp/no-referrer/img-tag/same-https.keep-origin.http.html.ini
  72. +0 −4 ...metadata/referrer-policy/gen/top.http-rp/no-referrer/img-tag/same-https.no-redirect.http.html.ini
  73. +0 −4 ...metadata/referrer-policy/gen/top.http-rp/no-referrer/img-tag/same-https.swap-origin.http.html.ini
  74. +0 −4 ...metadata/referrer-policy/gen/top.http-rp/same-origin/img-tag/cross-http.keep-origin.http.html.ini
  75. +0 −4 ...metadata/referrer-policy/gen/top.http-rp/same-origin/img-tag/cross-http.no-redirect.http.html.ini
  76. +0 −4 ...etadata/referrer-policy/gen/top.http-rp/same-origin/img-tag/cross-https.keep-origin.http.html.ini
  77. +0 −4 ...etadata/referrer-policy/gen/top.http-rp/same-origin/img-tag/cross-https.no-redirect.http.html.ini
  78. +0 −4 ...etadata/referrer-policy/gen/top.http-rp/same-origin/img-tag/cross-https.swap-origin.http.html.ini
  79. +0 −4 .../metadata/referrer-policy/gen/top.http-rp/same-origin/img-tag/same-http.swap-origin.http.html.ini
  80. +0 −4 ...metadata/referrer-policy/gen/top.http-rp/same-origin/img-tag/same-https.swap-origin.http.html.ini
  81. +0 −4 ...pt/metadata/referrer-policy/gen/top.meta/no-referrer/img-tag/cross-http.keep-origin.http.html.ini
  82. +0 −4 ...pt/metadata/referrer-policy/gen/top.meta/no-referrer/img-tag/cross-http.no-redirect.http.html.ini
  83. +0 −4 ...t/metadata/referrer-policy/gen/top.meta/no-referrer/img-tag/cross-https.keep-origin.http.html.ini
  84. +0 −4 ...t/metadata/referrer-policy/gen/top.meta/no-referrer/img-tag/cross-https.no-redirect.http.html.ini
  85. +0 −4 ...t/metadata/referrer-policy/gen/top.meta/no-referrer/img-tag/cross-https.swap-origin.http.html.ini
  86. +0 −4 ...wpt/metadata/referrer-policy/gen/top.meta/no-referrer/img-tag/same-http.swap-origin.http.html.ini
  87. +0 −4 ...pt/metadata/referrer-policy/gen/top.meta/no-referrer/img-tag/same-https.keep-origin.http.html.ini
  88. +0 −4 ...pt/metadata/referrer-policy/gen/top.meta/no-referrer/img-tag/same-https.no-redirect.http.html.ini
  89. +0 −4 ...pt/metadata/referrer-policy/gen/top.meta/no-referrer/img-tag/same-https.swap-origin.http.html.ini
  90. +0 −4 ...pt/metadata/referrer-policy/gen/top.meta/same-origin/img-tag/cross-http.keep-origin.http.html.ini
  91. +0 −4 ...pt/metadata/referrer-policy/gen/top.meta/same-origin/img-tag/cross-http.no-redirect.http.html.ini
  92. +0 −4 ...t/metadata/referrer-policy/gen/top.meta/same-origin/img-tag/cross-https.keep-origin.http.html.ini
  93. +0 −4 ...t/metadata/referrer-policy/gen/top.meta/same-origin/img-tag/cross-https.no-redirect.http.html.ini
  94. +0 −4 ...t/metadata/referrer-policy/gen/top.meta/same-origin/img-tag/cross-https.swap-origin.http.html.ini
  95. +0 −4 ...wpt/metadata/referrer-policy/gen/top.meta/same-origin/img-tag/same-http.swap-origin.http.html.ini
  96. +0 −4 ...pt/metadata/referrer-policy/gen/top.meta/same-origin/img-tag/same-https.swap-origin.http.html.ini
  97. +0 −3 tests/wpt/metadata/resource-timing/resource_TAO_multi_wildcard.html.ini
  98. +2 −0 tests/wpt/metadata/resource-timing/resource_timing_buffer_full_eventually.html.ini
  99. +1 −0 .../metadata/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-scaling.html.ini
  100. +3 −0 ...a/webaudio/the-audio-api/the-audiobuffersourcenode-interface/sub-sample-buffer-stitching.html.ini
  101. +0 −1 tests/wpt/metadata/workers/semantics/multiple-workers/005.html.ini
  102. +0 −1 tests/wpt/metadata/workers/semantics/run-a-worker/003.html.ini
@@ -126,6 +126,7 @@ impl<'a> LayoutContext<'a> {
let result = self.image_cache.find_image_or_metadata(
url.clone(),
self.origin.clone(),
None,
use_placeholder,
can_request,
);
@@ -8,6 +8,7 @@ use net_traits::image::base::{load_from_memory, Image, ImageMetadata};
use net_traits::image_cache::{CanRequestImages, CorsStatus, ImageCache, ImageResponder};
use net_traits::image_cache::{ImageOrMetadataAvailable, ImageResponse, ImageState};
use net_traits::image_cache::{PendingImageId, UsePlaceholder};
use net_traits::request::CorsSettings;
use net_traits::{FetchMetadata, FetchResponseMsg, FilteredMetadata, NetworkError};
use pixels::PixelFormat;
use servo_url::{ImmutableOrigin, ServoUrl};
@@ -92,6 +93,9 @@ fn set_webrender_image_key(webrender_api: &webrender_api::RenderApi, image: &mut
// Aux structs and enums.
// ======================================================================

/// https://html.spec.whatwg.org/multipage/#list-of-available-images
type ImageKey = (ServoUrl, ImmutableOrigin, Option<CorsSettings>);

// Represents all the currently pending loads/decodings. For
// performance reasons, loads are indexed by a dedicated load key.
struct AllPendingLoads {
@@ -101,7 +105,7 @@ struct AllPendingLoads {

// Get a load key from its url and requesting origin. Used ony when starting and
// finishing a load or when adding a new listener.
url_to_load_key: HashMap<(ServoUrl, ImmutableOrigin), LoadKey>,
url_to_load_key: HashMap<ImageKey, LoadKey>,

// A counter used to generate instances of LoadKey
keygen: LoadKeyGenerator,
@@ -124,7 +128,11 @@ impl AllPendingLoads {
fn remove(&mut self, key: &LoadKey) -> Option<PendingLoad> {
self.loads.remove(key).and_then(|pending_load| {
self.url_to_load_key
.remove(&(pending_load.url.clone(), pending_load.load_origin.clone()))
.remove(&(
pending_load.url.clone(),
pending_load.load_origin.clone(),
pending_load.cors_setting,
))
.unwrap();
Some(pending_load)
})
@@ -134,9 +142,13 @@ impl AllPendingLoads {
&'a mut self,
url: ServoUrl,
origin: ImmutableOrigin,
cors_status: Option<CorsSettings>,
can_request: CanRequestImages,
) -> CacheResult<'a> {
match self.url_to_load_key.entry((url.clone(), origin.clone())) {
match self
.url_to_load_key
.entry((url.clone(), origin.clone(), cors_status))
{
Occupied(url_entry) => {
let load_key = url_entry.get();
CacheResult::Hit(*load_key, self.loads.get_mut(load_key).unwrap())
@@ -149,7 +161,7 @@ impl AllPendingLoads {
let load_key = self.keygen.next();
url_entry.insert(load_key);

let pending_load = PendingLoad::new(url, origin);
let pending_load = PendingLoad::new(url, origin, cors_status);
match self.loads.entry(load_key) {
Occupied(_) => unreachable!(),
Vacant(load_entry) => {
@@ -274,6 +286,9 @@ struct PendingLoad {
/// The origin that requested this load.
load_origin: ImmutableOrigin,

/// The CORS attribute setting for the requesting
cors_setting: Option<CorsSettings>,

/// The CORS status of this image response.
cors_status: CorsStatus,

@@ -282,7 +297,11 @@ struct PendingLoad {
}

impl PendingLoad {
fn new(url: ServoUrl, load_origin: ImmutableOrigin) -> PendingLoad {
fn new(
url: ServoUrl,
load_origin: ImmutableOrigin,
cors_setting: Option<CorsSettings>,
) -> PendingLoad {
PendingLoad {
bytes: ImageBytes::InProgress(vec![]),
metadata: None,
@@ -291,6 +310,7 @@ impl PendingLoad {
url: url,
load_origin,
final_url: None,
cors_setting,
cors_status: CorsStatus::Unsafe,
}
}
@@ -308,7 +328,7 @@ struct ImageCacheStore {
pending_loads: AllPendingLoads,

// Images that have finished loading (successful or not)
completed_loads: HashMap<(ServoUrl, ImmutableOrigin), CompletedLoad>,
completed_loads: HashMap<ImageKey, CompletedLoad>,

// The placeholder image used when an image fails to load
placeholder_image: Option<Arc<Image>>,
@@ -346,7 +366,11 @@ impl ImageCacheStore {

let completed_load = CompletedLoad::new(image_response.clone(), key);
self.completed_loads.insert(
(pending_load.url.into(), pending_load.load_origin),
(
pending_load.url.into(),
pending_load.load_origin,
pending_load.cors_setting,
),
completed_load,
);

@@ -361,10 +385,11 @@ impl ImageCacheStore {
&self,
url: ServoUrl,
origin: ImmutableOrigin,
cors_setting: Option<CorsSettings>,
placeholder: UsePlaceholder,
) -> Option<Result<ImageOrMetadataAvailable, ImageState>> {
self.completed_loads
.get(&(url, origin))
.get(&(url, origin, cors_setting))
.map(
|completed_load| match (&completed_load.image_response, placeholder) {
(&ImageResponse::Loaded(ref image, ref url), _) |
@@ -421,22 +446,29 @@ impl ImageCache for ImageCacheImpl {
&self,
url: ServoUrl,
origin: ImmutableOrigin,
cors_setting: Option<CorsSettings>,
use_placeholder: UsePlaceholder,
can_request: CanRequestImages,
) -> Result<ImageOrMetadataAvailable, ImageState> {
debug!("Find image or metadata for {} ({:?})", url, origin);
let mut store = self.store.lock().unwrap();
if let Some(result) =
store.get_completed_image_if_available(url.clone(), origin.clone(), use_placeholder)
{
if let Some(result) = store.get_completed_image_if_available(
url.clone(),
origin.clone(),
cors_setting,
use_placeholder,
) {
debug!("{} is available", url);
return result;
}

let decoded = {
let result = store
.pending_loads
.get_cached(url.clone(), origin.clone(), can_request);
let result = store.pending_loads.get_cached(
url.clone(),
origin.clone(),
cors_setting,
can_request,
);
match result {
CacheResult::Hit(key, pl) => match (&pl.result, &pl.metadata) {
(&Some(Ok(_)), _) => {
@@ -468,7 +500,7 @@ impl ImageCache for ImageCacheImpl {
// and ignore the async decode when it finishes later.
// TODO: make this behaviour configurable according to the caller's needs.
store.handle_decoder(decoded);
match store.get_completed_image_if_available(url, origin, use_placeholder) {
match store.get_completed_image_if_available(url, origin, cors_setting, use_placeholder) {
Some(result) => result,
None => Err(ImageState::LoadError),
}
@@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::image::base::{Image, ImageMetadata};
use crate::request::CorsSettings;
use crate::FetchResponseMsg;
use ipc_channel::ipc::IpcSender;
use servo_url::{ImmutableOrigin, ServoUrl};
@@ -111,6 +112,7 @@ pub trait ImageCache: Sync + Send {
&self,
url: ServoUrl,
origin: ImmutableOrigin,
cors_setting: Option<CorsSettings>,
use_placeholder: UsePlaceholder,
can_request: CanRequestImages,
) -> Result<ImageOrMetadataAvailable, ImageState>;
@@ -10,7 +10,7 @@ use msg::constellation_msg::PipelineId;
use servo_url::{ImmutableOrigin, ServoUrl};

/// An [initiator](https://fetch.spec.whatwg.org/#concept-request-initiator)
#[derive(Clone, Copy, MallocSizeOf, PartialEq)]
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub enum Initiator {
None,
Download,
@@ -128,7 +128,7 @@ pub enum Window {
}

/// [CORS settings attribute](https://html.spec.whatwg.org/multipage/#attr-crossorigin-anonymous)
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum CorsSettings {
Anonymous,
UseCredentials,
@@ -178,6 +178,7 @@ pub struct RequestBuilder {
// to keep track of redirects
pub url_list: Vec<ServoUrl>,
pub parser_metadata: ParserMetadata,
pub initiator: Initiator,
}

impl RequestBuilder {
@@ -204,9 +205,15 @@ impl RequestBuilder {
integrity_metadata: "".to_owned(),
url_list: vec![],
parser_metadata: ParserMetadata::Default,
initiator: Initiator::None,
}
}

pub fn initiator(mut self, initiator: Initiator) -> RequestBuilder {
self.initiator = initiator;
self
}

pub fn method(mut self, method: Method) -> RequestBuilder {
self.method = method;
self
@@ -298,6 +305,7 @@ impl RequestBuilder {
Some(Origin::Origin(self.origin)),
self.pipeline_id,
);
request.initiator = self.initiator;
request.method = self.method;
request.headers = self.headers;
request.unsafe_request = self.unsafe_request;
@@ -19,6 +19,7 @@ use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom};
use crate::dom::bindings::str::DOMString;
use crate::dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
use crate::dom::canvaspattern::CanvasPattern;
use crate::dom::element::cors_setting_for_element;
use crate::dom::element::Element;
use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlcanvaselement::{CanvasContext, HTMLCanvasElement};
@@ -45,6 +46,7 @@ use net_traits::image_cache::ImageOrMetadataAvailable;
use net_traits::image_cache::ImageResponse;
use net_traits::image_cache::ImageState;
use net_traits::image_cache::UsePlaceholder;
use net_traits::request::CorsSettings;
use pixels::PixelFormat;
use profile_traits::ipc as profiled_ipc;
use script_traits::ScriptMsg;
@@ -210,8 +212,12 @@ impl CanvasState {
}
}

fn fetch_image_data(&self, url: ServoUrl) -> Option<(Vec<u8>, Size2D<u32>)> {
let img = match self.request_image_from_cache(url) {
fn fetch_image_data(
&self,
url: ServoUrl,
cors_setting: Option<CorsSettings>,
) -> Option<(Vec<u8>, Size2D<u32>)> {
let img = match self.request_image_from_cache(url, cors_setting) {
ImageResponse::Loaded(img, _) => img,
ImageResponse::PlaceholderLoaded(_, _) |
ImageResponse::None |
@@ -229,11 +235,15 @@ impl CanvasState {
Some((image_data, image_size))
}

#[inline]
fn request_image_from_cache(&self, url: ServoUrl) -> ImageResponse {
fn request_image_from_cache(
&self,
url: ServoUrl,
cors_setting: Option<CorsSettings>,
) -> ImageResponse {
let response = self.image_cache.find_image_or_metadata(
url.clone(),
self.origin.clone(),
cors_setting,
UsePlaceholder::No,
CanRequestImages::No,
);
@@ -353,13 +363,28 @@ impl CanvasState {
// If the image argument is an HTMLImageElement object that is in the broken state,
// then throw an InvalidStateError exception
let url = image.get_url().ok_or(Error::InvalidState)?;
self.fetch_and_draw_image_data(htmlcanvas, url, sx, sy, sw, sh, dx, dy, dw, dh)
let cors_setting = cors_setting_for_element(image.upcast());
self.fetch_and_draw_image_data(
htmlcanvas,
url,
cors_setting,
sx,
sy,
sw,
sh,
dx,
dy,
dw,
dh,
)
},
CanvasImageSource::CSSStyleValue(ref value) => {
let url = value
.get_url(self.base_url.clone())
.ok_or(Error::InvalidState)?;
self.fetch_and_draw_image_data(htmlcanvas, url, sx, sy, sw, sh, dx, dy, dw, dh)
self.fetch_and_draw_image_data(
htmlcanvas, url, None, sx, sy, sw, sh, dx, dy, dw, dh,
)
},
};

@@ -435,6 +460,7 @@ impl CanvasState {
&self,
canvas: Option<&HTMLCanvasElement>,
url: ServoUrl,
cors_setting: Option<CorsSettings>,
sx: f64,
sy: f64,
sw: Option<f64>,
@@ -445,7 +471,9 @@ impl CanvasState {
dh: Option<f64>,
) -> ErrorResult {
debug!("Fetching image {}.", url);
let (mut image_data, image_size) = self.fetch_image_data(url).ok_or(Error::InvalidState)?;
let (mut image_data, image_size) = self
.fetch_image_data(url, cors_setting)
.ok_or(Error::InvalidState)?;
pixels::rgba8_premultiply_inplace(&mut image_data);
let image_size = image_size.to_f64();

@@ -788,7 +816,9 @@ impl CanvasState {
// then throw an InvalidStateError exception
image
.get_url()
.and_then(|url| self.fetch_image_data(url))
.and_then(|url| {
self.fetch_image_data(url, cors_setting_for_element(image.upcast()))
})
.ok_or(Error::InvalidState)?
},
CanvasImageSource::HTMLCanvasElement(ref canvas) => {
@@ -800,7 +830,7 @@ impl CanvasState {
},
CanvasImageSource::CSSStyleValue(ref value) => value
.get_url(self.base_url.clone())
.and_then(|url| self.fetch_image_data(url))
.and_then(|url| self.fetch_image_data(url, None))
.ok_or(Error::InvalidState)?,
};

0 comments on commit 1df8d57

Please sign in to comment.
You can’t perform that action at this time.