Title: [127375] trunk/Source/WebCore
- Revision
- 127375
- Author
- [email protected]
- Date
- 2012-09-01 10:47:39 -0700 (Sat, 01 Sep 2012)
Log Message
Share inline style between cloned Nodes (copy on write.)
<http://webkit.org/b/95451>
Reviewed by Antti Koivisto.
When cloning a Node, use an immutable StylePropertySet for the new Node's inline style.
If the old Node already had an immutable inline style, we now reuse that, avoiding a copy.
Copying is deferred until mutation (either via CSSOM or setting of the style attribute.)
* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::cloneDataFrom):
* css/StylePropertySet.h:
* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::immutableCopyIfNeeded):
Added. Simply returns 'this' if the object is already immutable, otherwise creates a new one.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (127374 => 127375)
--- trunk/Source/WebCore/ChangeLog 2012-09-01 17:36:51 UTC (rev 127374)
+++ trunk/Source/WebCore/ChangeLog 2012-09-01 17:47:39 UTC (rev 127375)
@@ -1,3 +1,22 @@
+2012-09-01 Andreas Kling <[email protected]>
+
+ Share inline style between cloned Nodes (copy on write.)
+ <http://webkit.org/b/95451>
+
+ Reviewed by Antti Koivisto.
+
+ When cloning a Node, use an immutable StylePropertySet for the new Node's inline style.
+ If the old Node already had an immutable inline style, we now reuse that, avoiding a copy.
+ Copying is deferred until mutation (either via CSSOM or setting of the style attribute.)
+
+ * dom/ElementAttributeData.cpp:
+ (WebCore::ElementAttributeData::cloneDataFrom):
+ * css/StylePropertySet.h:
+ * css/StylePropertySet.cpp:
+ (WebCore::StylePropertySet::immutableCopyIfNeeded):
+
+ Added. Simply returns 'this' if the object is already immutable, otherwise creates a new one.
+
2012-09-01 Dirk Schulze <[email protected]>
[Qt] Fix the --minimal build after r127327
Modified: trunk/Source/WebCore/css/StylePropertySet.cpp (127374 => 127375)
--- trunk/Source/WebCore/css/StylePropertySet.cpp 2012-09-01 17:36:51 UTC (rev 127374)
+++ trunk/Source/WebCore/css/StylePropertySet.cpp 2012-09-01 17:47:39 UTC (rev 127375)
@@ -61,6 +61,13 @@
return adoptRef(new (slot) StylePropertySet(properties, count, cssParserMode, /* makeMutable */ false));
}
+PassRefPtr<StylePropertySet> StylePropertySet::immutableCopyIfNeeded() const
+{
+ if (!isMutable())
+ return const_cast<StylePropertySet*>(this);
+ return createImmutable(m_mutablePropertyVector->data(), m_mutablePropertyVector->size(), cssParserMode());
+}
+
StylePropertySet::StylePropertySet(CSSParserMode cssParserMode)
: m_cssParserMode(cssParserMode)
, m_ownsCSSOMWrapper(false)
Modified: trunk/Source/WebCore/css/StylePropertySet.h (127374 => 127375)
--- trunk/Source/WebCore/css/StylePropertySet.h 2012-09-01 17:36:51 UTC (rev 127374)
+++ trunk/Source/WebCore/css/StylePropertySet.h 2012-09-01 17:47:39 UTC (rev 127375)
@@ -91,6 +91,7 @@
void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetContents* contextStyleSheet) const;
PassRefPtr<StylePropertySet> copy() const;
+ PassRefPtr<StylePropertySet> immutableCopyIfNeeded() const;
void removeEquivalentProperties(const StylePropertySet*);
void removeEquivalentProperties(const CSSStyleDeclaration*);
Modified: trunk/Source/WebCore/dom/ElementAttributeData.cpp (127374 => 127375)
--- trunk/Source/WebCore/dom/ElementAttributeData.cpp 2012-09-01 17:36:51 UTC (rev 127374)
+++ trunk/Source/WebCore/dom/ElementAttributeData.cpp 2012-09-01 17:47:39 UTC (rev 127375)
@@ -363,7 +363,7 @@
}
if (targetElement.isStyledElement() && sourceData.m_inlineStyleDecl) {
- m_inlineStyleDecl = sourceData.m_inlineStyleDecl->copy();
+ m_inlineStyleDecl = sourceData.m_inlineStyleDecl->immutableCopyIfNeeded();
targetElement.setIsStyleAttributeValid(sourceElement.isStyleAttributeValid());
}
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes