Diff
Modified: trunk/Source/WTF/ChangeLog (117808 => 117809)
--- trunk/Source/WTF/ChangeLog 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WTF/ChangeLog 2012-05-21 19:36:39 UTC (rev 117809)
@@ -1,3 +1,25 @@
+2012-05-21 Andreas Kling <[email protected]>
+
+ CSS: Move duplicate property elimination to parser.
+ <http://webkit.org/b/86948>
+
+ Reviewed by Antti Koivisto.
+
+ Add WTF::BitArray, a simple, malloc free, fixed-size bit array class.
+
+ * GNUmakefile.list.am:
+ * WTF.gypi:
+ * WTF.pro:
+ * WTF.vcproj/WTF.vcproj:
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/BitArray.h: Added.
+ (WTF):
+ (BitArray):
+ (WTF::BitArray::BitArray):
+ (WTF::BitArray::set):
+ (WTF::BitArray::get):
+ * wtf/CMakeLists.txt:
+
2012-05-21 Allan Sandfeld Jensen <[email protected]>
Colliding isinf/isnan between C99 and C++11 with GCC >=4.6
Modified: trunk/Source/WTF/GNUmakefile.list.am (117808 => 117809)
--- trunk/Source/WTF/GNUmakefile.list.am 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WTF/GNUmakefile.list.am 2012-05-21 19:36:39 UTC (rev 117809)
@@ -12,6 +12,7 @@
Source/WTF/wtf/Assertions.cpp \
Source/WTF/wtf/Assertions.h \
Source/WTF/wtf/Atomics.h \
+ Source/WTF/wtf/BitArray.h \
Source/WTF/wtf/BitVector.cpp \
Source/WTF/wtf/BitVector.h \
Source/WTF/wtf/Bitmap.h \
Modified: trunk/Source/WTF/WTF.gypi (117808 => 117809)
--- trunk/Source/WTF/WTF.gypi 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WTF/WTF.gypi 2012-05-21 19:36:39 UTC (rev 117809)
@@ -8,6 +8,7 @@
'wtf/AlwaysInline.h',
'wtf/Assertions.h',
'wtf/Atomics.h',
+ 'wtf/BitArray.h',
'wtf/BitVector.h',
'wtf/Bitmap.h',
'wtf/BlockStack.h',
Modified: trunk/Source/WTF/WTF.pro (117808 => 117809)
--- trunk/Source/WTF/WTF.pro 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WTF/WTF.pro 2012-05-21 19:36:39 UTC (rev 117809)
@@ -22,6 +22,7 @@
Atomics.h \
AVLTree.h \
Bitmap.h \
+ BitArray.h \
BitVector.h \
BloomFilter.h \
BoundsCheckedPointer.h \
Modified: trunk/Source/WTF/WTF.vcproj/WTF.vcproj (117808 => 117809)
--- trunk/Source/WTF/WTF.vcproj/WTF.vcproj 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WTF/WTF.vcproj/WTF.vcproj 2012-05-21 19:36:39 UTC (rev 117809)
@@ -605,6 +605,10 @@
>
</File>
<File
+ RelativePath="..\wtf\BitArray.h"
+ >
+ </File>
+ <File
RelativePath="..\wtf\BitVector.cpp"
>
</File>
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (117808 => 117809)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2012-05-21 19:36:39 UTC (rev 117809)
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ 4F0321BC156AA8D1006EBAF6 /* BitArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F0321BB156AA8D1006EBAF6 /* BitArray.h */; };
A876DBD8151816E500DADB95 /* Platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A876DBD7151816E500DADB95 /* Platform.h */; };
A8A4737F151A825B004123FF /* Alignment.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47254151A825A004123FF /* Alignment.h */; };
A8A47380151A825B004123FF /* AlwaysInline.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A47255151A825A004123FF /* AlwaysInline.h */; };
@@ -240,6 +241,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ 4F0321BB156AA8D1006EBAF6 /* BitArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BitArray.h; sourceTree = "<group>"; };
5D247B6214689B8600E78B76 /* libWTF.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWTF.a; sourceTree = BUILT_PRODUCTS_DIR; };
5D247B6E14689C4700E78B76 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; };
5D247B6F14689C4700E78B76 /* CompilerVersion.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = CompilerVersion.xcconfig; sourceTree = "<group>"; };
@@ -546,6 +548,7 @@
A8A4725D151A825A004123FF /* Atomics.h */,
A8A4725E151A825A004123FF /* AVLTree.h */,
A8A4725F151A825A004123FF /* Bitmap.h */,
+ 4F0321BB156AA8D1006EBAF6 /* BitArray.h */,
A8A47260151A825A004123FF /* BitVector.cpp */,
A8A47261151A825A004123FF /* BitVector.h */,
A8A47264151A825A004123FF /* BlockStack.h */,
@@ -860,6 +863,7 @@
A8A47388151A825B004123FF /* Atomics.h in Headers */,
A8A47389151A825B004123FF /* AVLTree.h in Headers */,
A8A4738A151A825B004123FF /* Bitmap.h in Headers */,
+ 4F0321BC156AA8D1006EBAF6 /* BitArray.h in Headers */,
A8A4738C151A825B004123FF /* BitVector.h in Headers */,
A8A4738E151A825B004123FF /* BlockStack.h in Headers */,
A8A4738F151A825B004123FF /* BloomFilter.h in Headers */,
Added: trunk/Source/WTF/wtf/BitArray.h (0 => 117809)
--- trunk/Source/WTF/wtf/BitArray.h (rev 0)
+++ trunk/Source/WTF/wtf/BitArray.h 2012-05-21 19:36:39 UTC (rev 117809)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BitArray_h
+#define BitArray_h
+
+#include <string.h>
+#include <wtf/Assertions.h>
+
+namespace WTF {
+
+template<unsigned arraySize>
+class BitArray {
+public:
+ BitArray()
+ {
+ memset(m_data, 0, sizeof(m_data));
+ }
+
+ void set(unsigned index)
+ {
+ ASSERT(index < arraySize);
+ m_data[index / 8] |= 1 << (index & 7);
+ }
+
+ bool get(unsigned index) const
+ {
+ ASSERT(index < arraySize);
+ return !!(m_data[index / 8] & (1 << (index & 7)));
+ }
+
+private:
+ unsigned char m_data[arraySize / 8 + 1];
+};
+
+} // namespace WTF
+
+using WTF::BitArray;
+
+#endif // BitArray_h
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (117808 => 117809)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2012-05-21 19:36:39 UTC (rev 117809)
@@ -5,6 +5,7 @@
AlwaysInline.h
Assertions.h
Atomics.h
+ BitArray.h
BitVector.h
Bitmap.h
BoundsCheckedPointer.h
Modified: trunk/Source/WebCore/ChangeLog (117808 => 117809)
--- trunk/Source/WebCore/ChangeLog 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WebCore/ChangeLog 2012-05-21 19:36:39 UTC (rev 117809)
@@ -1,3 +1,36 @@
+2012-05-21 Andreas Kling <[email protected]>
+
+ CSS: Move duplicate property elimination to parser.
+ <http://webkit.org/b/86948>
+
+ Reviewed by Antti Koivisto.
+
+ Remove the StylePropertySet constructor that handled elimination of duplicate
+ properties and move that to a new parser method, CSSParser::filteredProperties().
+ Call sites are converted to using StylePropertySet(const Vector<CSSProperty>&).
+
+ Instead of building a hashmap of seen properties, use the new WTF::BitArray class
+ to track whether a given property ID has been seen, and whether we have an
+ !important entry for a given ID.
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseValue):
+ (WebCore::CSSParser::parseDeclaration):
+ (WebCore::CSSParser::filteredProperties):
+ (WebCore::CSSParser::createStyleRule):
+ (WebCore::CSSParser::createFontFaceRule):
+ (WebCore::CSSParser::createPageRule):
+ (WebCore::CSSParser::createKeyframe):
+ * css/CSSParser.h:
+ * css/StylePropertySet.cpp:
+ (WebCore::StylePropertySet::StylePropertySet):
+ (WebCore::StylePropertySet::addParsedProperties):
+ * css/StylePropertySet.h:
+ (WebCore::StylePropertySet::create):
+ (StylePropertySet):
+ * svg/SVGFontFaceElement.cpp:
+ (WebCore::SVGFontFaceElement::rebuildFontFace):
+
2012-05-21 Joshua Bell <[email protected]>
IndexedDB: Index key paths that yield invalid keys should not fail an add/put
Modified: trunk/Source/WebCore/css/CSSParser.cpp (117808 => 117809)
--- trunk/Source/WebCore/css/CSSParser.cpp 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2012-05-21 19:36:39 UTC (rev 117809)
@@ -89,6 +89,7 @@
#include "WebKitCSSShaderValue.h"
#endif
#include <limits.h>
+#include <wtf/BitArray.h>
#include <wtf/HexNumber.h>
#include <wtf/dtoa.h>
#include <wtf/text/StringBuffer.h>
@@ -977,7 +978,7 @@
deleteFontFaceOnlyValues();
if (!m_parsedProperties.isEmpty()) {
ok = true;
- declaration->addParsedProperties(m_parsedProperties.data(), m_parsedProperties.size());
+ declaration->addParsedProperties(m_parsedProperties);
clearProperties();
}
@@ -1073,7 +1074,7 @@
deleteFontFaceOnlyValues();
if (!m_parsedProperties.isEmpty()) {
ok = true;
- declaration->addParsedProperties(m_parsedProperties.data(), m_parsedProperties.size());
+ declaration->addParsedProperties(m_parsedProperties);
clearProperties();
}
@@ -1109,6 +1110,42 @@
return m_mediaQuery.release();
}
+Vector<CSSProperty> CSSParser::filteredProperties() const
+{
+ BitArray<numCSSProperties> seenProperties;
+ BitArray<numCSSProperties> seenImportantProperties;
+
+ Vector<CSSProperty> results;
+ results.reserveInitialCapacity(m_parsedProperties.size());
+
+ for (unsigned i = 0; i < m_parsedProperties.size(); ++i) {
+ const CSSProperty& property = m_parsedProperties[i];
+ const unsigned propertyIDIndex = property.id() - firstCSSProperty;
+
+ // Ignore non-important properties if we already have an important property with the same ID.
+ if (!property.isImportant() && seenImportantProperties.get(propertyIDIndex))
+ continue;
+
+ // If we already had this property, this new one takes precedence, so wipe out the old one.
+ if (seenProperties.get(propertyIDIndex)) {
+ for (unsigned i = 0; i < results.size(); ++i) {
+ if (results[i].id() == property.id()) {
+ results.remove(i);
+ break;
+ }
+ }
+ }
+
+ if (property.isImportant())
+ seenImportantProperties.set(propertyIDIndex);
+ seenProperties.set(propertyIDIndex);
+
+ results.append(property);
+ }
+
+ return results;
+}
+
void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important, bool implicit)
{
m_parsedProperties.append(CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand || implicit));
@@ -9041,7 +9078,7 @@
rule->parserAdoptSelectorVector(*selectors);
if (m_hasFontFaceOnlyValues)
deleteFontFaceOnlyValues();
- rule->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));
+ rule->setProperties(StylePropertySet::create(filteredProperties(), m_context.mode));
result = rule.get();
m_parsedRules.append(rule.release());
if (m_ruleRangeMap) {
@@ -9077,7 +9114,7 @@
}
}
RefPtr<StyleRuleFontFace> rule = StyleRuleFontFace::create();
- rule->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));
+ rule->setProperties(StylePropertySet::create(filteredProperties(), m_context.mode));
clearProperties();
StyleRuleFontFace* result = rule.get();
m_parsedRules.append(rule.release());
@@ -9150,7 +9187,7 @@
Vector<OwnPtr<CSSParserSelector> > selectorVector;
selectorVector.append(pageSelector);
rule->parserAdoptSelectorVector(selectorVector);
- rule->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));
+ rule->setProperties(StylePropertySet::create(filteredProperties(), m_context.mode));
pageRule = rule.get();
m_parsedRules.append(rule.release());
}
@@ -9228,7 +9265,7 @@
RefPtr<StyleKeyframe> keyframe = StyleKeyframe::create();
keyframe->setKeyText(keyString);
- keyframe->setProperties(StylePropertySet::create(m_parsedProperties.data(), m_parsedProperties.size(), m_context.mode));
+ keyframe->setProperties(StylePropertySet::create(filteredProperties(), m_context.mode));
clearProperties();
Modified: trunk/Source/WebCore/css/CSSParser.h (117808 => 117809)
--- trunk/Source/WebCore/css/CSSParser.h 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WebCore/css/CSSParser.h 2012-05-21 19:36:39 UTC (rev 117809)
@@ -282,6 +282,8 @@
void clearProperties();
+ Vector<CSSProperty> filteredProperties() const;
+
CSSParserContext m_context;
bool m_important;
Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (117808 => 117809)
--- trunk/Source/WebCore/css/StylePropertySet.cpp 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp 2012-05-21 19:36:39 UTC (rev 117809)
@@ -56,38 +56,14 @@
{
}
-StylePropertySet::StylePropertySet(const Vector<CSSProperty>& properties)
+StylePropertySet::StylePropertySet(const Vector<CSSProperty>& properties, CSSParserMode cssParserMode)
: m_properties(properties)
- , m_cssParserMode(CSSStrictMode)
+ , m_cssParserMode(cssParserMode)
, m_ownsCSSOMWrapper(false)
{
m_properties.shrinkToFit();
}
-StylePropertySet::StylePropertySet(const CSSProperty* properties, int numProperties, CSSParserMode cssParserMode)
- : m_cssParserMode(cssParserMode)
- , m_ownsCSSOMWrapper(false)
-{
- // FIXME: This logic belongs in CSSParser.
-
- m_properties.reserveInitialCapacity(numProperties);
- HashMap<int, bool> candidates;
- for (int i = 0; i < numProperties; ++i) {
- const CSSProperty& property = properties[i];
- bool important = property.isImportant();
-
- HashMap<int, bool>::iterator it = candidates.find(property.id());
- if (it != candidates.end()) {
- if (!important && it->second)
- continue;
- removeProperty(property.id());
- }
-
- m_properties.append(property);
- candidates.set(property.id(), important);
- }
-}
-
StylePropertySet::StylePropertySet(const StylePropertySet& o)
: RefCounted<StylePropertySet>()
, m_properties(o.m_properties)
@@ -592,10 +568,10 @@
parser.parseDeclaration(this, styleDeclaration, 0, contextStyleSheet);
}
-void StylePropertySet::addParsedProperties(const CSSProperty* properties, int numProperties)
+void StylePropertySet::addParsedProperties(const Vector<CSSProperty>& properties)
{
- m_properties.reserveCapacity(numProperties);
- for (int i = 0; i < numProperties; ++i)
+ m_properties.reserveCapacity(m_properties.size() + properties.size());
+ for (unsigned i = 0; i < properties.size(); ++i)
addParsedProperty(properties[i]);
}
Modified: trunk/Source/WebCore/css/StylePropertySet.h (117808 => 117809)
--- trunk/Source/WebCore/css/StylePropertySet.h 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WebCore/css/StylePropertySet.h 2012-05-21 19:36:39 UTC (rev 117809)
@@ -47,14 +47,10 @@
{
return adoptRef(new StylePropertySet(cssParserMode));
}
- static PassRefPtr<StylePropertySet> create(const CSSProperty* properties, int numProperties, CSSParserMode cssParserMode)
+ static PassRefPtr<StylePropertySet> create(const Vector<CSSProperty>& properties, CSSParserMode cssParserMode = CSSStrictMode)
{
- return adoptRef(new StylePropertySet(properties, numProperties, cssParserMode));
+ return adoptRef(new StylePropertySet(properties, cssParserMode));
}
- static PassRefPtr<StylePropertySet> create(const Vector<CSSProperty>& properties)
- {
- return adoptRef(new StylePropertySet(properties));
- }
unsigned propertyCount() const { return m_properties.size(); }
bool isEmpty() const { return m_properties.isEmpty(); }
@@ -80,7 +76,7 @@
void parseDeclaration(const String& styleDeclaration, StyleSheetInternal* contextStyleSheet);
- void addParsedProperties(const CSSProperty*, int numProperties);
+ void addParsedProperties(const Vector<CSSProperty>&);
void addParsedProperty(const CSSProperty&);
PassRefPtr<StylePropertySet> copyBlockProperties() const;
@@ -121,9 +117,8 @@
private:
StylePropertySet(CSSParserMode);
- StylePropertySet(const Vector<CSSProperty>&);
+ StylePropertySet(const Vector<CSSProperty>&, CSSParserMode);
StylePropertySet(const StylePropertySet&);
- StylePropertySet(const CSSProperty*, int numProperties, CSSParserMode);
void setNeedsStyleRecalc();
Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.cpp (117808 => 117809)
--- trunk/Source/WebCore/svg/SVGFontFaceElement.cpp 2012-05-21 19:28:01 UTC (rev 117808)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.cpp 2012-05-21 19:36:39 UTC (rev 117809)
@@ -297,8 +297,7 @@
return;
// Parse in-memory CSS rules
- CSSProperty srcProperty(CSSPropertySrc, list);
- m_fontFaceRule->properties()->addParsedProperties(&srcProperty, 1);
+ m_fontFaceRule->properties()->addParsedProperty(CSSProperty(CSSPropertySrc, list));
if (describesParentFont) {
// Traverse parsed CSS values and associate CSSFontFaceSrcValue elements with ourselves.