Commit 7d0d09ec authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Introduce TypingContinuation enum class as replacement of FrameSelection::SetSelectionOptions

This patch introduces |TypingContinuation| enum class as replacement of
|FrameSelection::SetSelectionOptions| to include of "FrameSelection.h"
from "SpellChecker.h" for improving code health.

Note: Since "Editor.h" still use |FrameSelection::SetSelectionOptions|,
we could not remove it in this patch.

This patch is a preparation of the patch[1].

[1] http://crrev.com/569662: Introduce SetSelectionData for
FrameSelection::SetSelection()

Change-Id: I87601bbca3b1cada0a30fd5a86904bed84828423
Reviewed-on: https://chromium-review.googlesource.com/569840
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486718}
parent 494196d1
......@@ -1753,10 +1753,10 @@ void Editor::SetMarkedTextMatchesAreHighlighted(bool flag) {
DocumentMarker::kTextMatch);
}
void Editor::RespondToChangedSelection(
const Position& old_selection_start,
FrameSelection::SetSelectionOptions options) {
GetSpellChecker().RespondToChangedSelection(old_selection_start, options);
void Editor::RespondToChangedSelection(const Position& old_selection_start,
TypingContinuation typing_continuation) {
GetSpellChecker().RespondToChangedSelection(old_selection_start,
typing_continuation);
Client().RespondToChangedSelection(
&GetFrame(), GetFrame().Selection().GetSelectionInDOMTree().Type());
SetStartNewKillRingSequence(true);
......
......@@ -61,6 +61,7 @@ enum class DeleteDirection;
enum class DeleteMode { kSimple, kSmart };
enum class InsertMode { kSimple, kSmart };
enum class DragSourceType { kHTMLSource, kPlainTextSource };
enum class TypingContinuation { kContinue, kEnd };
enum EditorCommandSource { kCommandFromMenuOrKeyBinding, kCommandFromDOM };
enum EditorParagraphSeparator {
......@@ -252,7 +253,7 @@ class CORE_EXPORT Editor final : public GarbageCollectedFinalized<Editor> {
IntRect FirstRectForRange(const EphemeralRange&) const;
void RespondToChangedSelection(const Position& old_selection_start,
FrameSelection::SetSelectionOptions);
TypingContinuation);
bool MarkedTextMatchesAreHighlighted() const;
void SetMarkedTextMatchesAreHighlighted(bool);
......
......@@ -229,7 +229,9 @@ bool FrameSelection::SetSelectionDeprecated(
// Note: Since, setting focus can modify DOM tree, we should use
// |oldSelection| before setting focus
frame_->GetEditor().RespondToChangedSelection(
old_selection_in_dom_tree.ComputeStartPosition(), options);
old_selection_in_dom_tree.ComputeStartPosition(),
options & kCloseTyping ? TypingContinuation::kEnd
: TypingContinuation::kContinue);
DCHECK_EQ(current_document, GetDocument());
return true;
}
......
......@@ -37,6 +37,7 @@
#include "core/editing/EditingUtilities.h"
#include "core/editing/Editor.h"
#include "core/editing/EphemeralRange.h"
#include "core/editing/FrameSelection.h"
#include "core/editing/VisibleUnits.h"
#include "core/editing/commands/CompositeEditCommand.h"
#include "core/editing/commands/ReplaceSelectionCommand.h"
......@@ -966,7 +967,7 @@ static bool ShouldCheckOldSelection(const Position& old_selection_start) {
void SpellChecker::RespondToChangedSelection(
const Position& old_selection_start,
FrameSelection::SetSelectionOptions options) {
TypingContinuation typing_continuation) {
if (RuntimeEnabledFeatures::IdleTimeSpellCheckingEnabled()) {
idle_spell_check_callback_->SetNeedsInvocation();
return;
......@@ -986,7 +987,7 @@ void SpellChecker::RespondToChangedSelection(
return;
}
if (!(options & FrameSelection::kCloseTyping))
if (typing_continuation == TypingContinuation::kContinue)
return;
if (!ShouldCheckOldSelection(old_selection_start))
return;
......
......@@ -27,7 +27,6 @@
#define SpellChecker_h
#include "core/CoreExport.h"
#include "core/editing/FrameSelection.h"
#include "core/editing/VisibleSelection.h"
#include "core/editing/markers/DocumentMarker.h"
#include "platform/heap/Handle.h"
......@@ -47,6 +46,7 @@ class TextCheckerClient;
class TextCheckingParagraph;
struct TextCheckingResult;
class TypingCommand;
enum class TypingContinuation;
class WebSpellCheckPanelHostClient;
class CORE_EXPORT SpellChecker final : public GarbageCollected<SpellChecker> {
......@@ -74,7 +74,7 @@ class CORE_EXPORT SpellChecker final : public GarbageCollected<SpellChecker> {
void MarkMisspellingsForMovingParagraphs(const VisibleSelection&);
void RespondToChangedContents();
void RespondToChangedSelection(const Position& old_selection_start,
FrameSelection::SetSelectionOptions);
TypingContinuation);
Optional<std::pair<Node*, SpellCheckMarker*>>
GetSpellCheckMarkerTouchingSelection();
void ReplaceMisspelledRange(const String&);
......
......@@ -27,6 +27,7 @@
#include "core/editing/spellcheck/SpellCheckerClientImpl.h"
#include "core/dom/Element.h"
#include "core/editing/FrameSelection.h"
#include "core/editing/markers/DocumentMarkerController.h"
#include "core/editing/spellcheck/SpellChecker.h"
#include "core/exported/WebViewBase.h"
......
......@@ -93,9 +93,8 @@ TEST_F(SpellCheckerTest, SpellCheckDoesNotCauseUpdateLayout) {
EXPECT_TRUE(GetSpellChecker().IsSpellCheckingEnabled());
ForceLayout();
int start_count = LayoutCount();
GetSpellChecker().RespondToChangedSelection(
old_selection.Start(),
FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle);
GetSpellChecker().RespondToChangedSelection(old_selection.Start(),
TypingContinuation::kEnd);
EXPECT_EQ(start_count, LayoutCount());
}
......
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