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

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

Issue 23548010: Have htmlediting create functions take a Document reference in argument (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 unsigned int offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0; 239 unsigned int offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0;
240 240
241 // keep tabs coalesced in tab span 241 // keep tabs coalesced in tab span
242 if (isTabSpanTextNode(node)) { 242 if (isTabSpanTextNode(node)) {
243 RefPtr<Text> textNode = toText(node); 243 RefPtr<Text> textNode = toText(node);
244 insertTextIntoNode(textNode, offset, "\t"); 244 insertTextIntoNode(textNode, offset, "\t");
245 return Position(textNode.release(), offset + 1); 245 return Position(textNode.release(), offset + 1);
246 } 246 }
247 247
248 // create new tab span 248 // create new tab span
249 RefPtr<Element> spanNode = createTabSpanElement(&document()); 249 RefPtr<Element> spanNode = createTabSpanElement(document());
250 250
251 // place it 251 // place it
252 if (!node->isTextNode()) { 252 if (!node->isTextNode()) {
253 insertNodeAt(spanNode.get(), insertPos); 253 insertNodeAt(spanNode.get(), insertPos);
254 } else { 254 } else {
255 RefPtr<Text> textNode = toText(node); 255 RefPtr<Text> textNode = toText(node);
256 if (offset >= textNode->length()) 256 if (offset >= textNode->length())
257 insertNodeAfter(spanNode, textNode.release()); 257 insertNodeAfter(spanNode, textNode.release());
258 else { 258 else {
259 // split node to make room for the span 259 // split node to make room for the span
260 // NOTE: splitTextNode uses textNode for the 260 // NOTE: splitTextNode uses textNode for the
261 // second node in the split, so we need to 261 // second node in the split, so we need to
262 // insert the span before it. 262 // insert the span before it.
263 if (offset > 0) 263 if (offset > 0)
264 splitTextNode(textNode, offset); 264 splitTextNode(textNode, offset);
265 insertNodeBefore(spanNode, textNode.release()); 265 insertNodeBefore(spanNode, textNode.release());
266 } 266 }
267 } 267 }
268 268
269 // return the position following the new tab 269 // return the position following the new tab
270 return lastPositionInNode(spanNode.get()); 270 return lastPositionInNode(spanNode.get());
271 } 271 }
272 272
273 } 273 }
OLDNEW
« no previous file with comments | « Source/core/editing/InsertParagraphSeparatorCommand.cpp ('k') | Source/core/editing/ModifySelectionListLevel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698