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

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

Issue 2171493003: [Editing][DOM][CodeHealth] Make Node::hasEditableStyle global functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 m_endingPosition = m_downstreamEnd; 328 m_endingPosition = m_downstreamEnd;
329 } 329 }
330 330
331 return false; 331 return false;
332 } 332 }
333 333
334 static Position firstEditablePositionInNode(Node* node) 334 static Position firstEditablePositionInNode(Node* node)
335 { 335 {
336 DCHECK(node); 336 DCHECK(node);
337 Node* next = node; 337 Node* next = node;
338 while (next && !next->hasEditableStyle()) 338 while (next && !hasEditableStyle(*next))
339 next = NodeTraversal::next(*next, node); 339 next = NodeTraversal::next(*next, node);
340 return next ? firstPositionInOrBeforeNode(next) : Position(); 340 return next ? firstPositionInOrBeforeNode(next) : Position();
341 } 341 }
342 342
343 void DeleteSelectionCommand::removeNode(Node* node, EditingState* editingState, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable) 343 void DeleteSelectionCommand::removeNode(Node* node, EditingState* editingState, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
344 { 344 {
345 if (!node) 345 if (!node)
346 return; 346 return;
347 347
348 if (m_startRoot != m_endRoot && !(node->isDescendantOf(m_startRoot.get()) && node->isDescendantOf(m_endRoot.get()))) { 348 if (m_startRoot != m_endRoot && !(node->isDescendantOf(m_startRoot.get()) && node->isDescendantOf(m_endRoot.get()))) {
349 // If a node is not in both the start and end editable roots, remove it only if its inside an editable region. 349 // If a node is not in both the start and end editable roots, remove it only if its inside an editable region.
350 if (!node->parentNode()->hasEditableStyle()) { 350 if (!hasEditableStyle(*node->parentNode())) {
351 // Don't remove non-editable atomic nodes. 351 // Don't remove non-editable atomic nodes.
352 if (!node->hasChildren()) 352 if (!node->hasChildren())
353 return; 353 return;
354 // Search this non-editable region for editable regions to empty. 354 // Search this non-editable region for editable regions to empty.
355 Node* child = node->firstChild(); 355 Node* child = node->firstChild();
356 while (child) { 356 while (child) {
357 Node* nextChild = child->nextSibling(); 357 Node* nextChild = child->nextSibling();
358 removeNode(child, editingState, shouldAssumeContentIsAlwaysEdita ble); 358 removeNode(child, editingState, shouldAssumeContentIsAlwaysEdita ble);
359 if (editingState->isAborted()) 359 if (editingState->isAborted())
360 return; 360 return;
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 visitor->trace(m_deleteIntoBlockquoteStyle); 961 visitor->trace(m_deleteIntoBlockquoteStyle);
962 visitor->trace(m_startRoot); 962 visitor->trace(m_startRoot);
963 visitor->trace(m_endRoot); 963 visitor->trace(m_endRoot);
964 visitor->trace(m_startTableRow); 964 visitor->trace(m_startTableRow);
965 visitor->trace(m_endTableRow); 965 visitor->trace(m_endTableRow);
966 visitor->trace(m_temporaryPlaceholder); 966 visitor->trace(m_temporaryPlaceholder);
967 CompositeEditCommand::trace(visitor); 967 CompositeEditCommand::trace(visitor);
968 } 968 }
969 969
970 } // namespace blink 970 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698