| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 EXPECT_EQ(3, textControl().selectionEnd()); | 108 EXPECT_EQ(3, textControl().selectionEnd()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 TEST_F(HTMLTextFormControlElementTest, SetSelectionRangeDoesNotCauseLayout) | 111 TEST_F(HTMLTextFormControlElementTest, SetSelectionRangeDoesNotCauseLayout) |
| 112 { | 112 { |
| 113 input().focus(); | 113 input().focus(); |
| 114 input().setValue("Hello, input form."); | 114 input().setValue("Hello, input form."); |
| 115 input().setSelectionRange(1, 1); | 115 input().setSelectionRange(1, 1); |
| 116 FrameSelection& frameSelection = document().frame()->selection(); | 116 FrameSelection& frameSelection = document().frame()->selection(); |
| 117 forceLayoutFlag(); | 117 forceLayoutFlag(); |
| 118 LayoutRect oldCaretRect = frameSelection.absoluteCaretBounds(); | 118 LayoutRect oldCaretRect(frameSelection.absoluteCaretBounds()); |
| 119 EXPECT_FALSE(oldCaretRect.isEmpty()); | 119 EXPECT_FALSE(oldCaretRect.isEmpty()); |
| 120 int startLayoutCount = layoutCount(); | 120 int startLayoutCount = layoutCount(); |
| 121 input().setSelectionRange(1, 1); | 121 input().setSelectionRange(1, 1); |
| 122 EXPECT_EQ(startLayoutCount, layoutCount()); | 122 EXPECT_EQ(startLayoutCount, layoutCount()); |
| 123 LayoutRect newCaretRect = frameSelection.absoluteCaretBounds(); | 123 LayoutRect newCaretRect(frameSelection.absoluteCaretBounds()); |
| 124 EXPECT_EQ(oldCaretRect, newCaretRect); | 124 EXPECT_EQ(oldCaretRect, newCaretRect); |
| 125 | 125 |
| 126 forceLayoutFlag(); | 126 forceLayoutFlag(); |
| 127 oldCaretRect = frameSelection.absoluteCaretBounds(); | 127 oldCaretRect = LayoutRect(frameSelection.absoluteCaretBounds()); |
| 128 EXPECT_FALSE(oldCaretRect.isEmpty()); | 128 EXPECT_FALSE(oldCaretRect.isEmpty()); |
| 129 startLayoutCount = layoutCount(); | 129 startLayoutCount = layoutCount(); |
| 130 input().setSelectionRange(2, 2); | 130 input().setSelectionRange(2, 2); |
| 131 EXPECT_EQ(startLayoutCount, layoutCount()); | 131 EXPECT_EQ(startLayoutCount, layoutCount()); |
| 132 newCaretRect = frameSelection.absoluteCaretBounds(); | 132 newCaretRect = LayoutRect(frameSelection.absoluteCaretBounds()); |
| 133 EXPECT_NE(oldCaretRect, newCaretRect); | 133 EXPECT_NE(oldCaretRect, newCaretRect); |
| 134 } | 134 } |
| 135 | 135 |
| 136 typedef Position (*PositionFunction)(const Position&); | 136 typedef Position (*PositionFunction)(const Position&); |
| 137 typedef VisiblePosition(*VisblePositionFunction)(const VisiblePosition&); | 137 typedef VisiblePosition(*VisblePositionFunction)(const VisiblePosition&); |
| 138 | 138 |
| 139 void testFunctionEquivalence(const Position& position, PositionFunction position
Function, VisblePositionFunction visibleFunction) | 139 void testFunctionEquivalence(const Position& position, PositionFunction position
Function, VisblePositionFunction visibleFunction) |
| 140 { | 140 { |
| 141 VisiblePosition visiblePosition(position); | 141 VisiblePosition visiblePosition(position); |
| 142 VisiblePosition expected = visibleFunction(visiblePosition); | 142 VisiblePosition expected = visibleFunction(visiblePosition); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 ASSERT_EQ(3, input->selectionStart()); | 219 ASSERT_EQ(3, input->selectionStart()); |
| 220 | 220 |
| 221 OwnPtrWillBePersistent<SpellChecker> spellChecker(SpellChecker::create(page(
).frame())); | 221 OwnPtrWillBePersistent<SpellChecker> spellChecker(SpellChecker::create(page(
).frame())); |
| 222 forceLayoutFlag(); | 222 forceLayoutFlag(); |
| 223 int startCount = layoutCount(); | 223 int startCount = layoutCount(); |
| 224 spellChecker->respondToChangedSelection(oldSelection, FrameSelection::CloseT
yping | FrameSelection::ClearTypingStyle); | 224 spellChecker->respondToChangedSelection(oldSelection, FrameSelection::CloseT
yping | FrameSelection::ClearTypingStyle); |
| 225 EXPECT_EQ(startCount, layoutCount()); | 225 EXPECT_EQ(startCount, layoutCount()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } | 228 } |
| OLD | NEW |