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

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

Issue 306583005: Avoid to insert TAB before HTML element (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 | « LayoutTests/editing/execCommand/insert-tab-to-html-element-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 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)
230 { 230 {
231 Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent(); 231 Position insertPos = VisiblePosition(pos, DOWNSTREAM).deepEquivalent();
232 if (insertPos.isNull())
233 return pos;
232 234
233 Node* node = insertPos.containerNode(); 235 Node* node = insertPos.containerNode();
234 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0 ; 236 unsigned offset = node->isTextNode() ? insertPos.offsetInContainerNode() : 0 ;
235 237
236 // keep tabs coalesced in tab span 238 // keep tabs coalesced in tab span
237 if (isTabSpanTextNode(node)) { 239 if (isTabSpanTextNode(node)) {
238 RefPtrWillBeRawPtr<Text> textNode = toText(node); 240 RefPtrWillBeRawPtr<Text> textNode = toText(node);
239 insertTextIntoNode(textNode, offset, "\t"); 241 insertTextIntoNode(textNode, offset, "\t");
240 return Position(textNode.release(), offset + 1); 242 return Position(textNode.release(), offset + 1);
241 } 243 }
(...skipping 17 matching lines...) Expand all
259 splitTextNode(textNode, offset); 261 splitTextNode(textNode, offset);
260 insertNodeBefore(spanNode, textNode.release()); 262 insertNodeBefore(spanNode, textNode.release());
261 } 263 }
262 } 264 }
263 265
264 // return the position following the new tab 266 // return the position following the new tab
265 return lastPositionInNode(spanNode.get()); 267 return lastPositionInNode(spanNode.get());
266 } 268 }
267 269
268 } 270 }
OLDNEW
« no previous file with comments | « LayoutTests/editing/execCommand/insert-tab-to-html-element-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698