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

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

Issue 2457523003: Support 'insertReplacementText' for spellcheck (Closed)
Patch Set: fix for chongz's nit 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 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 1784
1785 HeapVector<Member<Node>> matches; 1785 HeapVector<Member<Node>> matches;
1786 HitTestResult result(request, point, topPadding, rightPadding, bottomPadding, 1786 HitTestResult result(request, point, topPadding, rightPadding, bottomPadding,
1787 leftPadding); 1787 leftPadding);
1788 layoutViewItem.hitTest(result); 1788 layoutViewItem.hitTest(result);
1789 copyToVector(result.listBasedTestResult(), matches); 1789 copyToVector(result.listBasedTestResult(), matches);
1790 1790
1791 return StaticNodeList::adopt(matches); 1791 return StaticNodeList::adopt(matches);
1792 } 1792 }
1793 1793
1794 void Internals::setSpellingMarker(Document* document) {
1795 DCHECK(document);
yosin_UTC9 2016/10/28 04:06:14 Please throw an exception rather than DCHECK(). Cl
1796 DCHECK(document->frame());
1797
Xiaocheng 2016/10/28 02:55:24 Please call |document->updateStyleAndLayoutIgnoreP
1798 EphemeralRange range =
1799 document->frame()->selection().selection().toNormalizedEphemeralRange();
1800 document->markers().addMarker(range.startPosition(), range.endPosition(),
1801 DocumentMarker::Spelling);
1802 document->updateStyleAndLayoutIgnorePendingStylesheets();
Xiaocheng 2016/10/28 02:55:24 I don't think we should update layout here.
1803 }
1804
1794 bool Internals::hasSpellingMarker(Document* document, int from, int length) { 1805 bool Internals::hasSpellingMarker(Document* document, int from, int length) {
1795 ASSERT(document); 1806 ASSERT(document);
1796 if (!document->frame()) 1807 if (!document->frame())
1797 return false; 1808 return false;
1798 1809
1799 document->updateStyleAndLayoutIgnorePendingStylesheets(); 1810 document->updateStyleAndLayoutIgnorePendingStylesheets();
1800 return document->frame()->spellChecker().selectionStartHasMarkerFor( 1811 return document->frame()->spellChecker().selectionStartHasMarkerFor(
1801 DocumentMarker::Spelling, from, length); 1812 DocumentMarker::Spelling, from, length);
1802 } 1813 }
1803 1814
1804 void Internals::setSpellCheckingEnabled(bool enabled) { 1815 void Internals::setSpellCheckingEnabled(bool enabled) {
1805 if (!contextDocument() || !contextDocument()->frame()) 1816 if (!contextDocument() || !contextDocument()->frame())
1806 return; 1817 return;
1807 1818
1808 if (enabled != 1819 if (enabled !=
1809 contextDocument()->frame()->spellChecker().isSpellCheckingEnabled()) 1820 contextDocument()->frame()->spellChecker().isSpellCheckingEnabled())
1810 contextDocument()->frame()->spellChecker().toggleSpellCheckingEnabled(); 1821 contextDocument()->frame()->spellChecker().toggleSpellCheckingEnabled();
1811 } 1822 }
1812 1823
1824 void Internals::replaceMisspelled(Document* document,
1825 const String& replacement) {
1826 DCHECK(document);
yosin_UTC9 2016/10/28 04:06:14 Please throw an exception rather than DCHECK(). Cl
1827 DCHECK(document->frame());
1828
Xiaocheng 2016/10/28 02:55:23 Please call document->updateStyleAndLayoutIgnorePe
1829 document->frame()->spellChecker().replaceMisspelledRange(replacement);
1830 }
1831
1813 bool Internals::canHyphenate(const AtomicString& locale) { 1832 bool Internals::canHyphenate(const AtomicString& locale) {
1814 return LayoutLocale::valueOrDefault(LayoutLocale::get(locale)) 1833 return LayoutLocale::valueOrDefault(LayoutLocale::get(locale))
1815 .getHyphenation(); 1834 .getHyphenation();
1816 } 1835 }
1817 1836
1818 void Internals::setMockHyphenation(const AtomicString& locale) { 1837 void Internals::setMockHyphenation(const AtomicString& locale) {
1819 LayoutLocale::setHyphenationForTesting(locale, adoptRef(new MockHyphenation)); 1838 LayoutLocale::setHyphenationForTesting(locale, adoptRef(new MockHyphenation));
1820 } 1839 }
1821 1840
1822 bool Internals::isOverwriteModeEnabled(Document* document) { 1841 bool Internals::isOverwriteModeEnabled(Document* document) {
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
3009 return ClientRect::create(); 3028 return ClientRect::create();
3010 3029
3011 return ClientRect::create(FloatRect(node->layoutObject()->visualRect())); 3030 return ClientRect::create(FloatRect(node->layoutObject()->visualRect()));
3012 } 3031 }
3013 3032
3014 void Internals::crash() { 3033 void Internals::crash() {
3015 CHECK(false) << "Intentional crash"; 3034 CHECK(false) << "Intentional crash";
3016 } 3035 }
3017 3036
3018 } // namespace blink 3037 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698