[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.1/kdelibs/khtml
From:       Maks Orlovich <maksim () kde ! org>
Date:       2008-08-07 22:02:30
Message-ID: 1218146550.269937.21883.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 843791 by orlovich:

- Add ability to rewrite attributes on their parsing.
This required making sure that if we have an AttrImpl it still gets passed down 
to parseAttribute, hence the changes in the overloads for that
- Use that ability to fix border=00 on tables, as suggested by Germain.
It seems to not always restyle properly when border attributed changed dynamically, though,
hence keeping this open.
CCBUG:167567


 M  +2 -0      html/html_tableimpl.cpp  
 M  +30 -3     xml/dom_elementimpl.cpp  
 M  +18 -2     xml/dom_elementimpl.h  


--- branches/KDE/4.1/kdelibs/khtml/html/html_tableimpl.cpp #843790:843791
@@ -454,6 +454,8 @@
         DOMString v = QString::number( border );
         addCSSLength(CSS_PROP_BORDER_WIDTH, v );
 
+        attr->rewriteValue( v );
+
         // wanted by HTML4 specs
         if(!border)
             frame = Void, rules = None;
--- branches/KDE/4.1/kdelibs/khtml/xml/dom_elementimpl.cpp #843790:843791
@@ -185,7 +185,7 @@
     if (m_element) {
 	if (m_attrId == ATTR_ID)
 	    m_element->updateId(oldVal, m_value);
-	m_element->parseAttribute(m_attrId, m_value);
+	m_element->parseAttribute  (this);
 	m_element->attributeChanged(m_attrId);
     }
 
@@ -218,6 +218,17 @@
     appendChild(ownerDocument()->createTextNode(v.implementation()), e);
 }
 
+void AttrImpl::rewriteValue( const DOMString& newValue )
+{
+    int ec;
+
+    // We want to avoid any notifications, so temporarily set m_element to 0
+    ElementImpl* saveElement = m_element;
+    m_element = 0;
+    setValue(newValue, ec);
+    m_element = saveElement;
+}
+
 void AttrImpl::setNodeValue( const DOMString &v, int &exceptioncode )
 {
     exceptioncode = 0;
@@ -306,6 +317,22 @@
     }
 }
 
+void AttributeImpl::rewriteValue( const DOMString& newValue )
+{
+    if (m_attrId) {
+	DOMStringImpl* value = newValue.implementation();
+	if (m_data.value == value)
+	    return;
+
+	m_data.value->deref();
+	m_data.value = value;
+	m_data.value->ref();
+    }
+    else {
+	m_data.attr->rewriteValue(newValue);
+    }
+}
+
 AttrImpl *AttributeImpl::createAttr(ElementImpl *element, DocumentImpl *docPtr)
 {
     if (m_attrId) {
@@ -1262,7 +1289,7 @@
 	    memmove(m_attrs+i,m_attrs+i+1,(m_attrCount-i-1)*sizeof(AttributeImpl));
 	    m_attrCount--;
 	    m_attrs = (AttributeImpl*)realloc(m_attrs,m_attrCount*sizeof(AttributeImpl));
-	    m_element->parseAttribute(id,0);
+	    m_element->parseNullAttribute(id);
 	    m_element->attributeChanged(id);
 	    return removed;
 	}
@@ -1473,7 +1500,7 @@
 	    memmove(m_attrs+i,m_attrs+i+1,(m_attrCount-i-1)*sizeof(AttributeImpl));
 	    m_attrCount--;
 	    m_attrs = (AttributeImpl*)realloc(m_attrs,m_attrCount*sizeof(AttributeImpl));
-	    m_element->parseAttribute(id,0);
+	    m_element->parseNullAttribute(id);
 	    m_element->attributeChanged(id);
 	    // ### dispatch mutation events
 	    return removed;
--- branches/KDE/4.1/kdelibs/khtml/xml/dom_elementimpl.h #843790:843791
@@ -91,6 +91,11 @@
     virtual NodeImpl::Id id() const { return m_attrId; }
     virtual void childrenChanged();
 
+    // This is used for when the value is normalized on setting by
+    // parseAttribute; it silently updates it w/o issuing any events, etc.
+    // Doesn't work for ATTR_ID!
+    void rewriteValue( const DOMString& newValue );
+
     virtual DOMString toString() const;
 
     void setElement(ElementImpl *element);
@@ -126,6 +131,9 @@
     AttrImpl *createAttr(ElementImpl *element, DocumentImpl *docPtr);
     void free();
 
+    // See the description for AttrImpl.
+    void rewriteValue( const DOMString& newValue );
+
     NodeImpl::Id m_attrId;
     union {
         DOMStringImpl *value;
@@ -202,13 +210,21 @@
 
     //This is always called, whenever an attribute changed
     virtual void parseAttribute(AttributeImpl *) {}
-    void parseAttribute(NodeImpl::Id attrId, DOMStringImpl *value) {
+
+    void parseNullAttribute(NodeImpl::Id attrId) {
 	AttributeImpl aimpl;
 	aimpl.m_attrId = attrId;
-	aimpl.m_data.value = value;
+	aimpl.m_data.value = 0;
 	parseAttribute(&aimpl);
     }
 
+    void parseAttribute(AttrImpl* fullAttr) {
+	AttributeImpl aimpl;
+	aimpl.m_attrId = 0;
+	aimpl.m_data.attr = fullAttr;
+	parseAttribute(&aimpl);
+    }
+
     // not part of the DOM
     void setAttributeMap ( NamedAttrMapImpl* list );
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic