OLD | NEW |
---|---|
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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 } | 912 } |
913 | 913 |
914 WTF::Optional<DocumentMarker::MarkerType> type = markerTypeFrom(markerType); | 914 WTF::Optional<DocumentMarker::MarkerType> type = markerTypeFrom(markerType); |
915 if (!type) { | 915 if (!type) { |
916 exceptionState.throwDOMException( | 916 exceptionState.throwDOMException( |
917 SyntaxError, | 917 SyntaxError, |
918 "The marker type provided ('" + markerType + "') is invalid."); | 918 "The marker type provided ('" + markerType + "') is invalid."); |
919 return; | 919 return; |
920 } | 920 } |
921 | 921 |
922 // Grammar and Spelling markers are the only marker types that can be set with | |
923 // just a range | |
924 if (type != DocumentMarker::Grammar && type != DocumentMarker::Spelling) { | |
yosin_UTC9
2017/03/30 01:48:57
Move this check at end of function to utilize earl
| |
925 exceptionState.throwDOMException( | |
926 SyntaxError, | |
927 "Marker of type '" + markerType + | |
928 "' was provided; type must be either Grammar or Spelling."); | |
929 return; | |
930 } | |
931 | |
922 document->updateStyleAndLayoutIgnorePendingStylesheets(); | 932 document->updateStyleAndLayoutIgnorePendingStylesheets(); |
923 document->markers().addMarker(range->startPosition(), range->endPosition(), | 933 |
924 type.value()); | 934 if (type == DocumentMarker::Grammar) { |
935 document->markers().addGrammarMarker(range->startPosition(), | |
yosin_UTC9
2017/03/30 01:48:57
Let's use early return style.
| |
936 range->endPosition()); | |
937 } else { | |
938 document->markers().addSpellingMarker(range->startPosition(), | |
939 range->endPosition()); | |
940 } | |
925 } | 941 } |
926 | 942 |
927 unsigned Internals::markerCountForNode(Node* node, | 943 unsigned Internals::markerCountForNode(Node* node, |
928 const String& markerType, | 944 const String& markerType, |
929 ExceptionState& exceptionState) { | 945 ExceptionState& exceptionState) { |
930 DCHECK(node); | 946 DCHECK(node); |
931 WTF::Optional<DocumentMarker::MarkerTypes> markerTypes = | 947 WTF::Optional<DocumentMarker::MarkerTypes> markerTypes = |
932 markerTypesFrom(markerType); | 948 markerTypesFrom(markerType); |
933 if (!markerTypes) { | 949 if (!markerTypes) { |
934 exceptionState.throwDOMException( | 950 exceptionState.throwDOMException( |
(...skipping 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3210 | 3226 |
3211 void Internals::crash() { | 3227 void Internals::crash() { |
3212 CHECK(false) << "Intentional crash"; | 3228 CHECK(false) << "Intentional crash"; |
3213 } | 3229 } |
3214 | 3230 |
3215 void Internals::setIsLowEndDevice(bool isLowEndDevice) { | 3231 void Internals::setIsLowEndDevice(bool isLowEndDevice) { |
3216 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); | 3232 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); |
3217 } | 3233 } |
3218 | 3234 |
3219 } // namespace blink | 3235 } // namespace blink |
OLD | NEW |