[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:20:21 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit ed93ca7477109549a7fd5ce31a3387c9b0e8cd4c
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 20 21:59:15 2003 +0000

    	Fixes for 3150561 (blog articles vanish on stylesheet switch) and
            and 3150560 (crash changing fixed positioned element to normal
            positioning dynamically).
    
            This change makes layers able to deal with dynamic changes in
            position that cause you to have to either remove a layer from
            the hierarchy while preserving the children or to insert a
            layer into the hierarchy in between a parent and its descendants.
    
    	This patch also rewrites :hover/:active so that they can actually
    	be used in selectors other than the rightmost selector (e.g., so you
    	can write a rule like "li:hover > a").
    
    	Also, layers will now properly clear out their hover/active state
    	when the mouse is no longer inside them.
    
    	With these fixes, Eric Meyer's "Pure CSS Menus" work (perfectly)
    	and the repainting problems on sites like brainjar.com and
    	diveintomark.org and wired.com are fixed.
    
            Reviewed by mjs and john.
    
            * khtml/css/css_stylesheetimpl.h:
            * khtml/css/cssparser.cpp:
            (StyleBaseImpl::parseSelector):
            * khtml/css/cssparser.h:
            * khtml/css/cssstyleselector.cpp:
            * khtml/css/cssstyleselector.h:
            * khtml/dom/html_head.cpp:
            (HTMLLinkElement::setDisabled):
            * khtml/rendering/render_box.cpp:
            (RenderBox::setStyle):
            * khtml/rendering/render_box.h:
            * khtml/rendering/render_container.cpp:
            (RenderContainer::appendChildNode):
            (RenderContainer::insertChildNode):
            * khtml/rendering/render_flow.cpp:
            (RenderFlow::setStyle):
            * khtml/rendering/render_flow.h:
            * khtml/rendering/render_layer.cpp:
            (RenderLayer::addChild):
            (RenderLayer::removeOnlyThisLayer):
            (RenderLayer::insertOnlyThisLayer):
            (RenderLayer::clearOtherLayersHoverActiveState):
            (RenderLayer::clearHoverAndActiveState):
            (RenderLayer::nodeAtPoint):
            (RenderLayer::constructZTree):
            * khtml/rendering/render_layer.h:
            * khtml/rendering/render_object.cpp:
            (RenderObject::addLayers):
            (RenderObject::moveLayers):
            (RenderObject::findNextLayer):
            (RenderObject::setStyle):
            (RenderObject::setHoverAndActive):
            * khtml/rendering/render_object.h:
            * khtml/rendering/render_style.cpp:
            (RenderStyle::diff):
            * khtml/rendering/render_style.h:
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::DocumentImpl):
            * khtml/xml/dom_docimpl.h:
            * khtml/xml/dom_elementimpl.cpp:
            (ElementImpl::recalcStyle):
            * khtml/xml/dom_nodeimpl.cpp:
            (NodeBaseImpl::setActive):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3356 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index c136e89..d97f0c0 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,71 @@
+2003-01-19  David Hyatt  <hyatt at apple.com>
+
+	Fixes for 3150561 (blog articles vanish on stylesheet switch) and
+        and 3150560 (crash changing fixed positioned element to normal
+        positioning dynamically).
+
+        This change makes layers able to deal with dynamic changes in
+        position that cause you to have to either remove a layer from
+        the hierarchy while preserving the children or to insert a
+        layer into the hierarchy in between a parent and its descendants.
+
+	This patch also rewrites :hover/:active so that they can actually
+	be used in selectors other than the rightmost selector (e.g., so you
+	can write a rule like "li:hover > a").  
+
+	Also, layers will now properly clear out their hover/active state
+	when the mouse is no longer inside them.
+
+	With these fixes, Eric Meyer's "Pure CSS Menus" work (perfectly)
+	and the repainting problems on sites like brainjar.com and
+	diveintomark.org and wired.com are fixed.
+	
+        Reviewed by mjs and john.
+
+        * khtml/css/css_stylesheetimpl.h:
+        * khtml/css/cssparser.cpp:
+        (StyleBaseImpl::parseSelector):
+        * khtml/css/cssparser.h:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/cssstyleselector.h:
+        * khtml/dom/html_head.cpp:
+        (HTMLLinkElement::setDisabled):
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::setStyle):
+        * khtml/rendering/render_box.h:
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::appendChildNode):
+        (RenderContainer::insertChildNode):
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::setStyle):
+        * khtml/rendering/render_flow.h:
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::addChild):
+        (RenderLayer::removeOnlyThisLayer):
+        (RenderLayer::insertOnlyThisLayer):
+        (RenderLayer::clearOtherLayersHoverActiveState):
+        (RenderLayer::clearHoverAndActiveState):
+        (RenderLayer::nodeAtPoint):
+        (RenderLayer::constructZTree):
+        * khtml/rendering/render_layer.h:
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::addLayers):
+        (RenderObject::moveLayers):
+        (RenderObject::findNextLayer):
+        (RenderObject::setStyle):
+        (RenderObject::setHoverAndActive):
+        * khtml/rendering/render_object.h:
+        * khtml/rendering/render_style.cpp:
+        (RenderStyle::diff):
+        * khtml/rendering/render_style.h:
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_elementimpl.cpp:
+        (ElementImpl::recalcStyle):
+        * khtml/xml/dom_nodeimpl.cpp:
+        (NodeBaseImpl::setActive):
+
 2003-01-17  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by John.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c136e89..d97f0c0 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,71 @@
+2003-01-19  David Hyatt  <hyatt at apple.com>
+
+	Fixes for 3150561 (blog articles vanish on stylesheet switch) and
+        and 3150560 (crash changing fixed positioned element to normal
+        positioning dynamically).
+
+        This change makes layers able to deal with dynamic changes in
+        position that cause you to have to either remove a layer from
+        the hierarchy while preserving the children or to insert a
+        layer into the hierarchy in between a parent and its descendants.
+
+	This patch also rewrites :hover/:active so that they can actually
+	be used in selectors other than the rightmost selector (e.g., so you
+	can write a rule like "li:hover > a").  
+
+	Also, layers will now properly clear out their hover/active state
+	when the mouse is no longer inside them.
+
+	With these fixes, Eric Meyer's "Pure CSS Menus" work (perfectly)
+	and the repainting problems on sites like brainjar.com and
+	diveintomark.org and wired.com are fixed.
+	
+        Reviewed by mjs and john.
+
+        * khtml/css/css_stylesheetimpl.h:
+        * khtml/css/cssparser.cpp:
+        (StyleBaseImpl::parseSelector):
+        * khtml/css/cssparser.h:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/cssstyleselector.h:
+        * khtml/dom/html_head.cpp:
+        (HTMLLinkElement::setDisabled):
+        * khtml/rendering/render_box.cpp:
+        (RenderBox::setStyle):
+        * khtml/rendering/render_box.h:
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::appendChildNode):
+        (RenderContainer::insertChildNode):
+        * khtml/rendering/render_flow.cpp:
+        (RenderFlow::setStyle):
+        * khtml/rendering/render_flow.h:
+        * khtml/rendering/render_layer.cpp:
+        (RenderLayer::addChild):
+        (RenderLayer::removeOnlyThisLayer):
+        (RenderLayer::insertOnlyThisLayer):
+        (RenderLayer::clearOtherLayersHoverActiveState):
+        (RenderLayer::clearHoverAndActiveState):
+        (RenderLayer::nodeAtPoint):
+        (RenderLayer::constructZTree):
+        * khtml/rendering/render_layer.h:
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::addLayers):
+        (RenderObject::moveLayers):
+        (RenderObject::findNextLayer):
+        (RenderObject::setStyle):
+        (RenderObject::setHoverAndActive):
+        * khtml/rendering/render_object.h:
+        * khtml/rendering/render_style.cpp:
+        (RenderStyle::diff):
+        * khtml/rendering/render_style.h:
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_elementimpl.cpp:
+        (ElementImpl::recalcStyle):
+        * khtml/xml/dom_nodeimpl.cpp:
+        (NodeBaseImpl::setActive):
+
 2003-01-17  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by John.
diff --git a/WebCore/khtml/css/cssparser.cpp b/WebCore/khtml/css/cssparser.cpp
index 7aeaa75..537ef83 100644
--- a/WebCore/khtml/css/cssparser.cpp
+++ b/WebCore/khtml/css/cssparser.cpp
@@ -689,6 +689,27 @@ StyleBaseImpl::parseSelector(const QChar *curP, const QChar *endP)
                 slist->setAutoDelete(true);
             }
             slist->append(selector);
+            if (!sawDescendantRule && 
+                (selector->relation == CSSSelector::Descendant || 
+                 selector->relation == CSSSelector::Child)) {
+                // We encountered a descendant rule.  Get our document and set its
+                // descendant rule flag to true.
+                sawDescendantRule = true;
+                StyleBaseImpl *b = this;
+                StyleBaseImpl *root = this;
+                while (b) {
+                    root = b;
+                    b = b->m_parent;
+                }
+            
+                if (root && root->isStyleSheet()) {
+                    StyleSheetImpl *sheet = static_cast<StyleSheetImpl *>(root);
+                    if (sheet->ownerNode()) {
+                        DocumentImpl *doc = sheet->ownerNode()->getDocument();
+                        doc->setUsesDescendantRules(true);
+                    }
+                }
+            }
         }
         else
         {
diff --git a/WebCore/khtml/css/cssparser.h b/WebCore/khtml/css/cssparser.h
index 0618e54..cda4f48 100644
--- a/WebCore/khtml/css/cssparser.h
+++ b/WebCore/khtml/css/cssparser.h
@@ -142,8 +142,8 @@ private:
     class StyleBaseImpl : public khtml::TreeShared<StyleBaseImpl>
     {
     public:
-	StyleBaseImpl()  { m_parent = 0; hasInlinedDecl = false; strictParsing = true; }
-	StyleBaseImpl(StyleBaseImpl *p) { m_parent = p; hasInlinedDecl = false; strictParsing = (m_parent ? m_parent->useStrictParsing() : true); }
+	StyleBaseImpl()  { m_parent = 0; hasInlinedDecl = false; strictParsing = true; sawDescendantRule = false; }
+	StyleBaseImpl(StyleBaseImpl *p) { m_parent = p; hasInlinedDecl = false; strictParsing = (m_parent ? m_parent->useStrictParsing() : true); sawDescendantRule = false; }
 
 	virtual ~StyleBaseImpl() {}
 
@@ -238,6 +238,7 @@ private:
     protected:
 	bool hasInlinedDecl : 1;
 	bool strictParsing : 1;
+    bool sawDescendantRule : 1;
     };
 
     // a style class which has a list of children (StyleSheets for example)
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index c36a6f8..1edabdf 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -297,7 +297,7 @@ static inline void bubbleSort( CSSOrderedProperty **b, CSSOrderedProperty **e )
     }
 }
 
-RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
+RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e)
 {
     if (!e->getDocument()->haveStylesheetsLoaded()) {
         if (!styleNotYetAvailable) {
@@ -309,8 +309,6 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
     }
   
     // set some variables we will need
-    dynamicState = state;
-    usedDynamicStates = StyleSelector::None;
     ::encodedurl = &encodedurl;
     pseudoState = PseudoUnknown;
 
@@ -322,6 +320,12 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
     settings = part->settings();
     paintDeviceMetrics = element->getDocument()->paintDeviceMetrics();
 
+    style = new RenderStyle();
+    if( parentStyle )
+        style->inheritFrom( parentStyle );
+    else
+        parentStyle = style;
+    
     unsigned int numPropsToApply = 0;
     unsigned int numPseudoProps = 0;
 
@@ -379,12 +383,6 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
     bubbleSort( propsToApply, propsToApply+numPropsToApply-1 );
     bubbleSort( pseudoProps, pseudoProps+numPseudoProps-1 );
 
-    RenderStyle *style = new RenderStyle();
-    if( parentStyle )
-        style->inheritFrom( parentStyle );
-    else
-	parentStyle = style;
-
     // This member will be set to true if a rule specifies a font size
     // explicitly.  If they do this, then we don't need to check for a shift
     // in default size caused by a change in generic family. -dwh
@@ -455,11 +453,6 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e, int state)
         }
     }
 
