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

Side by Side Diff: third_party/WebKit/Source/core/editing/Editor.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) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 return selection.isRange() && selection.rootEditableElement(); 312 return selection.isRange() && selection.rootEditableElement();
313 } 313 }
314 314
315 bool Editor::canDeleteRange(const EphemeralRange& range) const 315 bool Editor::canDeleteRange(const EphemeralRange& range) const
316 { 316 {
317 Node* startContainer = range.startPosition().computeContainerNode(); 317 Node* startContainer = range.startPosition().computeContainerNode();
318 Node* endContainer = range.endPosition().computeContainerNode(); 318 Node* endContainer = range.endPosition().computeContainerNode();
319 if (!startContainer || !endContainer) 319 if (!startContainer || !endContainer)
320 return false; 320 return false;
321 321
322 if (!startContainer->hasEditableStyle() || !endContainer->hasEditableStyle() ) 322 if (!hasEditableStyle(*startContainer) || !hasEditableStyle(*endContainer))
323 return false; 323 return false;
324 324
325 if (range.isCollapsed()) { 325 if (range.isCollapsed()) {
326 VisiblePosition start = createVisiblePosition(range.startPosition()); 326 VisiblePosition start = createVisiblePosition(range.startPosition());
327 VisiblePosition previous = previousPositionOf(start); 327 VisiblePosition previous = previousPositionOf(start);
328 // FIXME: We sometimes allow deletions at the start of editable roots, l ike when the caret is in an empty list item. 328 // FIXME: We sometimes allow deletions at the start of editable roots, l ike when the caret is in an empty list item.
329 if (previous.isNull() || rootEditableElement(*previous.deepEquivalent(). anchorNode()) != rootEditableElement(*startContainer)) 329 if (previous.isNull() || rootEditableElement(*previous.deepEquivalent(). anchorNode()) != rootEditableElement(*startContainer))
330 return false; 330 return false;
331 } 331 }
332 return true; 332 return true;
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); 1393 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled);
1394 } 1394 }
1395 1395
1396 // TODO(tkent): This is a workaround of some crash bugs in the editing code, 1396 // TODO(tkent): This is a workaround of some crash bugs in the editing code,
1397 // which assumes a document has a valid HTML structure. We should make the 1397 // which assumes a document has a valid HTML structure. We should make the
1398 // editing code more robust, and should remove this hack. crbug.com/580941. 1398 // editing code more robust, and should remove this hack. crbug.com/580941.
1399 void Editor::tidyUpHTMLStructure(Document& document) 1399 void Editor::tidyUpHTMLStructure(Document& document)
1400 { 1400 {
1401 // hasEditableStyle() needs up-to-date ComputedStyle. 1401 // hasEditableStyle() needs up-to-date ComputedStyle.
1402 document.updateStyleAndLayoutTree(); 1402 document.updateStyleAndLayoutTree();
1403 bool needsValidStructure = document.hasEditableStyle() || (document.document Element() && document.documentElement()->hasEditableStyle()); 1403 bool needsValidStructure = hasEditableStyle(document) || (document.documentE lement() && hasEditableStyle(*document.documentElement()));
1404 if (!needsValidStructure) 1404 if (!needsValidStructure)
1405 return; 1405 return;
1406 Element* existingHead = nullptr; 1406 Element* existingHead = nullptr;
1407 Element* existingBody = nullptr; 1407 Element* existingBody = nullptr;
1408 Element* currentRoot = document.documentElement(); 1408 Element* currentRoot = document.documentElement();
1409 if (currentRoot) { 1409 if (currentRoot) {
1410 if (isHTMLHtmlElement(currentRoot)) 1410 if (isHTMLHtmlElement(currentRoot))
1411 return; 1411 return;
1412 if (isHTMLHeadElement(currentRoot)) 1412 if (isHTMLHeadElement(currentRoot))
1413 existingHead = currentRoot; 1413 existingHead = currentRoot;
(...skipping 28 matching lines...) Expand all
1442 1442
1443 DEFINE_TRACE(Editor) 1443 DEFINE_TRACE(Editor)
1444 { 1444 {
1445 visitor->trace(m_frame); 1445 visitor->trace(m_frame);
1446 visitor->trace(m_lastEditCommand); 1446 visitor->trace(m_lastEditCommand);
1447 visitor->trace(m_undoStack); 1447 visitor->trace(m_undoStack);
1448 visitor->trace(m_mark); 1448 visitor->trace(m_mark);
1449 } 1449 }
1450 1450
1451 } // namespace blink 1451 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698