- Revision
- 128697
- Author
- [email protected]
- Date
- 2012-09-15 16:16:50 -0700 (Sat, 15 Sep 2012)
Log Message
REGRESSION(r127438): Google Docs to renders text too small.
<http://webkit.org/b/96554>
Reviewed by Antti Koivisto.
Source/WebCore:
Don't remove the inline StylePropertySet from ElementAttributeData in ~StyledElement.
This behavior broke sharing of ElementAttributeData between elements with inline style,
since destroying one element would effectively disable the inline style from all other
elements that shared the same attribute data.
What we actually want in ~StyledElement is to detach from any CSSOM wrapper that may
have been instantiated. Added ElementAttributeData::detachCSSOMWrapperIfNeeded for this
purpose and call that instead.
Test: fast/dom/shared-inline-style-after-node-removal.html
* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::detachCSSOMWrapperIfNeeded):
(WebCore::ElementAttributeData::destroyInlineStyle):
* dom/ElementAttributeData.h:
(ElementAttributeData):
* dom/StyledElement.cpp:
(WebCore::StyledElement::~StyledElement):
(WebCore::StyledElement::styleAttributeChanged):
* dom/StyledElement.h:
(StyledElement):
LayoutTests:
Add a test that an element that shared its inline style with another element works as expected
after the other element is destroyed.
* fast/dom/shared-inline-style-after-node-removal-expected.txt: Added.
* fast/dom/shared-inline-style-after-node-removal.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (128696 => 128697)
--- trunk/LayoutTests/ChangeLog 2012-09-15 22:59:03 UTC (rev 128696)
+++ trunk/LayoutTests/ChangeLog 2012-09-15 23:16:50 UTC (rev 128697)
@@ -1,3 +1,16 @@
+2012-09-15 Andreas Kling <[email protected]>
+
+ REGRESSION(r127438): Google Docs to renders text too small.
+ <http://webkit.org/b/96554>
+
+ Reviewed by Antti Koivisto.
+
+ Add a test that an element that shared its inline style with another element works as expected
+ after the other element is destroyed.
+
+ * fast/dom/shared-inline-style-after-node-removal-expected.txt: Added.
+ * fast/dom/shared-inline-style-after-node-removal.html: Added.
+
2012-09-15 Dan Bernstein <[email protected]>
REGRESSION (r125578): The monospace code path in RenderText::widthFromCache disagrees with Font::width on word spacing
Added: trunk/LayoutTests/fast/dom/shared-inline-style-after-node-removal-expected.txt (0 => 128697)
--- trunk/LayoutTests/fast/dom/shared-inline-style-after-node-removal-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/shared-inline-style-after-node-removal-expected.txt 2012-09-15 23:16:50 UTC (rev 128697)
@@ -0,0 +1,10 @@
+This test checks that an element that shared its inline style with one or more other elements still retain that style after one of the sharing elements was destroyed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS computedStyle.color is 'rgb(0, 128, 0)'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/shared-inline-style-after-node-removal.html (0 => 128697)
--- trunk/LayoutTests/fast/dom/shared-inline-style-after-node-removal.html (rev 0)
+++ trunk/LayoutTests/fast/dom/shared-inline-style-after-node-removal.html 2012-09-15 23:16:50 UTC (rev 128697)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<div id="test" style="color: red">
+ <p style="color: green"></p>
+ <p style="color: green"></p>
+</div>
+<script>
+
+jsTestIsAsync = true;
+
+description("This test checks that an element that shared its inline style with one or more other elements still retain that style after one of the sharing elements was destroyed.");
+
+var testDiv = document.getElementById('test');
+var pees = testDiv.getElementsByTagName('p');
+
+testDiv.removeChild(pees[1])
+
+setTimeout("callMeMaybe()", 10);
+gc();
+
+function callMeMaybe()
+{
+ var testDiv = document.getElementById('test');
+ var pees = testDiv.getElementsByTagName('p');
+
+ // Trigger a style recalc on pees[0].
+ pees[0].style.background = '';
+
+ computedStyle = getComputedStyle(pees[0]);
+ shouldBe("computedStyle.color", "'rgb(0, 128, 0)'");
+ finishJSTest();
+}
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (128696 => 128697)
--- trunk/Source/WebCore/ChangeLog 2012-09-15 22:59:03 UTC (rev 128696)
+++ trunk/Source/WebCore/ChangeLog 2012-09-15 23:16:50 UTC (rev 128697)
@@ -1,3 +1,32 @@
+2012-09-15 Andreas Kling <[email protected]>
+
+ REGRESSION(r127438): Google Docs to renders text too small.
+ <http://webkit.org/b/96554>
+
+ Reviewed by Antti Koivisto.
+
+ Don't remove the inline StylePropertySet from ElementAttributeData in ~StyledElement.
+ This behavior broke sharing of ElementAttributeData between elements with inline style,
+ since destroying one element would effectively disable the inline style from all other
+ elements that shared the same attribute data.
+
+ What we actually want in ~StyledElement is to detach from any CSSOM wrapper that may
+ have been instantiated. Added ElementAttributeData::detachCSSOMWrapperIfNeeded for this
+ purpose and call that instead.
+
+ Test: fast/dom/shared-inline-style-after-node-removal.html
+
+ * dom/ElementAttributeData.cpp:
+ (WebCore::ElementAttributeData::detachCSSOMWrapperIfNeeded):
+ (WebCore::ElementAttributeData::destroyInlineStyle):
+ * dom/ElementAttributeData.h:
+ (ElementAttributeData):
+ * dom/StyledElement.cpp:
+ (WebCore::StyledElement::~StyledElement):
+ (WebCore::StyledElement::styleAttributeChanged):
+ * dom/StyledElement.h:
+ (StyledElement):
+
2012-09-15 Kalev Lember <[email protected]>
[GTK] Include missing header files in the tarball
Modified: trunk/Source/WebCore/dom/ElementAttributeData.cpp (128696 => 128697)
--- trunk/Source/WebCore/dom/ElementAttributeData.cpp 2012-09-15 22:59:03 UTC (rev 128696)
+++ trunk/Source/WebCore/dom/ElementAttributeData.cpp 2012-09-15 23:16:50 UTC (rev 128697)
@@ -213,11 +213,15 @@
m_inlineStyleDecl->parseDeclaration(text, element->document()->elementSheet()->contents());
}
-void ElementAttributeData::destroyInlineStyle(StyledElement* element) const
+void ElementAttributeData::detachCSSOMWrapperIfNeeded(StyledElement* element)
{
- if (!m_inlineStyleDecl)
- return;
- m_inlineStyleDecl->clearParentElement(element);
+ if (m_inlineStyleDecl)
+ m_inlineStyleDecl->clearParentElement(element);
+}
+
+void ElementAttributeData::destroyInlineStyle(StyledElement* element)
+{
+ detachCSSOMWrapperIfNeeded(element);
m_inlineStyleDecl = 0;
}
Modified: trunk/Source/WebCore/dom/ElementAttributeData.h (128696 => 128697)
--- trunk/Source/WebCore/dom/ElementAttributeData.h 2012-09-15 22:59:03 UTC (rev 128696)
+++ trunk/Source/WebCore/dom/ElementAttributeData.h 2012-09-15 23:16:50 UTC (rev 128697)
@@ -58,7 +58,8 @@
StylePropertySet* ensureInlineStyle(StyledElement*);
StylePropertySet* ensureMutableInlineStyle(StyledElement*);
void updateInlineStyleAvoidingMutation(StyledElement*, const String& text) const;
- void destroyInlineStyle(StyledElement*) const;
+ void destroyInlineStyle(StyledElement*);
+ void detachCSSOMWrapperIfNeeded(StyledElement*);
const StylePropertySet* attributeStyle() const { return m_attributeStyle.get(); }
void setAttributeStyle(PassRefPtr<StylePropertySet> style) const { m_attributeStyle = style; }
Modified: trunk/Source/WebCore/dom/StyledElement.cpp (128696 => 128697)
--- trunk/Source/WebCore/dom/StyledElement.cpp 2012-09-15 22:59:03 UTC (rev 128696)
+++ trunk/Source/WebCore/dom/StyledElement.cpp 2012-09-15 23:16:50 UTC (rev 128697)
@@ -139,7 +139,8 @@
StyledElement::~StyledElement()
{
- destroyInlineStyle();
+ if (attributeData() && attributeData()->isMutable())
+ mutableAttributeData()->detachCSSOMWrapperIfNeeded(this);
}
CSSStyleDeclaration* StyledElement::style()
@@ -163,8 +164,8 @@
WTF::OrdinalNumber startLineNumber = WTF::OrdinalNumber::beforeFirst();
if (document() && document()->scriptableDocumentParser() && !document()->isInDocumentWrite())
startLineNumber = document()->scriptableDocumentParser()->lineNumber();
- if (newStyleString.isNull())
- destroyInlineStyle();
+ if (newStyleString.isNull() && attributeData())
+ mutableAttributeData()->destroyInlineStyle(this);
else if (document()->contentSecurityPolicy()->allowInlineStyle(document()->url(), startLineNumber))
ensureAttributeData()->updateInlineStyleAvoidingMutation(this, newStyleString);
setIsStyleAttributeValid();
Modified: trunk/Source/WebCore/dom/StyledElement.h (128696 => 128697)
--- trunk/Source/WebCore/dom/StyledElement.h 2012-09-15 22:59:03 UTC (rev 128696)
+++ trunk/Source/WebCore/dom/StyledElement.h 2012-09-15 23:16:50 UTC (rev 128697)
@@ -79,12 +79,6 @@
void makePresentationAttributeCacheKey(PresentationAttributeCacheKey&) const;
void updateAttributeStyle();
-
- void destroyInlineStyle()
- {
- if (attributeData())
- attributeData()->destroyInlineStyle(this);
- }
};
inline void StyledElement::invalidateStyleAttribute()