Commit 43d4fc6b authored by dcheng's avatar dcheng Committed by Commit bot

Move core/editing timer to frame-specific task runners.

Caret blinking is an internal feature, so move it to the unpecced timer
task queue for now. In the future, this may change to be driven by
BeginFrame updates.

Similarly, spellcheck is also an internal feature of Chromium, so it
also uses the unspecced timer task queue.

BUG=624694

Review-Url: https://codereview.chromium.org/2612713002
Cr-Commit-Position: refs/heads/master@{#441390}
parent ba383c57
......@@ -25,6 +25,7 @@
#include "core/editing/FrameCaret.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/editing/EditingUtilities.h"
#include "core/editing/Editor.h"
#include "core/editing/SelectionEditor.h"
......@@ -41,19 +42,19 @@
namespace blink {
FrameCaret::FrameCaret(LocalFrame* frame,
FrameCaret::FrameCaret(LocalFrame& frame,
const SelectionEditor& selectionEditor)
: m_selectionEditor(&selectionEditor),
m_frame(frame),
m_caretVisibility(CaretVisibility::Hidden),
m_previousCaretVisibility(CaretVisibility::Hidden),
m_caretBlinkTimer(this, &FrameCaret::caretBlinkTimerFired),
m_caretBlinkTimer(TaskRunnerHelper::get(TaskType::UnspecedTimer, &frame),
this,
&FrameCaret::caretBlinkTimerFired),
m_caretRectDirty(true),
m_shouldPaintCaret(true),
m_isCaretBlinkingSuspended(false),
m_shouldShowBlockCursor(false) {
DCHECK(frame);
}
m_shouldShowBlockCursor(false) {}
FrameCaret::~FrameCaret() = default;
......
......@@ -38,7 +38,7 @@ enum class CaretVisibility { Visible, Hidden };
class CORE_EXPORT FrameCaret final : public CaretBase {
public:
FrameCaret(LocalFrame*, const SelectionEditor&);
FrameCaret(LocalFrame&, const SelectionEditor&);
~FrameCaret() override;
bool isActive() const { return caretPosition().isNotNull(); }
......@@ -95,7 +95,8 @@ class CORE_EXPORT FrameCaret final : public CaretBase {
LayoutRect m_previousCaretRect;
CaretVisibility m_caretVisibility;
CaretVisibility m_previousCaretVisibility;
Timer<FrameCaret> m_caretBlinkTimer;
// TODO(https://crbug.com/668758): Consider using BeginFrame update for this.
TaskRunnerTimer<FrameCaret> m_caretBlinkTimer;
bool m_caretRectDirty : 1;
bool m_shouldPaintCaret : 1;
bool m_isCaretBlinkingSuspended : 1;
......
......@@ -92,17 +92,15 @@ static inline bool shouldAlwaysUseDirectionalSelection(LocalFrame* frame) {
return frame->editor().behavior().shouldConsiderSelectionAsDirectional();
}
FrameSelection::FrameSelection(LocalFrame* frame)
FrameSelection::FrameSelection(LocalFrame& frame)
: m_frame(frame),
m_pendingSelection(PendingSelection::create(*this)),
m_selectionEditor(SelectionEditor::create(frame)),
m_granularity(CharacterGranularity),
m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation()),
m_focused(frame->page() &&
frame->page()->focusController().focusedFrame() == frame),
m_frameCaret(new FrameCaret(frame, *m_selectionEditor)) {
DCHECK(frame);
}
m_focused(frame.page() &&
frame.page()->focusController().focusedFrame() == frame),
m_frameCaret(new FrameCaret(frame, *m_selectionEditor)) {}
FrameSelection::~FrameSelection() {}
......
......@@ -70,7 +70,7 @@ class CORE_EXPORT FrameSelection final
WTF_MAKE_NONCOPYABLE(FrameSelection);
public:
static FrameSelection* create(LocalFrame* frame) {
static FrameSelection* create(LocalFrame& frame) {
return new FrameSelection(frame);
}
~FrameSelection();
......@@ -286,7 +286,7 @@ class CORE_EXPORT FrameSelection final
FRIEND_TEST_ALL_PREFIXES(PaintControllerPaintTestForSlimmingPaintV1AndV2,
FullDocumentPaintingWithCaret);
explicit FrameSelection(LocalFrame*);
explicit FrameSelection(LocalFrame&);
// Note: We have |selectionInFlatTree()| for unit tests, we should
// use |visibleSelection<EditingInFlatTreeStrategy>()|.
......
......@@ -32,9 +32,8 @@
namespace blink {
SelectionEditor::SelectionEditor(LocalFrame* frame)
SelectionEditor::SelectionEditor(LocalFrame& frame)
: m_frame(frame), m_observingVisibleSelection(false) {
DCHECK(m_frame);
clearVisibleSelection();
}
......
......@@ -40,7 +40,7 @@ class SelectionEditor final
WTF_MAKE_NONCOPYABLE(SelectionEditor);
public:
static SelectionEditor* create(LocalFrame* frame) {
static SelectionEditor* create(LocalFrame& frame) {
return new SelectionEditor(frame);
}
virtual ~SelectionEditor();
......@@ -85,7 +85,7 @@ class SelectionEditor final
DECLARE_TRACE();
private:
explicit SelectionEditor(LocalFrame*);
explicit SelectionEditor(LocalFrame&);
const Document& document() const;
LocalFrame* frame() const { return m_frame.get(); }
......
......@@ -5,6 +5,7 @@
#include "core/editing/spellcheck/IdleSpellCheckCallback.h"
#include "core/dom/IdleRequestOptions.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/editing/EditingUtilities.h"
#include "core/editing/FrameSelection.h"
#include "core/editing/VisibleSelection.h"
......@@ -47,7 +48,9 @@ IdleSpellCheckCallback* IdleSpellCheckCallback::create(LocalFrame& frame) {
IdleSpellCheckCallback::IdleSpellCheckCallback(LocalFrame& frame)
: m_state(State::kInactive),
m_frame(frame),
m_coldModeTimer(this, &IdleSpellCheckCallback::coldModeTimerFired) {}
m_coldModeTimer(TaskRunnerHelper::get(TaskType::UnspecedTimer, &frame),
this,
&IdleSpellCheckCallback::coldModeTimerFired) {}
SpellCheckRequester& IdleSpellCheckCallback::spellCheckRequester() const {
// TODO(xiaochengh): decouple with SpellChecker after SpellCheckRequester is
......
......@@ -79,8 +79,7 @@ class CORE_EXPORT IdleSpellCheckCallback final : public IdleRequestCallback {
State m_state;
const Member<LocalFrame> m_frame;
// TODO(xiaochengh): assign the timer to some proper task runner.
Timer<IdleSpellCheckCallback> m_coldModeTimer;
TaskRunnerTimer<IdleSpellCheckCallback> m_coldModeTimer;
};
} // namespace blink
......
......@@ -27,6 +27,7 @@
#include "core/dom/Document.h"
#include "core/dom/Node.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/editing/EditingUtilities.h"
#include "core/editing/markers/DocumentMarkerController.h"
#include "core/editing/spellcheck/SpellChecker.h"
......@@ -138,6 +139,7 @@ SpellCheckRequester::SpellCheckRequester(LocalFrame& frame)
m_lastRequestSequence(0),
m_lastProcessedSequence(0),
m_timerToProcessQueuedRequest(
TaskRunnerHelper::get(TaskType::UnspecedTimer, &frame),
this,
&SpellCheckRequester::timerFiredToProcessQueuedRequest) {}
......
......@@ -126,7 +126,7 @@ class SpellCheckRequester final
int m_lastRequestSequence;
int m_lastProcessedSequence;
Timer<SpellCheckRequester> m_timerToProcessQueuedRequest;
TaskRunnerTimer<SpellCheckRequester> m_timerToProcessQueuedRequest;
Member<SpellCheckRequest> m_processingRequest;
......
......@@ -871,7 +871,7 @@ inline LocalFrame::LocalFrame(FrameLoaderClient* client,
m_script(ScriptController::create(this)),
m_editor(Editor::create(*this)),
m_spellChecker(SpellChecker::create(*this)),
m_selection(FrameSelection::create(this)),
m_selection(FrameSelection::create(*this)),
m_eventHandler(new EventHandler(*this)),
m_console(FrameConsole::create(*this)),
m_inputMethodController(InputMethodController::create(*this)),
......
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