-    if ( usedDynamicStates & StyleSelector::Hover )
-	style->setHasHover();
-    if ( usedDynamicStates & StyleSelector::Active )
-	style->setHasActive();
-
     return style;
 }
 
@@ -522,7 +515,7 @@ static bool subject;
 void CSSStyleSelector::checkSelector(int selIndex, DOM::ElementImpl *e)
 {
     dynamicPseudo = RenderStyle::NOPSEUDO;
-    selectorDynamicState = StyleSelector::None;
+    
     NodeImpl *n = e;
 
     selectorCache[ selIndex ].state = Invalid;
@@ -530,11 +523,12 @@ void CSSStyleSelector::checkSelector(int selIndex, DOM::ElementImpl *e)
 
     // we have the subject part of the selector
     subject = true;
-
+    
     // hack. We can't allow :hover, as it would trigger a complete relayout with every mouse event.
     bool single = false;
+    bool affectedByHover = style->affectedByHoverRules();
     if ( sel->tag == -1 )
-	single = true;
+        single = true;
 
     // first selector has to match
     if(!checkOneSelector(sel, e)) return;
@@ -543,8 +537,8 @@ void CSSStyleSelector::checkSelector(int selIndex, DOM::ElementImpl *e)
     CSSSelector::Relation relation = sel->relation;
     while((sel = sel->tagHistory))
     {
-	single = false;
-        if(!n->isElementNode()) return;
+        single = false;
+	    if(!n->isElementNode()) return;
         switch(relation)
         {
         case CSSSelector::Descendant:
@@ -595,12 +589,13 @@ void CSSStyleSelector::checkSelector(int selIndex, DOM::ElementImpl *e)
         }
         relation = sel->relation;
     }
+    
     // disallow *:hover
-    if ( single && selectorDynamicState & StyleSelector::Hover )
-	return;
-    usedDynamicStates |= selectorDynamicState;
-    if ((selectorDynamicState & dynamicState) != selectorDynamicState)
-	return;
+    if (single && !affectedByHover && style->affectedByHoverRules()) {
+        style->setAffectedByHoverRules(false);
+        return;
+    }
+   
     if ( dynamicPseudo != RenderStyle::NOPSEUDO ) {
 	selectorCache[selIndex].state = AppliesPseudo;
 	selectors[ selIndex ]->pseudoId = dynamicPseudo;
@@ -811,19 +806,30 @@ bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl
                     return true;
                 break;
             case CSSSelector::PseudoHover:
-                selectorDynamicState |= StyleSelector::Hover;
-                // dynamic pseudos have to be sorted out in checkSelector, so we if it could in some state apply
-                // to the element.
-                return true;
+                if (element == e)
+                    style->setAffectedByHoverRules(true);
+                if (e->renderer()) {
+                    if (element != e)
+                        e->renderer()->style()->setAffectedByHoverRules(true);
+                    if (e->renderer()->mouseInside())
+                        return true;
+                }
+                break;
             case CSSSelector::PseudoFocus:
-                selectorDynamicState |= StyleSelector::Focus;
-                return true;
+                if (e && e->focused()) {
+                    return true;
+                }
+                break;
             case CSSSelector::PseudoActive:
                 if ( pseudoState == PseudoUnknown )
                     checkPseudoState( e );
                 if ( pseudoState != PseudoNone ) {
-                    selectorDynamicState |= StyleSelector::Active;
-                    return true;
+                    if (element == e)
+                        style->setAffectedByActiveRules(true);
+                    else if (e->renderer())
+                        e->renderer()->style()->setAffectedByActiveRules(true);
+                    if (e->active())
+                        return true;
                 }
                 break;
             case CSSSelector::PseudoBefore:
diff --git a/WebCore/khtml/css/cssstyleselector.h b/WebCore/khtml/css/cssstyleselector.h
index f1c9649..d0db74d 100644
--- a/WebCore/khtml/css/cssstyleselector.h
+++ b/WebCore/khtml/css/cssstyleselector.h
@@ -85,7 +85,7 @@ namespace khtml
 	   the virtual methods until then, so the class has no vptr.
 	*/
 // 	virtual ~StyleSelector() {};
-// 	virtual RenderStyle *styleForElement(DOM::ElementImpl *e, int = None) = 0;
+// 	virtual RenderStyle *styleForElement(DOM::ElementImpl *e) = 0;
 
 	enum State {
 	    None = 0x00,
@@ -124,7 +124,7 @@ namespace khtml
 	static void loadDefaultStyle(const KHTMLSettings *s = 0);
 	static void clear();
 
-	RenderStyle *styleForElement(DOM::ElementImpl *e, int state = None );
+	RenderStyle *styleForElement(DOM::ElementImpl *e);
 
         QValueList<int> fontSizes() const { return m_fontSizes; }
 	QValueList<int> fixedFontSizes() const { return m_fixedFontSizes; }
@@ -212,11 +212,8 @@ public:
 	unsigned int pseudoPropsSize;
 
 
-	int dynamicState;
 	RenderStyle::PseudoId dynamicPseudo;
-	int usedDynamicStates;
-	int selectorDynamicState;
-
+	
 	RenderStyle *style;
 	RenderStyle *parentStyle;
 	DOM::ElementImpl *element;
diff --git a/WebCore/khtml/dom/html_head.cpp b/WebCore/khtml/dom/html_head.cpp
index 07e3ca5..2afa520 100644
--- a/WebCore/khtml/dom/html_head.cpp
+++ b/WebCore/khtml/dom/html_head.cpp
@@ -115,6 +115,9 @@ bool HTMLLinkElement::disabled() const
 
 void HTMLLinkElement::setDisabled( bool _disabled )
 {
+    if (disabled() == _disabled)
+        return;
+        
     if(impl)
         ((ElementImpl *)impl)->setAttribute(ATTR_DISABLED, _disabled ? "" : 0);
 }
diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp
index a39d40f..da585df 100644
--- a/WebCore/khtml/rendering/bidi.cpp
+++ b/WebCore/khtml/rendering/bidi.cpp
@@ -1441,7 +1441,7 @@ BidiIterator RenderFlow::findNextLineBreak(BidiIterator &start, QPtrList<BidiIte
         last = o;
         o = Bidinext( start.par, o );
 
-        if (last->isReplaced() && last->style()->whiteSpace() != NOWRAP) {
+        if (!last->isSpecial() && last->isReplaced() && last->style()->whiteSpace() != NOWRAP) {
             // Go ahead and add in tmpW.
             w += tmpW;
             tmpW = 0;
diff --git a/WebCore/khtml/rendering/render_box.cpp b/WebCore/khtml/rendering/render_box.cpp
index 90cad8e..0f287fe 100644
--- a/WebCore/khtml/rendering/render_box.cpp
+++ b/WebCore/khtml/rendering/render_box.cpp
@@ -85,8 +85,16 @@ void RenderBox::setStyle(RenderStyle *_style)
             setRelPositioned(true);
     }
     
-    if (!isTableCell() && (isPositioned() || isRelPositioned()) && !m_layer)
-        m_layer = new (renderArena()) RenderLayer(this);
+    if (requiresLayer()) {
+        if (!m_layer) {
+            m_layer = new (renderArena()) RenderLayer(this);
+            m_layer->insertOnlyThisLayer();
+        }
+    }
+    else if (m_layer && !isHtml() && !isRoot()) {
+        m_layer->removeOnlyThisLayer();
+        m_layer = 0;
+    }
 }
 
 RenderBox::~RenderBox()
diff --git a/WebCore/khtml/rendering/render_box.h b/WebCore/khtml/rendering/render_box.h
index 4d427d0..81e5110 100644
--- a/WebCore/khtml/rendering/render_box.h
+++ b/WebCore/khtml/rendering/render_box.h
@@ -154,7 +154,6 @@ protected:
     // A pointer to our layer if we have one.  Currently only positioned elements
     // and floaters have layers.
     RenderLayer* m_layer;
-    bool m_hasChildLayers : 1;
 };
 
 
diff --git a/WebCore/khtml/rendering/render_container.cpp b/WebCore/khtml/rendering/render_container.cpp
index ceffc89..c5d952c 100644
--- a/WebCore/khtml/rendering/render_container.cpp
+++ b/WebCore/khtml/rendering/render_container.cpp
@@ -260,7 +260,8 @@ void RenderContainer::appendChildNode(RenderObject* newChild)
     setLastChild(newChild);
     
     // Keep our layer hierarchy updated.
-    newChild->appendLayers(enclosingLayer());
+    RenderLayer* layer = enclosingLayer();
+    newChild->addLayers(layer, findNextLayer(layer, newChild));
          
     newChild->setMinMaxKnown( false );
     newChild->setLayouted( false );
@@ -290,9 +291,8 @@ void RenderContainer::insertChildNode(RenderObject* child, RenderObject* beforeC
     child->setParent(this);
     
     // Keep our layer hierarchy updated.
-    // XXX Need this to do an insertion and really find the right place to
-    // put the new layer. Not a big deal though. -dwh
-    child->appendLayers(enclosingLayer());
+    RenderLayer* layer = enclosingLayer();
+    child->addLayers(layer, findNextLayer(layer, child));
            
     child->setMinMaxKnown( false );
     child->setLayouted( false );
diff --git a/WebCore/khtml/rendering/render_flow.cpp b/WebCore/khtml/rendering/render_flow.cpp
index 981df84..590e740 100644
--- a/WebCore/khtml/rendering/render_flow.cpp
+++ b/WebCore/khtml/rendering/render_flow.cpp
@@ -73,9 +73,6 @@ void RenderFlow::setStyle(RenderStyle *_style)
     if(isPositioned())
         setInline(false);
     
-    if (!isTableCell() && (isPositioned() || isRelPositioned() || style()->overflow()==OHIDDEN) && !m_layer)
-        m_layer = new (renderArena()) RenderLayer(this);
-    
     if(isFloating() || style()->display() != INLINE)
         setInline(false);
 
@@ -484,12 +481,6 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
         if ( relayoutChildren || floatBottom() > m_y ||
              (child->isReplaced() && (child->style()->width().isPercent() || child->style()->height().isPercent())))
             child->setLayouted(false);
-        if ( child->style()->flowAroundFloats() && !child->isFloating() &&
-                style()->width().isFixed() && child->minWidth() > lineWidth( m_height ) ) {
-            m_height = QMAX( m_height, floatBottom() );
-            shouldCollapseChild = false;
-            clearOccurred = true;
-        }
 	
 //         kdDebug( 6040 ) << "   " << child->renderName() << " loop " << child << ", " << child->isInline() << ", " << child->layouted() << endl;
 //         kdDebug( 6040 ) << t.elapsed() << endl;
@@ -525,6 +516,16 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
             continue;
         }
 
+        // Note this occurs after the test for positioning and floating above, since
+        // we want to ensure that we don't artificially increase our height because of
+        // a positioned or floating child.
+        if ( child->style()->flowAroundFloats() && !child->isFloating() &&
+                style()->width().isFixed() && child->minWidth() > lineWidth( m_height ) ) {
+            m_height = QMAX( m_height, floatBottom() );
+            shouldCollapseChild = false;
+            clearOccurred = true;
+        }
+        
         child->calcVerticalMargins();
          
         //kdDebug(0) << "margin = " << margin << " yPos = " << m_height << endl;
diff --git a/WebCore/khtml/rendering/render_flow.h b/WebCore/khtml/rendering/render_flow.h
index d5b1e15..d73b856 100644
--- a/WebCore/khtml/rendering/render_flow.h
+++ b/WebCore/khtml/rendering/render_flow.h
@@ -96,7 +96,10 @@ public:
                              int tx, int ty, int paintPhase);
     void paintFloats(QPainter *p, int _x, int _y,
                      int _w, int _h, int _tx, int _ty);
-                                       
+            
+    virtual bool requiresLayer() { return !isTableCell() && 
+                    (isPositioned() || isRelPositioned() || style()->overflow()==OHIDDEN); }
+                    
     virtual void layout( );
 
     virtual void close();
diff --git a/WebCore/khtml/rendering/render_layer.cpp b/WebCore/khtml/rendering/render_layer.cpp
index 799e522..fcca3cc 100644
--- a/WebCore/khtml/rendering/render_layer.cpp
+++ b/WebCore/khtml/rendering/render_layer.cpp
@@ -144,18 +144,23 @@ void RenderLayer::detach(RenderArena* renderArena)
     renderArena->free(*(size_t *)this, this);
 }
 
-void RenderLayer::addChild(RenderLayer *child)
+void RenderLayer::addChild(RenderLayer *child, RenderLayer* beforeChild)
 {
-    if (!firstChild()) {
-        setFirstChild(child);
-        setLastChild(child);
-    } else {
-        RenderLayer* last = lastChild();
-        setLastChild(child);
-        child->setPreviousSibling(last);
-        last->setNextSibling(child);
+    RenderLayer* prevSibling = beforeChild ? beforeChild->previousSibling() : lastChild();
+    if (prevSibling) {
+        child->setPreviousSibling(prevSibling);
+        prevSibling->setNextSibling(child);
     }
+    else
+        setFirstChild(child);
 
+    if (beforeChild) {
+        beforeChild->setPreviousSibling(child);
+        child->setNextSibling(beforeChild);
+    }
+    else
+        setLastChild(child);
+   
     child->setParent(this);
 }
 
@@ -179,6 +184,44 @@ RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild)
     return oldChild;
 }
 
