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

Side by Side Diff: Source/core/css/CSSComputedStyleDeclaration.cpp

Issue 21006006: Add forEach() to CSSVariablesMap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Corrected test expectations Created 7 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 3150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3161 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); 3161 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3162 const HashMap<AtomicString, String>* variables = variableMap(); 3162 const HashMap<AtomicString, String>* variables = variableMap();
3163 if (!variables) 3163 if (!variables)
3164 return emptyString(); 3164 return emptyString();
3165 HashMap<AtomicString, String>::const_iterator it = variables->find(name); 3165 HashMap<AtomicString, String>::const_iterator it = variables->find(name);
3166 if (it == variables->end()) 3166 if (it == variables->end())
3167 return emptyString(); 3167 return emptyString();
3168 return it->value; 3168 return it->value;
3169 } 3169 }
3170 3170
3171 void CSSComputedStyleDeclaration::setVariableValue(const AtomicString& name, con st String&, ExceptionState& es) 3171 bool CSSComputedStyleDeclaration::setVariableValue(const AtomicString& name, con st String&, ExceptionState& es)
3172 { 3172 {
3173 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); 3173 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3174 es.throwDOMException(NoModificationAllowedError, "Failed to set the '" + nam e + "' property on a computed 'CSSStyleDeclaration': computed styles are read-on ly."); 3174 es.throwDOMException(NoModificationAllowedError, "Failed to set the '" + nam e + "' property on a computed 'CSSStyleDeclaration': computed styles are read-on ly.");
3175 return false;
3175 } 3176 }
3176 3177
3177 bool CSSComputedStyleDeclaration::removeVariable(const AtomicString&) 3178 bool CSSComputedStyleDeclaration::removeVariable(const AtomicString&)
3178 { 3179 {
3179 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); 3180 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3180 return false; 3181 return false;
3181 } 3182 }
3182 3183
3183 void CSSComputedStyleDeclaration::clearVariables(ExceptionState& es) 3184 bool CSSComputedStyleDeclaration::clearVariables(ExceptionState& es)
3184 { 3185 {
3185 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); 3186 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3186 es.throwDOMException(NoModificationAllowedError, "Failed to clear variables from a computed 'CSSStyleDeclaration': computed styles are read-only."); 3187 es.throwDOMException(NoModificationAllowedError, "Failed to clear variables from a computed 'CSSStyleDeclaration': computed styles are read-only.");
3188 return false;
3189 }
3190
3191 CSSComputedStyleDeclaration::ComputedCSSVariablesIterator::ComputedCSSVariablesI terator(const HashMap<AtomicString, String>* variables)
3192 : m_active(variables)
3193 {
3194 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3195 if (m_active) {
3196 m_it = variables->begin();
3197 m_end = variables->end();
3198 }
3199 }
3200
3201 void CSSComputedStyleDeclaration::ComputedCSSVariablesIterator::advance()
3202 {
3203 ASSERT(m_active);
3204 ++m_it;
3205 m_active = !atEnd();
3206 }
3207
3208 AtomicString CSSComputedStyleDeclaration::ComputedCSSVariablesIterator::name() c onst
3209 {
3210 ASSERT(m_active);
3211 return m_it->key;
3212 }
3213
3214 String CSSComputedStyleDeclaration::ComputedCSSVariablesIterator::value() const
3215 {
3216 ASSERT(m_active);
3217 return m_it->value;
3187 } 3218 }
3188 3219
3189 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::valuesForBackgroundShortha nd() const 3220 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::valuesForBackgroundShortha nd() const
3190 { 3221 {
3191 static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSProperty BackgroundColor, CSSPropertyBackgroundImage, 3222 static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSProperty BackgroundColor, CSSPropertyBackgroundImage,
3192 CSSProperty BackgroundRepeat, CSSPropertyBackgroundAttachment, 3223 CSSProperty BackgroundRepeat, CSSPropertyBackgroundAttachment,
3193 CSSProperty BackgroundPosition }; 3224 CSSProperty BackgroundPosition };
3194 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin, 3225 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin,
3195 CSSPropertyB ackgroundClip }; 3226 CSSPropertyB ackgroundClip };
3196 3227
3197 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated(); 3228 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3198 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash Seperator)))); 3229 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash Seperator))));
3199 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe perator)))); 3230 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe perator))));
3200 return list.release(); 3231 return list.release();
3201 } 3232 }
3202 3233
3203 } // namespace WebCore 3234 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698