| 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 "bindings/core/v8/ExceptionStatePlaceholder.h" | 5 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 6 #include "core/dom/Document.h" | 6 #include "core/dom/Document.h" |
| 7 #include "core/dom/Element.h" | 7 #include "core/dom/Element.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/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 void GranularityStrategyTest::parseText(const TextNodeVector& textNodes) | 120 void GranularityStrategyTest::parseText(const TextNodeVector& textNodes) |
| 121 { | 121 { |
| 122 bool wordStarted = false; | 122 bool wordStarted = false; |
| 123 int wordStartIndex = 0; | 123 int wordStartIndex = 0; |
| 124 for (auto& text : textNodes) { | 124 for (auto& text : textNodes) { |
| 125 int wordStartIndexOffset = m_letterPos.size(); | 125 int wordStartIndexOffset = m_letterPos.size(); |
| 126 String str = text->wholeText(); | 126 String str = text->wholeText(); |
| 127 for (size_t i = 0; i < str.length(); i++) { | 127 for (size_t i = 0; i < str.length(); i++) { |
| 128 m_letterPos.append(visiblePositionToContentsPoint(createVisiblePosit
ion(Position(text, i)))); | 128 m_letterPos.append(visiblePositionToContentsPoint(createVisiblePosit
ion(Position(text, i)))); |
| 129 char c = str.characterAt(i); | 129 char c = str[i]; |
| 130 if (isASCIIAlphanumeric(c) && !wordStarted) { | 130 if (isASCIIAlphanumeric(c) && !wordStarted) { |
| 131 wordStartIndex = i + wordStartIndexOffset; | 131 wordStartIndex = i + wordStartIndexOffset; |
| 132 wordStarted = true; | 132 wordStarted = true; |
| 133 } else if (!isASCIIAlphanumeric(c) && wordStarted) { | 133 } else if (!isASCIIAlphanumeric(c) && wordStarted) { |
| 134 IntPoint wordMiddle((m_letterPos[wordStartIndex].x() + m_letterP
os[i + wordStartIndexOffset].x()) / 2, m_letterPos[wordStartIndex].y()); | 134 IntPoint wordMiddle((m_letterPos[wordStartIndex].x() + m_letterP
os[i + wordStartIndexOffset].x()) / 2, m_letterPos[wordStartIndex].y()); |
| 135 m_wordMiddles.append(wordMiddle); | 135 m_wordMiddles.append(wordMiddle); |
| 136 wordStarted = false; | 136 wordStarted = false; |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 } | 139 } |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 653 |
| 654 // "ab cd efghijkl ^mnopqr |>stuvwi inm," (^ means base and | means extent, | 654 // "ab cd efghijkl ^mnopqr |>stuvwi inm," (^ means base and | means extent, |
| 655 // > means end). | 655 // > means end). |
| 656 selection().setSelection(VisibleSelection(Position(text, 15), Position(text,
22))); | 656 selection().setSelection(VisibleSelection(Position(text, 15), Position(text,
22))); |
| 657 EXPECT_EQ_SELECTED_TEXT("mnopqr "); | 657 EXPECT_EQ_SELECTED_TEXT("mnopqr "); |
| 658 selection().moveRangeSelectionExtent(m_wordMiddles[4]); | 658 selection().moveRangeSelectionExtent(m_wordMiddles[4]); |
| 659 EXPECT_EQ_SELECTED_TEXT("mnopqr iiin"); | 659 EXPECT_EQ_SELECTED_TEXT("mnopqr iiin"); |
| 660 } | 660 } |
| 661 | 661 |
| 662 } // namespace blink | 662 } // namespace blink |
| OLD | NEW |