| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 visibleExtent = VisiblePosition(extent.positionAtLeftBoundaryOfBiDiRun()
); | 184 visibleExtent = VisiblePosition(extent.positionAtLeftBoundaryOfBiDiRun()
); |
| 185 return; | 185 return; |
| 186 } | 186 } |
| 187 | 187 |
| 188 if (extent.atRightBoundaryOfBidiRun() && extent.isEquivalent(base.rightBound
aryOfBidiRun(extent.bidiLevelOnLeft()))) { | 188 if (extent.atRightBoundaryOfBidiRun() && extent.isEquivalent(base.rightBound
aryOfBidiRun(extent.bidiLevelOnLeft()))) { |
| 189 visibleExtent = VisiblePosition(extent.positionAtRightBoundaryOfBiDiRun(
)); | 189 visibleExtent = VisiblePosition(extent.positionAtRightBoundaryOfBiDiRun(
)); |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 void FrameSelection::setNonDirectionalSelectionIfNeeded(const VisibleSelection&
passedNewSelection, TextGranularity granularity, | 194 template <typename Strategy> |
| 195 void FrameSelection::setNonDirectionalSelectionIfNeededAlgorithm(const VisibleSe
lection& passedNewSelection, TextGranularity granularity, |
| 195 EndPointsAdjustmentMode endpointsAdjustmentMode) | 196 EndPointsAdjustmentMode endpointsAdjustmentMode) |
| 196 { | 197 { |
| 197 VisibleSelection newSelection = passedNewSelection; | 198 VisibleSelection newSelection = passedNewSelection; |
| 198 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSele
ction.isDirectional(); | 199 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSele
ction.isDirectional(); |
| 199 | 200 |
| 200 VisiblePosition base = m_originalBase.isNotNull() ? m_originalBase : newSele
ction.visibleBase(); | 201 VisiblePosition base = m_originalBase.isNotNull() ? m_originalBase : Visible
Position(Strategy::selectionBase(newSelection)); |
| 201 VisiblePosition newBase = base; | 202 VisiblePosition newBase = base; |
| 202 VisiblePosition extent = newSelection.visibleExtent(); | 203 VisiblePosition extent(Strategy::selectionExtent(newSelection)); |
| 203 VisiblePosition newExtent = extent; | 204 VisiblePosition newExtent = extent; |
| 204 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary) | 205 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary) |
| 205 adjustEndpointsAtBidiBoundary(newBase, newExtent); | 206 adjustEndpointsAtBidiBoundary(newBase, newExtent); |
| 206 | 207 |
| 207 if (newBase != base || newExtent != extent) { | 208 if (newBase != base || newExtent != extent) { |
| 208 m_originalBase = base; | 209 m_originalBase = base; |
| 209 newSelection.setBase(newBase); | 210 newSelection.setBase(newBase); |
| 210 newSelection.setExtent(newExtent); | 211 newSelection.setExtent(newExtent); |
| 211 } else if (m_originalBase.isNotNull()) { | 212 } else if (m_originalBase.isNotNull()) { |
| 212 if (m_selection.base() == newSelection.base()) | 213 if (Strategy::selectionBase(m_selection) == Strategy::selectionBase(newS
election)) |
| 213 newSelection.setBase(m_originalBase); | 214 newSelection.setBase(m_originalBase); |
| 214 m_originalBase.clear(); | 215 m_originalBase.clear(); |
| 215 } | 216 } |
| 216 | 217 |
| 217 newSelection.setIsDirectional(isDirectional); // Adjusting base and extent w
ill make newSelection always directional | 218 newSelection.setIsDirectional(isDirectional); // Adjusting base and extent w
ill make newSelection always directional |
| 218 if (m_selection == newSelection) | 219 if (Strategy::equalSelections(m_selection, newSelection)) |
| 219 return; | 220 return; |
| 220 | 221 |
| 221 setSelection(newSelection, granularity); | 222 setSelection(newSelection, granularity); |
| 222 } | 223 } |
| 223 | 224 |
| 225 void FrameSelection::setNonDirectionalSelectionIfNeeded(const VisibleSelection&
passedNewSelection, TextGranularity granularity, EndPointsAdjustmentMode endpoin
tsAdjustmentMode) |
| 226 { |
| 227 setNonDirectionalSelectionIfNeededAlgorithm<VisibleSelection::InDOMTree>(pas
sedNewSelection, granularity, endpointsAdjustmentMode); |
| 228 } |
| 229 |
| 224 void FrameSelection::setSelection(const VisibleSelection& newSelection, SetSelec
tionOptions options, CursorAlignOnScroll align, TextGranularity granularity) | 230 void FrameSelection::setSelection(const VisibleSelection& newSelection, SetSelec
tionOptions options, CursorAlignOnScroll align, TextGranularity granularity) |
| 225 { | 231 { |
| 226 if (m_granularityStrategy && (options & FrameSelection::DoNotClearStrategy)
== 0) | 232 if (m_granularityStrategy && (options & FrameSelection::DoNotClearStrategy)
== 0) |
| 227 m_granularityStrategy->Clear(); | 233 m_granularityStrategy->Clear(); |
| 228 bool closeTyping = options & CloseTyping; | 234 bool closeTyping = options & CloseTyping; |
| 229 bool shouldClearTypingStyle = options & ClearTypingStyle; | 235 bool shouldClearTypingStyle = options & ClearTypingStyle; |
| 230 EUserTriggered userTriggered = selectionOptionsToUserTriggered(options); | 236 EUserTriggered userTriggered = selectionOptionsToUserTriggered(options); |
| 231 | 237 |
| 232 VisibleSelection s = validateSelection(newSelection); | 238 VisibleSelection s = validateSelection(newSelection); |
| 233 if (shouldAlwaysUseDirectionalSelection(m_frame)) | 239 if (shouldAlwaysUseDirectionalSelection(m_frame)) |
| (...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1973 | 1979 |
| 1974 void showTree(const blink::FrameSelection* sel) | 1980 void showTree(const blink::FrameSelection* sel) |
| 1975 { | 1981 { |
| 1976 if (sel) | 1982 if (sel) |
| 1977 sel->showTreeForThis(); | 1983 sel->showTreeForThis(); |
| 1978 else | 1984 else |
| 1979 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); | 1985 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); |
| 1980 } | 1986 } |
| 1981 | 1987 |
| 1982 #endif | 1988 #endif |
| OLD | NEW |