Changeset 63514 in webkit
- Timestamp:
- Jul 15, 2010 9:55:03 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r63511 r63514 1 2010-07-15 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 [Chromium] Update ThemeChromiumMac.mm for the recent changes of ThemeMac.mm 6 https://bugs.webkit.org/show_bug.cgi?id=41932 7 8 Sync with ThemeMac.mm r61760. 9 This change doesn't contain r54299, r57603, r57734, r57741, and 10 r58533 because they conflict with Chromium change for 11 FlippedView(). 12 13 * platform/chromium/ThemeChromiumMac.mm: 14 (WebCore::sizeFromNSControlSize): 15 (WebCore::sizeFromFont): 16 (WebCore::controlSizeFromPixelSize): 17 (WebCore::setControlSize): 18 (WebCore::convertControlStatesToThemeDrawState): 19 (WebCore::stepperSizes): 20 (WebCore::stepperControlSizeForFont): 21 (WebCore::paintStepper): 22 (WebCore::ThemeChromiumMac::controlSize): 23 (WebCore::ThemeChromiumMac::minimumControlSize): 24 (WebCore::ThemeChromiumMac::inflateControlPaintRect): 25 (WebCore::ThemeChromiumMac::paint): 26 1 27 2010-07-15 MORITA Hajime <morrita@google.com> 2 28 -
trunk/WebCore/platform/chromium/ThemeChromiumMac.mm
r61486 r63514 33 33 #import "ScrollView.h" 34 34 #import "WebCoreSystemInterface.h" 35 #import <Carbon/Carbon.h> 35 36 #include <wtf/StdLibExtras.h> 36 37 #import <objc/runtime.h> … … 211 212 } 212 213 213 static LengthSize sizeFrom Font(const Font& font, const LengthSize& zoomedSize, float zoomFactor, const IntSize* sizes)214 { 215 IntSize controlSize = sizes[ controlSizeForFont(font)];214 static LengthSize sizeFromNSControlSize(NSControlSize nsControlSize, const LengthSize& zoomedSize, float zoomFactor, const IntSize* sizes) 215 { 216 IntSize controlSize = sizes[nsControlSize]; 216 217 if (zoomFactor != 1.0f) 217 218 controlSize = IntSize(controlSize.width() * zoomFactor, controlSize.height() * zoomFactor); … … 224 225 } 225 226 226 static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor) 227 { 228 NSControlSize size; 227 static LengthSize sizeFromFont(const Font& font, const LengthSize& zoomedSize, float zoomFactor, const IntSize* sizes) 228 { 229 return sizeFromNSControlSize(controlSizeForFont(font), zoomedSize, zoomFactor, sizes); 230 } 231 232 static ControlSize controlSizeFromPixelSize(const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor) 233 { 229 234 if (minZoomedSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomFactor) && 230 235 minZoomedSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height() * zoomFactor)) 231 size = NSRegularControlSize; 232 else if (minZoomedSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomFactor) && 233 minZoomedSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomFactor)) 234 size = NSSmallControlSize; 235 else 236 size = NSMiniControlSize; 236 return NSRegularControlSize; 237 if (minZoomedSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomFactor) && 238 minZoomedSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomFactor)) 239 return NSSmallControlSize; 240 return NSMiniControlSize; 241 } 242 243 static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor) 244 { 245 ControlSize size = controlSizeFromPixelSize(sizes, minZoomedSize, zoomFactor); 237 246 if (size != [cell controlSize]) // Only update if we have to, since AppKit does work even if the size is the same. 238 [cell setControlSize: size];247 [cell setControlSize:(NSControlSize)size]; 239 248 } 240 249 … … 276 285 if (tint != oldTint) 277 286 [cell setControlTint:tint]; 287 } 288 289 static ThemeDrawState convertControlStatesToThemeDrawState(ThemeButtonKind kind, ControlStates states) 290 { 291 if (states & ReadOnlyState) 292 return kThemeStateUnavailableInactive; 293 if (!(states & EnabledState)) 294 return kThemeStateUnavailableInactive; 295 296 // Do not process PressedState if !EnabledState or ReadOnlyState. 297 if (states & PressedState) { 298 if (kind == kThemeIncDecButton || kind == kThemeIncDecButtonSmall || kind == kThemeIncDecButtonMini) 299 return states & SpinUpState ? kThemeStatePressedUp : kThemeStatePressedDown; 300 return kThemeStatePressed; 301 } 302 return kThemeStateActive; 278 303 } 279 304 … … 572 597 } 573 598 599 // Stepper 600 601 static const IntSize* stepperSizes() 602 { 603 static const IntSize sizes[3] = { IntSize(19, 27), IntSize(15, 22), IntSize(13, 15) }; 604 return sizes; 605 } 606 607 // We don't use controlSizeForFont() for steppers because the stepper height 608 // should be equal to or less than the corresponding text field height, 609 static NSControlSize stepperControlSizeForFont(const Font& font) 610 { 611 int fontSize = font.pixelSize(); 612 if (fontSize >= 18) 613 return NSRegularControlSize; 614 if (fontSize >= 13) 615 return NSSmallControlSize; 616 return NSMiniControlSize; 617 } 618 619 static void paintStepper(ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView*) 620 { 621 // We don't use NSStepperCell because there are no ways to draw an 622 // NSStepperCell with the up button highlighted. 623 624 HIThemeButtonDrawInfo drawInfo; 625 drawInfo.version = 0; 626 drawInfo.state = convertControlStatesToThemeDrawState(kThemeIncDecButton, states); 627 drawInfo.adornment = kThemeAdornmentDefault; 628 ControlSize controlSize = controlSizeFromPixelSize(stepperSizes(), zoomedRect.size(), zoomFactor); 629 if (controlSize == NSSmallControlSize) 630 drawInfo.kind = kThemeIncDecButtonSmall; 631 else if (controlSize == NSMiniControlSize) 632 drawInfo.kind = kThemeIncDecButtonMini; 633 else 634 drawInfo.kind = kThemeIncDecButton; 635 636 IntRect rect(zoomedRect); 637 context->save(); 638 if (zoomFactor != 1.0f) { 639 rect.setWidth(rect.width() / zoomFactor); 640 rect.setHeight(rect.height() / zoomFactor); 641 context->translate(rect.x(), rect.y()); 642 context->scale(FloatSize(zoomFactor, zoomFactor)); 643 context->translate(-rect.x(), -rect.y()); 644 } 645 CGRect bounds(rect); 646 // Adjust 'bounds' so that HIThemeDrawButton(bounds,...) draws exactly on 'rect'. 647 CGRect backgroundBounds; 648 HIThemeGetButtonBackgroundBounds(&bounds, &drawInfo, &backgroundBounds); 649 if (bounds.origin.x != backgroundBounds.origin.x) 650 bounds.origin.x += bounds.origin.x - backgroundBounds.origin.x; 651 if (bounds.origin.y != backgroundBounds.origin.y) 652 bounds.origin.y += bounds.origin.y - backgroundBounds.origin.y; 653 HIThemeDrawButton(&bounds, &drawInfo, context->platformContext(), kHIThemeOrientationNormal, 0); 654 context->restore(); 655 } 656 574 657 // Theme overrides 575 658 … … 614 697 return sizeFromFont(font, LengthSize(zoomedSize.width(), Length()), zoomFactor, listButtonSizes()); 615 698 #endif 699 case InnerSpinButtonPart: 700 // We don't use inner spin buttons on Mac. 701 return LengthSize(Length(Fixed), Length(Fixed)); 702 case OuterSpinButtonPart: 703 if (!zoomedSize.width().isIntrinsicOrAuto() && !zoomedSize.height().isIntrinsicOrAuto()) 704 return zoomedSize; 705 return sizeFromNSControlSize(stepperControlSizeForFont(font), zoomedSize, zoomFactor, stepperSizes()); 616 706 default: 617 707 return zoomedSize; … … 627 717 case ListButtonPart: 628 718 return LengthSize(Length(0, Fixed), Length(static_cast<int>(15 * zoomFactor), Fixed)); 719 case InnerSpinButtonPart: 720 // We don't use inner spin buttons on Mac. 721 return LengthSize(Length(Fixed), Length(Fixed)); 722 case OuterSpinButtonPart: { 723 IntSize base = stepperSizes()[NSMiniControlSize]; 724 return LengthSize(Length(static_cast<int>(base.width() * zoomFactor), Fixed), 725 Length(static_cast<int>(base.height() * zoomFactor), Fixed)); 726 } 629 727 default: 630 728 return Theme::minimumControlSize(part, font, zoomFactor); … … 703 801 break; 704 802 } 803 case OuterSpinButtonPart: { 804 static const int stepperMargin[4] = { 0, 0, 0, 0}; 805 ControlSize controlSize = controlSizeFromPixelSize(stepperSizes(), zoomedRect.size(), zoomFactor); 806 IntSize zoomedSize = stepperSizes()[controlSize]; 807 zoomedSize.setHeight(zoomedSize.height() * zoomFactor); 808 zoomedSize.setWidth(zoomedSize.width() * zoomFactor); 809 zoomedRect = inflateRect(zoomedRect, zoomedSize, stepperMargin, zoomFactor); 810 break; 811 } 705 812 default: 706 813 break; … … 725 832 paintButton(part, states, context, zoomedRect, zoomFactor, scrollView); 726 833 break; 834 case OuterSpinButtonPart: 835 paintStepper(states, context, zoomedRect, zoomFactor, scrollView); 836 break; 727 837 default: 728 838 break;
Note: See TracChangeset
for help on using the changeset viewer.