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

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

Issue 406843002: Optimize hasTagName when called on an HTMLElement / SVGElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/InsertListCommand.h ('k') | Source/core/editing/markup.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) 2006, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // operated on that paragraph. 120 // operated on that paragraph.
121 // FIXME: We paint the gap before some paragraphs that are indented with lef t 121 // FIXME: We paint the gap before some paragraphs that are indented with lef t
122 // margin/padding, but not others. We should make the gap painting more con sistent and 122 // margin/padding, but not others. We should make the gap painting more con sistent and
123 // then use a left margin/padding rule here. 123 // then use a left margin/padding rule here.
124 if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd, CanSkipOver EditingBoundary)) { 124 if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd, CanSkipOver EditingBoundary)) {
125 setEndingSelection(VisibleSelection(visibleStart, visibleEnd.previous(Ca nnotCrossEditingBoundary), endingSelection().isDirectional())); 125 setEndingSelection(VisibleSelection(visibleStart, visibleEnd.previous(Ca nnotCrossEditingBoundary), endingSelection().isDirectional()));
126 if (!endingSelection().rootEditableElement()) 126 if (!endingSelection().rootEditableElement())
127 return; 127 return;
128 } 128 }
129 129
130 const QualifiedName& listTag = (m_type == OrderedList) ? olTag : ulTag; 130 const HTMLQualifiedName& listTag = (m_type == OrderedList) ? olTag : ulTag;
131 if (endingSelection().isRange()) { 131 if (endingSelection().isRange()) {
132 bool forceListCreation = false; 132 bool forceListCreation = false;
133 VisibleSelection selection = selectionForParagraphIteration(endingSelect ion()); 133 VisibleSelection selection = selectionForParagraphIteration(endingSelect ion());
134 ASSERT(selection.isRange()); 134 ASSERT(selection.isRange());
135 VisiblePosition startOfSelection = selection.visibleStart(); 135 VisiblePosition startOfSelection = selection.visibleStart();
136 VisiblePosition endOfSelection = selection.visibleEnd(); 136 VisiblePosition endOfSelection = selection.visibleEnd();
137 VisiblePosition startOfLastParagraph = startOfParagraph(endOfSelection, CanSkipOverEditingBoundary); 137 VisiblePosition startOfLastParagraph = startOfParagraph(endOfSelection, CanSkipOverEditingBoundary);
138 138
139 RefPtrWillBeRawPtr<Range> currentSelection = endingSelection().firstRang e(); 139 RefPtrWillBeRawPtr<Range> currentSelection = endingSelection().firstRang e();
140 RefPtrWillBeRawPtr<ContainerNode> scopeForStartOfSelection = nullptr; 140 RefPtrWillBeRawPtr<ContainerNode> scopeForStartOfSelection = nullptr;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return; 190 return;
191 } 191 }
192 setEndingSelection(VisibleSelection(startOfSelection, endOfSelection, en dingSelection().isDirectional())); 192 setEndingSelection(VisibleSelection(startOfSelection, endOfSelection, en dingSelection().isDirectional()));
193 return; 193 return;
194 } 194 }
195 195
196 ASSERT(endingSelection().firstRange()); 196 ASSERT(endingSelection().firstRange());
197 doApplyForSingleParagraph(false, listTag, *endingSelection().firstRange()); 197 doApplyForSingleParagraph(false, listTag, *endingSelection().firstRange());
198 } 198 }
199 199
200 void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const Qu alifiedName& listTag, Range& currentSelection) 200 void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HT MLQualifiedName& listTag, Range& currentSelection)
201 { 201 {
202 // FIXME: This will produce unexpected results for a selection that starts j ust before a 202 // FIXME: This will produce unexpected results for a selection that starts j ust before a
203 // table and ends inside the first cell, selectionForParagraphIteration shou ld probably 203 // table and ends inside the first cell, selectionForParagraphIteration shou ld probably
204 // be renamed and deployed inside setEndingSelection(). 204 // be renamed and deployed inside setEndingSelection().
205 Node* selectionNode = endingSelection().start().deprecatedNode(); 205 Node* selectionNode = endingSelection().start().deprecatedNode();
206 Node* listChildNode = enclosingListChild(selectionNode); 206 Node* listChildNode = enclosingListChild(selectionNode);
207 bool switchListType = false; 207 bool switchListType = false;
208 if (listChildNode) { 208 if (listChildNode) {
209 // Remove the list chlild. 209 // Remove the list chlild.
210 RefPtrWillBeRawPtr<HTMLElement> listNode = enclosingList(listChildNode); 210 RefPtrWillBeRawPtr<HTMLElement> listNode = enclosingList(listChildNode);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 return listElement; 408 return listElement;
409 } 409 }
410 410
411 void InsertListCommand::trace(Visitor* visitor) 411 void InsertListCommand::trace(Visitor* visitor)
412 { 412 {
413 visitor->trace(m_listElement); 413 visitor->trace(m_listElement);
414 CompositeEditCommand::trace(visitor); 414 CompositeEditCommand::trace(visitor);
415 } 415 }
416 416
417 } 417 }
OLDNEW
« no previous file with comments | « Source/core/editing/InsertListCommand.h ('k') | Source/core/editing/markup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698