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

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

Issue 18074004: RefPtr Node since it can be blown away in load event. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 | « no previous file | 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, 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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 pushDownInlineStyleAroundNode(style, pushDownEnd.deprecatedNode()); 1091 pushDownInlineStyleAroundNode(style, pushDownEnd.deprecatedNode());
1092 1092
1093 // The s and e variables store the positions used to set the ending selectio n after style removal 1093 // The s and e variables store the positions used to set the ending selectio n after style removal
1094 // takes place. This will help callers to recognize when either the start no de or the end node 1094 // takes place. This will help callers to recognize when either the start no de or the end node
1095 // are removed from the document during the work of this function. 1095 // are removed from the document during the work of this function.
1096 // If pushDownInlineStyleAroundNode has pruned start.deprecatedNode() or end .deprecatedNode(), 1096 // If pushDownInlineStyleAroundNode has pruned start.deprecatedNode() or end .deprecatedNode(),
1097 // use pushDownStart or pushDownEnd instead, which pushDownInlineStyleAround Node won't prune. 1097 // use pushDownStart or pushDownEnd instead, which pushDownInlineStyleAround Node won't prune.
1098 Position s = start.isNull() || start.isOrphan() ? pushDownStart : start; 1098 Position s = start.isNull() || start.isOrphan() ? pushDownStart : start;
1099 Position e = end.isNull() || end.isOrphan() ? pushDownEnd : end; 1099 Position e = end.isNull() || end.isOrphan() ? pushDownEnd : end;
1100 1100
1101 Node* node = start.deprecatedNode(); 1101 RefPtr<Node> node = start.deprecatedNode();
1102 while (node) { 1102 while (node) {
1103 RefPtr<Node> next; 1103 RefPtr<Node> next;
1104 if (editingIgnoresContent(node)) { 1104 if (editingIgnoresContent(node.get())) {
1105 ASSERT(node == end.deprecatedNode() || !node->contains(end.deprecate dNode())); 1105 ASSERT(node == end.deprecatedNode() || !node->contains(end.deprecate dNode()));
1106 next = NodeTraversal::nextSkippingChildren(node); 1106 next = NodeTraversal::nextSkippingChildren(node.get());
1107 } else 1107 } else {
1108 next = NodeTraversal::next(node); 1108 next = NodeTraversal::next(node.get());
1109 if (node->isHTMLElement() && nodeFullySelected(node, start, end)) { 1109 }
1110 RefPtr<HTMLElement> elem = toHTMLElement(node); 1110 if (node->isHTMLElement() && nodeFullySelected(node.get(), start, end)) {
1111 RefPtr<HTMLElement> elem = toHTMLElement(node.get());
1111 RefPtr<Node> prev = NodeTraversal::previousPostOrder(elem.get()); 1112 RefPtr<Node> prev = NodeTraversal::previousPostOrder(elem.get());
1112 RefPtr<Node> next = NodeTraversal::next(elem.get()); 1113 RefPtr<Node> next = NodeTraversal::next(elem.get());
1113 RefPtr<EditingStyle> styleToPushDown; 1114 RefPtr<EditingStyle> styleToPushDown;
1114 RefPtr<Node> childNode; 1115 RefPtr<Node> childNode;
1115 if (isStyledInlineElementToRemove(elem.get())) { 1116 if (isStyledInlineElementToRemove(elem.get())) {
1116 styleToPushDown = EditingStyle::create(); 1117 styleToPushDown = EditingStyle::create();
1117 childNode = elem->firstChild(); 1118 childNode = elem->firstChild();
1118 } 1119 }
1119 1120
1120 removeInlineStyleFromElement(style, elem.get(), RemoveIfNeeded, styl eToPushDown.get()); 1121 removeInlineStyleFromElement(style, elem.get(), RemoveIfNeeded, styl eToPushDown.get());
(...skipping 13 matching lines...) Expand all
1134 } 1135 }
1135 } 1136 }
1136 1137
1137 if (styleToPushDown) { 1138 if (styleToPushDown) {
1138 for (; childNode; childNode = childNode->nextSibling()) 1139 for (; childNode; childNode = childNode->nextSibling())
1139 applyInlineStyleToPushDown(childNode.get(), styleToPushDown. get()); 1140 applyInlineStyleToPushDown(childNode.get(), styleToPushDown. get());
1140 } 1141 }
1141 } 1142 }
1142 if (node == end.deprecatedNode()) 1143 if (node == end.deprecatedNode())
1143 break; 1144 break;
1144 node = next.get(); 1145 node = next;
1145 } 1146 }
1146 1147
1147 updateStartEnd(s, e); 1148 updateStartEnd(s, e);
1148 } 1149 }
1149 1150
1150 bool ApplyStyleCommand::nodeFullySelected(Node *node, const Position &start, con st Position &end) const 1151 bool ApplyStyleCommand::nodeFullySelected(Node *node, const Position &start, con st Position &end) const
1151 { 1152 {
1152 ASSERT(node); 1153 ASSERT(node);
1153 ASSERT(node->isElementNode()); 1154 ASSERT(node->isElementNode());
1154 1155
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 String textToMove = nextText->data(); 1541 String textToMove = nextText->data();
1541 insertTextIntoNode(childText, childText->length(), textToMove); 1542 insertTextIntoNode(childText, childText->length(), textToMove);
1542 removeNode(next); 1543 removeNode(next);
1543 // don't move child node pointer. it may want to merge with more text no des. 1544 // don't move child node pointer. it may want to merge with more text no des.
1544 } 1545 }
1545 1546
1546 updateStartEnd(newStart, newEnd); 1547 updateStartEnd(newStart, newEnd);
1547 } 1548 }
1548 1549
1549 } 1550 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698