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/dom/Range.h" | 5 #include "core/dom/Range.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/V8BindingForTesting.h" | 8 #include "bindings/core/v8/V8BindingForTesting.h" |
9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
10 #include "core/dom/NodeList.h" | 10 #include "core/dom/NodeList.h" |
11 #include "core/dom/Text.h" | 11 #include "core/dom/Text.h" |
12 #include "core/editing/EditingTestBase.h" | 12 #include "core/editing/EditingTestBase.h" |
| 13 #include "core/editing/VisibleUnits.h" |
13 #include "core/frame/Settings.h" | 14 #include "core/frame/Settings.h" |
14 #include "core/html/HTMLBodyElement.h" | 15 #include "core/html/HTMLBodyElement.h" |
15 #include "core/html/HTMLDivElement.h" | 16 #include "core/html/HTMLDivElement.h" |
16 #include "core/html/HTMLDocument.h" | 17 #include "core/html/HTMLDocument.h" |
17 #include "core/html/HTMLElement.h" | 18 #include "core/html/HTMLElement.h" |
18 #include "core/html/HTMLHtmlElement.h" | 19 #include "core/html/HTMLHtmlElement.h" |
19 #include "core/html/HTMLTextAreaElement.h" | 20 #include "core/html/HTMLTextAreaElement.h" |
20 #include "platform/heap/Handle.h" | 21 #include "platform/heap/Handle.h" |
21 #include "platform/wtf/Compiler.h" | 22 #include "platform/wtf/Compiler.h" |
22 #include "platform/wtf/RefPtr.h" | 23 #include "platform/wtf/RefPtr.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 range->setStart(div, 0, ASSERT_NO_EXCEPTION); | 244 range->setStart(div, 0, ASSERT_NO_EXCEPTION); |
244 range->expand("", ASSERT_NO_EXCEPTION); | 245 range->expand("", ASSERT_NO_EXCEPTION); |
245 } | 246 } |
246 | 247 |
247 TEST_F(RangeTest, MultipleTextQuads) { | 248 TEST_F(RangeTest, MultipleTextQuads) { |
248 SetBodyContent("<div><p id='one'>one</p><p id='two'>two</p></div>"); | 249 SetBodyContent("<div><p id='one'>one</p><p id='two'>two</p></div>"); |
249 Position start(GetDocument().getElementById("one")->firstChild(), 0); | 250 Position start(GetDocument().getElementById("one")->firstChild(), 0); |
250 Position end(GetDocument().getElementById("two")->firstChild(), 3); | 251 Position end(GetDocument().getElementById("two")->firstChild(), 3); |
251 Range* range = Range::Create(GetDocument(), start, end); | 252 Range* range = Range::Create(GetDocument(), start, end); |
252 Vector<FloatQuad> quads; | 253 Vector<FloatQuad> quads; |
253 range->TextQuads(quads); | 254 quads.AppendVector(ComputeTextQuads(EphemeralRange(range))); |
254 EXPECT_EQ(2u, quads.size()); | 255 EXPECT_EQ(2u, quads.size()); |
255 } | 256 } |
256 | 257 |
257 TEST_F(RangeTest, ToPosition) { | 258 TEST_F(RangeTest, ToPosition) { |
258 Node& textarea = *HTMLTextAreaElement::Create(GetDocument()); | 259 Node& textarea = *HTMLTextAreaElement::Create(GetDocument()); |
259 Range& range = *Range::Create(GetDocument()); | 260 Range& range = *Range::Create(GetDocument()); |
260 const Position position = Position(&textarea, 0); | 261 const Position position = Position(&textarea, 0); |
261 range.setStart(position, ASSERT_NO_EXCEPTION); | 262 range.setStart(position, ASSERT_NO_EXCEPTION); |
262 EXPECT_EQ(position, range.StartPosition()); | 263 EXPECT_EQ(position, range.StartPosition()); |
263 EXPECT_EQ(position, range.EndPosition()); | 264 EXPECT_EQ(position, range.EndPosition()); |
264 } | 265 } |
265 | 266 |
266 } // namespace blink | 267 } // namespace blink |
OLD | NEW |