Changeset 61751 in webkit
- Timestamp:
- Jun 24, 2010 3:07:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r61750 r61751 1 2010-06-24 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 [Mac] The upper button of <input type=number> has no visual effect on click 6 https://bugs.webkit.org/show_bug.cgi?id=38380 7 8 * platform/mac/fast/forms/input-appearance-spinbutton-expected.checksum: 9 * platform/mac/fast/forms/input-appearance-spinbutton-expected.png: 10 * platform/mac/fast/forms/input-appearance-spinbutton-up-expected.checksum: Added. 11 * platform/mac/fast/forms/input-appearance-spinbutton-up-expected.png: Added. 12 * platform/mac/fast/forms/input-appearance-spinbutton-up-expected.txt: Added. 13 * platform/mac/fast/forms/input-appearance-spinbutton-up.html: Added. 14 1 15 2010-06-24 Oliver Hunt <oliver@apple.com> 2 16 -
trunk/LayoutTests/platform/mac/fast/forms/input-appearance-spinbutton-expected.checksum
r58561 r61751 1 7ec81a98ab133c920958c45632320ba1 1 adc036c913c7b9c13a0fa71c28e22253 -
trunk/WebCore/ChangeLog
r61749 r61751 1 2010-06-24 Kent Tamura <tkent@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 [Mac] The upper button of <input type=number> has no visual effect on click 6 https://bugs.webkit.org/show_bug.cgi?id=38380 7 8 Because we have no ways to draw an NSStepperCell with its up button 9 highlighted, use HIThemeDrawButton() instead. 10 11 Test: platform/mac/fast/forms/input-appearance-spinbutton-up.html 12 13 * platform/mac/ThemeMac.mm: 14 (WebCore::controlSizeFromPixelSize): 15 New function. Made from a part of setControlSize(). 16 (WebCore::setControlSize): 17 (WebCore::convertControlStatesToThemeDrawState): 18 (WebCore::paintStepper): Use HITheme API instead of NSStepperCell. 19 (WebCore::ThemeMac::inflateControlPaintRect): 20 Use controlSizeFromPixelSize(). 21 1 22 2010-06-24 Yury Semikhatsky <yurys@chromium.org> 2 23 -
trunk/WebCore/platform/mac/ThemeMac.mm
r58561 r61751 32 32 #import "ScrollView.h" 33 33 #import "WebCoreSystemInterface.h" 34 #import <Carbon/Carbon.h> 34 35 #include <wtf/StdLibExtras.h> 35 36 … … 101 102 } 102 103 103 static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor) 104 { 105 NSControlSize size; 104 static ControlSize controlSizeFromPixelSize(const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor) 105 { 106 106 if (minZoomedSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomFactor) && 107 107 minZoomedSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height() * zoomFactor)) 108 size = NSRegularControlSize; 109 else if (minZoomedSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomFactor) && 110 minZoomedSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomFactor)) 111 size = NSSmallControlSize; 112 else 113 size = NSMiniControlSize; 108 return NSRegularControlSize; 109 if (minZoomedSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomFactor) && 110 minZoomedSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomFactor)) 111 return NSSmallControlSize; 112 return NSMiniControlSize; 113 } 114 115 static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor) 116 { 117 NSControlSize size = controlSizeFromPixelSize(sizes, minZoomedSize, zoomFactor); 114 118 if (size != [cell controlSize]) // Only update if we have to, since AppKit does work even if the size is the same. 115 119 [cell setControlSize:size]; … … 148 152 // Window inactive state does not need to be checked explicitly, since we paint parented to 149 153 // a view in a window whose key state can be detected. 154 } 155 156 static ThemeDrawState convertControlStatesToThemeDrawState(ThemeButtonKind kind, ControlStates states) 157 { 158 if (states & ReadOnlyState) 159 return kThemeStateUnavailableInactive; 160 if (!(states & EnabledState)) 161 return kThemeStateUnavailableInactive; 162 163 // Do not process PressedState if !EnabledState or ReadOnlyState. 164 if (states & PressedState) { 165 if (kind == kThemeIncDecButton || kind == kThemeIncDecButtonSmall || kind == kThemeIncDecButtonMini) 166 return states & SpinUpState ? kThemeStatePressedUp : kThemeStatePressedDown; 167 return kThemeStatePressed; 168 } 169 return kThemeStateActive; 150 170 } 151 171 … … 470 490 } 471 491 472 static NSStepperCell* stepper(ControlStates states, const IntRect& zoomedRect, float zoomFactor)473 { 474 static NSStepperCell* cell = [[NSStepperCell alloc] init];475 setControlSize(cell, stepperSizes(), zoomedRect.size(), zoomFactor);476 477 updateStates(cell, states);478 if (states & PressedState && states & SpinUpState) {479 // FIXME: There is no way to draw a NSSteperCell with the up button hilighted.480 // Disables the hilight of the down button if the up button is pressed.481 [cell setHighlighted:NO];482 }483 return cell;484 } 485 486 static void paintStepper(ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView* scrollView) 487 { 488 NSStepperCell* cell = stepper(states, zoomedRect, zoomFactor); 489 492 static void paintStepper(ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView*) 493 { 494 // We don't use NSStepperCell because there are no ways to draw an 495 // NSStepperCell with the up button highlighted. 496 497 HIThemeButtonDrawInfo drawInfo; 498 drawInfo.version = 0; 499 drawInfo.state = convertControlStatesToThemeDrawState(kThemeIncDecButton, states); 500 drawInfo.adornment = kThemeAdornmentDefault; 501 ControlSize controlSize = controlSizeFromPixelSize(stepperSizes(), zoomedRect.size(), zoomFactor); 502 if (controlSize == NSSmallControlSize) 503 drawInfo.kind = kThemeIncDecButtonSmall; 504 else if (controlSize == NSMiniControlSize) 505 drawInfo.kind = kThemeIncDecButtonMini; 506 else 507 drawInfo.kind = kThemeIncDecButton; 508 509 IntRect rect(zoomedRect); 490 510 context->save(); 491 NSControlSize controlSize = [cell controlSize];492 IntSize zoomedSize = stepperSizes()[controlSize];493 IntRect rect(zoomedRect);494 495 511 if (zoomFactor != 1.0f) { 496 512 rect.setWidth(rect.width() / zoomFactor); … … 500 516 context->translate(-rect.x(), -rect.y()); 501 517 } 502 503 BEGIN_BLOCK_OBJC_EXCEPTIONS 504 [cell drawWithFrame:NSRect(rect) inView:ThemeMac::ensuredView(scrollView)]; 505 [cell setControlView:nil]; 506 END_BLOCK_OBJC_EXCEPTIONS 507 518 CGRect bounds(rect); 519 // Adjust 'bounds' so that HIThemeDrawButton(bounds,...) draws exactly on 'rect'. 520 CGRect backgroundBounds; 521 HIThemeGetButtonBackgroundBounds(&bounds, &drawInfo, &backgroundBounds); 522 if (bounds.origin.x != backgroundBounds.origin.x) 523 bounds.origin.x += bounds.origin.x - backgroundBounds.origin.x; 524 if (bounds.origin.y != backgroundBounds.origin.y) 525 bounds.origin.y += bounds.origin.y - backgroundBounds.origin.y; 526 HIThemeDrawButton(&bounds, &drawInfo, context->platformContext(), kHIThemeOrientationNormal, 0); 508 527 context->restore(); 509 528 } … … 670 689 case OuterSpinButtonPart: { 671 690 static const int stepperMargin[4] = { 0, 0, 0, 0}; 672 NSCell *cell = stepper(states, zoomedRect, zoomFactor); 673 NSControlSize controlSize = [cell controlSize]; 691 NSControlSize controlSize = controlSizeFromPixelSize(stepperSizes(), zoomedRect.size(), zoomFactor); 674 692 IntSize zoomedSize = stepperSizes()[controlSize]; 675 693 zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
Note: See TracChangeset
for help on using the changeset viewer.