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, |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 } | 463 } |
464 | 464 |
465 if (needsFallback) | 465 if (needsFallback) |
466 color = LayoutTheme::systemColor(cssValueId); | 466 color = LayoutTheme::systemColor(cssValueId); |
467 | 467 |
468 m_systemColorCache.set(cssValueId, color.rgb()); | 468 m_systemColorCache.set(cssValueId, color.rgb()); |
469 | 469 |
470 return color; | 470 return color; |
471 } | 471 } |
472 | 472 |
473 bool LayoutThemeMac::isControlStyled(const LayoutStyle& style, const AuthorStyle
Info& authorStyle) const | 473 bool LayoutThemeMac::isControlStyled(const ComputedStyle& style, const AuthorSty
leInfo& authorStyle) const |
474 { | 474 { |
475 if (style.appearance() == TextFieldPart || style.appearance() == TextAreaPar
t) | 475 if (style.appearance() == TextFieldPart || style.appearance() == TextAreaPar
t) |
476 return authorStyle.specifiesBorder() || style.boxShadow(); | 476 return authorStyle.specifiesBorder() || style.boxShadow(); |
477 | 477 |
478 // FIXME: This is horrible, but there is not much else that can be done. | 478 // FIXME: This is horrible, but there is not much else that can be done. |
479 // Menu lists cannot draw properly when scaled. They can't really draw | 479 // Menu lists cannot draw properly when scaled. They can't really draw |
480 // properly when transformed either. We can't detect the transform case at | 480 // properly when transformed either. We can't detect the transform case at |
481 // style adjustment time so that will just have to stay broken. We can | 481 // style adjustment time so that will just have to stay broken. We can |
482 // however detect that we're zooming. If zooming is in effect we treat it | 482 // however detect that we're zooming. If zooming is in effect we treat it |
483 // like the control is styled. | 483 // like the control is styled. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 } | 578 } |
579 | 579 |
580 void LayoutThemeMac::updatePressedState(NSCell* cell, const LayoutObject* o) | 580 void LayoutThemeMac::updatePressedState(NSCell* cell, const LayoutObject* o) |
581 { | 581 { |
582 bool oldPressed = [cell isHighlighted]; | 582 bool oldPressed = [cell isHighlighted]; |
583 bool pressed = o->node() && o->node()->active(); | 583 bool pressed = o->node() && o->node()->active(); |
584 if (pressed != oldPressed) | 584 if (pressed != oldPressed) |
585 [cell setHighlighted:pressed]; | 585 [cell setHighlighted:pressed]; |
586 } | 586 } |
587 | 587 |
588 NSControlSize LayoutThemeMac::controlSizeForFont(const LayoutStyle& style) const | 588 NSControlSize LayoutThemeMac::controlSizeForFont(const ComputedStyle& style) con
st |
589 { | 589 { |
590 int fontSize = style.fontSize(); | 590 int fontSize = style.fontSize(); |
591 if (fontSize >= 16) | 591 if (fontSize >= 16) |
592 return NSRegularControlSize; | 592 return NSRegularControlSize; |
593 if (fontSize >= 11) | 593 if (fontSize >= 11) |
594 return NSSmallControlSize; | 594 return NSSmallControlSize; |
595 return NSMiniControlSize; | 595 return NSMiniControlSize; |
596 } | 596 } |
597 | 597 |
598 // We don't use controlSizeForFont() for search field decorations because it | 598 // We don't use controlSizeForFont() for search field decorations because it |
599 // needs to fit into the search field. The font size will already be modified by | 599 // needs to fit into the search field. The font size will already be modified by |
600 // setFontFromControlSize() called on the search field. | 600 // setFontFromControlSize() called on the search field. |
601 static NSControlSize searchFieldControlSizeForFont(const LayoutStyle& style) | 601 static NSControlSize searchFieldControlSizeForFont(const ComputedStyle& style) |
602 { | 602 { |
603 int fontSize = style.fontSize(); | 603 int fontSize = style.fontSize(); |
604 if (fontSize >= 13) | 604 if (fontSize >= 13) |
605 return NSRegularControlSize; | 605 return NSRegularControlSize; |
606 if (fontSize >= 11) | 606 if (fontSize >= 11) |
607 return NSSmallControlSize; | 607 return NSSmallControlSize; |
608 return NSMiniControlSize; | 608 return NSMiniControlSize; |
609 } | 609 } |
610 | 610 |
611 void LayoutThemeMac::setControlSize(NSCell* cell, const IntSize* sizes, const In
tSize& minSize, float zoomLevel) | 611 void LayoutThemeMac::setControlSize(NSCell* cell, const IntSize* sizes, const In
tSize& minSize, float zoomLevel) |
612 { | 612 { |
613 NSControlSize size; | 613 NSControlSize size; |
614 if (minSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width()
* zoomLevel) && | 614 if (minSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width()
* zoomLevel) && |
615 minSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height(
) * zoomLevel)) | 615 minSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height(
) * zoomLevel)) |
616 size = NSRegularControlSize; | 616 size = NSRegularControlSize; |
617 else if (minSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width
() * zoomLevel) && | 617 else if (minSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width
() * zoomLevel) && |
618 minSize.height() >= static_cast<int>(sizes[NSSmallControlSize].heig
ht() * zoomLevel)) | 618 minSize.height() >= static_cast<int>(sizes[NSSmallControlSize].heig
ht() * zoomLevel)) |
619 size = NSSmallControlSize; | 619 size = NSSmallControlSize; |
620 else | 620 else |
621 size = NSMiniControlSize; | 621 size = NSMiniControlSize; |
622 // Only update if we have to, since AppKit does work even if the size is the | 622 // Only update if we have to, since AppKit does work even if the size is the |
623 // same. | 623 // same. |
624 if (size != [cell controlSize]) | 624 if (size != [cell controlSize]) |
625 [cell setControlSize:size]; | 625 [cell setControlSize:size]; |
626 } | 626 } |
627 | 627 |
628 IntSize LayoutThemeMac::sizeForFont(const LayoutStyle& style, const IntSize* siz
es) const | 628 IntSize LayoutThemeMac::sizeForFont(const ComputedStyle& style, const IntSize* s
izes) const |
629 { | 629 { |
630 if (style.effectiveZoom() != 1.0f) { | 630 if (style.effectiveZoom() != 1.0f) { |
631 IntSize result = sizes[controlSizeForFont(style)]; | 631 IntSize result = sizes[controlSizeForFont(style)]; |
632 return IntSize(result.width() * style.effectiveZoom(), result.height() *
style.effectiveZoom()); | 632 return IntSize(result.width() * style.effectiveZoom(), result.height() *
style.effectiveZoom()); |
633 } | 633 } |
634 return sizes[controlSizeForFont(style)]; | 634 return sizes[controlSizeForFont(style)]; |
635 } | 635 } |
636 | 636 |
637 IntSize LayoutThemeMac::sizeForSystemFont(const LayoutStyle& style, const IntSiz
e* sizes) const | 637 IntSize LayoutThemeMac::sizeForSystemFont(const ComputedStyle& style, const IntS
ize* sizes) const |
638 { | 638 { |
639 if (style.effectiveZoom() != 1.0f) { | 639 if (style.effectiveZoom() != 1.0f) { |
640 IntSize result = sizes[controlSizeForSystemFont(style)]; | 640 IntSize result = sizes[controlSizeForSystemFont(style)]; |
641 return IntSize(result.width() * style.effectiveZoom(), result.height() *
style.effectiveZoom()); | 641 return IntSize(result.width() * style.effectiveZoom(), result.height() *
style.effectiveZoom()); |
642 } | 642 } |
643 return sizes[controlSizeForSystemFont(style)]; | 643 return sizes[controlSizeForSystemFont(style)]; |
644 } | 644 } |
645 | 645 |
646 void LayoutThemeMac::setSizeFromFont(LayoutStyle& style, const IntSize* sizes) c
onst | 646 void LayoutThemeMac::setSizeFromFont(ComputedStyle& style, const IntSize* sizes)
const |
647 { | 647 { |
648 // FIXME: Check is flawed, since it doesn't take min-width/max-width into | 648 // FIXME: Check is flawed, since it doesn't take min-width/max-width into |
649 // account. | 649 // account. |
650 IntSize size = sizeForFont(style, sizes); | 650 IntSize size = sizeForFont(style, sizes); |
651 if (style.width().isIntrinsicOrAuto() && size.width() > 0) | 651 if (style.width().isIntrinsicOrAuto() && size.width() > 0) |
652 style.setWidth(Length(size.width(), Fixed)); | 652 style.setWidth(Length(size.width(), Fixed)); |
653 if (style.height().isAuto() && size.height() > 0) | 653 if (style.height().isAuto() && size.height() > 0) |
654 style.setHeight(Length(size.height(), Fixed)); | 654 style.setHeight(Length(size.height(), Fixed)); |
655 } | 655 } |
656 | 656 |
657 void LayoutThemeMac::setFontFromControlSize(LayoutStyle& style, NSControlSize co
ntrolSize) const | 657 void LayoutThemeMac::setFontFromControlSize(ComputedStyle& style, NSControlSize
controlSize) const |
658 { | 658 { |
659 FontDescription fontDescription; | 659 FontDescription fontDescription; |
660 fontDescription.setIsAbsoluteSize(true); | 660 fontDescription.setIsAbsoluteSize(true); |
661 fontDescription.setGenericFamily(FontDescription::SerifFamily); | 661 fontDescription.setGenericFamily(FontDescription::SerifFamily); |
662 | 662 |
663 NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:controlSize]]; | 663 NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize
:controlSize]]; |
664 fontDescription.firstFamily().setFamily([font webCoreFamilyName]); | 664 fontDescription.firstFamily().setFamily([font webCoreFamilyName]); |
665 fontDescription.setComputedSize([font pointSize] * style.effectiveZoom()); | 665 fontDescription.setComputedSize([font pointSize] * style.effectiveZoom()); |
666 fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom()); | 666 fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom()); |
667 | 667 |
668 // Reset line height. | 668 // Reset line height. |
669 style.setLineHeight(LayoutStyle::initialLineHeight()); | 669 style.setLineHeight(ComputedStyle::initialLineHeight()); |
670 | 670 |
671 if (style.setFontDescription(fontDescription)) | 671 if (style.setFontDescription(fontDescription)) |
672 style.font().update(nullptr); | 672 style.font().update(nullptr); |
673 } | 673 } |
674 | 674 |
675 NSControlSize LayoutThemeMac::controlSizeForSystemFont(const LayoutStyle& style)
const | 675 NSControlSize LayoutThemeMac::controlSizeForSystemFont(const ComputedStyle& styl
e) const |
676 { | 676 { |
677 float fontSize = style.fontSize(); | 677 float fontSize = style.fontSize(); |
678 float zoomLevel = style.effectiveZoom(); | 678 float zoomLevel = style.effectiveZoom(); |
679 if (zoomLevel != 1) | 679 if (zoomLevel != 1) |
680 fontSize /= zoomLevel; | 680 fontSize /= zoomLevel; |
681 if (fontSize >= [NSFont systemFontSizeForControlSize:NSRegularControlSize]) | 681 if (fontSize >= [NSFont systemFontSizeForControlSize:NSRegularControlSize]) |
682 return NSRegularControlSize; | 682 return NSRegularControlSize; |
683 if (fontSize >= [NSFont systemFontSizeForControlSize:NSSmallControlSize]) | 683 if (fontSize >= [NSFont systemFontSizeForControlSize:NSSmallControlSize]) |
684 return NSSmallControlSize; | 684 return NSSmallControlSize; |
685 return NSMiniControlSize; | 685 return NSMiniControlSize; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 return NSRatingLevelIndicatorStyle; | 907 return NSRatingLevelIndicatorStyle; |
908 case MeterPart: | 908 case MeterPart: |
909 case ContinuousCapacityLevelIndicatorPart: | 909 case ContinuousCapacityLevelIndicatorPart: |
910 default: | 910 default: |
911 return NSContinuousCapacityLevelIndicatorStyle; | 911 return NSContinuousCapacityLevelIndicatorStyle; |
912 } | 912 } |
913 } | 913 } |
914 | 914 |
915 NSLevelIndicatorCell* LayoutThemeMac::levelIndicatorFor(const LayoutMeter* layou
tMeter) const | 915 NSLevelIndicatorCell* LayoutThemeMac::levelIndicatorFor(const LayoutMeter* layou
tMeter) const |
916 { | 916 { |
917 const LayoutStyle& style = layoutMeter->styleRef(); | 917 const ComputedStyle& style = layoutMeter->styleRef(); |
918 ASSERT(style.appearance() != NoControlPart); | 918 ASSERT(style.appearance() != NoControlPart); |
919 | 919 |
920 if (!m_levelIndicator) | 920 if (!m_levelIndicator) |
921 m_levelIndicator.adoptNS([[NSLevelIndicatorCell alloc] initWithLevelIndi
catorStyle:NSContinuousCapacityLevelIndicatorStyle]); | 921 m_levelIndicator.adoptNS([[NSLevelIndicatorCell alloc] initWithLevelIndi
catorStyle:NSContinuousCapacityLevelIndicatorStyle]); |
922 NSLevelIndicatorCell* cell = m_levelIndicator.get(); | 922 NSLevelIndicatorCell* cell = m_levelIndicator.get(); |
923 | 923 |
924 HTMLMeterElement* element = layoutMeter->meterElement(); | 924 HTMLMeterElement* element = layoutMeter->meterElement(); |
925 double value = element->value(); | 925 double value = element->value(); |
926 | 926 |
927 // Because NSLevelIndicatorCell does not support optimum-in-the-middle type | 927 // Because NSLevelIndicatorCell does not support optimum-in-the-middle type |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 { | 965 { |
966 static const int margins[3][4] = | 966 static const int margins[3][4] = |
967 { | 967 { |
968 { 0, 0, 1, 0 }, | 968 { 0, 0, 1, 0 }, |
969 { 0, 0, 1, 0 }, | 969 { 0, 0, 1, 0 }, |
970 { 0, 0, 1, 0 }, | 970 { 0, 0, 1, 0 }, |
971 }; | 971 }; |
972 return margins[controlSize]; | 972 return margins[controlSize]; |
973 } | 973 } |
974 | 974 |
975 int LayoutThemeMac::minimumProgressBarHeight(const LayoutStyle& style) const | 975 int LayoutThemeMac::minimumProgressBarHeight(const ComputedStyle& style) const |
976 { | 976 { |
977 return sizeForSystemFont(style, progressBarSizes()).height(); | 977 return sizeForSystemFont(style, progressBarSizes()).height(); |
978 } | 978 } |
979 | 979 |
980 double LayoutThemeMac::animationRepeatIntervalForProgressBar() const | 980 double LayoutThemeMac::animationRepeatIntervalForProgressBar() const |
981 { | 981 { |
982 return progressAnimationFrameRate; | 982 return progressAnimationFrameRate; |
983 } | 983 } |
984 | 984 |
985 double LayoutThemeMac::animationDurationForProgressBar() const | 985 double LayoutThemeMac::animationDurationForProgressBar() const |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 paintInfo.context->fillPolygon(3, arrow2, color, true); | 1090 paintInfo.context->fillPolygon(3, arrow2, color, true); |
1091 return false; | 1091 return false; |
1092 } | 1092 } |
1093 | 1093 |
1094 static const IntSize* menuListButtonSizes() | 1094 static const IntSize* menuListButtonSizes() |
1095 { | 1095 { |
1096 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0,
15) }; | 1096 static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0,
15) }; |
1097 return sizes; | 1097 return sizes; |
1098 } | 1098 } |
1099 | 1099 |
1100 void LayoutThemeMac::adjustMenuListStyle(LayoutStyle& style, Element* e) const | 1100 void LayoutThemeMac::adjustMenuListStyle(ComputedStyle& style, Element* e) const |
1101 { | 1101 { |
1102 NSControlSize controlSize = controlSizeForFont(style); | 1102 NSControlSize controlSize = controlSizeForFont(style); |
1103 | 1103 |
1104 style.resetBorder(); | 1104 style.resetBorder(); |
1105 style.resetPadding(); | 1105 style.resetPadding(); |
1106 | 1106 |
1107 // Height is locked to auto. | 1107 // Height is locked to auto. |
1108 style.setHeight(Length(Auto)); | 1108 style.setHeight(Length(Auto)); |
1109 | 1109 |
1110 // White-space is locked to pre. | 1110 // White-space is locked to pre. |
(...skipping 15 matching lines...) Expand all Loading... |
1126 } | 1126 } |
1127 | 1127 |
1128 const int autofillPopupHorizontalPadding = 4; | 1128 const int autofillPopupHorizontalPadding = 4; |
1129 | 1129 |
1130 // These functions are called with MenuListPart or MenulistButtonPart appearance | 1130 // These functions are called with MenuListPart or MenulistButtonPart appearance |
1131 // by LayoutMenuList, or with TextFieldPart appearance by | 1131 // by LayoutMenuList, or with TextFieldPart appearance by |
1132 // AutofillPopupMenuClient. We assume only AutofillPopupMenuClient gives | 1132 // AutofillPopupMenuClient. We assume only AutofillPopupMenuClient gives |
1133 // TexfieldPart appearance here. We want to change only Autofill padding. In | 1133 // TexfieldPart appearance here. We want to change only Autofill padding. In |
1134 // the future, we have to separate Autofill popup window logic from WebKit to | 1134 // the future, we have to separate Autofill popup window logic from WebKit to |
1135 // Chromium. | 1135 // Chromium. |
1136 int LayoutThemeMac::popupInternalPaddingLeft(const LayoutStyle& style) const | 1136 int LayoutThemeMac::popupInternalPaddingLeft(const ComputedStyle& style) const |
1137 { | 1137 { |
1138 if (style.appearance() == TextFieldPart) | 1138 if (style.appearance() == TextFieldPart) |
1139 return autofillPopupHorizontalPadding; | 1139 return autofillPopupHorizontalPadding; |
1140 | 1140 |
1141 if (style.appearance() == MenulistPart) | 1141 if (style.appearance() == MenulistPart) |
1142 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::LeftMargi
n] * style.effectiveZoom(); | 1142 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::LeftMargi
n] * style.effectiveZoom(); |
1143 if (style.appearance() == MenulistButtonPart) | 1143 if (style.appearance() == MenulistButtonPart) |
1144 return styledPopupPaddingLeft * style.effectiveZoom(); | 1144 return styledPopupPaddingLeft * style.effectiveZoom(); |
1145 return 0; | 1145 return 0; |
1146 } | 1146 } |
1147 | 1147 |
1148 int LayoutThemeMac::popupInternalPaddingRight(const LayoutStyle& style) const | 1148 int LayoutThemeMac::popupInternalPaddingRight(const ComputedStyle& style) const |
1149 { | 1149 { |
1150 if (style.appearance() == TextFieldPart) | 1150 if (style.appearance() == TextFieldPart) |
1151 return autofillPopupHorizontalPadding; | 1151 return autofillPopupHorizontalPadding; |
1152 | 1152 |
1153 if (style.appearance() == MenulistPart) | 1153 if (style.appearance() == MenulistPart) |
1154 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::RightMarg
in] * style.effectiveZoom(); | 1154 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::RightMarg
in] * style.effectiveZoom(); |
1155 if (style.appearance() == MenulistButtonPart) { | 1155 if (style.appearance() == MenulistButtonPart) { |
1156 float fontScale = style.fontSize() / baseFontSize; | 1156 float fontScale = style.fontSize() / baseFontSize; |
1157 float arrowWidth = baseArrowWidth * fontScale; | 1157 float arrowWidth = baseArrowWidth * fontScale; |
1158 return static_cast<int>(ceilf(arrowWidth + (arrowPaddingLeft + arrowPadd
ingRight + paddingBeforeSeparator) * style.effectiveZoom())); | 1158 return static_cast<int>(ceilf(arrowWidth + (arrowPaddingLeft + arrowPadd
ingRight + paddingBeforeSeparator) * style.effectiveZoom())); |
1159 } | 1159 } |
1160 return 0; | 1160 return 0; |
1161 } | 1161 } |
1162 | 1162 |
1163 int LayoutThemeMac::popupInternalPaddingTop(const LayoutStyle& style) const | 1163 int LayoutThemeMac::popupInternalPaddingTop(const ComputedStyle& style) const |
1164 { | 1164 { |
1165 if (style.appearance() == MenulistPart) | 1165 if (style.appearance() == MenulistPart) |
1166 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::TopMargin
] * style.effectiveZoom(); | 1166 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::TopMargin
] * style.effectiveZoom(); |
1167 if (style.appearance() == MenulistButtonPart) | 1167 if (style.appearance() == MenulistButtonPart) |
1168 return styledPopupPaddingTop * style.effectiveZoom(); | 1168 return styledPopupPaddingTop * style.effectiveZoom(); |
1169 return 0; | 1169 return 0; |
1170 } | 1170 } |
1171 | 1171 |
1172 int LayoutThemeMac::popupInternalPaddingBottom(const LayoutStyle& style) const | 1172 int LayoutThemeMac::popupInternalPaddingBottom(const ComputedStyle& style) const |
1173 { | 1173 { |
1174 if (style.appearance() == MenulistPart) | 1174 if (style.appearance() == MenulistPart) |
1175 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::BottomMar
gin] * style.effectiveZoom(); | 1175 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::BottomMar
gin] * style.effectiveZoom(); |
1176 if (style.appearance() == MenulistButtonPart) | 1176 if (style.appearance() == MenulistButtonPart) |
1177 return styledPopupPaddingBottom * style.effectiveZoom(); | 1177 return styledPopupPaddingBottom * style.effectiveZoom(); |
1178 return 0; | 1178 return 0; |
1179 } | 1179 } |
1180 | 1180 |
1181 void LayoutThemeMac::adjustMenuListButtonStyle(LayoutStyle& style, Element*) con
st | 1181 void LayoutThemeMac::adjustMenuListButtonStyle(ComputedStyle& style, Element*) c
onst |
1182 { | 1182 { |
1183 float fontScale = style.fontSize() / baseFontSize; | 1183 float fontScale = style.fontSize() / baseFontSize; |
1184 | 1184 |
1185 style.resetPadding(); | 1185 style.resetPadding(); |
1186 style.setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(bas
eBorderRadius + fontScale - 1))); // FIXME: Round up? | 1186 style.setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(bas
eBorderRadius + fontScale - 1))); // FIXME: Round up? |
1187 | 1187 |
1188 const int minHeight = 15; | 1188 const int minHeight = 15; |
1189 style.setMinHeight(Length(minHeight, Fixed)); | 1189 style.setMinHeight(Length(minHeight, Fixed)); |
1190 | 1190 |
1191 style.setLineHeight(LayoutStyle::initialLineHeight()); | 1191 style.setLineHeight(ComputedStyle::initialLineHeight()); |
1192 } | 1192 } |
1193 | 1193 |
1194 void LayoutThemeMac::setPopupButtonCellState(const LayoutObject* o, const IntRec
t& r) | 1194 void LayoutThemeMac::setPopupButtonCellState(const LayoutObject* o, const IntRec
t& r) |
1195 { | 1195 { |
1196 NSPopUpButtonCell* popupButton = this->popupButton(); | 1196 NSPopUpButtonCell* popupButton = this->popupButton(); |
1197 | 1197 |
1198 // Set the control size based off the rectangle we're painting into. | 1198 // Set the control size based off the rectangle we're painting into. |
1199 setControlSize(popupButton, popupButtonSizes(), r.size(), o->style()->effect
iveZoom()); | 1199 setControlSize(popupButton, popupButtonSizes(), r.size(), o->style()->effect
iveZoom()); |
1200 | 1200 |
1201 // Update the various states we respond to. | 1201 // Update the various states we respond to. |
1202 updateActiveState(popupButton, o); | 1202 updateActiveState(popupButton, o); |
1203 updateCheckedState(popupButton, o); | 1203 updateCheckedState(popupButton, o); |
1204 updateEnabledState(popupButton, o); | 1204 updateEnabledState(popupButton, o); |
1205 updatePressedState(popupButton, o); | 1205 updatePressedState(popupButton, o); |
1206 #if BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING | 1206 #if BUTTON_CELL_DRAW_WITH_FRAME_DRAWS_FOCUS_RING |
1207 updateFocusedState(popupButton, o); | 1207 updateFocusedState(popupButton, o); |
1208 #endif | 1208 #endif |
1209 } | 1209 } |
1210 | 1210 |
1211 const IntSize* LayoutThemeMac::menuListSizes() const | 1211 const IntSize* LayoutThemeMac::menuListSizes() const |
1212 { | 1212 { |
1213 static const IntSize sizes[3] = { IntSize(9, 0), IntSize(5, 0), IntSize(0, 0
) }; | 1213 static const IntSize sizes[3] = { IntSize(9, 0), IntSize(5, 0), IntSize(0, 0
) }; |
1214 return sizes; | 1214 return sizes; |
1215 } | 1215 } |
1216 | 1216 |
1217 int LayoutThemeMac::minimumMenuListSize(const LayoutStyle& style) const | 1217 int LayoutThemeMac::minimumMenuListSize(const ComputedStyle& style) const |
1218 { | 1218 { |
1219 return sizeForSystemFont(style, menuListSizes()).width(); | 1219 return sizeForSystemFont(style, menuListSizes()).width(); |
1220 } | 1220 } |
1221 | 1221 |
1222 const int sliderTrackWidth = 5; | 1222 const int sliderTrackWidth = 5; |
1223 const int sliderTrackBorderWidth = 1; | 1223 const int sliderTrackBorderWidth = 1; |
1224 | 1224 |
1225 bool LayoutThemeMac::paintSliderTrack(LayoutObject* o, const PaintInfo& paintInf
o, const IntRect& r) | 1225 bool LayoutThemeMac::paintSliderTrack(LayoutObject* o, const PaintInfo& paintInf
o, const IntRect& r) |
1226 { | 1226 { |
1227 paintSliderTicks(o, paintInfo, r); | 1227 paintSliderTicks(o, paintInfo, r); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 static const IntSize sizes[3] = { IntSize(0, 22), IntSize(0, 19), IntSize(0,
15) }; | 1426 static const IntSize sizes[3] = { IntSize(0, 22), IntSize(0, 19), IntSize(0,
15) }; |
1427 return sizes; | 1427 return sizes; |
1428 } | 1428 } |
1429 | 1429 |
1430 static const int* searchFieldHorizontalPaddings() | 1430 static const int* searchFieldHorizontalPaddings() |
1431 { | 1431 { |
1432 static const int sizes[3] = { 3, 2, 1 }; | 1432 static const int sizes[3] = { 3, 2, 1 }; |
1433 return sizes; | 1433 return sizes; |
1434 } | 1434 } |
1435 | 1435 |
1436 void LayoutThemeMac::setSearchFieldSize(LayoutStyle& style) const | 1436 void LayoutThemeMac::setSearchFieldSize(ComputedStyle& style) const |
1437 { | 1437 { |
1438 // If the width and height are both specified, then we have nothing to do. | 1438 // If the width and height are both specified, then we have nothing to do. |
1439 if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto()) | 1439 if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto()) |
1440 return; | 1440 return; |
1441 | 1441 |
1442 // Use the font size to determine the intrinsic width of the control. | 1442 // Use the font size to determine the intrinsic width of the control. |
1443 setSizeFromFont(style, searchFieldSizes()); | 1443 setSizeFromFont(style, searchFieldSizes()); |
1444 } | 1444 } |
1445 | 1445 |
1446 const int searchFieldBorderWidth = 2; | 1446 const int searchFieldBorderWidth = 2; |
1447 void LayoutThemeMac::adjustSearchFieldStyle(LayoutStyle& style, Element*) const | 1447 void LayoutThemeMac::adjustSearchFieldStyle(ComputedStyle& style, Element*) cons
t |
1448 { | 1448 { |
1449 // Override border. | 1449 // Override border. |
1450 style.resetBorder(); | 1450 style.resetBorder(); |
1451 const short borderWidth = searchFieldBorderWidth * style.effectiveZoom(); | 1451 const short borderWidth = searchFieldBorderWidth * style.effectiveZoom(); |
1452 style.setBorderLeftWidth(borderWidth); | 1452 style.setBorderLeftWidth(borderWidth); |
1453 style.setBorderLeftStyle(INSET); | 1453 style.setBorderLeftStyle(INSET); |
1454 style.setBorderRightWidth(borderWidth); | 1454 style.setBorderRightWidth(borderWidth); |
1455 style.setBorderRightStyle(INSET); | 1455 style.setBorderRightStyle(INSET); |
1456 style.setBorderBottomWidth(borderWidth); | 1456 style.setBorderBottomWidth(borderWidth); |
1457 style.setBorderBottomStyle(INSET); | 1457 style.setBorderBottomStyle(INSET); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 | 1533 |
1534 return false; | 1534 return false; |
1535 } | 1535 } |
1536 | 1536 |
1537 const IntSize* LayoutThemeMac::cancelButtonSizes() const | 1537 const IntSize* LayoutThemeMac::cancelButtonSizes() const |
1538 { | 1538 { |
1539 static const IntSize sizes[3] = { IntSize(14, 14), IntSize(11, 11), IntSize(
9, 9) }; | 1539 static const IntSize sizes[3] = { IntSize(14, 14), IntSize(11, 11), IntSize(
9, 9) }; |
1540 return sizes; | 1540 return sizes; |
1541 } | 1541 } |
1542 | 1542 |
1543 void LayoutThemeMac::adjustSearchFieldCancelButtonStyle(LayoutStyle& style, Elem
ent*) const | 1543 void LayoutThemeMac::adjustSearchFieldCancelButtonStyle(ComputedStyle& style, El
ement*) const |
1544 { | 1544 { |
1545 IntSize size = sizeForSystemFont(style, cancelButtonSizes()); | 1545 IntSize size = sizeForSystemFont(style, cancelButtonSizes()); |
1546 style.setWidth(Length(size.width(), Fixed)); | 1546 style.setWidth(Length(size.width(), Fixed)); |
1547 style.setHeight(Length(size.height(), Fixed)); | 1547 style.setHeight(Length(size.height(), Fixed)); |
1548 style.setBoxShadow(nullptr); | 1548 style.setBoxShadow(nullptr); |
1549 } | 1549 } |
1550 | 1550 |
1551 const IntSize* LayoutThemeMac::resultsButtonSizes() const | 1551 const IntSize* LayoutThemeMac::resultsButtonSizes() const |
1552 { | 1552 { |
1553 static const IntSize sizes[3] = { IntSize(15, 14), IntSize(16, 13), IntSize(
14, 11) }; | 1553 static const IntSize sizes[3] = { IntSize(15, 14), IntSize(16, 13), IntSize(
14, 11) }; |
1554 return sizes; | 1554 return sizes; |
1555 } | 1555 } |
1556 | 1556 |
1557 void LayoutThemeMac::adjustSearchFieldDecorationStyle(LayoutStyle& style, Elemen
t*) const | 1557 void LayoutThemeMac::adjustSearchFieldDecorationStyle(ComputedStyle& style, Elem
ent*) const |
1558 { | 1558 { |
1559 NSControlSize controlSize = controlSizeForSystemFont(style); | 1559 NSControlSize controlSize = controlSizeForSystemFont(style); |
1560 IntSize searchFieldSize = searchFieldSizes()[controlSize]; | 1560 IntSize searchFieldSize = searchFieldSizes()[controlSize]; |
1561 int width = searchFieldSize.height() / 2 - searchFieldBorderWidth - searchFi
eldHorizontalPaddings()[controlSize]; | 1561 int width = searchFieldSize.height() / 2 - searchFieldBorderWidth - searchFi
eldHorizontalPaddings()[controlSize]; |
1562 style.setWidth(Length(width, Fixed)); | 1562 style.setWidth(Length(width, Fixed)); |
1563 style.setHeight(Length(0, Fixed)); | 1563 style.setHeight(Length(0, Fixed)); |
1564 style.setBoxShadow(nullptr); | 1564 style.setBoxShadow(nullptr); |
1565 } | 1565 } |
1566 | 1566 |
1567 bool LayoutThemeMac::paintSearchFieldDecoration(LayoutObject*, const PaintInfo&,
const IntRect&) | 1567 bool LayoutThemeMac::paintSearchFieldDecoration(LayoutObject*, const PaintInfo&,
const IntRect&) |
1568 { | 1568 { |
1569 return false; | 1569 return false; |
1570 } | 1570 } |
1571 | 1571 |
1572 void LayoutThemeMac::adjustSearchFieldResultsDecorationStyle(LayoutStyle& style,
Element*) const | 1572 void LayoutThemeMac::adjustSearchFieldResultsDecorationStyle(ComputedStyle& styl
e, Element*) const |
1573 { | 1573 { |
1574 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); | 1574 IntSize size = sizeForSystemFont(style, resultsButtonSizes()); |
1575 style.setWidth(Length(size.width(), Fixed)); | 1575 style.setWidth(Length(size.width(), Fixed)); |
1576 style.setHeight(Length(size.height(), Fixed)); | 1576 style.setHeight(Length(size.height(), Fixed)); |
1577 style.setBoxShadow(nullptr); | 1577 style.setBoxShadow(nullptr); |
1578 } | 1578 } |
1579 | 1579 |
1580 bool LayoutThemeMac::paintSearchFieldResultsDecoration(LayoutObject* o, const Pa
intInfo& paintInfo, const IntRect& r) | 1580 bool LayoutThemeMac::paintSearchFieldResultsDecoration(LayoutObject* o, const Pa
intInfo& paintInfo, const IntRect& r) |
1581 { | 1581 { |
1582 if (!o->node()) | 1582 if (!o->node()) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 IntSize LayoutThemeMac::sliderTickSize() const | 1617 IntSize LayoutThemeMac::sliderTickSize() const |
1618 { | 1618 { |
1619 return IntSize(1, 3); | 1619 return IntSize(1, 3); |
1620 } | 1620 } |
1621 | 1621 |
1622 int LayoutThemeMac::sliderTickOffsetFromTrackCenter() const | 1622 int LayoutThemeMac::sliderTickOffsetFromTrackCenter() const |
1623 { | 1623 { |
1624 return -9; | 1624 return -9; |
1625 } | 1625 } |
1626 | 1626 |
1627 void LayoutThemeMac::adjustSliderThumbSize(LayoutStyle& style, Element*) const | 1627 void LayoutThemeMac::adjustSliderThumbSize(ComputedStyle& style, Element*) const |
1628 { | 1628 { |
1629 float zoomLevel = style.effectiveZoom(); | 1629 float zoomLevel = style.effectiveZoom(); |
1630 if (style.appearance() == SliderThumbHorizontalPart || style.appearance() ==
SliderThumbVerticalPart) { | 1630 if (style.appearance() == SliderThumbHorizontalPart || style.appearance() ==
SliderThumbVerticalPart) { |
1631 style.setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLevel), Fi
xed)); | 1631 style.setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLevel), Fi
xed)); |
1632 style.setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLevel),
Fixed)); | 1632 style.setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLevel),
Fixed)); |
1633 } | 1633 } |
1634 | 1634 |
1635 adjustMediaSliderThumbSize(style); | 1635 adjustMediaSliderThumbSize(style); |
1636 } | 1636 } |
1637 | 1637 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 | 1756 |
1757 if (tint != oldTint) | 1757 if (tint != oldTint) |
1758 [cell setControlTint:tint]; | 1758 [cell setControlTint:tint]; |
1759 } | 1759 } |
1760 | 1760 |
1761 bool LayoutThemeMac::shouldShowPlaceholderWhenFocused() const | 1761 bool LayoutThemeMac::shouldShowPlaceholderWhenFocused() const |
1762 { | 1762 { |
1763 return true; | 1763 return true; |
1764 } | 1764 } |
1765 | 1765 |
1766 void LayoutThemeMac::adjustMediaSliderThumbSize(LayoutStyle& style) const | 1766 void LayoutThemeMac::adjustMediaSliderThumbSize(ComputedStyle& style) const |
1767 { | 1767 { |
1768 LayoutMediaControls::adjustMediaSliderThumbSize(style); | 1768 LayoutMediaControls::adjustMediaSliderThumbSize(style); |
1769 } | 1769 } |
1770 | 1770 |
1771 bool LayoutThemeMac::paintMediaPlayButton(LayoutObject* object, const PaintInfo&
paintInfo, const IntRect& rect) | 1771 bool LayoutThemeMac::paintMediaPlayButton(LayoutObject* object, const PaintInfo&
paintInfo, const IntRect& rect) |
1772 { | 1772 { |
1773 return LayoutMediaControls::paintMediaControlsPart(MediaPlayButton, object,
paintInfo, rect); | 1773 return LayoutMediaControls::paintMediaControlsPart(MediaPlayButton, object,
paintInfo, rect); |
1774 } | 1774 } |
1775 | 1775 |
1776 bool LayoutThemeMac::paintMediaOverlayPlayButton(LayoutObject* object, const Pai
ntInfo& paintInfo, const IntRect& rect) | 1776 bool LayoutThemeMac::paintMediaOverlayPlayButton(LayoutObject* object, const Pai
ntInfo& paintInfo, const IntRect& rect) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 bool LayoutThemeMac::paintMediaFullscreenButton(LayoutObject* object, const Pain
tInfo& paintInfo, const IntRect& rect) | 1835 bool LayoutThemeMac::paintMediaFullscreenButton(LayoutObject* object, const Pain
tInfo& paintInfo, const IntRect& rect) |
1836 { | 1836 { |
1837 return LayoutMediaControls::paintMediaControlsPart(MediaEnterFullscreenButto
n, object, paintInfo, rect); | 1837 return LayoutMediaControls::paintMediaControlsPart(MediaEnterFullscreenButto
n, object, paintInfo, rect); |
1838 } | 1838 } |
1839 | 1839 |
1840 bool LayoutThemeMac::paintMediaToggleClosedCaptionsButton(LayoutObject* object,
const PaintInfo& paintInfo, const IntRect& rect) | 1840 bool LayoutThemeMac::paintMediaToggleClosedCaptionsButton(LayoutObject* object,
const PaintInfo& paintInfo, const IntRect& rect) |
1841 { | 1841 { |
1842 return LayoutMediaControls::paintMediaControlsPart(MediaShowClosedCaptionsBu
tton, object, paintInfo, rect); | 1842 return LayoutMediaControls::paintMediaControlsPart(MediaShowClosedCaptionsBu
tton, object, paintInfo, rect); |
1843 } | 1843 } |
1844 | 1844 |
1845 bool LayoutThemeMac::shouldUseFallbackTheme(const LayoutStyle& style) const | 1845 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const |
1846 { | 1846 { |
1847 ControlPart part = style.appearance(); | 1847 ControlPart part = style.appearance(); |
1848 if (part == CheckboxPart || part == RadioPart) | 1848 if (part == CheckboxPart || part == RadioPart) |
1849 return style.effectiveZoom() != 1; | 1849 return style.effectiveZoom() != 1; |
1850 return false; | 1850 return false; |
1851 } | 1851 } |
1852 | 1852 |
1853 } // namespace blink | 1853 } // namespace blink |
OLD | NEW |