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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp

Issue 2571953004: Migrate WTF::Vector::append() to ::push_back() [part 5 of N] (Closed)
Patch Set: Created 4 years 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) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008, 2009 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 inlineStyle->setProperty( 501 inlineStyle->setProperty(
502 CSSPropertyFontSize, 502 CSSPropertyFontSize,
503 *CSSPrimitiveValue::create(desiredFontSize, 503 *CSSPrimitiveValue::create(desiredFontSize,
504 CSSPrimitiveValue::UnitType::Pixels), 504 CSSPrimitiveValue::UnitType::Pixels),
505 false); 505 false);
506 setNodeAttribute(element, styleAttr, AtomicString(inlineStyle->asText())); 506 setNodeAttribute(element, styleAttr, AtomicString(inlineStyle->asText()));
507 } 507 }
508 if (inlineStyle->isEmpty()) { 508 if (inlineStyle->isEmpty()) {
509 removeElementAttribute(element, styleAttr); 509 removeElementAttribute(element, styleAttr);
510 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element)) 510 if (isSpanWithoutAttributesOrUnstyledStyleSpan(element))
511 unstyledSpans.append(element); 511 unstyledSpans.push_back(element);
512 } 512 }
513 } 513 }
514 514
515 for (const auto& unstyledSpan : unstyledSpans) { 515 for (const auto& unstyledSpan : unstyledSpans) {
516 removeNodePreservingChildren(unstyledSpan, editingState); 516 removeNodePreservingChildren(unstyledSpan, editingState);
517 if (editingState->isAborted()) 517 if (editingState->isAborted())
518 return; 518 return;
519 } 519 }
520 } 520 }
521 521
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 runEnd = sibling; 999 runEnd = sibling;
1000 sibling = runEnd->nextSibling(); 1000 sibling = runEnd->nextSibling();
1001 } 1001 }
1002 DCHECK(runEnd); 1002 DCHECK(runEnd);
1003 next = NodeTraversal::nextSkippingChildren(*runEnd); 1003 next = NodeTraversal::nextSkippingChildren(*runEnd);
1004 1004
1005 Node* pastEndNode = NodeTraversal::nextSkippingChildren(*runEnd); 1005 Node* pastEndNode = NodeTraversal::nextSkippingChildren(*runEnd);
1006 if (!shouldApplyInlineStyleToRun(style, runStart, pastEndNode)) 1006 if (!shouldApplyInlineStyleToRun(style, runStart, pastEndNode))
1007 continue; 1007 continue;
1008 1008
1009 runs.append(InlineRunToApplyStyle(runStart, runEnd, pastEndNode)); 1009 runs.push_back(InlineRunToApplyStyle(runStart, runEnd, pastEndNode));
1010 } 1010 }
1011 1011
1012 for (auto& run : runs) { 1012 for (auto& run : runs) {
1013 removeConflictingInlineStyleFromRun(style, run.start, run.end, 1013 removeConflictingInlineStyleFromRun(style, run.start, run.end,
1014 run.pastEndNode, editingState); 1014 run.pastEndNode, editingState);
1015 if (editingState->isAborted()) 1015 if (editingState->isAborted())
1016 return; 1016 return;
1017 if (run.startAndEndAreStillInDocument()) { 1017 if (run.startAndEndAreStillInDocument()) {
1018 run.positionForStyleComputation = positionToComputeInlineStyleChange( 1018 run.positionForStyleComputation = positionToComputeInlineStyleChange(
1019 run.start, run.dummyElement, editingState); 1019 run.start, run.dummyElement, editingState);
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 // exclusing ancestors of targetNode, is then wrapped by clones of elements in 1332 // exclusing ancestors of targetNode, is then wrapped by clones of elements in
1333 // elementsToPushDown. 1333 // elementsToPushDown.
1334 HeapVector<Member<Element>> elementsToPushDown; 1334 HeapVector<Member<Element>> elementsToPushDown;
1335 while (current && current != targetNode && current->contains(targetNode)) { 1335 while (current && current != targetNode && current->contains(targetNode)) {
1336 NodeVector currentChildren; 1336 NodeVector currentChildren;
1337 getChildNodes(toContainerNode(*current), currentChildren); 1337 getChildNodes(toContainerNode(*current), currentChildren);
1338 Element* styledElement = nullptr; 1338 Element* styledElement = nullptr;
1339 if (current->isStyledElement() && 1339 if (current->isStyledElement() &&
1340 isStyledInlineElementToRemove(toElement(current))) { 1340 isStyledInlineElementToRemove(toElement(current))) {
1341 styledElement = toElement(current); 1341 styledElement = toElement(current);
1342 elementsToPushDown.append(styledElement); 1342 elementsToPushDown.push_back(styledElement);
1343 } 1343 }
1344 1344
1345 EditingStyle* styleToPushDown = EditingStyle::create(); 1345 EditingStyle* styleToPushDown = EditingStyle::create();
1346 if (current->isHTMLElement()) { 1346 if (current->isHTMLElement()) {
1347 removeInlineStyleFromElement(style, toHTMLElement(current), editingState, 1347 removeInlineStyleFromElement(style, toHTMLElement(current), editingState,
1348 RemoveIfNeeded, styleToPushDown); 1348 RemoveIfNeeded, styleToPushDown);
1349 if (editingState->isAborted()) 1349 if (editingState->isAborted())
1350 return; 1350 return;
1351 } 1351 }
1352 1352
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 return; 1994 return;
1995 1995
1996 Position newStart = start; 1996 Position newStart = start;
1997 Position newEnd = end; 1997 Position newEnd = end;
1998 1998
1999 HeapVector<Member<Text>> textNodes; 1999 HeapVector<Member<Text>> textNodes;
2000 for (Node* curr = node->firstChild(); curr; curr = curr->nextSibling()) { 2000 for (Node* curr = node->firstChild(); curr; curr = curr->nextSibling()) {
2001 if (!curr->isTextNode()) 2001 if (!curr->isTextNode())
2002 continue; 2002 continue;
2003 2003
2004 textNodes.append(toText(curr)); 2004 textNodes.push_back(toText(curr));
2005 } 2005 }
2006 2006
2007 for (const auto& textNode : textNodes) { 2007 for (const auto& textNode : textNodes) {
2008 Text* childText = textNode; 2008 Text* childText = textNode;
2009 Node* next = childText->nextSibling(); 2009 Node* next = childText->nextSibling();
2010 if (!next || !next->isTextNode()) 2010 if (!next || !next->isTextNode())
2011 continue; 2011 continue;
2012 2012
2013 Text* nextText = toText(next); 2013 Text* nextText = toText(next);
2014 if (start.isOffsetInAnchor() && next == start.computeContainerNode()) 2014 if (start.isOffsetInAnchor() && next == start.computeContainerNode())
(...skipping 14 matching lines...) Expand all
2029 2029
2030 DEFINE_TRACE(ApplyStyleCommand) { 2030 DEFINE_TRACE(ApplyStyleCommand) {
2031 visitor->trace(m_style); 2031 visitor->trace(m_style);
2032 visitor->trace(m_start); 2032 visitor->trace(m_start);
2033 visitor->trace(m_end); 2033 visitor->trace(m_end);
2034 visitor->trace(m_styledInlineElement); 2034 visitor->trace(m_styledInlineElement);
2035 CompositeEditCommand::trace(visitor); 2035 CompositeEditCommand::trace(visitor);
2036 } 2036 }
2037 2037
2038 } // namespace blink 2038 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698