+void RenderLayer::removeOnlyThisLayer()
+{
+    if (!m_parent)
+        return;
+    
+    // Remove us from the parent.
+    RenderLayer* parent = m_parent;
+    RenderLayer* nextSib = nextSibling();
+    parent->removeChild(this);
+    
+    // Now walk our kids and reattach them to our parent.
+    RenderLayer* current = m_first;
+    while (current) {
+        RenderLayer* next = current->nextSibling();
+        removeChild(current);
+        parent->addChild(current, nextSib);
+        current = next;
+    }
+    
+    detach(renderer()->renderArena());
+}
+
+void RenderLayer::insertOnlyThisLayer()
+{
+    if (!m_parent && renderer()->parent()) {
+        // We need to connect ourselves when our renderer() has a parent.
+        // Find our enclosingLayer and add ourselves.
+        RenderLayer* parentLayer = renderer()->parent()->enclosingLayer();
+        if (parentLayer)
+            parentLayer->addChild(this, 
+                                  renderer()->parent()->findNextLayer(parentLayer, renderer()));
+    }
+    
+    // Remove all descendant layers from the hierarchy and add them to the new position.
+    for (RenderObject* curr = renderer()->firstChild(); curr; curr = curr->nextSibling())
+        curr->moveLayers(m_parent, this);
+}
+
 void 
 RenderLayer::convertToLayerCoords(RenderLayer* ancestorLayer, int& x, int& y)
 {
@@ -314,10 +357,44 @@ RenderLayer::paint(QPainter *p, int x, int y, int w, int h)
     node->detach(renderer()->renderArena());
 }
 
