Fix for 7362, implement the CSS3 overflow-x and overflow-y properties.
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jun 2006 22:45:00 +0000 (22:45 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jun 2006 22:45:00 +0000 (22:45 +0000)
        Reviewed by adele

        * WebCore.xcodeproj/project.pbxproj:
        * css/CSSComputedStyleDeclaration.cpp:
        (WebCore::):
        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
        * css/CSSPropertyNames.in:
        * css/cssparser.cpp:
        (WebCore::CSSParser::parseValue):
        * css/cssstyleselector.cpp:
        (WebCore::CSSStyleSelector::adjustRenderStyle):
        (WebCore::CSSStyleSelector::applyProperty):
        * page/FrameView.cpp:
        (WebCore::FrameView::applyOverflowToViewport):
        (WebCore::FrameView::layout):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::layoutBlock):
        (WebCore::RenderBlock::determineHorizontalPosition):
        (WebCore::RenderBlock::layoutBlockChildren):
        (WebCore::RenderBlock::rightOffset):
        (WebCore::RenderBlock::rightmostPosition):
        (WebCore::RenderBlock::calcMinMaxWidth):
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::setStyle):
        (WebCore::RenderBox::contentWidth):
        (WebCore::RenderBox::contentHeight):
        (WebCore::RenderBox::sizesToIntrinsicWidth):
        (WebCore::RenderBox::calcHeight):
        (WebCore::RenderBox::calcPercentageHeight):
        * rendering/RenderFlexibleBox.cpp:
        (WebCore::RenderFlexibleBox::layoutBlock):
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::scrollToOffset):
        (WebCore::RenderLayer::shouldAutoscroll):
        (WebCore::RenderLayer::updateScrollInfoAfterLayout):
        (WebCore::RenderLayer::styleChanged):
        * rendering/RenderLayer.h:
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::clientWidth):
        (WebCore::RenderObject::clientHeight):
        * rendering/RenderObject.h:
        (WebCore::RenderObject::hasAutoVerticalScrollbar):
        (WebCore::RenderObject::hasAutoHorizontalScrollbar):
        (WebCore::RenderObject::scrollsOverflow):
        (WebCore::RenderObject::scrollsOverflowX):
        (WebCore::RenderObject::scrollsOverflowY):
        (WebCore::RenderObject::includeVerticalScrollbarSize):
        (WebCore::RenderObject::includeHorizontalScrollbarSize):
        * rendering/RenderTextArea.cpp:
        (WebCore::RenderTextArea::setStyle):
        * rendering/RenderTextField.cpp:
        (WebCore::RenderTextField::createDivStyle):
        (WebCore::RenderTextField::calcHeight):
        (WebCore::RenderTextField::calcMinMaxWidth):
        * rendering/bidi.cpp:
        (WebCore::RenderBlock::layoutInlineChildren):
        * rendering/render_style.cpp:
        (WebCore::RenderStyle::diff):
        * rendering/render_style.h:
        (WebCore::):
        (WebCore::RenderStyle::NonInheritedFlags::operator==):
        (WebCore::RenderStyle::setBitDefaults):
        (WebCore::RenderStyle::overflowX):
        (WebCore::RenderStyle::overflowY):
        (WebCore::RenderStyle::setOverflowX):
        (WebCore::RenderStyle::setOverflowY):
        (WebCore::RenderStyle::initialOverflowX):
        (WebCore::RenderStyle::initialOverflowY):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14953 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
WebCore/ChangeLog
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/CSSPropertyNames.in
WebCore/css/cssparser.cpp
WebCore/css/cssstyleselector.cpp
WebCore/page/FrameView.cpp
WebCore/rendering/RenderBlock.cpp
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderFlexibleBox.cpp
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderLayer.h
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObject.h
WebCore/rendering/RenderTextArea.cpp
WebCore/rendering/RenderTextField.cpp
WebCore/rendering/bidi.cpp
WebCore/rendering/render_style.cpp
WebCore/rendering/render_style.h

index bbc6c82b9af41fe46457a58d8e678d8c2ca1c156..d31f6d6ad1b9fe2a25333085d04d9bf6deb6f520 100644 (file)
@@ -1,3 +1,76 @@
+2006-06-21  David Hyatt  <hyatt@apple.com>
+
+        Fix for 7362, implement the CSS3 overflow-x and overflow-y properties.
+
+        Reviewed by adele
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSPropertyNames.in:
+        * css/cssparser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/cssstyleselector.cpp:
+        (WebCore::CSSStyleSelector::adjustRenderStyle):
+        (WebCore::CSSStyleSelector::applyProperty):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::applyOverflowToViewport):
+        (WebCore::FrameView::layout):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::layoutBlock):
+        (WebCore::RenderBlock::determineHorizontalPosition):
+        (WebCore::RenderBlock::layoutBlockChildren):
+        (WebCore::RenderBlock::rightOffset):
+        (WebCore::RenderBlock::rightmostPosition):
+        (WebCore::RenderBlock::calcMinMaxWidth):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::setStyle):
+        (WebCore::RenderBox::contentWidth):
+        (WebCore::RenderBox::contentHeight):
+        (WebCore::RenderBox::sizesToIntrinsicWidth):
+        (WebCore::RenderBox::calcHeight):
+        (WebCore::RenderBox::calcPercentageHeight):
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutBlock):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollToOffset):
+        (WebCore::RenderLayer::shouldAutoscroll):
+        (WebCore::RenderLayer::updateScrollInfoAfterLayout):
+        (WebCore::RenderLayer::styleChanged):
+        * rendering/RenderLayer.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::clientWidth):
+        (WebCore::RenderObject::clientHeight):
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::hasAutoVerticalScrollbar):
+        (WebCore::RenderObject::hasAutoHorizontalScrollbar):
+        (WebCore::RenderObject::scrollsOverflow):
+        (WebCore::RenderObject::scrollsOverflowX):
+        (WebCore::RenderObject::scrollsOverflowY):
+        (WebCore::RenderObject::includeVerticalScrollbarSize):
+        (WebCore::RenderObject::includeHorizontalScrollbarSize):
+        * rendering/RenderTextArea.cpp:
+        (WebCore::RenderTextArea::setStyle):
+        * rendering/RenderTextField.cpp:
+        (WebCore::RenderTextField::createDivStyle):
+        (WebCore::RenderTextField::calcHeight):
+        (WebCore::RenderTextField::calcMinMaxWidth):
+        * rendering/bidi.cpp:
+        (WebCore::RenderBlock::layoutInlineChildren):
+        * rendering/render_style.cpp:
+        (WebCore::RenderStyle::diff):
+        * rendering/render_style.h:
+        (WebCore::):
+        (WebCore::RenderStyle::NonInheritedFlags::operator==):
+        (WebCore::RenderStyle::setBitDefaults):
+        (WebCore::RenderStyle::overflowX):
+        (WebCore::RenderStyle::overflowY):
+        (WebCore::RenderStyle::setOverflowX):
+        (WebCore::RenderStyle::setOverflowY):
+        (WebCore::RenderStyle::initialOverflowX):
+        (WebCore::RenderStyle::initialOverflowY):
+
 2006-06-21  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi
index 9fc7f0732803159421bb0a43439a7c8f60a36c6b..fabfef93942e441151bb5c95efbf1b4fcf7f4e0f 100644 (file)
@@ -120,6 +120,8 @@ static const int computedProperties[] = {
     CSS_PROP_ORPHANS,
     CSS_PROP_OUTLINE_STYLE,
     CSS_PROP_OVERFLOW,
+    CSS_PROP_OVERFLOW_X,
+    CSS_PROP_OVERFLOW_Y,
     CSS_PROP_PADDING_TOP,
     CSS_PROP_PADDING_RIGHT,
     CSS_PROP_PADDING_BOTTOM,
@@ -889,7 +891,20 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
         // FIXME: unimplemented
         break;
     case CSS_PROP_OVERFLOW:
-        switch (style->overflow()) {
+    case CSS_PROP_OVERFLOW_X:
+    case CSS_PROP_OVERFLOW_Y:
+        EOverflow overflow;
+        switch (propertyID) {
+            case CSS_PROP_OVERFLOW_X:
+                overflow = style->overflowX();
+                break;
+            case CSS_PROP_OVERFLOW_Y:
+                overflow = style->overflowY();
+                break;
+            default:
+                overflow = max(style->overflowX(), style->overflowY());
+        }
+        switch (overflow) {
             case OVISIBLE:
                 return new CSSPrimitiveValue(CSS_VAL_VISIBLE);
             case OHIDDEN:
index 272ec6492656954083574c4773cf312568686116..bf75a13229c8d56de28cb511cd949692f6da2683 100644 (file)
@@ -107,6 +107,8 @@ outline-offset
 outline-style
 outline-width
 overflow
+overflow-x
+overflow-y
 padding-top
 padding-right
 padding-bottom
index 92c347b6a1900759ccf6810c50a67bc92d3712d7..0ae2c5035e3e248b203a4c7a3431048cc930f501 100644 (file)
@@ -542,8 +542,10 @@ bool CSSParser::parseValue(int propId, bool important)
         break;
 
     case CSS_PROP_OVERFLOW:             // visible | hidden | scroll | auto | marquee | overlay | inherit
+    case CSS_PROP_OVERFLOW_X:
+    case CSS_PROP_OVERFLOW_Y:
         if (id == CSS_VAL_VISIBLE || id == CSS_VAL_HIDDEN || id == CSS_VAL_SCROLL || id == CSS_VAL_AUTO ||
-            id == CSS_VAL__WEBKIT_MARQUEE || id == CSS_VAL__WEBKIT_OVERLAY)
+            id == CSS_VAL__WEBKIT_OVERLAY || id == CSS_VAL__WEBKIT_MARQUEE)
             valid_primitive = true;
         break;
 
index ceed725e09d1990f88e85daa2b65af0c3556c85b..3b3d1781ca558826d0b73bc8186e767f067ddb9d 100644 (file)
@@ -1038,12 +1038,25 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e)
     else
         style->addToTextDecorationsInEffect(style->textDecoration());
     
+    // If either overflow value is not visible, change to auto.
+    if (style->overflowX() == OMARQUEE && style->overflowY() != OMARQUEE)
+        style->setOverflowY(OMARQUEE);
+    else if (style->overflowY() == OMARQUEE && style->overflowX() != OMARQUEE)
+        style->setOverflowX(OMARQUEE);
+    else if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE)
+        style->setOverflowX(OAUTO);
+    else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE)
+        style->setOverflowY(OAUTO);
+
     // Table rows, sections and the table itself will support overflow:hidden and will ignore scroll/auto.
     // FIXME: Eventually table sections will support auto and scroll.
-    if (style->overflow() != OVISIBLE && style->overflow() != OHIDDEN && 
-        (style->display() == TABLE || style->display() == INLINE_TABLE ||
-         style->display() == TABLE_ROW_GROUP || style->display() == TABLE_ROW))
-        style->setOverflow(OVISIBLE);
+    if (style->display() == TABLE || style->display() == INLINE_TABLE ||
+        style->display() == TABLE_ROW_GROUP || style->display() == TABLE_ROW) {
+        if (style->overflowX() != OVISIBLE && style->overflowX() != OHIDDEN) 
+            style->setOverflowX(OVISIBLE);
+        if (style->overflowY() != OVISIBLE && style->overflowY() != OHIDDEN) 
+            style->setOverflowY(OVISIBLE);
+    }
 
     // Links should be user selectable when content editable
     if (e && e->isLink() && (style->userModify() == READ_WRITE || style->userModify() == READ_WRITE_PLAINTEXT_ONLY))
@@ -2044,8 +2057,66 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
 
     case CSS_PROP_OVERFLOW:
     {
-        HANDLE_INHERIT_AND_INITIAL(overflow, Overflow)
-        if (!primitiveValue) return;
+        if (isInherit) {
+            style->setOverflowX(parentStyle->overflowX());
+            style->setOverflowY(parentStyle->overflowY());
+            return;
+        }
+        
+        if (isInitial) {
+            style->setOverflowX(RenderStyle::initialOverflowX());
+            style->setOverflowY(RenderStyle::initialOverflowY());
+            return;
+        }
+            
+        EOverflow o;
+        switch(primitiveValue->getIdent()) {
+            case CSS_VAL_VISIBLE:
+                o = OVISIBLE; break;
+            case CSS_VAL_HIDDEN:
+                o = OHIDDEN; break;
+            case CSS_VAL_SCROLL:
+                o = OSCROLL; break;
+            case CSS_VAL_AUTO:
+                o = OAUTO; break;
+            case CSS_VAL__WEBKIT_MARQUEE:
+                o = OMARQUEE; break;
+            case CSS_VAL__WEBKIT_OVERLAY:
+                o = OOVERLAY; break;
+            default:
+                return;
+        }
+        style->setOverflowX(o);
+        style->setOverflowY(o);
+        return;
+    }
+
+    case CSS_PROP_OVERFLOW_X:
+    {
+        HANDLE_INHERIT_AND_INITIAL(overflowX, OverflowX)
+        EOverflow o;
+        switch(primitiveValue->getIdent())
+        {
+        case CSS_VAL_VISIBLE:
+            o = OVISIBLE; break;
+        case CSS_VAL_HIDDEN:
+            o = OHIDDEN; break;
+        case CSS_VAL_SCROLL:
+            o = OSCROLL; break;
+        case CSS_VAL_AUTO:
+            o = OAUTO; break;
+        case CSS_VAL__WEBKIT_OVERLAY:
+            o = OOVERLAY; break;
+        default:
+            return;
+        }
+        style->setOverflowX(o);
+        return;
+    }
+
+    case CSS_PROP_OVERFLOW_Y:
+    {
+        HANDLE_INHERIT_AND_INITIAL(overflowY, OverflowY)
         EOverflow o;
         switch(primitiveValue->getIdent())
         {
@@ -2057,14 +2128,12 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
             o = OSCROLL; break;
         case CSS_VAL_AUTO:
             o = OAUTO; break;
-        case CSS_VAL__WEBKIT_MARQUEE:
-            o = OMARQUEE; break;
         case CSS_VAL__WEBKIT_OVERLAY:
             o = OOVERLAY; break;
         default:
             return;
         }
-        style->setOverflow(o);
+        style->setOverflowY(o);
         return;
     }
 
index 71dfb91685b72e47006f012d0559bd9c6ddcb24e..eb4c77084893c5f32de0570099959948e93e3465 100644 (file)
@@ -263,15 +263,30 @@ void FrameView::applyOverflowToViewport(RenderObject* o, ScrollBarMode& hMode, S
     // overflow:hidden and overflow:scroll on <body> as applying to the document's
     // scrollbars.  The CSS2.1 draft states that HTML UAs should use the <html> or <body> element and XML/XHTML UAs should
     // use the root element.
-    switch(o->style()->overflow()) {
+    switch (o->style()->overflowX()) {
         case OHIDDEN:
-            hMode = vMode = ScrollBarAlwaysOff;
+            hMode = ScrollBarAlwaysOff;
             break;
         case OSCROLL:
-            hMode = vMode = ScrollBarAlwaysOn;
+            hMode = ScrollBarAlwaysOn;
             break;
         case OAUTO:
-            hMode = vMode = ScrollBarAuto;
+            hMode = ScrollBarAuto;
+            break;
+        default:
+            // Don't set it at all.
+            ;
+    }
+    
+     switch (o->style()->overflowY()) {
+        case OHIDDEN:
+            vMode = ScrollBarAlwaysOff;
+            break;
+        case OSCROLL:
+            vMode = ScrollBarAlwaysOn;
+            break;
+        case OAUTO:
+            vMode = ScrollBarAuto;
             break;
         default:
             // Don't set it at all.
@@ -362,7 +377,8 @@ void FrameView::layout(bool allowSubtree)
                     vMode = ScrollBarAlwaysOff;
                     hMode = ScrollBarAlwaysOff;
                 } else if (body->hasTagName(bodyTag)) {
-                    RenderObject* o = (rootRenderer->style()->overflow() == OVISIBLE) ? body->renderer() : rootRenderer;
+                    // It's sufficient to just check one overflow direction, since it's illegal to have visible in only one direction.
+                    RenderObject* o = rootRenderer->style()->overflowX() == OVISIBLE ? body->renderer() : rootRenderer;
                     applyOverflowToViewport(o, hMode, vMode); // Only applies to HTML UAs, not to XML/XHTML UAs
                 }
             }
index 3d25a5dcd23cf065867b26e2057980955513d677..0b58cd7cc9c6e443bdc2df015ebefcfec8d40414 100644 (file)
@@ -476,18 +476,14 @@ void RenderBlock::layoutBlock(bool relayoutChildren)
             m_maxBottomPosMargin = m_maxBottomNegMargin = 0;
     }
 
+    // For overflow:scroll blocks, ensure we have both scrollbars in place always.
     if (scrollsOverflow()) {
-        // For overflow:scroll blocks, ensure we have both scrollbars in place always.
-        if (style()->overflow() == OSCROLL) {
+        if (style()->overflowX() == OSCROLL)
             m_layer->setHasHorizontalScrollbar(true);
+        if (style()->overflowY() == OSCROLL)
             m_layer->setHasVerticalScrollbar(true);
-        }
-        
-        // Move the scrollbars aside during layout.  The layer will move them back when it
-        // does painting or event handling.
-        m_layer->moveScrollbarsAside();
     }
-   
+
     IntRect repaintRect;
     if (childrenInline())
         repaintRect = layoutInlineChildren(relayoutChildren);
@@ -496,7 +492,7 @@ void RenderBlock::layoutBlock(bool relayoutChildren)
 
     // Expand our intrinsic height to encompass floats.
     int toAdd = borderBottom() + paddingBottom();
-    if (includeScrollbarSize())
+    if (includeHorizontalScrollbarSize())
         toAdd += m_layer->horizontalScrollbarHeight();
     if (floatBottom() > (m_height - toAdd) && (isInlineBlockOrInlineTable() || isFloatingOrPositioned() || hasOverflowClip() ||
                                     (parent() && parent()->isFlexibleBox())))
