| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } else if (baseRemoved || extentRemoved) { | 352 } else if (baseRemoved || extentRemoved) { |
| 353 // The base and/or extent are about to be removed, but the start and end
aren't. | 353 // The base and/or extent are about to be removed, but the start and end
aren't. |
| 354 // Change the base and extent to the start and end, but don't re-validat
e the | 354 // Change the base and extent to the start and end, but don't re-validat
e the |
| 355 // selection, since doing so could move the start and end into the node | 355 // selection, since doing so could move the start and end into the node |
| 356 // that is about to be removed. | 356 // that is about to be removed. |
| 357 if (m_selection.isBaseFirst()) | 357 if (m_selection.isBaseFirst()) |
| 358 m_selection.setWithoutValidation(m_selection.start(), m_selection.en
d()); | 358 m_selection.setWithoutValidation(m_selection.start(), m_selection.en
d()); |
| 359 else | 359 else |
| 360 m_selection.setWithoutValidation(m_selection.end(), m_selection.star
t()); | 360 m_selection.setWithoutValidation(m_selection.end(), m_selection.star
t()); |
| 361 } else if (RefPtr<Range> range = m_selection.firstRange()) { | 361 } else if (RefPtr<Range> range = m_selection.firstRange()) { |
| 362 TrackExceptionState es; | 362 TrackExceptionState exceptionState; |
| 363 Range::CompareResults compareResult = range->compareNode(&node, es); | 363 Range::CompareResults compareResult = range->compareNode(&node, exceptio
nState); |
| 364 if (!es.hadException() && (compareResult == Range::NODE_BEFORE_AND_AFTER
|| compareResult == Range::NODE_INSIDE)) { | 364 if (!exceptionState.hadException() && (compareResult == Range::NODE_BEFO
RE_AND_AFTER || compareResult == Range::NODE_INSIDE)) { |
| 365 // If we did nothing here, when this node's renderer was destroyed,
the rect that it | 365 // If we did nothing here, when this node's renderer was destroyed,
the rect that it |
| 366 // occupied would be invalidated, but, selection gaps that change as
a result of | 366 // occupied would be invalidated, but, selection gaps that change as
a result of |
| 367 // the removal wouldn't be invalidated. | 367 // the removal wouldn't be invalidated. |
| 368 // FIXME: Don't do so much unnecessary invalidation. | 368 // FIXME: Don't do so much unnecessary invalidation. |
| 369 clearRenderTreeSelection = true; | 369 clearRenderTreeSelection = true; |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 if (clearRenderTreeSelection) | 373 if (clearRenderTreeSelection) |
| 374 m_selection.start().document()->renderView()->clearSelection(); | 374 m_selection.start().document()->renderView()->clearSelection(); |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool clo
seTyping) | 1420 bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool clo
seTyping) |
| 1421 { | 1421 { |
| 1422 if (!range || !range->startContainer() || !range->endContainer()) | 1422 if (!range || !range->startContainer() || !range->endContainer()) |
| 1423 return false; | 1423 return false; |
| 1424 ASSERT(range->startContainer()->document() == range->endContainer()->documen
t()); | 1424 ASSERT(range->startContainer()->document() == range->endContainer()->documen
t()); |
| 1425 | 1425 |
| 1426 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1426 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 1427 | 1427 |
| 1428 // Non-collapsed ranges are not allowed to start at the end of a line that i
s wrapped, | 1428 // Non-collapsed ranges are not allowed to start at the end of a line that i
s wrapped, |
| 1429 // they start at the beginning of the next line instead | 1429 // they start at the beginning of the next line instead |
| 1430 TrackExceptionState es; | 1430 TrackExceptionState exceptionState; |
| 1431 bool collapsed = range->collapsed(es); | 1431 bool collapsed = range->collapsed(exceptionState); |
| 1432 if (es.hadException()) | 1432 if (exceptionState.hadException()) |
| 1433 return false; | 1433 return false; |
| 1434 | 1434 |
| 1435 // FIXME: Can we provide extentAffinity? | 1435 // FIXME: Can we provide extentAffinity? |
| 1436 VisiblePosition visibleStart(range->startPosition(), collapsed ? affinity :
DOWNSTREAM); | 1436 VisiblePosition visibleStart(range->startPosition(), collapsed ? affinity :
DOWNSTREAM); |
| 1437 VisiblePosition visibleEnd(range->endPosition(), SEL_DEFAULT_AFFINITY); | 1437 VisiblePosition visibleEnd(range->endPosition(), SEL_DEFAULT_AFFINITY); |
| 1438 setSelection(VisibleSelection(visibleStart, visibleEnd), ClearTypingStyle |
(closeTyping ? CloseTyping : 0)); | 1438 setSelection(VisibleSelection(visibleStart, visibleEnd), ClearTypingStyle |
(closeTyping ? CloseTyping : 0)); |
| 1439 return true; | 1439 return true; |
| 1440 } | 1440 } |
| 1441 | 1441 |
| 1442 bool FrameSelection::isInPasswordField() const | 1442 bool FrameSelection::isInPasswordField() const |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 sel.showTreeForThis(); | 1856 sel.showTreeForThis(); |
| 1857 } | 1857 } |
| 1858 | 1858 |
| 1859 void showTree(const WebCore::FrameSelection* sel) | 1859 void showTree(const WebCore::FrameSelection* sel) |
| 1860 { | 1860 { |
| 1861 if (sel) | 1861 if (sel) |
| 1862 sel->showTreeForThis(); | 1862 sel->showTreeForThis(); |
| 1863 } | 1863 } |
| 1864 | 1864 |
| 1865 #endif | 1865 #endif |
| OLD | NEW |