Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: Source/core/editing/GranularityStrategyTest.cpp

Issue 1308323004: Introduce absoluteCaretBoundsOf() for VisiblePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-28T19:12:35 Rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/editing/GranularityStrategy.cpp ('k') | Source/core/editing/VisiblePosition.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/core/editing/GranularityStrategy.cpp ('k') | Source/core/editing/VisiblePosition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698