| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 Position end = updatePostionAfterAdoptingTextNodeSplit(m_selection.end(), ol
dNode); | 464 Position end = updatePostionAfterAdoptingTextNodeSplit(m_selection.end(), ol
dNode); |
| 465 updateSelectionIfNeeded(base, extent, start, end); | 465 updateSelectionIfNeeded(base, extent, start, end); |
| 466 } | 466 } |
| 467 | 467 |
| 468 void FrameSelection::updateSelectionIfNeeded(const Position& base, const Positio
n& extent, const Position& start, const Position& end) | 468 void FrameSelection::updateSelectionIfNeeded(const Position& base, const Positio
n& extent, const Position& start, const Position& end) |
| 469 { | 469 { |
| 470 if (base == m_selection.base() && extent == m_selection.extent() && start ==
m_selection.start() && end == m_selection.end()) | 470 if (base == m_selection.base() && extent == m_selection.extent() && start ==
m_selection.start() && end == m_selection.end()) |
| 471 return; | 471 return; |
| 472 VisibleSelection newSelection; | 472 VisibleSelection newSelection; |
| 473 newSelection.setWithoutValidation(base, extent); | 473 newSelection.setWithoutValidation(base, extent); |
| 474 m_frame->document()->updateLayout(); | |
| 475 setSelection(newSelection, DoNotSetFocus); | 474 setSelection(newSelection, DoNotSetFocus); |
| 476 } | 475 } |
| 477 | 476 |
| 478 TextDirection FrameSelection::directionOfEnclosingBlock() | 477 TextDirection FrameSelection::directionOfEnclosingBlock() |
| 479 { | 478 { |
| 480 return WebCore::directionOfEnclosingBlock(m_selection.extent()); | 479 return WebCore::directionOfEnclosingBlock(m_selection.extent()); |
| 481 } | 480 } |
| 482 | 481 |
| 483 TextDirection FrameSelection::directionOfSelection() | 482 TextDirection FrameSelection::directionOfSelection() |
| 484 { | 483 { |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 selectFrameElementInParentIfFullySelected(); | 1401 selectFrameElementInParentIfFullySelected(); |
| 1403 notifyRendererOfSelectionChange(UserTriggered); | 1402 notifyRendererOfSelectionChange(UserTriggered); |
| 1404 } | 1403 } |
| 1405 | 1404 |
| 1406 bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, SetSelec
tionOptions options) | 1405 bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, SetSelec
tionOptions options) |
| 1407 { | 1406 { |
| 1408 if (!range || !range->startContainer() || !range->endContainer()) | 1407 if (!range || !range->startContainer() || !range->endContainer()) |
| 1409 return false; | 1408 return false; |
| 1410 ASSERT(range->startContainer()->document() == range->endContainer()->documen
t()); | 1409 ASSERT(range->startContainer()->document() == range->endContainer()->documen
t()); |
| 1411 | 1410 |
| 1412 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | |
| 1413 | |
| 1414 // Non-collapsed ranges are not allowed to start at the end of a line that i
s wrapped, | 1411 // Non-collapsed ranges are not allowed to start at the end of a line that i
s wrapped, |
| 1415 // they start at the beginning of the next line instead | 1412 // they start at the beginning of the next line instead |
| 1416 m_logicalRange = nullptr; | 1413 m_logicalRange = nullptr; |
| 1417 stopObservingVisibleSelectionChangeIfNecessary(); | 1414 stopObservingVisibleSelectionChangeIfNecessary(); |
| 1418 | 1415 |
| 1419 // FIXME: Can we provide extentAffinity? | 1416 VisibleSelection newSelection(range, affinity); |
| 1420 VisiblePosition visibleStart(range->startPosition(), range->collapsed() ? af
finity : DOWNSTREAM); | 1417 setSelection(newSelection, options); |
| 1421 VisiblePosition visibleEnd(range->endPosition(), SEL_DEFAULT_AFFINITY); | |
| 1422 setSelection(VisibleSelection(visibleStart, visibleEnd), options); | |
| 1423 | 1418 |
| 1424 m_logicalRange = range->cloneRange(); | 1419 m_logicalRange = range->cloneRange(); |
| 1425 startObservingVisibleSelectionChange(); | 1420 startObservingVisibleSelectionChange(); |
| 1426 | 1421 |
| 1427 return true; | 1422 return true; |
| 1428 } | 1423 } |
| 1429 | 1424 |
| 1430 PassRefPtrWillBeRawPtr<Range> FrameSelection::firstRange() const | 1425 PassRefPtrWillBeRawPtr<Range> FrameSelection::firstRange() const |
| 1431 { | 1426 { |
| 1432 if (m_logicalRange) | 1427 if (m_logicalRange) |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1886 sel.showTreeForThis(); | 1881 sel.showTreeForThis(); |
| 1887 } | 1882 } |
| 1888 | 1883 |
| 1889 void showTree(const WebCore::FrameSelection* sel) | 1884 void showTree(const WebCore::FrameSelection* sel) |
| 1890 { | 1885 { |
| 1891 if (sel) | 1886 if (sel) |
| 1892 sel->showTreeForThis(); | 1887 sel->showTreeForThis(); |
| 1893 } | 1888 } |
| 1894 | 1889 |
| 1895 #endif | 1890 #endif |
| OLD | NEW |