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

Side by Side Diff: Source/core/editing/ReplaceSelectionCommand.cpp

Issue 414863002: Minimize RenderObject* casting to RenderText* (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 RefPtrWillBeRawPtr<Node> nodeToSplitTo = splitTreeToNode(node.get(), anc estor.get(), true); 668 RefPtrWillBeRawPtr<Node> nodeToSplitTo = splitTreeToNode(node.get(), anc estor.get(), true);
669 removeNode(node); 669 removeNode(node);
670 insertNodeBefore(node, nodeToSplitTo); 670 insertNodeBefore(node, nodeToSplitTo);
671 } 671 }
672 if (!ancestor->firstChild()) 672 if (!ancestor->firstChild())
673 removeNode(ancestor.release()); 673 removeNode(ancestor.release());
674 } 674 }
675 675
676 static inline bool nodeHasVisibleRenderText(Text& text) 676 static inline bool nodeHasVisibleRenderText(Text& text)
677 { 677 {
678 return text.renderer() && toRenderText(text.renderer())->renderedTextLength( ) > 0; 678 return text.renderer() && text.renderer()->renderedTextLength() > 0;
679 } 679 }
680 680
681 void ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds(InsertedNodes& ins ertedNodes) 681 void ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds(InsertedNodes& ins ertedNodes)
682 { 682 {
683 document().updateLayoutIgnorePendingStylesheets(); 683 document().updateLayoutIgnorePendingStylesheets();
684 684
685 Node* lastLeafInserted = insertedNodes.lastLeafInserted(); 685 Node* lastLeafInserted = insertedNodes.lastLeafInserted();
686 if (lastLeafInserted && lastLeafInserted->isTextNode() && !nodeHasVisibleRen derText(toText(*lastLeafInserted)) 686 if (lastLeafInserted && lastLeafInserted->isTextNode() && !nodeHasVisibleRen derText(toText(*lastLeafInserted))
687 && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted ), selectTag) 687 && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted ), selectTag)
688 && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted ), scriptTag)) { 688 && !enclosingElementWithTag(firstPositionInOrBeforeNode(lastLeafInserted ), scriptTag)) {
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 void ReplaceSelectionCommand::trace(Visitor* visitor) 1530 void ReplaceSelectionCommand::trace(Visitor* visitor)
1531 { 1531 {
1532 visitor->trace(m_startOfInsertedContent); 1532 visitor->trace(m_startOfInsertedContent);
1533 visitor->trace(m_endOfInsertedContent); 1533 visitor->trace(m_endOfInsertedContent);
1534 visitor->trace(m_insertionStyle); 1534 visitor->trace(m_insertionStyle);
1535 visitor->trace(m_documentFragment); 1535 visitor->trace(m_documentFragment);
1536 CompositeEditCommand::trace(visitor); 1536 CompositeEditCommand::trace(visitor);
1537 } 1537 }
1538 1538
1539 } // namespace blink 1539 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/InsertParagraphSeparatorCommand.cpp ('k') | Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698