| 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, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
| 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #include "config.h" | 22 #include "config.h" |
| 23 #include "StylePropertySet.h" | 23 #include "StylePropertySet.h" |
| 24 | 24 |
| 25 #include "core/page/RuntimeCSSEnabled.h" |
| 25 #include "CSSParser.h" | 26 #include "CSSParser.h" |
| 26 #include "CSSValueKeywords.h" | 27 #include "CSSValueKeywords.h" |
| 27 #include "CSSValueList.h" | 28 #include "CSSValueList.h" |
| 28 #include "CSSValuePool.h" | 29 #include "CSSValuePool.h" |
| 29 #include "CSSVariableValue.h" | 30 #include "CSSVariableValue.h" |
| 30 #include "Document.h" | 31 #include "Document.h" |
| 31 #include "PropertySetCSSStyleDeclaration.h" | 32 #include "PropertySetCSSStyleDeclaration.h" |
| 32 #include "StylePropertyShorthand.h" | 33 #include "StylePropertyShorthand.h" |
| 33 #include "StyleSheetContents.h" | 34 #include "StyleSheetContents.h" |
| 34 #include <wtf/BitArray.h> | 35 #include <wtf/BitArray.h> |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 unsigned size = propertyCount(); | 1059 unsigned size = propertyCount(); |
| 1059 for (unsigned i = 0; i < size; ++i) { | 1060 for (unsigned i = 0; i < size; ++i) { |
| 1060 if (propertyAt(i).value()->hasFailedOrCanceledSubresources()) | 1061 if (propertyAt(i).value()->hasFailedOrCanceledSubresources()) |
| 1061 return true; | 1062 return true; |
| 1062 } | 1063 } |
| 1063 return false; | 1064 return false; |
| 1064 } | 1065 } |
| 1065 | 1066 |
| 1066 // This is the list of properties we want to copy in the copyBlockProperties() f
unction. | 1067 // This is the list of properties we want to copy in the copyBlockProperties() f
unction. |
| 1067 // It is the list of CSS properties that apply specially to block-level elements
. | 1068 // It is the list of CSS properties that apply specially to block-level elements
. |
| 1068 static const CSSPropertyID blockProperties[] = { | 1069 static const CSSPropertyID staticBlockProperties[] = { |
| 1069 CSSPropertyOrphans, | 1070 CSSPropertyOrphans, |
| 1070 CSSPropertyOverflow, // This can be also be applied to replaced elements | 1071 CSSPropertyOverflow, // This can be also be applied to replaced elements |
| 1071 CSSPropertyWebkitAspectRatio, | 1072 CSSPropertyWebkitAspectRatio, |
| 1072 CSSPropertyWebkitColumnCount, | 1073 CSSPropertyWebkitColumnCount, |
| 1073 CSSPropertyWebkitColumnGap, | 1074 CSSPropertyWebkitColumnGap, |
| 1074 CSSPropertyWebkitColumnRuleColor, | 1075 CSSPropertyWebkitColumnRuleColor, |
| 1075 CSSPropertyWebkitColumnRuleStyle, | 1076 CSSPropertyWebkitColumnRuleStyle, |
| 1076 CSSPropertyWebkitColumnRuleWidth, | 1077 CSSPropertyWebkitColumnRuleWidth, |
| 1077 CSSPropertyWebkitColumnBreakBefore, | 1078 CSSPropertyWebkitColumnBreakBefore, |
| 1078 CSSPropertyWebkitColumnBreakAfter, | 1079 CSSPropertyWebkitColumnBreakAfter, |
| 1079 CSSPropertyWebkitColumnBreakInside, | 1080 CSSPropertyWebkitColumnBreakInside, |
| 1080 CSSPropertyWebkitColumnWidth, | 1081 CSSPropertyWebkitColumnWidth, |
| 1081 CSSPropertyPageBreakAfter, | 1082 CSSPropertyPageBreakAfter, |
| 1082 CSSPropertyPageBreakBefore, | 1083 CSSPropertyPageBreakBefore, |
| 1083 CSSPropertyPageBreakInside, | 1084 CSSPropertyPageBreakInside, |
| 1084 #if ENABLE(CSS_REGIONS) | 1085 #if ENABLE(CSS_REGIONS) |
| 1085 CSSPropertyWebkitRegionBreakAfter, | 1086 CSSPropertyWebkitRegionBreakAfter, |
| 1086 CSSPropertyWebkitRegionBreakBefore, | 1087 CSSPropertyWebkitRegionBreakBefore, |
| 1087 CSSPropertyWebkitRegionBreakInside, | 1088 CSSPropertyWebkitRegionBreakInside, |
| 1088 #endif | 1089 #endif |
| 1089 CSSPropertyTextAlign, | 1090 CSSPropertyTextAlign, |
| 1090 #if ENABLE(CSS3_TEXT) | 1091 #if ENABLE(CSS3_TEXT) |
| 1091 CSSPropertyWebkitTextAlignLast, | 1092 CSSPropertyWebkitTextAlignLast, |
| 1092 #endif // CSS3_TEXT | 1093 #endif // CSS3_TEXT |
| 1093 CSSPropertyTextIndent, | 1094 CSSPropertyTextIndent, |
| 1094 CSSPropertyWidows | 1095 CSSPropertyWidows |
| 1095 }; | 1096 }; |
| 1096 | 1097 |
| 1098 static const Vector<CSSPropertyID>& blockProperties() |
| 1099 { |
| 1100 DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ()); |
| 1101 if (properties.isEmpty()) |
| 1102 RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticBlockPrope
rties, WTF_ARRAY_LENGTH(staticBlockProperties), properties); |
| 1103 return properties; |
| 1104 } |
| 1105 |
| 1097 void StylePropertySet::clear() | 1106 void StylePropertySet::clear() |
| 1098 { | 1107 { |
| 1099 ASSERT(isMutable()); | 1108 ASSERT(isMutable()); |
| 1100 mutablePropertyVector().clear(); | 1109 mutablePropertyVector().clear(); |
| 1101 } | 1110 } |
| 1102 | 1111 |
| 1103 const unsigned numBlockProperties = WTF_ARRAY_LENGTH(blockProperties); | |
| 1104 | |
| 1105 PassRefPtr<StylePropertySet> StylePropertySet::copyBlockProperties() const | 1112 PassRefPtr<StylePropertySet> StylePropertySet::copyBlockProperties() const |
| 1106 { | 1113 { |
| 1107 return copyPropertiesInSet(blockProperties, numBlockProperties); | 1114 return copyPropertiesInSet(blockProperties()); |
| 1108 } | 1115 } |
| 1109 | 1116 |
| 1110 void StylePropertySet::removeBlockProperties() | 1117 void StylePropertySet::removeBlockProperties() |
| 1111 { | 1118 { |
| 1112 removePropertiesInSet(blockProperties, numBlockProperties); | 1119 removePropertiesInSet(blockProperties().data(), blockProperties().size()); |
| 1113 } | 1120 } |
| 1114 | 1121 |
| 1115 bool StylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned
length) | 1122 bool StylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned
length) |
| 1116 { | 1123 { |
| 1117 ASSERT(isMutable()); | 1124 ASSERT(isMutable()); |
| 1118 if (mutablePropertyVector().isEmpty()) | 1125 if (mutablePropertyVector().isEmpty()) |
| 1119 return false; | 1126 return false; |
| 1120 | 1127 |
| 1121 // FIXME: This is always used with static sets and in that case constructing
the hash repeatedly is pretty pointless. | 1128 // FIXME: This is always used with static sets and in that case constructing
the hash repeatedly is pretty pointless. |
| 1122 HashSet<CSSPropertyID> toRemove; | 1129 HashSet<CSSPropertyID> toRemove; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 // FIXME: This should use mass removal. | 1203 // FIXME: This should use mass removal. |
| 1197 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) | 1204 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) |
| 1198 removeProperty(propertiesToRemove[i]); | 1205 removeProperty(propertiesToRemove[i]); |
| 1199 } | 1206 } |
| 1200 | 1207 |
| 1201 PassRefPtr<StylePropertySet> StylePropertySet::copy() const | 1208 PassRefPtr<StylePropertySet> StylePropertySet::copy() const |
| 1202 { | 1209 { |
| 1203 return adoptRef(new MutableStylePropertySet(*this)); | 1210 return adoptRef(new MutableStylePropertySet(*this)); |
| 1204 } | 1211 } |
| 1205 | 1212 |
| 1206 PassRefPtr<StylePropertySet> StylePropertySet::copyPropertiesInSet(const CSSProp
ertyID* set, unsigned length) const | 1213 PassRefPtr<StylePropertySet> StylePropertySet::copyPropertiesInSet(const Vector<
CSSPropertyID>& properties) const |
| 1207 { | 1214 { |
| 1208 Vector<CSSProperty, 256> list; | 1215 Vector<CSSProperty, 256> list; |
| 1209 list.reserveInitialCapacity(length); | 1216 list.reserveInitialCapacity(properties.size()); |
| 1210 for (unsigned i = 0; i < length; ++i) { | 1217 for (unsigned i = 0; i < properties.size(); ++i) { |
| 1211 RefPtr<CSSValue> value = getPropertyCSSValue(set[i]); | 1218 RefPtr<CSSValue> value = getPropertyCSSValue(properties[i]); |
| 1212 if (value) | 1219 if (value) |
| 1213 list.append(CSSProperty(set[i], value.release(), false)); | 1220 list.append(CSSProperty(properties[i], value.release(), false)); |
| 1214 } | 1221 } |
| 1215 return StylePropertySet::create(list.data(), list.size()); | 1222 return StylePropertySet::create(list.data(), list.size()); |
| 1216 } | 1223 } |
| 1217 | 1224 |
| 1218 PropertySetCSSStyleDeclaration* StylePropertySet::cssStyleDeclaration() | 1225 PropertySetCSSStyleDeclaration* StylePropertySet::cssStyleDeclaration() |
| 1219 { | 1226 { |
| 1220 if (!m_ownsCSSOMWrapper) | 1227 if (!m_ownsCSSOMWrapper) |
| 1221 return 0; | 1228 return 0; |
| 1222 ASSERT(isMutable()); | 1229 ASSERT(isMutable()); |
| 1223 return propertySetCSSOMWrapperMap().get(this); | 1230 return propertySetCSSOMWrapperMap().get(this); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 result.appendLiteral(": "); | 1318 result.appendLiteral(": "); |
| 1312 result.append(propertyValue()->cssText()); | 1319 result.append(propertyValue()->cssText()); |
| 1313 if (isImportant()) | 1320 if (isImportant()) |
| 1314 result.appendLiteral(" !important"); | 1321 result.appendLiteral(" !important"); |
| 1315 result.append(';'); | 1322 result.append(';'); |
| 1316 return result.toString(); | 1323 return result.toString(); |
| 1317 } | 1324 } |
| 1318 | 1325 |
| 1319 | 1326 |
| 1320 } // namespace WebCore | 1327 } // namespace WebCore |
| OLD | NEW |