Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: third_party/WebKit/Source/core/dom/Range.cpp

Issue 2265853002: boundaryTextInserted/Removed() should not call markValid() for irrelavent changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 // FIXME: Once DOMNodeRemovedFromDocument mutation event removed, we 1379 // FIXME: Once DOMNodeRemovedFromDocument mutation event removed, we
1380 // should change following if-statement to DCHECK(!node->parentNode). 1380 // should change following if-statement to DCHECK(!node->parentNode).
1381 if (!node.parentNode()) 1381 if (!node.parentNode())
1382 return; 1382 return;
1383 boundaryNodeWillBeRemoved(m_start, node); 1383 boundaryNodeWillBeRemoved(m_start, node);
1384 boundaryNodeWillBeRemoved(m_end, node); 1384 boundaryNodeWillBeRemoved(m_end, node);
1385 } 1385 }
1386 1386
1387 static inline void boundaryTextInserted(RangeBoundaryPoint& boundary, Node* text , unsigned offset, unsigned length) 1387 static inline void boundaryTextInserted(RangeBoundaryPoint& boundary, Node* text , unsigned offset, unsigned length)
1388 { 1388 {
1389 boundary.markValid();
1390 if (boundary.container() != text) 1389 if (boundary.container() != text)
1391 return; 1390 return;
1391 boundary.markValid();
1392 unsigned boundaryOffset = boundary.offset(); 1392 unsigned boundaryOffset = boundary.offset();
1393 if (offset >= boundaryOffset) 1393 if (offset >= boundaryOffset)
1394 return; 1394 return;
1395 boundary.setOffset(boundaryOffset + length); 1395 boundary.setOffset(boundaryOffset + length);
1396 } 1396 }
1397 1397
1398 void Range::didInsertText(Node* text, unsigned offset, unsigned length) 1398 void Range::didInsertText(Node* text, unsigned offset, unsigned length)
1399 { 1399 {
1400 DCHECK(text); 1400 DCHECK(text);
1401 DCHECK_EQ(text->document(), m_ownerDocument); 1401 DCHECK_EQ(text->document(), m_ownerDocument);
1402 boundaryTextInserted(m_start, text, offset, length); 1402 boundaryTextInserted(m_start, text, offset, length);
1403 boundaryTextInserted(m_end, text, offset, length); 1403 boundaryTextInserted(m_end, text, offset, length);
1404 } 1404 }
1405 1405
1406 static inline void boundaryTextRemoved(RangeBoundaryPoint& boundary, Node* text, unsigned offset, unsigned length) 1406 static inline void boundaryTextRemoved(RangeBoundaryPoint& boundary, Node* text, unsigned offset, unsigned length)
1407 { 1407 {
1408 boundary.markValid();
1409 if (boundary.container() != text) 1408 if (boundary.container() != text)
1410 return; 1409 return;
1410 boundary.markValid();
1411 unsigned boundaryOffset = boundary.offset(); 1411 unsigned boundaryOffset = boundary.offset();
1412 if (offset >= boundaryOffset) 1412 if (offset >= boundaryOffset)
1413 return; 1413 return;
1414 if (offset + length >= boundaryOffset) 1414 if (offset + length >= boundaryOffset)
1415 boundary.setOffset(offset); 1415 boundary.setOffset(offset);
1416 else 1416 else
1417 boundary.setOffset(boundaryOffset - length); 1417 boundary.setOffset(boundaryOffset - length);
1418 } 1418 }
1419 1419
1420 void Range::didRemoveText(Node* text, unsigned offset, unsigned length) 1420 void Range::didRemoveText(Node* text, unsigned offset, unsigned length)
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 { 1587 {
1588 if (range && range->boundaryPointsValid()) { 1588 if (range && range->boundaryPointsValid()) {
1589 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1589 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1590 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1590 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1591 } else { 1591 } else {
1592 fprintf(stderr, "Cannot show tree if range is null, or if boundary point s are invalid.\n"); 1592 fprintf(stderr, "Cannot show tree if range is null, or if boundary point s are invalid.\n");
1593 } 1593 }
1594 } 1594 }
1595 1595
1596 #endif 1596 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698