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

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

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

Powered by Google App Engine
This is Rietveld 408576698