+void
+RenderLayer::clearOtherLayersHoverActiveState()
+{
+    if (!m_parent)
+        return;
+        
+    for (RenderLayer* curr = m_parent->firstChild(); curr; curr = curr->nextSibling()) {
+        if (curr == this)
+            continue;
+        curr->clearHoverAndActiveState(curr->renderer());
+    }
+    
+    m_parent->clearOtherLayersHoverActiveState();
+}
+
+void
+RenderLayer::clearHoverAndActiveState(RenderObject* obj)
+{
+    if (!obj->mouseInside())
+        return;
+    
+    obj->setMouseInside(false);
+    if (obj->element()) {
+        obj->element()->setActive(false);
+        if (obj->style()->affectedByHoverRules() || obj->style()->affectedByActiveRules())
+            obj->element()->setChanged(true);
+    }
+    
+    for (RenderObject* child = obj->firstChild(); child; child = child->nextSibling())
+        if (child->mouseInside())
+            clearHoverAndActiveState(child);
+}
+
 bool
 RenderLayer::nodeAtPoint(RenderObject::NodeInfo& info, int x, int y)
 {
     bool inside = false;
+    RenderLayer* insideLayer = 0;
     QRect damageRect(m_x, m_y, m_width, m_height);
     RenderZTreeNode* node = constructZTree(damageRect, damageRect, this, true, x, y);
     if (!node)
@@ -341,11 +418,23 @@ RenderLayer::nodeAtPoint(RenderObject::NodeInfo& info, int x, int y)
         inside = elt->layer->renderer()->nodeAtPoint(info, x, y,
                                       elt->absBounds.x() - elt->layer->renderer()->xPos(),
                                       elt->absBounds.y() - elt->layer->renderer()->yPos());
-        if (inside)
+        if (inside) {
+            insideLayer = elt->layer;
             break;
+        }
     }
     node->detach(renderer()->renderArena());
 
