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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 { | 180 { |
181 RenderedPosition base(visibleBase); | 181 RenderedPosition base(visibleBase); |
182 RenderedPosition extent(visibleExtent); | 182 RenderedPosition extent(visibleExtent); |
183 | 183 |
184 if (base.isNull() || extent.isNull() || base.isEquivalent(extent)) | 184 if (base.isNull() || extent.isNull() || base.isEquivalent(extent)) |
185 return; | 185 return; |
186 | 186 |
187 if (base.atLeftBoundaryOfBidiRun()) { | 187 if (base.atLeftBoundaryOfBidiRun()) { |
188 if (!extent.atRightBoundaryOfBidiRun(base.bidiLevelOnRight()) | 188 if (!extent.atRightBoundaryOfBidiRun(base.bidiLevelOnRight()) |
189 && base.isEquivalent(extent.leftBoundaryOfBidiRun(base.bidiLevelOnRi
ght()))) { | 189 && base.isEquivalent(extent.leftBoundaryOfBidiRun(base.bidiLevelOnRi
ght()))) { |
190 visibleBase = createVisiblePosition(fromPositionInDOMTree<Strategy>(
base.positionAtLeftBoundaryOfBiDiRun())); | 190 visibleBase = createVisiblePositionDeprecated(fromPositionInDOMTree<
Strategy>(base.positionAtLeftBoundaryOfBiDiRun())); |
191 return; | 191 return; |
192 } | 192 } |
193 return; | 193 return; |
194 } | 194 } |
195 | 195 |
196 if (base.atRightBoundaryOfBidiRun()) { | 196 if (base.atRightBoundaryOfBidiRun()) { |
197 if (!extent.atLeftBoundaryOfBidiRun(base.bidiLevelOnLeft()) | 197 if (!extent.atLeftBoundaryOfBidiRun(base.bidiLevelOnLeft()) |
198 && base.isEquivalent(extent.rightBoundaryOfBidiRun(base.bidiLevelOnL
eft()))) { | 198 && base.isEquivalent(extent.rightBoundaryOfBidiRun(base.bidiLevelOnL
eft()))) { |
199 visibleBase = createVisiblePosition(fromPositionInDOMTree<Strategy>(
base.positionAtRightBoundaryOfBiDiRun())); | 199 visibleBase = createVisiblePositionDeprecated(fromPositionInDOMTree<
Strategy>(base.positionAtRightBoundaryOfBiDiRun())); |
200 return; | 200 return; |
201 } | 201 } |
202 return; | 202 return; |
203 } | 203 } |
204 | 204 |
205 if (extent.atLeftBoundaryOfBidiRun() && extent.isEquivalent(base.leftBoundar
yOfBidiRun(extent.bidiLevelOnRight()))) { | 205 if (extent.atLeftBoundaryOfBidiRun() && extent.isEquivalent(base.leftBoundar
yOfBidiRun(extent.bidiLevelOnRight()))) { |
206 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>(ex
tent.positionAtLeftBoundaryOfBiDiRun())); | 206 visibleExtent = createVisiblePositionDeprecated(fromPositionInDOMTree<St
rategy>(extent.positionAtLeftBoundaryOfBiDiRun())); |
207 return; | 207 return; |
208 } | 208 } |
209 | 209 |
210 if (extent.atRightBoundaryOfBidiRun() && extent.isEquivalent(base.rightBound
aryOfBidiRun(extent.bidiLevelOnLeft()))) { | 210 if (extent.atRightBoundaryOfBidiRun() && extent.isEquivalent(base.rightBound
aryOfBidiRun(extent.bidiLevelOnLeft()))) { |
211 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>(ex
tent.positionAtRightBoundaryOfBiDiRun())); | 211 visibleExtent = createVisiblePositionDeprecated(fromPositionInDOMTree<St
rategy>(extent.positionAtRightBoundaryOfBiDiRun())); |
212 return; | 212 return; |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 void FrameSelection::setNonDirectionalSelectionIfNeeded(const VisibleSelectionIn
FlatTree& passedNewSelection, TextGranularity granularity, EndPointsAdjustmentMo
de endpointsAdjustmentMode) | 216 void FrameSelection::setNonDirectionalSelectionIfNeeded(const VisibleSelectionIn
FlatTree& passedNewSelection, TextGranularity granularity, EndPointsAdjustmentMo
de endpointsAdjustmentMode) |
217 { | 217 { |
218 VisibleSelectionInFlatTree newSelection = passedNewSelection; | 218 VisibleSelectionInFlatTree newSelection = passedNewSelection; |
219 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSele
ction.isDirectional(); | 219 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSele
ction.isDirectional(); |
220 | 220 |
221 const PositionInFlatTree basePosition = m_originalBaseInFlatTree.deepEquival
ent(); | 221 const PositionInFlatTree basePosition = m_originalBaseInFlatTree.deepEquival
ent(); |
222 const VisiblePositionInFlatTree originalBase = basePosition.isConnected() ?
createVisiblePosition(basePosition) : VisiblePositionInFlatTree(); | 222 const VisiblePositionInFlatTree originalBase = basePosition.isConnected() ?
createVisiblePositionDeprecated(basePosition) : VisiblePositionInFlatTree(); |
223 const VisiblePositionInFlatTree base = originalBase.isNotNull() ? originalBa
se : createVisiblePosition(newSelection.base()); | 223 const VisiblePositionInFlatTree base = originalBase.isNotNull() ? originalBa
se : createVisiblePositionDeprecated(newSelection.base()); |
224 VisiblePositionInFlatTree newBase = base; | 224 VisiblePositionInFlatTree newBase = base; |
225 const VisiblePositionInFlatTree extent = createVisiblePosition(newSelection.
extent()); | 225 const VisiblePositionInFlatTree extent = createVisiblePositionDeprecated(new
Selection.extent()); |
226 VisiblePositionInFlatTree newExtent = extent; | 226 VisiblePositionInFlatTree newExtent = extent; |
227 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary) | 227 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary) |
228 adjustEndpointsAtBidiBoundary(newBase, newExtent); | 228 adjustEndpointsAtBidiBoundary(newBase, newExtent); |
229 | 229 |
230 if (newBase.deepEquivalent() != base.deepEquivalent() || newExtent.deepEquiv
alent() != extent.deepEquivalent()) { | 230 if (newBase.deepEquivalent() != base.deepEquivalent() || newExtent.deepEquiv
alent() != extent.deepEquivalent()) { |
231 m_originalBaseInFlatTree = base; | 231 m_originalBaseInFlatTree = base; |
232 newSelection.setBase(newBase); | 232 newSelection.setBase(newBase); |
233 newSelection.setExtent(newExtent); | 233 newSelection.setExtent(newExtent); |
234 } else if (originalBase.isNotNull()) { | 234 } else if (originalBase.isNotNull()) { |
235 if (visibleSelection<EditingInFlatTreeStrategy>().base() == newSelection
.base()) | 235 if (visibleSelection<EditingInFlatTreeStrategy>().base() == newSelection
.base()) |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 if (!visibleSelection.isRange()) | 738 if (!visibleSelection.isRange()) |
739 return false; | 739 return false; |
740 | 740 |
741 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); | 741 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); |
742 HitTestResult result(request, point); | 742 HitTestResult result(request, point); |
743 document().layoutViewItem().hitTest(result); | 743 document().layoutViewItem().hitTest(result); |
744 Node* innerNode = result.innerNode(); | 744 Node* innerNode = result.innerNode(); |
745 if (!innerNode || !innerNode->layoutObject()) | 745 if (!innerNode || !innerNode->layoutObject()) |
746 return false; | 746 return false; |
747 | 747 |
748 const VisiblePositionInFlatTree& visiblePos = createVisiblePosition(fromPosi
tionInDOMTree<EditingInFlatTreeStrategy>(innerNode->layoutObject()->positionForP
oint(result.localPoint()))); | 748 const VisiblePositionInFlatTree& visiblePos = createVisiblePositionDeprecate
d(fromPositionInDOMTree<EditingInFlatTreeStrategy>(innerNode->layoutObject()->po
sitionForPoint(result.localPoint()))); |
749 if (visiblePos.isNull()) | 749 if (visiblePos.isNull()) |
750 return false; | 750 return false; |
751 | 751 |
752 const VisiblePositionInFlatTree& visibleStart = visibleSelection.visibleStar
t(); | 752 const VisiblePositionInFlatTree& visibleStart = visibleSelection.visibleStar
t(); |
753 const VisiblePositionInFlatTree& visibleEnd = visibleSelection.visibleEnd(); | 753 const VisiblePositionInFlatTree& visibleEnd = visibleSelection.visibleEnd(); |
754 if (visibleStart.isNull() || visibleEnd.isNull()) | 754 if (visibleStart.isNull() || visibleEnd.isNull()) |
755 return false; | 755 return false; |
756 | 756 |
757 const PositionInFlatTree& start = visibleStart.deepEquivalent(); | 757 const PositionInFlatTree& start = visibleStart.deepEquivalent(); |
758 const PositionInFlatTree& end = visibleEnd.deepEquivalent(); | 758 const PositionInFlatTree& end = visibleEnd.deepEquivalent(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 ContainerNode* ownerElementParent = ownerElement->parentNode(); | 795 ContainerNode* ownerElementParent = ownerElement->parentNode(); |
796 if (!ownerElementParent) | 796 if (!ownerElementParent) |
797 return; | 797 return; |
798 | 798 |
799 // This method's purpose is it to make it easier to select iframes (in order
to delete them). Don't do anything if the iframe isn't deletable. | 799 // This method's purpose is it to make it easier to select iframes (in order
to delete them). Don't do anything if the iframe isn't deletable. |
800 if (!blink::hasEditableStyle(*ownerElementParent)) | 800 if (!blink::hasEditableStyle(*ownerElementParent)) |
801 return; | 801 return; |
802 | 802 |
803 // Create compute positions before and after the element. | 803 // Create compute positions before and after the element. |
804 unsigned ownerElementNodeIndex = ownerElement->nodeIndex(); | 804 unsigned ownerElementNodeIndex = ownerElement->nodeIndex(); |
805 VisiblePosition beforeOwnerElement = createVisiblePosition(Position(ownerEle
mentParent, ownerElementNodeIndex)); | 805 VisiblePosition beforeOwnerElement = createVisiblePositionDeprecated(Positio
n(ownerElementParent, ownerElementNodeIndex)); |
806 VisiblePosition afterOwnerElement = createVisiblePosition(Position(ownerElem
entParent, ownerElementNodeIndex + 1), VP_UPSTREAM_IF_POSSIBLE); | 806 VisiblePosition afterOwnerElement = createVisiblePositionDeprecated(Position
(ownerElementParent, ownerElementNodeIndex + 1), VP_UPSTREAM_IF_POSSIBLE); |
807 | 807 |
808 // Focus on the parent frame, and then select from before this element to af
ter. | 808 // Focus on the parent frame, and then select from before this element to af
ter. |
809 VisibleSelection newSelection(beforeOwnerElement, afterOwnerElement); | 809 VisibleSelection newSelection(beforeOwnerElement, afterOwnerElement); |
810 page->focusController().setFocusedFrame(parent); | 810 page->focusController().setFocusedFrame(parent); |
811 // setFocusedFrame can dispatch synchronous focus/blur events. The document | 811 // setFocusedFrame can dispatch synchronous focus/blur events. The document |
812 // tree might be modified. | 812 // tree might be modified. |
813 if (newSelection.isNonOrphanedCaretOrRange()) | 813 if (newSelection.isNonOrphanedCaretOrRange()) |
814 toLocalFrame(parent)->selection().setSelection(newSelection); | 814 toLocalFrame(parent)->selection().setSelection(newSelection); |
815 } | 815 } |
816 | 816 |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 | 1160 |
1161 LayoutRect rect; | 1161 LayoutRect rect; |
1162 | 1162 |
1163 switch (getSelectionType()) { | 1163 switch (getSelectionType()) { |
1164 case NoSelection: | 1164 case NoSelection: |
1165 return; | 1165 return; |
1166 case CaretSelection: | 1166 case CaretSelection: |
1167 rect = LayoutRect(absoluteCaretBounds()); | 1167 rect = LayoutRect(absoluteCaretBounds()); |
1168 break; | 1168 break; |
1169 case RangeSelection: | 1169 case RangeSelection: |
1170 rect = LayoutRect(revealExtentOption == RevealExtent ? absoluteCaretBoun
dsOf(createVisiblePosition(extent())) : enclosingIntRect(unclippedBounds())); | 1170 rect = LayoutRect(revealExtentOption == RevealExtent ? absoluteCaretBoun
dsOf(createVisiblePositionDeprecated(extent())) : enclosingIntRect(unclippedBoun
ds())); |
1171 break; | 1171 break; |
1172 } | 1172 } |
1173 | 1173 |
1174 Position start = this->start(); | 1174 Position start = this->start(); |
1175 DCHECK(start.anchorNode()); | 1175 DCHECK(start.anchorNode()); |
1176 if (start.anchorNode() && start.anchorNode()->layoutObject()) { | 1176 if (start.anchorNode() && start.anchorNode()->layoutObject()) { |
1177 // FIXME: This code only handles scrolling the startContainer's layer, b
ut | 1177 // FIXME: This code only handles scrolling the startContainer's layer, b
ut |
1178 // the selection rect could intersect more than just that. | 1178 // the selection rect could intersect more than just that. |
1179 if (DocumentLoader* documentLoader = m_frame->loader().documentLoader()) | 1179 if (DocumentLoader* documentLoader = m_frame->loader().documentLoader()) |
1180 documentLoader->initialScrollState().wasScrolledByUser = true; | 1180 documentLoader->initialScrollState().wasScrolledByUser = true; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 | 1380 |
1381 void showTree(const blink::FrameSelection* sel) | 1381 void showTree(const blink::FrameSelection* sel) |
1382 { | 1382 { |
1383 if (sel) | 1383 if (sel) |
1384 sel->showTreeForThis(); | 1384 sel->showTreeForThis(); |
1385 else | 1385 else |
1386 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1386 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
1387 } | 1387 } |
1388 | 1388 |
1389 #endif | 1389 #endif |
OLD | NEW |