Title: [110450] trunk/Source/WebCore
Revision
110450
Author
[email protected]
Date
2012-03-12 11:51:32 -0700 (Mon, 12 Mar 2012)

Log Message

Restore Attr::style() functionality.
<http://webkit.org/b/80678>
<rdar://problem/10933904>

Reviewed by Antti Koivisto.

The neutering of Attr::style() in r106740 broke some internal clients of the Obj-C API,
so this was definitely premature.

Since we no longer have a per-Attribute style object, synthesize one in style() and
hang it off of the Attr. This grows Attr by one pointer, but it's a low-volume object
so it shouldn't matter much.

We recreate the StylePropertySet object on every call to style(), to avoid complicating
things with custom invalidation code.

* dom/Attr.cpp:
(WebCore::Attr::style):
* dom/Attr.h:
* dom/StyledElement.h:
(WebCore::StyledElement::collectStyleForAttribute):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110449 => 110450)


--- trunk/Source/WebCore/ChangeLog	2012-03-12 18:38:12 UTC (rev 110449)
+++ trunk/Source/WebCore/ChangeLog	2012-03-12 18:51:32 UTC (rev 110450)
@@ -1,3 +1,27 @@
+2012-03-12  Andreas Kling  <[email protected]>
+
+        Restore Attr::style() functionality.
+        <http://webkit.org/b/80678>
+        <rdar://problem/10933904>
+
+        Reviewed by Antti Koivisto.
+
+        The neutering of Attr::style() in r106740 broke some internal clients of the Obj-C API,
+        so this was definitely premature.
+
+        Since we no longer have a per-Attribute style object, synthesize one in style() and
+        hang it off of the Attr. This grows Attr by one pointer, but it's a low-volume object
+        so it shouldn't matter much.
+
+        We recreate the StylePropertySet object on every call to style(), to avoid complicating
+        things with custom invalidation code.
+
+        * dom/Attr.cpp:
+        (WebCore::Attr::style):
+        * dom/Attr.h:
+        * dom/StyledElement.h:
+        (WebCore::StyledElement::collectStyleForAttribute):
+
 2012-03-12  Ryosuke Niwa  <[email protected]>
 
         REGRESSION(r109285): Crash in WebCore::Document::nodeChildrenWillBeRemoved

Modified: trunk/Source/WebCore/dom/Attr.cpp (110449 => 110450)


--- trunk/Source/WebCore/dom/Attr.cpp	2012-03-12 18:38:12 UTC (rev 110449)
+++ trunk/Source/WebCore/dom/Attr.cpp	2012-03-12 18:51:32 UTC (rev 110450)
@@ -23,10 +23,10 @@
 #include "config.h"
 #include "Attr.h"
 
-#include "Element.h"
 #include "ExceptionCode.h"
 #include "HTMLNames.h"
 #include "ScopedEventQueue.h"
+#include "StyledElement.h"
 #include "Text.h"
 #include "XMLNSNames.h"
 #include <wtf/text/AtomicString.h>
@@ -196,4 +196,14 @@
     return qualifiedName().matches(document()->idAttributeName());
 }
 
+CSSStyleDeclaration* Attr::style()
+{
+    // This function only exists to support the Obj-C bindings.
+    if (!m_element->isStyledElement())
+        return 0;
+    m_style = StylePropertySet::create();
+    static_cast<StyledElement*>(m_element)->collectStyleForAttribute(m_attribute.get(), m_style.get());
+    return m_style->ensureCSSStyleDeclaration();
 }
+
+}

Modified: trunk/Source/WebCore/dom/Attr.h (110449 => 110450)


--- trunk/Source/WebCore/dom/Attr.h	2012-03-12 18:38:12 UTC (rev 110449)
+++ trunk/Source/WebCore/dom/Attr.h	2012-03-12 18:51:32 UTC (rev 110450)
@@ -31,6 +31,7 @@
 namespace WebCore {
 
 class CSSStyleDeclaration;
+class StylePropertySet;
 
 // Attr can have Text and EntityReference children
 // therefore it has to be a fullblown Node. The plan
@@ -58,9 +59,7 @@
 
     bool isId() const;
 
-    // A deprecated extension to get presentational information for attributes.
-    // We have to keep it around because it's exposed in the Obj-C DOM API.
-    CSSStyleDeclaration* style() { return 0; }
+    CSSStyleDeclaration* style();
 
     void setSpecified(bool specified) { m_specified = specified; }
 
@@ -93,6 +92,7 @@
 
     Element* m_element;
     RefPtr<Attribute> m_attribute;
+    RefPtr<StylePropertySet> m_style;
     unsigned m_ignoreChildrenChanged : 31;
     bool m_specified : 1;
 };

Modified: trunk/Source/WebCore/dom/StyledElement.h (110449 => 110450)


--- trunk/Source/WebCore/dom/StyledElement.h	2012-03-12 18:38:12 UTC (rev 110449)
+++ trunk/Source/WebCore/dom/StyledElement.h	2012-03-12 18:51:32 UTC (rev 110450)
@@ -55,6 +55,8 @@
 
     const SpaceSplitString& classNames() const;
 
+    virtual void collectStyleForAttribute(Attribute*, StylePropertySet*) { }
+
 protected:
     StyledElement(const QualifiedName& name, Document* document, ConstructionType type)
         : Element(name, document, type)
@@ -66,7 +68,6 @@
     virtual void copyNonAttributeProperties(const Element*);
 
     virtual bool isPresentationAttribute(const QualifiedName&) const { return false; }
-    virtual void collectStyleForAttribute(Attribute*, StylePropertySet*) { }
 
     void addPropertyToAttributeStyle(StylePropertySet*, int propertyID, int identifier);
     void addPropertyToAttributeStyle(StylePropertySet*, int propertyID, double value, CSSPrimitiveValue::UnitTypes);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to