OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 // panel, and store a marker so we draw the red squiggle later. | 298 // panel, and store a marker so we draw the red squiggle later. |
299 | 299 |
300 const EphemeralRange misspelling_range = CalculateCharacterSubrange( | 300 const EphemeralRange misspelling_range = CalculateCharacterSubrange( |
301 EphemeralRange(spelling_search_start, spelling_search_end), | 301 EphemeralRange(spelling_search_start, spelling_search_end), |
302 misspelling_offset, misspelled_word.length()); | 302 misspelling_offset, misspelled_word.length()); |
303 GetFrame().Selection().SetSelection(SelectionInDOMTree::Builder() | 303 GetFrame().Selection().SetSelection(SelectionInDOMTree::Builder() |
304 .SetBaseAndExtent(misspelling_range) | 304 .SetBaseAndExtent(misspelling_range) |
305 .Build()); | 305 .Build()); |
306 GetFrame().Selection().RevealSelection(); | 306 GetFrame().Selection().RevealSelection(); |
307 GetSpellCheckerClient().UpdateSpellingUIWithMisspelledWord(misspelled_word); | 307 GetSpellCheckerClient().UpdateSpellingUIWithMisspelledWord(misspelled_word); |
308 GetFrame().GetDocument()->Markers().AddMarker( | 308 GetFrame().GetDocument()->Markers().AddSpellingMarker( |
309 misspelling_range.StartPosition(), misspelling_range.EndPosition(), | 309 misspelling_range.StartPosition(), misspelling_range.EndPosition()); |
310 DocumentMarker::kSpelling); | |
311 } | 310 } |
312 } | 311 } |
313 | 312 |
314 void SpellChecker::ShowSpellingGuessPanel() { | 313 void SpellChecker::ShowSpellingGuessPanel() { |
315 if (GetSpellCheckerClient().SpellingUIIsShowing()) { | 314 if (GetSpellCheckerClient().SpellingUIIsShowing()) { |
316 GetSpellCheckerClient().ShowSpellingUI(false); | 315 GetSpellCheckerClient().ShowSpellingUI(false); |
317 return; | 316 return; |
318 } | 317 } |
319 | 318 |
320 AdvanceToNextMisspelling(true); | 319 AdvanceToNextMisspelling(true); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
532 } | 531 } |
533 } | 532 } |
534 } | 533 } |
535 | 534 |
536 static void AddMarker(Document* document, | 535 static void AddMarker(Document* document, |
537 const EphemeralRange& checking_range, | 536 const EphemeralRange& checking_range, |
538 DocumentMarker::MarkerType type, | 537 DocumentMarker::MarkerType type, |
539 int location, | 538 int location, |
540 int length, | 539 int length, |
541 const String& description) { | 540 const String& description) { |
541 DCHECK(type == DocumentMarker::kSpelling || type == DocumentMarker::kGrammar); | |
yosin_UTC9
2017/05/23 09:35:04
nit: s/);/) << type;/
| |
542 DCHECK_GT(length, 0); | 542 DCHECK_GT(length, 0); |
543 DCHECK_GE(location, 0); | 543 DCHECK_GE(location, 0); |
544 const EphemeralRange& range_to_mark = | 544 const EphemeralRange& range_to_mark = |
545 CalculateCharacterSubrange(checking_range, location, length); | 545 CalculateCharacterSubrange(checking_range, location, length); |
546 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.StartPosition())) | 546 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.StartPosition())) |
547 return; | 547 return; |
548 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.EndPosition())) | 548 if (!SpellChecker::IsSpellCheckingEnabledAt(range_to_mark.EndPosition())) |
549 return; | 549 return; |
550 document->Markers().AddMarker(range_to_mark.StartPosition(), | 550 |
551 range_to_mark.EndPosition(), type, description); | 551 if (type == DocumentMarker::kSpelling) { |
552 document->Markers().AddSpellingMarker(range_to_mark.StartPosition(), | |
553 range_to_mark.EndPosition(), | |
554 description); | |
yosin_UTC9
2017/05/23 09:35:04
Please add |return| for early-return style.
| |
555 } else { | |
556 document->Markers().AddGrammarMarker(range_to_mark.StartPosition(), | |
yosin_UTC9
2017/05/23 09:35:04
Please add DCHECK_EQ(type, DM::kGrammar);
| |
557 range_to_mark.EndPosition(), | |
558 description); | |
559 } | |
552 } | 560 } |
553 | 561 |
554 void SpellChecker::MarkAndReplaceFor( | 562 void SpellChecker::MarkAndReplaceFor( |
555 SpellCheckRequest* request, | 563 SpellCheckRequest* request, |
556 const Vector<TextCheckingResult>& results) { | 564 const Vector<TextCheckingResult>& results) { |
557 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); | 565 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); |
558 DCHECK(request); | 566 DCHECK(request); |
559 if (!GetFrame().Selection().IsAvailable()) { | 567 if (!GetFrame().Selection().IsAvailable()) { |
560 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. | 568 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. |
561 return; | 569 return; |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 if (!input.IsFocusedElementInDocument()) | 1228 if (!input.IsFocusedElementInDocument()) |
1221 return false; | 1229 return false; |
1222 } | 1230 } |
1223 } | 1231 } |
1224 HTMLElement* element = | 1232 HTMLElement* element = |
1225 Traversal<HTMLElement>::FirstAncestorOrSelf(*position.AnchorNode()); | 1233 Traversal<HTMLElement>::FirstAncestorOrSelf(*position.AnchorNode()); |
1226 return element && element->IsSpellCheckingEnabled(); | 1234 return element && element->IsSpellCheckingEnabled(); |
1227 } | 1235 } |
1228 | 1236 |
1229 } // namespace blink | 1237 } // namespace blink |
OLD | NEW |