| OLD | NEW | 
|    1 // Copyright 2016 The Chromium Authors. All rights reserved. |    1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "core/editing/spellcheck/SpellChecker.h" |    5 #include "core/editing/spellcheck/SpellChecker.h" | 
|    6  |    6  | 
|    7 #include "core/editing/Editor.h" |    7 #include "core/editing/Editor.h" | 
|    8 #include "core/editing/spellcheck/SpellCheckTestBase.h" |    8 #include "core/editing/spellcheck/SpellCheckTestBase.h" | 
|    9 #include "core/frame/LocalFrame.h" |    9 #include "core/frame/LocalFrame.h" | 
|   10 #include "core/frame/LocalFrameView.h" |   10 #include "core/frame/LocalFrameView.h" | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   48       "</td></tr></table>" |   48       "</td></tr></table>" | 
|   49       "zz zz zz" |   49       "zz zz zz" | 
|   50       "</div>"); |   50       "</div>"); | 
|   51   GetDocument().QuerySelector("div")->focus(); |   51   GetDocument().QuerySelector("div")->focus(); | 
|   52   UpdateAllLifecyclePhases(); |   52   UpdateAllLifecyclePhases(); | 
|   53  |   53  | 
|   54   // Do not crash in advanceToNextMisspelling. |   54   // Do not crash in advanceToNextMisspelling. | 
|   55   GetDocument().GetFrame()->GetSpellChecker().AdvanceToNextMisspelling(false); |   55   GetDocument().GetFrame()->GetSpellChecker().AdvanceToNextMisspelling(false); | 
|   56 } |   56 } | 
|   57  |   57  | 
 |   58 // Regression test for crbug.com/728801 | 
 |   59 TEST_F(SpellCheckerTest, AdvancedToNextMisspellingWrapSearchNoCrash) { | 
 |   60   SetBodyContent("<div contenteditable>  zz zz zz  </div>"); | 
 |   61  | 
 |   62   Element* div = GetDocument().QuerySelector("div"); | 
 |   63   div->focus(); | 
 |   64   Selection().SetSelection(SelectionInDOMTree::Builder() | 
 |   65                                .Collapse(Position::LastPositionInNode(div)) | 
 |   66                                .Build()); | 
 |   67   UpdateAllLifecyclePhases(); | 
 |   68  | 
 |   69   // TODO(xiaochengh): We should have SpellCheckTestBase::GetSpellChecker(). | 
 |   70   GetFrame().GetSpellChecker().AdvanceToNextMisspelling(false); | 
 |   71 } | 
 |   72  | 
|   58 TEST_F(SpellCheckerTest, SpellCheckDoesNotCauseUpdateLayout) { |   73 TEST_F(SpellCheckerTest, SpellCheckDoesNotCauseUpdateLayout) { | 
|   59   SetBodyContent("<input>"); |   74   SetBodyContent("<input>"); | 
|   60   HTMLInputElement* input = |   75   HTMLInputElement* input = | 
|   61       toHTMLInputElement(GetDocument().QuerySelector("input")); |   76       toHTMLInputElement(GetDocument().QuerySelector("input")); | 
|   62   input->focus(); |   77   input->focus(); | 
|   63   input->setValue("Hello, input field"); |   78   input->setValue("Hello, input field"); | 
|   64   GetDocument().UpdateStyleAndLayout(); |   79   GetDocument().UpdateStyleAndLayout(); | 
|   65   VisibleSelection old_selection = |   80   VisibleSelection old_selection = | 
|   66       GetDocument() |   81       GetDocument() | 
|   67           .GetFrame() |   82           .GetFrame() | 
|   68           ->Selection() |   83           ->Selection() | 
|   69           .ComputeVisibleSelectionInDOMTreeDeprecated(); |   84           .ComputeVisibleSelectionInDOMTreeDeprecated(); | 
|   70  |   85  | 
|   71   Position new_position(input->InnerEditorElement()->firstChild(), 3); |   86   Position new_position(input->InnerEditorElement()->firstChild(), 3); | 
|   72   GetDocument().GetFrame()->Selection().SetSelection( |   87   GetDocument().GetFrame()->Selection().SetSelection( | 
|   73       SelectionInDOMTree::Builder().Collapse(new_position).Build()); |   88       SelectionInDOMTree::Builder().Collapse(new_position).Build()); | 
|   74   ASSERT_EQ(3u, input->selectionStart()); |   89   ASSERT_EQ(3u, input->selectionStart()); | 
|   75  |   90  | 
|   76   EXPECT_TRUE(GetFrame().GetSpellChecker().IsSpellCheckingEnabled()); |   91   EXPECT_TRUE(GetFrame().GetSpellChecker().IsSpellCheckingEnabled()); | 
|   77   ForceLayout(); |   92   ForceLayout(); | 
|   78   int start_count = LayoutCount(); |   93   int start_count = LayoutCount(); | 
|   79   GetFrame().GetSpellChecker().RespondToChangedSelection( |   94   GetFrame().GetSpellChecker().RespondToChangedSelection( | 
|   80       old_selection.Start(), |   95       old_selection.Start(), | 
|   81       FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle); |   96       FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle); | 
|   82   EXPECT_EQ(start_count, LayoutCount()); |   97   EXPECT_EQ(start_count, LayoutCount()); | 
|   83 } |   98 } | 
|   84  |   99  | 
|   85 }  // namespace blink |  100 }  // namespace blink | 
| OLD | NEW |