| OLD | NEW | 
|    1 // Copyright 2014 The Chromium Authors. All rights reserved. |    1 // Copyright 2014 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 "config.h" |    5 #include "config.h" | 
|    6 #include "core/html/HTMLTextFormControlElement.h" |    6 #include "core/html/HTMLTextFormControlElement.h" | 
|    7  |    7  | 
|    8 #include "core/dom/Position.h" |    8 #include "core/dom/Position.h" | 
|    9 #include "core/dom/Text.h" |    9 #include "core/dom/Text.h" | 
|   10 #include "core/editing/FrameSelection.h" |   10 #include "core/editing/FrameSelection.h" | 
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   87 { |   87 { | 
|   88     FrameView& frameView = page().frameView(); |   88     FrameView& frameView = page().frameView(); | 
|   89     IntRect frameRect = frameView.frameRect(); |   89     IntRect frameRect = frameView.frameRect(); | 
|   90     frameRect.setWidth(frameRect.width() + 1); |   90     frameRect.setWidth(frameRect.width() + 1); | 
|   91     frameRect.setHeight(frameRect.height() + 1); |   91     frameRect.setHeight(frameRect.height() + 1); | 
|   92     page().frameView().setFrameRect(frameRect); |   92     page().frameView().setFrameRect(frameRect); | 
|   93 } |   93 } | 
|   94  |   94  | 
|   95 TEST_F(HTMLTextFormControlElementTest, SetSelectionRange) |   95 TEST_F(HTMLTextFormControlElementTest, SetSelectionRange) | 
|   96 { |   96 { | 
|   97     EXPECT_EQ(0, textControl().selectionStart()); |   97     EXPECT_EQ(0u, textControl().selectionStart()); | 
|   98     EXPECT_EQ(0, textControl().selectionEnd()); |   98     EXPECT_EQ(0u, textControl().selectionEnd()); | 
|   99  |   99  | 
|  100     textControl().setInnerEditorValue("Hello, text form."); |  100     textControl().setInnerEditorValue("Hello, text form."); | 
|  101     EXPECT_EQ(0, textControl().selectionStart()); |  101     EXPECT_EQ(0u, textControl().selectionStart()); | 
|  102     EXPECT_EQ(0, textControl().selectionEnd()); |  102     EXPECT_EQ(0u, textControl().selectionEnd()); | 
|  103  |  103  | 
|  104     textControl().setSelectionRange(1, 3); |  104     textControl().setSelectionRange(1, 3); | 
|  105     EXPECT_EQ(1, textControl().selectionStart()); |  105     EXPECT_EQ(1u, textControl().selectionStart()); | 
|  106     EXPECT_EQ(3, textControl().selectionEnd()); |  106     EXPECT_EQ(3u, textControl().selectionEnd()); | 
|  107 } |  107 } | 
|  108  |  108  | 
|  109 TEST_F(HTMLTextFormControlElementTest, SetSelectionRangeDoesNotCauseLayout) |  109 TEST_F(HTMLTextFormControlElementTest, SetSelectionRangeDoesNotCauseLayout) | 
|  110 { |  110 { | 
|  111     input().focus(); |  111     input().focus(); | 
|  112     input().setValue("Hello, input form."); |  112     input().setValue("Hello, input form."); | 
|  113     input().setSelectionRange(1, 1); |  113     input().setSelectionRange(1, 1); | 
|  114     FrameSelection& frameSelection = document().frame()->selection(); |  114     FrameSelection& frameSelection = document().frame()->selection(); | 
|  115     forceLayoutFlag(); |  115     forceLayoutFlag(); | 
|  116     LayoutRect oldCaretRect(frameSelection.absoluteCaretBounds()); |  116     LayoutRect oldCaretRect(frameSelection.absoluteCaretBounds()); | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  207 TEST_F(HTMLTextFormControlElementTest, SpellCheckDoesNotCauseUpdateLayout) |  207 TEST_F(HTMLTextFormControlElementTest, SpellCheckDoesNotCauseUpdateLayout) | 
|  208 { |  208 { | 
|  209     HTMLInputElement* input = toHTMLInputElement(document().getElementById("inpu
     t")); |  209     HTMLInputElement* input = toHTMLInputElement(document().getElementById("inpu
     t")); | 
|  210     input->focus(); |  210     input->focus(); | 
|  211     input->setValue("Hello, input field"); |  211     input->setValue("Hello, input field"); | 
|  212     VisibleSelection oldSelection = document().frame()->selection().selection(); |  212     VisibleSelection oldSelection = document().frame()->selection().selection(); | 
|  213  |  213  | 
|  214     Position newPosition(input->innerEditorElement()->firstChild(), 3); |  214     Position newPosition(input->innerEditorElement()->firstChild(), 3); | 
|  215     VisibleSelection newSelection(newPosition, DOWNSTREAM); |  215     VisibleSelection newSelection(newPosition, DOWNSTREAM); | 
|  216     document().frame()->selection().setSelection(newSelection, FrameSelection::C
     loseTyping | FrameSelection::ClearTypingStyle | FrameSelection::DoNotUpdateAppea
     rance); |  216     document().frame()->selection().setSelection(newSelection, FrameSelection::C
     loseTyping | FrameSelection::ClearTypingStyle | FrameSelection::DoNotUpdateAppea
     rance); | 
|  217     ASSERT_EQ(3, input->selectionStart()); |  217     ASSERT_EQ(3u, input->selectionStart()); | 
|  218  |  218  | 
|  219     OwnPtrWillBePersistent<SpellChecker> spellChecker(SpellChecker::create(page(
     ).frame())); |  219     OwnPtrWillBePersistent<SpellChecker> spellChecker(SpellChecker::create(page(
     ).frame())); | 
|  220     forceLayoutFlag(); |  220     forceLayoutFlag(); | 
|  221     int startCount = layoutCount(); |  221     int startCount = layoutCount(); | 
|  222     spellChecker->respondToChangedSelection(oldSelection, FrameSelection::CloseT
     yping | FrameSelection::ClearTypingStyle); |  222     spellChecker->respondToChangedSelection(oldSelection, FrameSelection::CloseT
     yping | FrameSelection::ClearTypingStyle); | 
|  223     EXPECT_EQ(startCount, layoutCount()); |  223     EXPECT_EQ(startCount, layoutCount()); | 
|  224 } |  224 } | 
|  225  |  225  | 
|  226 } // namespace blink |  226 } // namespace blink | 
| OLD | NEW |