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

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

Issue 2457523003: Support 'insertReplacementText' for spellcheck (Closed)
Patch Set: dtapuska's comment addressed Created 4 years, 1 month 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 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 1788
1789 HeapVector<Member<Node>> matches; 1789 HeapVector<Member<Node>> matches;
1790 HitTestResult result(request, point, topPadding, rightPadding, bottomPadding, 1790 HitTestResult result(request, point, topPadding, rightPadding, bottomPadding,
1791 leftPadding); 1791 leftPadding);
1792 layoutViewItem.hitTest(result); 1792 layoutViewItem.hitTest(result);
1793 copyToVector(result.listBasedTestResult(), matches); 1793 copyToVector(result.listBasedTestResult(), matches);
1794 1794
1795 return StaticNodeList::adopt(matches); 1795 return StaticNodeList::adopt(matches);
1796 } 1796 }
1797 1797
1798 bool Internals::hasSpellingMarker(Document* document, int from, int length) { 1798 void Internals::setSpellingMarker(Document* document,
yosin_UTC9 2016/11/10 01:49:52 It is better that |setSepllingMarker| to take |Ran
Xiaocheng 2016/11/10 02:35:53 Agreed. In fact, that would help us a lot by simpl
yosin_UTC9 2016/11/10 03:25:46 As usual, it is better to have another patch conta
1799 ASSERT(document); 1799 ExceptionState& exceptionState) {
1800 if (!document->frame()) 1800 if (!document || !document->frame()) {
1801 exceptionState.throwDOMException(
1802 InvalidAccessError,
1803 "No frame can be obtained from the provided document.");
1804 return;
1805 }
1806
1807 document->updateStyleAndLayoutIgnorePendingStylesheets();
1808 EphemeralRange range =
1809 document->frame()->selection().selection().toNormalizedEphemeralRange();
1810 document->markers().addMarker(range.startPosition(), range.endPosition(),
1811 DocumentMarker::Spelling);
1812 }
1813
1814 bool Internals::hasSpellingMarker(Document* document,
1815 int from,
1816 int length,
1817 ExceptionState& exceptionState) {
1818 if (!document || !document->frame()) {
1819 exceptionState.throwDOMException(
1820 InvalidAccessError,
1821 "No frame can be obtained from the provided document.");
1801 return false; 1822 return false;
1823 }
1802 1824
1803 document->updateStyleAndLayoutIgnorePendingStylesheets(); 1825 document->updateStyleAndLayoutIgnorePendingStylesheets();
1804 return document->frame()->spellChecker().selectionStartHasMarkerFor( 1826 return document->frame()->spellChecker().selectionStartHasMarkerFor(
1805 DocumentMarker::Spelling, from, length); 1827 DocumentMarker::Spelling, from, length);
1806 } 1828 }
1807 1829
1808 void Internals::setSpellCheckingEnabled(bool enabled) { 1830 void Internals::setSpellCheckingEnabled(bool enabled,
1809 if (!contextDocument() || !contextDocument()->frame()) 1831 ExceptionState& exceptionState) {
1832 if (!contextDocument() || !contextDocument()->frame()) {
1833 exceptionState.throwDOMException(
1834 InvalidAccessError,
1835 "No frame can be obtained from the provided document.");
1810 return; 1836 return;
1837 }
1811 1838
1812 if (enabled != 1839 if (enabled !=
1813 contextDocument()->frame()->spellChecker().isSpellCheckingEnabled()) 1840 contextDocument()->frame()->spellChecker().isSpellCheckingEnabled())
1814 contextDocument()->frame()->spellChecker().toggleSpellCheckingEnabled(); 1841 contextDocument()->frame()->spellChecker().toggleSpellCheckingEnabled();
1815 } 1842 }
1816 1843
1844 void Internals::replaceMisspelled(Document* document,
1845 const String& replacement,
1846 ExceptionState& exceptionState) {
1847 if (!document || !document->frame()) {
1848 exceptionState.throwDOMException(
1849 InvalidAccessError,
1850 "No frame can be obtained from the provided document.");
1851 return;
1852 }
1853
1854 document->updateStyleAndLayoutIgnorePendingStylesheets();
1855 document->frame()->spellChecker().replaceMisspelledRange(replacement);
1856 }
1857
1817 bool Internals::canHyphenate(const AtomicString& locale) { 1858 bool Internals::canHyphenate(const AtomicString& locale) {
1818 return LayoutLocale::valueOrDefault(LayoutLocale::get(locale)) 1859 return LayoutLocale::valueOrDefault(LayoutLocale::get(locale))
1819 .getHyphenation(); 1860 .getHyphenation();
1820 } 1861 }
1821 1862
1822 void Internals::setMockHyphenation(const AtomicString& locale) { 1863 void Internals::setMockHyphenation(const AtomicString& locale) {
1823 LayoutLocale::setHyphenationForTesting(locale, adoptRef(new MockHyphenation)); 1864 LayoutLocale::setHyphenationForTesting(locale, adoptRef(new MockHyphenation));
1824 } 1865 }
1825 1866
1826 bool Internals::isOverwriteModeEnabled(Document* document) { 1867 bool Internals::isOverwriteModeEnabled(Document* document) {
(...skipping 17 matching lines...) Expand all
1844 } 1885 }
1845 1886
1846 unsigned Internals::numberOfLiveDocuments() const { 1887 unsigned Internals::numberOfLiveDocuments() const {
1847 return InstanceCounters::counterValue(InstanceCounters::DocumentCounter); 1888 return InstanceCounters::counterValue(InstanceCounters::DocumentCounter);
1848 } 1889 }
1849 1890
1850 String Internals::dumpRefCountedInstanceCounts() const { 1891 String Internals::dumpRefCountedInstanceCounts() const {
1851 return WTF::dumpRefCountedInstanceCounts(); 1892 return WTF::dumpRefCountedInstanceCounts();
1852 } 1893 }
1853 1894
1854 bool Internals::hasGrammarMarker(Document* document, int from, int length) { 1895 bool Internals::hasGrammarMarker(Document* document,
1855 ASSERT(document); 1896 int from,
1856 if (!document->frame()) 1897 int length,
1898 ExceptionState& exceptionState) {
1899 if (!document || !document->frame()) {
1900 exceptionState.throwDOMException(
1901 InvalidAccessError,
1902 "No frame can be obtained from the provided document.");
1857 return false; 1903 return false;
1904 }
1858 1905
1859 document->updateStyleAndLayoutIgnorePendingStylesheets(); 1906 document->updateStyleAndLayoutIgnorePendingStylesheets();
1860 return document->frame()->spellChecker().selectionStartHasMarkerFor( 1907 return document->frame()->spellChecker().selectionStartHasMarkerFor(
1861 DocumentMarker::Grammar, from, length); 1908 DocumentMarker::Grammar, from, length);
1862 } 1909 }
1863 1910
1864 unsigned Internals::numberOfScrollableAreas(Document* document) { 1911 unsigned Internals::numberOfScrollableAreas(Document* document) {
1865 ASSERT(document); 1912 ASSERT(document);
1866 if (!document->frame()) 1913 if (!document->frame())
1867 return 0; 1914 return 0;
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
3015 return ClientRect::create(); 3062 return ClientRect::create();
3016 3063
3017 return ClientRect::create(FloatRect(node->layoutObject()->visualRect())); 3064 return ClientRect::create(FloatRect(node->layoutObject()->visualRect()));
3018 } 3065 }
3019 3066
3020 void Internals::crash() { 3067 void Internals::crash() {
3021 CHECK(false) << "Intentional crash"; 3068 CHECK(false) << "Intentional crash";
3022 } 3069 }
3023 3070
3024 } // namespace blink 3071 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698