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

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

Issue 299353004: Oilpan: move editing objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make test wrapper class finalized Created 6 years, 6 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 | « Source/core/editing/InsertTextCommand.h ('k') | Source/core/editing/MarkupAccumulator.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 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005 Apple Computer, 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 30 matching lines...) Expand all
41 , m_text(text) 41 , m_text(text)
42 , m_selectInsertedText(selectInsertedText) 42 , m_selectInsertedText(selectInsertedText)
43 , m_rebalanceType(rebalanceType) 43 , m_rebalanceType(rebalanceType)
44 { 44 {
45 } 45 }
46 46
47 Position InsertTextCommand::positionInsideTextNode(const Position& p) 47 Position InsertTextCommand::positionInsideTextNode(const Position& p)
48 { 48 {
49 Position pos = p; 49 Position pos = p;
50 if (isTabSpanTextNode(pos.anchorNode())) { 50 if (isTabSpanTextNode(pos.anchorNode())) {
51 RefPtr<Node> textNode = document().createEditingTextNode(""); 51 RefPtrWillBeRawPtr<Node> textNode = document().createEditingTextNode("") ;
52 insertNodeAtTabSpanPosition(textNode.get(), pos); 52 insertNodeAtTabSpanPosition(textNode.get(), pos);
53 return firstPositionInNode(textNode.get()); 53 return firstPositionInNode(textNode.get());
54 } 54 }
55 55
56 // Prepare for text input by looking at the specified position. 56 // Prepare for text input by looking at the specified position.
57 // It may be necessary to insert a text node to receive characters. 57 // It may be necessary to insert a text node to receive characters.
58 if (!pos.containerNode()->isTextNode()) { 58 if (!pos.containerNode()->isTextNode()) {
59 RefPtr<Node> textNode = document().createEditingTextNode(""); 59 RefPtrWillBeRawPtr<Node> textNode = document().createEditingTextNode("") ;
60 insertNodeAt(textNode.get(), pos); 60 insertNodeAt(textNode.get(), pos);
61 return firstPositionInNode(textNode.get()); 61 return firstPositionInNode(textNode.get());
62 } 62 }
63 63
64 return pos; 64 return pos;
65 } 65 }
66 66
67 void InsertTextCommand::setEndingSelectionWithoutValidation(const Position& star tPosition, const Position& endPosition) 67 void InsertTextCommand::setEndingSelectionWithoutValidation(const Position& star tPosition, const Position& endPosition)
68 { 68 {
69 // We could have inserted a part of composed character sequence, 69 // We could have inserted a part of composed character sequence,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } else { 209 } else {
210 ASSERT(m_rebalanceType == RebalanceAllWhitespaces); 210 ASSERT(m_rebalanceType == RebalanceAllWhitespaces);
211 if (canRebalance(startPosition) && canRebalance(endPosition)) 211 if (canRebalance(startPosition) && canRebalance(endPosition))
212 rebalanceWhitespaceOnTextSubstring(textNode, startPosition.offse tInContainerNode(), endPosition.offsetInContainerNode()); 212 rebalanceWhitespaceOnTextSubstring(textNode, startPosition.offse tInContainerNode(), endPosition.offsetInContainerNode());
213 } 213 }
214 } 214 }
215 215
216 setEndingSelectionWithoutValidation(startPosition, endPosition); 216 setEndingSelectionWithoutValidation(startPosition, endPosition);
217 217
218 // Handle the case where there is a typing style. 218 // Handle the case where there is a typing style.
219 if (RefPtr<EditingStyle> typingStyle = document().frame()->selection().typin gStyle()) { 219 if (RefPtrWillBeRawPtr<EditingStyle> typingStyle = document().frame()->selec tion().typingStyle()) {
220 typingStyle->prepareToApplyAt(endPosition, EditingStyle::PreserveWriting Direction); 220 typingStyle->prepareToApplyAt(endPosition, EditingStyle::PreserveWriting Direction);
221 if (!typingStyle->isEmpty()) 221 if (!typingStyle->isEmpty())
222 applyStyle(typingStyle.get()); 222 applyStyle(typingStyle.get());
223 } 223 }
224 224
225 if (!m_selectInsertedText) 225 if (!m_selectInsertedText)
226 setEndingSelection(VisibleSelection(endingSelection().end(), endingSelec tion().affinity(), endingSelection().isDirectional())); 226 setEndingSelection(VisibleSelection(endingSelection().end(), endingSelec tion().affinity(), endingSelection().isDirectional()));
227 } 227 }
228 228
229 Position InsertTextCommand::insertTab(const Position& pos) 229 Position InsertTextCommand::insertTab(const Position& pos)
(...skipping 29 matching lines...) Expand all
259 splitTextNode(textNode, offset); 259 splitTextNode(textNode, offset);
260 insertNodeBefore(spanNode, textNode.release()); 260 insertNodeBefore(spanNode, textNode.release());
261 } 261 }
262 } 262 }
263 263
264 // return the position following the new tab 264 // return the position following the new tab
265 return lastPositionInNode(spanNode.get()); 265 return lastPositionInNode(spanNode.get());
266 } 266 }
267 267
268 } 268 }
OLDNEW
« no previous file with comments | « Source/core/editing/InsertTextCommand.h ('k') | Source/core/editing/MarkupAccumulator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698