diff --git a/components/layout/layout_impl.rs b/components/layout/layout_impl.rs index 68219e9f156..bb84806ebdb 100644 --- a/components/layout/layout_impl.rs +++ b/components/layout/layout_impl.rs @@ -452,6 +452,8 @@ impl Layout for LayoutThread { .map(|tree| tree.conditional_size_of(ops)) .unwrap_or_default(), }); + + reports.push(self.image_cache.memory_report(formatted_url, ops)); } fn set_quirks_mode(&mut self, quirks_mode: QuirksMode) { diff --git a/components/net/image_cache.rs b/components/net/image_cache.rs index eab2f9c08fe..e3d31b11736 100644 --- a/components/net/image_cache.rs +++ b/components/net/image_cache.rs @@ -431,7 +431,7 @@ pub struct ImageCacheImpl { store: Arc>, /// Thread pool for image decoding - thread_pool: CoreResourceThreadPool, + thread_pool: Arc, } impl ImageCache for ImageCacheImpl { @@ -454,7 +454,10 @@ impl ImageCache for ImageCacheImpl { placeholder_url: ServoUrl::parse("chrome://resources/rippy.png").unwrap(), compositor_api, })), - thread_pool: CoreResourceThreadPool::new(thread_count, "ImageCache".to_string()), + thread_pool: Arc::new(CoreResourceThreadPool::new( + thread_count, + "ImageCache".to_string(), + )), } } @@ -651,6 +654,25 @@ impl ImageCache for ImageCacheImpl { }, } } + + fn create_new_image_cache( + &self, + compositor_api: CrossProcessCompositorApi, + ) -> Arc { + let store = self.store.lock().unwrap(); + let placeholder_image = store.placeholder_image.clone(); + let placeholder_url = store.placeholder_url.clone(); + Arc::new(ImageCacheImpl { + store: Arc::new(Mutex::new(ImageCacheStore { + pending_loads: AllPendingLoads::new(), + completed_loads: HashMap::new(), + placeholder_image, + placeholder_url, + compositor_api, + })), + thread_pool: self.thread_pool.clone(), + }) + } } impl ImageCacheImpl { diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 7241c115a2a..6e192cc920c 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -745,7 +745,9 @@ impl ScriptThread { .senders .pipeline_to_constellation_sender .clone(), - image_cache: script_thread.image_cache.clone(), + image_cache: script_thread + .image_cache + .create_new_image_cache(script_thread.compositor_api.clone()), #[cfg(feature = "webgpu")] gpu_id_hub: script_thread.gpu_id_hub.clone(), inherited_secure_context: script_thread.inherited_secure_context, @@ -2443,8 +2445,6 @@ impl ScriptThread { let prefix = format!("url({urls})"); reports.extend(self.get_cx().get_reports(prefix.clone(), ops)); - - reports.push(self.image_cache.memory_report(&prefix, ops)); }); reports_chan.send(ProcessReports::new(reports)); @@ -3145,13 +3145,17 @@ impl ScriptThread { self.resource_threads.clone(), )); + let image_cache = self + .image_cache + .create_new_image_cache(self.compositor_api.clone()); + let layout_config = LayoutConfig { id: incomplete.pipeline_id, webview_id: incomplete.webview_id, url: final_url.clone(), is_iframe: incomplete.parent_info.is_some(), script_chan: self.senders.constellation_sender.clone(), - image_cache: self.image_cache.clone(), + image_cache: image_cache.clone(), font_context: font_context.clone(), time_profiler_chan: self.senders.time_profiler_sender.clone(), compositor_api: self.compositor_api.clone(), @@ -3166,7 +3170,7 @@ impl ScriptThread { self.layout_factory.create(layout_config), font_context, self.senders.image_cache_sender.clone(), - self.image_cache.clone(), + image_cache.clone(), self.resource_threads.clone(), #[cfg(feature = "bluetooth")] self.senders.bluetooth_sender.clone(), diff --git a/components/shared/net/image_cache.rs b/components/shared/net/image_cache.rs index 8fb329d304f..3f316388755 100644 --- a/components/shared/net/image_cache.rs +++ b/components/shared/net/image_cache.rs @@ -141,4 +141,10 @@ pub trait ImageCache: Sync + Send { /// Inform the image cache about a response for a pending request. fn notify_pending_response(&self, id: PendingImageId, action: FetchResponseMsg); + + /// Create new image cache based on this one, while reusing the existing thread_pool. + fn create_new_image_cache( + &self, + compositor_api: CrossProcessCompositorApi, + ) -> Arc; } diff --git a/tests/wpt/meta/content-security-policy/generic/invalid-characters-in-policy.html.ini b/tests/wpt/meta/content-security-policy/generic/invalid-characters-in-policy.html.ini index ccb770e00d4..395e5cf9f3f 100644 --- a/tests/wpt/meta/content-security-policy/generic/invalid-characters-in-policy.html.ini +++ b/tests/wpt/meta/content-security-policy/generic/invalid-characters-in-policy.html.ini @@ -1,18 +1,12 @@ [invalid-characters-in-policy.html] - [Should not load image with 'none' CSP - meta tag] - expected: FAIL - - [Should not load image with 'none' CSP - HTTP header] - expected: FAIL - - [Non-ASCII character in directive value should not affect other directives. - meta tag] - expected: FAIL - [Non-ASCII character in directive value should not affect other directives. - HTTP header] expected: FAIL - [Non-ASCII character in directive name should not affect other directives. - meta tag] - expected: FAIL - [Non-ASCII character in directive name should not affect other directives. - HTTP header] expected: FAIL + + [Non-ASCII character in directive value should drop the whole directive. - meta tag] + expected: FAIL + + [Non-ASCII quote character in directive value should drop the whole directive. - meta tag] + expected: FAIL diff --git a/tests/wpt/meta/content-security-policy/generic/only-valid-whitespaces-are-allowed.html.ini b/tests/wpt/meta/content-security-policy/generic/only-valid-whitespaces-are-allowed.html.ini index a8dd0149615..e3648061bc3 100644 --- a/tests/wpt/meta/content-security-policy/generic/only-valid-whitespaces-are-allowed.html.ini +++ b/tests/wpt/meta/content-security-policy/generic/only-valid-whitespaces-are-allowed.html.ini @@ -6,50 +6,5 @@ [U+000C FF should be properly parsed inside directive value - HTTP header] expected: TIMEOUT - [Should not load image with 'none' CSP - meta tag] - expected: FAIL - - [Should not load image with 'none' CSP - HTTP header] - expected: FAIL - - [U+0009 TAB should be properly parsed between directive name and value - meta tag] - expected: FAIL - - [U+0009 TAB should be properly parsed between directive name and value - HTTP header] - expected: FAIL - - [U+000C FF should be properly parsed between directive name and value - meta tag] - expected: FAIL - - [U+000A LF should be properly parsed between directive name and value - meta tag] - expected: FAIL - - [U+000D CR should be properly parsed between directive name and value - meta tag] - expected: FAIL - - [U+0020 SPACE should be properly parsed between directive name and value - meta tag] - expected: FAIL - - [U+0020 SPACE should be properly parsed between directive name and value - HTTP header] - expected: FAIL - - [U+0009 TAB should be properly parsed inside directive value - meta tag] - expected: FAIL - - [U+0009 TAB should be properly parsed inside directive value - HTTP header] - expected: FAIL - - [U+000C FF should be properly parsed inside directive value - meta tag] - expected: FAIL - - [U+000A LF should be properly parsed inside directive value - meta tag] - expected: FAIL - - [U+000D CR should be properly parsed inside directive value - meta tag] - expected: FAIL - - [U+0020 SPACE should be properly parsed inside directive value - meta tag] - expected: FAIL - - [U+0020 SPACE should be properly parsed inside directive value - HTTP header] + [U+00A0 NBSP should not be parsed inside directive value - meta tag] expected: FAIL diff --git a/tests/wpt/meta/content-security-policy/inheritance/history-iframe.sub.html.ini b/tests/wpt/meta/content-security-policy/inheritance/history-iframe.sub.html.ini index d629ffef04f..73a32477504 100644 --- a/tests/wpt/meta/content-security-policy/inheritance/history-iframe.sub.html.ini +++ b/tests/wpt/meta/content-security-policy/inheritance/history-iframe.sub.html.ini @@ -16,9 +16,3 @@ [History navigation in iframe: data URL document is navigated back from history cross-origin.] expected: FAIL - - [History navigation in iframe: srcdoc iframe is navigated back from history same-origin.] - expected: FAIL - - [History navigation in iframe: srcdoc iframe is navigated back from history cross-origin.] - expected: FAIL diff --git a/tests/wpt/meta/content-security-policy/inheritance/iframe-all-local-schemes.sub.html.ini b/tests/wpt/meta/content-security-policy/inheritance/iframe-all-local-schemes.sub.html.ini index af308a4588e..fcd96aa7a47 100644 --- a/tests/wpt/meta/content-security-policy/inheritance/iframe-all-local-schemes.sub.html.ini +++ b/tests/wpt/meta/content-security-policy/inheritance/iframe-all-local-schemes.sub.html.ini @@ -4,3 +4,15 @@ [