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

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

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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) 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 static bool executeApplyStyle(LocalFrame& frame, EditorCommandSource source, Edi tAction action, CSSPropertyID propertyID, CSSValueID propertyValue) 128 static bool executeApplyStyle(LocalFrame& frame, EditorCommandSource source, Edi tAction action, CSSPropertyID propertyID, CSSValueID propertyValue)
129 { 129 {
130 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet: :create(); 130 RefPtrWillBeRawPtr<MutableStylePropertySet> style = MutableStylePropertySet: :create();
131 style->setProperty(propertyID, propertyValue); 131 style->setProperty(propertyID, propertyValue);
132 return applyCommandToFrame(frame, source, action, style.get()); 132 return applyCommandToFrame(frame, source, action, style.get());
133 } 133 }
134 134
135 // FIXME: executeToggleStyleInList does not handle complicated cases such as <b> <u>hello</u>world</b> properly. 135 // FIXME: executeToggleStyleInList does not handle complicated cases such as <b> <u>hello</u>world</b> properly.
136 // This function must use Editor::selectionHasStyle to determine the curr ent style but we cannot fix this 136 // This function must use Editor::selectionHasStyle to determine the curr ent style but we cannot fix this
137 // until https://bugs.webkit.org/show_bug.cgi?id=27818 is resolved. 137 // until https://bugs.webkit.org/show_bug.cgi?id=27818 is resolved.
138 static bool executeToggleStyleInList(LocalFrame& frame, EditorCommandSource sour ce, EditAction action, CSSPropertyID propertyID, CSSValue* value) 138 static bool executeToggleStyleInList(LocalFrame& frame, EditorCommandSource sour ce, EditAction action, CSSPropertyID propertyID, CSSValue value)
139 { 139 {
140 RefPtrWillBeRawPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelec tionStart(frame.selection().selection()); 140 RefPtrWillBeRawPtr<EditingStyle> selectionStyle = EditingStyle::styleAtSelec tionStart(frame.selection().selection());
141 if (!selectionStyle || !selectionStyle->style()) 141 if (!selectionStyle || !selectionStyle->style())
142 return false; 142 return false;
143 143
144 RefPtrWillBeRawPtr<CSSValue> selectedCSSValue = selectionStyle->style()->get PropertyCSSValue(propertyID); 144 NullableCSSValue selectedCSSValue = selectionStyle->style()->getPropertyCSSV alue(propertyID);
145 String newStyle("none"); 145 String newStyle("none");
Timothy Loh 2015/06/02 00:42:04 looks like the previous code expected this to be n
146 if (selectedCSSValue->isValueList()) { 146 if (selectedCSSValue && selectedCSSValue->isValueList()) {
147 RefPtrWillBeRawPtr<CSSValueList> selectedCSSValueList = toCSSValueList(s electedCSSValue.get()); 147 RefPtrWillBeRawPtr<CSSValueList> selectedCSSValueList = toCSSValueList(s electedCSSValue);
148 if (!selectedCSSValueList->removeAll(value)) 148 if (!selectedCSSValueList->removeAll(value))
149 selectedCSSValueList->append(value); 149 selectedCSSValueList->append(value);
150 if (selectedCSSValueList->length()) 150 if (selectedCSSValueList->length())
151 newStyle = selectedCSSValueList->cssText(); 151 newStyle = selectedCSSValueList->cssText();
152 152
153 } else if (selectedCSSValue->cssText() == "none") 153 } else if (selectedCSSValue && selectedCSSValue->cssText() == "none") {
154 newStyle = value->cssText(); 154 newStyle = value.cssText();
155 }
155 156
156 // FIXME: We shouldn't be having to convert new style into text. We should have setPropertyCSSValue. 157 // FIXME: We shouldn't be having to convert new style into text. We should have setPropertyCSSValue.
157 RefPtrWillBeRawPtr<MutableStylePropertySet> newMutableStyle = MutableStylePr opertySet::create(); 158 RefPtrWillBeRawPtr<MutableStylePropertySet> newMutableStyle = MutableStylePr opertySet::create();
158 newMutableStyle->setProperty(propertyID, newStyle); 159 newMutableStyle->setProperty(propertyID, newStyle);
159 return applyCommandToFrame(frame, source, action, newMutableStyle.get()); 160 return applyCommandToFrame(frame, source, action, newMutableStyle.get());
160 } 161 }
161 162
162 static bool executeToggleStyle(LocalFrame& frame, EditorCommandSource source, Ed itAction action, CSSPropertyID propertyID, const char* offValue, const char* onV alue) 163 static bool executeToggleStyle(LocalFrame& frame, EditorCommandSource source, Ed itAction action, CSSPropertyID propertyID, const char* offValue, const char* onV alue)
163 { 164 {
164 // Style is considered present when 165 // Style is considered present when
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 { 1788 {
1788 return m_command && m_command->isTextInsertion; 1789 return m_command && m_command->isTextInsertion;
1789 } 1790 }
1790 1791
1791 int Editor::Command::idForHistogram() const 1792 int Editor::Command::idForHistogram() const
1792 { 1793 {
1793 return isSupported() ? m_command->idForUserMetrics : 0; 1794 return isSupported() ? m_command->idForUserMetrics : 0;
1794 } 1795 }
1795 1796
1796 } // namespace blink 1797 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698