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

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

Issue 2184823004: [Editing][CodeHealth] Remove redundant Editabletype arguments in layoutObjectIsRichlyEditable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp ('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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 Element* shadowAncestorElement; 166 Element* shadowAncestorElement;
167 if (editableRoot->isInShadowTree()) 167 if (editableRoot->isInShadowTree())
168 shadowAncestorElement = editableRoot->shadowHost(); 168 shadowAncestorElement = editableRoot->shadowHost();
169 else 169 else
170 shadowAncestorElement = editableRoot; 170 shadowAncestorElement = editableRoot;
171 171
172 if (!editableRoot->getAttributeEventListener(EventTypeNames::webkitBeforeTex tInserted) 172 if (!editableRoot->getAttributeEventListener(EventTypeNames::webkitBeforeTex tInserted)
173 // FIXME: Remove these checks once textareas and textfields actually reg ister an event handler. 173 // FIXME: Remove these checks once textareas and textfields actually reg ister an event handler.
174 && !(shadowAncestorElement && shadowAncestorElement->layoutObject() && s hadowAncestorElement->layoutObject()->isTextControl()) 174 && !(shadowAncestorElement && shadowAncestorElement->layoutObject() && s hadowAncestorElement->layoutObject()->isTextControl())
175 && layoutObjectIsRichlyEditable(*editableRoot)) { 175 && hasRichlyEditableStyle(*editableRoot)) {
176 removeInterchangeNodes(m_fragment.get()); 176 removeInterchangeNodes(m_fragment.get());
177 return; 177 return;
178 } 178 }
179 179
180 if (!layoutObjectIsRichlyEditable(*editableRoot)) { 180 if (!hasRichlyEditableStyle(*editableRoot)) {
181 bool isPlainText = true; 181 bool isPlainText = true;
182 for (Node& node : NodeTraversal::childrenOf(*m_fragment)) { 182 for (Node& node : NodeTraversal::childrenOf(*m_fragment)) {
183 if (isInterchangeHTMLBRElement(&node) && &node == m_fragment->lastCh ild()) 183 if (isInterchangeHTMLBRElement(&node) && &node == m_fragment->lastCh ild())
184 continue; 184 continue;
185 if (!node.isTextNode()) { 185 if (!node.isTextNode()) {
186 isPlainText = false; 186 isPlainText = false;
187 break; 187 break;
188 } 188 }
189 } 189 }
190 // We don't need TestRendering for plain-text editing + plain-text inser tion. 190 // We don't need TestRendering for plain-text editing + plain-text inser tion.
(...skipping 19 matching lines...) Expand all
210 const EphemeralRange range = VisibleSelection::selectionFromContentsOfNode(h older).toNormalizedEphemeralRange(); 210 const EphemeralRange range = VisibleSelection::selectionFromContentsOfNode(h older).toNormalizedEphemeralRange();
211 String text = plainText(range, static_cast<TextIteratorBehavior>(TextIterato rEmitsOriginalText | TextIteratorIgnoresStyleVisibility)); 211 String text = plainText(range, static_cast<TextIteratorBehavior>(TextIterato rEmitsOriginalText | TextIteratorIgnoresStyleVisibility));
212 212
213 removeInterchangeNodes(holder); 213 removeInterchangeNodes(holder);
214 removeUnrenderedNodes(holder); 214 removeUnrenderedNodes(holder);
215 restoreAndRemoveTestRenderingNodesToFragment(holder); 215 restoreAndRemoveTestRenderingNodesToFragment(holder);
216 216
217 // Give the root a chance to change the text. 217 // Give the root a chance to change the text.
218 BeforeTextInsertedEvent* evt = BeforeTextInsertedEvent::create(text); 218 BeforeTextInsertedEvent* evt = BeforeTextInsertedEvent::create(text);
219 editableRoot->dispatchEvent(evt); 219 editableRoot->dispatchEvent(evt);
220 if (text != evt->text() || !layoutObjectIsRichlyEditable(*editableRoot)) { 220 if (text != evt->text() || !hasRichlyEditableStyle(*editableRoot)) {
221 restoreAndRemoveTestRenderingNodesToFragment(holder); 221 restoreAndRemoveTestRenderingNodesToFragment(holder);
222 222
223 m_fragment = createFragmentFromText(selection.toNormalizedEphemeralRange (), evt->text()); 223 m_fragment = createFragmentFromText(selection.toNormalizedEphemeralRange (), evt->text());
224 if (!m_fragment->hasChildren()) 224 if (!m_fragment->hasChildren())
225 return; 225 return;
226 226
227 holder = insertFragmentForTestRendering(editableRoot); 227 holder = insertFragmentForTestRendering(editableRoot);
228 removeInterchangeNodes(holder); 228 removeInterchangeNodes(holder);
229 removeUnrenderedNodes(holder); 229 removeUnrenderedNodes(holder);
230 restoreAndRemoveTestRenderingNodesToFragment(holder); 230 restoreAndRemoveTestRenderingNodesToFragment(holder);
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 if (element->parentNode() && isNonTableCellHTMLBlockElement(element) && areIdenticalElements(*element, *element->parentNode()) 574 if (element->parentNode() && isNonTableCellHTMLBlockElement(element) && areIdenticalElements(*element, *element->parentNode())
575 && VisiblePosition::firstPositionInNode(element->parentNode()).deepE quivalent() == VisiblePosition::firstPositionInNode(element).deepEquivalent() 575 && VisiblePosition::firstPositionInNode(element->parentNode()).deepE quivalent() == VisiblePosition::firstPositionInNode(element).deepEquivalent()
576 && VisiblePosition::lastPositionInNode(element->parentNode()).deepEq uivalent() == VisiblePosition::lastPositionInNode(element).deepEquivalent()) { 576 && VisiblePosition::lastPositionInNode(element->parentNode()).deepEq uivalent() == VisiblePosition::lastPositionInNode(element).deepEquivalent()) {
577 insertedNodes.willRemoveNodePreservingChildren(*element); 577 insertedNodes.willRemoveNodePreservingChildren(*element);
578 removeNodePreservingChildren(element, editingState); 578 removeNodePreservingChildren(element, editingState);
579 if (editingState->isAborted()) 579 if (editingState->isAborted())
580 return; 580 return;
581 continue; 581 continue;
582 } 582 }
583 583
584 if (element->parentNode() && layoutObjectIsRichlyEditable(*element->pare ntNode())) 584 if (element->parentNode() && hasRichlyEditableStyle(*element->parentNode ()))
585 removeElementAttribute(element, contenteditableAttr); 585 removeElementAttribute(element, contenteditableAttr);
586 586
587 // WebKit used to not add display: inline and float: none on copy. 587 // WebKit used to not add display: inline and float: none on copy.
588 // Keep this code around for backward compatibility 588 // Keep this code around for backward compatibility
589 if (isLegacyAppleHTMLSpanElement(element)) { 589 if (isLegacyAppleHTMLSpanElement(element)) {
590 if (!element->hasChildren()) { 590 if (!element->hasChildren()) {
591 insertedNodes.willRemoveNodePreservingChildren(*element); 591 insertedNodes.willRemoveNodePreservingChildren(*element);
592 removeNodePreservingChildren(element, editingState); 592 removeNodePreservingChildren(element, editingState);
593 if (editingState->isAborted()) 593 if (editingState->isAborted())
594 return; 594 return;
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 visitor->trace(m_startOfInsertedContent); 1755 visitor->trace(m_startOfInsertedContent);
1756 visitor->trace(m_endOfInsertedContent); 1756 visitor->trace(m_endOfInsertedContent);
1757 visitor->trace(m_insertionStyle); 1757 visitor->trace(m_insertionStyle);
1758 visitor->trace(m_documentFragment); 1758 visitor->trace(m_documentFragment);
1759 visitor->trace(m_startOfInsertedRange); 1759 visitor->trace(m_startOfInsertedRange);
1760 visitor->trace(m_endOfInsertedRange); 1760 visitor->trace(m_endOfInsertedRange);
1761 CompositeEditCommand::trace(visitor); 1761 CompositeEditCommand::trace(visitor);
1762 } 1762 }
1763 1763
1764 } // namespace blink 1764 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698