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

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

Issue 182383012: Have positionInParentBeforeNode() / positionInParentAfterNode() take a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/PositionIterator.cpp ('k') | Source/core/editing/CompositeEditCommand.h » ('j') | 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, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008, 2009 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 if (hasTextDirection) { 605 if (hasTextDirection) {
606 // Leave alone an ancestor that provides the desired single level embedd ing, if there is one. 606 // Leave alone an ancestor that provides the desired single level embedd ing, if there is one.
607 HTMLElement* startUnsplitAncestor = splitAncestorsWithUnicodeBidi(start. deprecatedNode(), true, textDirection); 607 HTMLElement* startUnsplitAncestor = splitAncestorsWithUnicodeBidi(start. deprecatedNode(), true, textDirection);
608 HTMLElement* endUnsplitAncestor = splitAncestorsWithUnicodeBidi(end.depr ecatedNode(), false, textDirection); 608 HTMLElement* endUnsplitAncestor = splitAncestorsWithUnicodeBidi(end.depr ecatedNode(), false, textDirection);
609 removeEmbeddingUpToEnclosingBlock(start.deprecatedNode(), startUnsplitAn cestor); 609 removeEmbeddingUpToEnclosingBlock(start.deprecatedNode(), startUnsplitAn cestor);
610 removeEmbeddingUpToEnclosingBlock(end.deprecatedNode(), endUnsplitAncest or); 610 removeEmbeddingUpToEnclosingBlock(end.deprecatedNode(), endUnsplitAncest or);
611 611
612 // Avoid removing the dir attribute and the unicode-bidi and direction p roperties from the unsplit ancestors. 612 // Avoid removing the dir attribute and the unicode-bidi and direction p roperties from the unsplit ancestors.
613 Position embeddingRemoveStart = removeStart; 613 Position embeddingRemoveStart = removeStart;
614 if (startUnsplitAncestor && nodeFullySelected(startUnsplitAncestor, remo veStart, end)) 614 if (startUnsplitAncestor && nodeFullySelected(startUnsplitAncestor, remo veStart, end))
615 embeddingRemoveStart = positionInParentAfterNode(startUnsplitAncesto r); 615 embeddingRemoveStart = positionInParentAfterNode(*startUnsplitAncest or);
616 616
617 Position embeddingRemoveEnd = end; 617 Position embeddingRemoveEnd = end;
618 if (endUnsplitAncestor && nodeFullySelected(endUnsplitAncestor, removeSt art, end)) 618 if (endUnsplitAncestor && nodeFullySelected(endUnsplitAncestor, removeSt art, end))
619 embeddingRemoveEnd = positionInParentBeforeNode(endUnsplitAncestor). downstream(); 619 embeddingRemoveEnd = positionInParentBeforeNode(*endUnsplitAncestor) .downstream();
620 620
621 if (embeddingRemoveEnd != removeStart || embeddingRemoveEnd != end) { 621 if (embeddingRemoveEnd != removeStart || embeddingRemoveEnd != end) {
622 styleWithoutEmbedding = style->copy(); 622 styleWithoutEmbedding = style->copy();
623 embeddingStyle = styleWithoutEmbedding->extractAndRemoveTextDirectio n(); 623 embeddingStyle = styleWithoutEmbedding->extractAndRemoveTextDirectio n();
624 624
625 if (comparePositions(embeddingRemoveStart, embeddingRemoveEnd) <= 0) 625 if (comparePositions(embeddingRemoveStart, embeddingRemoveEnd) <= 0)
626 removeInlineStyle(embeddingStyle.get(), embeddingRemoveStart, em beddingRemoveEnd); 626 removeInlineStyle(embeddingStyle.get(), embeddingRemoveStart, em beddingRemoveEnd);
627 } 627 }
628 } 628 }
629 629
(...skipping 19 matching lines...) Expand all
649 // to check a computed style 649 // to check a computed style
650 document().updateLayoutIgnorePendingStylesheets(); 650 document().updateLayoutIgnorePendingStylesheets();
651 651
652 RefPtr<EditingStyle> styleToApply = style; 652 RefPtr<EditingStyle> styleToApply = style;
653 if (hasTextDirection) { 653 if (hasTextDirection) {
654 // Avoid applying the unicode-bidi and direction properties beneath ance stors that already have them. 654 // Avoid applying the unicode-bidi and direction properties beneath ance stors that already have them.
655 Node* embeddingStartNode = highestEmbeddingAncestor(start.deprecatedNode (), enclosingBlock(start.deprecatedNode())); 655 Node* embeddingStartNode = highestEmbeddingAncestor(start.deprecatedNode (), enclosingBlock(start.deprecatedNode()));
656 Node* embeddingEndNode = highestEmbeddingAncestor(end.deprecatedNode(), enclosingBlock(end.deprecatedNode())); 656 Node* embeddingEndNode = highestEmbeddingAncestor(end.deprecatedNode(), enclosingBlock(end.deprecatedNode()));
657 657
658 if (embeddingStartNode || embeddingEndNode) { 658 if (embeddingStartNode || embeddingEndNode) {
659 Position embeddingApplyStart = embeddingStartNode ? positionInParent AfterNode(embeddingStartNode) : start; 659 Position embeddingApplyStart = embeddingStartNode ? positionInParent AfterNode(*embeddingStartNode) : start;
660 Position embeddingApplyEnd = embeddingEndNode ? positionInParentBefo reNode(embeddingEndNode) : end; 660 Position embeddingApplyEnd = embeddingEndNode ? positionInParentBefo reNode(*embeddingEndNode) : end;
661 ASSERT(embeddingApplyStart.isNotNull() && embeddingApplyEnd.isNotNul l()); 661 ASSERT(embeddingApplyStart.isNotNull() && embeddingApplyEnd.isNotNul l());
662 662
663 if (!embeddingStyle) { 663 if (!embeddingStyle) {
664 styleWithoutEmbedding = style->copy(); 664 styleWithoutEmbedding = style->copy();
665 embeddingStyle = styleWithoutEmbedding->extractAndRemoveTextDire ction(); 665 embeddingStyle = styleWithoutEmbedding->extractAndRemoveTextDire ction();
666 } 666 }
667 fixRangeAndApplyInlineStyle(embeddingStyle.get(), embeddingApplyStar t, embeddingApplyEnd); 667 fixRangeAndApplyInlineStyle(embeddingStyle.get(), embeddingApplyStar t, embeddingApplyEnd);
668 668
669 styleToApply = styleWithoutEmbedding; 669 styleToApply = styleWithoutEmbedding;
670 } 670 }
(...skipping 26 matching lines...) Expand all
697 // if they want style applied to the empty line. 697 // if they want style applied to the empty line.
698 if (start == end && start.deprecatedNode()->hasTagName(brTag)) 698 if (start == end && start.deprecatedNode()->hasTagName(brTag))
699 pastEndNode = NodeTraversal::next(*start.deprecatedNode()); 699 pastEndNode = NodeTraversal::next(*start.deprecatedNode());
700 700
701 // Start from the highest fully selected ancestor so that we can modify the fully selected node. 701 // Start from the highest fully selected ancestor so that we can modify the fully selected node.
702 // e.g. When applying font-size: large on <font color="blue">hello</font>, w e need to include the font element in our run 702 // e.g. When applying font-size: large on <font color="blue">hello</font>, w e need to include the font element in our run
703 // to generate <font color="blue" size="4">hello</font> instead of <font col or="blue"><font size="4">hello</font></font> 703 // to generate <font color="blue" size="4">hello</font> instead of <font col or="blue"><font size="4">hello</font></font>
704 RefPtr<Range> range = Range::create(startNode->document(), start, end); 704 RefPtr<Range> range = Range::create(startNode->document(), start, end);
705 Element* editableRoot = startNode->rootEditableElement(); 705 Element* editableRoot = startNode->rootEditableElement();
706 if (startNode != editableRoot) { 706 if (startNode != editableRoot) {
707 while (editableRoot && startNode->parentNode() != editableRoot && isNode VisiblyContainedWithin(startNode->parentNode(), range.get())) 707 while (editableRoot && startNode->parentNode() != editableRoot && isNode VisiblyContainedWithin(*startNode->parentNode(), *range))
708 startNode = startNode->parentNode(); 708 startNode = startNode->parentNode();
709 } 709 }
710 710
711 applyInlineStyleToNodeRange(style, startNode, pastEndNode); 711 applyInlineStyleToNodeRange(style, startNode, pastEndNode);
712 } 712 }
713 713
714 static bool containsNonEditableRegion(Node& node) 714 static bool containsNonEditableRegion(Node& node)
715 { 715 {
716 if (!node.rendererIsEditable()) 716 if (!node.rendererIsEditable())
717 return true; 717 return true;
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 String textToMove = nextText->data(); 1542 String textToMove = nextText->data();
1543 insertTextIntoNode(childText, childText->length(), textToMove); 1543 insertTextIntoNode(childText, childText->length(), textToMove);
1544 removeNode(next); 1544 removeNode(next);
1545 // don't move child node pointer. it may want to merge with more text no des. 1545 // don't move child node pointer. it may want to merge with more text no des.
1546 } 1546 }
1547 1547
1548 updateStartEnd(newStart, newEnd); 1548 updateStartEnd(newStart, newEnd);
1549 } 1549 }
1550 1550
1551 } 1551 }
OLDNEW
« no previous file with comments | « Source/core/dom/PositionIterator.cpp ('k') | Source/core/editing/CompositeEditCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698