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 1046457 by ggarand:

better design for |style| attribute synchronization : use a specific
class for inline styles (CSSInlineStyleDeclarationImpl) that knows better
when to mark its node.

cleaner that way, and solves the problem that the node used to be marked as
needing sync upon initial |style| attribute parsing.

 M  +20 -3     css/css_valueimpl.cpp  
 M  +9 -1      css/css_valueimpl.h  
 M  +1 -5      html/html_elementimpl.cpp  
 M  +3 -3      xml/dom_elementimpl.cpp  
 M  +8 -6      xml/dom_elementimpl.h  


--- trunk/KDE/kdelibs/khtml/css/css_valueimpl.cpp #1046456:1046457
@@ -684,9 +684,6 @@
 void CSSStyleDeclarationImpl::setChanged()
 {
     if (m_node) {
-        if (m_node->nodeType() == Node::ELEMENT_NODE && (static_cast<ElementImpl*>(m_node)->inlineStyleDecls() == this)) {
-            m_node->setNeedsStyleAttributeUpdate();
-        }
         m_node->setChanged();
         return;
     }
@@ -877,7 +874,27 @@
     // ###
 }
 
+// --------------------------------------------------------------------------------------
 
+void CSSInlineStyleDeclarationImpl::setChanged()
+{
+    if (m_node)
+        m_node->setNeedsStyleAttributeUpdate();
+    CSSStyleDeclarationImpl::setChanged();
+}
+
+void CSSInlineStyleDeclarationImpl::updateFromAttribute(const DOMString &value)
+{
+    if(!m_lstValues) {
+ m_lstValues = new QList<CSSProperty*>;
+    } else {
+        clear();
+    }
+    CSSParser parser( strictParsing );
+    parser.parseDeclaration( this, value );
+    CSSStyleDeclarationImpl::setChanged();
+}
+
 // --------------------------------------------------------------------------------------
 
 unsigned short CSSInheritedValueImpl::cssValueType() const
--- trunk/KDE/kdelibs/khtml/css/css_valueimpl.h #1046456:1046457
@@ -91,7 +91,7 @@
     QList<CSSProperty*> *values() const { return m_lstValues; }
     void setNode(NodeImpl *_node) { m_node = _node; }
 
-    void setChanged();
+    virtual void setChanged();
 
     void removeCSSHints();
 
@@ -109,6 +109,14 @@
     CSSStyleDeclarationImpl(const CSSStyleDeclarationImpl& o);
 };
 
