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