| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>(ex
tent.positionAtLeftBoundaryOfBiDiRun())); | 218 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>(ex
tent.positionAtLeftBoundaryOfBiDiRun())); |
| 219 return; | 219 return; |
| 220 } | 220 } |
| 221 | 221 |
| 222 if (extent.atRightBoundaryOfBidiRun() && extent.isEquivalent(base.rightBound
aryOfBidiRun(extent.bidiLevelOnLeft()))) { | 222 if (extent.atRightBoundaryOfBidiRun() && extent.isEquivalent(base.rightBound
aryOfBidiRun(extent.bidiLevelOnLeft()))) { |
| 223 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>(ex
tent.positionAtRightBoundaryOfBiDiRun())); | 223 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>(ex
tent.positionAtRightBoundaryOfBiDiRun())); |
| 224 return; | 224 return; |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 void FrameSelection::setOriginalBase(const VisiblePosition& newBase) |
| 229 { |
| 230 m_originalBase = newBase; |
| 231 m_originalBaseInFlatTree = createVisiblePosition(toPositionInFlatTree(newBas
e.deepEquivalent())); |
| 232 } |
| 233 |
| 234 void FrameSelection::setOriginalBase(const VisiblePositionInFlatTree& newBase) |
| 235 { |
| 236 m_originalBaseInFlatTree = newBase; |
| 237 m_originalBase = createVisiblePosition(toPositionInDOMTree(newBase.deepEquiv
alent())); |
| 238 } |
| 239 |
| 228 template <typename Strategy> | 240 template <typename Strategy> |
| 229 void FrameSelection::setNonDirectionalSelectionIfNeededAlgorithm(const VisibleSe
lectionTemplate<Strategy>& passedNewSelection, TextGranularity granularity, | 241 void FrameSelection::setNonDirectionalSelectionIfNeededAlgorithm(const VisibleSe
lectionTemplate<Strategy>& passedNewSelection, TextGranularity granularity, |
| 230 EndPointsAdjustmentMode endpointsAdjustmentMode) | 242 EndPointsAdjustmentMode endpointsAdjustmentMode) |
| 231 { | 243 { |
| 232 VisibleSelectionTemplate<Strategy> newSelection = passedNewSelection; | 244 VisibleSelectionTemplate<Strategy> newSelection = passedNewSelection; |
| 233 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSele
ction.isDirectional(); | 245 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSele
ction.isDirectional(); |
| 234 | 246 |
| 235 const VisiblePositionTemplate<Strategy> originalBase = this->originalBase<St
rategy>(); | 247 const PositionTemplate<Strategy> basePosition = this->originalBase<Strategy>
().deepEquivalent(); |
| 248 const VisiblePositionTemplate<Strategy> originalBase = basePosition.inShadow
IncludingDocument() ? createVisiblePosition(basePosition) : VisiblePositionTempl
ate<Strategy>(); |
| 236 const VisiblePositionTemplate<Strategy> base = originalBase.isNotNull() ? or
iginalBase : createVisiblePosition(newSelection.base()); | 249 const VisiblePositionTemplate<Strategy> base = originalBase.isNotNull() ? or
iginalBase : createVisiblePosition(newSelection.base()); |
| 237 VisiblePositionTemplate<Strategy> newBase = base; | 250 VisiblePositionTemplate<Strategy> newBase = base; |
| 238 const VisiblePositionTemplate<Strategy> extent = createVisiblePosition(newSe
lection.extent()); | 251 const VisiblePositionTemplate<Strategy> extent = createVisiblePosition(newSe
lection.extent()); |
| 239 VisiblePositionTemplate<Strategy> newExtent = extent; | 252 VisiblePositionTemplate<Strategy> newExtent = extent; |
| 240 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary) | 253 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary) |
| 241 adjustEndpointsAtBidiBoundary(newBase, newExtent); | 254 adjustEndpointsAtBidiBoundary(newBase, newExtent); |
| 242 | 255 |
| 243 if (newBase.deepEquivalent() != base.deepEquivalent() || newExtent.deepEquiv
alent() != extent.deepEquivalent()) { | 256 if (newBase.deepEquivalent() != base.deepEquivalent() || newExtent.deepEquiv
alent() != extent.deepEquivalent()) { |
| 244 setOriginalBase(base); | 257 setOriginalBase(base); |
| 245 newSelection.setBase(newBase); | 258 newSelection.setBase(newBase); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 void FrameSelection::clear() | 670 void FrameSelection::clear() |
| 658 { | 671 { |
| 659 m_granularity = CharacterGranularity; | 672 m_granularity = CharacterGranularity; |
| 660 if (m_granularityStrategy) | 673 if (m_granularityStrategy) |
| 661 m_granularityStrategy->Clear(); | 674 m_granularityStrategy->Clear(); |
| 662 setSelection(VisibleSelection()); | 675 setSelection(VisibleSelection()); |
| 663 } | 676 } |
| 664 | 677 |
| 665 void FrameSelection::prepareForDestruction() | 678 void FrameSelection::prepareForDestruction() |
| 666 { | 679 { |
| 680 m_originalBase = VisiblePosition(); |
| 681 m_originalBaseInFlatTree = VisiblePositionInFlatTree(); |
| 667 m_granularity = CharacterGranularity; | 682 m_granularity = CharacterGranularity; |
| 668 | 683 |
| 669 m_caretBlinkTimer.stop(); | 684 m_caretBlinkTimer.stop(); |
| 670 | 685 |
| 671 LayoutViewItem view = m_frame->contentLayoutItem(); | 686 LayoutViewItem view = m_frame->contentLayoutItem(); |
| 672 if (!view.isNull()) | 687 if (!view.isNull()) |
| 673 view.clearSelection(); | 688 view.clearSelection(); |
| 674 | 689 |
| 675 setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdat
eAppearance); | 690 setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdat
eAppearance); |
| 676 m_selectionEditor->dispose(); | 691 m_selectionEditor->dispose(); |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 | 1470 |
| 1456 void showTree(const blink::FrameSelection* sel) | 1471 void showTree(const blink::FrameSelection* sel) |
| 1457 { | 1472 { |
| 1458 if (sel) | 1473 if (sel) |
| 1459 sel->showTreeForThis(); | 1474 sel->showTreeForThis(); |
| 1460 else | 1475 else |
| 1461 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); | 1476 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); |
| 1462 } | 1477 } |
| 1463 | 1478 |
| 1464 #endif | 1479 #endif |
| OLD | NEW |