+class CSSInlineStyleDeclarationImpl : public CSSStyleDeclarationImpl
+{
+public:
+    CSSInlineStyleDeclarationImpl(CSSRuleImpl *parentRule): CSSStyleDeclarationImpl(parentRule) {}
+    virtual void setChanged();
+    void updateFromAttribute(const DOMString &value);
+};
+
 class CSSValueImpl : public StyleBaseImpl
 {
 public:
--- trunk/KDE/kdelibs/khtml/html/html_elementimpl.cpp #1046456:1046457
@@ -156,11 +156,7 @@
         setContentEditable(attr);
         break;
     case ATTR_STYLE:
-        if (inlineStyleDecls())
-    inlineStyleDecls()->clear();
- else
-    createInlineDecl();
-        inlineStyleDecls()->setProperty(attr->value());
+        getInlineStyleDecls()->updateFromAttribute(attr->value());
         setChanged();
         break;
     case ATTR_TABINDEX:
--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.cpp #1046456:1046457
@@ -1098,7 +1098,7 @@
 void ElementImpl::createNonCSSDecl()
 {
     assert(!m_hasCombinedStyle);
-    CSSStyleDeclarationImpl *ild = m_style.inlineDecls;
+    CSSInlineStyleDeclarationImpl *ild = m_style.inlineDecls;
     m_style.combinedDecls = new CombinedStyleDecl;
     m_style.combinedDecls->inlineDecls = ild;
     CSSStyleDeclarationImpl *ncd = new CSSStyleDeclarationImpl(0);
@@ -1110,7 +1110,7 @@
     m_hasCombinedStyle = true;
 }
 
-CSSStyleDeclarationImpl *ElementImpl::getInlineStyleDecls()
+CSSInlineStyleDeclarationImpl *ElementImpl::getInlineStyleDecls()
 {
     if (!inlineStyleDecls()) createInlineDecl();
         return inlineStyleDecls();
@@ -1120,7 +1120,7 @@
 {
     assert( !m_style.inlineDecls || (m_hasCombinedStyle && !m_style.combinedDecls->inlineDecls) );
 
-    CSSStyleDeclarationImpl *dcl = new CSSStyleDeclarationImpl(0);
+    CSSInlineStyleDeclarationImpl *dcl = new CSSInlineStyleDeclarationImpl(0);
     dcl->ref();
     dcl->setParent(document()->elementSheet());
     dcl->setNode(this);
--- trunk/KDE/kdelibs/khtml/xml/dom_elementimpl.h #1046456:1046457
@@ -48,6 +48,7 @@
 class DocumentImpl;
 class NamedAttrMapImpl;
 class ElementRareDataImpl;
+class CSSInlineStyleDeclarationImpl;
 
 // Attr can have Text and EntityReference children
 // therefore it has to be a fullblown Node. The plan
@@ -160,7 +161,7 @@
 
 struct CombinedStyleDecl
 {
-    DOM::CSSStyleDeclarationImpl *inlineDecls;
+    DOM::CSSInlineStyleDeclarationImpl *inlineDecls;
     DOM::CSSStyleDeclarationImpl *nonCSSDecls;
 };
 
@@ -178,7 +179,7 @@
     // stuff for WebCore DOM & SVG api compatibility
     virtual bool hasTagName(const QualifiedName& name) const { return qualifiedName() == name;/*should be matches here*/ }
     QualifiedName qualifiedName() const { return QualifiedName(id(), m_prefix); }
-    CSSStyleDeclarationImpl* style() { return getInlineStyleDecls(); }
+    CSSInlineStyleDeclarationImpl* style() { return getInlineStyleDecls(); }
     void setAttribute(const QualifiedName& name, const DOMString& value) {
         setAttribute(name.id(), value); /* is it enough for SVG or should the full setAttribute() be called? */
     }
@@ -313,9 +314,9 @@
 
     virtual bool childAllowed( NodeImpl *newChild );
     virtual bool childTypeAllowed( unsigned short type );
-    DOM::CSSStyleDeclarationImpl *inlineStyleDecls() const { return m_hasCombinedStyle ? m_style.combinedDecls->inlineDecls : m_style.inlineDecls; }
+    DOM::CSSInlineStyleDeclarationImpl *inlineStyleDecls() const { return m_hasCombinedStyle ? m_style.combinedDecls->inlineDecls : m_style.inlineDecls; }
     DOM::CSSStyleDeclarationImpl *nonCSSStyleDecls() const { return m_hasCombinedStyle ? m_style.combinedDecls->nonCSSDecls : 0; }
-    DOM::CSSStyleDeclarationImpl *getInlineStyleDecls();
+    DOM::CSSInlineStyleDeclarationImpl *getInlineStyleDecls();
 
     void dispatchAttrRemovalEvent(NodeImpl::Id id, DOMStringImpl *value);
     void dispatchAttrAdditionEvent(NodeImpl::Id id, DOMStringImpl *value);
@@ -371,7 +372,7 @@
     mutable NamedAttrMapImpl *namedAttrMap;
 
     union {
-        DOM::CSSStyleDeclarationImpl *inlineDecls;
+        DOM::CSSInlineStyleDeclarationImpl *inlineDecls;
         CombinedStyleDecl *combinedDecls;
     } m_style;
     PrefixName m_prefix;
@@ -540,9 +541,10 @@
     }
 }
 
-// methods that could be very hot they are need to be inlined
+// methods that could be very hot and therefore need to be inlined
 inline DOMStringImpl* ElementImpl::getAttributeImpl(NodeImpl::Id id, const PrefixName& prefix, bool nsAware) const
 {
+    if (m_needsStyleAttributeUpdate && (id == ATTR_STYLE)) synchronizeStyleAttribute();
     return namedAttrMap ? namedAttrMap->getValue(id, prefix, nsAware) : 0;
 }
 
_______________________________________________
Khtml-cvs mailing list
Khtml-cvs@...
https://mail.kde.org/mailman/listinfo/khtml-cvs