| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 unsigned positionOffset = static_cast<unsigned>(position.offsetInContainerNo
de()); | 376 unsigned positionOffset = static_cast<unsigned>(position.offsetInContainerNo
de()); |
| 377 // Replacing text can be viewed as a deletion followed by insertion. | 377 // Replacing text can be viewed as a deletion followed by insertion. |
| 378 if (positionOffset >= offset && positionOffset <= offset + oldLength) | 378 if (positionOffset >= offset && positionOffset <= offset + oldLength) |
| 379 positionOffset = offset; | 379 positionOffset = offset; |
| 380 | 380 |
| 381 // Adjust the offset if the position is after the end of the deleted content
s | 381 // Adjust the offset if the position is after the end of the deleted content
s |
| 382 // (positionOffset > offset + oldLength) to avoid having a stale offset. | 382 // (positionOffset > offset + oldLength) to avoid having a stale offset. |
| 383 if (positionOffset > offset + oldLength) | 383 if (positionOffset > offset + oldLength) |
| 384 positionOffset = positionOffset - oldLength + newLength; | 384 positionOffset = positionOffset - oldLength + newLength; |
| 385 | 385 |
| 386 ASSERT(positionOffset <= node->length()); | 386 ASSERT_WITH_SECURITY_IMPLICATION(positionOffset <= node->length()); |
| 387 // CharacterNode in VisibleSelection must be Text node, because Comment | 387 // CharacterNode in VisibleSelection must be Text node, because Comment |
| 388 // and ProcessingInstruction node aren't visible. | 388 // and ProcessingInstruction node aren't visible. |
| 389 return Position(toText(node), positionOffset); | 389 return Position(toText(node), positionOffset); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void FrameSelection::didUpdateCharacterData(CharacterData* node, unsigned offset
, unsigned oldLength, unsigned newLength) | 392 void FrameSelection::didUpdateCharacterData(CharacterData* node, unsigned offset
, unsigned oldLength, unsigned newLength) |
| 393 { | 393 { |
| 394 // The fragment check is a performance optimization. See http://trac.webkit.
org/changeset/30062. | 394 // The fragment check is a performance optimization. See http://trac.webkit.
org/changeset/30062. |
| 395 if (isNone() || !node || !node->inDocument()) | 395 if (isNone() || !node || !node->inDocument()) |
| 396 return; | 396 return; |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 sel.showTreeForThis(); | 1830 sel.showTreeForThis(); |
| 1831 } | 1831 } |
| 1832 | 1832 |
| 1833 void showTree(const WebCore::FrameSelection* sel) | 1833 void showTree(const WebCore::FrameSelection* sel) |
| 1834 { | 1834 { |
| 1835 if (sel) | 1835 if (sel) |
| 1836 sel->showTreeForThis(); | 1836 sel->showTreeForThis(); |
| 1837 } | 1837 } |
| 1838 | 1838 |
| 1839 #endif | 1839 #endif |
| OLD | NEW |