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

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

Issue 224113002: Oilpan: move Range object to the oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use STACK_ALLOCATED() + incorporate ager's overview of macros in this area. Created 6 years, 8 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
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 27 matching lines...) Expand all
38 #include "core/dom/Range.h" 38 #include "core/dom/Range.h"
39 #include "core/dom/Text.h" 39 #include "core/dom/Text.h"
40 #include "core/editing/EditingStyle.h" 40 #include "core/editing/EditingStyle.h"
41 #include "core/editing/HTMLInterchange.h" 41 #include "core/editing/HTMLInterchange.h"
42 #include "core/editing/PlainTextRange.h" 42 #include "core/editing/PlainTextRange.h"
43 #include "core/editing/TextIterator.h" 43 #include "core/editing/TextIterator.h"
44 #include "core/editing/VisibleUnits.h" 44 #include "core/editing/VisibleUnits.h"
45 #include "core/editing/htmlediting.h" 45 #include "core/editing/htmlediting.h"
46 #include "core/rendering/RenderObject.h" 46 #include "core/rendering/RenderObject.h"
47 #include "core/rendering/RenderText.h" 47 #include "core/rendering/RenderText.h"
48 #include "platform/heap/Handle.h"
48 #include "wtf/StdLibExtras.h" 49 #include "wtf/StdLibExtras.h"
49 #include "wtf/text/StringBuilder.h" 50 #include "wtf/text/StringBuilder.h"
50 51
51 namespace WebCore { 52 namespace WebCore {
52 53
53 using namespace HTMLNames; 54 using namespace HTMLNames;
54 55
55 static String& styleSpanClassString() 56 static String& styleSpanClassString()
56 { 57 {
57 DEFINE_STATIC_LOCAL(String, styleSpanClassString, ((AppleStyleSpanClass))); 58 DEFINE_STATIC_LOCAL(String, styleSpanClassString, ((AppleStyleSpanClass)));
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 VisiblePosition visibleStart(start); 248 VisiblePosition visibleStart(start);
248 VisiblePosition visibleEnd(end); 249 VisiblePosition visibleEnd(end);
249 250
250 if (visibleStart.isNull() || visibleStart.isOrphan() || visibleEnd.isNull() || visibleEnd.isOrphan()) 251 if (visibleStart.isNull() || visibleStart.isOrphan() || visibleEnd.isNull() || visibleEnd.isOrphan())
251 return; 252 return;
252 253
253 // Save and restore the selection endpoints using their indices in the docum ent, since 254 // Save and restore the selection endpoints using their indices in the docum ent, since
254 // addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoint s. 255 // addBlockStyleIfNeeded may moveParagraphs, which can remove these endpoint s.
255 // Calculate start and end indices from the start of the tree that they're i n. 256 // Calculate start and end indices from the start of the tree that they're i n.
256 Node& scope = visibleStart.deepEquivalent().deprecatedNode()->highestAncesto r(); 257 Node& scope = visibleStart.deepEquivalent().deprecatedNode()->highestAncesto r();
257 RefPtr<Range> startRange = Range::create(document(), firstPositionInNode(&sc ope), visibleStart.deepEquivalent().parentAnchoredEquivalent()); 258 RefPtrWillBeRawPtr<Range> startRange = Range::create(document(), firstPositi onInNode(&scope), visibleStart.deepEquivalent().parentAnchoredEquivalent());
258 RefPtr<Range> endRange = Range::create(document(), firstPositionInNode(&scop e), visibleEnd.deepEquivalent().parentAnchoredEquivalent()); 259 RefPtrWillBeRawPtr<Range> endRange = Range::create(document(), firstPosition InNode(&scope), visibleEnd.deepEquivalent().parentAnchoredEquivalent());
259 int startIndex = TextIterator::rangeLength(startRange.get(), true); 260 int startIndex = TextIterator::rangeLength(startRange.get(), true);
260 int endIndex = TextIterator::rangeLength(endRange.get(), true); 261 int endIndex = TextIterator::rangeLength(endRange.get(), true);
261 262
262 VisiblePosition paragraphStart(startOfParagraph(visibleStart)); 263 VisiblePosition paragraphStart(startOfParagraph(visibleStart));
263 VisiblePosition nextParagraphStart(endOfParagraph(paragraphStart).next()); 264 VisiblePosition nextParagraphStart(endOfParagraph(paragraphStart).next());
264 VisiblePosition beyondEnd(endOfParagraph(visibleEnd).next()); 265 VisiblePosition beyondEnd(endOfParagraph(visibleEnd).next());
265 while (paragraphStart.isNotNull() && paragraphStart != beyondEnd) { 266 while (paragraphStart.isNotNull() && paragraphStart != beyondEnd) {
266 StyleChange styleChange(style, paragraphStart.deepEquivalent()); 267 StyleChange styleChange(style, paragraphStart.deepEquivalent());
267 if (styleChange.cssStyle().length() || m_removeOnly) { 268 if (styleChange.cssStyle().length() || m_removeOnly) {
268 RefPtr<Node> block = enclosingBlock(paragraphStart.deepEquivalent(). deprecatedNode()); 269 RefPtr<Node> block = enclosingBlock(paragraphStart.deepEquivalent(). deprecatedNode());
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 pastEndNode = NodeTraversal::nextSkippingChildren(*end.deprecatedNode()) ; 695 pastEndNode = NodeTraversal::nextSkippingChildren(*end.deprecatedNode()) ;
695 696
696 // FIXME: Callers should perform this operation on a Range that includes the br 697 // FIXME: Callers should perform this operation on a Range that includes the br
697 // if they want style applied to the empty line. 698 // if they want style applied to the empty line.
698 if (start == end && isHTMLBRElement(*start.deprecatedNode())) 699 if (start == end && isHTMLBRElement(*start.deprecatedNode()))
699 pastEndNode = NodeTraversal::next(*start.deprecatedNode()); 700 pastEndNode = NodeTraversal::next(*start.deprecatedNode());
700 701
701 // Start from the highest fully selected ancestor so that we can modify the fully selected node. 702 // Start from the highest fully selected ancestor so that we can modify the fully selected node.
702 // e.g. When applying font-size: large on <font color="blue">hello</font>, w e need to include the font element in our run 703 // e.g. When applying font-size: large on <font color="blue">hello</font>, w e need to include the font element in our run
703 // to generate <font color="blue" size="4">hello</font> instead of <font col or="blue"><font size="4">hello</font></font> 704 // to generate <font color="blue" size="4">hello</font> instead of <font col or="blue"><font size="4">hello</font></font>
704 RefPtr<Range> range = Range::create(startNode->document(), start, end); 705 RefPtrWillBeRawPtr<Range> range = Range::create(startNode->document(), start , end);
705 Element* editableRoot = startNode->rootEditableElement(); 706 Element* editableRoot = startNode->rootEditableElement();
706 if (startNode != editableRoot) { 707 if (startNode != editableRoot) {
707 while (editableRoot && startNode->parentNode() != editableRoot && isNode VisiblyContainedWithin(*startNode->parentNode(), *range)) 708 while (editableRoot && startNode->parentNode() != editableRoot && isNode VisiblyContainedWithin(*startNode->parentNode(), *range))
708 startNode = startNode->parentNode(); 709 startNode = startNode->parentNode();
709 } 710 }
710 711
711 applyInlineStyleToNodeRange(style, startNode, pastEndNode); 712 applyInlineStyleToNodeRange(style, startNode, pastEndNode);
712 } 713 }
713 714
714 static bool containsNonEditableRegion(Node& node) 715 static bool containsNonEditableRegion(Node& node)
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 String textToMove = nextText->data(); 1543 String textToMove = nextText->data();
1543 insertTextIntoNode(childText, childText->length(), textToMove); 1544 insertTextIntoNode(childText, childText->length(), textToMove);
1544 removeNode(next); 1545 removeNode(next);
1545 // don't move child node pointer. it may want to merge with more text no des. 1546 // don't move child node pointer. it may want to merge with more text no des.
1546 } 1547 }
1547 1548
1548 updateStartEnd(newStart, newEnd); 1549 updateStartEnd(newStart, newEnd);
1549 } 1550 }
1550 1551
1551 } 1552 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698