diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-04-22 10:52:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-22 10:52:49 -0400 |
commit | 4e12deb7b6b61e2e329e8eaee431eddb473d1252 (patch) | |
tree | e81ca857db00b9266a4202b9a72977996049f057 /components/script/dom/window.rs | |
parent | 328244684a8b1f98d515d5f40655b9cf7347affd (diff) | |
parent | 4fd9fea7a64420265dfe482b577ad0fc74d2a817 (diff) | |
download | servo-4e12deb7b6b61e2e329e8eaee431eddb473d1252.tar.gz servo-4e12deb7b6b61e2e329e8eaee431eddb473d1252.zip |
Auto merge of #23115 - pylbrecht:measure.blocked.layout.queries, r=jdm
measure blocked layout queries
<!-- Please describe your changes on the following line: -->
---
<!-- 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
- [x] These changes fix #19797
<!-- Either: -->
- [ ] There are tests for these changes
<!-- 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/23115)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r-- | components/script/dom/window.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 104060c25ba..43f072ddbe0 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -92,7 +92,7 @@ use net_traits::{ReferrerPolicy, ResourceThreads}; use num_traits::ToPrimitive; use profile_traits::ipc as ProfiledIpc; use profile_traits::mem::ProfilerChan as MemProfilerChan; -use profile_traits::time::ProfilerChan as TimeProfilerChan; +use profile_traits::time::{ProfilerChan as TimeProfilerChan, ProfilerMsg}; use script_layout_interface::message::{Msg, QueryMsg, Reflow, ReflowGoal, ScriptReflow}; use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC}; use script_layout_interface::rpc::{ @@ -117,7 +117,7 @@ use std::fs; use std::io::{stderr, stdout, Write}; use std::mem; use std::rc::Rc; -use std::sync::atomic::Ordering; +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; use style::dom::OpaqueNode; use style::error_reporting::{ContextualParseError, ParseErrorReporter}; @@ -293,6 +293,10 @@ pub struct Window { /// Indicate whether a SetDocumentStatus message has been sent after a reflow is complete. /// It is used to avoid sending idle message more than once, which is unneccessary. has_sent_idle_message: Cell<bool>, + + /// Flag that indicates if the layout thread is busy handling a request. + #[ignore_malloc_size_of = "Arc<T> is hard"] + layout_is_busy: Arc<AtomicBool>, } impl Window { @@ -1558,6 +1562,12 @@ impl Window { } pub fn layout_reflow(&self, query_msg: QueryMsg) -> bool { + if self.layout_is_busy.load(Ordering::Relaxed) { + let url = self.get_url().into_string(); + self.time_profiler_chan() + .send(ProfilerMsg::BlockedLayoutQuery(url)); + } + self.reflow( ReflowGoal::LayoutQuery(query_msg, time::precise_time_ns()), ReflowReason::Query, @@ -2023,6 +2033,7 @@ impl Window { microtask_queue: Rc<MicrotaskQueue>, webrender_document: DocumentId, webrender_api_sender: RenderApiSender, + layout_is_busy: Arc<AtomicBool>, ) -> DomRoot<Self> { let layout_rpc: Box<dyn LayoutRPC + Send> = { let (rpc_send, rpc_recv) = unbounded(); @@ -2095,6 +2106,7 @@ impl Window { exists_mut_observer: Cell::new(false), webrender_api_sender, has_sent_idle_message: Cell::new(false), + layout_is_busy, }); unsafe { WindowBinding::Wrap(runtime.cx(), win) } |