OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 DeleteFromTextNodeCommand::create(node, offset, count), | 525 DeleteFromTextNodeCommand::create(node, offset, count), |
526 ASSERT_NO_EDITING_ABORT); | 526 ASSERT_NO_EDITING_ABORT); |
527 } | 527 } |
528 | 528 |
529 void CompositeEditCommand::replaceTextInNode(Text* node, | 529 void CompositeEditCommand::replaceTextInNode(Text* node, |
530 unsigned offset, | 530 unsigned offset, |
531 unsigned count, | 531 unsigned count, |
532 const String& replacementText) { | 532 const String& replacementText) { |
533 // DeleteFromTextNodeCommand and InsertIntoTextNodeCommand are never | 533 // DeleteFromTextNodeCommand and InsertIntoTextNodeCommand are never |
534 // aborted. | 534 // aborted. |
535 applyCommandToComposite( | 535 |
536 DeleteFromTextNodeCommand::create(node, offset, count), | 536 // Insert must happen before delete to preserve markers correctly |
537 ASSERT_NO_EDITING_ABORT); | 537 // See algorithm in https://dom.spec.whatwg.org/#concept-cd-replace |
538 if (!replacementText.isEmpty()) | 538 if (!replacementText.isEmpty()) |
539 applyCommandToComposite( | 539 applyCommandToComposite( |
540 InsertIntoTextNodeCommand::create(node, offset, replacementText), | 540 InsertIntoTextNodeCommand::create(node, offset, replacementText), |
541 ASSERT_NO_EDITING_ABORT); | 541 ASSERT_NO_EDITING_ABORT); |
542 applyCommandToComposite(DeleteFromTextNodeCommand::create( | |
rlanday
2017/01/31 19:50:21
Again, hope this doesn't break anything...
rlanday
2017/01/31 22:33:45
I have a test case that requires this fix to work
esprehn
2017/01/31 22:41:34
What did the code do before and what's different?
rlanday
2017/01/31 22:58:43
Actually this doesn't break any of the webkit_unit
| |
543 node, offset + replacementText.length(), count), | |
544 ASSERT_NO_EDITING_ABORT); | |
542 } | 545 } |
543 | 546 |
544 Position CompositeEditCommand::replaceSelectedTextInNode(const String& text) { | 547 Position CompositeEditCommand::replaceSelectedTextInNode(const String& text) { |
545 Position start = endingSelection().start(); | 548 Position start = endingSelection().start(); |
546 Position end = endingSelection().end(); | 549 Position end = endingSelection().end(); |
547 if (start.computeContainerNode() != end.computeContainerNode() || | 550 if (start.computeContainerNode() != end.computeContainerNode() || |
548 !start.computeContainerNode()->isTextNode() || | 551 !start.computeContainerNode()->isTextNode() || |
549 isTabHTMLSpanElementTextNode(start.computeContainerNode())) | 552 isTabHTMLSpanElementTextNode(start.computeContainerNode())) |
550 return Position(); | 553 return Position(); |
551 | 554 |
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1985 | 1988 |
1986 DEFINE_TRACE(CompositeEditCommand) { | 1989 DEFINE_TRACE(CompositeEditCommand) { |
1987 visitor->trace(m_commands); | 1990 visitor->trace(m_commands); |
1988 visitor->trace(m_startingSelection); | 1991 visitor->trace(m_startingSelection); |
1989 visitor->trace(m_endingSelection); | 1992 visitor->trace(m_endingSelection); |
1990 visitor->trace(m_undoStep); | 1993 visitor->trace(m_undoStep); |
1991 EditCommand::trace(visitor); | 1994 EditCommand::trace(visitor); |
1992 } | 1995 } |
1993 | 1996 |
1994 } // namespace blink | 1997 } // namespace blink |
OLD | NEW |