Changeset 10909 in webkit
- Timestamp:
- Oct 22, 2005, 11:19:27 AM (20 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog-2005-12-19
r10903 r10909 1 2005-10-21 David Hyatt <hyatt@apple.com> 2 3 Reviewed by darin 4 5 * khtml/css/cssstyleselector.cpp: 6 Add support for the GrayText CSS2 system color to represent 7 the disabled text color for controls. 8 9 * khtml/css/html4.css: 10 Make sure that the default cursor is set for all types of buttons 11 and not just the HTML4 button. 12 13 Set the foreground color for buttons using the CSS2 system color. 14 Set the disabled text color using the CSS2 system color. 15 16 Move the default padding for buttons into the CSS file. It will 17 get overridden by Aqua buttons but be honored by all other types 18 of buttons. This allows the author to override it as well when 19 customizing. 20 21 * khtml/rendering/render_block.h: 22 Make paintChildren virtual so that RenderButton can push a clip 23 and pop a clip when painting children. 24 25 * khtml/rendering/render_box.cpp: 26 (RenderBox::paintBoxDecorations): 27 Let the theme now decide whether the border/background should 28 still be painted after the theme has painted. This allows buttons 29 to paint custom borders but still use a pretty OS X background for 30 the button face. 31 32 * khtml/rendering/render_button.cpp: 33 (khtml::RenderButton::paintChildren): 34 Overridden to push/pop a clip so that the contents of a button 35 don't ever spill out. 36 37 * khtml/rendering/render_button.h: 38 Added paintChildren method. 39 40 * khtml/rendering/render_style.h: 41 (khtml::BorderData::hasBorder): 42 Fixed a regression in hasBorder. The border-image logic was 43 inverted, resulting in hasBorder being true for every element! 44 45 * khtml/rendering/render_theme.cpp: 46 (khtml::RenderTheme::paint): 47 Patched to return a boolean indicating whether or not the 48 border/background should be painted. 49 50 * khtml/rendering/render_theme.h: 51 * khtml/rendering/render_theme_mac.h: 52 * khtml/rendering/render_theme_mac.mm: 53 (khtml::RenderThemeMac::adjustRepaintRect): 54 Forgot to include radio and button in this method so that repaint 55 rects would be correct. 56 57 (khtml::RenderThemeMac::paintCheckbox): 58 (khtml::RenderThemeMac::paintRadio): 59 Adjusted to return the boolean to indicate that painting of 60 border/background should not occur. 61 62 (khtml::RenderThemeMac::adjustButtonStyle): 63 Added support for border/background/colors. Also locked 64 white-space to nowrap for Aqua buttons to avoid line wrapping. 65 66 (khtml::RenderThemeMac::setButtonCellState): 67 (khtml::RenderThemeMac::paintButton): 68 More support for custom border/background/color. 69 1 70 2005-10-21 Geoffrey Garen <ggaren@apple.com> 2 71 -
trunk/WebCore/khtml/css/cssstyleselector.cpp
r10888 r10909 747 747 if (m_medium == "print") 748 748 matchRules(defaultPrintStyle, firstUARule, lastUARule); 749 749 750 750 // 4. Now we check user sheet rules. 751 751 int firstUserRule = -1, lastUserRule = -1; … … 1626 1626 { CSS_VAL_BUTTONTEXT, 0xFF000000 }, 1627 1627 { CSS_VAL_CAPTIONTEXT, 0xFF000000 }, 1628 { CSS_VAL_GRAYTEXT, 0xFF 000000 },1628 { CSS_VAL_GRAYTEXT, 0xFF808080 }, 1629 1629 { CSS_VAL_HIGHLIGHT, 0xFFFFFFFF }, 1630 1630 { CSS_VAL_HIGHLIGHTTEXT, 0xFFFFFFFF }, -
trunk/WebCore/khtml/css/html4.css
r10888 r10909 279 279 280 280 button { 281 cursor: default;282 -khtml-appearance: button281 -khtml-appearance: button; 282 white-space: normal 283 283 } 284 284 … … 307 307 input[type="button"], input[type="submit"], input[type="reset"] 308 308 { 309 -khtml-appearance: push-button 309 -khtml-appearance: push-button; 310 white-space: pre; 311 line-height: normal !important 310 312 } 311 313 … … 313 315 -khtml-box-align: center; 314 316 text-align:center; 317 cursor: default; 318 color: ButtonText; 319 padding: 2px 8px 3px 8px 320 } 321 322 input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled, button:disabled { 323 color: GrayText; 315 324 } 316 325 -
trunk/WebCore/khtml/rendering/render_box.cpp
r10755 r10909 326 326 mh = kMin(i.r.height(), h); 327 327 328 // If we have a native theme appearance, use that instead of painting our border/background. 329 if (style()->hasAppearance()) 330 return theme()->paint(this, i, QRect(_tx, _ty, w, h)); 331 328 // If we have a native theme appearance, paint that before painting our border/background. The theme will 329 // tell us whether or not we should also paint the CSS border/background. 330 if (style()->hasAppearance() && !theme()->paint(this, i, QRect(_tx, _ty, w, h))) 331 return; 332 332 333 // The <body> only paints its background if the root element has defined a background 333 334 // independent of the body. Go through the DOM to get to the root element's render object, -
trunk/WebCore/khtml/rendering/render_button.cpp
r10888 r10909 94 94 } 95 95 96 void RenderButton::paintObject(PaintInfo& i, int _tx, int _ty) 97 { 98 // Push a clip. 99 if (m_inner && i.phase == PaintActionForeground) { 100 QRect clipRect(_tx + m_inner->xPos(), _ty + m_inner->yPos(), m_inner->width(), m_inner->height()); 101 clipRect = i.p->xForm(clipRect); 102 i.p->save(); 103 i.p->addClip(clipRect); 104 } 105 106 // Paint the children. 107 RenderBlock::paintObject(i, _tx, _ty); 108 109 // Pop the clip. 110 if (m_inner && i.phase == PaintActionForeground) 111 i.p->restore(); 96 112 } 113 114 } -
trunk/WebCore/khtml/rendering/render_button.h
r10888 r10909 44 44 virtual void updateFromElement(); 45 45 46 void paintObject(PaintInfo& i, int _tx, int _ty); 47 46 48 virtual const char *renderName() const { return "RenderButton"; } 47 49 -
trunk/WebCore/khtml/rendering/render_style.h
r10888 r10909 315 315 { 316 316 bool haveImage = image.hasImage(); 317 return left.nonZero( haveImage) || right.nonZero(haveImage) || top.nonZero(haveImage) || bottom.nonZero(haveImage);317 return left.nonZero(!haveImage) || right.nonZero(!haveImage) || top.nonZero(!haveImage) || bottom.nonZero(!haveImage); 318 318 } 319 319 -
trunk/WebCore/khtml/rendering/render_theme.cpp
r10888 r10909 60 60 } 61 61 62 voidRenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)62 bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) 63 63 { 64 64 // If painting is disabled, but we aren't updating control tints, then just bail. … … 68 68 if (controlSupportsTints(o)) 69 69 o->repaint(); 70 return ;70 return false; 71 71 } 72 72 if (i.p->paintingDisabled()) 73 return ;73 return false; 74 74 75 75 // Call the appropriate paint method based off the appearance value. … … 86 86 break; 87 87 } 88 89 return false; 88 90 } 89 91 -
trunk/WebCore/khtml/rendering/render_theme.h
r10888 r10909 49 49 50 50 // This method is called to paint the widget as a background of the RenderObject. A widget's foreground, e.g., the 51 // text of a button, is always rendered by the engine itself. 52 void paint(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r); 51 // text of a button, is always rendered by the engine itself. The boolean return value indicates 52 // whether the CSS border/background should also be painted. 53 bool paint(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r); 53 54 54 55 // The remaining methods should be implemented by the platform-specific portion of the theme, e.g., … … 91 92 // Methods for each appearance value. 92 93 virtual void adjustCheckboxStyle(CSSStyleSelector* selector, RenderStyle* style, DOM::ElementImpl* e) const; 93 virtual voidpaintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0;94 virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0; 94 95 virtual void setCheckboxSize(RenderStyle* style) const {}; 95 96 96 97 virtual void adjustRadioStyle(CSSStyleSelector* selector, RenderStyle* style, DOM::ElementImpl* e) const; 97 virtual voidpaintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0;98 virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0; 98 99 virtual void setRadioSize(RenderStyle* style) const {}; 99 100 100 101 virtual void adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, DOM::ElementImpl* e) const; 101 virtual voidpaintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0;102 virtual bool paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) = 0; 102 103 virtual void setButtonSize(RenderStyle* style) const {}; 103 104 }; -
trunk/WebCore/khtml/rendering/render_theme_mac.h
r10888 r10909 50 50 protected: 51 51 // Methods for each appearance value. 52 virtual voidpaintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);52 virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r); 53 53 virtual void setCheckboxSize(RenderStyle* style) const; 54 54 55 virtual voidpaintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);55 virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r); 56 56 virtual void setRadioSize(RenderStyle* style) const; 57 57 58 58 virtual void adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, DOM::ElementImpl* e) const; 59 virtual voidpaintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r);59 virtual bool paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r); 60 60 virtual void setButtonSize(RenderStyle* style) const; 61 61 -
trunk/WebCore/khtml/rendering/render_theme_mac.mm
r10894 r10909 56 56 void RenderThemeMac::adjustRepaintRect(const RenderObject* o, QRect& r) 57 57 { 58 if (o->style()->appearance() == CheckboxAppearance) { 59 // Since we query the prototype cell, we need to update its state to match. 60 setCheckboxCellState(o, r); 61 62 // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox 63 // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. 64 r = inflateRect(r, checkboxSizes()[[checkbox controlSize]], checkboxMargins()); 58 switch (o->style()->appearance()) { 59 case CheckboxAppearance: { 60 // Since we query the prototype cell, we need to update its state to match. 61 setCheckboxCellState(o, r); 62 63 // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox 64 // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. 65 r = inflateRect(r, checkboxSizes()[[checkbox controlSize]], checkboxMargins()); 66 break; 67 } 68 case RadioAppearance: { 69 // Since we query the prototype cell, we need to update its state to match. 70 setRadioCellState(o, r); 71 72 // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox 73 // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. 74 r = inflateRect(r, radioSizes()[[radio controlSize]], radioMargins()); 75 break; 76 } 77 case PushButtonAppearance: 78 case ButtonAppearance: { 79 // Since we query the prototype cell, we need to update its state to match. 80 setButtonCellState(o, r); 81 82 // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox 83 // shadow" and the check. We don't consider this part of the bounds of the control in WebKit. 84 if ([button bezelStyle] == NSRoundedBezelStyle) 85 r = inflateRect(r, buttonSizes()[[button controlSize]], buttonMargins()); 86 break; 87 } 88 default: 89 break; 65 90 } 66 91 } … … 217 242 } 218 243 219 voidRenderThemeMac::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)244 bool RenderThemeMac::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) 220 245 { 221 246 // Determine the width and height needed for the control and prepare the cell for painting. … … 227 252 [checkbox drawWithFrame:NSRect(inflatedRect) inView:o->canvas()->view()->getDocumentView()]; 228 253 [checkbox setControlView: nil]; 254 255 return false; 229 256 } 230 257 … … 274 301 } 275 302 276 voidRenderThemeMac::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r)303 bool RenderThemeMac::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) 277 304 { 278 305 // Determine the width and height needed for the control and prepare the cell for painting. … … 284 311 [radio drawWithFrame:NSRect(inflatedRect) inView:o->canvas()->view()->getDocumentView()]; 285 312 [radio setControlView: nil]; 313 314 return false; 286 315 } 287 316 … … 358 387 // There are three appearance constants for buttons. 359 388 // (1) Push-button is the constant for the default Aqua system button. Push buttons will not scale vertically and will not allow 360 // custom fonts or colors. <input>s use this constant. Th e fundamental rule for push-button is that we will never display a push-button361 // that looks "half-Aqua." Either the button will look perfectly native, or it will turn off the Aqua look completely.389 // custom fonts or colors. <input>s use this constant. This button will allow custom colors and font weights/variants but won't 390 // scale vertically. 362 391 // (2) square-button is the constant for the square button. This button will allow custom fonts and colors and will scale vertically. 363 392 // (3) Button is the constant that means "pick the best button as appropriate." <button>s use this constant. This button will … … 372 401 373 402 // Whenever a button has a background or border specified, then appearance is disabled. 374 // FIXME: We can't support the disabling of appearance yet until box-sizing is fully implemented.375 bool disableAppearance = false; //style->hasBorder() || style->hasBackground();403 // FIXME: We need to support box-sizing properly on bordered buttons! They end up too big right now! 404 bool disableAppearance = style->hasBorder() || style->hasBackground(); 376 405 if (!disableAppearance) { 377 // FIXME: This line is temporary. It can go away once the presence of a border really disables appearance.378 style->resetBorder();379 380 406 if (style->appearance() == PushButtonAppearance) { 381 // Color is locked to black.382 if (!e || e->isEnabled())383 style->setColor(Qt::black);384 else385 style->setColor(QColor(128,128,128));386 387 407 // Height is locked to auto. 388 408 style->setHeight(Length(Auto)); 389 409 410 // White-space is locked to nowrap 411 style->setWhiteSpace(PRE); 412 390 413 // Set the button's vertical size. 391 414 setButtonSize(style); … … 399 422 setFontFromControlSize(selector, style, controlSize); 400 423 } else { 401 // Reset padding to a sensible size.402 // FIXME: Honor author's padding if it's set.403 style->setPaddingLeft(Length(8, Fixed));404 style->setPaddingRight(Length(8, Fixed));405 style->setPaddingTop(Length(2, Fixed));406 style->setPaddingBottom(Length(3, Fixed));407 408 424 // Set a min-height so that we can't get smaller than the mini button. 409 425 // FIXME: Once we support box-sizing, we'll have to change this value to include the padding. 410 426 style->setMinHeight(Length(10, Fixed)); 411 412 // Color is locked to black.413 // FIXME: Honor author's color if it's set.414 if (!e || e->isEnabled())415 style->setColor(Qt::black);416 else417 style->setColor(QColor(128,128,128));418 427 } 419 } else { 420 // 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. 421 // We will need to know whether or not the user set these, and then fill in the ones that weren't set. 422 } 423 428 } 424 429 } 425 430 … … 460 465 461 466 // Set the control size based off the rectangle we're painting into. 462 if (o->style()->appearance() == SquareButtonAppearance || r.height() > buttonSizes()[NSRegularControlSize].height()) { 467 if (o->style()->appearance() == SquareButtonAppearance || 468 o->style()->hasBorder() || 469 r.height() > buttonSizes()[NSRegularControlSize].height()) { 463 470 // Use the square button 464 471 if ([button bezelStyle] != NSShadowlessSquareBezelStyle) … … 476 483 } 477 484 478 void RenderThemeMac::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) 479 { 480 // Determine the width and height needed for the control and prepare the cell for painting. 481 setButtonCellState(o, r); 482 483 // We inflate the rect as needed to account for padding included in the cell to accommodate the button 484 // shadow. We don't consider this part of the bounds of the control in WebKit. 485 QSize size = buttonSizes()[[button controlSize]]; 486 size.setWidth(r.width()); 487 QRect inflatedRect = r; 488 if ([button bezelStyle] == NSRoundedBezelStyle) { 489 // Center the button within the available space. 490 if (inflatedRect.height() > size.height()) { 491 inflatedRect.setX(inflatedRect.x() + (inflatedRect.height() - size.height())/2); 492 inflatedRect.setHeight(size.height()); 485 bool RenderThemeMac::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const QRect& r) 486 { 487 bool hasBorder = o->style()->hasBorder(); 488 bool hasBackground = o->style()->hasBackground(); 489 490 if (!hasBackground) { 491 // Determine the width and height needed for the control and prepare the cell for painting. 492 setButtonCellState(o, r); 493 494 // We inflate the rect as needed to account for padding included in the cell to accommodate the button 495 // shadow. We don't consider this part of the bounds of the control in WebKit. 496 QSize size = buttonSizes()[[button controlSize]]; 497 size.setWidth(r.width()); 498 QRect inflatedRect = r; 499 if ([button bezelStyle] == NSRoundedBezelStyle) { 500 // Center the button within the available space. 501 if (inflatedRect.height() > size.height()) { 502 inflatedRect.setX(inflatedRect.x() + (inflatedRect.height() - size.height())/2); 503 inflatedRect.setHeight(size.height()); 504 } 505 506 // Now inflate it to account for the shadow. 507 inflatedRect = inflateRect(inflatedRect, size, buttonMargins()); 493 508 } 494 495 // Now inflate it to account for the shadow.496 inflatedRect = inflateRect(inflatedRect, size, buttonMargins());497 } 498 [button drawWithFrame:NSRect(inflatedRect) inView:o->canvas()->view()->getDocumentView()];499 [button setControlView: nil];500 } 501 502 } 509 510 [button drawWithFrame:NSRect(inflatedRect) inView:o->canvas()->view()->getDocumentView()]; 511 [button setControlView: nil]; 512 } 513 514 return hasBorder || hasBackground; 515 } 516 517 }
Note:
See TracChangeset
for help on using the changeset viewer.