[webkit-changes] cvs commit: WebCore/khtml/rendering render_box.cpp render_button.cpp render_button.h render_style.h render_theme.cpp render_theme.h render_theme_mac.h render_theme_mac.mm

David hyatt at opensource.apple.com
Sat Oct 22 11:19:29 PDT 2005


hyatt       05/10/22 11:19:29

  Modified:    .        ChangeLog
               khtml/css cssstyleselector.cpp html4.css
               khtml/rendering render_box.cpp render_button.cpp
                        render_button.h render_style.h render_theme.cpp
                        render_theme.h render_theme_mac.h
                        render_theme_mac.mm
  Log:
          Reviewed by darin
  
          * khtml/css/cssstyleselector.cpp:
  	Add support for the GrayText CSS2 system color to represent
  	the disabled text color for controls.
  
          * khtml/css/html4.css:
  	Make sure that the default cursor is set for all types of buttons
  	and not just the HTML4 button.
  
  	Set the foreground color for buttons using the CSS2 system color.
  	Set the disabled text color using the CSS2 system color.
  
  	Move the default padding for buttons into the CSS file.  It will
  	get overridden by Aqua buttons but be honored by all other types
  	of buttons.  This allows the author to override it as well when
  	customizing.
  
          * khtml/rendering/render_block.h:
          Make paintChildren virtual so that RenderButton can push a clip
  	and pop a clip when painting children.
  
  	* khtml/rendering/render_box.cpp:
          (RenderBox::paintBoxDecorations):
          Let the theme now decide whether the border/background should
  	still be painted after the theme has painted.  This allows buttons
  	to paint custom borders but still use a pretty OS X background for
  	the button face.
  
  	* khtml/rendering/render_button.cpp:
          (khtml::RenderButton::paintChildren):
          Overridden to push/pop a clip so that the contents of a button
  	don't ever spill out.
  
  	* khtml/rendering/render_button.h:
          Added paintChildren method.
  
  	* khtml/rendering/render_style.h:
          (khtml::BorderData::hasBorder):
          Fixed a regression in hasBorder.  The border-image logic was
  	inverted, resulting in hasBorder being true for every element!
  
  	* khtml/rendering/render_theme.cpp:
          (khtml::RenderTheme::paint):
          Patched to return a boolean indicating whether or not the
  	border/background should be painted.
  
  	* khtml/rendering/render_theme.h:
          * khtml/rendering/render_theme_mac.h:
          * khtml/rendering/render_theme_mac.mm:
          (khtml::RenderThemeMac::adjustRepaintRect):
          Forgot to include radio and button in this method so that repaint
  	rects would be correct.
  
  	(khtml::RenderThemeMac::paintCheckbox):
          (khtml::RenderThemeMac::paintRadio):
          Adjusted to return the boolean to indicate that painting of
  	border/background should not occur.
  
  	(khtml::RenderThemeMac::adjustButtonStyle):
          Added support for border/background/colors.  Also locked
  	white-space to nowrap for Aqua buttons to avoid line wrapping.
  
  	(khtml::RenderThemeMac::setButtonCellState):
  	(khtml::RenderThemeMac::paintButton):
  	More support for custom border/background/color.
  
  Revision  Changes    Path
  1.261     +69 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.260
  retrieving revision 1.261
  diff -u -r1.260 -r1.261
  --- ChangeLog	22 Oct 2005 01:41:34 -0000	1.260
  +++ ChangeLog	22 Oct 2005 18:19:21 -0000	1.261
  @@ -1,3 +1,72 @@
  +2005-10-21  David Hyatt  <hyatt at apple.com>
  +
  +        Reviewed by darin
  +
  +        * khtml/css/cssstyleselector.cpp:
  +	Add support for the GrayText CSS2 system color to represent
  +	the disabled text color for controls.
  +	
  +        * khtml/css/html4.css:
  +	Make sure that the default cursor is set for all types of buttons
  +	and not just the HTML4 button.
  +
  +	Set the foreground color for buttons using the CSS2 system color.
  +	Set the disabled text color using the CSS2 system color.
  +
  +	Move the default padding for buttons into the CSS file.  It will
  +	get overridden by Aqua buttons but be honored by all other types
  +	of buttons.  This allows the author to override it as well when
  +	customizing.
  +	
  +        * khtml/rendering/render_block.h:
  +        Make paintChildren virtual so that RenderButton can push a clip
  +	and pop a clip when painting children.
  +	
  +	* khtml/rendering/render_box.cpp:
  +        (RenderBox::paintBoxDecorations):
  +        Let the theme now decide whether the border/background should
  +	still be painted after the theme has painted.  This allows buttons
  +	to paint custom borders but still use a pretty OS X background for
  +	the button face.
  +	
  +	* khtml/rendering/render_button.cpp:
  +        (khtml::RenderButton::paintChildren):
  +        Overridden to push/pop a clip so that the contents of a button
  +	don't ever spill out.
  +	
  +	* khtml/rendering/render_button.h:
  +        Added paintChildren method.
  +	
  +	* khtml/rendering/render_style.h:
  +        (khtml::BorderData::hasBorder):
  +        Fixed a regression in hasBorder.  The border-image logic was
  +	inverted, resulting in hasBorder being true for every element!
  +	
  +	* khtml/rendering/render_theme.cpp:
  +        (khtml::RenderTheme::paint):
  +        Patched to return a boolean indicating whether or not the
  +	border/background should be painted.
  +	
  +	* khtml/rendering/render_theme.h:
  +        * khtml/rendering/render_theme_mac.h:
  +        * khtml/rendering/render_theme_mac.mm:
  +        (khtml::RenderThemeMac::adjustRepaintRect):
  +        Forgot to include radio and button in this method so that repaint
  +	rects would be correct.
  +	
  +	(khtml::RenderThemeMac::paintCheckbox):
  +        (khtml::RenderThemeMac::paintRadio):
  +        Adjusted to return the boolean to indicate that painting of
  +	border/background should not occur.
  +	
  +	(khtml::RenderThemeMac::adjustButtonStyle):
  +        Added support for border/background/colors.  Also locked
  +	white-space to nowrap for Aqua buttons to avoid line wrapping.
  +	
  +	(khtml::RenderThemeMac::setButtonCellState):
  +	(khtml::RenderThemeMac::paintButton):
  +	More support for custom border/background/color.
  +	
   2005-10-21  Geoffrey Garen  <ggaren at apple.com>
   
           Reviewed by darin.
  
  
  
  1.212     +2 -2      WebCore/khtml/css/cssstyleselector.cpp
  
  Index: cssstyleselector.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/cssstyleselector.cpp,v
  retrieving revision 1.211
  retrieving revision 1.212
  diff -u -r1.211 -r1.212
  --- cssstyleselector.cpp	21 Oct 2005 21:27:43 -0000	1.211
  +++ cssstyleselector.cpp	22 Oct 2005 18:19:24 -0000	1.212
  @@ -746,7 +746,7 @@
       // 3. If our medium is print, then we match rules from the print sheet.
       if (m_medium == "print")
           matchRules(defaultPrintStyle, firstUARule, lastUARule);
  -    
  +
       // 4. Now we check user sheet rules.
       int firstUserRule = -1, lastUserRule = -1;
       matchRules(m_userStyle, firstUserRule, lastUserRule);
  @@ -1625,7 +1625,7 @@
       { CSS_VAL_BUTTONSHADOW, 0xFFFFFFFF },
       { CSS_VAL_BUTTONTEXT, 0xFF000000 },
       { CSS_VAL_CAPTIONTEXT, 0xFF000000 },
  -    { CSS_VAL_GRAYTEXT, 0xFF000000 },
  +    { CSS_VAL_GRAYTEXT, 0xFF808080 },
       { CSS_VAL_HIGHLIGHT, 0xFFFFFFFF },
       { CSS_VAL_HIGHLIGHTTEXT, 0xFFFFFFFF },
       { CSS_VAL_INACTIVEBORDER, 0xFFFFFFFF },
  
  
  
  1.79      +12 -3     WebCore/khtml/css/html4.css
  
  Index: html4.css
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/html4.css,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- html4.css	21 Oct 2005 21:27:44 -0000	1.78
  +++ html4.css	22 Oct 2005 18:19:25 -0000	1.79
  @@ -278,8 +278,8 @@
   }
   
   button {
  -    cursor: default;
  -    -khtml-appearance: button
  +    -khtml-appearance: button;
  +    white-space: normal
   }
   
   input, textarea {
  @@ -306,12 +306,21 @@
   
   input[type="button"], input[type="submit"], input[type="reset"]
   {
  -    -khtml-appearance: push-button
  +    -khtml-appearance: push-button;
  +    white-space: pre;
  +    line-height: normal !important
   }
   
   input[type="button"], input[type="submit"], input[type="reset"], button {
       -khtml-box-align: center;
       text-align:center;
  +    cursor: default;
  +    color: ButtonText;
  +    padding: 2px 8px 3px 8px
  +}
  +
  +input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled, button:disabled {
  +    color: GrayText;
   }
   
   select, button, input[type="button"], input[type="image"], input[type="submit"], input[type="reset"], img {
  
  
  
  1.172     +5 -4      WebCore/khtml/rendering/render_box.cpp
  
  Index: render_box.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_box.cpp,v
  retrieving revision 1.171
  retrieving revision 1.172
  diff -u -r1.171 -r1.172
  --- render_box.cpp	6 Oct 2005 00:53:56 -0000	1.171
  +++ render_box.cpp	22 Oct 2005 18:19:26 -0000	1.172
  @@ -325,10 +325,11 @@
       else
           mh = kMin(i.r.height(), h);
   
  -    // If we have a native theme appearance, use that instead of painting our border/background.
  -    if (style()->hasAppearance())
  -        return theme()->paint(this, i, QRect(_tx, _ty, w, h));
  -        
  +    // If we have a native theme appearance, paint that before painting our border/background.  The theme will
  +    // tell us whether or not we should also paint the CSS border/background.
  +    if (style()->hasAppearance() && !theme()->paint(this, i, QRect(_tx, _ty, w, h)))
  +        return;
  +
       // The <body> only paints its background if the root element has defined a background
       // independent of the body.  Go through the DOM to get to the root element's render object,
       // since the root could be inline and wrapped in an anonymous block.
  
  
  
  1.2       +18 -0     WebCore/khtml/rendering/render_button.cpp
  
  Index: render_button.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_button.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- render_button.cpp	21 Oct 2005 21:27:46 -0000	1.1
  +++ render_button.cpp	22 Oct 2005 18:19:27 -0000	1.2
  @@ -93,4 +93,22 @@
       }
   }
   
  +void RenderButton::paintObject(PaintInfo& i, int _tx, int _ty)
  +{
  +    // Push a clip.
  +    if (m_inner && i.phase == PaintActionForeground) {
  +        QRect clipRect(_tx + m_inner->xPos(), _ty + m_inner->yPos(), m_inner->width(), m_inner->height());
  +        clipRect = i.p->xForm(clipRect);
  +        i.p->save();
  +        i.p->addClip(clipRect);
  +    }
  +    
  +    // Paint the children.
  +    RenderBlock::paintObject(i, _tx, _ty);
  +    
  +    // Pop the clip.
  +    if (m_inner && i.phase == PaintActionForeground)
  +        i.p->restore();
  +}
  +
   }
  
  
  
  1.2       +2 -0      WebCore/khtml/rendering/render_button.h
  
  Index: render_button.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_button.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- render_button.h	21 Oct 2005 21:27:46 -0000	1.1
  +++ render_button.h	22 Oct 2005 18:19:27 -0000	1.2
  @@ -43,6 +43,8 @@
       virtual void setStyle(RenderStyle* style);
       virtual void updateFromElement();
   
  +    void paintObject(PaintInfo& i, int _tx, int _ty);
  +
       virtual const char *renderName() const { return "RenderButton"; }
   
   protected:
  
  
  
  1.95      +1 -1      WebCore/khtml/rendering/render_style.h
  
  Index: render_style.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_style.h,v
  retrieving revision 1.94
  retrieving revision 1.95
  diff -u -r1.94 -r1.95
  --- render_style.h	21 Oct 2005 21:27:47 -0000	1.94
  +++ render_style.h	22 Oct 2005 18:19:27 -0000	1.95
  @@ -314,7 +314,7 @@
       bool hasBorder() const
       {
           bool haveImage = image.hasImage();
  -    	return left.nonZero(haveImage) || right.nonZero(haveImage) || top.nonZero(haveImage) || bottom.nonZero(haveImage);
  +    	return left.nonZero(!haveImage) || right.nonZero(!haveImage) || top.nonZero(!haveImage) || bottom.nonZero(!haveImage);
       }
   
       bool hasBorderRadius() const {
  
  
  
  1.13      +5 -3      WebCore/khtml/rendering/render_theme.cpp
  
  Index: render_theme.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_theme.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- render_theme.cpp	21 Oct 2005 21:27:47 -0000	1.12
  +++ render_theme.cpp	22 Oct 2005 18:19:27 -0000	1.13
  @@ -59,7 +59,7 @@
       }
   }
   
  -void RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)
  +bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)
   {
       // If painting is disabled, but we aren't updating control tints, then just bail.
       // If we are updating control tints, just schedule a repaint if the theme supports tinting
  @@ -67,10 +67,10 @@
       if (i.p->updatingControlTints()) {
           if (controlSupportsTints(o))
               o->repaint();
  -        return;
  +        return false;
       }
       if (i.p->paintingDisabled())
  -        return;
  +        return false;
           
       // Call the appropriate paint method based off the appearance value.
       switch (o->style()->appearance()) {
  @@ -85,6 +85,8 @@
           default:
               break;
       }
  +    
  +    return false;
   }
   
   short RenderTheme::baselinePosition(const RenderObject* o) const
  
  
  
  1.11      +6 -5      WebCore/khtml/rendering/render_theme.h
  
  Index: render_theme.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_theme.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- render_theme.h	21 Oct 2005 21:27:47 -0000	1.10
  +++ render_theme.h	22 Oct 2005 18:19:27 -0000	1.11
  @@ -48,8 +48,9 @@
       void adjustStyle(CSSStyleSelector* selector, RenderStyle* style, DOM::ElementImpl* e);
       
       // This method is called to paint the widget as a background of the RenderObject.  A widget's foreground, e.g., the
  -    // text of a button, is always rendered by the engine itself.
  -    void paint(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);
  +    // text of a button, is always rendered by the engine itself.  The boolean return value indicates
  +    // whether the CSS border/background should also be painted.
  +    bool paint(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);
   
       // The remaining methods should be implemented by the platform-specific portion of the theme, e.g.,
       // render_theme_mac.cpp for Mac OS X.
  @@ -90,15 +91,15 @@
   
       // Methods for each appearance value.
       virtual void adjustCheckboxStyle(CSSStyleSelector* selector, RenderStyle* style, DOM::ElementImpl* e) const;
  -    virtual void paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0;
  +    virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0;
       virtual void setCheckboxSize(RenderStyle* style) const {};
       
       virtual void adjustRadioStyle(CSSStyleSelector* selector, RenderStyle* style, DOM::ElementImpl* e) const;
  -    virtual void paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0;
  +    virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0;
       virtual void setRadioSize(RenderStyle* style) const {};
       
       virtual void adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, DOM::ElementImpl* e) const;
  -    virtual void paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0;
  +    virtual bool paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0;
       virtual void setButtonSize(RenderStyle* style) const {};
   };
   
  
  
  
  1.8       +3 -3      WebCore/khtml/rendering/render_theme_mac.h
  
  Index: render_theme_mac.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_theme_mac.h,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- render_theme_mac.h	21 Oct 2005 21:27:47 -0000	1.7
  +++ render_theme_mac.h	22 Oct 2005 18:19:27 -0000	1.8
  @@ -49,14 +49,14 @@
   
   protected:
       // Methods for each appearance value.
  -    virtual void paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);
  +    virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);
       virtual void setCheckboxSize(RenderStyle* style) const;
       
  -    virtual void paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);
  +    virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);
       virtual void setRadioSize(RenderStyle* style) const;
       
       virtual void adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, DOM::ElementImpl* e) const;
  -    virtual void paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);
  +    virtual bool paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);
       virtual void setButtonSize(RenderStyle* style) const;
   
   private:
  
  
  
  1.11      +74 -59    WebCore/khtml/rendering/render_theme_mac.mm
  
  Index: render_theme_mac.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_theme_mac.mm,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- render_theme_mac.mm	21 Oct 2005 22:45:53 -0000	1.10
  +++ render_theme_mac.mm	22 Oct 2005 18:19:27 -0000	1.11
  @@ -55,13 +55,38 @@
   
   void RenderThemeMac::adjustRepaintRect(const RenderObject* o, QRect& r)
   {
  -    if (o->style()->appearance() == CheckboxAppearance) {
  -        // Since we query the prototype cell, we need to update its state to match.
  -        setCheckboxCellState(o, r);
  -    
  -        // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox
  -        // shadow" and the check.  We don't consider this part of the bounds of the control in WebKit.
  -        r = inflateRect(r, checkboxSizes()[[checkbox controlSize]], checkboxMargins());
  +    switch (o->style()->appearance()) {
  +        case CheckboxAppearance: {
  +            // Since we query the prototype cell, we need to update its state to match.
  +            setCheckboxCellState(o, r);
  +        
  +            // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox
  +            // shadow" and the check.  We don't consider this part of the bounds of the control in WebKit.
  +            r = inflateRect(r, checkboxSizes()[[checkbox controlSize]], checkboxMargins());
  +            break;
  +        }
  +        case RadioAppearance: {
  +            // Since we query the prototype cell, we need to update its state to match.
  +            setRadioCellState(o, r);
  +        
  +            // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox
  +            // shadow" and the check.  We don't consider this part of the bounds of the control in WebKit.
  +            r = inflateRect(r, radioSizes()[[radio controlSize]], radioMargins());
  +            break;
  +        }
  +        case PushButtonAppearance:
  +        case ButtonAppearance: {
  +            // Since we query the prototype cell, we need to update its state to match.
  +            setButtonCellState(o, r);
  +        
  +            // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox
  +            // shadow" and the check.  We don't consider this part of the bounds of the control in WebKit.
  +            if ([button bezelStyle] == NSRoundedBezelStyle)
  +                r = inflateRect(r, buttonSizes()[[button controlSize]], buttonMargins());
  +            break;
  +        }
  +        default:
  +            break;
       }
   }
   
  @@ -216,7 +241,7 @@
       }
   }
   
  -void RenderThemeMac::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)
  +bool RenderThemeMac::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)
   {
       // Determine the width and height needed for the control and prepare the cell for painting.
       setCheckboxCellState(o, r);
  @@ -226,6 +251,8 @@
       QRect inflatedRect = inflateRect(r, checkboxSizes()[[checkbox controlSize]], checkboxMargins());
       [checkbox drawWithFrame:NSRect(inflatedRect) inView:o->canvas()->view()->getDocumentView()];
       [checkbox setControlView: nil];
  +    
  +    return false;
   }
   
   const QSize* RenderThemeMac::checkboxSizes() const
  @@ -273,7 +300,7 @@
       setSizeFromFont(style, checkboxSizes());
   }
   
  -void RenderThemeMac::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)
  +bool RenderThemeMac::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)
   {
       // Determine the width and height needed for the control and prepare the cell for painting.
       setRadioCellState(o, r);
  @@ -283,6 +310,8 @@
       QRect inflatedRect = inflateRect(r, radioSizes()[[radio controlSize]], radioMargins());
       [radio drawWithFrame:NSRect(inflatedRect) inView:o->canvas()->view()->getDocumentView()];
       [radio setControlView: nil];
  +    
  +    return false;
   }
   
   const QSize* RenderThemeMac::radioSizes() const
  @@ -357,8 +386,8 @@
   {
       // There are three appearance constants for buttons.
       // (1) Push-button is the constant for the default Aqua system button.  Push buttons will not scale vertically and will not allow
  -    // custom fonts or colors.  <input>s use this constant.  The fundamental rule for push-button is that we will never display a push-button
  -    // that looks "half-Aqua."  Either the button will look perfectly native, or it will turn off the Aqua look completely.
  +    // custom fonts or colors.  <input>s use this constant.  This button will allow custom colors and font weights/variants but won't
  +    // scale vertically.
       // (2) square-button is the constant for the square button.  This button will allow custom fonts and colors and will scale vertically.
       // (3) Button is the constant that means "pick the best button as appropriate."  <button>s use this constant.  This button will
       // also scale vertically and allow custom fonts and colors.  It will attempt to use Aqua if possible and will make this determination
  @@ -371,22 +400,16 @@
       addIntrinsicMargins(style, controlSize);
               
       // Whenever a button has a background or border specified, then appearance is disabled.
  -    // FIXME: We can't support the disabling of appearance yet until box-sizing is fully implemented.
  -    bool disableAppearance = false; // style->hasBorder() || style->hasBackground();
  +    // FIXME: We need to support box-sizing properly on bordered buttons!  They end up too big right now!
  +    bool disableAppearance = style->hasBorder() || style->hasBackground();
       if (!disableAppearance) {
  -        // FIXME: This line is temporary. It can go away once the presence of a border really disables appearance.
  -        style->resetBorder();
  -     
           if (style->appearance() == PushButtonAppearance) {
  -            // Color is locked to black.
  -            if (!e || e->isEnabled())
  -                style->setColor(Qt::black);
  -            else
  -                style->setColor(QColor(128,128,128));
  -
               // Height is locked to auto.
               style->setHeight(Length(Auto));
               
  +            // White-space is locked to nowrap
  +            style->setWhiteSpace(PRE);
  +
               // Set the button's vertical size.
               setButtonSize(style);
   
  @@ -398,29 +421,11 @@
               // system font for the control size instead.
               setFontFromControlSize(selector, style, controlSize);
           } else {
  -            // Reset padding to a sensible size.
  -            // FIXME: Honor author's padding if it's set.
  -            style->setPaddingLeft(Length(8, Fixed));
  -            style->setPaddingRight(Length(8, Fixed));
  -            style->setPaddingTop(Length(2, Fixed));
  -            style->setPaddingBottom(Length(3, Fixed));
  -            
               // Set a min-height so that we can't get smaller than the mini button.
               // FIXME: Once we support box-sizing, we'll have to change this value to include the padding.
               style->setMinHeight(Length(10, Fixed));
  -
  -            // Color is locked to black.
  -            // FIXME: Honor author's color if it's set.
  -            if (!e || e->isEnabled())
  -                style->setColor(Qt::black);
  -            else
  -                style->setColor(QColor(128,128,128));
           }
  -    } else {
  -        // FIXME: We're going to have to make sure some sort of decent padding/border/background is in effect when the appearance gets turned off.
  -        // We will need to know whether or not the user set these, and then fill in the ones that weren't set.
       }
  -
   }
   
   const QSize* RenderThemeMac::buttonSizes() const
  @@ -459,7 +464,9 @@
       }
   
       // Set the control size based off the rectangle we're painting into.
  -    if (o->style()->appearance() == SquareButtonAppearance || r.height() > buttonSizes()[NSRegularControlSize].height()) {
  +    if (o->style()->appearance() == SquareButtonAppearance ||
  +        o->style()->hasBorder() || 
  +        r.height() > buttonSizes()[NSRegularControlSize].height()) {
           // Use the square button
           if ([button bezelStyle] != NSShadowlessSquareBezelStyle)
               [button setBezelStyle:NSShadowlessSquareBezelStyle];
  @@ -475,28 +482,36 @@
       updateFocusedState(button, o);
   }
   
  -void RenderThemeMac::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)
  +bool RenderThemeMac::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)
   {
  -    // Determine the width and height needed for the control and prepare the cell for painting.
  -    setButtonCellState(o, r);
  +    bool hasBorder = o->style()->hasBorder();
  +    bool hasBackground = o->style()->hasBackground();
       
  -    // We inflate the rect as needed to account for padding included in the cell to accommodate the button
  -    // shadow.  We don't consider this part of the bounds of the control in WebKit.
  -    QSize size = buttonSizes()[[button controlSize]];
  -    size.setWidth(r.width());
  -    QRect inflatedRect = r;
  -    if ([button bezelStyle] == NSRoundedBezelStyle) {
  -        // Center the button within the available space.
  -        if (inflatedRect.height() > size.height()) {
  -            inflatedRect.setX(inflatedRect.x() + (inflatedRect.height() - size.height())/2);
  -            inflatedRect.setHeight(size.height());
  -        }
  +    if (!hasBackground) {
  +        // Determine the width and height needed for the control and prepare the cell for painting.
  +        setButtonCellState(o, r);
           
  -        // Now inflate it to account for the shadow.
  -        inflatedRect = inflateRect(inflatedRect, size, buttonMargins());
  +        // We inflate the rect as needed to account for padding included in the cell to accommodate the button
  +        // shadow.  We don't consider this part of the bounds of the control in WebKit.
  +        QSize size = buttonSizes()[[button controlSize]];
  +        size.setWidth(r.width());
  +        QRect inflatedRect = r;
  +        if ([button bezelStyle] == NSRoundedBezelStyle) {
  +            // Center the button within the available space.
  +            if (inflatedRect.height() > size.height()) {
  +                inflatedRect.setX(inflatedRect.x() + (inflatedRect.height() - size.height())/2);
  +                inflatedRect.setHeight(size.height());
  +            }
  +            
  +            // Now inflate it to account for the shadow.
  +            inflatedRect = inflateRect(inflatedRect, size, buttonMargins());
  +        }
  +
  +        [button drawWithFrame:NSRect(inflatedRect) inView:o->canvas()->view()->getDocumentView()];
  +        [button setControlView: nil];
       }
  -    [button drawWithFrame:NSRect(inflatedRect) inView:o->canvas()->view()->getDocumentView()];
  -    [button setControlView: nil];
  +    
  +    return hasBorder || hasBackground;
   }
   
   }
  
  
  



More information about the webkit-changes mailing list