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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #include "core/dom/shadow/FlatTreeTraversal.h" | 63 #include "core/dom/shadow/FlatTreeTraversal.h" |
64 #include "core/dom/shadow/SelectRuleFeatureSet.h" | 64 #include "core/dom/shadow/SelectRuleFeatureSet.h" |
65 #include "core/dom/shadow/ShadowRoot.h" | 65 #include "core/dom/shadow/ShadowRoot.h" |
66 #include "core/editing/Editor.h" | 66 #include "core/editing/Editor.h" |
67 #include "core/editing/PlainTextRange.h" | 67 #include "core/editing/PlainTextRange.h" |
68 #include "core/editing/SurroundingText.h" | 68 #include "core/editing/SurroundingText.h" |
69 #include "core/editing/iterators/TextIterator.h" | 69 #include "core/editing/iterators/TextIterator.h" |
70 #include "core/editing/markers/DocumentMarker.h" | 70 #include "core/editing/markers/DocumentMarker.h" |
71 #include "core/editing/markers/DocumentMarkerController.h" | 71 #include "core/editing/markers/DocumentMarkerController.h" |
72 #include "core/editing/serializers/Serialization.h" | 72 #include "core/editing/serializers/Serialization.h" |
| 73 #include "core/editing/spellcheck/IdleSpellCheckCallback.h" |
73 #include "core/editing/spellcheck/SpellCheckRequester.h" | 74 #include "core/editing/spellcheck/SpellCheckRequester.h" |
74 #include "core/editing/spellcheck/SpellChecker.h" | 75 #include "core/editing/spellcheck/SpellChecker.h" |
75 #include "core/frame/EventHandlerRegistry.h" | 76 #include "core/frame/EventHandlerRegistry.h" |
76 #include "core/frame/FrameConsole.h" | 77 #include "core/frame/FrameConsole.h" |
77 #include "core/frame/FrameView.h" | 78 #include "core/frame/FrameView.h" |
78 #include "core/frame/LocalDOMWindow.h" | 79 #include "core/frame/LocalDOMWindow.h" |
79 #include "core/frame/LocalFrame.h" | 80 #include "core/frame/LocalFrame.h" |
80 #include "core/frame/Settings.h" | 81 #include "core/frame/Settings.h" |
81 #include "core/frame/VisualViewport.h" | 82 #include "core/frame/VisualViewport.h" |
82 #include "core/html/HTMLContentElement.h" | 83 #include "core/html/HTMLContentElement.h" |
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 if (!requester) { | 1488 if (!requester) { |
1488 exceptionState.throwDOMException( | 1489 exceptionState.throwDOMException( |
1489 InvalidAccessError, | 1490 InvalidAccessError, |
1490 "No spell check requestor can be obtained for the provided document."); | 1491 "No spell check requestor can be obtained for the provided document."); |
1491 return -1; | 1492 return -1; |
1492 } | 1493 } |
1493 | 1494 |
1494 return requester->lastProcessedSequence(); | 1495 return requester->lastProcessedSequence(); |
1495 } | 1496 } |
1496 | 1497 |
| 1498 String Internals::idleTimeSpellCheckerState(Document* document, |
| 1499 ExceptionState& exceptionState) { |
| 1500 static const char* const texts[] = { |
| 1501 #define V(state) #state, |
| 1502 FOR_EACH_IDLE_SPELL_CHECK_CALLBACK_STATE(V) |
| 1503 #undef V |
| 1504 }; |
| 1505 |
| 1506 if (!document || !document->frame()) { |
| 1507 exceptionState.throwDOMException( |
| 1508 InvalidAccessError, |
| 1509 "No frame can be obtained from the provided document."); |
| 1510 return String(); |
| 1511 } |
| 1512 |
| 1513 IdleSpellCheckCallback::State state = |
| 1514 document->frame()->spellChecker().idleSpellCheckCallback().state(); |
| 1515 const auto& it = std::begin(texts) + static_cast<size_t>(state); |
| 1516 DCHECK_GE(it, std::begin(texts)) << "Unknown state value"; |
| 1517 DCHECK_LT(it, std::end(texts)) << "Unknown state value"; |
| 1518 return *it; |
| 1519 } |
| 1520 |
| 1521 void Internals::runIdleTimeSpellChecker(Document* document, |
| 1522 ExceptionState& exceptionState) { |
| 1523 if (!document || !document->frame()) { |
| 1524 exceptionState.throwDOMException( |
| 1525 InvalidAccessError, |
| 1526 "No frame can be obtained from the provided document."); |
| 1527 return; |
| 1528 } |
| 1529 |
| 1530 document->frame() |
| 1531 ->spellChecker() |
| 1532 .idleSpellCheckCallback() |
| 1533 .forceInvocationForTesting(); |
| 1534 } |
| 1535 |
1497 Vector<AtomicString> Internals::userPreferredLanguages() const { | 1536 Vector<AtomicString> Internals::userPreferredLanguages() const { |
1498 return blink::userPreferredLanguages(); | 1537 return blink::userPreferredLanguages(); |
1499 } | 1538 } |
1500 | 1539 |
1501 // Optimally, the bindings generator would pass a Vector<AtomicString> here but | 1540 // Optimally, the bindings generator would pass a Vector<AtomicString> here but |
1502 // this is not supported yet. | 1541 // this is not supported yet. |
1503 void Internals::setUserPreferredLanguages(const Vector<String>& languages) { | 1542 void Internals::setUserPreferredLanguages(const Vector<String>& languages) { |
1504 Vector<AtomicString> atomicLanguages; | 1543 Vector<AtomicString> atomicLanguages; |
1505 for (size_t i = 0; i < languages.size(); ++i) | 1544 for (size_t i = 0; i < languages.size(); ++i) |
1506 atomicLanguages.push_back(AtomicString(languages[i])); | 1545 atomicLanguages.push_back(AtomicString(languages[i])); |
(...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3176 | 3215 |
3177 void Internals::crash() { | 3216 void Internals::crash() { |
3178 CHECK(false) << "Intentional crash"; | 3217 CHECK(false) << "Intentional crash"; |
3179 } | 3218 } |
3180 | 3219 |
3181 void Internals::setIsLowEndDevice(bool isLowEndDevice) { | 3220 void Internals::setIsLowEndDevice(bool isLowEndDevice) { |
3182 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); | 3221 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); |
3183 } | 3222 } |
3184 | 3223 |
3185 } // namespace blink | 3224 } // namespace blink |
OLD | NEW |