| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 return VisibleSelectionInFlatTree(visibleStart, visibleExtent); | 79 return VisibleSelectionInFlatTree(visibleStart, visibleExtent); |
| 80 } | 80 } |
| 81 const VisiblePositionInFlatTree visibleEnd = createVisiblePosition(end, sele
ctionType == SelectionType::RangeSelection ? TextAffinity::Upstream : affinity); | 81 const VisiblePositionInFlatTree visibleEnd = createVisiblePosition(end, sele
ctionType == SelectionType::RangeSelection ? TextAffinity::Upstream : affinity); |
| 82 return VisibleSelectionInFlatTree(visibleStart, visibleEnd); | 82 return VisibleSelectionInFlatTree(visibleStart, visibleEnd); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void PendingSelection::commit(LayoutView& layoutView) | 85 void PendingSelection::commit(LayoutView& layoutView) |
| 86 { | 86 { |
| 87 if (!hasPendingSelection()) | 87 if (!hasPendingSelection()) |
| 88 return; | 88 return; |
| 89 ASSERT(!layoutView.needsLayout()); | 89 DCHECK(!layoutView.needsLayout()); |
| 90 m_hasPendingSelection = false; | 90 m_hasPendingSelection = false; |
| 91 | 91 |
| 92 const VisibleSelectionInFlatTree& originalSelection = m_frameSelection->visi
bleSelection<EditingInFlatTreeStrategy>(); | 92 const VisibleSelectionInFlatTree& originalSelection = m_frameSelection->visi
bleSelection<EditingInFlatTreeStrategy>(); |
| 93 | 93 |
| 94 // Skip if pending VisibilePositions became invalid before we reach here. | 94 // Skip if pending VisibilePositions became invalid before we reach here. |
| 95 if (!isSelectionInDocument(originalSelection, layoutView.document())) | 95 if (!isSelectionInDocument(originalSelection, layoutView.document())) |
| 96 return; | 96 return; |
| 97 | 97 |
| 98 // Construct a new VisibleSolution, since visibleSelection() is not necessar
ily | 98 // Construct a new VisibleSolution, since visibleSelection() is not necessar
ily |
| 99 // valid, and the following steps assume a valid selection. | 99 // valid, and the following steps assume a valid selection. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 123 | 123 |
| 124 // We can get into a state where the selection endpoints map to the same | 124 // We can get into a state where the selection endpoints map to the same |
| 125 // |VisiblePosition| when a selection is deleted because we don't yet notify | 125 // |VisiblePosition| when a selection is deleted because we don't yet notify |
| 126 // the |FrameSelection| of text removal. | 126 // the |FrameSelection| of text removal. |
| 127 if (startPos.isNull() || endPos.isNull() || selection.visibleStart().deepEqu
ivalent() == selection.visibleEnd().deepEquivalent()) | 127 if (startPos.isNull() || endPos.isNull() || selection.visibleStart().deepEqu
ivalent() == selection.visibleEnd().deepEquivalent()) |
| 128 return; | 128 return; |
| 129 LayoutObject* startLayoutObject = startPos.anchorNode()->layoutObject(); | 129 LayoutObject* startLayoutObject = startPos.anchorNode()->layoutObject(); |
| 130 LayoutObject* endLayoutObject = endPos.anchorNode()->layoutObject(); | 130 LayoutObject* endLayoutObject = endPos.anchorNode()->layoutObject(); |
| 131 if (!startLayoutObject || !endLayoutObject) | 131 if (!startLayoutObject || !endLayoutObject) |
| 132 return; | 132 return; |
| 133 ASSERT(layoutView == startLayoutObject->view() && layoutView == endLayoutObj
ect->view()); | 133 DCHECK(layoutView == startLayoutObject->view()); |
| 134 DCHECK(layoutView == endLayoutObject->view()); |
| 134 layoutView.setSelection(startLayoutObject, startPos.computeEditingOffset(),
endLayoutObject, endPos.computeEditingOffset()); | 135 layoutView.setSelection(startLayoutObject, startPos.computeEditingOffset(),
endLayoutObject, endPos.computeEditingOffset()); |
| 135 } | 136 } |
| 136 | 137 |
| 137 DEFINE_TRACE(PendingSelection) | 138 DEFINE_TRACE(PendingSelection) |
| 138 { | 139 { |
| 139 visitor->trace(m_frameSelection); | 140 visitor->trace(m_frameSelection); |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |