| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 typedef int NSInteger; | 51 typedef int NSInteger; |
| 52 typedef unsigned NSUInteger; | 52 typedef unsigned NSUInteger; |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 using std::min; | 55 using std::min; |
| 56 | 56 |
| 57 // The methods in this file are specific to the Mac OS X platform. | 57 // The methods in this file are specific to the Mac OS X platform. |
| 58 | 58 |
| 59 // FIXME: The platform-independent code in this class should be factored out and
merged with RenderThemeSafari. | 59 // FIXME: The platform-independent code in this class should be factored out and
merged with RenderThemeSafari. |
| 60 | 60 |
| 61 | |
| 62 @interface WebCoreRenderThemeNotificationObserver : NSObject | 61 @interface WebCoreRenderThemeNotificationObserver : NSObject |
| 63 { | 62 { |
| 64 WebCore::RenderTheme *_theme; | 63 WebCore::RenderTheme *_theme; |
| 65 } | 64 } |
| 66 | 65 |
| 67 - (id)initWithTheme:(WebCore::RenderTheme *)theme; | 66 - (id)initWithTheme:(WebCore::RenderTheme *)theme; |
| 68 - (void)systemColorsDidChange:(NSNotification *)notification; | 67 - (void)systemColorsDidChange:(NSNotification *)notification; |
| 69 | 68 |
| 70 @end | 69 @end |
| 71 | 70 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 enum { | 100 enum { |
| 102 topPadding, | 101 topPadding, |
| 103 rightPadding, | 102 rightPadding, |
| 104 bottomPadding, | 103 bottomPadding, |
| 105 leftPadding | 104 leftPadding |
| 106 }; | 105 }; |
| 107 | 106 |
| 108 // In our Mac port, we don't define PLATFORM(MAC) and thus don't pick up the | 107 // In our Mac port, we don't define PLATFORM(MAC) and thus don't pick up the |
| 109 // |operator NSRect()| on WebCore::IntRect and FloatRect. This substitues for th
at missing | 108 // |operator NSRect()| on WebCore::IntRect and FloatRect. This substitues for |
| 110 // conversion operator. | 109 // that missing conversion operator. |
| 111 NSRect IntRectToNSRect(const IntRect & rect) | 110 NSRect IntRectToNSRect(const IntRect & rect) |
| 112 { | 111 { |
| 113 return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); | 112 return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); |
| 114 } | 113 } |
| 115 | 114 |
| 116 NSRect FloatRectToNSRect(const FloatRect & rect) | 115 NSRect FloatRectToNSRect(const FloatRect & rect) |
| 117 { | 116 { |
| 118 return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); | 117 return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); |
| 119 } | 118 } |
| 120 | 119 |
| 121 IntRect NSRectToIntRect(const NSRect & rect) | 120 IntRect NSRectToIntRect(const NSRect & rect) |
| 122 { | 121 { |
| 123 return IntRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.heig
ht); | 122 return IntRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.heig
ht); |
| 124 } | 123 } |
| 125 | 124 |
| 125 |
| 126 RenderTheme* theme() | 126 RenderTheme* theme() |
| 127 { | 127 { |
| 128 static RenderThemeMac* macTheme = new RenderThemeMac; | 128 static RenderThemeMac* macTheme = new RenderThemeMac; |
| 129 return macTheme; | 129 return macTheme; |
| 130 } | 130 } |
| 131 | 131 |
| 132 RenderThemeMac::RenderThemeMac() | 132 RenderThemeMac::RenderThemeMac() |
| 133 : m_isSliderThumbHorizontalPressed(false) | 133 : m_isSliderThumbHorizontalPressed(false) |
| 134 , m_isSliderThumbVerticalPressed(false) | 134 , m_isSliderThumbVerticalPressed(false) |
| 135 , m_notificationObserver(AdoptNS, [[WebCoreRenderThemeNotificationObserver a
lloc] initWithTheme:this]) | 135 , m_notificationObserver(AdoptNS, [[WebCoreRenderThemeNotificationObserver a
lloc] initWithTheme:this]) |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 431 |
| 432 if (color.isValid()) | 432 if (color.isValid()) |
| 433 m_systemColorCache.set(cssValueId, color.rgb()); | 433 m_systemColorCache.set(cssValueId, color.rgb()); |
| 434 | 434 |
| 435 return color; | 435 return color; |
| 436 } | 436 } |
| 437 | 437 |
| 438 bool RenderThemeMac::isControlStyled(const RenderStyle* style, const BorderData&
border, | 438 bool RenderThemeMac::isControlStyled(const RenderStyle* style, const BorderData&
border, |
| 439 const FillLayer& background, const Color& b
ackgroundColor) const | 439 const FillLayer& background, const Color& b
ackgroundColor) const |
| 440 { | 440 { |
| 441 if (style->appearance() == TextFieldAppearance || style->appearance() == Tex
tAreaAppearance || style->appearance() == ListboxAppearance) | 441 if (style->appearance() == TextFieldPart || style->appearance() == TextAreaP
art || style->appearance() == ListboxPart) |
| 442 return style->border() != border; | 442 return style->border() != border; |
| 443 return RenderTheme::isControlStyled(style, border, background, backgroundCol
or); | 443 return RenderTheme::isControlStyled(style, border, background, backgroundCol
or); |
| 444 } | 444 } |
| 445 | 445 |
| 446 // TODO(port): Use the code from the old upstream version, before it was convert
ed to the new theme API in r37731. |
| 446 void RenderThemeMac::adjustRepaintRect(const RenderObject* o, IntRect& r) | 447 void RenderThemeMac::adjustRepaintRect(const RenderObject* o, IntRect& r) |
| 447 { | 448 { |
| 448 float zoomLevel = o->style()->effectiveZoom(); | 449 float zoomLevel = o->style()->effectiveZoom(); |
| 449 | 450 |
| 450 switch (o->style()->appearance()) { | 451 switch (o->style()->appearance()) { |
| 451 case CheckboxAppearance: { | 452 case CheckboxPart: { |
| 452 // Since we query the prototype cell, we need to update its state to
match. | 453 // Since we query the prototype cell, we need to update its state to
match. |
| 453 setCheckboxCellState(o, r); | 454 setCheckboxCellState(o, r); |
| 454 | 455 |
| 455 // We inflate the rect as needed to account for padding included in
the cell to accommodate the checkbox | 456 // We inflate the rect as needed to account for padding included in
the cell to accommodate the checkbox |
| 456 // shadow" and the check. We don't consider this part of the bounds
of the control in WebKit. | 457 // shadow" and the check. We don't consider this part of the bounds
of the control in WebKit. |
| 457 IntSize size = checkboxSizes()[[checkbox() controlSize]]; | 458 IntSize size = checkboxSizes()[[checkbox() controlSize]]; |
| 458 size.setHeight(size.height() * zoomLevel); | 459 size.setHeight(size.height() * zoomLevel); |
| 459 size.setWidth(size.width() * zoomLevel); | 460 size.setWidth(size.width() * zoomLevel); |
| 460 r = inflateRect(r, size, checkboxMargins(), zoomLevel); | 461 r = inflateRect(r, size, checkboxMargins(), zoomLevel); |
| 461 break; | 462 break; |
| 462 } | 463 } |
| 463 case RadioAppearance: { | 464 case RadioPart: { |
| 464 // Since we query the prototype cell, we need to update its state to
match. | 465 // Since we query the prototype cell, we need to update its state to
match. |
| 465 setRadioCellState(o, r); | 466 setRadioCellState(o, r); |
| 466 | 467 |
| 467 // We inflate the rect as needed to account for padding included in
the cell to accommodate the checkbox | 468 // We inflate the rect as needed to account for padding included in
the cell to accommodate the checkbox |
| 468 // shadow" and the check. We don't consider this part of the bounds
of the control in WebKit. | 469 // shadow" and the check. We don't consider this part of the bounds
of the control in WebKit. |
| 469 IntSize size = radioSizes()[[radio() controlSize]]; | 470 IntSize size = radioSizes()[[radio() controlSize]]; |
| 470 size.setHeight(size.height() * zoomLevel); | 471 size.setHeight(size.height() * zoomLevel); |
| 471 size.setWidth(size.width() * zoomLevel); | 472 size.setWidth(size.width() * zoomLevel); |
| 472 r = inflateRect(r, size, radioMargins(), zoomLevel); | 473 r = inflateRect(r, size, radioMargins(), zoomLevel); |
| 473 break; | 474 break; |
| 474 } | 475 } |
| 475 case PushButtonAppearance: | 476 case PushButtonPart: |
| 476 case DefaultButtonAppearance: | 477 case DefaultButtonPart: |
| 477 case ButtonAppearance: { | 478 case ButtonPart: { |
| 478 // Since we query the prototype cell, we need to update its state to
match. | 479 // Since we query the prototype cell, we need to update its state to
match. |
| 479 setButtonCellState(o, r); | 480 setButtonCellState(o, r); |
| 480 | 481 |
| 481 // We inflate the rect as needed to account for padding included in
the cell to accommodate the checkbox | 482 // We inflate the rect as needed to account for padding included in
the cell to accommodate the checkbox |
| 482 // shadow" and the check. We don't consider this part of the bounds
of the control in WebKit. | 483 // shadow" and the check. We don't consider this part of the bounds
of the control in WebKit. |
| 483 if ([button() bezelStyle] == NSRoundedBezelStyle) { | 484 if ([button() bezelStyle] == NSRoundedBezelStyle) { |
| 484 IntSize size = buttonSizes()[[button() controlSize]]; | 485 IntSize size = buttonSizes()[[button() controlSize]]; |
| 485 size.setHeight(size.height() * zoomLevel); | 486 size.setHeight(size.height() * zoomLevel); |
| 486 size.setWidth(r.width()); | 487 size.setWidth(r.width()); |
| 487 r = inflateRect(r, size, buttonMargins(), zoomLevel); | 488 r = inflateRect(r, size, buttonMargins(), zoomLevel); |
| 488 } | 489 } |
| 489 break; | 490 break; |
| 490 } | 491 } |
| 491 case MenulistAppearance: { | 492 case MenulistPart: { |
| 492 setPopupButtonCellState(o, r); | 493 setPopupButtonCellState(o, r); |
| 493 IntSize size = popupButtonSizes()[[popupButton() controlSize]]; | 494 IntSize size = popupButtonSizes()[[popupButton() controlSize]]; |
| 494 size.setHeight(size.height() * zoomLevel); | 495 size.setHeight(size.height() * zoomLevel); |
| 495 size.setWidth(r.width()); | 496 size.setWidth(r.width()); |
| 496 r = inflateRect(r, size, popupButtonMargins(), zoomLevel); | 497 r = inflateRect(r, size, popupButtonMargins(), zoomLevel); |
| 497 break; | 498 break; |
| 498 } | 499 } |
| 499 default: | 500 default: |
| 500 break; | 501 break; |
| 501 } | 502 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 } | 553 } |
| 553 | 554 |
| 554 void RenderThemeMac::updatePressedState(NSCell* cell, const RenderObject* o) | 555 void RenderThemeMac::updatePressedState(NSCell* cell, const RenderObject* o) |
| 555 { | 556 { |
| 556 bool oldPressed = [cell isHighlighted]; | 557 bool oldPressed = [cell isHighlighted]; |
| 557 bool pressed = (o->element() && o->element()->active()); | 558 bool pressed = (o->element() && o->element()->active()); |
| 558 if (pressed != oldPressed) | 559 if (pressed != oldPressed) |
| 559 [cell setHighlighted:pressed]; | 560 [cell setHighlighted:pressed]; |
| 560 } | 561 } |
| 561 | 562 |
| 563 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 562 int RenderThemeMac::baselinePosition(const RenderObject* o) const | 564 int RenderThemeMac::baselinePosition(const RenderObject* o) const |
| 563 { | 565 { |
| 564 if (o->style()->appearance() == CheckboxAppearance || o->style()->appearance
() == RadioAppearance) | 566 if (o->style()->appearance() == CheckboxPart || o->style()->appearance() ==
RadioPart) |
| 565 return o->marginTop() + o->height() - 2 * o->style()->effectiveZoom(); /
/ The baseline is 2px up from the bottom of the checkbox/radio in AppKit. | 567 return o->marginTop() + o->height() - 2 * o->style()->effectiveZoom(); /
/ The baseline is 2px up from the bottom of the checkbox/radio in AppKit. |
| 566 return RenderTheme::baselinePosition(o); | 568 return RenderTheme::baselinePosition(o); |
| 567 } | 569 } |
| 568 | 570 |
| 569 bool RenderThemeMac::controlSupportsTints(const RenderObject* o) const | 571 bool RenderThemeMac::controlSupportsTints(const RenderObject* o) const |
| 570 { | 572 { |
| 571 // An alternate way to implement this would be to get the appropriate cell o
bject | 573 // An alternate way to implement this would be to get the appropriate cell o
bject |
| 572 // and call the private _needRedrawOnWindowChangedKeyState method. An advant
age of | 574 // and call the private _needRedrawOnWindowChangedKeyState method. An advant
age of |
| 573 // that would be that we would match AppKit behavior more closely, but a dis
advantage | 575 // that would be that we would match AppKit behavior more closely, but a dis
advantage |
| 574 // would be that we would rely on an AppKit SPI method. | 576 // would be that we would rely on an AppKit SPI method. |
| 575 | 577 |
| 576 if (!isEnabled(o)) | 578 if (!isEnabled(o)) |
| 577 return false; | 579 return false; |
| 578 | 580 |
| 579 // Checkboxes only have tint when checked. | 581 // Checkboxes only have tint when checked. |
| 580 if (o->style()->appearance() == CheckboxAppearance) | 582 if (o->style()->appearance() == CheckboxPart) |
| 581 return isChecked(o); | 583 return isChecked(o); |
| 582 | 584 |
| 583 // For now assume other controls have tint if enabled. | 585 // For now assume other controls have tint if enabled. |
| 584 return true; | 586 return true; |
| 585 } | 587 } |
| 586 | 588 |
| 587 NSControlSize RenderThemeMac::controlSizeForFont(RenderStyle* style) const | 589 NSControlSize RenderThemeMac::controlSizeForFont(RenderStyle* style) const |
| 588 { | 590 { |
| 589 int fontSize = style->fontSize(); | 591 int fontSize = style->fontSize(); |
| 590 if (fontSize >= 16) | 592 if (fontSize >= 16) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 NSControlSize RenderThemeMac::controlSizeForSystemFont(RenderStyle* style) const | 660 NSControlSize RenderThemeMac::controlSizeForSystemFont(RenderStyle* style) const |
| 659 { | 661 { |
| 660 int fontSize = style->fontSize(); | 662 int fontSize = style->fontSize(); |
| 661 if (fontSize >= [NSFont systemFontSizeForControlSize:NSRegularControlSize]) | 663 if (fontSize >= [NSFont systemFontSizeForControlSize:NSRegularControlSize]) |
| 662 return NSRegularControlSize; | 664 return NSRegularControlSize; |
| 663 if (fontSize >= [NSFont systemFontSizeForControlSize:NSSmallControlSize]) | 665 if (fontSize >= [NSFont systemFontSizeForControlSize:NSSmallControlSize]) |
| 664 return NSSmallControlSize; | 666 return NSSmallControlSize; |
| 665 return NSMiniControlSize; | 667 return NSMiniControlSize; |
| 666 } | 668 } |
| 667 | 669 |
| 670 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 668 bool RenderThemeMac::paintCheckbox(RenderObject* o, const RenderObject::PaintInf
o& paintInfo, const IntRect& r) | 671 bool RenderThemeMac::paintCheckbox(RenderObject* o, const RenderObject::PaintInf
o& paintInfo, const IntRect& r) |
| 669 { | 672 { |
| 670 // Determine the width and height needed for the control and prepare the cel
l for painting. | 673 // Determine the width and height needed for the control and prepare the cel
l for painting. |
| 671 setCheckboxCellState(o, r); | 674 setCheckboxCellState(o, r); |
| 672 | 675 |
| 673 paintInfo.context->save(); | 676 paintInfo.context->save(); |
| 674 | 677 |
| 675 float zoomLevel = o->style()->effectiveZoom(); | 678 float zoomLevel = o->style()->effectiveZoom(); |
| 676 | 679 |
| 677 // We inflate the rect as needed to account for padding included in the cell
to accommodate the checkbox | 680 // We inflate the rect as needed to account for padding included in the cell
to accommodate the checkbox |
| 678 // shadow" and the check. We don't consider this part of the bounds of the
control in WebKit. | 681 // shadow" and the check. We don't consider this part of the bounds of the
control in WebKit. |
| 679 NSButtonCell* checkbox = this->checkbox(); | 682 NSButtonCell* checkbox = this->checkbox(); |
| 680 IntSize size = checkboxSizes()[[checkbox controlSize]]; | 683 IntSize size = checkboxSizes()[[checkbox controlSize]]; |
| 681 size.setWidth(size.width() * zoomLevel); | 684 size.setWidth(size.width() * zoomLevel); |
| 682 size.setHeight(size.height() * zoomLevel); | 685 size.setHeight(size.height() * zoomLevel); |
| 683 IntRect inflatedRect = inflateRect(r, size, checkboxMargins(), zoomLevel); | 686 IntRect inflatedRect = inflateRect(r, size, checkboxMargins(), zoomLevel); |
| 684 | 687 |
| 685 if (zoomLevel != 1.0f) { | 688 if (zoomLevel != 1.0f) { |
| 686 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); | 689 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); |
| 687 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); | 690 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); |
| 688 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); | 691 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); |
| 689 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 692 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 690 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); | 693 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); |
| 691 } | 694 } |
| 692 | 695 |
| 693 #if 0 | 696 [checkbox drawWithFrame:NSRect(IntRectToNSRect(inflatedRect)) inView:nil]; |
| 694 [checkbox drawWithFrame:NSRect(IntRectToNSRect(inflatedRect)) inView:o->view
()->frameView()->documentView()]; | |
| 695 #endif | |
| 696 [checkbox setControlView:nil]; | 697 [checkbox setControlView:nil]; |
| 697 | 698 |
| 698 paintInfo.context->restore(); | 699 paintInfo.context->restore(); |
| 699 | 700 |
| 700 return false; | 701 return false; |
| 701 } | 702 } |
| 702 | 703 |
| 704 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 703 const IntSize* RenderThemeMac::checkboxSizes() const | 705 const IntSize* RenderThemeMac::checkboxSizes() const |
| 704 { | 706 { |
| 705 static const IntSize sizes[3] = { IntSize(14, 14), IntSize(12, 12), IntSize(
10, 10) }; | 707 static const IntSize sizes[3] = { IntSize(14, 14), IntSize(12, 12), IntSize(
10, 10) }; |
| 706 return sizes; | 708 return sizes; |
| 707 } | 709 } |
| 708 | 710 |
| 711 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 709 const int* RenderThemeMac::checkboxMargins() const | 712 const int* RenderThemeMac::checkboxMargins() const |
| 710 { | 713 { |
| 711 static const int margins[3][4] = | 714 static const int margins[3][4] = |
| 712 { | 715 { |
| 713 { 3, 4, 4, 2 }, | 716 { 3, 4, 4, 2 }, |
| 714 { 4, 3, 3, 3 }, | 717 { 4, 3, 3, 3 }, |
| 715 { 4, 3, 3, 3 }, | 718 { 4, 3, 3, 3 }, |
| 716 }; | 719 }; |
| 717 return margins[[checkbox() controlSize]]; | 720 return margins[[checkbox() controlSize]]; |
| 718 } | 721 } |
| 719 | 722 |
| 723 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 720 void RenderThemeMac::setCheckboxCellState(const RenderObject* o, const IntRect&
r) | 724 void RenderThemeMac::setCheckboxCellState(const RenderObject* o, const IntRect&
r) |
| 721 { | 725 { |
| 722 NSButtonCell* checkbox = this->checkbox(); | 726 NSButtonCell* checkbox = this->checkbox(); |
| 723 | 727 |
| 724 // Set the control size based off the rectangle we're painting into. | 728 // Set the control size based off the rectangle we're painting into. |
| 725 setControlSize(checkbox, checkboxSizes(), r.size(), o->style()->effectiveZoo
m()); | 729 setControlSize(checkbox, checkboxSizes(), r.size(), o->style()->effectiveZoo
m()); |
| 726 | 730 |
| 727 // Update the various states we respond to. | 731 // Update the various states we respond to. |
| 728 updateCheckedState(checkbox, o); | 732 updateCheckedState(checkbox, o); |
| 729 updateEnabledState(checkbox, o); | 733 updateEnabledState(checkbox, o); |
| 730 updatePressedState(checkbox, o); | 734 updatePressedState(checkbox, o); |
| 731 updateFocusedState(checkbox, o); | 735 updateFocusedState(checkbox, o); |
| 732 } | 736 } |
| 733 | 737 |
| 738 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 734 void RenderThemeMac::setCheckboxSize(RenderStyle* style) const | 739 void RenderThemeMac::setCheckboxSize(RenderStyle* style) const |
| 735 { | 740 { |
| 736 // If the width and height are both specified, then we have nothing to do. | 741 // If the width and height are both specified, then we have nothing to do. |
| 737 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | 742 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) |
| 738 return; | 743 return; |
| 739 | 744 |
| 740 // Use the font size to determine the intrinsic width of the control. | 745 // Use the font size to determine the intrinsic width of the control. |
| 741 setSizeFromFont(style, checkboxSizes()); | 746 setSizeFromFont(style, checkboxSizes()); |
| 742 } | 747 } |
| 743 | 748 |
| 749 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 744 bool RenderThemeMac::paintRadio(RenderObject* o, const RenderObject::PaintInfo&
paintInfo, const IntRect& r) | 750 bool RenderThemeMac::paintRadio(RenderObject* o, const RenderObject::PaintInfo&
paintInfo, const IntRect& r) |
| 745 { | 751 { |
| 746 // Determine the width and height needed for the control and prepare the cel
l for painting. | 752 // Determine the width and height needed for the control and prepare the cel
l for painting. |
| 747 setRadioCellState(o, r); | 753 setRadioCellState(o, r); |
| 748 | 754 |
| 749 paintInfo.context->save(); | 755 paintInfo.context->save(); |
| 750 | 756 |
| 751 float zoomLevel = o->style()->effectiveZoom(); | 757 float zoomLevel = o->style()->effectiveZoom(); |
| 752 | 758 |
| 753 // We inflate the rect as needed to account for padding included in the cell
to accommodate the checkbox | 759 // We inflate the rect as needed to account for padding included in the cell
to accommodate the checkbox |
| 754 // shadow" and the check. We don't consider this part of the bounds of the
control in WebKit. | 760 // shadow" and the check. We don't consider this part of the bounds of the
control in WebKit. |
| 755 NSButtonCell* radio = this->radio(); | 761 NSButtonCell* radio = this->radio(); |
| 756 IntSize size = radioSizes()[[radio controlSize]]; | 762 IntSize size = radioSizes()[[radio controlSize]]; |
| 757 size.setWidth(size.width() * zoomLevel); | 763 size.setWidth(size.width() * zoomLevel); |
| 758 size.setHeight(size.height() * zoomLevel); | 764 size.setHeight(size.height() * zoomLevel); |
| 759 IntRect inflatedRect = inflateRect(r, size, radioMargins(), zoomLevel); | 765 IntRect inflatedRect = inflateRect(r, size, radioMargins(), zoomLevel); |
| 760 | 766 |
| 761 if (zoomLevel != 1.0f) { | 767 if (zoomLevel != 1.0f) { |
| 762 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); | 768 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); |
| 763 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); | 769 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); |
| 764 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); | 770 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); |
| 765 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 771 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 766 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); | 772 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); |
| 767 } | 773 } |
| 768 | 774 |
| 769 #if 0 | 775 [radio drawWithFrame:NSRect(IntRectToNSRect(inflatedRect)) inView:nil]; |
| 770 NSView* view = o->view()->frameView()->documentView(); | |
| 771 #endif | |
| 772 NSView* view = nil; | |
| 773 [radio drawWithFrame:NSRect(IntRectToNSRect(inflatedRect)) inView:view]; | |
| 774 [radio setControlView:nil]; | 776 [radio setControlView:nil]; |
| 775 | 777 |
| 776 paintInfo.context->restore(); | 778 paintInfo.context->restore(); |
| 777 | 779 |
| 778 return false; | 780 return false; |
| 779 } | 781 } |
| 780 | 782 |
| 783 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 781 const IntSize* RenderThemeMac::radioSizes() const | 784 const IntSize* RenderThemeMac::radioSizes() const |
| 782 { | 785 { |
| 783 static const IntSize sizes[3] = { IntSize(14, 15), IntSize(12, 13), IntSize(
10, 10) }; | 786 static const IntSize sizes[3] = { IntSize(14, 15), IntSize(12, 13), IntSize(
10, 10) }; |
| 784 return sizes; | 787 return sizes; |
| 785 } | 788 } |
| 786 | 789 |
| 790 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 787 const int* RenderThemeMac::radioMargins() const | 791 const int* RenderThemeMac::radioMargins() const |
| 788 { | 792 { |
| 789 static const int margins[3][4] = | 793 static const int margins[3][4] = |
| 790 { | 794 { |
| 791 { 2, 2, 4, 2 }, | 795 { 2, 2, 4, 2 }, |
| 792 { 3, 2, 3, 2 }, | 796 { 3, 2, 3, 2 }, |
| 793 { 1, 0, 2, 0 }, | 797 { 1, 0, 2, 0 }, |
| 794 }; | 798 }; |
| 795 return margins[[radio() controlSize]]; | 799 return margins[[radio() controlSize]]; |
| 796 } | 800 } |
| 797 | 801 |
| 802 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 798 void RenderThemeMac::setRadioCellState(const RenderObject* o, const IntRect& r) | 803 void RenderThemeMac::setRadioCellState(const RenderObject* o, const IntRect& r) |
| 799 { | 804 { |
| 800 NSButtonCell* radio = this->radio(); | 805 NSButtonCell* radio = this->radio(); |
| 801 | 806 |
| 802 // Set the control size based off the rectangle we're painting into. | 807 // Set the control size based off the rectangle we're painting into. |
| 803 setControlSize(radio, radioSizes(), r.size(), o->style()->effectiveZoom()); | 808 setControlSize(radio, radioSizes(), r.size(), o->style()->effectiveZoom()); |
| 804 | 809 |
| 805 // Update the various states we respond to. | 810 // Update the various states we respond to. |
| 806 updateCheckedState(radio, o); | 811 updateCheckedState(radio, o); |
| 807 updateEnabledState(radio, o); | 812 updateEnabledState(radio, o); |
| 808 updatePressedState(radio, o); | 813 updatePressedState(radio, o); |
| 809 updateFocusedState(radio, o); | 814 updateFocusedState(radio, o); |
| 810 } | 815 } |
| 811 | 816 |
| 812 | 817 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 813 void RenderThemeMac::setRadioSize(RenderStyle* style) const | 818 void RenderThemeMac::setRadioSize(RenderStyle* style) const |
| 814 { | 819 { |
| 815 // If the width and height are both specified, then we have nothing to do. | 820 // If the width and height are both specified, then we have nothing to do. |
| 816 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | 821 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) |
| 817 return; | 822 return; |
| 818 | 823 |
| 819 // Use the font size to determine the intrinsic width of the control. | 824 // Use the font size to determine the intrinsic width of the control. |
| 820 setSizeFromFont(style, radioSizes()); | 825 setSizeFromFont(style, radioSizes()); |
| 821 } | 826 } |
| 822 | 827 |
| 828 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 823 void RenderThemeMac::setButtonPaddingFromControlSize(RenderStyle* style, NSContr
olSize size) const | 829 void RenderThemeMac::setButtonPaddingFromControlSize(RenderStyle* style, NSContr
olSize size) const |
| 824 { | 830 { |
| 825 // Just use 8px. AppKit wants to use 11px for mini buttons, but that paddin
g is just too large | 831 // Just use 8px. AppKit wants to use 11px for mini buttons, but that paddin
g is just too large |
| 826 // for real-world Web sites (creating a huge necessary minimum width for but
tons whose space is | 832 // for real-world Web sites (creating a huge necessary minimum width for but
tons whose space is |
| 827 // by definition constrained, since we select mini only for small cramped en
vironments. | 833 // by definition constrained, since we select mini only for small cramped en
vironments. |
| 828 // This also guarantees the HTML4 <button> will match our rendering by defau
lt, since we're using a consistent | 834 // This also guarantees the HTML4 <button> will match our rendering by defau
lt, since we're using a consistent |
| 829 // padding. | 835 // padding. |
| 830 const int padding = 8 * style->effectiveZoom(); | 836 const int padding = 8 * style->effectiveZoom(); |
| 831 style->setPaddingLeft(Length(padding, Fixed)); | 837 style->setPaddingLeft(Length(padding, Fixed)); |
| 832 style->setPaddingRight(Length(padding, Fixed)); | 838 style->setPaddingRight(Length(padding, Fixed)); |
| 833 style->setPaddingTop(Length(0, Fixed)); | 839 style->setPaddingTop(Length(0, Fixed)); |
| 834 style->setPaddingBottom(Length(0, Fixed)); | 840 style->setPaddingBottom(Length(0, Fixed)); |
| 835 } | 841 } |
| 836 | 842 |
| 843 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 837 void RenderThemeMac::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle*
style, Element* e) const | 844 void RenderThemeMac::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle*
style, Element* e) const |
| 838 { | 845 { |
| 839 // There are three appearance constants for buttons. | 846 // There are three appearance constants for buttons. |
| 840 // (1) Push-button is the constant for the default Aqua system button. Push
buttons will not scale vertically and will not allow | 847 // (1) Push-button is the constant for the default Aqua system button. Push
buttons will not scale vertically and will not allow |
| 841 // custom fonts or colors. <input>s use this constant. This button will al
low custom colors and font weights/variants but won't | 848 // custom fonts or colors. <input>s use this constant. This button will al
low custom colors and font weights/variants but won't |
| 842 // scale vertically. | 849 // scale vertically. |
| 843 // (2) square-button is the constant for the square button. This button wil
l allow custom fonts and colors and will scale vertically. | 850 // (2) square-button is the constant for the square button. This button wil
l allow custom fonts and colors and will scale vertically. |
| 844 // (3) Button is the constant that means "pick the best button as appropriat
e." <button>s use this constant. This button will | 851 // (3) Button is the constant that means "pick the best button as appropriat
e." <button>s use this constant. This button will |
| 845 // also scale vertically and allow custom fonts and colors. It will attempt
to use Aqua if possible and will make this determination | 852 // also scale vertically and allow custom fonts and colors. It will attempt
to use Aqua if possible and will make this determination |
| 846 // solely on the rectangle of the control. | 853 // solely on the rectangle of the control. |
| 847 | 854 |
| 848 // Determine our control size based off our font. | 855 // Determine our control size based off our font. |
| 849 NSControlSize controlSize = controlSizeForFont(style); | 856 NSControlSize controlSize = controlSizeForFont(style); |
| 850 | 857 |
| 851 if (style->appearance() == PushButtonAppearance) { | 858 if (style->appearance() == PushButtonPart) { |
| 852 // Ditch the border. | 859 // Ditch the border. |
| 853 style->resetBorder(); | 860 style->resetBorder(); |
| 854 | 861 |
| 855 // Height is locked to auto. | 862 // Height is locked to auto. |
| 856 style->setHeight(Length(Auto)); | 863 style->setHeight(Length(Auto)); |
| 857 | 864 |
| 858 // White-space is locked to pre | 865 // White-space is locked to pre |
| 859 style->setWhiteSpace(PRE); | 866 style->setWhiteSpace(PRE); |
| 860 | 867 |
| 861 // Set the button's vertical size. | 868 // Set the button's vertical size. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 873 style->setMinHeight(Length(static_cast<int>(15 * style->effectiveZoom())
, Fixed)); | 880 style->setMinHeight(Length(static_cast<int>(15 * style->effectiveZoom())
, Fixed)); |
| 874 | 881 |
| 875 // Reset the top and bottom borders. | 882 // Reset the top and bottom borders. |
| 876 style->resetBorderTop(); | 883 style->resetBorderTop(); |
| 877 style->resetBorderBottom(); | 884 style->resetBorderBottom(); |
| 878 } | 885 } |
| 879 | 886 |
| 880 style->setBoxShadow(0); | 887 style->setBoxShadow(0); |
| 881 } | 888 } |
| 882 | 889 |
| 890 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 883 const IntSize* RenderThemeMac::buttonSizes() const | 891 const IntSize* RenderThemeMac::buttonSizes() const |
| 884 { | 892 { |
| 885 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0,
15) }; | 893 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0,
15) }; |
| 886 return sizes; | 894 return sizes; |
| 887 } | 895 } |
| 888 | 896 |
| 897 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 889 const int* RenderThemeMac::buttonMargins() const | 898 const int* RenderThemeMac::buttonMargins() const |
| 890 { | 899 { |
| 891 static const int margins[3][4] = | 900 static const int margins[3][4] = |
| 892 { | 901 { |
| 893 { 4, 6, 7, 6 }, | 902 { 4, 6, 7, 6 }, |
| 894 { 4, 5, 6, 5 }, | 903 { 4, 5, 6, 5 }, |
| 895 { 0, 1, 1, 1 }, | 904 { 0, 1, 1, 1 }, |
| 896 }; | 905 }; |
| 897 return margins[[button() controlSize]]; | 906 return margins[[button() controlSize]]; |
| 898 } | 907 } |
| 899 | 908 |
| 909 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 900 void RenderThemeMac::setButtonSize(RenderStyle* style) const | 910 void RenderThemeMac::setButtonSize(RenderStyle* style) const |
| 901 { | 911 { |
| 902 // If the width and height are both specified, then we have nothing to do. | 912 // If the width and height are both specified, then we have nothing to do. |
| 903 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | 913 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) |
| 904 return; | 914 return; |
| 905 | 915 |
| 906 // Use the font size to determine the intrinsic width of the control. | 916 // Use the font size to determine the intrinsic width of the control. |
| 907 setSizeFromFont(style, buttonSizes()); | 917 setSizeFromFont(style, buttonSizes()); |
| 908 } | 918 } |
| 909 | 919 |
| 920 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 910 void RenderThemeMac::setButtonCellState(const RenderObject* o, const IntRect& r) | 921 void RenderThemeMac::setButtonCellState(const RenderObject* o, const IntRect& r) |
| 911 { | 922 { |
| 912 NSButtonCell* button = this->button(); | 923 NSButtonCell* button = this->button(); |
| 913 | 924 |
| 914 // Set the control size based off the rectangle we're painting into. | 925 // Set the control size based off the rectangle we're painting into. |
| 915 if (o->style()->appearance() == SquareButtonAppearance || | 926 if (o->style()->appearance() == SquareButtonPart || |
| 916 r.height() > buttonSizes()[NSRegularControlSize].height() * o->style()->
effectiveZoom()) { | 927 r.height() > buttonSizes()[NSRegularControlSize].height() * o->style()->
effectiveZoom()) { |
| 917 // Use the square button | 928 // Use the square button |
| 918 if ([button bezelStyle] != NSShadowlessSquareBezelStyle) | 929 if ([button bezelStyle] != NSShadowlessSquareBezelStyle) |
| 919 [button setBezelStyle:NSShadowlessSquareBezelStyle]; | 930 [button setBezelStyle:NSShadowlessSquareBezelStyle]; |
| 920 } else if ([button bezelStyle] != NSRoundedBezelStyle) | 931 } else if ([button bezelStyle] != NSRoundedBezelStyle) |
| 921 [button setBezelStyle:NSRoundedBezelStyle]; | 932 [button setBezelStyle:NSRoundedBezelStyle]; |
| 922 | 933 |
| 923 setControlSize(button, buttonSizes(), r.size(), o->style()->effectiveZoom())
; | 934 setControlSize(button, buttonSizes(), r.size(), o->style()->effectiveZoom())
; |
| 924 | 935 |
| 925 #if 0 | 936 NSWindow *window = [nil window]; |
| 926 NSWindow *window = [o->view()->frameView()->documentView() window]; | |
| 927 BOOL isDefaultButton = (isDefault(o) && [window isKeyWindow]); | 937 BOOL isDefaultButton = (isDefault(o) && [window isKeyWindow]); |
| 928 [button setKeyEquivalent:(isDefaultButton ? @"\r" : @"")]; | 938 [button setKeyEquivalent:(isDefaultButton ? @"\r" : @"")]; |
| 929 #endif | |
| 930 | 939 |
| 931 // Update the various states we respond to. | 940 // Update the various states we respond to. |
| 932 updateCheckedState(button, o); | 941 updateCheckedState(button, o); |
| 933 updateEnabledState(button, o); | 942 updateEnabledState(button, o); |
| 934 updatePressedState(button, o); | 943 updatePressedState(button, o); |
| 935 updateFocusedState(button, o); | 944 updateFocusedState(button, o); |
| 936 } | 945 } |
| 937 | 946 |
| 947 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 938 bool RenderThemeMac::paintButton(RenderObject* o, const RenderObject::PaintInfo&
paintInfo, const IntRect& r) | 948 bool RenderThemeMac::paintButton(RenderObject* o, const RenderObject::PaintInfo&
paintInfo, const IntRect& r) |
| 939 { | 949 { |
| 940 NSButtonCell* button = this->button(); | 950 NSButtonCell* button = this->button(); |
| 941 LocalCurrentGraphicsContext localContext(paintInfo.context); | 951 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 942 | 952 |
| 943 // Determine the width and height needed for the control and prepare the cel
l for painting. | 953 // Determine the width and height needed for the control and prepare the cel
l for painting. |
| 944 setButtonCellState(o, r); | 954 setButtonCellState(o, r); |
| 945 | 955 |
| 946 paintInfo.context->save(); | 956 paintInfo.context->save(); |
| 947 | 957 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 964 | 974 |
| 965 if (zoomLevel != 1.0f) { | 975 if (zoomLevel != 1.0f) { |
| 966 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); | 976 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); |
| 967 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); | 977 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); |
| 968 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); | 978 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); |
| 969 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 979 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 970 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); | 980 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); |
| 971 } | 981 } |
| 972 } | 982 } |
| 973 | 983 |
| 974 #if 0 | |
| 975 NSView *view = o->view()->frameView()->documentView(); | |
| 976 #endif | |
| 977 NSView *view = nil; | 984 NSView *view = nil; |
| 978 NSWindow *window = [view window]; | 985 NSWindow *window = [view window]; |
| 979 NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell]; | 986 NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell]; |
| 980 | 987 |
| 981 if (isDefault(o) && [window isKeyWindow]) { | 988 if (isDefault(o) && [window isKeyWindow]) { |
| 982 [window setDefaultButtonCell:button]; | 989 [window setDefaultButtonCell:button]; |
| 983 wkAdvanceDefaultButtonPulseAnimation(button); | 990 wkAdvanceDefaultButtonPulseAnimation(button); |
| 984 } else if ([previousDefaultButtonCell isEqual:button]) | 991 } else if ([previousDefaultButtonCell isEqual:button]) |
| 985 [window setDefaultButtonCell:nil]; | 992 [window setDefaultButtonCell:nil]; |
| 986 | 993 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 #endif | 1087 #endif |
| 1081 | 1088 |
| 1082 if (zoomLevel != 1.0f) { | 1089 if (zoomLevel != 1.0f) { |
| 1083 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); | 1090 inflatedRect.setWidth(inflatedRect.width() / zoomLevel); |
| 1084 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); | 1091 inflatedRect.setHeight(inflatedRect.height() / zoomLevel); |
| 1085 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); | 1092 paintInfo.context->translate(inflatedRect.x(), inflatedRect.y()); |
| 1086 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1093 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1087 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); | 1094 paintInfo.context->translate(-inflatedRect.x(), -inflatedRect.y()); |
| 1088 } | 1095 } |
| 1089 | 1096 |
| 1090 #if 0 | 1097 [popupButton drawWithFrame:IntRectToNSRect(inflatedRect) inView:nil]; |
| 1091 NSView* view = o->view()->frameView()->documentView(); | |
| 1092 #endif | |
| 1093 NSView* view = nil; | |
| 1094 [popupButton drawWithFrame:IntRectToNSRect(inflatedRect) inView:view]; | |
| 1095 [popupButton setControlView:nil]; | 1098 [popupButton setControlView:nil]; |
| 1096 | 1099 |
| 1097 paintInfo.context->restore(); | 1100 paintInfo.context->restore(); |
| 1098 | 1101 |
| 1099 return false; | 1102 return false; |
| 1100 } | 1103 } |
| 1101 | 1104 |
| 1102 const float baseFontSize = 11.0f; | 1105 const float baseFontSize = 11.0f; |
| 1103 const float baseArrowHeight = 4.0f; | 1106 const float baseArrowHeight = 4.0f; |
| 1104 const float baseArrowWidth = 5.0f; | 1107 const float baseArrowWidth = 5.0f; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 IntPoint(leftEdgeOfSeparator, bounds.bottom())); | 1273 IntPoint(leftEdgeOfSeparator, bounds.bottom())); |
| 1271 | 1274 |
| 1272 paintInfo.context->setStrokeColor(rightSeparatorColor); | 1275 paintInfo.context->setStrokeColor(rightSeparatorColor); |
| 1273 paintInfo.context->drawLine(IntPoint(leftEdgeOfSeparator + separatorSpace, b
ounds.y()), | 1276 paintInfo.context->drawLine(IntPoint(leftEdgeOfSeparator + separatorSpace, b
ounds.y()), |
| 1274 IntPoint(leftEdgeOfSeparator + separatorSpace, b
ounds.bottom())); | 1277 IntPoint(leftEdgeOfSeparator + separatorSpace, b
ounds.bottom())); |
| 1275 | 1278 |
| 1276 paintInfo.context->restore(); | 1279 paintInfo.context->restore(); |
| 1277 return false; | 1280 return false; |
| 1278 } | 1281 } |
| 1279 | 1282 |
| 1283 static const IntSize* menuListButtonSizes() |
| 1284 { |
| 1285 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0,
15) }; |
| 1286 return sizes; |
| 1287 } |
| 1288 |
| 1280 void RenderThemeMac::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle
* style, Element* e) const | 1289 void RenderThemeMac::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle
* style, Element* e) const |
| 1281 { | 1290 { |
| 1282 NSControlSize controlSize = controlSizeForFont(style); | 1291 NSControlSize controlSize = controlSizeForFont(style); |
| 1283 | 1292 |
| 1284 style->resetBorder(); | 1293 style->resetBorder(); |
| 1285 style->resetPadding(); | 1294 style->resetPadding(); |
| 1286 | 1295 |
| 1287 // Height is locked to auto. | 1296 // Height is locked to auto. |
| 1288 style->setHeight(Length(Auto)); | 1297 style->setHeight(Length(Auto)); |
| 1289 | 1298 |
| 1290 // White-space is locked to pre | 1299 // White-space is locked to pre |
| 1291 style->setWhiteSpace(PRE); | 1300 style->setWhiteSpace(PRE); |
| 1292 | 1301 |
| 1293 // Set the foreground color to black or gray when we have the aqua look. | 1302 // Set the foreground color to black or gray when we have the aqua look. |
| 1294 // Cast to RGB32 is to work around a compiler bug. | 1303 // Cast to RGB32 is to work around a compiler bug. |
| 1295 style->setColor(e->isEnabled() ? static_cast<RGBA32>(Color::black) : Color::
darkGray); | 1304 style->setColor(e->isEnabled() ? static_cast<RGBA32>(Color::black) : Color::
darkGray); |
| 1296 | 1305 |
| 1297 // Set the button's vertical size. | 1306 // Set the button's vertical size. |
| 1298 setButtonSize(style); | 1307 setSizeFromFont(style, menuListButtonSizes()); |
| 1299 | 1308 |
| 1300 // Our font is locked to the appropriate system font size for the control.
To clarify, we first use the CSS-specified font to figure out | 1309 // Our font is locked to the appropriate system font size for the control.
To clarify, we first use the CSS-specified font to figure out |
| 1301 // a reasonable control size, but once that control size is determined, we t
hrow that font away and use the appropriate | 1310 // a reasonable control size, but once that control size is determined, we t
hrow that font away and use the appropriate |
| 1302 // system font for the control size instead. | 1311 // system font for the control size instead. |
| 1303 setFontFromControlSize(selector, style, controlSize); | 1312 setFontFromControlSize(selector, style, controlSize); |
| 1304 | 1313 |
| 1305 style->setBoxShadow(0); | 1314 style->setBoxShadow(0); |
| 1306 } | 1315 } |
| 1307 | 1316 |
| 1308 int RenderThemeMac::popupInternalPaddingLeft(RenderStyle* style) const | 1317 int RenderThemeMac::popupInternalPaddingLeft(RenderStyle* style) const |
| 1309 { | 1318 { |
| 1310 if (style->appearance() == MenulistAppearance) | 1319 if (style->appearance() == MenulistPart) |
| 1311 return popupButtonPadding(controlSizeForFont(style))[leftPadding] * styl
e->effectiveZoom(); | 1320 return popupButtonPadding(controlSizeForFont(style))[leftPadding] * styl
e->effectiveZoom(); |
| 1312 if (style->appearance() == MenulistButtonAppearance) | 1321 if (style->appearance() == MenulistButtonPart) |
| 1313 return styledPopupPaddingLeft * style->effectiveZoom(); | 1322 return styledPopupPaddingLeft * style->effectiveZoom(); |
| 1314 return 0; | 1323 return 0; |
| 1315 } | 1324 } |
| 1316 | 1325 |
| 1317 int RenderThemeMac::popupInternalPaddingRight(RenderStyle* style) const | 1326 int RenderThemeMac::popupInternalPaddingRight(RenderStyle* style) const |
| 1318 { | 1327 { |
| 1319 if (style->appearance() == MenulistAppearance) | 1328 if (style->appearance() == MenulistPart) |
| 1320 return popupButtonPadding(controlSizeForFont(style))[rightPadding] * sty
le->effectiveZoom(); | 1329 return popupButtonPadding(controlSizeForFont(style))[rightPadding] * sty
le->effectiveZoom(); |
| 1321 if (style->appearance() == MenulistButtonAppearance) { | 1330 if (style->appearance() == MenulistButtonPart) { |
| 1322 float fontScale = style->fontSize() / baseFontSize; | 1331 float fontScale = style->fontSize() / baseFontSize; |
| 1323 float arrowWidth = baseArrowWidth * fontScale; | 1332 float arrowWidth = baseArrowWidth * fontScale; |
| 1324 return static_cast<int>(ceilf(arrowWidth + (arrowPaddingLeft + arrowPadd
ingRight + paddingBeforeSeparator) * style->effectiveZoom())); | 1333 return static_cast<int>(ceilf(arrowWidth + (arrowPaddingLeft + arrowPadd
ingRight + paddingBeforeSeparator) * style->effectiveZoom())); |
| 1325 } | 1334 } |
| 1326 return 0; | 1335 return 0; |
| 1327 } | 1336 } |
| 1328 | 1337 |
| 1329 int RenderThemeMac::popupInternalPaddingTop(RenderStyle* style) const | 1338 int RenderThemeMac::popupInternalPaddingTop(RenderStyle* style) const |
| 1330 { | 1339 { |
| 1331 if (style->appearance() == MenulistAppearance) | 1340 if (style->appearance() == MenulistPart) |
| 1332 return popupButtonPadding(controlSizeForFont(style))[topPadding] * style
->effectiveZoom(); | 1341 return popupButtonPadding(controlSizeForFont(style))[topPadding] * style
->effectiveZoom(); |
| 1333 if (style->appearance() == MenulistButtonAppearance) | 1342 if (style->appearance() == MenulistButtonPart) |
| 1334 return styledPopupPaddingTop * style->effectiveZoom(); | 1343 return styledPopupPaddingTop * style->effectiveZoom(); |
| 1335 return 0; | 1344 return 0; |
| 1336 } | 1345 } |
| 1337 | 1346 |
| 1338 int RenderThemeMac::popupInternalPaddingBottom(RenderStyle* style) const | 1347 int RenderThemeMac::popupInternalPaddingBottom(RenderStyle* style) const |
| 1339 { | 1348 { |
| 1340 if (style->appearance() == MenulistAppearance) | 1349 if (style->appearance() == MenulistPart) |
| 1341 return popupButtonPadding(controlSizeForFont(style))[bottomPadding] * st
yle->effectiveZoom(); | 1350 return popupButtonPadding(controlSizeForFont(style))[bottomPadding] * st
yle->effectiveZoom(); |
| 1342 if (style->appearance() == MenulistButtonAppearance) | 1351 if (style->appearance() == MenulistButtonPart) |
| 1343 return styledPopupPaddingBottom * style->effectiveZoom(); | 1352 return styledPopupPaddingBottom * style->effectiveZoom(); |
| 1344 return 0; | 1353 return 0; |
| 1345 } | 1354 } |
| 1346 | 1355 |
| 1347 void RenderThemeMac::adjustMenuListButtonStyle(CSSStyleSelector* selector, Rende
rStyle* style, Element* e) const | 1356 void RenderThemeMac::adjustMenuListButtonStyle(CSSStyleSelector* selector, Rende
rStyle* style, Element* e) const |
| 1348 { | 1357 { |
| 1349 float fontScale = style->fontSize() / baseFontSize; | 1358 float fontScale = style->fontSize() / baseFontSize; |
| 1350 | 1359 |
| 1351 style->resetPadding(); | 1360 style->resetPadding(); |
| 1352 style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(ba
seBorderRadius + fontScale - 1))); // FIXME: Round up? | 1361 style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(ba
seBorderRadius + fontScale - 1))); // FIXME: Round up? |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 { | 1398 { |
| 1390 style->setBoxShadow(0); | 1399 style->setBoxShadow(0); |
| 1391 } | 1400 } |
| 1392 | 1401 |
| 1393 bool RenderThemeMac::paintSliderTrack(RenderObject* o, const RenderObject::Paint
Info& paintInfo, const IntRect& r) | 1402 bool RenderThemeMac::paintSliderTrack(RenderObject* o, const RenderObject::Paint
Info& paintInfo, const IntRect& r) |
| 1394 { | 1403 { |
| 1395 IntRect bounds = r; | 1404 IntRect bounds = r; |
| 1396 float zoomLevel = o->style()->effectiveZoom(); | 1405 float zoomLevel = o->style()->effectiveZoom(); |
| 1397 float zoomedTrackWidth = trackWidth * zoomLevel; | 1406 float zoomedTrackWidth = trackWidth * zoomLevel; |
| 1398 | 1407 |
| 1399 if (o->style()->appearance() == SliderHorizontalAppearance || o->style()->a
ppearance() == MediaSliderAppearance) { | 1408 if (o->style()->appearance() == SliderHorizontalPart || o->style()->appeara
nce() == MediaSliderPart) { |
| 1400 bounds.setHeight(zoomedTrackWidth); | 1409 bounds.setHeight(zoomedTrackWidth); |
| 1401 bounds.setY(r.y() + r.height() / 2 - zoomedTrackWidth / 2); | 1410 bounds.setY(r.y() + r.height() / 2 - zoomedTrackWidth / 2); |
| 1402 } else if (o->style()->appearance() == SliderVerticalAppearance) { | 1411 } else if (o->style()->appearance() == SliderVerticalPart) { |
| 1403 bounds.setWidth(zoomedTrackWidth); | 1412 bounds.setWidth(zoomedTrackWidth); |
| 1404 bounds.setX(r.x() + r.width() / 2 - zoomedTrackWidth / 2); | 1413 bounds.setX(r.x() + r.width() / 2 - zoomedTrackWidth / 2); |
| 1405 } | 1414 } |
| 1406 | 1415 |
| 1407 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1416 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1408 CGContextRef context = paintInfo.context->platformContext(); | 1417 CGContextRef context = paintInfo.context->platformContext(); |
| 1409 RetainPtr<CGColorSpaceRef> cspace(AdoptCF, CGColorSpaceCreateDeviceRGB()); | 1418 RetainPtr<CGColorSpaceRef> cspace(AdoptCF, CGColorSpaceCreateDeviceRGB()); |
| 1410 | 1419 |
| 1411 paintInfo.context->save(); | 1420 paintInfo.context->save(); |
| 1412 CGContextClipToRect(context, bounds); | 1421 CGContextClipToRect(context, bounds); |
| 1413 | 1422 |
| 1414 struct CGFunctionCallbacks mainCallbacks = { 0, TrackGradientInterpolate, NU
LL }; | 1423 struct CGFunctionCallbacks mainCallbacks = { 0, TrackGradientInterpolate, NU
LL }; |
| 1415 RetainPtr<CGFunctionRef> mainFunction(AdoptCF, CGFunctionCreate(NULL, 1, NUL
L, 4, NULL, &mainCallbacks)); | 1424 RetainPtr<CGFunctionRef> mainFunction(AdoptCF, CGFunctionCreate(NULL, 1, NUL
L, 4, NULL, &mainCallbacks)); |
| 1416 RetainPtr<CGShadingRef> mainShading; | 1425 RetainPtr<CGShadingRef> mainShading; |
| 1417 if (o->style()->appearance() == SliderVerticalAppearance) | 1426 if (o->style()->appearance() == SliderVerticalPart) |
| 1418 mainShading.adoptCF(CGShadingCreateAxial(cspace.get(), CGPointMake(bound
s.x(), bounds.bottom()), CGPointMake(bounds.right(), bounds.bottom()), mainFunc
tion.get(), false, false)); | 1427 mainShading.adoptCF(CGShadingCreateAxial(cspace.get(), CGPointMake(bound
s.x(), bounds.bottom()), CGPointMake(bounds.right(), bounds.bottom()), mainFunc
tion.get(), false, false)); |
| 1419 else | 1428 else |
| 1420 mainShading.adoptCF(CGShadingCreateAxial(cspace.get(), CGPointMake(bound
s.x(), bounds.y()), CGPointMake(bounds.x(), bounds.bottom()), mainFunction.get(
), false, false)); | 1429 mainShading.adoptCF(CGShadingCreateAxial(cspace.get(), CGPointMake(bound
s.x(), bounds.y()), CGPointMake(bounds.x(), bounds.bottom()), mainFunction.get(
), false, false)); |
| 1421 | 1430 |
| 1422 IntSize radius(trackRadius, trackRadius); | 1431 IntSize radius(trackRadius, trackRadius); |
| 1423 paintInfo.context->addRoundedRectClip(bounds, | 1432 paintInfo.context->addRoundedRectClip(bounds, |
| 1424 radius, radius, | 1433 radius, radius, |
| 1425 radius, radius); | 1434 radius, radius); |
| 1426 CGContextDrawShading(context, mainShading.get()); | 1435 CGContextDrawShading(context, mainShading.get()); |
| 1427 paintInfo.context->restore(); | 1436 paintInfo.context->restore(); |
| 1428 | 1437 |
| 1429 return false; | 1438 return false; |
| 1430 } | 1439 } |
| 1431 | 1440 |
| 1432 void RenderThemeMac::adjustSliderThumbStyle(CSSStyleSelector* selector, RenderSt
yle* style, Element* e) const | 1441 void RenderThemeMac::adjustSliderThumbStyle(CSSStyleSelector* selector, RenderSt
yle* style, Element* e) const |
| 1433 { | 1442 { |
| 1434 style->setBoxShadow(0); | 1443 style->setBoxShadow(0); |
| 1435 } | 1444 } |
| 1436 | 1445 |
| 1437 const float verticalSliderHeightPadding = 0.1f; | 1446 const float verticalSliderHeightPadding = 0.1f; |
| 1438 | 1447 |
| 1439 bool RenderThemeMac::paintSliderThumb(RenderObject* o, const RenderObject::Paint
Info& paintInfo, const IntRect& r) | 1448 bool RenderThemeMac::paintSliderThumb(RenderObject* o, const RenderObject::Paint
Info& paintInfo, const IntRect& r) |
| 1440 { | 1449 { |
| 1441 ASSERT(o->parent()->isSlider()); | 1450 ASSERT(o->parent()->isSlider()); |
| 1442 | 1451 |
| 1443 NSSliderCell* sliderThumbCell = o->style()->appearance() == SliderThumbVerti
calAppearance | 1452 NSSliderCell* sliderThumbCell = o->style()->appearance() == SliderThumbVerti
calPart |
| 1444 ? sliderThumbVertical() | 1453 ? sliderThumbVertical() |
| 1445 : sliderThumbHorizontal(); | 1454 : sliderThumbHorizontal(); |
| 1446 | 1455 |
| 1447 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1456 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1448 | 1457 |
| 1449 // Update the various states we respond to. | 1458 // Update the various states we respond to. |
| 1450 updateEnabledState(sliderThumbCell, o->parent()); | 1459 updateEnabledState(sliderThumbCell, o->parent()); |
| 1451 updateFocusedState(sliderThumbCell, o->parent()); | 1460 updateFocusedState(sliderThumbCell, o->parent()); |
| 1452 | 1461 |
| 1453 // Update the pressed state using the NSCell tracking methods, since that's
how NSSliderCell keeps track of it. | 1462 // Update the pressed state using the NSCell tracking methods, since that's
how NSSliderCell keeps track of it. |
| 1454 bool oldPressed; | 1463 bool oldPressed; |
| 1455 if (o->style()->appearance() == SliderThumbVerticalAppearance) | 1464 if (o->style()->appearance() == SliderThumbVerticalPart) |
| 1456 oldPressed = m_isSliderThumbVerticalPressed; | 1465 oldPressed = m_isSliderThumbVerticalPressed; |
| 1457 else | 1466 else |
| 1458 oldPressed = m_isSliderThumbHorizontalPressed; | 1467 oldPressed = m_isSliderThumbHorizontalPressed; |
| 1459 | 1468 |
| 1460 bool pressed = static_cast<RenderSlider*>(o->parent())->inDragMode(); | 1469 bool pressed = static_cast<RenderSlider*>(o->parent())->inDragMode(); |
| 1461 | 1470 |
| 1462 if (o->style()->appearance() == SliderThumbVerticalAppearance) | 1471 if (o->style()->appearance() == SliderThumbVerticalPart) |
| 1463 m_isSliderThumbVerticalPressed = pressed; | 1472 m_isSliderThumbVerticalPressed = pressed; |
| 1464 else | 1473 else |
| 1465 m_isSliderThumbHorizontalPressed = pressed; | 1474 m_isSliderThumbHorizontalPressed = pressed; |
| 1466 | 1475 |
| 1467 if (pressed != oldPressed) { | 1476 if (pressed != oldPressed) { |
| 1468 if (pressed) | 1477 if (pressed) |
| 1469 [sliderThumbCell startTrackingAt:NSPoint() inView:nil]; | 1478 [sliderThumbCell startTrackingAt:NSPoint() inView:nil]; |
| 1470 else | 1479 else |
| 1471 [sliderThumbCell stopTracking:NSPoint() at:NSPoint() inView:nil mous
eIsUp:YES]; | 1480 [sliderThumbCell stopTracking:NSPoint() at:NSPoint() inView:nil mous
eIsUp:YES]; |
| 1472 } | 1481 } |
| 1473 | 1482 |
| 1474 FloatRect bounds = r; | 1483 FloatRect bounds = r; |
| 1475 // Make the height of the vertical slider slightly larger so NSSliderCell wi
ll draw a vertical slider. | 1484 // Make the height of the vertical slider slightly larger so NSSliderCell wi
ll draw a vertical slider. |
| 1476 if (o->style()->appearance() == SliderThumbVerticalAppearance) | 1485 if (o->style()->appearance() == SliderThumbVerticalPart) |
| 1477 bounds.setHeight(bounds.height() + verticalSliderHeightPadding * o->styl
e()->effectiveZoom()); | 1486 bounds.setHeight(bounds.height() + verticalSliderHeightPadding * o->styl
e()->effectiveZoom()); |
| 1478 | 1487 |
| 1479 paintInfo.context->save(); | 1488 paintInfo.context->save(); |
| 1480 float zoomLevel = o->style()->effectiveZoom(); | 1489 float zoomLevel = o->style()->effectiveZoom(); |
| 1481 | 1490 |
| 1482 FloatRect unzoomedRect = bounds; | 1491 FloatRect unzoomedRect = bounds; |
| 1483 if (zoomLevel != 1.0f) { | 1492 if (zoomLevel != 1.0f) { |
| 1484 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1493 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1485 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1494 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1486 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1495 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1487 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1496 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1488 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1497 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1489 } | 1498 } |
| 1490 | 1499 |
| 1491 #if 0 | 1500 [sliderThumbCell drawWithFrame:FloatRectToNSRect(unzoomedRect) inView:nil]; |
| 1492 NSView* view = o->view()->frameView()->documentView(); | |
| 1493 #endif | |
| 1494 NSView* view = nil; | |
| 1495 [sliderThumbCell drawWithFrame:FloatRectToNSRect(unzoomedRect) inView:view]; | |
| 1496 [sliderThumbCell setControlView:nil]; | 1501 [sliderThumbCell setControlView:nil]; |
| 1497 | 1502 |
| 1498 paintInfo.context->restore(); | 1503 paintInfo.context->restore(); |
| 1499 | 1504 |
| 1500 return false; | 1505 return false; |
| 1501 } | 1506 } |
| 1502 | 1507 |
| 1503 const int sliderThumbWidth = 15; | 1508 const int sliderThumbWidth = 15; |
| 1504 const int sliderThumbHeight = 15; | 1509 const int sliderThumbHeight = 15; |
| 1505 const int mediaSliderThumbWidth = 13; | 1510 const int mediaSliderThumbWidth = 13; |
| 1506 const int mediaSliderThumbHeight = 14; | 1511 const int mediaSliderThumbHeight = 14; |
| 1507 | 1512 |
| 1508 void RenderThemeMac::adjustSliderThumbSize(RenderObject* o) const | 1513 void RenderThemeMac::adjustSliderThumbSize(RenderObject* o) const |
| 1509 { | 1514 { |
| 1510 float zoomLevel = o->style()->effectiveZoom(); | 1515 float zoomLevel = o->style()->effectiveZoom(); |
| 1511 if (o->style()->appearance() == SliderThumbHorizontalAppearance || o->style(
)->appearance() == SliderThumbVerticalAppearance) { | 1516 if (o->style()->appearance() == SliderThumbHorizontalPart || o->style()->app
earance() == SliderThumbVerticalPart) { |
| 1512 o->style()->setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLeve
l), Fixed)); | 1517 o->style()->setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLeve
l), Fixed)); |
| 1513 o->style()->setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLe
vel), Fixed)); | 1518 o->style()->setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLe
vel), Fixed)); |
| 1514 } else if (o->style()->appearance() == MediaSliderThumbAppearance) { | 1519 } else if (o->style()->appearance() == MediaSliderThumbPart) { |
| 1515 o->style()->setWidth(Length(mediaSliderThumbWidth, Fixed)); | 1520 o->style()->setWidth(Length(mediaSliderThumbWidth, Fixed)); |
| 1516 o->style()->setHeight(Length(mediaSliderThumbHeight, Fixed)); | 1521 o->style()->setHeight(Length(mediaSliderThumbHeight, Fixed)); |
| 1517 } | 1522 } |
| 1518 } | 1523 } |
| 1519 | 1524 |
| 1520 bool RenderThemeMac::paintSearchField(RenderObject* o, const RenderObject::Paint
Info& paintInfo, const IntRect& r) | 1525 bool RenderThemeMac::paintSearchField(RenderObject* o, const RenderObject::Paint
Info& paintInfo, const IntRect& r) |
| 1521 { | 1526 { |
| 1522 NSSearchFieldCell* search = this->search(); | 1527 NSSearchFieldCell* search = this->search(); |
| 1523 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1528 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1524 | 1529 |
| 1525 setSearchCellState(o, r); | 1530 setSearchCellState(o, r); |
| 1526 | 1531 |
| 1527 paintInfo.context->save(); | 1532 paintInfo.context->save(); |
| 1528 | 1533 |
| 1529 float zoomLevel = o->style()->effectiveZoom(); | 1534 float zoomLevel = o->style()->effectiveZoom(); |
| 1530 | 1535 |
| 1531 IntRect unzoomedRect = r; | 1536 IntRect unzoomedRect = r; |
| 1532 | 1537 |
| 1533 if (zoomLevel != 1.0f) { | 1538 if (zoomLevel != 1.0f) { |
| 1534 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1539 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1535 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1540 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1536 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1541 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1537 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1542 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1538 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1543 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1539 } | 1544 } |
| 1540 | 1545 |
| 1541 // Set the search button to nil before drawing. Then reset it so we can dra
w it later. | 1546 // Set the search button to nil before drawing. Then reset it so we can dra
w it later. |
| 1542 [search setSearchButtonCell:nil]; | 1547 [search setSearchButtonCell:nil]; |
| 1543 | 1548 |
| 1544 #if 0 | 1549 [search drawWithFrame:NSRect(IntRectToNSRect(unzoomedRect)) inView:nil]; |
| 1545 NSView* view = o->view()->frameView()->documentView(); | |
| 1546 #endif | |
| 1547 NSView* view = nil; | |
| 1548 [search drawWithFrame:NSRect(IntRectToNSRect(unzoomedRect)) inView:view]; | |
| 1549 #ifdef BUILDING_ON_TIGER | 1550 #ifdef BUILDING_ON_TIGER |
| 1550 if ([search showsFirstResponder]) | 1551 if ([search showsFirstResponder]) |
| 1551 wkDrawTextFieldCellFocusRing(search, NSRect(unzoomedRect)); | 1552 wkDrawTextFieldCellFocusRing(search, NSRect(unzoomedRect)); |
| 1552 #endif | 1553 #endif |
| 1553 | 1554 |
| 1554 [search setControlView:nil]; | 1555 [search setControlView:nil]; |
| 1555 [search resetSearchButtonCell]; | 1556 [search resetSearchButtonCell]; |
| 1556 | 1557 |
| 1557 paintInfo.context->restore(); | 1558 paintInfo.context->restore(); |
| 1558 | 1559 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 | 1635 |
| 1635 IntRect unzoomedRect(NSRectToIntRect(bounds)); | 1636 IntRect unzoomedRect(NSRectToIntRect(bounds)); |
| 1636 if (zoomLevel != 1.0f) { | 1637 if (zoomLevel != 1.0f) { |
| 1637 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1638 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1638 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1639 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1639 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1640 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1640 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1641 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1641 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1642 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1642 } | 1643 } |
| 1643 | 1644 |
| 1644 #if 0 | 1645 [[search cancelButtonCell] drawWithFrame:IntRectToNSRect(unzoomedRect) inVie
w:nil]; |
| 1645 NSView* view = o->view()->frameView()->documentView(); | |
| 1646 #endif | |
| 1647 NSView* view = nil; | |
| 1648 [[search cancelButtonCell] drawWithFrame:IntRectToNSRect(unzoomedRect) inVie
w:view]; | |
| 1649 [[search cancelButtonCell] setControlView:nil]; | 1646 [[search cancelButtonCell] setControlView:nil]; |
| 1650 | 1647 |
| 1651 paintInfo.context->restore(); | 1648 paintInfo.context->restore(); |
| 1652 return false; | 1649 return false; |
| 1653 } | 1650 } |
| 1654 | 1651 |
| 1655 const IntSize* RenderThemeMac::cancelButtonSizes() const | 1652 const IntSize* RenderThemeMac::cancelButtonSizes() const |
| 1656 { | 1653 { |
| 1657 static const IntSize sizes[3] = { IntSize(16, 13), IntSize(13, 11), IntSize(
13, 9) }; | 1654 static const IntSize sizes[3] = { IntSize(16, 13), IntSize(13, 11), IntSize(
13, 9) }; |
| 1658 return sizes; | 1655 return sizes; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 { | 1695 { |
| 1699 Node* input = o->node()->shadowAncestorNode(); | 1696 Node* input = o->node()->shadowAncestorNode(); |
| 1700 setSearchCellState(input->renderer(), r); | 1697 setSearchCellState(input->renderer(), r); |
| 1701 | 1698 |
| 1702 NSSearchFieldCell* search = this->search(); | 1699 NSSearchFieldCell* search = this->search(); |
| 1703 | 1700 |
| 1704 if ([search searchMenuTemplate] != nil) | 1701 if ([search searchMenuTemplate] != nil) |
| 1705 [search setSearchMenuTemplate:nil]; | 1702 [search setSearchMenuTemplate:nil]; |
| 1706 | 1703 |
| 1707 NSRect bounds = [search searchButtonRectForBounds:NSRect(IntRectToNSRect(inp
ut->renderer()->absoluteBoundingBoxRect()))]; | 1704 NSRect bounds = [search searchButtonRectForBounds:NSRect(IntRectToNSRect(inp
ut->renderer()->absoluteBoundingBoxRect()))]; |
| 1708 #if 0 | 1705 [[search searchButtonCell] drawWithFrame:bounds inView:nil]; |
| 1709 NSView* view = o->view()->frameView()->documentView(); | |
| 1710 #endif | |
| 1711 NSView* view = nil; | |
| 1712 [[search searchButtonCell] drawWithFrame:bounds inView:view]; | |
| 1713 [[search searchButtonCell] setControlView:nil]; | 1706 [[search searchButtonCell] setControlView:nil]; |
| 1714 return false; | 1707 return false; |
| 1715 } | 1708 } |
| 1716 | 1709 |
| 1717 const int resultsArrowWidth = 5; | 1710 const int resultsArrowWidth = 5; |
| 1718 void RenderThemeMac::adjustSearchFieldResultsButtonStyle(CSSStyleSelector* selec
tor, RenderStyle* style, Element* e) const | 1711 void RenderThemeMac::adjustSearchFieldResultsButtonStyle(CSSStyleSelector* selec
tor, RenderStyle* style, Element* e) const |
| 1719 { | 1712 { |
| 1720 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); | 1713 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); |
| 1721 style->setWidth(Length(size.width() + resultsArrowWidth, Fixed)); | 1714 style->setWidth(Length(size.width() + resultsArrowWidth, Fixed)); |
| 1722 style->setHeight(Length(size.height(), Fixed)); | 1715 style->setHeight(Length(size.height(), Fixed)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1741 | 1734 |
| 1742 IntRect unzoomedRect(NSRectToIntRect(bounds)); | 1735 IntRect unzoomedRect(NSRectToIntRect(bounds)); |
| 1743 if (zoomLevel != 1.0f) { | 1736 if (zoomLevel != 1.0f) { |
| 1744 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1737 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1745 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1738 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1746 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1739 paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1747 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); | 1740 paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel)); |
| 1748 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1741 paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1749 } | 1742 } |
| 1750 | 1743 |
| 1751 #if 0 | 1744 [[search searchButtonCell] drawWithFrame:IntRectToNSRect(unzoomedRect) inVie
w:nil]; |
| 1752 NSView* view = o->view()->frameView()->documentView(); | |
| 1753 #endif | |
| 1754 NSView* view = nil; | |
| 1755 [[search searchButtonCell] drawWithFrame:IntRectToNSRect(unzoomedRect) inVie
w:view]; | |
| 1756 [[search searchButtonCell] setControlView:nil]; | 1745 [[search searchButtonCell] setControlView:nil]; |
| 1757 | 1746 |
| 1758 paintInfo.context->restore(); | 1747 paintInfo.context->restore(); |
| 1759 | 1748 |
| 1760 return false; | 1749 return false; |
| 1761 } | 1750 } |
| 1762 | 1751 |
| 1763 bool RenderThemeMac::paintMediaFullscreenButton(RenderObject* o, const RenderObj
ect::PaintInfo& paintInfo, const IntRect& r) | 1752 bool RenderThemeMac::paintMediaFullscreenButton(RenderObject* o, const RenderObj
ect::PaintInfo& paintInfo, const IntRect& r) |
| 1764 { | 1753 { |
| 1765 Node* node = o->element(); | 1754 Node* node = o->element(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 return false; | 1790 return false; |
| 1802 | 1791 |
| 1803 HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode); | 1792 HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(mediaNode); |
| 1804 if (!mediaElement) | 1793 if (!mediaElement) |
| 1805 return false; | 1794 return false; |
| 1806 | 1795 |
| 1807 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1796 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1808 if (mediaElement->canPlay()) | 1797 if (mediaElement->canPlay()) |
| 1809 wkDrawMediaPlayButton(paintInfo.context->platformContext(), r, node->act
ive()); | 1798 wkDrawMediaPlayButton(paintInfo.context->platformContext(), r, node->act
ive()); |
| 1810 else | 1799 else |
| 1811 wkDrawMediaPauseButton(paintInfo.context->platformContext(), r, node->ac
tive()); | 1800 wkDrawMediaPauseButton(paintInfo.context->platformContext(), r, node->ac
tive()); |
| 1812 #endif | 1801 #endif |
| 1813 return false; | 1802 return false; |
| 1814 } | 1803 } |
| 1815 | 1804 |
| 1816 bool RenderThemeMac::paintMediaSeekBackButton(RenderObject* o, const RenderObjec
t::PaintInfo& paintInfo, const IntRect& r) | 1805 bool RenderThemeMac::paintMediaSeekBackButton(RenderObject* o, const RenderObjec
t::PaintInfo& paintInfo, const IntRect& r) |
| 1817 { | 1806 { |
| 1818 Node* node = o->element(); | 1807 Node* node = o->element(); |
| 1819 if (!node) | 1808 if (!node) |
| 1820 return false; | 1809 return false; |
| 1821 | 1810 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 { | 1850 { |
| 1862 Node* node = o->element(); | 1851 Node* node = o->element(); |
| 1863 if (!node) | 1852 if (!node) |
| 1864 return false; | 1853 return false; |
| 1865 | 1854 |
| 1866 LocalCurrentGraphicsContext localContext(paintInfo.context); | 1855 LocalCurrentGraphicsContext localContext(paintInfo.context); |
| 1867 wkDrawMediaSliderThumb(paintInfo.context->platformContext(), r, node->active
()); | 1856 wkDrawMediaSliderThumb(paintInfo.context->platformContext(), r, node->active
()); |
| 1868 return false; | 1857 return false; |
| 1869 } | 1858 } |
| 1870 | 1859 |
| 1860 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 1871 NSButtonCell* RenderThemeMac::checkbox() const | 1861 NSButtonCell* RenderThemeMac::checkbox() const |
| 1872 { | 1862 { |
| 1873 if (!m_checkbox) { | 1863 if (!m_checkbox) { |
| 1874 m_checkbox.adoptNS([[NSButtonCell alloc] init]); | 1864 m_checkbox.adoptNS([[NSButtonCell alloc] init]); |
| 1875 [m_checkbox.get() setButtonType:NSSwitchButton]; | 1865 [m_checkbox.get() setButtonType:NSSwitchButton]; |
| 1876 [m_checkbox.get() setTitle:nil]; | 1866 [m_checkbox.get() setTitle:nil]; |
| 1877 [m_checkbox.get() setAllowsMixedState:YES]; | 1867 [m_checkbox.get() setAllowsMixedState:YES]; |
| 1878 [m_checkbox.get() setFocusRingType:NSFocusRingTypeExterior]; | 1868 [m_checkbox.get() setFocusRingType:NSFocusRingTypeExterior]; |
| 1879 } | 1869 } |
| 1880 | 1870 |
| 1881 return m_checkbox.get(); | 1871 return m_checkbox.get(); |
| 1882 } | 1872 } |
| 1883 | 1873 |
| 1874 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 1884 NSButtonCell* RenderThemeMac::radio() const | 1875 NSButtonCell* RenderThemeMac::radio() const |
| 1885 { | 1876 { |
| 1886 if (!m_radio) { | 1877 if (!m_radio) { |
| 1887 m_radio.adoptNS([[NSButtonCell alloc] init]); | 1878 m_radio.adoptNS([[NSButtonCell alloc] init]); |
| 1888 [m_radio.get() setButtonType:NSRadioButton]; | 1879 [m_radio.get() setButtonType:NSRadioButton]; |
| 1889 [m_radio.get() setTitle:nil]; | 1880 [m_radio.get() setTitle:nil]; |
| 1890 [m_radio.get() setFocusRingType:NSFocusRingTypeExterior]; | 1881 [m_radio.get() setFocusRingType:NSFocusRingTypeExterior]; |
| 1891 } | 1882 } |
| 1892 | 1883 |
| 1893 return m_radio.get(); | 1884 return m_radio.get(); |
| 1894 } | 1885 } |
| 1895 | 1886 |
| 1887 // TODO(port): This used to be in the upstream version until it was converted to
the new theme API in r37731. |
| 1896 NSButtonCell* RenderThemeMac::button() const | 1888 NSButtonCell* RenderThemeMac::button() const |
| 1897 { | 1889 { |
| 1898 if (!m_button) { | 1890 if (!m_button) { |
| 1899 m_button.adoptNS([[NSButtonCell alloc] init]); | 1891 m_button.adoptNS([[NSButtonCell alloc] init]); |
| 1900 [m_button.get() setTitle:nil]; | 1892 [m_button.get() setTitle:nil]; |
| 1901 [m_button.get() setButtonType:NSMomentaryPushInButton]; | 1893 [m_button.get() setButtonType:NSMomentaryPushInButton]; |
| 1902 } | 1894 } |
| 1903 | 1895 |
| 1904 return m_button.get(); | 1896 return m_button.get(); |
| 1905 } | 1897 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 [m_sliderThumbVertical.get() setTitle:nil]; | 1948 [m_sliderThumbVertical.get() setTitle:nil]; |
| 1957 [m_sliderThumbVertical.get() setSliderType:NSLinearSlider]; | 1949 [m_sliderThumbVertical.get() setSliderType:NSLinearSlider]; |
| 1958 [m_sliderThumbVertical.get() setControlSize:NSSmallControlSize]; | 1950 [m_sliderThumbVertical.get() setControlSize:NSSmallControlSize]; |
| 1959 [m_sliderThumbVertical.get() setFocusRingType:NSFocusRingTypeExterior]; | 1951 [m_sliderThumbVertical.get() setFocusRingType:NSFocusRingTypeExterior]; |
| 1960 } | 1952 } |
| 1961 | 1953 |
| 1962 return m_sliderThumbVertical.get(); | 1954 return m_sliderThumbVertical.get(); |
| 1963 } | 1955 } |
| 1964 | 1956 |
| 1965 } // namespace WebCore | 1957 } // namespace WebCore |
| OLD | NEW |