OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008, 2009 Google, Inc. | 3 * Copyright (C) 2008, 2009 Google, Inc. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #import "core/layout/LayoutThemeMac.h" | 21 #import "core/layout/LayoutThemeMac.h" |
22 | 22 |
23 #import "core/CSSValueKeywords.h" | 23 #import "core/CSSValueKeywords.h" |
24 #import "core/HTMLNames.h" | 24 #import "core/HTMLNames.h" |
25 #import "core/fileapi/FileList.h" | 25 #import "core/fileapi/FileList.h" |
26 #import "core/html/HTMLMeterElement.h" | |
27 #import "core/layout/LayoutMeter.h" | |
28 #import "core/layout/LayoutProgress.h" | 26 #import "core/layout/LayoutProgress.h" |
29 #import "core/layout/LayoutView.h" | 27 #import "core/layout/LayoutView.h" |
30 #import "core/paint/MediaControlsPainter.h" | 28 #import "core/paint/MediaControlsPainter.h" |
31 #import "core/style/ShadowList.h" | 29 #import "core/style/ShadowList.h" |
32 #import "platform/LayoutTestSupport.h" | 30 #import "platform/LayoutTestSupport.h" |
33 #import "platform/PlatformResourceLoader.h" | 31 #import "platform/PlatformResourceLoader.h" |
34 #import "platform/Theme.h" | 32 #import "platform/Theme.h" |
35 #import "platform/graphics/BitmapImage.h" | 33 #import "platform/graphics/BitmapImage.h" |
36 #import "platform/mac/ColorMac.h" | 34 #import "platform/mac/ColorMac.h" |
37 #import "platform/mac/LocalCurrentGraphicsContext.h" | 35 #import "platform/mac/LocalCurrentGraphicsContext.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 { | 650 { |
653 static const int padding[3][4] = | 651 static const int padding[3][4] = |
654 { | 652 { |
655 { 2, 26, 3, 8 }, | 653 { 2, 26, 3, 8 }, |
656 { 2, 23, 3, 8 }, | 654 { 2, 23, 3, 8 }, |
657 { 2, 22, 3, 10 } | 655 { 2, 22, 3, 10 } |
658 }; | 656 }; |
659 return padding[size]; | 657 return padding[size]; |
660 } | 658 } |
661 | 659 |
662 IntSize LayoutThemeMac::meterSizeForBounds(const LayoutMeter& layoutMeter, const
IntRect& bounds) const | |
663 { | |
664 if (NoControlPart == layoutMeter.style()->appearance()) | |
665 return bounds.size(); | |
666 | |
667 NSLevelIndicatorCell* cell = levelIndicatorFor(layoutMeter); | |
668 // Makes enough room for cell's intrinsic size. | |
669 NSSize cellSize = [cell cellSizeForBounds:IntRect(IntPoint(), bounds.size())
]; | |
670 return IntSize(bounds.width() < cellSize.width ? cellSize.width : bounds.wid
th(), | |
671 bounds.height() < cellSize.height ? cellSize.height : bounds.
height()); | |
672 } | |
673 | |
674 bool LayoutThemeMac::supportsMeter(ControlPart part) const | |
675 { | |
676 switch (part) { | |
677 case RelevancyLevelIndicatorPart: | |
678 case DiscreteCapacityLevelIndicatorPart: | |
679 case RatingLevelIndicatorPart: | |
680 case MeterPart: | |
681 case ContinuousCapacityLevelIndicatorPart: | |
682 return true; | |
683 default: | |
684 return false; | |
685 } | |
686 } | |
687 | |
688 NSLevelIndicatorStyle LayoutThemeMac::levelIndicatorStyleFor(ControlPart part) c
onst | |
689 { | |
690 switch (part) { | |
691 case RelevancyLevelIndicatorPart: | |
692 return NSRelevancyLevelIndicatorStyle; | |
693 case DiscreteCapacityLevelIndicatorPart: | |
694 return NSDiscreteCapacityLevelIndicatorStyle; | |
695 case RatingLevelIndicatorPart: | |
696 return NSRatingLevelIndicatorStyle; | |
697 case MeterPart: | |
698 case ContinuousCapacityLevelIndicatorPart: | |
699 default: | |
700 return NSContinuousCapacityLevelIndicatorStyle; | |
701 } | |
702 } | |
703 | |
704 NSLevelIndicatorCell* LayoutThemeMac::levelIndicatorFor(const LayoutMeter& layou
tMeter) const | |
705 { | |
706 const ComputedStyle& style = layoutMeter.styleRef(); | |
707 ASSERT(style.appearance() != NoControlPart); | |
708 | |
709 if (!m_levelIndicator) | |
710 m_levelIndicator.adoptNS([[NSLevelIndicatorCell alloc] initWithLevelIndi
catorStyle:NSContinuousCapacityLevelIndicatorStyle]); | |
711 NSLevelIndicatorCell* cell = m_levelIndicator.get(); | |
712 | |
713 HTMLMeterElement* element = layoutMeter.meterElement(); | |
714 double value = element->value(); | |
715 | |
716 // Because NSLevelIndicatorCell does not support optimum-in-the-middle type | |
717 // coloring, we explicitly control the color instead giving low and high | |
718 // value to NSLevelIndicatorCell as is. | |
719 switch (element->gaugeRegion()) { | |
720 case HTMLMeterElement::GaugeRegionOptimum: | |
721 // Make meter the green. | |
722 [cell setWarningValue:value + 1]; | |
723 [cell setCriticalValue:value + 2]; | |
724 break; | |
725 case HTMLMeterElement::GaugeRegionSuboptimal: | |
726 // Make the meter yellow. | |
727 [cell setWarningValue:value - 1]; | |
728 [cell setCriticalValue:value + 1]; | |
729 break; | |
730 case HTMLMeterElement::GaugeRegionEvenLessGood: | |
731 // Make the meter red. | |
732 [cell setWarningValue:value - 2]; | |
733 [cell setCriticalValue:value - 1]; | |
734 break; | |
735 } | |
736 | |
737 [cell setLevelIndicatorStyle:levelIndicatorStyleFor(style.appearance())]; | |
738 [cell setBaseWritingDirection:style.isLeftToRightDirection() ? NSWritingDire
ctionLeftToRight : NSWritingDirectionRightToLeft]; | |
739 [cell setMinValue:element->min()]; | |
740 [cell setMaxValue:element->max()]; | |
741 RetainPtr<NSNumber> valueObject = [NSNumber numberWithDouble:value]; | |
742 [cell setObjectValue:valueObject.get()]; | |
743 | |
744 return cell; | |
745 } | |
746 | |
747 const IntSize* LayoutThemeMac::progressBarSizes() const | 660 const IntSize* LayoutThemeMac::progressBarSizes() const |
748 { | 661 { |
749 static const IntSize sizes[3] = { IntSize(0, 20), IntSize(0, 12), IntSize(0,
12) }; | 662 static const IntSize sizes[3] = { IntSize(0, 20), IntSize(0, 12), IntSize(0,
12) }; |
750 return sizes; | 663 return sizes; |
751 } | 664 } |
752 | 665 |
753 const int* LayoutThemeMac::progressBarMargins(NSControlSize controlSize) const | 666 const int* LayoutThemeMac::progressBarMargins(NSControlSize controlSize) const |
754 { | 667 { |
755 static const int margins[3][4] = | 668 static const int margins[3][4] = |
756 { | 669 { |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 | 1082 |
1170 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const | 1083 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const |
1171 { | 1084 { |
1172 ControlPart part = style.appearance(); | 1085 ControlPart part = style.appearance(); |
1173 if (part == CheckboxPart || part == RadioPart) | 1086 if (part == CheckboxPart || part == RadioPart) |
1174 return style.effectiveZoom() != 1; | 1087 return style.effectiveZoom() != 1; |
1175 return false; | 1088 return false; |
1176 } | 1089 } |
1177 | 1090 |
1178 } // namespace blink | 1091 } // namespace blink |
OLD | NEW |