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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp

Issue 1570733002: [Editing][BugFix] Check editability in InserListCommand::listifyParagraph (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2010 Apple 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 354 }
355 355
356 void InsertListCommand::listifyParagraph(const VisiblePosition& originalStart, c onst HTMLQualifiedName& listTag) 356 void InsertListCommand::listifyParagraph(const VisiblePosition& originalStart, c onst HTMLQualifiedName& listTag)
357 { 357 {
358 const VisiblePosition& start = startOfParagraph(originalStart, CanSkipOverEd itingBoundary); 358 const VisiblePosition& start = startOfParagraph(originalStart, CanSkipOverEd itingBoundary);
359 const VisiblePosition& end = endOfParagraph(start, CanSkipOverEditingBoundar y); 359 const VisiblePosition& end = endOfParagraph(start, CanSkipOverEditingBoundar y);
360 360
361 if (start.isNull() || end.isNull()) 361 if (start.isNull() || end.isNull())
362 return; 362 return;
363 363
364 {
365 // The paragraph between |start| and |end| shoule be editable.
366 const Position& startPosition = start.toParentAnchoredPosition();
367 const Position& endPosition = end.toParentAnchoredPosition();
368 if (!isEditablePosition(startPosition) || !isEditablePosition(endPositio n))
369 return;
370 Node* commonAncestor = NodeTraversal::commonAncestor(*startPosition.anch orNode(), *endPosition.anchorNode());
371 if (!commonAncestor || !commonAncestor->hasEditableStyle())
372 return;
373 }
374
364 // Check for adjoining lists. 375 // Check for adjoining lists.
365 HTMLElement* const previousList = adjacentEnclosingList(start, previousPosit ionOf(start, CannotCrossEditingBoundary), listTag); 376 HTMLElement* const previousList = adjacentEnclosingList(start, previousPosit ionOf(start, CannotCrossEditingBoundary), listTag);
366 HTMLElement* const nextList = adjacentEnclosingList(start, nextPositionOf(en d, CannotCrossEditingBoundary), listTag); 377 HTMLElement* const nextList = adjacentEnclosingList(start, nextPositionOf(en d, CannotCrossEditingBoundary), listTag);
367 if (previousList || nextList) { 378 if (previousList || nextList) {
368 // Place list item into adjoining lists. 379 // Place list item into adjoining lists.
369 const RefPtrWillBeRawPtr<HTMLLIElement> listItemElement = HTMLLIElement: :create(document()); 380 const RefPtrWillBeRawPtr<HTMLLIElement> listItemElement = HTMLLIElement: :create(document());
370 if (previousList) 381 if (previousList)
371 appendNode(listItemElement, previousList); 382 appendNode(listItemElement, previousList);
372 else 383 else
373 insertNodeAt(listItemElement, Position::beforeNode(nextList)); 384 insertNodeAt(listItemElement, Position::beforeNode(nextList));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 const VisiblePosition& end = endOfParagraph(pos, CanSkipOverEditingBoundary) ; 442 const VisiblePosition& end = endOfParagraph(pos, CanSkipOverEditingBoundary) ;
432 moveParagraph(start, end, createVisiblePosition(positionBeforeNode(placehold er.get())), true); 443 moveParagraph(start, end, createVisiblePosition(positionBeforeNode(placehold er.get())), true);
433 } 444 }
434 445
435 DEFINE_TRACE(InsertListCommand) 446 DEFINE_TRACE(InsertListCommand)
436 { 447 {
437 CompositeEditCommand::trace(visitor); 448 CompositeEditCommand::trace(visitor);
438 } 449 }
439 450
440 } // namespace blink 451 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/execCommand/insertunorderedlist-crash-in-domsubtreemodified-event.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698