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

Side by Side Diff: third_party/WebKit/Source/core/testing/Internals.cpp

Issue 2765133002: [WIP] Add DocumentMarkerController::addGrammarMarker() and addSpellingMarker() (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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 955 }
956 956
957 WTF::Optional<DocumentMarker::MarkerType> type = markerTypeFrom(markerType); 957 WTF::Optional<DocumentMarker::MarkerType> type = markerTypeFrom(markerType);
958 if (!type) { 958 if (!type) {
959 exceptionState.throwDOMException( 959 exceptionState.throwDOMException(
960 SyntaxError, 960 SyntaxError,
961 "The marker type provided ('" + markerType + "') is invalid."); 961 "The marker type provided ('" + markerType + "') is invalid.");
962 return; 962 return;
963 } 963 }
964 964
965 // Grammar and Spelling markers are the only marker types that can be set with
966 // just a range
967 if (type != DocumentMarker::Grammar && type != DocumentMarker::Spelling) {
968 exceptionState.throwDOMException(
969 SyntaxError,
970 "Marker of type '" + markerType +
971 "' was provided; type must be either Grammar or Spelling.");
972 return;
973 }
974
965 document->updateStyleAndLayoutIgnorePendingStylesheets(); 975 document->updateStyleAndLayoutIgnorePendingStylesheets();
966 document->markers().addMarker(range->startPosition(), range->endPosition(), 976
967 type.value()); 977 if (type == DocumentMarker::Grammar) {
978 document->markers().addGrammarMarker(range->startPosition(),
979 range->endPosition());
980 } else {
981 document->markers().addSpellingMarker(range->startPosition(),
982 range->endPosition());
983 }
968 } 984 }
969 985
970 unsigned Internals::markerCountForNode(Node* node, 986 unsigned Internals::markerCountForNode(Node* node,
971 const String& markerType, 987 const String& markerType,
972 ExceptionState& exceptionState) { 988 ExceptionState& exceptionState) {
973 DCHECK(node); 989 DCHECK(node);
974 WTF::Optional<DocumentMarker::MarkerTypes> markerTypes = 990 WTF::Optional<DocumentMarker::MarkerTypes> markerTypes =
975 markerTypesFrom(markerType); 991 markerTypesFrom(markerType);
976 if (!markerTypes) { 992 if (!markerTypes) {
977 exceptionState.throwDOMException( 993 exceptionState.throwDOMException(
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after
3226 3242
3227 void Internals::crash() { 3243 void Internals::crash() {
3228 CHECK(false) << "Intentional crash"; 3244 CHECK(false) << "Intentional crash";
3229 } 3245 }
3230 3246
3231 void Internals::setIsLowEndDevice(bool isLowEndDevice) { 3247 void Internals::setIsLowEndDevice(bool isLowEndDevice) {
3232 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); 3248 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice);
3233 } 3249 }
3234 3250
3235 } // namespace blink 3251 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698