Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutThemeMac.mm

Issue 2224063003: LayoutTheme: Clean up popupInternalPadding* functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutThemeMac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 setFontFromControlSize(style, controlSize); 750 setFontFromControlSize(style, controlSize);
751 } 751 }
752 752
753 static const int baseBorderRadius = 5; 753 static const int baseBorderRadius = 5;
754 static const int styledPopupPaddingStart = 8; 754 static const int styledPopupPaddingStart = 8;
755 static const int styledPopupPaddingTop = 1; 755 static const int styledPopupPaddingTop = 1;
756 static const int styledPopupPaddingBottom = 2; 756 static const int styledPopupPaddingBottom = 2;
757 757
758 // These functions are called with MenuListPart or MenulistButtonPart appearance 758 // These functions are called with MenuListPart or MenulistButtonPart appearance
759 // by LayoutMenuList. 759 // by LayoutMenuList.
760 int LayoutThemeMac::popupInternalPaddingLeft(const ComputedStyle& style) const 760 int LayoutThemeMac::popupInternalPaddingStart(const ComputedStyle& style) const
761 { 761 {
762 bool isRTL = style.direction() == RTL;
763 if (style.appearance() == MenulistPart) 762 if (style.appearance() == MenulistPart)
764 return popupButtonPadding(controlSizeForFont(style))[isRTL ? ThemeMac::R ightMargin : ThemeMac::LeftMargin] * style.effectiveZoom(); 763 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::LeftMargi n] * style.effectiveZoom();
764 if (style.appearance() == MenulistButtonPart)
765 return styledPopupPaddingStart * style.effectiveZoom();
766 return 0;
767 }
768
769 int LayoutThemeMac::popupInternalPaddingEnd(const ComputedStyle& style) const
770 {
771 if (style.appearance() == MenulistPart)
772 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::RightMarg in] * style.effectiveZoom();
765 if (style.appearance() != MenulistButtonPart) 773 if (style.appearance() != MenulistButtonPart)
766 return 0; 774 return 0;
767 if (isRTL) {
768 float fontScale = style.fontSize() / baseFontSize;
769 float arrowWidth = menuListBaseArrowWidth * fontScale;
770 return static_cast<int>(ceilf(arrowWidth + (menuListArrowPaddingStart + menuListArrowPaddingEnd) * style.effectiveZoom()));
771 }
772 return styledPopupPaddingStart * style.effectiveZoom();
773 }
774
775 int LayoutThemeMac::popupInternalPaddingRight(const ComputedStyle& style) const
776 {
777 bool isRTL = style.direction() == RTL;
778 if (style.appearance() == MenulistPart)
779 return popupButtonPadding(controlSizeForFont(style))[isRTL ? ThemeMac::L eftMargin : ThemeMac::RightMargin] * style.effectiveZoom();
780 if (style.appearance() != MenulistButtonPart)
781 return 0;
782 if (isRTL) {
783 return styledPopupPaddingStart * style.effectiveZoom();
784 }
785 float fontScale = style.fontSize() / baseFontSize; 775 float fontScale = style.fontSize() / baseFontSize;
786 float arrowWidth = menuListBaseArrowWidth * fontScale; 776 float arrowWidth = menuListBaseArrowWidth * fontScale;
787 return static_cast<int>(ceilf(arrowWidth + (menuListArrowPaddingStart + menu ListArrowPaddingEnd) * style.effectiveZoom())); 777 return static_cast<int>(ceilf(arrowWidth + (menuListArrowPaddingStart + menu ListArrowPaddingEnd) * style.effectiveZoom()));
788 } 778 }
789 779
790 int LayoutThemeMac::popupInternalPaddingTop(const ComputedStyle& style) const 780 int LayoutThemeMac::popupInternalPaddingTop(const ComputedStyle& style) const
791 { 781 {
792 if (style.appearance() == MenulistPart) 782 if (style.appearance() == MenulistPart)
793 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::TopMargin ] * style.effectiveZoom(); 783 return popupButtonPadding(controlSizeForFont(style))[ThemeMac::TopMargin ] * style.effectiveZoom();
794 if (style.appearance() == MenulistButtonPart) 784 if (style.appearance() == MenulistButtonPart)
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 1106
1117 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const 1107 bool LayoutThemeMac::shouldUseFallbackTheme(const ComputedStyle& style) const
1118 { 1108 {
1119 ControlPart part = style.appearance(); 1109 ControlPart part = style.appearance();
1120 if (part == CheckboxPart || part == RadioPart) 1110 if (part == CheckboxPart || part == RadioPart)
1121 return style.effectiveZoom() != 1; 1111 return style.effectiveZoom() != 1;
1122 return false; 1112 return false;
1123 } 1113 }
1124 1114
1125 } // namespace blink 1115 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutThemeMac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698