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

Unified Diff: third_party/WebKit/Source/core/testing/Internals.cpp

Issue 2763893002: [WIP] Clean up DocumentMarkerController API (Closed)
Patch Set: Created 3 years, 9 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/testing/Internals.cpp
diff --git a/third_party/WebKit/Source/core/testing/Internals.cpp b/third_party/WebKit/Source/core/testing/Internals.cpp
index d88d52258c2f2344ed3f9baccb99b47c64675178..6bde7b88a79bf7c9dce2f083a17ee5fe61113612 100644
--- a/third_party/WebKit/Source/core/testing/Internals.cpp
+++ b/third_party/WebKit/Source/core/testing/Internals.cpp
@@ -962,9 +962,25 @@ void Internals::setMarker(Document* document,
return;
}
+ // Grammar and Spelling markers are the only marker types that can be set with
+ // just a range
+ if (type != DocumentMarker::Grammar && type != DocumentMarker::Spelling) {
+ exceptionState.throwDOMException(
+ SyntaxError,
+ "Marker of type '" + markerType +
+ "' was provided; type must be either Grammar or Spelling.");
+ return;
+ }
+
document->updateStyleAndLayoutIgnorePendingStylesheets();
- document->markers().addMarker(range->startPosition(), range->endPosition(),
- type.value());
+
+ if (type == DocumentMarker::Grammar) {
+ document->markers().addGrammarMarker(range->startPosition(),
+ range->endPosition());
+ } else {
+ document->markers().addSpellingMarker(range->startPosition(),
+ range->endPosition());
+ }
}
unsigned Internals::markerCountForNode(Node* node,
@@ -1052,8 +1068,8 @@ void Internals::addTextMatchMarker(const Range* range, bool isActive) {
return;
range->ownerDocument().updateStyleAndLayoutIgnorePendingStylesheets();
- range->ownerDocument().markers().addTextMatchMarker(EphemeralRange(range),
- isActive);
+ range->ownerDocument().markers().addTextMatchMarker(
+ range->startPosition(), range->endPosition(), isActive);
// This simulates what the production code does after
// DocumentMarkerController::addTextMatchMarker().
@@ -1096,8 +1112,8 @@ void Internals::setMarkersActive(Node* node,
unsigned endOffset,
bool active) {
DCHECK(node);
- node->document().markers().setMarkersActive(node, startOffset, endOffset,
- active);
+ node->document().markers().setTextMatchMarkersActive(node, startOffset,
+ endOffset, active);
}
void Internals::setMarkedTextMatchesAreHighlighted(Document* document,

Powered by Google App Engine
This is Rietveld 408576698