Обычно, если вы перемещаете указатель внутри документа, вы получаете такое поведение:

Это так называемое событие, выровненное по rAF, и оно находится внутри задачи рендеринга (это это поведение де-факто в Chrome).
Но мне удалось добиться совершенно другого поведения, когда событие pointermove происходит перед задачей рендеринга, в отдельной задаче:

Итак, настоящий вопрос заключается в следующем: когда это возможно? И как это объясняется в исходном коде Chromium?
У меня есть подозрение, что, возможно, эта функция делает что-то интересное:
Код: Выделить всё
void MainThreadEventQueue::QueueEvent(
std::unique_ptr event) {
bool is_raf_aligned = IsRafAlignedEvent(event);
bool needs_main_frame = false;
bool needs_post_task = false;
// Record the input event's type prior to enqueueing so that the scheduler
// can be notified of its dispatch (if the event is not coalesced).
bool is_input_event = event->IsWebInputEvent();
WebInputEvent::Type input_event_type = WebInputEvent::Type::kUndefined;
WebInputEventAttribution attribution;
if (is_input_event) {
auto* queued_input_event = static_cast(event.get());
input_event_type = queued_input_event->Event().GetType();
attribution = queued_input_event->attribution();
queued_input_event->SetQueuedTimeStamp(base::TimeTicks::Now());
}
{
base::AutoLock lock(shared_state_lock_);
if (shared_state_.events_.Enqueue(std::move(event)) ==
MainThreadEventQueueTaskList::EnqueueResult::kEnqueued) {
if (!is_raf_aligned) {
needs_post_task = !shared_state_.sent_post_task_;
shared_state_.sent_post_task_ = true;
} else {
needs_main_frame = !shared_state_.sent_main_frame_request_;
shared_state_.sent_main_frame_request_ = true;
}
// Notify the scheduler that we'll enqueue a task to the main thread.
if (is_input_event) {
widget_scheduler_->WillPostInputEventToMainThread(input_event_type,
attribution);
}
}
}
if (needs_post_task)
PostTaskToMainThread();
if (needs_main_frame) {
// This main frame request is coming from input, make it urgent.
//
// We only ever want to consider urgent frames for clients which could have
// main frames throttled, hence we check the eligibility.
bool urgent =
::features::IsEligibleForThrottleMainFrameTo60Hz() &&
base::FeatureList::IsEnabled(blink::features::kUrgentMainFrameForInput);
SetNeedsMainFrame(urgent);
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... move-event
Мобильная версия