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

Side by Side Diff: Source/WebCore/editing/CompositeEditCommand.cpp

Issue 9570057: Merge 107761 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 9 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 | « LayoutTests/editing/inserting/delete-insignificant-text-crash-expected.txt ('k') | 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 * 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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 rebalanceWhitespaceAt(selection.start()); 521 rebalanceWhitespaceAt(selection.start());
522 if (selection.isRange()) 522 if (selection.isRange())
523 rebalanceWhitespaceAt(selection.end()); 523 rebalanceWhitespaceAt(selection.end());
524 } 524 }
525 525
526 void CompositeEditCommand::deleteInsignificantText(PassRefPtr<Text> textNode, un signed start, unsigned end) 526 void CompositeEditCommand::deleteInsignificantText(PassRefPtr<Text> textNode, un signed start, unsigned end)
527 { 527 {
528 if (!textNode || start >= end) 528 if (!textNode || start >= end)
529 return; 529 return;
530 530
531 document()->updateLayout();
532
531 RenderText* textRenderer = toRenderText(textNode->renderer()); 533 RenderText* textRenderer = toRenderText(textNode->renderer());
532 if (!textRenderer) 534 if (!textRenderer)
533 return; 535 return;
534 536
535 Vector<InlineTextBox*> sortedTextBoxes; 537 Vector<InlineTextBox*> sortedTextBoxes;
536 size_t sortedTextBoxesPosition = 0; 538 size_t sortedTextBoxesPosition = 0;
537 539
538 for (InlineTextBox* textBox = textRenderer->firstTextBox(); textBox; textBox = textBox->nextTextBox()) 540 for (InlineTextBox* textBox = textRenderer->firstTextBox(); textBox; textBox = textBox->nextTextBox())
539 sortedTextBoxes.append(textBox); 541 sortedTextBoxes.append(textBox);
540 542
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 } 605 }
604 606
605 void CompositeEditCommand::deleteInsignificantText(const Position& start, const Position& end) 607 void CompositeEditCommand::deleteInsignificantText(const Position& start, const Position& end)
606 { 608 {
607 if (start.isNull() || end.isNull()) 609 if (start.isNull() || end.isNull())
608 return; 610 return;
609 611
610 if (comparePositions(start, end) >= 0) 612 if (comparePositions(start, end) >= 0)
611 return; 613 return;
612 614
613 Node* next; 615 Vector<RefPtr<Text> > nodes;
614 for (Node* node = start.deprecatedNode(); node; node = next) { 616 for (Node* node = start.deprecatedNode(); node; node = node->traverseNextNod e()) {
615 next = node->traverseNextNode(); 617 if (node->isTextNode())
616 if (node->isTextNode()) { 618 nodes.append(static_cast<Text*>(node));
617 Text* textNode = static_cast<Text*>(node);
618 int startOffset = node == start.deprecatedNode() ? start.deprecatedE ditingOffset() : 0;
619 int endOffset = node == end.deprecatedNode() ? end.deprecatedEditing Offset() : static_cast<int>(textNode->length());
620 deleteInsignificantText(textNode, startOffset, endOffset);
621 }
622 if (node == end.deprecatedNode()) 619 if (node == end.deprecatedNode())
623 break; 620 break;
624 } 621 }
622
623 for (size_t i = 0; i < nodes.size(); ++i) {
624 Text* textNode = nodes[i].get();
625 int startOffset = textNode == start.deprecatedNode() ? start.deprecatedE ditingOffset() : 0;
626 int endOffset = textNode == end.deprecatedNode() ? end.deprecatedEditing Offset() : static_cast<int>(textNode->length());
627 deleteInsignificantText(textNode, startOffset, endOffset);
628 }
625 } 629 }
626 630
627 void CompositeEditCommand::deleteInsignificantTextDownstream(const Position& pos ) 631 void CompositeEditCommand::deleteInsignificantTextDownstream(const Position& pos )
628 { 632 {
629 Position end = VisiblePosition(pos, VP_DEFAULT_AFFINITY).next().deepEquivale nt().downstream(); 633 Position end = VisiblePosition(pos, VP_DEFAULT_AFFINITY).next().deepEquivale nt().downstream();
630 deleteInsignificantText(pos, end); 634 deleteInsignificantText(pos, end);
631 } 635 }
632 636
633 PassRefPtr<Node> CompositeEditCommand::appendBlockPlaceholder(PassRefPtr<Element > container) 637 PassRefPtr<Node> CompositeEditCommand::appendBlockPlaceholder(PassRefPtr<Element > container)
634 { 638 {
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 return node.release(); 1258 return node.release();
1255 } 1259 }
1256 1260
1257 PassRefPtr<Element> createBlockPlaceholderElement(Document* document) 1261 PassRefPtr<Element> createBlockPlaceholderElement(Document* document)
1258 { 1262 {
1259 RefPtr<Element> breakNode = document->createElement(brTag, false); 1263 RefPtr<Element> breakNode = document->createElement(brTag, false);
1260 return breakNode.release(); 1264 return breakNode.release();
1261 } 1265 }
1262 1266
1263 } // namespace WebCore 1267 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/editing/inserting/delete-insignificant-text-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698