Commit f7522701 authored by Nate Chapin's avatar Nate Chapin Committed by Commit Bot

Merge NavigatorScheduling and Scheduling

Change-Id: Ic9adc4348e51e831b6a4eba184a7438512774546
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2527776
Auto-Submit: Nate Chapin <japhet@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Nate Chapin <japhet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826514}
parent d62ba389
......@@ -119,8 +119,6 @@ blink_core_sources_frame = [
"navigator_language.cc",
"navigator_language.h",
"navigator_on_line.h",
"navigator_scheduling.cc",
"navigator_scheduling.h",
"navigator_ua.cc",
"navigator_ua.h",
"navigator_ua_data.cc",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/frame/navigator_scheduling.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/scheduling.h"
namespace blink {
const char NavigatorScheduling::kSupplementName[] = "NavigatorScheduling";
NavigatorScheduling& NavigatorScheduling::From(Navigator& navigator) {
NavigatorScheduling* supplement =
Supplement<Navigator>::From<NavigatorScheduling>(navigator);
if (!supplement) {
supplement = MakeGarbageCollected<NavigatorScheduling>(navigator);
ProvideTo(navigator, supplement);
}
return *supplement;
}
Scheduling* NavigatorScheduling::scheduling(Navigator& navigator) {
return From(navigator).scheduling();
}
Scheduling* NavigatorScheduling::scheduling() {
return scheduling_;
}
void NavigatorScheduling::Trace(Visitor* visitor) const {
visitor->Trace(scheduling_);
Supplement<Navigator>::Trace(visitor);
}
NavigatorScheduling::NavigatorScheduling(Navigator& navigator)
: Supplement<Navigator>(navigator) {
scheduling_ = MakeGarbageCollected<Scheduling>();
}
} // namespace blink
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_NAVIGATOR_SCHEDULING_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_NAVIGATOR_SCHEDULING_H_
#include "third_party/blink/renderer/core/frame/navigator.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/supplementable.h"
namespace blink {
class Scheduling;
class CORE_EXPORT NavigatorScheduling final
: public GarbageCollected<NavigatorScheduling>,
public Supplement<Navigator> {
public:
static const char kSupplementName[];
static Scheduling* scheduling(Navigator& navigator);
Scheduling* scheduling();
explicit NavigatorScheduling(Navigator&);
void Trace(Visitor*) const override;
private:
static NavigatorScheduling& From(Navigator&);
Member<Scheduling> scheduling_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_NAVIGATOR_SCHEDULING_H_
......@@ -4,7 +4,7 @@
// https://github.com/WICG/is-input-pending
[
ImplementedAs=NavigatorScheduling,
ImplementedAs=Scheduling,
RuntimeEnabled=ExperimentalIsInputPending
] partial interface Navigator {
readonly attribute Scheduling scheduling;
......
......@@ -8,27 +8,39 @@
#include "third_party/blink/renderer/bindings/core/v8/v8_is_input_pending_options.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/navigator.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/main_thread/pending_user_input.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
namespace blink {
bool Scheduling::isInputPending(ScriptState* script_state,
const IsInputPendingOptions* options) const {
DCHECK(RuntimeEnabledFeatures::ExperimentalIsInputPendingEnabled(
ExecutionContext::From(script_state)));
DCHECK(options);
const char Scheduling::kSupplementName[] = "Scheduling";
Scheduling* Scheduling::scheduling(Navigator& navigator) {
Scheduling* supplement = Supplement<Navigator>::From<Scheduling>(navigator);
if (!supplement) {
supplement = MakeGarbageCollected<Scheduling>(navigator);
ProvideTo(navigator, supplement);
}
return supplement;
}
auto* frame = LocalDOMWindow::From(script_state)->GetFrame();
if (!frame)
Scheduling::Scheduling(Navigator& navigator)
: Supplement<Navigator>(navigator) {}
bool Scheduling::isInputPending(const IsInputPendingOptions* options) const {
LocalDOMWindow* window = GetSupplementable()->DomWindow();
DCHECK(RuntimeEnabledFeatures::ExperimentalIsInputPendingEnabled(window));
DCHECK(options);
if (!window)
return false;
auto* scheduler = ThreadScheduler::Current();
auto info = scheduler->GetPendingUserInputInfo(options->includeContinuous());
for (const auto& attribution : info) {
if (frame->CanAccessEvent(attribution)) {
if (window->GetFrame()->CanAccessEvent(attribution)) {
return true;
}
}
......@@ -40,4 +52,9 @@ bool Scheduling::isFramePending() const {
return scheduler->IsBeginMainFrameScheduled();
}
void Scheduling::Trace(Visitor* visitor) const {
ScriptWrappable::Trace(visitor);
Supplement<Navigator>::Trace(visitor);
}
} // namespace blink
......@@ -5,22 +5,31 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_SCHEDULING_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_SCHEDULING_H_
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/supplementable.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
class IsInputPendingOptions;
class Navigator;
// Low-level scheduling primitives for JS scheduler implementations.
class Scheduling : public ScriptWrappable {
class CORE_EXPORT Scheduling : public ScriptWrappable,
public Supplement<Navigator> {
DEFINE_WRAPPERTYPEINFO();
public:
bool isInputPending(ScriptState*, const IsInputPendingOptions* options) const;
static const char kSupplementName[];
static Scheduling* scheduling(Navigator&);
explicit Scheduling(Navigator&);
bool isInputPending(const IsInputPendingOptions* options) const;
bool isFramePending() const;
void Trace(Visitor*) const override;
};
} // namespace blink
......
......@@ -8,5 +8,5 @@
RuntimeEnabled=ExperimentalIsInputPending
] interface Scheduling {
[RuntimeEnabled=ExperimentalIsFramePending] boolean isFramePending();
[CallWith=ScriptState, MeasureAs=SchedulingIsInputPending, RuntimeEnabled=ExperimentalIsInputPending] boolean isInputPending(optional IsInputPendingOptions options = {});
[MeasureAs=SchedulingIsInputPending, RuntimeEnabled=ExperimentalIsInputPending] boolean isInputPending(optional IsInputPendingOptions options = {});
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment