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

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

Issue 1219723004: Make "insertHTML" execCommand not to crash on TEXTAREA (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « LayoutTests/editing/inserting/insert-html-to-textarea-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, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return; 175 return;
176 } 176 }
177 177
178 RefPtrWillBeRawPtr<HTMLElement> holder = insertFragmentForTestRendering(edit ableRoot.get()); 178 RefPtrWillBeRawPtr<HTMLElement> holder = insertFragmentForTestRendering(edit ableRoot.get());
179 if (!holder) { 179 if (!holder) {
180 removeInterchangeNodes(m_fragment.get()); 180 removeInterchangeNodes(m_fragment.get());
181 return; 181 return;
182 } 182 }
183 183
184 RefPtrWillBeRawPtr<Range> range = VisibleSelection::selectionFromContentsOfN ode(holder.get()).toNormalizedRange(); 184 RefPtrWillBeRawPtr<Range> range = VisibleSelection::selectionFromContentsOfN ode(holder.get()).toNormalizedRange();
185 String text = plainText(range.get(), static_cast<TextIteratorBehavior>(TextI teratorEmitsOriginalText | TextIteratorIgnoresStyleVisibility)); 185 String text = range ? plainText(range.get(), static_cast<TextIteratorBehavio r>(TextIteratorEmitsOriginalText | TextIteratorIgnoresStyleVisibility)) : emptyS tring();
hajimehoshi 2015/06/30 05:02:55 Does this mean plainText always accept non-null ra
yosin_UTC9 2015/06/30 05:04:54 Another patch will remove |plainText(Range*)| API
186 186
187 removeInterchangeNodes(holder.get()); 187 removeInterchangeNodes(holder.get());
188 removeUnrenderedNodes(holder.get()); 188 removeUnrenderedNodes(holder.get());
189 restoreAndRemoveTestRenderingNodesToFragment(holder.get()); 189 restoreAndRemoveTestRenderingNodesToFragment(holder.get());
190 190
191 // Give the root a chance to change the text. 191 // Give the root a chance to change the text.
192 RefPtrWillBeRawPtr<BeforeTextInsertedEvent> evt = BeforeTextInsertedEvent::c reate(text); 192 RefPtrWillBeRawPtr<BeforeTextInsertedEvent> evt = BeforeTextInsertedEvent::c reate(text);
193 editableRoot->dispatchEvent(evt, ASSERT_NO_EXCEPTION); 193 editableRoot->dispatchEvent(evt, ASSERT_NO_EXCEPTION);
194 if (text != evt->text() || !editableRoot->layoutObjectIsRichlyEditable()) { 194 if (text != evt->text() || !editableRoot->layoutObjectIsRichlyEditable()) {
195 restoreAndRemoveTestRenderingNodesToFragment(holder.get()); 195 restoreAndRemoveTestRenderingNodesToFragment(holder.get());
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 DEFINE_TRACE(ReplaceSelectionCommand) 1542 DEFINE_TRACE(ReplaceSelectionCommand)
1543 { 1543 {
1544 visitor->trace(m_startOfInsertedContent); 1544 visitor->trace(m_startOfInsertedContent);
1545 visitor->trace(m_endOfInsertedContent); 1545 visitor->trace(m_endOfInsertedContent);
1546 visitor->trace(m_insertionStyle); 1546 visitor->trace(m_insertionStyle);
1547 visitor->trace(m_documentFragment); 1547 visitor->trace(m_documentFragment);
1548 CompositeEditCommand::trace(visitor); 1548 CompositeEditCommand::trace(visitor);
1549 } 1549 }
1550 1550
1551 } // namespace blink 1551 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/editing/inserting/insert-html-to-textarea-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698