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

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

Issue 2822963002: [DMC #1.3] Add DocumentMarkerController::ListForType() (Closed)
Patch Set: Fix nits, remove a dependency Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
index 22b90905b537ed8d71be0d3873721c65aa91235e..723063240c45796675049c24957c8cabfd33b823 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
@@ -77,6 +77,13 @@ DocumentMarker::MarkerTypeIndex MarkerTypeToMarkerIndex(
} // namespace
+Member<DocumentMarkerController::MarkerList>&
+DocumentMarkerController::ListForType(MarkerLists* marker_lists,
+ DocumentMarker::MarkerType type) {
+ const size_t marker_list_index = MarkerTypeToMarkerIndex(type);
+ return (*marker_lists)[marker_list_index];
+}
+
inline bool DocumentMarkerController::PossiblyHasMarkers(
DocumentMarker::MarkerTypes types) {
return possibly_existing_marker_types_.Intersects(types);
@@ -227,13 +234,11 @@ void DocumentMarkerController::AddMarker(Node* node,
markers->Grow(DocumentMarker::kMarkerTypeIndexesCount);
}
- DocumentMarker::MarkerTypeIndex marker_list_index =
- MarkerTypeToMarkerIndex(new_marker.GetType());
- if (!markers->at(marker_list_index)) {
- markers->at(marker_list_index) = new MarkerList;
- }
+ const DocumentMarker::MarkerType new_marker_type = new_marker.GetType();
+ if (!ListForType(markers, new_marker_type))
+ ListForType(markers, new_marker_type) = new MarkerList;
- Member<MarkerList>& list = markers->at(marker_list_index);
+ Member<MarkerList>& list = ListForType(markers, new_marker_type);
DocumentMarkerListEditor::AddMarker(list, &new_marker);
// repaint the affected node
@@ -761,8 +766,7 @@ bool DocumentMarkerController::SetMarkersActive(Node* node,
return false;
bool doc_dirty = false;
- Member<MarkerList>& list =
- (*markers)[MarkerTypeToMarkerIndex(DocumentMarker::kTextMatch)];
+ Member<MarkerList>& list = ListForType(markers, DocumentMarker::kTextMatch);
if (!list)
return false;
MarkerList::iterator start_pos =
« no previous file with comments | « third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698