OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) | 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) |
4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) | 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) |
5 * (C) 2001 Peter Kelly (pmk@post.com) | 5 * (C) 2001 Peter Kelly (pmk@post.com) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 { | 1332 { |
1333 if (a == b) | 1333 if (a == b) |
1334 return true; | 1334 return true; |
1335 if (!a || !b) | 1335 if (!a || !b) |
1336 return false; | 1336 return false; |
1337 return a->startPosition() == b->startPosition() && a->endPosition() == b->en
dPosition(); | 1337 return a->startPosition() == b->startPosition() && a->endPosition() == b->en
dPosition(); |
1338 } | 1338 } |
1339 | 1339 |
1340 static inline void boundaryNodeChildrenChanged(RangeBoundaryPoint& boundary, Con
tainerNode* container) | 1340 static inline void boundaryNodeChildrenChanged(RangeBoundaryPoint& boundary, Con
tainerNode* container) |
1341 { | 1341 { |
| 1342 boundary.markValid(); |
1342 if (!boundary.childBefore()) | 1343 if (!boundary.childBefore()) |
1343 return; | 1344 return; |
1344 if (boundary.container() != container) | 1345 if (boundary.container() != container) |
1345 return; | 1346 return; |
1346 boundary.invalidateOffset(); | 1347 boundary.invalidateOffset(); |
1347 } | 1348 } |
1348 | 1349 |
1349 void Range::nodeChildrenChanged(ContainerNode* container) | 1350 void Range::nodeChildrenChanged(ContainerNode* container) |
1350 { | 1351 { |
1351 DCHECK(container); | 1352 DCHECK(container); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 // FIXME: Once DOMNodeRemovedFromDocument mutation event removed, we | 1402 // FIXME: Once DOMNodeRemovedFromDocument mutation event removed, we |
1402 // should change following if-statement to DCHECK(!node->parentNode). | 1403 // should change following if-statement to DCHECK(!node->parentNode). |
1403 if (!node.parentNode()) | 1404 if (!node.parentNode()) |
1404 return; | 1405 return; |
1405 boundaryNodeWillBeRemoved(m_start, node); | 1406 boundaryNodeWillBeRemoved(m_start, node); |
1406 boundaryNodeWillBeRemoved(m_end, node); | 1407 boundaryNodeWillBeRemoved(m_end, node); |
1407 } | 1408 } |
1408 | 1409 |
1409 static inline void boundaryTextInserted(RangeBoundaryPoint& boundary, Node* text
, unsigned offset, unsigned length) | 1410 static inline void boundaryTextInserted(RangeBoundaryPoint& boundary, Node* text
, unsigned offset, unsigned length) |
1410 { | 1411 { |
| 1412 boundary.markValid(); |
1411 if (boundary.container() != text) | 1413 if (boundary.container() != text) |
1412 return; | 1414 return; |
1413 unsigned boundaryOffset = boundary.offset(); | 1415 unsigned boundaryOffset = boundary.offset(); |
1414 if (offset >= boundaryOffset) | 1416 if (offset >= boundaryOffset) |
1415 return; | 1417 return; |
1416 boundary.setOffset(boundaryOffset + length); | 1418 boundary.setOffset(boundaryOffset + length); |
1417 } | 1419 } |
1418 | 1420 |
1419 void Range::didInsertText(Node* text, unsigned offset, unsigned length) | 1421 void Range::didInsertText(Node* text, unsigned offset, unsigned length) |
1420 { | 1422 { |
1421 DCHECK(text); | 1423 DCHECK(text); |
1422 DCHECK_EQ(text->document(), m_ownerDocument); | 1424 DCHECK_EQ(text->document(), m_ownerDocument); |
1423 boundaryTextInserted(m_start, text, offset, length); | 1425 boundaryTextInserted(m_start, text, offset, length); |
1424 boundaryTextInserted(m_end, text, offset, length); | 1426 boundaryTextInserted(m_end, text, offset, length); |
1425 } | 1427 } |
1426 | 1428 |
1427 static inline void boundaryTextRemoved(RangeBoundaryPoint& boundary, Node* text,
unsigned offset, unsigned length) | 1429 static inline void boundaryTextRemoved(RangeBoundaryPoint& boundary, Node* text,
unsigned offset, unsigned length) |
1428 { | 1430 { |
| 1431 boundary.markValid(); |
1429 if (boundary.container() != text) | 1432 if (boundary.container() != text) |
1430 return; | 1433 return; |
1431 unsigned boundaryOffset = boundary.offset(); | 1434 unsigned boundaryOffset = boundary.offset(); |
1432 if (offset >= boundaryOffset) | 1435 if (offset >= boundaryOffset) |
1433 return; | 1436 return; |
1434 if (offset + length >= boundaryOffset) | 1437 if (offset + length >= boundaryOffset) |
1435 boundary.setOffset(offset); | 1438 boundary.setOffset(offset); |
1436 else | 1439 else |
1437 boundary.setOffset(boundaryOffset - length); | 1440 boundary.setOffset(boundaryOffset - length); |
1438 } | 1441 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 { | 1610 { |
1608 if (range && range->boundaryPointsValid()) { | 1611 if (range && range->boundaryPointsValid()) { |
1609 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 1612 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1610 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 1613 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1611 } else { | 1614 } else { |
1612 fprintf(stderr, "Cannot show tree if range is null, or if boundary point
s are invalid.\n"); | 1615 fprintf(stderr, "Cannot show tree if range is null, or if boundary point
s are invalid.\n"); |
1613 } | 1616 } |
1614 } | 1617 } |
1615 | 1618 |
1616 #endif | 1619 #endif |
OLD | NEW |