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

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

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
« no previous file with comments | « Source/core/editing/Editor.cpp ('k') | Source/core/editing/FormatBlockCommand.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) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2009 Igalia S.L. 4 * Copyright (C) 2009 Igalia S.L.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet: :create(); 128 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet: :create();
129 style->setProperty(propertyID, propertyValue); 129 style->setProperty(propertyID, propertyValue);
130 return applyCommandToFrame(frame, source, action, style.get()); 130 return applyCommandToFrame(frame, source, action, style.get());
131 } 131 }
132 132
133 // FIXME: executeToggleStyleInList does not handle complicated cases such as <b> <u>hello</u>world</b> properly. 133 // FIXME: executeToggleStyleInList does not handle complicated cases such as <b> <u>hello</u>world</b> properly.
134 // This function must use Editor::selectionHasStyle to determine the curr ent style but we cannot fix this 134 // This function must use Editor::selectionHasStyle to determine the curr ent style but we cannot fix this
135 // until https://bugs.webkit.org/show_bug.cgi?id=27818 is resolved. 135 // until https://bugs.webkit.org/show_bug.cgi?id=27818 is resolved.
136 static bool executeToggleStyleInList(LocalFrame& frame, EditorCommandSource sour ce, EditAction action, CSSPropertyID propertyID, CSSValue* value) 136 static bool executeToggleStyleInList(LocalFrame& frame, EditorCommandSource sour ce, EditAction action, CSSPropertyID propertyID, CSSValue* value)
137 { 137 {
138 RefPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelectionStart(fr ame.selection().selection()); 138 RefPtrWillBeRawPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelec tionStart(frame.selection().selection());
139 if (!selectionStyle || !selectionStyle->style()) 139 if (!selectionStyle || !selectionStyle->style())
140 return false; 140 return false;
141 141
142 RefPtrWillBeRawPtr<CSSValue> selectedCSSValue = selectionStyle->style()->get PropertyCSSValue(propertyID); 142 RefPtrWillBeRawPtr<CSSValue> selectedCSSValue = selectionStyle->style()->get PropertyCSSValue(propertyID);
143 String newStyle("none"); 143 String newStyle("none");
144 if (selectedCSSValue->isValueList()) { 144 if (selectedCSSValue->isValueList()) {
145 RefPtrWillBeRawPtr<CSSValueList> selectedCSSValueList = toCSSValueList(s electedCSSValue.get()); 145 RefPtrWillBeRawPtr<CSSValueList> selectedCSSValueList = toCSSValueList(s electedCSSValue.get());
146 if (!selectedCSSValueList->removeAll(value)) 146 if (!selectedCSSValueList->removeAll(value))
147 selectedCSSValueList->append(value); 147 selectedCSSValueList->append(value);
148 if (selectedCSSValueList->length()) 148 if (selectedCSSValueList->length())
(...skipping 13 matching lines...) Expand all
162 // Style is considered present when 162 // Style is considered present when
163 // Mac: present at the beginning of selection 163 // Mac: present at the beginning of selection
164 // other: present throughout the selection 164 // other: present throughout the selection
165 165
166 bool styleIsPresent; 166 bool styleIsPresent;
167 if (frame.editor().behavior().shouldToggleStyleBasedOnStartOfSelection()) 167 if (frame.editor().behavior().shouldToggleStyleBasedOnStartOfSelection())
168 styleIsPresent = frame.editor().selectionStartHasStyle(propertyID, onVal ue); 168 styleIsPresent = frame.editor().selectionStartHasStyle(propertyID, onVal ue);
169 else 169 else
170 styleIsPresent = frame.editor().selectionHasStyle(propertyID, onValue) = = TrueTriState; 170 styleIsPresent = frame.editor().selectionHasStyle(propertyID, onValue) = = TrueTriState;
171 171
172 RefPtr<EditingStyle> style = EditingStyle::create(propertyID, styleIsPresent ? offValue : onValue); 172 RefPtrWillBeRawPtr<EditingStyle> style = EditingStyle::create(propertyID, st yleIsPresent ? offValue : onValue);
173 return applyCommandToFrame(frame, source, action, style->style()); 173 return applyCommandToFrame(frame, source, action, style->style());
174 } 174 }
175 175
176 static bool executeApplyParagraphStyle(LocalFrame& frame, EditorCommandSource so urce, EditAction action, CSSPropertyID propertyID, const String& propertyValue) 176 static bool executeApplyParagraphStyle(LocalFrame& frame, EditorCommandSource so urce, EditAction action, CSSPropertyID propertyID, const String& propertyValue)
177 { 177 {
178 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet: :create(); 178 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet: :create();
179 style->setProperty(propertyID, propertyValue); 179 style->setProperty(propertyID, propertyValue);
180 // FIXME: We don't call shouldApplyStyle when the source is DOM; is there a good reason for that? 180 // FIXME: We don't call shouldApplyStyle when the source is DOM; is there a good reason for that?
181 switch (source) { 181 switch (source) {
182 case CommandFromMenuOrKeyBinding: 182 case CommandFromMenuOrKeyBinding:
183 frame.editor().applyParagraphStyleToSelection(style.get(), action); 183 frame.editor().applyParagraphStyleToSelection(style.get(), action);
184 return true; 184 return true;
185 case CommandFromDOM: 185 case CommandFromDOM:
186 case CommandFromDOMWithUserInterface: 186 case CommandFromDOMWithUserInterface:
187 frame.editor().applyParagraphStyle(style.get()); 187 frame.editor().applyParagraphStyle(style.get());
188 return true; 188 return true;
189 } 189 }
190 ASSERT_NOT_REACHED(); 190 ASSERT_NOT_REACHED();
191 return false; 191 return false;
192 } 192 }
193 193
194 static bool executeInsertFragment(LocalFrame& frame, PassRefPtrWillBeRawPtr<Docu mentFragment> fragment) 194 static bool executeInsertFragment(LocalFrame& frame, PassRefPtrWillBeRawPtr<Docu mentFragment> fragment)
195 { 195 {
196 ASSERT(frame.document()); 196 ASSERT(frame.document());
197 ReplaceSelectionCommand::create(*frame.document(), fragment, ReplaceSelectio nCommand::PreventNesting, EditActionUnspecified)->apply(); 197 ReplaceSelectionCommand::create(*frame.document(), fragment, ReplaceSelectio nCommand::PreventNesting, EditActionUnspecified)->apply();
198 return true; 198 return true;
199 } 199 }
200 200
201 static bool executeInsertNode(LocalFrame& frame, PassRefPtr<Node> content) 201 static bool executeInsertNode(LocalFrame& frame, PassRefPtrWillBeRawPtr<Node> co ntent)
202 { 202 {
203 ASSERT(frame.document()); 203 ASSERT(frame.document());
204 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(*fr ame.document()); 204 RefPtrWillBeRawPtr<DocumentFragment> fragment = DocumentFragment::create(*fr ame.document());
205 TrackExceptionState exceptionState; 205 TrackExceptionState exceptionState;
206 fragment->appendChild(content, exceptionState); 206 fragment->appendChild(content, exceptionState);
207 if (exceptionState.hadException()) 207 if (exceptionState.hadException())
208 return false; 208 return false;
209 return executeInsertFragment(frame, fragment.release()); 209 return executeInsertFragment(frame, fragment.release());
210 } 210 }
211 211
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 String tagName = value.lower(); 436 String tagName = value.lower();
437 if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>') 437 if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>')
438 tagName = tagName.substring(1, tagName.length() - 2); 438 tagName = tagName.substring(1, tagName.length() - 2);
439 439
440 AtomicString localName, prefix; 440 AtomicString localName, prefix;
441 if (!Document::parseQualifiedName(AtomicString(tagName), prefix, localName, IGNORE_EXCEPTION)) 441 if (!Document::parseQualifiedName(AtomicString(tagName), prefix, localName, IGNORE_EXCEPTION))
442 return false; 442 return false;
443 QualifiedName qualifiedTagName(prefix, localName, xhtmlNamespaceURI); 443 QualifiedName qualifiedTagName(prefix, localName, xhtmlNamespaceURI);
444 444
445 ASSERT(frame.document()); 445 ASSERT(frame.document());
446 RefPtr<FormatBlockCommand> command = FormatBlockCommand::create(*frame.docum ent(), qualifiedTagName); 446 RefPtrWillBeRawPtr<FormatBlockCommand> command = FormatBlockCommand::create( *frame.document(), qualifiedTagName);
447 command->apply(); 447 command->apply();
448 return command->didApply(); 448 return command->didApply();
449 } 449 }
450 450
451 static bool executeForwardDelete(LocalFrame& frame, Event*, EditorCommandSource source, const String&) 451 static bool executeForwardDelete(LocalFrame& frame, Event*, EditorCommandSource source, const String&)
452 { 452 {
453 switch (source) { 453 switch (source) {
454 case CommandFromMenuOrKeyBinding: 454 case CommandFromMenuOrKeyBinding:
455 frame.editor().deleteWithDirection(DirectionForward, CharacterGranularit y, false, true); 455 frame.editor().deleteWithDirection(DirectionForward, CharacterGranularit y, false, true);
456 return true; 456 return true;
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 { 1734 {
1735 return m_command && m_command->isTextInsertion; 1735 return m_command && m_command->isTextInsertion;
1736 } 1736 }
1737 1737
1738 int Editor::Command::idForHistogram() const 1738 int Editor::Command::idForHistogram() const
1739 { 1739 {
1740 return isSupported() ? m_command->idForUserMetrics : 0; 1740 return isSupported() ? m_command->idForUserMetrics : 0;
1741 } 1741 }
1742 1742
1743 } // namespace WebCore 1743 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/Editor.cpp ('k') | Source/core/editing/FormatBlockCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698