| 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 "core/html/TextControlElement.h" | 5 #include "core/html/TextControlElement.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/Text.h" | 8 #include "core/dom/Text.h" |
| 9 #include "core/editing/FrameSelection.h" | 9 #include "core/editing/FrameSelection.h" |
| 10 #include "core/editing/Position.h" | 10 #include "core/editing/Position.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 TEST_F(TextControlElementTest, IndexForPosition) { | 203 TEST_F(TextControlElementTest, IndexForPosition) { |
| 204 HTMLInputElement* input = | 204 HTMLInputElement* input = |
| 205 toHTMLInputElement(document().getElementById("input")); | 205 toHTMLInputElement(document().getElementById("input")); |
| 206 input->setValue("Hello"); | 206 input->setValue("Hello"); |
| 207 HTMLElement* innerEditor = input->innerEditorElement(); | 207 HTMLElement* innerEditor = input->innerEditorElement(); |
| 208 EXPECT_EQ(5, TextControlElement::indexForPosition( | 208 EXPECT_EQ(5, TextControlElement::indexForPosition( |
| 209 innerEditor, | 209 innerEditor, |
| 210 Position(innerEditor, PositionAnchorType::AfterAnchor))); | 210 Position(innerEditor, PositionAnchorType::AfterAnchor))); |
| 211 } | 211 } |
| 212 | 212 |
| 213 TEST_F(TextControlElementTest, EnclosingTextControl) { |
| 214 textControl().setValue("foobar"); |
| 215 EXPECT_EQ(nullptr, enclosingTextControl(Position(&document(), 0))); |
| 216 EXPECT_EQ(nullptr, enclosingTextControl(Position(&textControl(), 0))); |
| 217 EXPECT_EQ(&textControl(), enclosingTextControl(Position( |
| 218 textControl().innerEditorElement(), 0))); |
| 219 EXPECT_EQ(&textControl(), |
| 220 enclosingTextControl( |
| 221 Position(textControl().innerEditorElement()->firstChild(), 0))); |
| 222 EXPECT_EQ(nullptr, |
| 223 enclosingTextControl(Position(textControl().innerEditorElement(), |
| 224 PositionAnchorType::BeforeAnchor))); |
| 225 } |
| 226 |
| 213 } // namespace blink | 227 } // namespace blink |
| OLD | NEW |