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

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

Issue 299353004: Oilpan: move editing objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make test wrapper class finalized Created 6 years, 6 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 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 29 matching lines...) Expand all
40 SelectReplacement = 1 << 0, 40 SelectReplacement = 1 << 0,
41 SmartReplace = 1 << 1, 41 SmartReplace = 1 << 1,
42 MatchStyle = 1 << 2, 42 MatchStyle = 1 << 2,
43 PreventNesting = 1 << 3, 43 PreventNesting = 1 << 3,
44 MovingParagraph = 1 << 4, 44 MovingParagraph = 1 << 4,
45 SanitizeFragment = 1 << 5 45 SanitizeFragment = 1 << 5
46 }; 46 };
47 47
48 typedef unsigned CommandOptions; 48 typedef unsigned CommandOptions;
49 49
50 static PassRefPtr<ReplaceSelectionCommand> create(Document& document, PassRe fPtrWillBeRawPtr<DocumentFragment> fragment, CommandOptions options, EditAction action = EditActionPaste) 50 static PassRefPtrWillBeRawPtr<ReplaceSelectionCommand> create(Document& docu ment, PassRefPtrWillBeRawPtr<DocumentFragment> fragment, CommandOptions options, EditAction action = EditActionPaste)
51 { 51 {
52 return adoptRef(new ReplaceSelectionCommand(document, fragment, options, action)); 52 return adoptRefWillBeNoop(new ReplaceSelectionCommand(document, fragment , options, action));
53 } 53 }
54 54
55 virtual void trace(Visitor*) OVERRIDE;
56
55 private: 57 private:
56 ReplaceSelectionCommand(Document&, PassRefPtrWillBeRawPtr<DocumentFragment>, CommandOptions, EditAction); 58 ReplaceSelectionCommand(Document&, PassRefPtrWillBeRawPtr<DocumentFragment>, CommandOptions, EditAction);
57 59
58 virtual void doApply() OVERRIDE; 60 virtual void doApply() OVERRIDE;
59 virtual EditAction editingAction() const OVERRIDE; 61 virtual EditAction editingAction() const OVERRIDE;
60 62
61 class InsertedNodes { 63 class InsertedNodes {
64 STACK_ALLOCATED();
62 public: 65 public:
63 void respondToNodeInsertion(Node&); 66 void respondToNodeInsertion(Node&);
64 void willRemoveNodePreservingChildren(Node&); 67 void willRemoveNodePreservingChildren(Node&);
65 void willRemoveNode(Node&); 68 void willRemoveNode(Node&);
66 void didReplaceNode(Node&, Node& newNode); 69 void didReplaceNode(Node&, Node& newNode);
67 70
68 Node* firstNodeInserted() const { return m_firstNodeInserted.get(); } 71 Node* firstNodeInserted() const { return m_firstNodeInserted.get(); }
69 Node* lastLeafInserted() const { return m_lastNodeInserted ? &m_lastNode Inserted->lastDescendantOrSelf() : 0; } 72 Node* lastLeafInserted() const { return m_lastNodeInserted ? &m_lastNode Inserted->lastDescendantOrSelf() : 0; }
70 Node* pastLastLeaf() const { return m_lastNodeInserted ? NodeTraversal:: next(m_lastNodeInserted->lastDescendantOrSelf()) : 0; } 73 Node* pastLastLeaf() const { return m_lastNodeInserted ? NodeTraversal:: next(m_lastNodeInserted->lastDescendantOrSelf()) : 0; }
71 74
72 private: 75 private:
73 RefPtr<Node> m_firstNodeInserted; 76 RefPtrWillBeMember<Node> m_firstNodeInserted;
74 RefPtr<Node> m_lastNodeInserted; 77 RefPtrWillBeMember<Node> m_lastNodeInserted;
75 }; 78 };
76 79
77 Node* insertAsListItems(PassRefPtrWillBeRawPtr<HTMLElement> listElement, Nod e* insertionNode, const Position&, InsertedNodes&); 80 Node* insertAsListItems(PassRefPtrWillBeRawPtr<HTMLElement> listElement, Nod e* insertionNode, const Position&, InsertedNodes&);
78 81
79 void updateNodesInserted(Node*); 82 void updateNodesInserted(Node*);
80 bool shouldRemoveEndBR(Node*, const VisiblePosition&); 83 bool shouldRemoveEndBR(Node*, const VisiblePosition&);
81 84
82 bool shouldMergeStart(bool, bool, bool); 85 bool shouldMergeStart(bool, bool, bool);
83 bool shouldMergeEnd(bool selectionEndWasEndOfParagraph); 86 bool shouldMergeEnd(bool selectionEndWasEndOfParagraph);
84 bool shouldMerge(const VisiblePosition&, const VisiblePosition&); 87 bool shouldMerge(const VisiblePosition&, const VisiblePosition&);
85 88
86 void mergeEndIfNeeded(); 89 void mergeEndIfNeeded();
87 90
88 void removeUnrenderedTextNodesAtEnds(InsertedNodes&); 91 void removeUnrenderedTextNodesAtEnds(InsertedNodes&);
89 92
90 void removeRedundantStylesAndKeepStyleSpanInline(InsertedNodes&); 93 void removeRedundantStylesAndKeepStyleSpanInline(InsertedNodes&);
91 void makeInsertedContentRoundTrippableWithHTMLTreeBuilder(const InsertedNode s&); 94 void makeInsertedContentRoundTrippableWithHTMLTreeBuilder(const InsertedNode s&);
92 void moveNodeOutOfAncestor(PassRefPtr<Node>, PassRefPtr<Node> ancestor); 95 void moveNodeOutOfAncestor(PassRefPtrWillBeRawPtr<Node>, PassRefPtrWillBeRaw Ptr<Node> ancestor);
93 void handleStyleSpans(InsertedNodes&); 96 void handleStyleSpans(InsertedNodes&);
94 97
95 VisiblePosition positionAtStartOfInsertedContent() const; 98 VisiblePosition positionAtStartOfInsertedContent() const;
96 VisiblePosition positionAtEndOfInsertedContent() const; 99 VisiblePosition positionAtEndOfInsertedContent() const;
97 100
98 bool shouldPerformSmartReplace() const; 101 bool shouldPerformSmartReplace() const;
99 void addSpacesForSmartReplace(); 102 void addSpacesForSmartReplace();
100 void completeHTMLReplacement(const Position& lastPositionToSelect); 103 void completeHTMLReplacement(const Position& lastPositionToSelect);
101 void mergeTextNodesAroundPosition(Position&, Position& positionOnlyToBeUpdat ed); 104 void mergeTextNodesAroundPosition(Position&, Position& positionOnlyToBeUpdat ed);
102 105
103 bool performTrivialReplace(const ReplacementFragment&); 106 bool performTrivialReplace(const ReplacementFragment&);
104 107
105 Position m_startOfInsertedContent; 108 Position m_startOfInsertedContent;
106 Position m_endOfInsertedContent; 109 Position m_endOfInsertedContent;
107 RefPtr<EditingStyle> m_insertionStyle; 110 RefPtrWillBeMember<EditingStyle> m_insertionStyle;
108 bool m_selectReplacement; 111 bool m_selectReplacement;
109 bool m_smartReplace; 112 bool m_smartReplace;
110 bool m_matchStyle; 113 bool m_matchStyle;
111 RefPtrWillBePersistent<DocumentFragment> m_documentFragment; 114 RefPtrWillBeMember<DocumentFragment> m_documentFragment;
112 bool m_preventNesting; 115 bool m_preventNesting;
113 bool m_movingParagraph; 116 bool m_movingParagraph;
114 EditAction m_editAction; 117 EditAction m_editAction;
115 bool m_sanitizeFragment; 118 bool m_sanitizeFragment;
116 bool m_shouldMergeEnd; 119 bool m_shouldMergeEnd;
117 }; 120 };
118 121
119 } // namespace WebCore 122 } // namespace WebCore
120 123
121 #endif // ReplaceSelectionCommand_h 124 #endif // ReplaceSelectionCommand_h
OLDNEW
« no previous file with comments | « Source/core/editing/ReplaceNodeWithSpanCommand.cpp ('k') | Source/core/editing/ReplaceSelectionCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698