KDE/kdelibs/khtml

View: New views
1 Messages — Rating Filter:   Alert me  

KDE/kdelibs/khtml

by Bugzilla from germain@ebooksfrance.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

SVN commit 1046453 by ggarand:

rework synchronization of the |style| attribute so that is is done
lazzily on attribute retrieval instead.

 M  +1 -2      css/css_valueimpl.cpp  
 M  +7 -3      xml/dom_elementimpl.cpp  
 M  +2 -1      xml/dom_elementimpl.h  
 M  +3 -2      xml/dom_nodeimpl.cpp  
 M  +5 -2      xml/dom_nodeimpl.h  


--- trunk/KDE/kdelibs/khtml/css/css_valueimpl.cpp #1046452:1046453
@@ -685,8 +685,7 @@
 {
     if (m_node) {
         if (m_node->nodeType() == Node::ELEMENT_NODE && (static_cast<ElementImpl*>(m_node)->inlineStyleDecls() == this)) {
-            // FIXME: potentially costly...
-            static_cast<ElementImpl*>(m_node)->synchronizeStyleAttribute();
+            m_node->setNeedsStyleAttributeUpdate();
         }
         m_node->setChanged();
         return;
--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.cpp #1046452:1046453
@@ -587,8 +587,10 @@
 {
     // clone attributes
     if (namedAttrMap)
- clone->attributes()->copyAttributes(namedAttrMap);
+ clone->attributes()->copyAttributes(attributes(true));
 
+    assert( !m_needsStyleAttributeUpdate ); // ensured by previous line
+
     // clone individual style rules
     if (m_style.inlineDecls) {
         if (m_hasCombinedStyle) {
@@ -1368,9 +1370,11 @@
     document()->setFocusNode(this);
 }
 
-void ElementImpl::synchronizeStyleAttribute()
+void ElementImpl::synchronizeStyleAttribute() const
 {
-    DOMString value = getInlineStyleDecls()->cssText();
+    assert(inlineStyleDecls() && m_needsStyleAttributeUpdate);
+    m_needsStyleAttributeUpdate = false;
+    DOMString value = inlineStyleDecls()->cssText();
     attributes()->setValueWithoutElementUpdate(ATTR_STYLE, value.implementation());
 }
 
--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.h #1046452:1046453
@@ -260,6 +260,7 @@
 
     NamedAttrMapImpl* attributes(bool readonly = false) const
     {
+        if (m_needsStyleAttributeUpdate) synchronizeStyleAttribute();
         if (!readonly && !namedAttrMap) createAttributeMap();
         return namedAttrMap;
     }
@@ -349,7 +350,7 @@
     virtual void addId   (const DOMString& id);
 
     // Synchronize style attribute after it was changed via CSSOM
-    void synchronizeStyleAttribute();
+    void synchronizeStyleAttribute() const;
 
 protected:
     void createAttributeMap() const;
--- trunk/KDE/kdelibs/khtml/xml/dom_nodeimpl.cpp #1046452:1046453
@@ -78,7 +78,6 @@
       m_changedAscendentAttribute( false ),
       m_inDocument( false ),
       m_hasAnchor( false ),
-      m_elementHasRareData( false ),
       m_hovered( false ),
       m_focused( false ),
       m_active( false ),
@@ -86,7 +85,9 @@
       m_htmlCompat( false ),
       m_hasClass( false ),
       m_hasCombinedStyle( false ),
-      m_hasHoverDependency(false)
+      m_hasHoverDependency( false ),
+      m_elementHasRareData( false ),
+      m_needsStyleAttributeUpdate( false )
 {
 }
 
--- trunk/KDE/kdelibs/khtml/xml/dom_nodeimpl.h #1046452:1046453
@@ -280,6 +280,7 @@
     void setHTMLCompat(bool b) { m_htmlCompat = b; }
     bool hasHoverDependency() { return m_hasHoverDependency; }
     void setHasHoverDependency(bool b = true) { m_hasHoverDependency = b; }
+    void setNeedsStyleAttributeUpdate(bool b = true) { m_needsStyleAttributeUpdate = b; }
     virtual void setFocus(bool b=true) { m_focused = b; }
     virtual void setActive(bool b=true) { m_active = b; }
     virtual void setHovered(bool b=true) { m_hovered = b; }
@@ -527,7 +528,6 @@
     bool m_changedAscendentAttribute : 1;
     bool m_inDocument : 1;
     bool m_hasAnchor : 1;
-    bool m_elementHasRareData : 1;
 
     bool m_hovered : 1;
     bool m_focused : 1;
@@ -538,7 +538,10 @@
     bool m_hasCombinedStyle : 1; // true if element has inline styles and presentational styles
     bool m_hasHoverDependency : 1; // true if element has hover dependency on itself
 
-    // 15 bits left
+    bool m_elementHasRareData : 1;
+    mutable bool m_needsStyleAttributeUpdate : 1; // true if |style| attribute is out of sync (i.e. CSSOM modified our inline styles)
+
+    // 14 bits left
 };
 
 // this is the full Node Implementation with parents and children.
_______________________________________________
Khtml-cvs mailing list
Khtml-cvs@...
https://mail.kde.org/mailman/listinfo/khtml-cvs