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

Side by Side Diff: Source/core/editing/FrameSelection.cpp

Issue 229793004: Add CharacterData.deleteData()/replaceData() overflow handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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 * 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 unsigned positionOffset = static_cast<unsigned>(position.offsetInContainerNo de()); 383 unsigned positionOffset = static_cast<unsigned>(position.offsetInContainerNo de());
384 // Replacing text can be viewed as a deletion followed by insertion. 384 // Replacing text can be viewed as a deletion followed by insertion.
385 if (positionOffset >= offset && positionOffset <= offset + oldLength) 385 if (positionOffset >= offset && positionOffset <= offset + oldLength)
386 positionOffset = offset; 386 positionOffset = offset;
387 387
388 // Adjust the offset if the position is after the end of the deleted content s 388 // Adjust the offset if the position is after the end of the deleted content s
389 // (positionOffset > offset + oldLength) to avoid having a stale offset. 389 // (positionOffset > offset + oldLength) to avoid having a stale offset.
390 if (positionOffset > offset + oldLength) 390 if (positionOffset > offset + oldLength)
391 positionOffset = positionOffset - oldLength + newLength; 391 positionOffset = positionOffset - oldLength + newLength;
392 392
393 ASSERT(positionOffset <= node->length()); 393 ASSERT_WITH_SECURITY_IMPLICATION(positionOffset <= node->length());
394 // CharacterNode in VisibleSelection must be Text node, because Comment 394 // CharacterNode in VisibleSelection must be Text node, because Comment
395 // and ProcessingInstruction node aren't visible. 395 // and ProcessingInstruction node aren't visible.
396 return Position(toText(node), positionOffset); 396 return Position(toText(node), positionOffset);
397 } 397 }
398 398
399 void FrameSelection::didUpdateCharacterData(CharacterData* node, unsigned offset , unsigned oldLength, unsigned newLength) 399 void FrameSelection::didUpdateCharacterData(CharacterData* node, unsigned offset , unsigned oldLength, unsigned newLength)
400 { 400 {
401 // The fragment check is a performance optimization. See http://trac.webkit. org/changeset/30062. 401 // The fragment check is a performance optimization. See http://trac.webkit. org/changeset/30062.
402 if (isNone() || !node || !node->inDocument()) 402 if (isNone() || !node || !node->inDocument())
403 return; 403 return;
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 sel.showTreeForThis(); 1876 sel.showTreeForThis();
1877 } 1877 }
1878 1878
1879 void showTree(const WebCore::FrameSelection* sel) 1879 void showTree(const WebCore::FrameSelection* sel)
1880 { 1880 {
1881 if (sel) 1881 if (sel)
1882 sel->showTreeForThis(); 1882 sel->showTreeForThis();
1883 } 1883 }
1884 1884
1885 #endif 1885 #endif
OLDNEW
« Source/core/dom/CharacterData.cpp ('K') | « Source/core/dom/CharacterData.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698