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

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

Issue 289273002: Oilpan: make DocumentFragment a heap allocated object. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased + add WillBeGarbageCollected FIXME. Created 6 years, 7 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
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.h ('k') | Source/core/editing/markup.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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "wtf/Vector.h" 56 #include "wtf/Vector.h"
57 57
58 namespace WebCore { 58 namespace WebCore {
59 59
60 using namespace HTMLNames; 60 using namespace HTMLNames;
61 61
62 enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment }; 62 enum EFragmentType { EmptyFragment, SingleTextNodeFragment, TreeFragment };
63 63
64 // --- ReplacementFragment helper class 64 // --- ReplacementFragment helper class
65 65
66 class ReplacementFragment { 66 class ReplacementFragment FINAL {
67 WTF_MAKE_NONCOPYABLE(ReplacementFragment); 67 WTF_MAKE_NONCOPYABLE(ReplacementFragment);
68 STACK_ALLOCATED();
68 public: 69 public:
69 ReplacementFragment(Document*, DocumentFragment*, const VisibleSelection&); 70 ReplacementFragment(Document*, DocumentFragment*, const VisibleSelection&);
70 71
71 Node* firstChild() const; 72 Node* firstChild() const;
72 Node* lastChild() const; 73 Node* lastChild() const;
73 74
74 bool isEmpty() const; 75 bool isEmpty() const;
75 76
76 bool hasInterchangeNewlineAtStart() const { return m_hasInterchangeNewlineAt Start; } 77 bool hasInterchangeNewlineAtStart() const { return m_hasInterchangeNewlineAt Start; }
77 bool hasInterchangeNewlineAtEnd() const { return m_hasInterchangeNewlineAtEn d; } 78 bool hasInterchangeNewlineAtEnd() const { return m_hasInterchangeNewlineAtEn d; }
78 79
79 void removeNode(PassRefPtr<Node>); 80 void removeNode(PassRefPtr<Node>);
80 void removeNodePreservingChildren(PassRefPtr<Node>); 81 void removeNodePreservingChildren(PassRefPtr<Node>);
81 82
82 private: 83 private:
83 PassRefPtr<Element> insertFragmentForTestRendering(Node* rootEditableNode); 84 PassRefPtr<Element> insertFragmentForTestRendering(Node* rootEditableNode);
84 void removeUnrenderedNodes(Node*); 85 void removeUnrenderedNodes(Node*);
85 void restoreAndRemoveTestRenderingNodesToFragment(Element*); 86 void restoreAndRemoveTestRenderingNodesToFragment(Element*);
86 void removeInterchangeNodes(Node*); 87 void removeInterchangeNodes(Node*);
87 88
88 void insertNodeBefore(PassRefPtr<Node> node, Node* refNode); 89 void insertNodeBefore(PassRefPtr<Node> node, Node* refNode);
89 90
90 RefPtr<Document> m_document; 91 RefPtrWillBeMember<Document> m_document;
91 RefPtr<DocumentFragment> m_fragment; 92 RefPtrWillBeMember<DocumentFragment> m_fragment;
92 bool m_hasInterchangeNewlineAtStart; 93 bool m_hasInterchangeNewlineAtStart;
93 bool m_hasInterchangeNewlineAtEnd; 94 bool m_hasInterchangeNewlineAtEnd;
94 }; 95 };
95 96
96 static bool isInterchangeNewlineNode(const Node *node) 97 static bool isInterchangeNewlineNode(const Node *node)
97 { 98 {
98 DEFINE_STATIC_LOCAL(String, interchangeNewlineClassString, (AppleInterchange Newline)); 99 DEFINE_STATIC_LOCAL(String, interchangeNewlineClassString, (AppleInterchange Newline));
99 return isHTMLBRElement(node) && toElement(node)->getAttribute(classAttr) == interchangeNewlineClassString; 100 return isHTMLBRElement(node) && toElement(node)->getAttribute(classAttr) == interchangeNewlineClassString;
100 } 101 }
101 102
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 349 }
349 350
350 inline void ReplaceSelectionCommand::InsertedNodes::didReplaceNode(Node& node, N ode& newNode) 351 inline void ReplaceSelectionCommand::InsertedNodes::didReplaceNode(Node& node, N ode& newNode)
351 { 352 {
352 if (m_firstNodeInserted == node) 353 if (m_firstNodeInserted == node)
353 m_firstNodeInserted = &newNode; 354 m_firstNodeInserted = &newNode;
354 if (m_lastNodeInserted == node) 355 if (m_lastNodeInserted == node)
355 m_lastNodeInserted = &newNode; 356 m_lastNodeInserted = &newNode;
356 } 357 }
357 358
358 ReplaceSelectionCommand::ReplaceSelectionCommand(Document& document, PassRefPtr< DocumentFragment> fragment, CommandOptions options, EditAction editAction) 359 ReplaceSelectionCommand::ReplaceSelectionCommand(Document& document, PassRefPtrW illBeRawPtr<DocumentFragment> fragment, CommandOptions options, EditAction editA ction)
359 : CompositeEditCommand(document) 360 : CompositeEditCommand(document)
360 , m_selectReplacement(options & SelectReplacement) 361 , m_selectReplacement(options & SelectReplacement)
361 , m_smartReplace(options & SmartReplace) 362 , m_smartReplace(options & SmartReplace)
362 , m_matchStyle(options & MatchStyle) 363 , m_matchStyle(options & MatchStyle)
363 , m_documentFragment(fragment) 364 , m_documentFragment(fragment)
364 , m_preventNesting(options & PreventNesting) 365 , m_preventNesting(options & PreventNesting)
365 , m_movingParagraph(options & MovingParagraph) 366 , m_movingParagraph(options & MovingParagraph)
366 , m_editAction(editAction) 367 , m_editAction(editAction)
367 , m_sanitizeFragment(options & SanitizeFragment) 368 , m_sanitizeFragment(options & SanitizeFragment)
368 , m_shouldMergeEnd(false) 369 , m_shouldMergeEnd(false)
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); 1497 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get());
1497 1498
1498 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); 1499 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d);
1499 1500
1500 setEndingSelection(selectionAfterReplace); 1501 setEndingSelection(selectionAfterReplace);
1501 1502
1502 return true; 1503 return true;
1503 } 1504 }
1504 1505
1505 } // namespace WebCore 1506 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.h ('k') | Source/core/editing/markup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698