Skip to content
Permalink
Browse files
Simplify cloning of inline style (below Node.cloneNode)
<http://webkit.org/b/95095>

Reviewed by Eric Seidel.

Just use StylePropertySet::copy() instead of copying the properties and CSS parser mode manually
when cloning an element that has inline style.

* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::StylePropertySet):
* css/StylePropertySet.h:
(StylePropertySet):
* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::cloneDataFrom):


Canonical link: https://commits.webkit.org/113049@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126872 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Aug 28, 2012
1 parent b19131d commit a9cf051bd00d290e6197c932be07f45d6746ad58
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
@@ -1,3 +1,20 @@
2012-08-28 Andreas Kling <kling@webkit.org>

Simplify cloning of inline style (below Node.cloneNode)
<http://webkit.org/b/95095>

Reviewed by Eric Seidel.

Just use StylePropertySet::copy() instead of copying the properties and CSS parser mode manually
when cloning an element that has inline style.

* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::StylePropertySet):
* css/StylePropertySet.h:
(StylePropertySet):
* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::cloneDataFrom):

2012-08-28 Sukolsak Sakshuwong <sukolsak@gmail.com>

Crash in EditingStyle::mergeStyle
@@ -87,15 +87,22 @@ StylePropertySet::StylePropertySet(const CSSProperty* properties, unsigned count
}
}

StylePropertySet::StylePropertySet(const StylePropertySet& o)
StylePropertySet::StylePropertySet(const StylePropertySet& other)
: RefCounted<StylePropertySet>()
, m_cssParserMode(o.m_cssParserMode)
, m_cssParserMode(other.m_cssParserMode)
, m_ownsCSSOMWrapper(false)
, m_isMutable(true)
, m_arraySize(0)
, m_mutablePropertyVector(new Vector<CSSProperty>)
{
copyPropertiesFrom(o);
if (other.isMutable())
*m_mutablePropertyVector = *other.m_mutablePropertyVector;
else {
m_mutablePropertyVector->clear();
m_mutablePropertyVector->reserveCapacity(other.m_arraySize);
for (unsigned i = 0; i < other.m_arraySize; ++i)
m_mutablePropertyVector->uncheckedAppend(other.array()[i]);
}
}

StylePropertySet::~StylePropertySet()
@@ -111,27 +118,6 @@ StylePropertySet::~StylePropertySet()
}
}

void StylePropertySet::setCSSParserMode(CSSParserMode cssParserMode)
{
ASSERT(isMutable());
m_cssParserMode = cssParserMode;
}

void StylePropertySet::copyPropertiesFrom(const StylePropertySet& other)
{
ASSERT(isMutable());

if (other.isMutable()) {
*m_mutablePropertyVector = *other.m_mutablePropertyVector;
return;
}

m_mutablePropertyVector->clear();
m_mutablePropertyVector->reserveCapacity(other.m_arraySize);
for (unsigned i = 0; i < other.m_arraySize; ++i)
m_mutablePropertyVector->uncheckedAppend(other.array()[i]);
}

String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const
{
RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
@@ -86,16 +86,12 @@ class StylePropertySet : public RefCounted<StylePropertySet> {

void mergeAndOverrideOnConflict(const StylePropertySet*);

void setCSSParserMode(CSSParserMode);
CSSParserMode cssParserMode() const { return static_cast<CSSParserMode>(m_cssParserMode); }

void addSubresourceStyleURLs(ListHashSet<KURL>&, StyleSheetContents* contextStyleSheet) const;

PassRefPtr<StylePropertySet> copy() const;

// Used by StyledElement::copyNonAttributeProperties().
void copyPropertiesFrom(const StylePropertySet&);

void removeEquivalentProperties(const StylePropertySet*);
void removeEquivalentProperties(const CSSStyleDeclaration*);

@@ -363,9 +363,7 @@ void ElementAttributeData::cloneDataFrom(const ElementAttributeData& sourceData,
}

if (targetElement.isStyledElement() && sourceData.m_inlineStyleDecl) {
StylePropertySet* inlineStyle = ensureMutableInlineStyle(static_cast<StyledElement*>(&targetElement));
inlineStyle->copyPropertiesFrom(*sourceData.m_inlineStyleDecl);
inlineStyle->setCSSParserMode(sourceData.m_inlineStyleDecl->cssParserMode());
m_inlineStyleDecl = sourceData.m_inlineStyleDecl->copy();
targetElement.setIsStyleAttributeValid(sourceElement.isStyleAttributeValid());
}
}

0 comments on commit a9cf051

Please sign in to comment.