+    if (insideLayer) {
+        // Clear out the other layers' hover/active state
+        insideLayer->clearOtherLayersHoverActiveState();
+    
+        // Now clear out our descendant layers
+        for (RenderLayer* child = insideLayer->firstChild();
+             child; child = child->nextSibling())
+            child->clearHoverAndActiveState(child->renderer());
+    }
+    
     return inside;
 }
 
@@ -458,7 +547,7 @@ RenderLayer::constructZTree(QRect overflowClipRect, QRect posClipRect,
         }
         else
             returnNode->layerElement = layerElt;
-    }
+    } 
     
     // Now look for children that have a negative z-index.
     for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) {
diff --git a/WebCore/khtml/rendering/render_layer.h b/WebCore/khtml/rendering/render_layer.h
index fff06ae..9ebb034 100644
--- a/WebCore/khtml/rendering/render_layer.h
+++ b/WebCore/khtml/rendering/render_layer.h
@@ -75,9 +75,12 @@ public:
     RenderLayer *firstChild() const { return m_first; }
     RenderLayer *lastChild() const { return m_last; }
 
-    void addChild(RenderLayer *newChild);
+    void addChild(RenderLayer *newChild, RenderLayer* beforeChild = 0);
     RenderLayer* removeChild(RenderLayer *oldChild);
 
+    void removeOnlyThisLayer();
+    void insertOnlyThisLayer();
+    
     RenderLayer* root() {
         RenderLayer* curr = this;
         while (curr->parent()) curr = curr->parent();
@@ -118,6 +121,9 @@ public:
     void paint(QPainter *p, int x, int y, int w, int h);
     bool nodeAtPoint(RenderObject::NodeInfo& info, int x, int y);
     
+    void clearOtherLayersHoverActiveState();
+    void clearHoverAndActiveState(RenderObject* obj);
+    
     void detach(RenderArena* renderArena);
     
      // Overloaded new operator.  Derived classes must override operator new
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index ca7d4c1..c3ffc92 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -181,18 +181,18 @@ void RenderObject::insertChildNode(RenderObject*, RenderObject*)
     KHTMLAssert(0);
 }
 
-void RenderObject::appendLayers(RenderLayer* parentLayer)
+void RenderObject::addLayers(RenderLayer* parentLayer, RenderLayer* beforeChild)
 {
     if (!parentLayer)
         return;
     
     if (layer()) {
-        parentLayer->addChild(layer());
+        parentLayer->addChild(layer(), beforeChild);
         return;
     }
 
     for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
-        curr->appendLayers(parentLayer);
+        curr->addLayers(parentLayer, beforeChild);
 }
 
 void RenderObject::removeLayers(RenderLayer* parentLayer)
@@ -209,6 +209,61 @@ void RenderObject::removeLayers(RenderLayer* parentLayer)
         curr->removeLayers(parentLayer);
 }
 
+void RenderObject::moveLayers(RenderLayer* oldParent, RenderLayer* newParent)
+{
+    if (!newParent)
+        return;
+    
+    if (layer()) {
+        if (oldParent)
+            oldParent->removeChild(layer());
+        newParent->addChild(layer());
+        return;
+    }
+
+    for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
+        curr->moveLayers(oldParent, newParent);
+}
+
+RenderLayer* RenderObject::findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint,
+                                         bool checkParent)
+{
+    // Error check the parent layer passed in.  If it's null, we can't find anything.
+    if (!parentLayer)
+        return 0;
+        
+    // Step 1: Descend into our siblings trying to find the next layer.  If we do find
+    // a layer, and if its parent layer matches our desired parent layer, then we have
+    // a match.
+    for (RenderObject* curr = startPoint ? startPoint->nextSibling() : firstChild();
+         curr; curr = curr->nextSibling()) {
+        RenderLayer* nextLayer = curr->findNextLayer(parentLayer, 0, false);
+        if (nextLayer) {
+            if (nextLayer->parent() == parentLayer)
+                return nextLayer;
+            return 0;
+        }
+    }
+    
+    // Step 2: If our layer is the desired parent layer, then we're finished.  We didn't
+    // find anything.
+    RenderLayer* ourLayer = layer();
+    if (parentLayer == ourLayer)
+        return 0;
+    
+    // Step 3: If we have a layer, then return that layer.  It will be checked against
+    // the desired parent layer in the for loop above.
+    if (ourLayer)
+        return ourLayer;
+    
+    // Step 4: If |checkParent| is set, climb up to our parent and check its siblings that
+    // follow us to see if we can locate a layer.
+    if (checkParent && parent())
+        return parent()->findNextLayer(parentLayer, this, true);
+    
+    return 0;
+}
+    
 RenderLayer* RenderObject::enclosingLayer()
 {
     RenderObject* curr = this;
@@ -765,6 +820,15 @@ void RenderObject::setStyle(RenderStyle *style)
         return;
 
     RenderStyle::Diff d = m_style ? m_style->diff( style ) : RenderStyle::Layout;
+    if (isFloating() || isPositioned()) {
+        // For changes in float or position, we need to conceivably remove ourselves
+        // from the special objects list.
+        bool floatOrPos = style->isFloating() || style->position() == ABSOLUTE ||
+                          style->position() == FIXED;
+        if (!floatOrPos)
+            removeFromSpecialObjects();
+    }
+    
     //qDebug("new style, diff=%d", d);
     // reset style flags
     m_floating = false;
@@ -1077,8 +1141,8 @@ void RenderObject::setHoverAndActive(NodeInfo& info, bool oldinside, bool inside
             bool oldactive = elt->active();
             if (oldactive != (inside && info.active() && elt == info.innerNode()))
                 elt->setActive(inside && info.active() && elt == info.innerNode());
-            if ( ((oldinside != mouseInside()) && style()->hasHover()) ||
-                ((oldactive != elt->active()) && style()->hasActive()))
+            if ((oldinside != mouseInside() && style()->affectedByHoverRules()) ||
+                (oldactive != elt->active() && style()->affectedByActiveRules()))
                 elt->setChanged();
         }
     }
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index b13eab5..e9d3fad 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -105,10 +105,13 @@ public:
 
     virtual RenderLayer* layer() const { return 0; }
     RenderLayer* enclosingLayer();
