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

List:       kde-commits
Subject:    kdenonbeta/khtml2/impl
From:       Nikolas Zimmermann <wildfox () kde ! org>
Date:       2005-07-12 14:09:38
Message-ID: 1121177378.707097.5536.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 433995 by wildfox:

This makes style recalculations work again for external css style sheets loaded \
through <link> elements. kde.org finally shows up! :-)
CCMAIL: buis@kde.org


 M  +60 -2     HTMLElementImpl.cc  


--- trunk/kdenonbeta/khtml2/impl/HTMLElementImpl.cc #433994:433995
@@ -26,6 +26,7 @@
 #include <kdom/impl/AttrImpl.h>
 #include <kdom/css/impl/cssvalues.h>
 #include <kdom/css/impl/cssproperties.h>
+#include <kdom/css/impl/CSSStyleSelector.h>
 #include <kdom/css/impl/CSSStyleSheetImpl.h>
 #include <kdom/events/impl/EventListenerImpl.h>
 #include <kdom/css/impl/CSSStyleDeclarationImpl.h>
@@ -192,10 +193,67 @@
 	return static_cast<RenderObject *>(m_render)->style();
 }
 
-void HTMLElementImpl::recalcStyle(KDOM::NodeImpl::StyleChange ch)
+void HTMLElementImpl::recalcStyle(KDOM::NodeImpl::StyleChange change)
 {
-	KDOM::ElementImpl::recalcStyle(ch);
+	kdDebug() << "recalcStyle here in htmlelementimpl!" << endl;
 
+	// In khtml(1) this lived in ElementImpl::recalcStyle()!
+	HTMLRenderStyle *_style = m_render ? static_cast<RenderObject *>(m_render)->style() \
: 0; +	bool hasParentRenderer = parentNode() ? parentNode()->attached() : false;
+	if(hasParentRenderer && (change >= Inherit || changed()))
+	{
+		KDOM::EDisplay oldDisplay = _style ? _style->display() : KDOM::DS_NONE;
+		KDOM::EPosition oldPosition = _style ? _style->position() : KDOM::PS_STATIC;
+
+		HTMLRenderStyle *newStyle = static_cast<HTMLRenderStyle \
*>(getDocument()->styleSelector()->styleForElement(this)); +		newStyle->ref();
+
+		StyleChange ch = diff(_style, newStyle);
+		if(ch != NoChange)
+		{
+			if(oldDisplay != newStyle->display() || oldPosition != newStyle->position())
+			{
+				if(attached())
+					detach();
+
+				// ### uuhm, suboptimal. style gets calculated again
+				attach();
+
+				// attach recalulates the style for all children. No need to do it twice.
+				setChanged(false);
+				setHasChangedChild(false);
+				newStyle->deref();
+				return;
+			}
+
+			if(m_render && newStyle)
+				static_cast<RenderObject *>(m_render)->setStyle(newStyle);
+		}
+
+		newStyle->deref();
+
+		if(change != Force)
+		{
+			if(getDocument()->usesDescendantRules())
+				change = Force;
+			else
+				change = ch;
+		}
+	}
+
+	NodeImpl *n;
+	for(n = firstChild(); n; n = n->nextSibling())
+	{
+		if(change >= Inherit || isTextNode(n) || n->hasChangedChild() || n->changed())
+		{
+			// qDebug("    (%p) calling recalcStyle on child %p/%s, change=%d", this, n, \
n->isElementNode() ? ((ElementImpl *)n)-> +			n->recalcStyle(change);
+		}
+	}
+
+	setChanged(false);
+	setHasChangedChild(false);
+
 	if(m_render)
 		static_cast<RenderObject *>(m_render)->updateFromElement();
 }


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

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