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().AddSpellingMarker( | 308 GetFrame().GetDocument()->Markers().AddSpellingMarker(misspelling_range); |
309 misspelling_range.StartPosition(), misspelling_range.EndPosition()); | |
310 } | 309 } |
311 } | 310 } |
312 | 311 |
313 void SpellChecker::ShowSpellingGuessPanel() { | 312 void SpellChecker::ShowSpellingGuessPanel() { |
314 if (GetSpellCheckerClient().SpellingUIIsShowing()) { | 313 if (GetSpellCheckerClient().SpellingUIIsShowing()) { |
315 GetSpellCheckerClient().ShowSpellingUI(false); | 314 GetSpellCheckerClient().ShowSpellingUI(false); |
316 return; | 315 return; |
317 } | 316 } |
318 | 317 |
319 AdvanceToNextMisspelling(true); | 318 AdvanceToNextMisspelling(true); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 return; | 549 return; |
551 | 550 |
552 String description; | 551 String description; |
553 for (size_t i = 0; i < descriptions.size(); ++i) { | 552 for (size_t i = 0; i < descriptions.size(); ++i) { |
554 if (i != 0) | 553 if (i != 0) |
555 description.append('\n'); | 554 description.append('\n'); |
556 description.append(descriptions[i]); | 555 description.append(descriptions[i]); |
557 } | 556 } |
558 | 557 |
559 if (type == DocumentMarker::kSpelling) { | 558 if (type == DocumentMarker::kSpelling) { |
560 document->Markers().AddSpellingMarker(range_to_mark.StartPosition(), | 559 document->Markers().AddSpellingMarker(range_to_mark, description); |
561 range_to_mark.EndPosition(), | |
562 description); | |
563 return; | 560 return; |
564 } | 561 } |
565 | 562 |
566 DCHECK_EQ(type, DocumentMarker::kGrammar); | 563 DCHECK_EQ(type, DocumentMarker::kGrammar); |
567 document->Markers().AddGrammarMarker( | 564 document->Markers().AddGrammarMarker(range_to_mark, description); |
568 range_to_mark.StartPosition(), range_to_mark.EndPosition(), description); | |
569 } | 565 } |
570 | 566 |
571 void SpellChecker::MarkAndReplaceFor( | 567 void SpellChecker::MarkAndReplaceFor( |
572 SpellCheckRequest* request, | 568 SpellCheckRequest* request, |
573 const Vector<TextCheckingResult>& results) { | 569 const Vector<TextCheckingResult>& results) { |
574 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); | 570 TRACE_EVENT0("blink", "SpellChecker::markAndReplaceFor"); |
575 DCHECK(request); | 571 DCHECK(request); |
576 if (!GetFrame().Selection().IsAvailable()) { | 572 if (!GetFrame().Selection().IsAvailable()) { |
577 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. | 573 // "editing/spelling/spellcheck-async-remove-frame.html" reaches here. |
578 return; | 574 return; |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 if (!input.IsFocusedElementInDocument()) | 1233 if (!input.IsFocusedElementInDocument()) |
1238 return false; | 1234 return false; |
1239 } | 1235 } |
1240 } | 1236 } |
1241 HTMLElement* element = | 1237 HTMLElement* element = |
1242 Traversal<HTMLElement>::FirstAncestorOrSelf(*position.AnchorNode()); | 1238 Traversal<HTMLElement>::FirstAncestorOrSelf(*position.AnchorNode()); |
1243 return element && element->IsSpellCheckingEnabled(); | 1239 return element && element->IsSpellCheckingEnabled(); |
1244 } | 1240 } |
1245 | 1241 |
1246 } // namespace blink | 1242 } // namespace blink |
OLD | NEW |