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

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

Issue 18311002: Partial implementation of CSSVariablesMap for CSS Variables CSSOM (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Minor optimisation to clearVariables Created 7 years, 5 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
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details. 16 * Lesser General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Lesser General Public 18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software 19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301 USA 21 * 02110-1301 USA
22 */ 22 */
23 23
24 #include "config.h" 24 #include "config.h"
25 #include "core/css/CSSComputedStyleDeclaration.h" 25 #include "core/css/CSSComputedStyleDeclaration.h"
26 26
27 #include "CSSPropertyNames.h" 27 #include "CSSPropertyNames.h"
28 #include "FontFamilyNames.h" 28 #include "FontFamilyNames.h"
29 #include "RuntimeEnabledFeatures.h"
29 #include "core/css/BasicShapeFunctions.h" 30 #include "core/css/BasicShapeFunctions.h"
30 #include "core/css/CSSArrayFunctionValue.h" 31 #include "core/css/CSSArrayFunctionValue.h"
31 #include "core/css/CSSAspectRatioValue.h" 32 #include "core/css/CSSAspectRatioValue.h"
32 #include "core/css/CSSBorderImage.h" 33 #include "core/css/CSSBorderImage.h"
33 #include "core/css/CSSFilterValue.h" 34 #include "core/css/CSSFilterValue.h"
34 #include "core/css/CSSFunctionValue.h" 35 #include "core/css/CSSFunctionValue.h"
35 #include "core/css/CSSLineBoxContainValue.h" 36 #include "core/css/CSSLineBoxContainValue.h"
36 #include "core/css/CSSMixFunctionValue.h" 37 #include "core/css/CSSMixFunctionValue.h"
37 #include "core/css/CSSParser.h" 38 #include "core/css/CSSParser.h"
38 #include "core/css/CSSPrimitiveValue.h" 39 #include "core/css/CSSPrimitiveValue.h"
(...skipping 2963 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope rtyID) 3003 String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope rtyID)
3003 { 3004 {
3004 return getPropertyValue(propertyID); 3005 return getPropertyValue(propertyID);
3005 } 3006 }
3006 3007
3007 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const Strin g&, bool, ExceptionCode& ec) 3008 void CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const Strin g&, bool, ExceptionCode& ec)
3008 { 3009 {
3009 ec = NO_MODIFICATION_ALLOWED_ERR; 3010 ec = NO_MODIFICATION_ALLOWED_ERR;
3010 } 3011 }
3011 3012
3013 const HashMap<AtomicString, String>* CSSComputedStyleDeclaration::variableMap() const
3014 {
3015 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3016 Node* styledNode = this->styledNode();
3017 if (!styledNode)
3018 return 0;
3019 RefPtr<RenderStyle> style = styledNode->computedStyle(styledNode->isPseudoEl ement() ? NOPSEUDO : m_pseudoElementSpecifier);
3020 if (!style)
3021 return 0;
3022 return style->variables();
3023 }
3024
3025 unsigned CSSComputedStyleDeclaration::variableCount() const
3026 {
3027 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3028 const HashMap<AtomicString, String>* variables = variableMap();
3029 if (!variables)
3030 return 0;
3031 return variables->size();
3032 }
3033
3034 String CSSComputedStyleDeclaration::variableValue(const AtomicString& name) cons t
3035 {
3036 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3037 const HashMap<AtomicString, String>* variables = variableMap();
3038 if (!variables)
3039 return emptyString();
3040 HashMap<AtomicString, String>::const_iterator it = variables->find(name);
3041 if (it == variables->end())
3042 return emptyString();
3043 return it->value;
3044 }
3045
3046 void CSSComputedStyleDeclaration::setVariableValue(const AtomicString&, const St ring&, ExceptionCode& ec)
3047 {
3048 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3049 ec = NO_MODIFICATION_ALLOWED_ERR;
3050 }
3051
3052 bool CSSComputedStyleDeclaration::removeVariable(const AtomicString&)
3053 {
3054 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3055 return false;
3056 }
3057
3058 void CSSComputedStyleDeclaration::clearVariables(ExceptionCode& ec)
3059 {
3060 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled());
3061 ec = NO_MODIFICATION_ALLOWED_ERR;
3062 }
3063
3012 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getBackgroundShorthandValu e() const 3064 PassRefPtr<CSSValueList> CSSComputedStyleDeclaration::getBackgroundShorthandValu e() const
3013 { 3065 {
3014 static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSProperty BackgroundColor, CSSPropertyBackgroundImage, 3066 static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSProperty BackgroundColor, CSSPropertyBackgroundImage,
3015 CSSProperty BackgroundRepeat, CSSPropertyBackgroundAttachment, 3067 CSSProperty BackgroundRepeat, CSSPropertyBackgroundAttachment,
3016 CSSProperty BackgroundPosition }; 3068 CSSProperty BackgroundPosition };
3017 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin, 3069 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin,
3018 CSSPropertyB ackgroundClip }; 3070 CSSPropertyB ackgroundClip };
3019 3071
3020 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated(); 3072 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3021 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShortha nd(CSSPropertyBackground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(prope rtiesBeforeSlashSeperator)))); 3073 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShortha nd(CSSPropertyBackground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(prope rtiesBeforeSlashSeperator))));
3022 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShortha nd(CSSPropertyBackground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(proper tiesAfterSlashSeperator)))); 3074 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShortha nd(CSSPropertyBackground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(proper tiesAfterSlashSeperator))));
3023 return list.release(); 3075 return list.release();
3024 } 3076 }
3025 3077
3026 } // namespace WebCore 3078 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698