Index: khtml/rendering/render_box.cpp =================================================================== RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_box.cpp,v retrieving revision 1.150 diff -u -p -r1.150 khtml/rendering/render_box.cpp --- khtml/rendering/render_box.cpp 2005/04/14 18:33:54 1.150 +++ khtml/rendering/render_box.cpp 2005/04/15 09:49:09 @@ -98,9 +98,9 @@ void RenderBox::setStyle(RenderStyle *_s // FIXME: Note that we restrict overflow to blocks for now. One day table bodies and cells // will need to support overflow. - // We also deal with the body scroll quirk here, since it sets the scrollbars for the document. - if (_style->overflow() != OVISIBLE && isBlockFlow() && !isTableCell() && - (!document()->isHTMLDocument() || !isBody())) + // We also handle and , whose overflow applies to the viewport. + if (_style->overflow() != OVISIBLE && isBlockFlow() && !isTableCell() && !isRoot() && + (!isBody() || !document()->isHTMLDocument() || !(parent() && parent()->style()->overflow() == OVISIBLE))) setHasOverflowClip(); if (requiresLayer()) { Index: khtml/khtmlview.h =================================================================== RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/khtmlview.h,v retrieving revision 1.45 diff -u -p -r1.45 khtml/khtmlview.h --- khtml/khtmlview.h 2004/12/14 00:10:07 1.45 +++ khtml/khtmlview.h 2005/04/15 09:49:10 @@ -288,7 +288,7 @@ private: int mouseEventType); bool dispatchDragEvent(int eventId, DOM::NodeImpl *dragTarget, const QPoint &loc, DOM::ClipboardImpl *clipboard); - void applyBodyScrollQuirk(khtml::RenderObject* o, ScrollBarMode& hMode, ScrollBarMode& vMode); + void applyOverflowToViewport(khtml::RenderObject* o, ScrollBarMode& hMode, ScrollBarMode& vMode); #if APPLE_CHANGES virtual bool isKHTMLView() const; Index: khtml/khtmlview.cpp =================================================================== RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/khtmlview.cpp,v retrieving revision 1.128 diff -u -p -r1.128 khtml/khtmlview.cpp --- khtml/khtmlview.cpp 2005/02/23 17:42:36 1.128 +++ khtml/khtmlview.cpp 2005/04/15 09:49:11 @@ -518,13 +518,12 @@ void KHTMLView::adjustViewSize() } } -void KHTMLView::applyBodyScrollQuirk(khtml::RenderObject* o, ScrollBarMode& hMode, ScrollBarMode& vMode) +void KHTMLView::applyOverflowToViewport(khtml::RenderObject* o, ScrollBarMode& hMode, ScrollBarMode& vMode) { - // Handle the overflow:hidden/scroll quirk for the body elements. WinIE treats + // Handle the overflow:hidden/scroll case for the body/html elements. WinIE treats // overflow:hidden and overflow:scroll on as applying to the document's - // scrollbars. The CSS2.1 draft has even added a sentence, "HTML UAs may apply overflow - // specified on the body or HTML elements to the viewport." Since WinIE and Mozilla both - // do it, we will do it too for elements. + // scrollbars. The CSS2.1 draft states that HTML UAs should use the or element and XML/XHTML UAs should + // use the root element. switch(o->style()->overflow()) { case OHIDDEN: hMode = vMode = AlwaysOff; @@ -604,6 +603,7 @@ void KHTMLView::layout() ScrollBarMode hMode = d->hmode; ScrollBarMode vMode = d->vmode; + RenderObject* rootRenderer = document->documentElement()->renderer(); if (document->isHTMLDocument()) { NodeImpl *body = static_cast(document)->body(); if (body && body->renderer()) { @@ -612,10 +612,14 @@ void KHTMLView::layout() vMode = AlwaysOff; hMode = AlwaysOff; } - else if (body->id() == ID_BODY) - applyBodyScrollQuirk(body->renderer(), hMode, vMode); // Only applies to HTML UAs, not to XML/XHTML UAs + else if (body->id() == ID_BODY) { + RenderObject* o = (rootRenderer->style()->overflow() == OVISIBLE) ? body->renderer() : rootRenderer; + applyOverflowToViewport(o, hMode, vMode); // Only applies to HTML UAs, not to XML/XHTML UAs + } } } + else + applyOverflowToViewport(rootRenderer, hMode, vMode); // XML/XHTML UAs use the root element. #ifdef INSTRUMENT_LAYOUT_SCHEDULING if (d->firstLayout && !document->ownerElement())