| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Even if selection was not changed, selection offsets may have been ch
anged. | 213 // Even if selection was not changed, selection offsets may have been ch
anged. |
| 214 notifyRendererOfSelectionChange(userTriggered); | 214 notifyRendererOfSelectionChange(userTriggered); |
| 215 return; | 215 return; |
| 216 } | 216 } |
| 217 | 217 |
| 218 VisibleSelection oldSelection = m_selection; | 218 VisibleSelection oldSelection = m_selection; |
| 219 | 219 |
| 220 m_selection = s; | 220 m_selection = s; |
| 221 setCaretRectNeedsUpdate(); | 221 setCaretRectNeedsUpdate(); |
| 222 | 222 |
| 223 if (!s.isNone()) | 223 if (!s.isNone() && !(options & DoNotSetFocus)) |
| 224 setFocusedNodeIfNeeded(); | 224 setFocusedNodeIfNeeded(); |
| 225 | 225 |
| 226 updateAppearance(); | 226 updateAppearance(); |
| 227 | 227 |
| 228 // Always clear the x position used for vertical arrow navigation. | 228 // Always clear the x position used for vertical arrow navigation. |
| 229 // It will be restored by the vertical arrow navigation code if necessary. | 229 // It will be restored by the vertical arrow navigation code if necessary. |
| 230 m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); | 230 m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); |
| 231 selectFrameElementInParentIfFullySelected(); | 231 selectFrameElementInParentIfFullySelected(); |
| 232 notifyRendererOfSelectionChange(userTriggered); | 232 notifyRendererOfSelectionChange(userTriggered); |
| 233 m_frame->editor()->respondToChangedSelection(oldSelection, options); | 233 m_frame->editor()->respondToChangedSelection(oldSelection, options); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // the removal wouldn't be invalidated. | 319 // the removal wouldn't be invalidated. |
| 320 // FIXME: Don't do so much unnecessary invalidation. | 320 // FIXME: Don't do so much unnecessary invalidation. |
| 321 clearRenderTreeSelection = true; | 321 clearRenderTreeSelection = true; |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 | 324 |
| 325 if (clearRenderTreeSelection) | 325 if (clearRenderTreeSelection) |
| 326 clearRenderViewSelection(m_selection.start()); | 326 clearRenderViewSelection(m_selection.start()); |
| 327 | 327 |
| 328 if (clearDOMTreeSelection) | 328 if (clearDOMTreeSelection) |
| 329 setSelection(VisibleSelection(), 0); | 329 setSelection(VisibleSelection(), DoNotSetFocus); |
| 330 } | 330 } |
| 331 | 331 |
| 332 enum EndPointType { EndPointIsStart, EndPointIsEnd }; | 332 enum EndPointType { EndPointIsStart, EndPointIsEnd }; |
| 333 | 333 |
| 334 static bool shouldRemovePositionAfterAdoptingTextReplacement(Position& position,
EndPointType type, CharacterData* node, unsigned offset, unsigned oldLength, un
signed newLength) | 334 static bool shouldRemovePositionAfterAdoptingTextReplacement(Position& position,
EndPointType type, CharacterData* node, unsigned offset, unsigned oldLength, un
signed newLength) |
| 335 { | 335 { |
| 336 if (!position.anchorNode() || position.anchorNode() != node || position.anch
orType() != Position::PositionIsOffsetInAnchor) | 336 if (!position.anchorNode() || position.anchorNode() != node || position.anch
orType() != Position::PositionIsOffsetInAnchor) |
| 337 return false; | 337 return false; |
| 338 | 338 |
| 339 ASSERT(position.offsetInContainerNode() >= 0); | 339 ASSERT(position.offsetInContainerNode() >= 0); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 370 VisibleSelection newSelection; | 370 VisibleSelection newSelection; |
| 371 if (!shouldRemoveBase && !shouldRemoveExtent) | 371 if (!shouldRemoveBase && !shouldRemoveExtent) |
| 372 newSelection.setWithoutValidation(base, extent); | 372 newSelection.setWithoutValidation(base, extent); |
| 373 else { | 373 else { |
| 374 if (newSelection.isBaseFirst()) | 374 if (newSelection.isBaseFirst()) |
| 375 newSelection.setWithoutValidation(start, end); | 375 newSelection.setWithoutValidation(start, end); |
| 376 else | 376 else |
| 377 newSelection.setWithoutValidation(end, start); | 377 newSelection.setWithoutValidation(end, start); |
| 378 } | 378 } |
| 379 m_frame->document()->updateLayout(); | 379 m_frame->document()->updateLayout(); |
| 380 setSelection(newSelection, 0); | 380 setSelection(newSelection, DoNotSetFocus); |
| 381 return; | 381 return; |
| 382 } | 382 } |
| 383 | 383 |
| 384 respondToNodeModification(node, shouldRemoveBase, shouldRemoveExtent, should
RemoveStart, shouldRemoveEnd); | 384 respondToNodeModification(node, shouldRemoveBase, shouldRemoveExtent, should
RemoveStart, shouldRemoveEnd); |
| 385 } | 385 } |
| 386 | 386 |
| 387 TextDirection FrameSelection::directionOfEnclosingBlock() | 387 TextDirection FrameSelection::directionOfEnclosingBlock() |
| 388 { | 388 { |
| 389 return WebCore::directionOfEnclosingBlock(m_selection.extent()); | 389 return WebCore::directionOfEnclosingBlock(m_selection.extent()); |
| 390 } | 390 } |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 sel.showTreeForThis(); | 1907 sel.showTreeForThis(); |
| 1908 } | 1908 } |
| 1909 | 1909 |
| 1910 void showTree(const WebCore::FrameSelection* sel) | 1910 void showTree(const WebCore::FrameSelection* sel) |
| 1911 { | 1911 { |
| 1912 if (sel) | 1912 if (sel) |
| 1913 sel->showTreeForThis(); | 1913 sel->showTreeForThis(); |
| 1914 } | 1914 } |
| 1915 | 1915 |
| 1916 #endif | 1916 #endif |
| OLD | NEW |