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

Side by Side Diff: Source/core/editing/SpellingCorrectionCommand.cpp

Issue 23822003: Have EditCommand classes deal with Document references, not pointers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months 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 | Annotate | Revision Log
OLDNEW
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
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
OLDNEW
« no previous file with comments | « Source/core/editing/SimplifyMarkupCommand.cpp ('k') | Source/core/editing/SplitElementCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698