mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #22451 - kingdido999:send-idle-message-once, r=jdm
Avoid sending idle message more than once after a reflow is complete <!-- Please describe your changes on the following line: --> A boolean variable is introduced to prevent sending SetDocumentState idle message multiple times after a reflow is complete. --- <!-- 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 #22410 (GitHub issue number if applicable) <!-- Either: --> - [x] These changes do not require tests because automated test is not possible. <!-- 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/22451) <!-- Reviewable:end -->
This commit is contained in:
commit
45e238938f
1 changed files with 11 additions and 3 deletions
|
@ -289,6 +289,10 @@ pub struct Window {
|
|||
/// Webrender API Sender
|
||||
#[ignore_malloc_size_of = "defined in webrender_api"]
|
||||
webrender_api_sender: RenderApiSender,
|
||||
|
||||
/// 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>,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -1541,12 +1545,15 @@ impl Window {
|
|||
elem.has_class(&atom!("reftest-wait"), CaseSensitivity::CaseSensitive)
|
||||
});
|
||||
|
||||
let ready_state = document.ReadyState();
|
||||
|
||||
let has_sent_idle_message = self.has_sent_idle_message.get();
|
||||
let is_ready_state_complete = document.ReadyState() == DocumentReadyState::Complete;
|
||||
let pending_images = self.pending_layout_images.borrow().is_empty();
|
||||
if ready_state == DocumentReadyState::Complete && !reftest_wait && pending_images {
|
||||
|
||||
if !has_sent_idle_message && is_ready_state_complete && !reftest_wait && pending_images
|
||||
{
|
||||
let event = ScriptMsg::SetDocumentState(DocumentState::Idle);
|
||||
self.send_to_constellation(event);
|
||||
self.has_sent_idle_message.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2094,6 +2101,7 @@ impl Window {
|
|||
webrender_document,
|
||||
exists_mut_observer: Cell::new(false),
|
||||
webrender_api_sender,
|
||||
has_sent_idle_message: Cell::new(false),
|
||||
});
|
||||
|
||||
unsafe { WindowBinding::Wrap(runtime.cx(), win) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue