Title: [152935] trunk/Source/WebCore
- Revision
- 152935
- Author
- [email protected]
- Date
- 2013-07-19 17:58:36 -0700 (Fri, 19 Jul 2013)
Log Message
Cache style declaration CSSOM wrappers directly on MutableStylePropertySet.
<http://webkit.org/b/118883>
Reviewed by Gavin Barraclough
Merge https://chromium.googlesource.com/chromium/blink/+/183bcd51eb0e79cab930cf46695df05dc793630f
>From Blink r153700 by <[email protected]>:
In my measurements the mapping is adding more overhead than just having a field
in all MutableStylePropertySet objects. So this saves memory and makes access
faster.
* css/StylePropertySet.cpp:
(WebCore::MutableStylePropertySet::MutableStylePropertySet):
(WebCore::MutableStylePropertySet::~MutableStylePropertySet):
(WebCore::StylePropertySet::hasCSSOMWrapper):
(WebCore::MutableStylePropertySet::cssStyleDeclaration):
(WebCore::MutableStylePropertySet::ensureCSSStyleDeclaration):
(WebCore::MutableStylePropertySet::ensureInlineCSSStyleDeclaration):
* css/StylePropertySet.h:
(WebCore::StylePropertySet::StylePropertySet):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (152934 => 152935)
--- trunk/Source/WebCore/ChangeLog 2013-07-20 00:11:32 UTC (rev 152934)
+++ trunk/Source/WebCore/ChangeLog 2013-07-20 00:58:36 UTC (rev 152935)
@@ -1,3 +1,27 @@
+2013-07-19 Andreas Kling <[email protected]>
+
+ Cache style declaration CSSOM wrappers directly on MutableStylePropertySet.
+ <http://webkit.org/b/118883>
+
+ Reviewed by Gavin Barraclough
+
+ Merge https://chromium.googlesource.com/chromium/blink/+/183bcd51eb0e79cab930cf46695df05dc793630f
+ From Blink r153700 by <[email protected]>:
+
+ In my measurements the mapping is adding more overhead than just having a field
+ in all MutableStylePropertySet objects. So this saves memory and makes access
+ faster.
+
+ * css/StylePropertySet.cpp:
+ (WebCore::MutableStylePropertySet::MutableStylePropertySet):
+ (WebCore::MutableStylePropertySet::~MutableStylePropertySet):
+ (WebCore::StylePropertySet::hasCSSOMWrapper):
+ (WebCore::MutableStylePropertySet::cssStyleDeclaration):
+ (WebCore::MutableStylePropertySet::ensureCSSStyleDeclaration):
+ (WebCore::MutableStylePropertySet::ensureInlineCSSStyleDeclaration):
+ * css/StylePropertySet.h:
+ (WebCore::StylePropertySet::StylePropertySet):
+
2013-07-19 Brent Fulgham <[email protected]>
[Windows] Avoid passing addresses of temporaries to Windows API.
Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (152934 => 152935)
--- trunk/Source/WebCore/css/StylePropertySet.cpp 2013-07-20 00:11:32 UTC (rev 152934)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp 2013-07-20 00:58:36 UTC (rev 152935)
@@ -48,13 +48,6 @@
namespace WebCore {
-typedef HashMap<MutableStylePropertySet*, OwnPtr<PropertySetCSSStyleDeclaration> > PropertySetCSSOMWrapperMap;
-static PropertySetCSSOMWrapperMap& propertySetCSSOMWrapperMap()
-{
- DEFINE_STATIC_LOCAL(PropertySetCSSOMWrapperMap, propertySetCSSOMWrapperMapInstance, ());
- return propertySetCSSOMWrapperMapInstance;
-}
-
static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count)
{
return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(CSSValue*) * count + sizeof(StylePropertyMetadata) * count;
@@ -81,6 +74,11 @@
return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data(), mutableThis->m_propertyVector.size(), cssParserMode());
}
+MutableStylePropertySet::MutableStylePropertySet(CSSParserMode cssParserMode)
+ : StylePropertySet(cssParserMode)
+{
+}
+
MutableStylePropertySet::MutableStylePropertySet(const CSSProperty* properties, unsigned length)
: StylePropertySet(CSSStrictMode)
{
@@ -89,6 +87,10 @@
m_propertyVector.uncheckedAppend(properties[i]);
}
+MutableStylePropertySet::~MutableStylePropertySet()
+{
+}
+
ImmutableStylePropertySet::ImmutableStylePropertySet(const CSSProperty* properties, unsigned length, CSSParserMode cssParserMode)
: StylePropertySet(cssParserMode, length)
{
@@ -120,13 +122,6 @@
}
}
-MutableStylePropertySet::~MutableStylePropertySet()
-{
- ASSERT(!m_ownsCSSOMWrapper || propertySetCSSOMWrapperMap().contains(this));
- if (m_ownsCSSOMWrapper)
- propertySetCSSOMWrapperMap().remove(this);
-}
-
String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const
{
RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
@@ -1023,6 +1018,11 @@
return result.toString();
}
+bool StylePropertySet::hasCSSOMWrapper() const
+{
+ return m_isMutable && static_cast<const MutableStylePropertySet*>(this)->m_cssomWrapper;
+}
+
void MutableStylePropertySet::mergeAndOverrideOnConflict(const StylePropertySet* other)
{
unsigned size = other->propertyCount();
@@ -1197,34 +1197,28 @@
PropertySetCSSStyleDeclaration* MutableStylePropertySet::cssStyleDeclaration()
{
- if (!m_ownsCSSOMWrapper)
- return 0;
- return propertySetCSSOMWrapperMap().get(this);
+ return m_cssomWrapper.get();
}
CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration()
{
- if (m_ownsCSSOMWrapper) {
- ASSERT(!static_cast<CSSStyleDeclaration*>(propertySetCSSOMWrapperMap().get(this))->parentRule());
- ASSERT(!propertySetCSSOMWrapperMap().get(this)->parentElement());
- return propertySetCSSOMWrapperMap().get(this);
+ if (m_cssomWrapper) {
+ ASSERT(!static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentRule());
+ ASSERT(!m_cssomWrapper->parentElement());
+ return m_cssomWrapper.get();
}
- m_ownsCSSOMWrapper = true;
- PropertySetCSSStyleDeclaration* cssomWrapper = new PropertySetCSSStyleDeclaration(this);
- propertySetCSSOMWrapperMap().add(this, adoptPtr(cssomWrapper));
- return cssomWrapper;
+ m_cssomWrapper = adoptPtr(new PropertySetCSSStyleDeclaration(this));
+ return m_cssomWrapper.get();
}
CSSStyleDeclaration* MutableStylePropertySet::ensureInlineCSSStyleDeclaration(StyledElement* parentElement)
{
- if (m_ownsCSSOMWrapper) {
- ASSERT(propertySetCSSOMWrapperMap().get(this)->parentElement() == parentElement);
- return propertySetCSSOMWrapperMap().get(this);
+ if (m_cssomWrapper) {
+ ASSERT(m_cssomWrapper->parentElement() == parentElement);
+ return m_cssomWrapper.get();
}
- m_ownsCSSOMWrapper = true;
- PropertySetCSSStyleDeclaration* cssomWrapper = new InlineCSSStyleDeclaration(this, parentElement);
- propertySetCSSOMWrapperMap().add(this, adoptPtr(cssomWrapper));
- return cssomWrapper;
+ m_cssomWrapper = adoptPtr(new InlineCSSStyleDeclaration(this, parentElement));
+ return m_cssomWrapper.get();
}
unsigned StylePropertySet::averageSizeInBytes()
Modified: trunk/Source/WebCore/css/StylePropertySet.h (152934 => 152935)
--- trunk/Source/WebCore/css/StylePropertySet.h 2013-07-20 00:11:32 UTC (rev 152934)
+++ trunk/Source/WebCore/css/StylePropertySet.h 2013-07-20 00:58:36 UTC (rev 152935)
@@ -107,7 +107,7 @@
String asText() const;
bool isMutable() const { return m_isMutable; }
- bool hasCSSOMWrapper() const { return m_ownsCSSOMWrapper; }
+ bool hasCSSOMWrapper() const;
bool hasFailedOrCanceledSubresources() const;
@@ -122,14 +122,12 @@
protected:
StylePropertySet(CSSParserMode cssParserMode)
: m_cssParserMode(cssParserMode)
- , m_ownsCSSOMWrapper(false)
, m_isMutable(true)
, m_arraySize(0)
{ }
StylePropertySet(CSSParserMode cssParserMode, unsigned immutableArraySize)
: m_cssParserMode(cssParserMode)
- , m_ownsCSSOMWrapper(false)
, m_isMutable(false)
, m_arraySize(immutableArraySize)
{ }
@@ -137,9 +135,8 @@
int findPropertyIndex(CSSPropertyID) const;
unsigned m_cssParserMode : 2;
- mutable unsigned m_ownsCSSOMWrapper : 1;
mutable unsigned m_isMutable : 1;
- unsigned m_arraySize : 28;
+ unsigned m_arraySize : 29;
private:
String getShorthandValue(const StylePropertyShorthand&) const;
@@ -183,12 +180,10 @@
class MutableStylePropertySet : public StylePropertySet {
public:
- ~MutableStylePropertySet();
-
static PassRefPtr<MutableStylePropertySet> create(CSSParserMode = CSSQuirksMode);
static PassRefPtr<MutableStylePropertySet> create(const CSSProperty* properties, unsigned count);
- MutableStylePropertySet(const StylePropertySet&);
+ ~MutableStylePropertySet();
unsigned propertyCount() const { return m_propertyVector.size(); }
@@ -228,14 +223,15 @@
Vector<CSSProperty, 4> m_propertyVector;
private:
- MutableStylePropertySet(CSSParserMode cssParserMode)
- : StylePropertySet(cssParserMode)
- { }
-
+ explicit MutableStylePropertySet(CSSParserMode);
+ explicit MutableStylePropertySet(const StylePropertySet&);
MutableStylePropertySet(const CSSProperty* properties, unsigned count);
bool removeShorthandProperty(CSSPropertyID);
CSSProperty* findCSSPropertyWithID(CSSPropertyID);
+ OwnPtr<PropertySetCSSStyleDeclaration> m_cssomWrapper;
+
+ friend class StylePropertySet;
};
inline StylePropertyMetadata StylePropertySet::PropertyReference::propertyMetadata() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes