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

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

Issue 2254423002: boundaryTextInserted/Removed() should not call markValid() for irrelavent changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit test 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
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();
yosin_UTC9 2016/08/19 06:02:43 Sorry, I don't understand this change. Changing d
yosin_UTC9 2016/08/19 06:25:48 Discussed offline. I understand this patch is corr
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 { 1591 {
1592 if (range && range->boundaryPointsValid()) { 1592 if (range && range->boundaryPointsValid()) {
1593 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E"); 1593 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r ange->endContainer(), "E");
1594 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset()); 1594 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset (), range->endOffset());
1595 } else { 1595 } else {
1596 fprintf(stderr, "Cannot show tree if range is null, or if boundary point s are invalid.\n"); 1596 fprintf(stderr, "Cannot show tree if range is null, or if boundary point s are invalid.\n");
1597 } 1597 }
1598 } 1598 }
1599 1599
1600 #endif 1600 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/RangeTest.cpp » ('j') | third_party/WebKit/Source/core/dom/RangeTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698