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

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

Issue 422693002: Use tighter typing in editing: htmlediting create methods (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
« no previous file with comments | « Source/core/editing/InsertListCommand.cpp ('k') | Source/core/editing/htmlediting.h » ('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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "core/editing/TextIterator.h" 45 #include "core/editing/TextIterator.h"
46 #include "core/editing/VisibleUnits.h" 46 #include "core/editing/VisibleUnits.h"
47 #include "core/editing/htmlediting.h" 47 #include "core/editing/htmlediting.h"
48 #include "core/editing/markup.h" 48 #include "core/editing/markup.h"
49 #include "core/events/BeforeTextInsertedEvent.h" 49 #include "core/events/BeforeTextInsertedEvent.h"
50 #include "core/frame/LocalFrame.h" 50 #include "core/frame/LocalFrame.h"
51 #include "core/frame/UseCounter.h" 51 #include "core/frame/UseCounter.h"
52 #include "core/html/HTMLBRElement.h" 52 #include "core/html/HTMLBRElement.h"
53 #include "core/html/HTMLElement.h" 53 #include "core/html/HTMLElement.h"
54 #include "core/html/HTMLInputElement.h" 54 #include "core/html/HTMLInputElement.h"
55 #include "core/html/HTMLLIElement.h"
55 #include "core/rendering/RenderObject.h" 56 #include "core/rendering/RenderObject.h"
56 #include "core/rendering/RenderText.h" 57 #include "core/rendering/RenderText.h"
57 #include "wtf/StdLibExtras.h" 58 #include "wtf/StdLibExtras.h"
58 #include "wtf/Vector.h" 59 #include "wtf/Vector.h"
59 60
60 namespace blink { 61 namespace blink {
61 62
62 using namespace HTMLNames; 63 using namespace HTMLNames;
63 64
64 enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment }; 65 enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment };
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 Position lastPositionToSelect; 1209 Position lastPositionToSelect;
1209 if (fragment.hasInterchangeNewlineAtEnd()) { 1210 if (fragment.hasInterchangeNewlineAtEnd()) {
1210 VisiblePosition endOfInsertedContent = positionAtEndOfInsertedContent(); 1211 VisiblePosition endOfInsertedContent = positionAtEndOfInsertedContent();
1211 VisiblePosition next = endOfInsertedContent.next(CannotCrossEditingBound ary); 1212 VisiblePosition next = endOfInsertedContent.next(CannotCrossEditingBound ary);
1212 1213
1213 if (selectionEndWasEndOfParagraph || !isEndOfParagraph(endOfInsertedCont ent) || next.isNull()) { 1214 if (selectionEndWasEndOfParagraph || !isEndOfParagraph(endOfInsertedCont ent) || next.isNull()) {
1214 if (!isStartOfParagraph(endOfInsertedContent)) { 1215 if (!isStartOfParagraph(endOfInsertedContent)) {
1215 setEndingSelection(endOfInsertedContent); 1216 setEndingSelection(endOfInsertedContent);
1216 Node* enclosingNode = enclosingBlock(endOfInsertedContent.deepEq uivalent().deprecatedNode()); 1217 Node* enclosingNode = enclosingBlock(endOfInsertedContent.deepEq uivalent().deprecatedNode());
1217 if (isListItem(enclosingNode)) { 1218 if (isListItem(enclosingNode)) {
1218 RefPtrWillBeRawPtr<Node> newListItem = createListItemElement (document()); 1219 RefPtrWillBeRawPtr<HTMLLIElement> newListItem = createListIt emElement(document());
1219 insertNodeAfter(newListItem, enclosingNode); 1220 insertNodeAfter(newListItem, enclosingNode);
1220 setEndingSelection(VisiblePosition(firstPositionInNode(newLi stItem.get()))); 1221 setEndingSelection(VisiblePosition(firstPositionInNode(newLi stItem.get())));
1221 } else { 1222 } else {
1222 // Use a default paragraph element (a plain div) for the emp ty paragraph, using the last paragraph 1223 // Use a default paragraph element (a plain div) for the emp ty paragraph, using the last paragraph
1223 // block's style seems to annoy users. 1224 // block's style seems to annoy users.
1224 insertParagraphSeparator(true, !startIsInsideMailBlockquote && highestEnclosingNodeOfType(endOfInsertedContent.deepEquivalent(), 1225 insertParagraphSeparator(true, !startIsInsideMailBlockquote && highestEnclosingNodeOfType(endOfInsertedContent.deepEquivalent(),
1225 isMailHTMLBlockquoteElement, CannotCrossEditingBoundary, insertedNodes.firstNodeInserted()->parentNode())); 1226 isMailHTMLBlockquoteElement, CannotCrossEditingBoundary, insertedNodes.firstNodeInserted()->parentNode()));
1226 } 1227 }
1227 1228
1228 // Select up to the paragraph separator that was added. 1229 // Select up to the paragraph separator that was added.
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 void ReplaceSelectionCommand::trace(Visitor* visitor) 1529 void ReplaceSelectionCommand::trace(Visitor* visitor)
1529 { 1530 {
1530 visitor->trace(m_startOfInsertedContent); 1531 visitor->trace(m_startOfInsertedContent);
1531 visitor->trace(m_endOfInsertedContent); 1532 visitor->trace(m_endOfInsertedContent);
1532 visitor->trace(m_insertionStyle); 1533 visitor->trace(m_insertionStyle);
1533 visitor->trace(m_documentFragment); 1534 visitor->trace(m_documentFragment);
1534 CompositeEditCommand::trace(visitor); 1535 CompositeEditCommand::trace(visitor);
1535 } 1536 }
1536 1537
1537 } // namespace blink 1538 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/InsertListCommand.cpp ('k') | Source/core/editing/htmlediting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698