Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/rendering/RenderThemeChromiumFontProvider.h" | 27 #include "core/rendering/RenderThemeChromiumFontProvider.h" |
| 28 | 28 |
| 29 #include "core/CSSValueKeywords.h" | 29 #include "core/CSSValueKeywords.h" |
| 30 #include "platform/fonts/FontCache.h" | |
| 30 #include "platform/fonts/FontDescription.h" | 31 #include "platform/fonts/FontDescription.h" |
| 31 #include "platform/win/HWndDC.h" | 32 #include "platform/win/HWndDC.h" |
| 32 #include "platform/win/SystemInfo.h" | 33 #include "platform/win/SystemInfo.h" |
| 33 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
| 34 #include <windows.h> | 35 #include <windows.h> |
| 35 | 36 |
| 36 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(structName, member) \ | 37 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(structName, member) \ |
| 37 offsetof(structName, member) + \ | 38 offsetof(structName, member) + \ |
| 38 (sizeof static_cast<structName*>(0)->member) | 39 (sizeof static_cast<structName*>(0)->member) |
| 39 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ | 40 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 } | 101 } |
| 101 | 102 |
| 102 // static | 103 // static |
| 103 void RenderThemeChromiumFontProvider::systemFont(CSSValueID systemFontID, FontSt yle& fontStyle, FontWeight& fontWeight, float& fontSize, AtomicString& fontFamil y) | 104 void RenderThemeChromiumFontProvider::systemFont(CSSValueID systemFontID, FontSt yle& fontStyle, FontWeight& fontWeight, float& fontSize, AtomicString& fontFamil y) |
| 104 { | 105 { |
| 105 fontStyle = FontStyleNormal; | 106 fontStyle = FontStyleNormal; |
| 106 fontWeight = FontWeightNormal; | 107 fontWeight = FontWeightNormal; |
| 107 | 108 |
| 108 switch (systemFontID) { | 109 switch (systemFontID) { |
| 109 case CSSValueSmallCaption: { | 110 case CSSValueSmallCaption: { |
| 110 NONCLIENTMETRICS metrics; | 111 fontSize = FontCache::smallCaptionFontHeight(); |
| 111 getNonClientMetrics(&metrics); | 112 if (fontSize) { |
| 112 fontSize = systemFontSize(metrics.lfSmCaptionFont); | 113 fontFamily = AtomicString(FontCache::smallCaptionFontFamily()); |
|
scottmg
2015/01/06 23:15:23
Since they're only used as AtomicString, maybe sto
| |
| 113 fontFamily = AtomicString(metrics.lfSmCaptionFont.lfFaceName, wcslen(met rics.lfSmCaptionFont.lfFaceName)); | 114 } else { |
| 115 NONCLIENTMETRICS metrics; | |
| 116 getNonClientMetrics(&metrics); | |
| 117 fontSize = systemFontSize(metrics.lfSmCaptionFont); | |
| 118 fontFamily = AtomicString(metrics.lfSmCaptionFont.lfFaceName, wcslen (metrics.lfSmCaptionFont.lfFaceName)); | |
| 119 } | |
| 114 break; | 120 break; |
| 115 } | 121 } |
| 116 case CSSValueMenu: { | 122 case CSSValueMenu: { |
| 117 NONCLIENTMETRICS metrics; | 123 fontSize = FontCache::menuFontHeight(); |
| 118 getNonClientMetrics(&metrics); | 124 if (fontSize) { |
| 119 fontSize = systemFontSize(metrics.lfMenuFont); | 125 fontFamily = AtomicString(FontCache::menuFontFamily()); |
| 120 fontFamily = AtomicString(metrics.lfMenuFont.lfFaceName, wcslen(metrics. lfMenuFont.lfFaceName)); | 126 } else { |
| 127 NONCLIENTMETRICS metrics; | |
| 128 getNonClientMetrics(&metrics); | |
| 129 fontSize = systemFontSize(metrics.lfMenuFont); | |
| 130 fontFamily = AtomicString(metrics.lfMenuFont.lfFaceName, wcslen(metr ics.lfMenuFont.lfFaceName)); | |
| 131 } | |
| 121 break; | 132 break; |
| 122 } | 133 } |
| 123 case CSSValueStatusBar: { | 134 case CSSValueStatusBar: { |
| 124 NONCLIENTMETRICS metrics; | 135 fontSize = FontCache::statusFontHeight(); |
| 125 getNonClientMetrics(&metrics); | 136 if (fontSize) { |
| 126 fontSize = systemFontSize(metrics.lfStatusFont); | 137 fontFamily = AtomicString(FontCache::statusFontFamily()); |
| 127 fontFamily = metrics.lfStatusFont.lfFaceName; | 138 } else { |
| 139 NONCLIENTMETRICS metrics; | |
| 140 getNonClientMetrics(&metrics); | |
| 141 fontSize = systemFontSize(metrics.lfStatusFont); | |
| 142 fontFamily = metrics.lfStatusFont.lfFaceName; | |
| 143 } | |
| 128 break; | 144 break; |
| 129 } | 145 } |
| 130 case CSSValueWebkitMiniControl: | 146 case CSSValueWebkitMiniControl: |
| 131 case CSSValueWebkitSmallControl: | 147 case CSSValueWebkitSmallControl: |
| 132 case CSSValueWebkitControl: | 148 case CSSValueWebkitControl: |
| 133 // Why 2 points smaller? Because that's what Gecko does. | 149 // Why 2 points smaller? Because that's what Gecko does. |
| 134 fontSize = s_defaultFontSize - pointsToPixels(2); | 150 fontSize = s_defaultFontSize - pointsToPixels(2); |
| 135 fontFamily = defaultGUIFont(); | 151 fontFamily = defaultGUIFont(); |
| 136 break; | 152 break; |
| 137 default: | 153 default: |
| 138 fontSize = s_defaultFontSize; | 154 fontSize = s_defaultFontSize; |
| 139 fontFamily = defaultGUIFont(); | 155 fontFamily = defaultGUIFont(); |
| 140 break; | 156 break; |
| 141 } | 157 } |
| 142 } | 158 } |
| 143 | 159 |
| 144 // static | 160 // static |
| 145 void RenderThemeChromiumFontProvider::setDefaultFontSize(int fontSize) | 161 void RenderThemeChromiumFontProvider::setDefaultFontSize(int fontSize) |
| 146 { | 162 { |
| 147 s_defaultFontSize = static_cast<float>(fontSize); | 163 s_defaultFontSize = static_cast<float>(fontSize); |
| 148 } | 164 } |
| 149 | 165 |
| 150 } // namespace blink | 166 } // namespace blink |
| OLD | NEW |