Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Unified Diff: third_party/WebKit/Source/core/editing/markers/DocumentMarker.cpp

Issue 2907643004: [DMC #22] Move DocumentMarker::MatchStatus enum to TextMatchMarker (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/markers/DocumentMarker.cpp
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarker.cpp b/third_party/WebKit/Source/core/editing/markers/DocumentMarker.cpp
index 1accf9afe0e92d19460b3694e0dc88531de4e071..967a5b58927aaedd5af6e391502e4e9972db0d53 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarker.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarker.cpp
@@ -62,43 +62,6 @@ inline DocumentMarkerDescription* ToDocumentMarkerDescription(
return 0;
}
-class DocumentMarkerTextMatch final : public DocumentMarkerDetails {
- public:
- static DocumentMarkerTextMatch* Create(DocumentMarker::MatchStatus);
-
- bool IsActiveMatch() const {
- return match_status_ == DocumentMarker::MatchStatus::kActive;
- }
-
- bool IsTextMatch() const override { return true; }
-
- private:
- explicit DocumentMarkerTextMatch(DocumentMarker::MatchStatus match_status)
- : match_status_(match_status) {}
-
- DocumentMarker::MatchStatus match_status_;
-};
-
-DocumentMarkerTextMatch* DocumentMarkerTextMatch::Create(
- DocumentMarker::MatchStatus match_status) {
- DEFINE_STATIC_LOCAL(
- DocumentMarkerTextMatch, active_instance,
- (new DocumentMarkerTextMatch(DocumentMarker::MatchStatus::kActive)));
- DEFINE_STATIC_LOCAL(
- DocumentMarkerTextMatch, inactive_instance,
- (new DocumentMarkerTextMatch(DocumentMarker::MatchStatus::kInactive)));
- return match_status == DocumentMarker::MatchStatus::kActive
- ? &active_instance
- : &inactive_instance;
-}
-
-inline DocumentMarkerTextMatch* ToDocumentMarkerTextMatch(
- DocumentMarkerDetails* details) {
- if (details && details->IsTextMatch())
- return static_cast<DocumentMarkerTextMatch*>(details);
- return 0;
-}
-
class TextCompositionMarkerDetails final : public DocumentMarkerDetails {
public:
static TextCompositionMarkerDetails* Create(Color underline_color,
@@ -138,6 +101,13 @@ inline TextCompositionMarkerDetails* ToTextCompositionMarkerDetails(
return nullptr;
}
+DocumentMarker::DocumentMarker(MarkerType type,
+ unsigned start_offset,
+ unsigned end_offset)
+ : type_(type), start_offset_(start_offset), end_offset_(end_offset) {
+ DCHECK_LT(start_offset, end_offset);
+}
+
DocumentMarker::DocumentMarker(MarkerType type,
unsigned start_offset,
unsigned end_offset,
@@ -149,14 +119,6 @@ DocumentMarker::DocumentMarker(MarkerType type,
? nullptr
: DocumentMarkerDescription::Create(description)) {}
-DocumentMarker::DocumentMarker(unsigned start_offset,
- unsigned end_offset,
- DocumentMarker::MatchStatus match_status)
- : type_(DocumentMarker::kTextMatch),
- start_offset_(start_offset),
- end_offset_(end_offset),
- details_(DocumentMarkerTextMatch::Create(match_status)) {}
-
DocumentMarker::DocumentMarker(unsigned start_offset,
unsigned end_offset,
Color underline_color,
@@ -220,12 +182,6 @@ void DocumentMarker::ShiftOffsets(int delta) {
end_offset_ += delta;
}
-void DocumentMarker::SetIsActiveMatch(bool active) {
- details_ = DocumentMarkerTextMatch::Create(
- active ? DocumentMarker::MatchStatus::kActive
- : DocumentMarker::MatchStatus::kInactive);
-}
-
const String& DocumentMarker::Description() const {
if (DocumentMarkerDescription* details =
ToDocumentMarkerDescription(details_.Get()))
@@ -233,13 +189,6 @@ const String& DocumentMarker::Description() const {
return g_empty_string;
}
-bool DocumentMarker::IsActiveMatch() const {
- if (DocumentMarkerTextMatch* details =
- ToDocumentMarkerTextMatch(details_.Get()))
- return details->IsActiveMatch();
- return false;
-}
-
Color DocumentMarker::UnderlineColor() const {
if (TextCompositionMarkerDetails* details =
ToTextCompositionMarkerDetails(details_.Get()))

Powered by Google App Engine
This is Rietveld 408576698