-    void appendLayers(RenderLayer* parentLayer);
+    void addLayers(RenderLayer* parentLayer, RenderLayer* beforeChild=0);
     void removeLayers(RenderLayer* parentLayer);
-    virtual void setHasChildLayers(bool hasLayers) { }
+    void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);
+    RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint,
+                               bool checkParent=true);
     virtual void positionChildLayers() { }
+    virtual bool requiresLayer() { return !isTableCell() && (isPositioned() || isRelPositioned()); }
     
     virtual QRect getOverflowClipRect(int tx, int ty) { return QRect(0,0,0,0); }
     virtual QRect getClipRect(int tx, int ty) { return QRect(0,0,0,0); }
diff --git a/WebCore/khtml/rendering/render_style.cpp b/WebCore/khtml/rendering/render_style.cpp
index 6106915..3ced727 100644
--- a/WebCore/khtml/rendering/render_style.cpp
+++ b/WebCore/khtml/rendering/render_style.cpp
@@ -320,8 +320,6 @@ bool RenderStyle::inheritedNotEqual( RenderStyle *other ) const
 */
 RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
 {
-    Diff d = Equal;
-
     // we anyway assume they are the same
 // 	EDisplay _display : 5;
 
@@ -341,22 +339,19 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
 
     if ( *box.get() != *other->box.get() ||
         *visual.get() != *other->visual.get() ||
-        *surround.get() != *other->surround.get())
-     	d = CbLayout;
-
-    if ( d == CbLayout )
-        return d;
-
-    if (!(inherited->indent == other->inherited->indent) ||
+        *surround.get() != *other->surround.get() ||
+        !(inherited->indent == other->inherited->indent) ||
         !(inherited->line_height == other->inherited->line_height) ||
         !(inherited->style_image == other->inherited->style_image) ||
         !(inherited->cursor_image == other->inherited->cursor_image) ||
         !(inherited->font == other->inherited->font) ||
-        !(inherited->border_spacing == other->inherited->border_spacing))
-        d = CbLayout;
-    if (d == CbLayout)
-        return d;
-        
+        !(inherited->border_spacing == other->inherited->border_spacing) ||
+        !(inherited_flags._visuallyOrdered == other->inherited_flags._visuallyOrdered) ||
+        !(inherited_flags._htmlHacks == other->inherited_flags._htmlHacks) ||
+        !(noninherited_flags._position == other->noninherited_flags._position) ||
+        !(noninherited_flags._floating == other->noninherited_flags._floating) )
+        return CbLayout;
+   
     // changes causing Layout changes:
 
 // only for tables:
@@ -373,11 +368,8 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
 	if ( !(inherited_flags._border_collapse == other->inherited_flags._border_collapse) ||
 	     !(inherited_flags._empty_cells == other->inherited_flags._empty_cells) ||
 	     !(inherited_flags._caption_side == other->inherited_flags._caption_side) ||
-	     !(noninherited_flags._table_layout == other->noninherited_flags._table_layout) ||
-	     !(noninherited_flags._position == other->noninherited_flags._position) ||
-	     !(noninherited_flags._floating == other->noninherited_flags._floating) )
-
-	    d = CbLayout;
+	     !(noninherited_flags._table_layout == other->noninherited_flags._table_layout))
+        return CbLayout;
     }
 
 // only for lists:
@@ -386,12 +378,9 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
     if (noninherited_flags._display == LIST_ITEM ) {
 	if ( !(inherited_flags._list_style_type == other->inherited_flags._list_style_type) ||
 	     !(inherited_flags._list_style_position == other->inherited_flags._list_style_position) )
-	    d = Layout;
+	    return Layout;
     }
 
-    if ( d == Layout )
-	return d;
-
 // ### These could be better optimised
 // 	ETextAlign _text_align : 3;
 // 	ETextTransform _text_transform : 4;
@@ -406,22 +395,14 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
 	 !(inherited_flags._font_variant == other->inherited_flags._font_variant) ||
 	 !(noninherited_flags._clear == other->noninherited_flags._clear)
 	)
-	d = Layout;
+	return Layout;
 
 // only for inline:
 //     EVerticalAlign _vertical_align : 4;
 
-    if ( !(noninherited_flags._display == INLINE) ) {
-	if ( !(noninherited_flags._vertical_align == other->noninherited_flags._vertical_align))
-	    d = Layout;
-    }
-
-    if ( d == Layout )
-	return d;
-
-    if (inherited->color != other->inherited->color ||
-        inherited->decoration_color != other->inherited->decoration_color)
-        d = Visible;
+    if ( !(noninherited_flags._display == INLINE) &&
+         !(noninherited_flags._vertical_align == other->noninherited_flags._vertical_align))
+        return Layout;
 
     // Visible:
 // 	EVisibility _visibility : 2;
@@ -430,18 +411,18 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
 //     bool _bg_attachment : 1;
 // 	int _text_decoration : 4;
 //     DataRef<StyleBackgroundData> background;
