OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #include "config.h" | 21 #include "config.h" |
22 #include "CSSStyleDeclaration.h" | 22 #include "CSSStyleDeclaration.h" |
23 | 23 |
24 #include "CSSMutableStyleDeclaration.h" | 24 #include "CSSMutableStyleDeclaration.h" |
25 #include "CSSMutableValue.h" | |
26 #include "CSSParser.h" | 25 #include "CSSParser.h" |
27 #include "CSSProperty.h" | 26 #include "CSSProperty.h" |
28 #include "CSSPropertyNames.h" | 27 #include "CSSPropertyNames.h" |
29 #include "CSSRule.h" | 28 #include "CSSRule.h" |
30 #include "Node.h" | |
31 #include "SVGElement.h" | |
32 #include <wtf/ASCIICType.h> | 29 #include <wtf/ASCIICType.h> |
33 | 30 |
34 using namespace WTF; | 31 using namespace WTF; |
35 | 32 |
36 namespace WebCore { | 33 namespace WebCore { |
37 | 34 |
38 CSSStyleDeclaration::CSSStyleDeclaration(CSSRule* parent) | 35 CSSStyleDeclaration::CSSStyleDeclaration(CSSRule* parent) |
39 : StyleBase(parent) | 36 : StyleBase(parent) |
40 { | 37 { |
41 } | 38 } |
42 | 39 |
43 PassRefPtr<CSSValue> CSSStyleDeclaration::getPropertyCSSValue(const String& prop
ertyName) | 40 PassRefPtr<CSSValue> CSSStyleDeclaration::getPropertyCSSValue(const String& prop
ertyName) |
44 { | 41 { |
45 int propID = cssPropertyID(propertyName); | 42 int propID = cssPropertyID(propertyName); |
46 if (!propID) | 43 if (!propID) |
47 return 0; | 44 return 0; |
48 | 45 return getPropertyCSSValue(propID); |
49 // Short-cut, not involving any change to the refcount. | |
50 if (!isMutableStyleDeclaration()) | |
51 return getPropertyCSSValue(propID); | |
52 | |
53 // Slow path. | |
54 RefPtr<CSSValue> value = getPropertyCSSValue(propID); | |
55 if (!value || !value->isMutableValue()) | |
56 return value.release(); | |
57 | |
58 Node* node = static_cast<CSSMutableStyleDeclaration*>(this)->node(); | |
59 if (!node || !node->isStyledElement()) | |
60 return value.release(); | |
61 | |
62 Node* associatedNode = static_cast<CSSMutableValue*>(value.get())->node(); | |
63 if (associatedNode) { | |
64 ASSERT(associatedNode == node); | |
65 return value.release(); | |
66 } | |
67 | |
68 static_cast<CSSMutableValue*>(value.get())->setNode(node); | |
69 return value.release(); | |
70 } | 46 } |
71 | 47 |
72 String CSSStyleDeclaration::getPropertyValue(const String &propertyName) | 48 String CSSStyleDeclaration::getPropertyValue(const String &propertyName) |
73 { | 49 { |
74 int propID = cssPropertyID(propertyName); | 50 int propID = cssPropertyID(propertyName); |
75 if (!propID) | 51 if (!propID) |
76 return String(); | 52 return String(); |
77 return getPropertyValue(propID); | 53 return getPropertyValue(propID); |
78 } | 54 } |
79 | 55 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 list.reserveInitialCapacity(length); | 153 list.reserveInitialCapacity(length); |
178 for (unsigned i = 0; i < length; i++) { | 154 for (unsigned i = 0; i < length; i++) { |
179 RefPtr<CSSValue> value = getPropertyCSSValue(set[i]); | 155 RefPtr<CSSValue> value = getPropertyCSSValue(set[i]); |
180 if (value) | 156 if (value) |
181 list.append(CSSProperty(set[i], value.release(), false)); | 157 list.append(CSSProperty(set[i], value.release(), false)); |
182 } | 158 } |
183 return CSSMutableStyleDeclaration::create(list); | 159 return CSSMutableStyleDeclaration::create(list); |
184 } | 160 } |
185 | 161 |
186 } // namespace WebCore | 162 } // namespace WebCore |
OLD | NEW |