| 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 | 6 |
| 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "wtf/StdLibExtras.h" | 21 #include "wtf/StdLibExtras.h" |
| 22 #include <gtest/gtest.h> | 22 #include <gtest/gtest.h> |
| 23 | 23 |
| 24 namespace blink { | 24 namespace blink { |
| 25 | 25 |
| 26 #define EXPECT_EQ_SELECTED_TEXT(text) \ | 26 #define EXPECT_EQ_SELECTED_TEXT(text) \ |
| 27 EXPECT_EQ(text, WebString(selection().selectedText()).utf8()) | 27 EXPECT_EQ(text, WebString(selection().selectedText()).utf8()) |
| 28 | 28 |
| 29 IntPoint visiblePositionToContentsPoint(const VisiblePosition& pos) | 29 IntPoint visiblePositionToContentsPoint(const VisiblePosition& pos) |
| 30 { | 30 { |
| 31 IntPoint result = pos.absoluteCaretBounds().minXMaxYCorner(); | 31 IntPoint result = absoluteCaretBoundsOf(pos).minXMaxYCorner(); |
| 32 // Need to move the point at least by 1 - caret's minXMaxYCorner is not | 32 // Need to move the point at least by 1 - caret's minXMaxYCorner is not |
| 33 // evaluated to the same line as the text by hit testing. | 33 // evaluated to the same line as the text by hit testing. |
| 34 result.move(0, -1); | 34 result.move(0, -1); |
| 35 return result; | 35 return result; |
| 36 } | 36 } |
| 37 | 37 |
| 38 class GranularityStrategyTest : public ::testing::Test { | 38 class GranularityStrategyTest : public ::testing::Test { |
| 39 protected: | 39 protected: |
| 40 void SetUp() override; | 40 void SetUp() override; |
| 41 | 41 |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 | 652 |
| 653 // "ab cd efghijkl ^mnopqr |>stuvwi inm," (^ means base and | means extent, | 653 // "ab cd efghijkl ^mnopqr |>stuvwi inm," (^ means base and | means extent, |
| 654 // > means end). | 654 // > means end). |
| 655 selection().setSelection(VisibleSelection(Position(text, 15), Position(text,
22))); | 655 selection().setSelection(VisibleSelection(Position(text, 15), Position(text,
22))); |
| 656 EXPECT_EQ_SELECTED_TEXT("mnopqr "); | 656 EXPECT_EQ_SELECTED_TEXT("mnopqr "); |
| 657 selection().moveRangeSelectionExtent(m_wordMiddles[4]); | 657 selection().moveRangeSelectionExtent(m_wordMiddles[4]); |
| 658 EXPECT_EQ_SELECTED_TEXT("mnopqr iiin"); | 658 EXPECT_EQ_SELECTED_TEXT("mnopqr iiin"); |
| 659 } | 659 } |
| 660 | 660 |
| 661 } // namespace blink | 661 } // namespace blink |
| OLD | NEW |