| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
| 30 #include "core/editing/InsertTextCommand.h" | 30 #include "core/editing/InsertTextCommand.h" |
| 31 #include "core/editing/SetSelectionCommand.h" | 31 #include "core/editing/SetSelectionCommand.h" |
| 32 #include "core/editing/TextIterator.h" | 32 #include "core/editing/TextIterator.h" |
| 33 #include "core/page/Frame.h" | 33 #include "core/page/Frame.h" |
| 34 | 34 |
| 35 namespace WebCore { | 35 namespace WebCore { |
| 36 | 36 |
| 37 SpellingCorrectionCommand::SpellingCorrectionCommand(PassRefPtr<Range> rangeToBe
Corrected, const String& correction) | 37 SpellingCorrectionCommand::SpellingCorrectionCommand(PassRefPtr<Range> rangeToBe
Corrected, const String& correction) |
| 38 : CompositeEditCommand(&rangeToBeCorrected->startContainer()->document()) | 38 : CompositeEditCommand(rangeToBeCorrected->startContainer()->document()) |
| 39 , m_rangeToBeCorrected(rangeToBeCorrected) | 39 , m_rangeToBeCorrected(rangeToBeCorrected) |
| 40 , m_selectionToBeCorrected(m_rangeToBeCorrected.get()) | 40 , m_selectionToBeCorrected(m_rangeToBeCorrected.get()) |
| 41 , m_correction(correction) | 41 , m_correction(correction) |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 void SpellingCorrectionCommand::doApply() | 45 void SpellingCorrectionCommand::doApply() |
| 46 { | 46 { |
| 47 m_corrected = plainText(m_rangeToBeCorrected.get()); | 47 m_corrected = plainText(m_rangeToBeCorrected.get()); |
| 48 if (!m_corrected.length()) | 48 if (!m_corrected.length()) |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 if (!document()->frame()->selection()->shouldChangeSelection(m_selectionToBe
Corrected)) | 51 if (!document().frame()->selection()->shouldChangeSelection(m_selectionToBeC
orrected)) |
| 52 return; | 52 return; |
| 53 | 53 |
| 54 applyCommandToComposite(SetSelectionCommand::create(m_selectionToBeCorrected
, FrameSelection::SpellCorrectionTriggered | FrameSelection::CloseTyping | Frame
Selection::ClearTypingStyle)); | 54 applyCommandToComposite(SetSelectionCommand::create(m_selectionToBeCorrected
, FrameSelection::SpellCorrectionTriggered | FrameSelection::CloseTyping | Frame
Selection::ClearTypingStyle)); |
| 55 applyCommandToComposite(InsertTextCommand::create(document(), m_correction))
; | 55 applyCommandToComposite(InsertTextCommand::create(document(), m_correction))
; |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool SpellingCorrectionCommand::shouldRetainAutocorrectionIndicator() const | 58 bool SpellingCorrectionCommand::shouldRetainAutocorrectionIndicator() const |
| 59 { | 59 { |
| 60 return true; | 60 return true; |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace WebCore | 63 } // namespace WebCore |
| OLD | NEW |