| 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/editing/FrameSelection.h" | 5 #include "core/editing/FrameSelection.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/dom/Text.h" | 10 #include "core/dom/Text.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 namespace blink { | 27 namespace blink { |
| 28 | 28 |
| 29 class FrameSelectionTest : public EditingTestBase { | 29 class FrameSelectionTest : public EditingTestBase { |
| 30 protected: | 30 protected: |
| 31 void setSelection(const VisibleSelection&); | 31 void setSelection(const VisibleSelection&); |
| 32 FrameSelection& selection() const; | 32 FrameSelection& selection() const; |
| 33 const VisibleSelection& visibleSelectionInDOMTree() const { return selection
().selection(); } | 33 const VisibleSelection& visibleSelectionInDOMTree() const { return selection
().selection(); } |
| 34 const VisibleSelectionInFlatTree& visibleSelectionInFlatTree() const { retur
n selection().selectionInFlatTree(); } | 34 const VisibleSelectionInFlatTree& visibleSelectionInFlatTree() const { retur
n selection().selectionInFlatTree(); } |
| 35 | 35 |
| 36 PassRefPtrWillBeRawPtr<Text> appendTextNode(const String& data); | 36 RawPtr<Text> appendTextNode(const String& data); |
| 37 int layoutCount() const { return dummyPageHolder().frameView().layoutCount()
; } | 37 int layoutCount() const { return dummyPageHolder().frameView().layoutCount()
; } |
| 38 | 38 |
| 39 bool shouldPaintCaretForTesting() const { return selection().shouldPaintCare
tForTesting(); } | 39 bool shouldPaintCaretForTesting() const { return selection().shouldPaintCare
tForTesting(); } |
| 40 bool isPreviousCaretDirtyForTesting() const { return selection().isPreviousC
aretDirtyForTesting(); } | 40 bool isPreviousCaretDirtyForTesting() const { return selection().isPreviousC
aretDirtyForTesting(); } |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 RefPtrWillBePersistent<Text> m_textNode; | 43 Persistent<Text> m_textNode; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 void FrameSelectionTest::setSelection(const VisibleSelection& newSelection) | 46 void FrameSelectionTest::setSelection(const VisibleSelection& newSelection) |
| 47 { | 47 { |
| 48 dummyPageHolder().frame().selection().setSelection(newSelection); | 48 dummyPageHolder().frame().selection().setSelection(newSelection); |
| 49 } | 49 } |
| 50 | 50 |
| 51 FrameSelection& FrameSelectionTest::selection() const | 51 FrameSelection& FrameSelectionTest::selection() const |
| 52 { | 52 { |
| 53 return dummyPageHolder().frame().selection(); | 53 return dummyPageHolder().frame().selection(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 PassRefPtrWillBeRawPtr<Text> FrameSelectionTest::appendTextNode(const String& da
ta) | 56 RawPtr<Text> FrameSelectionTest::appendTextNode(const String& data) |
| 57 { | 57 { |
| 58 RefPtrWillBeRawPtr<Text> text = document().createTextNode(data); | 58 RawPtr<Text> text = document().createTextNode(data); |
| 59 document().body()->appendChild(text); | 59 document().body()->appendChild(text); |
| 60 return text.release(); | 60 return text.release(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 TEST_F(FrameSelectionTest, SetValidSelection) | 63 TEST_F(FrameSelectionTest, SetValidSelection) |
| 64 { | 64 { |
| 65 RefPtrWillBeRawPtr<Text> text = appendTextNode("Hello, World!"); | 65 RawPtr<Text> text = appendTextNode("Hello, World!"); |
| 66 VisibleSelection validSelection(Position(text, 0), Position(text, 5)); | 66 VisibleSelection validSelection(Position(text, 0), Position(text, 5)); |
| 67 EXPECT_FALSE(validSelection.isNone()); | 67 EXPECT_FALSE(validSelection.isNone()); |
| 68 setSelection(validSelection); | 68 setSelection(validSelection); |
| 69 EXPECT_FALSE(selection().isNone()); | 69 EXPECT_FALSE(selection().isNone()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 TEST_F(FrameSelectionTest, SetInvalidSelection) | 72 TEST_F(FrameSelectionTest, SetInvalidSelection) |
| 73 { | 73 { |
| 74 // Create a new document without frame by using DOMImplementation. | 74 // Create a new document without frame by using DOMImplementation. |
| 75 DocumentInit dummy; | 75 DocumentInit dummy; |
| 76 RefPtrWillBeRawPtr<Document> documentWithoutFrame = Document::create(); | 76 RawPtr<Document> documentWithoutFrame = Document::create(); |
| 77 RefPtrWillBeRawPtr<Element> body = HTMLBodyElement::create(*documentWithoutF
rame); | 77 RawPtr<Element> body = HTMLBodyElement::create(*documentWithoutFrame); |
| 78 documentWithoutFrame->appendChild(body); | 78 documentWithoutFrame->appendChild(body); |
| 79 RefPtrWillBeRawPtr<Text> anotherText = documentWithoutFrame->createTextNode(
"Hello, another world"); | 79 RawPtr<Text> anotherText = documentWithoutFrame->createTextNode("Hello, anot
her world"); |
| 80 body->appendChild(anotherText); | 80 body->appendChild(anotherText); |
| 81 | 81 |
| 82 // Create a new VisibleSelection for the new document without frame and | 82 // Create a new VisibleSelection for the new document without frame and |
| 83 // update FrameSelection with the selection. | 83 // update FrameSelection with the selection. |
| 84 VisibleSelection invalidSelection; | 84 VisibleSelection invalidSelection; |
| 85 invalidSelection.setWithoutValidation(Position(anotherText, 0), Position(ano
therText, 5)); | 85 invalidSelection.setWithoutValidation(Position(anotherText, 0), Position(ano
therText, 5)); |
| 86 setSelection(invalidSelection); | 86 setSelection(invalidSelection); |
| 87 | 87 |
| 88 EXPECT_TRUE(selection().isNone()); | 88 EXPECT_TRUE(selection().isNone()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(FrameSelectionTest, InvalidateCaretRect) | 91 TEST_F(FrameSelectionTest, InvalidateCaretRect) |
| 92 { | 92 { |
| 93 RefPtrWillBeRawPtr<Text> text = appendTextNode("Hello, World!"); | 93 RawPtr<Text> text = appendTextNode("Hello, World!"); |
| 94 document().view()->updateAllLifecyclePhases(); | 94 document().view()->updateAllLifecyclePhases(); |
| 95 | 95 |
| 96 VisibleSelection validSelection(Position(text, 0), Position(text, 0)); | 96 VisibleSelection validSelection(Position(text, 0), Position(text, 0)); |
| 97 setSelection(validSelection); | 97 setSelection(validSelection); |
| 98 selection().setCaretRectNeedsUpdate(); | 98 selection().setCaretRectNeedsUpdate(); |
| 99 EXPECT_TRUE(selection().isCaretBoundsDirty()); | 99 EXPECT_TRUE(selection().isCaretBoundsDirty()); |
| 100 selection().invalidateCaretRect(); | 100 selection().invalidateCaretRect(); |
| 101 EXPECT_FALSE(selection().isCaretBoundsDirty()); | 101 EXPECT_FALSE(selection().isCaretBoundsDirty()); |
| 102 | 102 |
| 103 document().body()->removeChild(text); | 103 document().body()->removeChild(text); |
| 104 document().updateLayoutIgnorePendingStylesheets(); | 104 document().updateLayoutIgnorePendingStylesheets(); |
| 105 selection().setCaretRectNeedsUpdate(); | 105 selection().setCaretRectNeedsUpdate(); |
| 106 EXPECT_TRUE(selection().isCaretBoundsDirty()); | 106 EXPECT_TRUE(selection().isCaretBoundsDirty()); |
| 107 selection().invalidateCaretRect(); | 107 selection().invalidateCaretRect(); |
| 108 EXPECT_FALSE(selection().isCaretBoundsDirty()); | 108 EXPECT_FALSE(selection().isCaretBoundsDirty()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) | 111 TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) |
| 112 { | 112 { |
| 113 RefPtrWillBeRawPtr<Text> text = appendTextNode("Hello, World!"); | 113 RawPtr<Text> text = appendTextNode("Hello, World!"); |
| 114 document().view()->updateAllLifecyclePhases(); | 114 document().view()->updateAllLifecyclePhases(); |
| 115 | 115 |
| 116 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); | 116 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); |
| 117 document().body()->focus(); | 117 document().body()->focus(); |
| 118 EXPECT_TRUE(document().body()->focused()); | 118 EXPECT_TRUE(document().body()->focused()); |
| 119 | 119 |
| 120 VisibleSelection validSelection(Position(text, 0), Position(text, 0)); | 120 VisibleSelection validSelection(Position(text, 0), Position(text, 0)); |
| 121 selection().setCaretVisible(true); | 121 selection().setCaretVisible(true); |
| 122 setSelection(validSelection); | 122 setSelection(validSelection); |
| 123 EXPECT_TRUE(selection().isCaret()); | 123 EXPECT_TRUE(selection().isCaret()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 134 } | 134 } |
| 135 OwnPtr<PaintController> paintController = PaintController::create(); | 135 OwnPtr<PaintController> paintController = PaintController::create(); |
| 136 GraphicsContext context(*paintController); | 136 GraphicsContext context(*paintController); |
| 137 DrawingRecorder drawingRecorder(context, *dummyPageHolder().frameView().layo
utView(), DisplayItem::Caret, LayoutRect::infiniteIntRect()); | 137 DrawingRecorder drawingRecorder(context, *dummyPageHolder().frameView().layo
utView(), DisplayItem::Caret, LayoutRect::infiniteIntRect()); |
| 138 selection().paintCaret(context, LayoutPoint()); | 138 selection().paintCaret(context, LayoutPoint()); |
| 139 EXPECT_EQ(startCount, layoutCount()); | 139 EXPECT_EQ(startCount, layoutCount()); |
| 140 } | 140 } |
| 141 | 141 |
| 142 TEST_F(FrameSelectionTest, InvalidatePreviousCaretAfterRemovingLastCharacter) | 142 TEST_F(FrameSelectionTest, InvalidatePreviousCaretAfterRemovingLastCharacter) |
| 143 { | 143 { |
| 144 RefPtrWillBeRawPtr<Text> text = appendTextNode("Hello, World!"); | 144 RawPtr<Text> text = appendTextNode("Hello, World!"); |
| 145 document().view()->updateAllLifecyclePhases(); | 145 document().view()->updateAllLifecyclePhases(); |
| 146 | 146 |
| 147 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); | 147 document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION); |
| 148 document().body()->focus(); | 148 document().body()->focus(); |
| 149 EXPECT_TRUE(document().body()->focused()); | 149 EXPECT_TRUE(document().body()->focused()); |
| 150 | 150 |
| 151 selection().setCaretVisible(true); | 151 selection().setCaretVisible(true); |
| 152 EXPECT_TRUE(selection().isCaret()); | 152 EXPECT_TRUE(selection().isCaret()); |
| 153 EXPECT_TRUE(shouldPaintCaretForTesting()); | 153 EXPECT_TRUE(shouldPaintCaretForTesting()); |
| 154 | 154 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 EXPECT_FALSE(selection().isCaretBoundsDirty()); | 186 EXPECT_FALSE(selection().isCaretBoundsDirty()); |
| 187 EXPECT_TRUE(isPreviousCaretDirtyForTesting()); | 187 EXPECT_TRUE(isPreviousCaretDirtyForTesting()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 #define EXPECT_EQ_SELECTED_TEXT(text) \ | 190 #define EXPECT_EQ_SELECTED_TEXT(text) \ |
| 191 EXPECT_EQ(text, WebString(selection().selectedText()).utf8()) | 191 EXPECT_EQ(text, WebString(selection().selectedText()).utf8()) |
| 192 | 192 |
| 193 TEST_F(FrameSelectionTest, SelectWordAroundPosition) | 193 TEST_F(FrameSelectionTest, SelectWordAroundPosition) |
| 194 { | 194 { |
| 195 // "Foo Bar Baz," | 195 // "Foo Bar Baz," |
| 196 RefPtrWillBeRawPtr<Text> text = appendTextNode("Foo Bar Baz,"); | 196 RawPtr<Text> text = appendTextNode("Foo Bar Baz,"); |
| 197 // "Fo|o Bar Baz," | 197 // "Fo|o Bar Baz," |
| 198 EXPECT_TRUE(selection().selectWordAroundPosition(createVisiblePosition(Posit
ion(text, 2)))); | 198 EXPECT_TRUE(selection().selectWordAroundPosition(createVisiblePosition(Posit
ion(text, 2)))); |
| 199 EXPECT_EQ_SELECTED_TEXT("Foo"); | 199 EXPECT_EQ_SELECTED_TEXT("Foo"); |
| 200 // "Foo| Bar Baz," | 200 // "Foo| Bar Baz," |
| 201 EXPECT_TRUE(selection().selectWordAroundPosition(createVisiblePosition(Posit
ion(text, 3)))); | 201 EXPECT_TRUE(selection().selectWordAroundPosition(createVisiblePosition(Posit
ion(text, 3)))); |
| 202 EXPECT_EQ_SELECTED_TEXT("Foo"); | 202 EXPECT_EQ_SELECTED_TEXT("Foo"); |
| 203 // "Foo Bar | Baz," | 203 // "Foo Bar | Baz," |
| 204 EXPECT_FALSE(selection().selectWordAroundPosition(createVisiblePosition(Posi
tion(text, 13)))); | 204 EXPECT_FALSE(selection().selectWordAroundPosition(createVisiblePosition(Posi
tion(text, 13)))); |
| 205 // "Foo Bar Baz|," | 205 // "Foo Bar Baz|," |
| 206 EXPECT_TRUE(selection().selectWordAroundPosition(createVisiblePosition(Posit
ion(text, 22)))); | 206 EXPECT_TRUE(selection().selectWordAroundPosition(createVisiblePosition(Posit
ion(text, 22)))); |
| 207 EXPECT_EQ_SELECTED_TEXT("Baz"); | 207 EXPECT_EQ_SELECTED_TEXT("Baz"); |
| 208 } | 208 } |
| 209 | 209 |
| 210 TEST_F(FrameSelectionTest, ModifyExtendWithFlatTree) | 210 TEST_F(FrameSelectionTest, ModifyExtendWithFlatTree) |
| 211 { | 211 { |
| 212 setBodyContent("<span id=host></span>one"); | 212 setBodyContent("<span id=host></span>one"); |
| 213 setShadowContent("two<content></content>", "host"); | 213 setShadowContent("two<content></content>", "host"); |
| 214 updateLayoutAndStyleForPainting(); | 214 updateLayoutAndStyleForPainting(); |
| 215 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | 215 RawPtr<Element> host = document().getElementById("host"); |
| 216 Node* const two = FlatTreeTraversal::firstChild(*host); | 216 Node* const two = FlatTreeTraversal::firstChild(*host); |
| 217 // Select "two" for selection in DOM tree | 217 // Select "two" for selection in DOM tree |
| 218 // Select "twoone" for selection in Flat tree | 218 // Select "twoone" for selection in Flat tree |
| 219 selection().setSelection(VisibleSelectionInFlatTree(PositionInFlatTree(host.
get(), 0), PositionInFlatTree(document().body(), 2))); | 219 selection().setSelection(VisibleSelectionInFlatTree(PositionInFlatTree(host.
get(), 0), PositionInFlatTree(document().body(), 2))); |
| 220 selection().modify(FrameSelection::AlterationExtend, DirectionForward, WordG
ranularity); | 220 selection().modify(FrameSelection::AlterationExtend, DirectionForward, WordG
ranularity); |
| 221 EXPECT_EQ(Position(two, 0), visibleSelectionInDOMTree().start()); | 221 EXPECT_EQ(Position(two, 0), visibleSelectionInDOMTree().start()); |
| 222 EXPECT_EQ(Position(two, 3), visibleSelectionInDOMTree().end()); | 222 EXPECT_EQ(Position(two, 3), visibleSelectionInDOMTree().end()); |
| 223 EXPECT_EQ(PositionInFlatTree(two, 0), visibleSelectionInFlatTree().start()); | 223 EXPECT_EQ(PositionInFlatTree(two, 0), visibleSelectionInFlatTree().start()); |
| 224 EXPECT_EQ(PositionInFlatTree(two, 3), visibleSelectionInFlatTree().end()); | 224 EXPECT_EQ(PositionInFlatTree(two, 3), visibleSelectionInFlatTree().end()); |
| 225 } | 225 } |
| 226 | 226 |
| 227 TEST_F(FrameSelectionTest, MoveRangeSelectionTest) | 227 TEST_F(FrameSelectionTest, MoveRangeSelectionTest) |
| 228 { | 228 { |
| 229 // "Foo Bar Baz," | 229 // "Foo Bar Baz," |
| 230 RefPtrWillBeRawPtr<Text> text = appendTextNode("Foo Bar Baz,"); | 230 RawPtr<Text> text = appendTextNode("Foo Bar Baz,"); |
| 231 // Itinitializes with "Foo B|a>r Baz," (| means start and > means end). | 231 // Itinitializes with "Foo B|a>r Baz," (| means start and > means end). |
| 232 selection().setSelection(VisibleSelection(Position(text, 5), Position(text,
6))); | 232 selection().setSelection(VisibleSelection(Position(text, 5), Position(text,
6))); |
| 233 EXPECT_EQ_SELECTED_TEXT("a"); | 233 EXPECT_EQ_SELECTED_TEXT("a"); |
| 234 | 234 |
| 235 // "Foo B|ar B>az," with the Character granularity. | 235 // "Foo B|ar B>az," with the Character granularity. |
| 236 selection().moveRangeSelection(createVisiblePosition(Position(text, 5)), cre
ateVisiblePosition(Position(text, 9)), CharacterGranularity); | 236 selection().moveRangeSelection(createVisiblePosition(Position(text, 5)), cre
ateVisiblePosition(Position(text, 9)), CharacterGranularity); |
| 237 EXPECT_EQ_SELECTED_TEXT("ar B"); | 237 EXPECT_EQ_SELECTED_TEXT("ar B"); |
| 238 // "Foo B|ar B>az," with the Word granularity. | 238 // "Foo B|ar B>az," with the Word granularity. |
| 239 selection().moveRangeSelection(createVisiblePosition(Position(text, 5)), cre
ateVisiblePosition(Position(text, 9)), WordGranularity); | 239 selection().moveRangeSelection(createVisiblePosition(Position(text, 5)), cre
ateVisiblePosition(Position(text, 9)), WordGranularity); |
| 240 EXPECT_EQ_SELECTED_TEXT("Bar Baz"); | 240 EXPECT_EQ_SELECTED_TEXT("Bar Baz"); |
| 241 // "Fo<o B|ar Baz," with the Character granularity. | 241 // "Fo<o B|ar Baz," with the Character granularity. |
| 242 selection().moveRangeSelection(createVisiblePosition(Position(text, 5)), cre
ateVisiblePosition(Position(text, 2)), CharacterGranularity); | 242 selection().moveRangeSelection(createVisiblePosition(Position(text, 5)), cre
ateVisiblePosition(Position(text, 2)), CharacterGranularity); |
| 243 EXPECT_EQ_SELECTED_TEXT("o B"); | 243 EXPECT_EQ_SELECTED_TEXT("o B"); |
| 244 // "Fo<o B|ar Baz," with the Word granularity. | 244 // "Fo<o B|ar Baz," with the Word granularity. |
| 245 selection().moveRangeSelection(createVisiblePosition(Position(text, 5)), cre
ateVisiblePosition(Position(text, 2)), WordGranularity); | 245 selection().moveRangeSelection(createVisiblePosition(Position(text, 5)), cre
ateVisiblePosition(Position(text, 2)), WordGranularity); |
| 246 EXPECT_EQ_SELECTED_TEXT("Foo Bar"); | 246 EXPECT_EQ_SELECTED_TEXT("Foo Bar"); |
| 247 } | 247 } |
| 248 | 248 |
| 249 TEST_F(FrameSelectionTest, setNonDirectionalSelectionIfNeeded) | 249 TEST_F(FrameSelectionTest, setNonDirectionalSelectionIfNeeded) |
| 250 { | 250 { |
| 251 const char* bodyContent = "<span id=top>top</span><span id=host></span>"; | 251 const char* bodyContent = "<span id=top>top</span><span id=host></span>"; |
| 252 const char* shadowContent = "<span id=bottom>bottom</span>"; | 252 const char* shadowContent = "<span id=bottom>bottom</span>"; |
| 253 setBodyContent(bodyContent); | 253 setBodyContent(bodyContent); |
| 254 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent,
"host"); | 254 RawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); |
| 255 updateLayoutAndStyleForPainting(); | 255 updateLayoutAndStyleForPainting(); |
| 256 | 256 |
| 257 Node* top = document().getElementById("top")->firstChild(); | 257 Node* top = document().getElementById("top")->firstChild(); |
| 258 Node* bottom = shadowRoot->getElementById("bottom")->firstChild(); | 258 Node* bottom = shadowRoot->getElementById("bottom")->firstChild(); |
| 259 Node* host = document().getElementById("host"); | 259 Node* host = document().getElementById("host"); |
| 260 | 260 |
| 261 // top to bottom | 261 // top to bottom |
| 262 selection().setNonDirectionalSelectionIfNeeded(VisibleSelectionInFlatTree(Po
sitionInFlatTree(top, 1), PositionInFlatTree(bottom, 3)), CharacterGranularity); | 262 selection().setNonDirectionalSelectionIfNeeded(VisibleSelectionInFlatTree(Po
sitionInFlatTree(top, 1), PositionInFlatTree(bottom, 3)), CharacterGranularity); |
| 263 EXPECT_EQ(Position(top, 1), visibleSelectionInDOMTree().base()); | 263 EXPECT_EQ(Position(top, 1), visibleSelectionInDOMTree().base()); |
| 264 EXPECT_EQ(Position::beforeNode(host), visibleSelectionInDOMTree().extent()); | 264 EXPECT_EQ(Position::beforeNode(host), visibleSelectionInDOMTree().extent()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 278 EXPECT_EQ(Position(bottom, 3), visibleSelectionInDOMTree().end()); | 278 EXPECT_EQ(Position(bottom, 3), visibleSelectionInDOMTree().end()); |
| 279 | 279 |
| 280 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().base()
); | 280 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().base()
); |
| 281 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().extent())
; | 281 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().extent())
; |
| 282 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().start()); | 282 EXPECT_EQ(PositionInFlatTree(top, 1), visibleSelectionInFlatTree().start()); |
| 283 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().end())
; | 283 EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().end())
; |
| 284 } | 284 } |
| 285 | 285 |
| 286 TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot) | 286 TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot) |
| 287 { | 287 { |
| 288 RefPtrWillBeRawPtr<Element> select = document().createElement("select", ASSE
RT_NO_EXCEPTION); | 288 RawPtr<Element> select = document().createElement("select", ASSERT_NO_EXCEPT
ION); |
| 289 document().replaceChild(select.get(), document().documentElement()); | 289 document().replaceChild(select.get(), document().documentElement()); |
| 290 selection().selectAll(); | 290 selection().selectAll(); |
| 291 EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the cont
ent of the documentElement is not selctable."; | 291 EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the cont
ent of the documentElement is not selctable."; |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace blink | 294 } // namespace blink |
| OLD | NEW |