@@ -936,7 +932,7 @@ void RenderBlock::determineHorizontalPosition(RenderObject* child)
         }
         child->setPos(chPos, child->yPos());
     } else {
-        int xPos = m_width - borderRight() - paddingRight() - (includeScrollbarSize() ? m_layer->verticalScrollbarWidth() : 0);
+        int xPos = m_width - borderRight() - paddingRight() - (includeVerticalScrollbarSize() ? m_layer->verticalScrollbarWidth() : 0);
         int chPos = xPos - (child->width() + child->marginRight());
         if (child->avoidsFloats()) {
             int rightOff = rightOffset(m_height);
@@ -1006,7 +1002,7 @@ void RenderBlock::handleBottomOfBlock(int top, int bottom, MarginInfo& marginInf
 void RenderBlock::layoutBlockChildren(bool relayoutChildren)
 {
     int top = borderTop() + paddingTop();
-    int bottom = borderBottom() + paddingBottom() + (includeScrollbarSize() ? m_layer->horizontalScrollbarHeight() : 0);
+    int bottom = borderBottom() + paddingBottom() + (includeHorizontalScrollbarSize() ? m_layer->horizontalScrollbarHeight() : 0);
 
     m_height = m_overflowHeight = top;
 
@@ -2020,7 +2016,7 @@ int
 RenderBlock::rightOffset() const
 {
     int right = m_width - borderRight() - paddingRight();
-    if (includeScrollbarSize())
+    if (includeVerticalScrollbarSize())
         right -= m_layer->verticalScrollbarWidth();
     return right;
 }
@@ -2180,11 +2176,12 @@ int RenderBlock::rightmostPosition(bool includeOverflowInterior, bool includeSel
     if (!includeSelf && firstLineBox()) {
         for (InlineRunBox* currBox = firstLineBox(); currBox; currBox = currBox->nextLineBox()) {
             int rp = currBox->xPos() + currBox->width();
+            // If this node is a root editable element, then the rightmostPosition should account for a caret at the end.
+            // FIXME: Need to find another way to do this, since scrollbars could show when we don't want them to.
+            if (node()->isContentEditable() && node() == node()->rootEditableElement() && style()->direction() == LTR)
+                rp += 1;
             right = max(right, rp);
         }
-        // If this node is a root editable element, then the rightmostPosition should account for a caret at the end.
-        if (node()->isContentEditable() && node() == node()->rootEditableElement() && style()->direction() == LTR)
-            right += 1;
     }
     
     return right;
@@ -2737,8 +2734,7 @@ void RenderBlock::calcMinMaxWidth()
         m_minWidth = m_maxWidth;
         
         // A horizontal marquee with inline children has no minimum width.
-        if (style()->overflow() == OMARQUEE && m_layer && m_layer->marquee() && 
-            m_layer->marquee()->isHorizontal() && !m_layer->marquee()->isUnfurlMarquee())
+        if (m_layer && m_layer->marquee() && m_layer->marquee()->isHorizontal() && !m_layer->marquee()->isUnfurlMarquee())
             m_minWidth = 0;
     }
 
index 8403da28e842fcab05b898f5fb3a068b211893ba..caa173a81c580957fbfdd0d97748c8156b647079 100644 (file)
@@ -109,9 +109,12 @@ void RenderBox::setStyle(RenderStyle *_style)
     }
 
     // We also handle <body> and <html>, whose overflow applies to the viewport.
-    if (_style->overflow() != OVISIBLE && !isRoot() && (!isBody() || !document()->isHTMLDocument()) &&
-        (isRenderBlock() || isTableRow() || isTableSection()))
-        setHasOverflowClip();
+    if (!isRoot() && (!isBody() || !document()->isHTMLDocument()) && (isRenderBlock() || isTableRow() || isTableSection())) {
+        // Check for overflow clip.
+        // It's sufficient to just check one direction, since it's illegal to have visible on only one overflow value.
+        if (_style->overflowX() != OVISIBLE)
+            setHasOverflowClip();
+    }
 
     if (requiresLayer()) {
         if (!m_layer) {
@@ -173,7 +176,7 @@ int RenderBox::contentWidth() const
 {
     int w = m_width - (borderLeft() + borderRight() + paddingLeft() + paddingRight());
 
-    if (includeScrollbarSize())
+    if (includeVerticalScrollbarSize())
         w -= m_layer->verticalScrollbarWidth();
     
     return w;
@@ -183,7 +186,7 @@ int RenderBox::contentHeight() const
 {
     int h = m_height - (borderTop() + borderBottom() + paddingTop() + paddingBottom());
 
-    if (includeScrollbarSize())
+    if (includeHorizontalScrollbarSize())
         h -= m_layer->horizontalScrollbarHeight();
 
     return h;
@@ -1086,7 +1089,7 @@ bool RenderBox::sizesToIntrinsicWidth(WidthType widthType) const
     
     // Children of a horizontal marquee do not fill the container by default.
     // FIXME: Need to deal with MAUTO value properly.  It could be vertical.
-    if (parent()->style()->overflow() == OMARQUEE) {
+    if (parent()->style()->overflowX() == OMARQUEE) {
         EMarqueeDirection dir = parent()->style()->marqueeDirection();
         if (dir == MAUTO || dir == MFORWARD || dir == MBACKWARD || dir == MLEFT || dir == MRIGHT)
             return true;
@@ -1205,7 +1208,7 @@ void RenderBox::calcHeight()
     }
     
     // Unfurling marquees override with the furled height.
-    if (style()->overflow() == OMARQUEE && m_layer && m_layer->marquee() && 
+    if (style()->overflowX() == OMARQUEE && m_layer && m_layer->marquee() && 
         m_layer->marquee()->isUnfurlMarquee() && !m_layer->marquee()->isHorizontal()) {
         m_layer->marquee()->setEnd(m_height);
         m_height = min(m_height, m_layer->marquee()->unfurlPos());
@@ -1272,8 +1275,7 @@ int RenderBox::calcPercentageHeight(const Length& height)
             // to grow to fill the space.  This could end up being wrong in some cases, but it is
             // preferable to the alternative (sizing intrinsically and making the row end up too big).
             RenderTableCell* cell = static_cast<RenderTableCell*>(cb);
-            if (scrollsOverflow() && 
-                (!cell->style()->height().isAuto() || !cell->table()->style()->height().isAuto()))
+            if (scrollsOverflowY() && (!cell->style()->height().isAuto() || !cell->table()->style()->height().isAuto()))
                 return 0;
             return -1;
         }
index 82983a0f43e26d19f3fc089da47659b706961795..772022a0b5cde22d4f18b7987533cf2712e3ba8d 100644 (file)
@@ -270,16 +270,12 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren)
 
     initMaxMarginValues();
 
+    // For overflow:scroll blocks, ensure we have both scrollbars in place always.
     if (scrollsOverflow()) {
-        // For overflow:scroll blocks, ensure we have both scrollbars in place always.
-        if (style()->overflow() == OSCROLL) {
+        if (style()->overflowX() == OSCROLL)
             m_layer->setHasHorizontalScrollbar(true);
+        if (style()->overflowY() == OSCROLL)
             m_layer->setHasVerticalScrollbar(true);
-        }
-
-        // Move the scrollbars aside during layout.  The layer will move them back when it
-        // does painting or event handling.
-        m_layer->moveScrollbarsAside();
     }
 
     if (isHorizontal())
index ed748e3251f894a1f6631ef744fc0ffcd42b9526..fd9641b1588db0e34b79795b66841dafc7905898 100644 (file)
@@ -577,7 +577,7 @@ RenderLayer::subtractScrollOffset(int& x, int& y)
 
 void RenderLayer::scrollToOffset(int x, int y, bool updateScrollbars, bool repaint)
 {
-    if (renderer()->style()->overflow() != OMARQUEE) {
+    if (renderer()->style()->overflowX() != OMARQUEE) {
         if (x < 0) x = 0;
         if (y < 0) y = 0;
     
@@ -793,7 +793,7 @@ void RenderLayer::autoscroll()
 
 bool RenderLayer::shouldAutoscroll()
 {
-    if (renderer()->hasOverflowClip() && (m_object->style()->overflow() != OHIDDEN || renderer()->node()->isContentEditable()))
+    if (renderer()->hasOverflowClip() && (m_object->scrollsOverflow() || renderer()->node()->isContentEditable()))
         return true;
     return false;
 }
@@ -916,15 +916,6 @@ RenderLayer::horizontalScrollbarHeight()
     return m_hBar->height();
 }
 
-void
-RenderLayer::moveScrollbarsAside()
-{
-    if (m_hBar)
-        m_hBar->move(0, -50000);
-    if (m_vBar)
-        m_vBar->move(0, -50000);
-}
-
 bool RenderLayer::isPointInResizeControl(const IntPoint& p)
 {
     return resizeControlRect().contains(IntRect(p, IntSize()));
@@ -1007,13 +998,13 @@ void
 RenderLayer::updateScrollInfoAfterLayout()
 {
     m_scrollDimensionsDirty = true;
-    if (m_object->style()->overflow() == OHIDDEN)
+    if (m_object->style()->overflowX() == OHIDDEN && m_object->style()->overflowY() == OHIDDEN)
         return; // All we had to do was dirty.
 
     bool needHorizontalBar, needVerticalBar;
     computeScrollDimensions(&needHorizontalBar, &needVerticalBar);
 
-    if (m_object->style()->overflow() != OMARQUEE) {
+    if (m_object->style()->overflowX() != OMARQUEE) {
         // Layout may cause us to be in an invalid scroll position.  In this case we need
         // to pull our scroll offsets back to the max (or push them up to the min).
         int newX = max(0, min(scrollXOffset(), scrollWidth() - m_object->clientWidth()));
@@ -1028,18 +1019,20 @@ RenderLayer::updateScrollInfoAfterLayout()
     bool haveVerticalBar = m_vBar;
 
     // overflow:scroll should just enable/disable.
-    if (m_object->style()->overflow() == OSCROLL) {
+    if (m_object->style()->overflowX() == OSCROLL)
         m_hBar->setEnabled(needHorizontalBar);
+    if (m_object->style()->overflowY() == OSCROLL)
         m_vBar->setEnabled(needVerticalBar);
-    }
 
     // overflow:auto may need to lay out again if scrollbars got added/removed.
-    bool scrollbarsChanged = (m_object->hasAutoScrollbars()) &&
-        (haveHorizontalBar != needHorizontalBar || haveVerticalBar != needVerticalBar);    
+    bool scrollbarsChanged = (m_object->hasAutoHorizontalScrollbar() && haveHorizontalBar != needHorizontalBar) || 
+                             (m_object->hasAutoVerticalScrollbar() && haveVerticalBar != needVerticalBar);    
     if (scrollbarsChanged) {
-        setHasHorizontalScrollbar(needHorizontalBar);
-        setHasVerticalScrollbar(needVerticalBar);
-    
+        if (m_object->hasAutoHorizontalScrollbar())
+            setHasHorizontalScrollbar(needHorizontalBar);
+        if (m_object->hasAutoVerticalScrollbar())
+            setHasVerticalScrollbar(needVerticalBar);
+
 #if __APPLE__
         // Force an update since we know the scrollbars have changed things.
         if (m_object->document()->hasDashboardRegions())
@@ -1048,7 +1041,7 @@ RenderLayer::updateScrollInfoAfterLayout()
 
         m_object->repaint();
 
-        if (m_object->style()->overflow() == OAUTO) {
+        if (m_object->style()->overflowX() == OAUTO || m_object->style()->overflowY() == OAUTO) {
             if (!m_inOverflowRelayout) {
                 // Our proprietary overflow: overlay value doesn't trigger a layout.
                 m_inOverflowRelayout = true;
@@ -1819,7 +1812,7 @@ void RenderLayer::styleChanged()
             sc->dirtyZOrderLists();
     }
 
-    if (m_object->style()->overflow() == OMARQUEE && m_object->style()->marqueeBehavior() != MNONE) {
+    if (m_object->style()->overflowX() == OMARQUEE && m_object->style()->marqueeBehavior() != MNONE) {
         if (!m_marquee)
             m_marquee = new Marquee(this);
         m_marquee->updateMarqueeStyle();
index 431272a691ec3a8c6249cbd61e81a4441c62c8c1..3a27b5237a14ef988c01a0a4a9289d63df94848f 100644 (file)
@@ -238,7 +238,6 @@ public:
     QScrollBar* verticalScrollbar() { return m_vBar; }
     int verticalScrollbarWidth();
     int horizontalScrollbarHeight();
-    void moveScrollbarsAside();
     void positionScrollbars(const IntRect& absBounds);
     void positionResizeControl();
     bool isPointInResizeControl(const IntPoint&);
index 9152bdd2c8fdccd283858724d835c280a2b92f25..0ca2145bf27984ac6414852dc023a02d4fb726c7 100644 (file)
@@ -598,14 +598,14 @@ int
 RenderObject::clientWidth() const
 {
     return width() - borderLeft() - borderRight() -
-        (includeScrollbarSize() ? layer()->verticalScrollbarWidth() : 0);
+        (includeVerticalScrollbarSize() ? layer()->verticalScrollbarWidth() : 0);
 }
 
 int
 RenderObject::clientHeight() const
 {
     return height() - borderTop() - borderBottom() -
-      (includeScrollbarSize() ? layer()->horizontalScrollbarHeight() : 0);
+      (includeHorizontalScrollbarSize() ? layer()->horizontalScrollbarHeight() : 0);
 }
 
 // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the
index d185f4ea3c3571665cd84280376a23eebc5f6d8e..9c4b2db21230a6b3875461c01f9fbd2115164533 100644 (file)
@@ -310,12 +310,16 @@ public:
     bool isSelectionBorder() const;
     
     bool hasOverflowClip() const { return m_hasOverflowClip; }
-    bool hasAutoScrollbars() const { return hasOverflowClip() && 
-        (style()->overflow() == OAUTO || style()->overflow() == OOVERLAY); }
-    bool scrollsOverflow() const { return hasOverflowClip() &&
-        (style()->overflow() == OSCROLL || hasAutoScrollbars()); }
-    bool includeScrollbarSize() const { return hasOverflowClip() &&
-        (style()->overflow() == OSCROLL || style()->overflow() == OAUTO); }
+    
+    bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style()->overflowY() == OAUTO || style()->overflowY() == OOVERLAY); }
+    bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() && (style()->overflowX() == OAUTO || style()->overflowX() == OOVERLAY); }
+
+    bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY(); }
+    bool scrollsOverflowX() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || hasAutoHorizontalScrollbar()); }
+    bool scrollsOverflowY() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || hasAutoVerticalScrollbar()); }
+    
+    bool includeVerticalScrollbarSize() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL || style()->overflowY() == OAUTO); }
+    bool includeHorizontalScrollbarSize() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL || style()->overflowX() == OAUTO); }
 
     RenderStyle* getPseudoStyle(RenderStyle::PseudoId pseudo, RenderStyle* parentStyle = 0) const;
     
index 2fd9e12507e349b75850e5a6a339cd5651d785a6..cebf8d0043252f9f148de383870d4d9a7c5bf928 100644 (file)
@@ -78,25 +78,39 @@ void RenderTextArea::setStyle(RenderStyle* s)
 
     w->setWritingDirection(style()->direction() == RTL ? RTL : LTR);
 
-    ScrollBarMode scrollMode = ScrollBarAuto;
-    switch (style()->overflow()) {
+    ScrollBarMode verticalScrollMode = ScrollBarAuto;
+    switch (style()->overflowY()) {
         case OAUTO:
         case OMARQUEE: // makes no sense, map to auto
         case OOVERLAY: // not implemented for text, map to auto
         case OVISIBLE:
             break;
         case OHIDDEN:
-            scrollMode = ScrollBarAlwaysOff;
+            verticalScrollMode = ScrollBarAlwaysOff;
             break;
         case OSCROLL:
-            scrollMode = ScrollBarAlwaysOn;
+            verticalScrollMode = ScrollBarAlwaysOn;
             break;
     }
-    ScrollBarMode horizontalScrollMode = scrollMode;
+    ScrollBarMode horizontalScrollMode = ScrollBarAuto;
+    switch (style()->overflowX()) {
+        case OAUTO:
+        case OMARQUEE: // makes no sense, map to auto
+        case OOVERLAY: // not implemented for text, map to auto
+        case OVISIBLE:
+            break;
+        case OHIDDEN:
+            horizontalScrollMode = ScrollBarAlwaysOff;
+            break;
+        case OSCROLL:
+            horizontalScrollMode = ScrollBarAlwaysOn;
+            break;
+    }
+
     if (static_cast<HTMLTextAreaElement*>(node())->wrap() != HTMLTextAreaElement::ta_NoWrap)
         horizontalScrollMode = ScrollBarAlwaysOff;
 
-    w->setScrollBarModes(horizontalScrollMode, scrollMode);
+    w->setScrollBarModes(horizontalScrollMode, verticalScrollMode);
 }
 
 void RenderTextArea::setEdited(bool x)
index 7dbd8530cf05964b7ac0908423cd055b4491fe8a..0d1131951b03dafb86cf0e39252fd87003d42121 100644 (file)
@@ -82,11 +82,10 @@ RenderStyle* RenderTextField::createDivStyle(RenderStyle* startStyle)
     divStyle->setUserModify(element->isReadOnlyControl() ? READ_ONLY : READ_WRITE_PLAINTEXT_ONLY);
 
     if (m_multiLine) {
-        // Forward overflow property
-        if (startStyle->overflow() == OHIDDEN || startStyle->overflow() == OSCROLL) 
-            divStyle->setOverflow(startStyle->overflow());
-        else
-            divStyle->setOverflow(OAUTO);
+        // Forward overflow properties.
+        divStyle->setOverflowX(startStyle->overflowX() == OVISIBLE ? OAUTO : startStyle->overflowX());
+        divStyle->setOverflowY(startStyle->overflowY() == OVISIBLE ? OAUTO : startStyle->overflowY());
+
         // Set word wrap property based on wrap attribute
         if (static_cast<HTMLTextAreaElement*>(element)->wrap() == HTMLTextAreaElement::ta_NoWrap) {
             divStyle->setWhiteSpace(PRE);
@@ -98,7 +97,8 @@ RenderStyle* RenderTextField::createDivStyle(RenderStyle* startStyle)
 
     } else {
         divStyle->setWhiteSpace(PRE);
-        divStyle->setOverflow(OHIDDEN);
+        divStyle->setOverflowX(OHIDDEN);
+        divStyle->setOverflowY(OHIDDEN);
     }
 
     if (!m_multiLine) {
@@ -316,7 +316,7 @@ void RenderTextField::calcHeight()
     // FIXME: We should get the size of the scrollbar from the RenderTheme instead of hard coding it here.
     int scrollbarSize = 0;
     // We are able to have a horizontal scrollbar if the overflow style is scroll, or if its auto and there's no word wrap.
-    if (m_div->renderer()->style()->overflow() == OSCROLL ||  (m_div->renderer()->style()->overflow() == OAUTO && m_div->renderer()->style()->wordWrap() == WBNORMAL))
+    if (m_div->renderer()->style()->overflowX() == OSCROLL ||  (m_div->renderer()->style()->overflowX() == OAUTO && m_div->renderer()->style()->wordWrap() == WBNORMAL))
         scrollbarSize = 15;
 
     m_height = line * rows + toAdd + scrollbarSize;
@@ -348,7 +348,7 @@ void RenderTextField::calcMinMaxWidth()
         if (m_multiLine) {
             factor = static_cast<HTMLTextAreaElement*>(node())->cols();
             // FIXME: We should get the size of the scrollbar from the RenderTheme instead of hard coding it here.
-            if (m_div->renderer()->style()->overflow() != OHIDDEN)
+            if (m_div->renderer()->style()->overflowY() != OHIDDEN)
                 scrollbarSize = 15;
         }
         else {
index 8277afa262a617d3ef170ca4798a491937e7855e..ea528f9260182863f157a54cb63ca41c0833e47e 100644 (file)
@@ -1485,7 +1485,7 @@ IntRect RenderBlock::layoutInlineChildren(bool relayoutChildren)
     
     m_height = borderTop() + paddingTop();
     int toAdd = borderBottom() + paddingBottom();
-    if (includeScrollbarSize())
+    if (includeHorizontalScrollbarSize())
         toAdd += m_layer->horizontalScrollbarHeight();
     
     // Figure out if we should clear out our line boxes.
index 3b7913890941fbb21ecff9b8e13bf1de554286f7..6df2baa68bffd0ccbe7705a5fd27a635a4bd3d2c 100644 (file)
@@ -877,6 +877,11 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
         )
         return Layout;
 
+    // Overflow returns a layout hint.
+    if (noninherited_flags._overflowX != other->noninherited_flags._overflowX ||
+        noninherited_flags._overflowY != other->noninherited_flags._overflowY)
+        return Layout;
+        
 // only for inline:
 //     EVerticalAlign _vertical_align : 4;
 
@@ -918,12 +923,10 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
 
     // Repaint:
 //      EVisibility _visibility : 2;
-//     EOverflow _overflow : 4 ;
 //      int _text_decoration : 4;
 //     DataRef<StyleBackgroundData> background;
     if (inherited->color != other->inherited->color ||
-        !(inherited_flags._visibility == other->inherited_flags._visibility) ||
-        !(noninherited_flags._overflow == other->noninherited_flags._overflow) ||
+        inherited_flags._visibility != other->inherited_flags._visibility ||
         !(inherited_flags._text_decorations == other->inherited_flags._text_decorations) ||
         !(inherited_flags._force_backgrounds_to_white == other->inherited_flags._force_backgrounds_to_white) ||
         !(surround->border == other->surround->border) ||
index 02219cee437d6e8c73e5e53b1a8cedd17f0dfe48..c9ed483926556dc69f4655260316825f787da033 100644 (file)
@@ -375,7 +375,7 @@ struct StyleDashboardRegion
 // Random visual rendering model attributes. Not inherited.
 
 enum EOverflow {
-    OVISIBLE, OHIDDEN, OSCROLL, OAUTO, OMARQUEE, OOVERLAY
+    OVISIBLE, OHIDDEN, OSCROLL, OAUTO, OOVERLAY, OMARQUEE
 };
 
 enum EVerticalAlign {
@@ -972,7 +972,8 @@ protected:
             return (_effectiveDisplay == other._effectiveDisplay) &&
             (_originalDisplay == other._originalDisplay) &&
             (_bg_repeat == other._bg_repeat) &&
-            (_overflow == other._overflow) &&
+            (_overflowX == other._overflowX) &&
+            (_overflowY == other._overflowY) &&
             (_vertical_align == other._vertical_align) &&
             (_clear == other._clear) &&
             (_position == other._position) &&
@@ -995,7 +996,8 @@ protected:
         unsigned _effectiveDisplay : 5; // EDisplay
         unsigned _originalDisplay : 5; // EDisplay
         unsigned _bg_repeat : 2; // EBackgroundRepeat
-        unsigned _overflow : 4; // EOverflow
+        unsigned _overflowX : 4; // EOverflow
+        unsigned _overflowY : 4; // EOverflow
         unsigned _vertical_align : 4; // EVerticalAlign
         unsigned _clear : 2; // EClear
         unsigned _position : 2; // EPosition
@@ -1063,7 +1065,8 @@ protected:
         inherited_flags._force_backgrounds_to_white = false;
         
         noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = initialDisplay();
-        noninherited_flags._overflow = initialOverflow();
+        noninherited_flags._overflowX = initialOverflowX();
+        noninherited_flags._overflowY = initialOverflowY();
         noninherited_flags._vertical_align = initialVerticalAlign();
         noninherited_flags._clear = initialClear();
         noninherited_flags._position = initialPosition();
@@ -1185,7 +1188,9 @@ public:
     bool outlineStyleIsAuto() const { return background->m_outline._auto; }
     const Color &  outlineColor() const {  return background->m_outline.color; }
 
-    EOverflow overflow() const { return  static_cast<EOverflow>(noninherited_flags._overflow); }
+    EOverflow overflowX() const { return static_cast<EOverflow>(noninherited_flags._overflowX); }
+    EOverflow overflowY() const { return static_cast<EOverflow>(noninherited_flags._overflowY); }
+
     EVisibility visibility() const { return static_cast<EVisibility>(inherited_flags._visibility); }
     EVerticalAlign verticalAlign() const { return  static_cast<EVerticalAlign>(noninherited_flags._vertical_align); }
     Length verticalAlignLength() const { return box->vertical_align; }
@@ -1427,7 +1432,8 @@ public:
     }
     void setOutlineColor(const Color & v) {  SET_VAR(background,m_outline.color,v) }
 
-    void setOverflow(EOverflow v) {  noninherited_flags._overflow = v; }
+    void setOverflowX(EOverflow v) { noninherited_flags._overflowX = v; }
+    void setOverflowY(EOverflow v) { noninherited_flags._overflowY = v; }
     void setVisibility(EVisibility v) { inherited_flags._visibility = v; }
     void setVerticalAlign(EVerticalAlign v) { noninherited_flags._vertical_align = v; }
     void setVerticalAlignLength(Length l) { SET_VAR(box, vertical_align, l ) }
@@ -1625,7 +1631,8 @@ public:
     static EFloat initialFloating() { return FNONE; }
     static EListStylePosition initialListStylePosition() { return OUTSIDE; }
     static EListStyleType initialListStyleType() { return DISC; }
-    static EOverflow initialOverflow() { return OVISIBLE; }
+    static EOverflow initialOverflowX() { return OVISIBLE; }
+    static EOverflow initialOverflowY() { return OVISIBLE; }
     static EPageBreak initialPageBreak() { return PBAUTO; }
     static EPosition initialPosition() { return StaticPosition; }
     static ETableLayout initialTableLayout() { return TAUTO; }