-    if ( !(inherited_flags._visibility == other->inherited_flags._visibility) ||
-	 !(noninherited_flags._overflow == other->noninherited_flags._overflow) ||
-	 !(noninherited_flags._bg_repeat == other->noninherited_flags._bg_repeat) ||
-	 !(noninherited_flags._bg_attachment == other->noninherited_flags._bg_attachment) ||
-	 !(inherited_flags._text_decoration == other->inherited_flags._text_decoration) ||
-	 *background.get() != *other->background.get()
+    if (inherited->color != other->inherited->color ||
+        inherited->decoration_color != other->inherited->decoration_color ||
+        !(inherited_flags._visibility == other->inherited_flags._visibility) ||
+        !(noninherited_flags._overflow == other->noninherited_flags._overflow) ||
+        !(noninherited_flags._bg_repeat == other->noninherited_flags._bg_repeat) ||
+        !(noninherited_flags._bg_attachment == other->noninherited_flags._bg_attachment) ||
+        !(inherited_flags._text_decoration == other->inherited_flags._text_decoration) ||
+        *background.get() != *other->background.get()
 	)
-	d = Visible;
-
-    // Position:
+        return Visible;
 
-    return d;
+    return Equal;
 }
 
 
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index 10e59a3..14473f6 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -553,8 +553,8 @@ protected:
         bool _flowAroundFloats :1;
 
         PseudoId _styleType : 3;
-        bool _hasHover : 1;
-        bool _hasActive : 1;
+        bool _affectedByHover : 1;
+        bool _affectedByActive : 1;
         EUnicodeBidi _unicodeBidi : 2;
     } noninherited_flags;
 
@@ -609,8 +609,8 @@ protected:
 	noninherited_flags._table_layout = TAUTO;
 	noninherited_flags._flowAroundFloats=false;
 	noninherited_flags._styleType = NOPSEUDO;
-	noninherited_flags._hasHover = false;
-	noninherited_flags._hasActive = false;
+    noninherited_flags._affectedByHover = false;
+    noninherited_flags._affectedByActive = false;
 	noninherited_flags._unicodeBidi = UBNormal;
     }
 
@@ -632,12 +632,12 @@ public:
     bool hasPseudoStyle() const { return pseudoStyle; }
     void removePseudoStyle(PseudoId pi);
 
-    bool hasHover() const { return  noninherited_flags._hasHover; }
-    bool hasActive() const { return  noninherited_flags._hasActive; }
-
-    void setHasHover() {  noninherited_flags._hasHover = true; }
-    void setHasActive() {  noninherited_flags._hasActive = true; }
+    bool affectedByHoverRules() const { return  noninherited_flags._affectedByHover; }
+    bool affectedByActiveRules() const { return  noninherited_flags._affectedByActive; }
 
+    void setAffectedByHoverRules(bool b) {  noninherited_flags._affectedByHover = b; }
+    void setAffectedByActiveRules(bool b) {  noninherited_flags._affectedByActive = b; }
+ 
     bool operator==(const RenderStyle& other) const;
     bool        isFloating() const { return !(noninherited_flags._floating == FNONE); }
     bool        hasMargin() const { return surround->margin.nonZero(); }
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 6123ff5..4a07f17 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -288,7 +288,8 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
     m_inDocument = true;
     m_styleSelectorDirty = false;
     m_inStyleRecalc = false;
-
+    m_usesDescendantRules = false;
+    
     m_styleSelector = new CSSStyleSelector( this, m_usersheet, m_styleSheets, m_url,
                                             pMode == Strict );
     m_windowEventListeners.setAutoDelete(true);
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 3006f05..121080f 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -199,6 +199,9 @@ public:
 
     void recalcStyleSelector();
 
+    bool usesDescendantRules() { return m_usesDescendantRules; }
+    void setUsesDescendantRules(bool b) { m_usesDescendantRules = b; }
+    
     QString nextState();
 
     // Query all registered elements for their state
@@ -499,6 +502,7 @@ protected:
     bool m_docChanged;
     bool m_styleSelectorDirty;
     bool m_inStyleRecalc;
+    bool m_usesDescendantRules;
     
     DOMString m_title;
     
diff --git a/WebCore/khtml/xml/dom_elementimpl.cpp b/WebCore/khtml/xml/dom_elementimpl.cpp
index 28d3f34..b121bcb 100644
--- a/WebCore/khtml/xml/dom_elementimpl.cpp
+++ b/WebCore/khtml/xml/dom_elementimpl.cpp
@@ -348,27 +348,19 @@ void ElementImpl::recalcStyle( StyleChange change )
     if ( change >= Inherit || changed() ) {
         EDisplay oldDisplay = _style ? _style->display() : NONE;
 
-        int dynamicState = StyleSelector::None;
-        if ( m_render && m_render->mouseInside() )
-            dynamicState |= StyleSelector::Hover;
-        if ( m_focused )
-            dynamicState |= StyleSelector::Focus;
-        if ( m_active )
-            dynamicState |= StyleSelector::Active;
-
-        RenderStyle *newStyle = getDocument()->styleSelector()->styleForElement(this, dynamicState);
+        RenderStyle *newStyle = getDocument()->styleSelector()->styleForElement(this);
         newStyle->ref();
         StyleChange ch = diff( _style, newStyle );
         if ( ch != NoChange ) {
             if (oldDisplay != newStyle->display()) {
                 if (attached()) detach();
-                // ### uuhm, suboptimal. style gets calculated again
+                // ### 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;
+                // attach recalulates the style for all children. No need to do it twice.
+                setChanged( false );
+                setHasChangedChild( false );
+                newStyle->deref();
+                return;
             }
             if( m_render && newStyle ) {
                 //qDebug("--> setting style on render element bgcolor=%s", newStyle->backgroundColor().name().latin1());
@@ -377,8 +369,12 @@ void ElementImpl::recalcStyle( StyleChange change )
         }
         newStyle->deref();
 
-        if ( change != Force )
-            change = ch;
+        if ( change != Force) {
+            if (getDocument()->usesDescendantRules())
+                change = Force;
+            else
+                change = ch;
+        }
     }
 
     NodeImpl *n;
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index 8ead729..bd9cbfa 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -1625,7 +1625,7 @@ void NodeBaseImpl::setActive(bool down)
     NodeImpl::setActive(down);
 
     // note that we need to recalc the style
-    if (m_render && m_render->style()->hasActive())
+    if (m_render && m_render->style()->affectedByActiveRules())
         setChanged();
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list