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

Side by Side Diff: sky/engine/core/editing/ReplaceSelectionCommand.cpp

Issue 1215103007: Remove remaining HTML elements (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « sky/engine/core/editing/EditorCommand.cpp ('k') | sky/engine/core/fetch/FontResource.cpp » ('j') | 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 appendNode(element, ancestor->parentNode()); 404 appendNode(element, ancestor->parentNode());
405 } else { 405 } else {
406 RefPtr<Node> nodeToSplitTo = splitTreeToNode(element.get(), ancestor.get (), true); 406 RefPtr<Node> nodeToSplitTo = splitTreeToNode(element.get(), ancestor.get (), true);
407 removeNode(element); 407 removeNode(element);
408 insertNodeBefore(element, nodeToSplitTo); 408 insertNodeBefore(element, nodeToSplitTo);
409 } 409 }
410 if (!ancestor->hasChildren()) 410 if (!ancestor->hasChildren())
411 removeNode(ancestor.release()); 411 removeNode(ancestor.release());
412 } 412 }
413 413
414 static inline bool nodeHasVisibleRenderText(Text& text)
415 {
416 return text.renderer() && text.renderer()->renderedTextLength() > 0;
417 }
418
419 void ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds(InsertedNodes& ins ertedNodes) 414 void ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds(InsertedNodes& ins ertedNodes)
420 { 415 {
421 document().updateLayout();
422
423 Node* lastLeafInserted = insertedNodes.lastLeafInserted();
424 if (lastLeafInserted && lastLeafInserted->isTextNode() && !nodeHasVisibleRen derText(toText(*lastLeafInserted))
425 && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted ), HTMLNames::scriptTag)) {
426 insertedNodes.willRemoveNode(*lastLeafInserted);
427 removeNode(lastLeafInserted);
428 }
429
430 // We don't have to make sure that firstNodeInserted isn't inside a select o r script element, because
431 // it is a top level node in the fragment and the user can't insert into tho se elements.
432 Node* firstNodeInserted = insertedNodes.firstNodeInserted();
433 if (firstNodeInserted && firstNodeInserted->isTextNode() && !nodeHasVisibleR enderText(toText(*firstNodeInserted))) {
434 insertedNodes.willRemoveNode(*firstNodeInserted);
435 removeNode(firstNodeInserted);
436 }
437 } 416 }
438 417
439 VisiblePosition ReplaceSelectionCommand::positionAtEndOfInsertedContent() const 418 VisiblePosition ReplaceSelectionCommand::positionAtEndOfInsertedContent() const
440 { 419 {
441 return VisiblePosition(m_endOfInsertedContent); 420 return VisiblePosition(m_endOfInsertedContent);
442 } 421 }
443 422
444 VisiblePosition ReplaceSelectionCommand::positionAtStartOfInsertedContent() cons t 423 VisiblePosition ReplaceSelectionCommand::positionAtStartOfInsertedContent() cons t
445 { 424 {
446 return VisiblePosition(m_startOfInsertedContent); 425 return VisiblePosition(m_startOfInsertedContent);
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 return false; 976 return false;
998 977
999 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); 978 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d);
1000 979
1001 setEndingSelection(selectionAfterReplace); 980 setEndingSelection(selectionAfterReplace);
1002 981
1003 return true; 982 return true;
1004 } 983 }
1005 984
1006 } // namespace blink 985 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/editing/EditorCommand.cpp ('k') | sky/engine/core/fetch/FontResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698