Commit fc704eaa authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Chromium LUCI CQ

Get rid of enum SelectionType

This patch gets rid of |enum SelectionType| because most of usage can be
replaced with |IsRange()| to simplify source code for improving code
health.

Change-Id: Ibe73e8a6b98767191e3dcc25beea9a02311a3dc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2566317
Commit-Queue: Kent Tamura <tkent@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832596}
parent 18c7a65b
...@@ -262,7 +262,6 @@ blink_core_sources_editing = [ ...@@ -262,7 +262,6 @@ blink_core_sources_editing = [
"selection_strategy.h", "selection_strategy.h",
"selection_template.cc", "selection_template.cc",
"selection_template.h", "selection_template.h",
"selection_type.h",
"serializers/create_markup_options.cc", "serializers/create_markup_options.cc",
"serializers/create_markup_options.h", "serializers/create_markup_options.h",
"serializers/html_interchange.cc", "serializers/html_interchange.cc",
......
...@@ -655,7 +655,7 @@ void ChangeSelectionAfterCommand(LocalFrame* frame, ...@@ -655,7 +655,7 @@ void ChangeSelectionAfterCommand(LocalFrame* frame,
if (!selection_did_not_change_dom_position) if (!selection_did_not_change_dom_position)
return; return;
frame->Client()->DidChangeSelection( frame->Client()->DidChangeSelection(
frame->Selection().GetSelectionInDOMTree().Type() != kRangeSelection); !frame->Selection().GetSelectionInDOMTree().IsRange());
} }
InputEvent::EventIsComposing IsComposingFromCommand( InputEvent::EventIsComposing IsComposingFromCommand(
......
...@@ -886,7 +886,7 @@ void Editor::SetMarkedTextMatchesAreHighlighted(bool flag) { ...@@ -886,7 +886,7 @@ void Editor::SetMarkedTextMatchesAreHighlighted(bool flag) {
void Editor::RespondToChangedSelection() { void Editor::RespondToChangedSelection() {
GetSpellChecker().RespondToChangedSelection(); GetSpellChecker().RespondToChangedSelection();
frame_->Client()->DidChangeSelection( frame_->Client()->DidChangeSelection(
GetFrameSelection().GetSelectionInDOMTree().Type() != kRangeSelection); !GetFrameSelection().GetSelectionInDOMTree().IsRange());
SetStartNewKillRingSequence(true); SetStartNewKillRingSequence(true);
} }
......
...@@ -662,9 +662,8 @@ void FrameSelection::SelectFrameElementInParentIfFullySelected() { ...@@ -662,9 +662,8 @@ void FrameSelection::SelectFrameElementInParentIfFullySelected() {
// Check if the selection contains the entire frame contents; if not, then // Check if the selection contains the entire frame contents; if not, then
// there is nothing to do. // there is nothing to do.
if (GetSelectionInDOMTree().Type() != kRangeSelection) { if (!GetSelectionInDOMTree().IsRange())
return; return;
}
// TODO(editing-dev): The use of UpdateStyleAndLayout // TODO(editing-dev): The use of UpdateStyleAndLayout
// needs to be audited. See http://crbug.com/590369 for more details. // needs to be audited. See http://crbug.com/590369 for more details.
......
...@@ -32,6 +32,8 @@ namespace blink { ...@@ -32,6 +32,8 @@ namespace blink {
class InputMethodControllerTest : public EditingTestBase { class InputMethodControllerTest : public EditingTestBase {
protected: protected:
enum SelectionType { kNoSelection, kCaretSelection, kRangeSelection };
InputMethodController& Controller() { InputMethodController& Controller() {
return GetFrame().GetInputMethodController(); return GetFrame().GetInputMethodController();
} }
......
...@@ -1293,18 +1293,16 @@ void SelectionController::NotifySelectionChanged() { ...@@ -1293,18 +1293,16 @@ void SelectionController::NotifySelectionChanged() {
const SelectionInDOMTree& selection = const SelectionInDOMTree& selection =
this->Selection().GetSelectionInDOMTree(); this->Selection().GetSelectionInDOMTree();
switch (selection.Type()) { if (selection.IsNone()) {
case kNoSelection: selection_state_ = SelectionState::kHaveNotStartedSelection;
selection_state_ = SelectionState::kHaveNotStartedSelection; return;
return; }
case kCaretSelection: if (selection.IsCaret()) {
selection_state_ = SelectionState::kPlacedCaret; selection_state_ = SelectionState::kPlacedCaret;
return; return;
case kRangeSelection:
selection_state_ = SelectionState::kExtendedSelection;
return;
} }
NOTREACHED() << "We should handle all SelectionType" << selection; DCHECK(selection.IsRange()) << selection;
selection_state_ = SelectionState::kExtendedSelection;
} }
FrameSelection& SelectionController::Selection() const { FrameSelection& SelectionController::Selection() const {
......
...@@ -185,15 +185,6 @@ void SelectionTemplate<Strategy>::ResetDirectionCache() const { ...@@ -185,15 +185,6 @@ void SelectionTemplate<Strategy>::ResetDirectionCache() const {
direction_ = base_ == extent_ ? Direction::kForward : Direction::kNotComputed; direction_ = base_ == extent_ ? Direction::kForward : Direction::kNotComputed;
} }
template <typename Strategy>
SelectionType SelectionTemplate<Strategy>::Type() const {
if (base_.IsNull())
return kNoSelection;
if (base_ == extent_)
return kCaretSelection;
return kRangeSelection;
}
template <typename Strategy> template <typename Strategy>
void SelectionTemplate<Strategy>::PrintTo(std::ostream* ostream, void SelectionTemplate<Strategy>::PrintTo(std::ostream* ostream,
const char* type) const { const char* type) const {
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/editing/forward.h" #include "third_party/blink/renderer/core/editing/forward.h"
#include "third_party/blink/renderer/core/editing/position.h" #include "third_party/blink/renderer/core/editing/position.h"
#include "third_party/blink/renderer/core/editing/selection_type.h"
#include "third_party/blink/renderer/core/editing/text_affinity.h" #include "third_party/blink/renderer/core/editing/text_affinity.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
...@@ -118,9 +117,6 @@ class SelectionTemplate final { ...@@ -118,9 +117,6 @@ class SelectionTemplate final {
PositionTemplate<Strategy> ComputeStartPosition() const; PositionTemplate<Strategy> ComputeStartPosition() const;
EphemeralRangeTemplate<Strategy> ComputeRange() const; EphemeralRangeTemplate<Strategy> ComputeRange() const;
// Returns |SelectionType| for |this| based on |base_| and |extent_|.
SelectionType Type() const;
void Trace(Visitor*) const; void Trace(Visitor*) const;
void PrintTo(std::ostream*, const char* type) const; void PrintTo(std::ostream*, const char* type) const;
......
/*
* Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SELECTION_TYPE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SELECTION_TYPE_H_
namespace blink {
enum SelectionType { kNoSelection, kCaretSelection, kRangeSelection };
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_SELECTION_TYPE_H_
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "third_party/blink/renderer/core/editing/editing_strategy.h" #include "third_party/blink/renderer/core/editing/editing_strategy.h"
#include "third_party/blink/renderer/core/editing/forward.h" #include "third_party/blink/renderer/core/editing/forward.h"
#include "third_party/blink/renderer/core/editing/position.h" #include "third_party/blink/renderer/core/editing/position.h"
#include "third_party/blink/renderer/core/editing/selection_type.h"
#include "third_party/blink/renderer/core/editing/text_affinity.h" #include "third_party/blink/renderer/core/editing/text_affinity.h"
#include "third_party/blink/renderer/core/editing/text_granularity.h" #include "third_party/blink/renderer/core/editing/text_granularity.h"
#include "third_party/blink/renderer/core/editing/visible_units.h" #include "third_party/blink/renderer/core/editing/visible_units.h"
......
...@@ -779,7 +779,7 @@ void TextControlElement::SelectionChanged(bool user_triggered) { ...@@ -779,7 +779,7 @@ void TextControlElement::SelectionChanged(bool user_triggered) {
return; return;
const SelectionInDOMTree& selection = const SelectionInDOMTree& selection =
frame->Selection().GetSelectionInDOMTree(); frame->Selection().GetSelectionInDOMTree();
if (selection.Type() != kRangeSelection) if (!selection.IsRange())
return; return;
DispatchEvent(*Event::CreateBubble(event_type_names::kSelect)); DispatchEvent(*Event::CreateBubble(event_type_names::kSelect));
} }
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "third_party/blink/renderer/core/editing/editor.h" #include "third_party/blink/renderer/core/editing/editor.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h" #include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/selection_template.h" #include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/selection_type.h"
#include "third_party/blink/renderer/core/editing/visible_selection.h" #include "third_party/blink/renderer/core/editing/visible_selection.h"
#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/html/html_element.h" #include "third_party/blink/renderer/core/html/html_element.h"
......
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