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

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

Issue 1280263002: Make ApplyBlockElementCommand not to modify uneditable element (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-10T14:45:18 Created 5 years, 4 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/format-block-uneditable-crash.html ('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) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Include \n at the end of line if we're at an empty paragraph 220 // Include \n at the end of line if we're at an empty paragraph
221 if (endStyle->preserveNewline() && start == end && end.offsetInContainer Node() < end.computeContainerNode()->maxCharacterOffset()) { 221 if (endStyle->preserveNewline() && start == end && end.offsetInContainer Node() < end.computeContainerNode()->maxCharacterOffset()) {
222 int endOffset = end.offsetInContainerNode(); 222 int endOffset = end.offsetInContainerNode();
223 if (!isNewLineAtPosition(end.previous()) && isNewLineAtPosition(end) ) 223 if (!isNewLineAtPosition(end.previous()) && isNewLineAtPosition(end) )
224 end = Position(end.computeContainerNode(), endOffset + 1); 224 end = Position(end.computeContainerNode(), endOffset + 1);
225 if (isEndAndEndOfLastParagraphOnSameNode && end.offsetInContainerNod e() >= m_endOfLastParagraph.offsetInContainerNode()) 225 if (isEndAndEndOfLastParagraphOnSameNode && end.offsetInContainerNod e() >= m_endOfLastParagraph.offsetInContainerNode())
226 m_endOfLastParagraph = end; 226 m_endOfLastParagraph = end;
227 } 227 }
228 228
229 // If end is in the middle of a text node, split. 229 // If end is in the middle of a text node, split.
230 if (!endStyle->collapseWhiteSpace() && end.offsetInContainerNode() && en d.offsetInContainerNode() < end.computeContainerNode()->maxCharacterOffset()) { 230 if (endStyle->userModify() != READ_ONLY && !endStyle->collapseWhiteSpace () && end.offsetInContainerNode() && end.offsetInContainerNode() < end.computeCo ntainerNode()->maxCharacterOffset()) {
231 RefPtrWillBeRawPtr<Text> endContainer = toText(end.computeContainerN ode()); 231 RefPtrWillBeRawPtr<Text> endContainer = toText(end.computeContainerN ode());
232 splitTextNode(endContainer, end.offsetInContainerNode()); 232 splitTextNode(endContainer, end.offsetInContainerNode());
233 if (isStartAndEndOnSameNode) 233 if (isStartAndEndOnSameNode)
234 start = firstPositionInOrBeforeNode(endContainer->previousSiblin g()); 234 start = firstPositionInOrBeforeNode(endContainer->previousSiblin g());
235 if (isEndAndEndOfLastParagraphOnSameNode) { 235 if (isEndAndEndOfLastParagraphOnSameNode) {
236 if (m_endOfLastParagraph.offsetInContainerNode() == end.offsetIn ContainerNode()) 236 if (m_endOfLastParagraph.offsetInContainerNode() == end.offsetIn ContainerNode())
237 m_endOfLastParagraph = lastPositionInOrAfterNode(endContaine r->previousSibling()); 237 m_endOfLastParagraph = lastPositionInOrAfterNode(endContaine r->previousSibling());
238 else 238 else
239 m_endOfLastParagraph = Position(endContainer, m_endOfLastPar agraph.offsetInContainerNode() - end.offsetInContainerNode()); 239 m_endOfLastParagraph = Position(endContainer, m_endOfLastPar agraph.offsetInContainerNode() - end.offsetInContainerNode());
240 } 240 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return element.release(); 289 return element.release();
290 } 290 }
291 291
292 DEFINE_TRACE(ApplyBlockElementCommand) 292 DEFINE_TRACE(ApplyBlockElementCommand)
293 { 293 {
294 visitor->trace(m_endOfLastParagraph); 294 visitor->trace(m_endOfLastParagraph);
295 CompositeEditCommand::trace(visitor); 295 CompositeEditCommand::trace(visitor);
296 } 296 }
297 297
298 } 298 }
OLDNEW
« no previous file with comments | « LayoutTests/editing/execCommand/format-block-uneditable-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698