| 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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 selectFrameElementInParentIfFullySelected(); | 680 selectFrameElementInParentIfFullySelected(); |
| 681 notifyLayoutObjectOfSelectionChange(UserTriggered); | 681 notifyLayoutObjectOfSelectionChange(UserTriggered); |
| 682 } | 682 } |
| 683 | 683 |
| 684 bool FrameSelection::setSelectedRange(const EphemeralRange& range, | 684 bool FrameSelection::setSelectedRange(const EphemeralRange& range, |
| 685 TextAffinity affinity, | 685 TextAffinity affinity, |
| 686 SelectionDirectionalMode directional, | 686 SelectionDirectionalMode directional, |
| 687 SetSelectionOptions options) { | 687 SetSelectionOptions options) { |
| 688 if (range.isNull()) | 688 if (range.isNull()) |
| 689 return false; | 689 return false; |
| 690 m_selectionEditor->resetLogicalRange(); | |
| 691 // Since |FrameSeleciton::setSelection()| dispatches events and DOM tree | |
| 692 // can be modified by event handlers, we should create |Range| object before | |
| 693 // calling it. | |
| 694 Range* logicalRange = createRange(range); | |
| 695 setSelection(SelectionInDOMTree::Builder() | 690 setSelection(SelectionInDOMTree::Builder() |
| 696 .setBaseAndExtent(range) | 691 .setBaseAndExtent(range) |
| 697 .setAffinity(affinity) | 692 .setAffinity(affinity) |
| 698 .setIsDirectional(directional == | 693 .setIsDirectional(directional == |
| 699 SelectionDirectionalMode::Directional) | 694 SelectionDirectionalMode::Directional) |
| 700 .build(), | 695 .build(), |
| 701 options); | 696 options); |
| 702 m_selectionEditor->setLogicalRange(logicalRange); | |
| 703 return true; | 697 return true; |
| 704 } | 698 } |
| 705 | 699 |
| 706 Range* FrameSelection::firstRange() const { | 700 Range* FrameSelection::firstRange() const { |
| 707 return m_selectionEditor->firstRange(); | 701 return m_selectionEditor->firstRange(); |
| 708 } | 702 } |
| 709 | 703 |
| 710 bool FrameSelection::isInPasswordField() const { | 704 bool FrameSelection::isInPasswordField() const { |
| 711 TextControlElement* textControl = enclosingTextControl( | 705 TextControlElement* textControl = enclosingTextControl( |
| 712 computeVisibleSelectionInDOMTreeDeprecated().start()); | 706 computeVisibleSelectionInDOMTreeDeprecated().start()); |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 } | 1194 } |
| 1201 | 1195 |
| 1202 void showTree(const blink::FrameSelection* sel) { | 1196 void showTree(const blink::FrameSelection* sel) { |
| 1203 if (sel) | 1197 if (sel) |
| 1204 sel->showTreeForThis(); | 1198 sel->showTreeForThis(); |
| 1205 else | 1199 else |
| 1206 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1200 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
| 1207 } | 1201 } |
| 1208 | 1202 |
| 1209 #endif | 1203 #endif |
| OLD | NEW |