| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 builder.setAffinity(newSelection.affinity()) | 300 builder.setAffinity(newSelection.affinity()) |
| 301 .setBaseAndExtent(toPositionInDOMTree(newSelection.base()), | 301 .setBaseAndExtent(toPositionInDOMTree(newSelection.base()), |
| 302 toPositionInDOMTree(newSelection.extent())) | 302 toPositionInDOMTree(newSelection.extent())) |
| 303 .setGranularity(newSelection.granularity()) | 303 .setGranularity(newSelection.granularity()) |
| 304 .setIsDirectional(newSelection.isDirectional()) | 304 .setIsDirectional(newSelection.isDirectional()) |
| 305 .setIsHandleVisible(newSelection.isHandleVisible()) | 305 .setIsHandleVisible(newSelection.isHandleVisible()) |
| 306 .setHasTrailingWhitespace(newSelection.hasTrailingWhitespace()); | 306 .setHasTrailingWhitespace(newSelection.hasTrailingWhitespace()); |
| 307 return setSelection(builder.build(), options, align, granularity); | 307 return setSelection(builder.build(), options, align, granularity); |
| 308 } | 308 } |
| 309 | 309 |
| 310 void FrameSelection::setSelection(const VisibleSelection& newSelection, | |
| 311 HandleVisibility handleVisibility, | |
| 312 SetSelectionOptions options, | |
| 313 CursorAlignOnScroll align, | |
| 314 TextGranularity granularity) { | |
| 315 setSelection( | |
| 316 SelectionInDOMTree::Builder(newSelection.asSelection()) | |
| 317 .setIsHandleVisible(handleVisibility == HandleVisibility::Visible) | |
| 318 .build(), | |
| 319 options, align, granularity); | |
| 320 } | |
| 321 | |
| 322 void FrameSelection::nodeChildrenWillBeRemoved(ContainerNode& container) { | 310 void FrameSelection::nodeChildrenWillBeRemoved(ContainerNode& container) { |
| 323 if (!container.inActiveDocument()) | 311 if (!container.inActiveDocument()) |
| 324 return; | 312 return; |
| 325 // TODO(yosin): We should move to call |TypingCommand::closeTyping()| to | 313 // TODO(yosin): We should move to call |TypingCommand::closeTyping()| to |
| 326 // |Editor| class. | 314 // |Editor| class. |
| 327 if (!document().isRunningExecCommand()) | 315 if (!document().isRunningExecCommand()) |
| 328 TypingCommand::closeTyping(m_frame); | 316 TypingCommand::closeTyping(m_frame); |
| 329 } | 317 } |
| 330 | 318 |
| 331 void FrameSelection::nodeWillBeRemoved(Node& node) { | 319 void FrameSelection::nodeWillBeRemoved(Node& node) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 bool FrameSelection::modify(EAlteration alter, | 397 bool FrameSelection::modify(EAlteration alter, |
| 410 unsigned verticalDistance, | 398 unsigned verticalDistance, |
| 411 VerticalDirection direction) { | 399 VerticalDirection direction) { |
| 412 SelectionModifier selectionModifier( | 400 SelectionModifier selectionModifier( |
| 413 *frame(), computeVisibleSelectionInDOMTreeDeprecated()); | 401 *frame(), computeVisibleSelectionInDOMTreeDeprecated()); |
| 414 if (!selectionModifier.modifyWithPageGranularity(alter, verticalDistance, | 402 if (!selectionModifier.modifyWithPageGranularity(alter, verticalDistance, |
| 415 direction)) { | 403 direction)) { |
| 416 return false; | 404 return false; |
| 417 } | 405 } |
| 418 | 406 |
| 419 setSelection(selectionModifier.selection(), HandleVisibility::NotVisible, | 407 setSelection(selectionModifier.selection().asSelection(), |
| 420 CloseTyping | ClearTypingStyle | UserTriggered, | 408 CloseTyping | ClearTypingStyle | UserTriggered, |
| 421 alter == AlterationMove ? CursorAlignOnScroll::Always | 409 alter == AlterationMove ? CursorAlignOnScroll::Always |
| 422 : CursorAlignOnScroll::IfNeeded); | 410 : CursorAlignOnScroll::IfNeeded); |
| 423 | 411 |
| 424 m_granularity = CharacterGranularity; | 412 m_granularity = CharacterGranularity; |
| 425 | 413 |
| 426 return true; | 414 return true; |
| 427 } | 415 } |
| 428 | 416 |
| 429 void FrameSelection::clear() { | 417 void FrameSelection::clear() { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 | 581 |
| 594 // Focus on the parent frame, and then select from before this element to | 582 // Focus on the parent frame, and then select from before this element to |
| 595 // after. | 583 // after. |
| 596 VisibleSelection newSelection = createVisibleSelection(builder.build()); | 584 VisibleSelection newSelection = createVisibleSelection(builder.build()); |
| 597 // TODO(yosin): We should call |FocusController::setFocusedFrame()| before | 585 // TODO(yosin): We should call |FocusController::setFocusedFrame()| before |
| 598 // |createVisibleSelection()|. | 586 // |createVisibleSelection()|. |
| 599 page->focusController().setFocusedFrame(parent); | 587 page->focusController().setFocusedFrame(parent); |
| 600 // setFocusedFrame can dispatch synchronous focus/blur events. The document | 588 // setFocusedFrame can dispatch synchronous focus/blur events. The document |
| 601 // tree might be modified. | 589 // tree might be modified. |
| 602 if (newSelection.isNonOrphanedCaretOrRange()) | 590 if (newSelection.isNonOrphanedCaretOrRange()) |
| 603 toLocalFrame(parent)->selection().setSelection(newSelection); | 591 toLocalFrame(parent)->selection().setSelection(newSelection.asSelection()); |
| 604 } | 592 } |
| 605 | 593 |
| 606 // Returns a shadow tree node for legacy shadow trees, a child of the | 594 // Returns a shadow tree node for legacy shadow trees, a child of the |
| 607 // ShadowRoot node for new shadow trees, or 0 for non-shadow trees. | 595 // ShadowRoot node for new shadow trees, or 0 for non-shadow trees. |
| 608 static Node* nonBoundaryShadowTreeRootNode(const Position& position) { | 596 static Node* nonBoundaryShadowTreeRootNode(const Position& position) { |
| 609 return position.anchorNode() && !position.anchorNode()->isShadowRoot() | 597 return position.anchorNode() && !position.anchorNode()->isShadowRoot() |
| 610 ? position.anchorNode()->nonBoundaryShadowTreeRootNode() | 598 ? position.anchorNode()->nonBoundaryShadowTreeRootNode() |
| 611 : nullptr; | 599 : nullptr; |
| 612 } | 600 } |
| 613 | 601 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 m_granularityStrategy = WTF::makeUnique<CharacterGranularityStrategy>(); | 1094 m_granularityStrategy = WTF::makeUnique<CharacterGranularityStrategy>(); |
| 1107 return m_granularityStrategy.get(); | 1095 return m_granularityStrategy.get(); |
| 1108 } | 1096 } |
| 1109 | 1097 |
| 1110 void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) { | 1098 void FrameSelection::moveRangeSelectionExtent(const IntPoint& contentsPoint) { |
| 1111 if (computeVisibleSelectionInDOMTreeDeprecated().isNone()) | 1099 if (computeVisibleSelectionInDOMTreeDeprecated().isNone()) |
| 1112 return; | 1100 return; |
| 1113 | 1101 |
| 1114 VisibleSelection newSelection = | 1102 VisibleSelection newSelection = |
| 1115 granularityStrategy()->updateExtent(contentsPoint, m_frame); | 1103 granularityStrategy()->updateExtent(contentsPoint, m_frame); |
| 1116 setSelection(newSelection, HandleVisibility::Visible, | 1104 setSelection(SelectionInDOMTree::Builder(newSelection.asSelection()) |
| 1105 .setIsHandleVisible(true) |
| 1106 .build(), |
| 1117 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | | 1107 FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | |
| 1118 FrameSelection::DoNotClearStrategy | UserTriggered, | 1108 FrameSelection::DoNotClearStrategy | UserTriggered, |
| 1119 CursorAlignOnScroll::IfNeeded, CharacterGranularity); | 1109 CursorAlignOnScroll::IfNeeded, CharacterGranularity); |
| 1120 } | 1110 } |
| 1121 | 1111 |
| 1122 // TODO(yosin): We should make |FrameSelection::moveRangeSelection()| to take | 1112 // TODO(yosin): We should make |FrameSelection::moveRangeSelection()| to take |
| 1123 // two |IntPoint| instead of two |VisiblePosition| like | 1113 // two |IntPoint| instead of two |VisiblePosition| like |
| 1124 // |moveRangeSelectionExtent()|. | 1114 // |moveRangeSelectionExtent()|. |
| 1125 void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition, | 1115 void FrameSelection::moveRangeSelection(const VisiblePosition& basePosition, |
| 1126 const VisiblePosition& extentPosition, | 1116 const VisiblePosition& extentPosition, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 } | 1165 } |
| 1176 | 1166 |
| 1177 void showTree(const blink::FrameSelection* sel) { | 1167 void showTree(const blink::FrameSelection* sel) { |
| 1178 if (sel) | 1168 if (sel) |
| 1179 sel->showTreeForThis(); | 1169 sel->showTreeForThis(); |
| 1180 else | 1170 else |
| 1181 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1171 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
| 1182 } | 1172 } |
| 1183 | 1173 |
| 1184 #endif | 1174 #endif |
| OLD | NEW |