OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. | 2 * Copyright (C) 2007 Apple Inc. |
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
4 * Copyright (C) 2008 Collabora Ltd. | 4 * Copyright (C) 2008 Collabora Ltd. |
5 * Copyright (C) 2008, 2009 Google Inc. | 5 * Copyright (C) 2008, 2009 Google Inc. |
6 * Copyright (C) 2009 Kenneth Rohde Christiansen | 6 * Copyright (C) 2009 Kenneth Rohde Christiansen |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 10 matching lines...) Expand all Loading... |
21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "core/layout/LayoutThemeDefault.h" | 25 #include "core/layout/LayoutThemeDefault.h" |
26 | 26 |
27 #include "core/CSSValueKeywords.h" | 27 #include "core/CSSValueKeywords.h" |
28 #include "core/layout/LayoutThemeFontProvider.h" | 28 #include "core/layout/LayoutThemeFontProvider.h" |
29 #include "core/paint/MediaControlsPainter.h" | 29 #include "core/paint/MediaControlsPainter.h" |
30 #include "core/style/ComputedStyle.h" | 30 #include "core/style/ComputedStyle.h" |
| 31 #include "platform/HostWindow.h" |
31 #include "platform/LayoutTestSupport.h" | 32 #include "platform/LayoutTestSupport.h" |
32 #include "platform/PlatformResourceLoader.h" | 33 #include "platform/PlatformResourceLoader.h" |
33 #include "platform/graphics/Color.h" | 34 #include "platform/graphics/Color.h" |
34 #include "public/platform/Platform.h" | 35 #include "public/platform/Platform.h" |
35 #include "public/platform/WebThemeEngine.h" | 36 #include "public/platform/WebThemeEngine.h" |
36 #include "wtf/text/StringBuilder.h" | 37 #include "wtf/text/StringBuilder.h" |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 // These values all match Safari/Win. | 41 // These values all match Safari/Win. |
41 static const float defaultControlFontPixelSize = 13; | 42 static const float defaultControlFontPixelSize = 13; |
42 static const float defaultCancelButtonSize = 9; | 43 static const float defaultCancelButtonSize = 9; |
43 static const float minCancelButtonSize = 5; | 44 static const float minCancelButtonSize = 5; |
44 static const float maxCancelButtonSize = 21; | 45 static const float maxCancelButtonSize = 21; |
45 static const int menuListArrowPaddingSize = 14; | |
46 | 46 |
47 static bool useMockTheme() { | 47 static bool useMockTheme() { |
48 return LayoutTestSupport::isMockThemeEnabledForTest(); | 48 return LayoutTestSupport::isMockThemeEnabledForTest(); |
49 } | 49 } |
50 | 50 |
51 unsigned LayoutThemeDefault::m_activeSelectionBackgroundColor = 0xff1e90ff; | 51 unsigned LayoutThemeDefault::m_activeSelectionBackgroundColor = 0xff1e90ff; |
52 unsigned LayoutThemeDefault::m_activeSelectionForegroundColor = Color::black; | 52 unsigned LayoutThemeDefault::m_activeSelectionForegroundColor = Color::black; |
53 unsigned LayoutThemeDefault::m_inactiveSelectionBackgroundColor = 0xffc8c8c8; | 53 unsigned LayoutThemeDefault::m_inactiveSelectionBackgroundColor = 0xffc8c8c8; |
54 unsigned LayoutThemeDefault::m_inactiveSelectionForegroundColor = 0xff323232; | 54 unsigned LayoutThemeDefault::m_inactiveSelectionForegroundColor = 0xff323232; |
55 | 55 |
56 double LayoutThemeDefault::m_caretBlinkInterval; | 56 double LayoutThemeDefault::m_caretBlinkInterval; |
57 | 57 |
58 LayoutThemeDefault::LayoutThemeDefault() : LayoutTheme(nullptr) { | 58 LayoutThemeDefault::LayoutThemeDefault() |
| 59 : LayoutTheme(nullptr), m_painter(*this) { |
59 m_caretBlinkInterval = LayoutTheme::caretBlinkInterval(); | 60 m_caretBlinkInterval = LayoutTheme::caretBlinkInterval(); |
60 } | 61 } |
61 | 62 |
62 LayoutThemeDefault::~LayoutThemeDefault() {} | 63 LayoutThemeDefault::~LayoutThemeDefault() {} |
63 | 64 |
64 bool LayoutThemeDefault::themeDrawsFocusRing(const ComputedStyle& style) const { | 65 bool LayoutThemeDefault::themeDrawsFocusRing(const ComputedStyle& style) const { |
65 if (useMockTheme()) { | 66 if (useMockTheme()) { |
66 // Don't use focus rings for buttons when mocking controls. | 67 // Don't use focus rings for buttons when mocking controls. |
67 return style.appearance() == ButtonPart || | 68 return style.appearance() == ButtonPart || |
68 style.appearance() == PushButtonPart || | 69 style.appearance() == PushButtonPart || |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 310 |
310 // The following internal paddings are in addition to the user-supplied padding. | 311 // The following internal paddings are in addition to the user-supplied padding. |
311 // Matches the Firefox behavior. | 312 // Matches the Firefox behavior. |
312 | 313 |
313 int LayoutThemeDefault::popupInternalPaddingStart( | 314 int LayoutThemeDefault::popupInternalPaddingStart( |
314 const ComputedStyle& style) const { | 315 const ComputedStyle& style) const { |
315 return menuListInternalPadding(style, 4); | 316 return menuListInternalPadding(style, 4); |
316 } | 317 } |
317 | 318 |
318 int LayoutThemeDefault::popupInternalPaddingEnd( | 319 int LayoutThemeDefault::popupInternalPaddingEnd( |
| 320 const HostWindow* host, |
319 const ComputedStyle& style) const { | 321 const ComputedStyle& style) const { |
320 return menuListInternalPadding(style, 4 + menuListArrowPaddingSize); | 322 if (style.appearance() == NoControlPart) |
| 323 return 0; |
| 324 return 1 * style.effectiveZoom() + |
| 325 clampedMenuListArrowPaddingSize(host, style); |
321 } | 326 } |
322 | 327 |
323 int LayoutThemeDefault::popupInternalPaddingTop( | 328 int LayoutThemeDefault::popupInternalPaddingTop( |
324 const ComputedStyle& style) const { | 329 const ComputedStyle& style) const { |
325 return menuListInternalPadding(style, 1); | 330 return menuListInternalPadding(style, 1); |
326 } | 331 } |
327 | 332 |
328 int LayoutThemeDefault::popupInternalPaddingBottom( | 333 int LayoutThemeDefault::popupInternalPaddingBottom( |
329 const ComputedStyle& style) const { | 334 const ComputedStyle& style) const { |
330 return menuListInternalPadding(style, 1); | 335 return menuListInternalPadding(style, 1); |
331 } | 336 } |
332 | 337 |
333 // static | 338 // static |
| 339 int LayoutThemeDefault::scrollbarThicknessInDIP() { |
| 340 int width = Platform::current() |
| 341 ->themeEngine() |
| 342 ->getSize(WebThemeEngine::PartScrollbarDownArrow) |
| 343 .width; |
| 344 return width > 0 ? width : 15; |
| 345 } |
| 346 |
| 347 // static |
| 348 float LayoutThemeDefault::clampedMenuListArrowPaddingSize( |
| 349 const HostWindow* host, |
| 350 const ComputedStyle& style) { |
| 351 int originalSize = scrollbarThicknessInDIP(); |
| 352 int scaledSize = |
| 353 host ? host->windowToViewportScalar(originalSize) : originalSize; |
| 354 // The result should not be samller than the scrollbar thickness in order to |
| 355 // secure space for scrollbar in popup. |
| 356 float deviceScale = 1.0f * scaledSize / originalSize; |
| 357 if (style.effectiveZoom() < deviceScale) |
| 358 return scaledSize; |
| 359 // The value should be zoomed though scrollbars aren't scaled by zoom. |
| 360 // crbug.com/432795. |
| 361 return originalSize * style.effectiveZoom(); |
| 362 } |
| 363 |
| 364 // static |
334 void LayoutThemeDefault::setDefaultFontSize(int fontSize) { | 365 void LayoutThemeDefault::setDefaultFontSize(int fontSize) { |
335 LayoutThemeFontProvider::setDefaultFontSize(fontSize); | 366 LayoutThemeFontProvider::setDefaultFontSize(fontSize); |
336 } | 367 } |
337 | 368 |
338 int LayoutThemeDefault::menuListInternalPadding(const ComputedStyle& style, | 369 int LayoutThemeDefault::menuListInternalPadding(const ComputedStyle& style, |
339 int padding) const { | 370 int padding) const { |
340 if (style.appearance() == NoControlPart) | 371 if (style.appearance() == NoControlPart) |
341 return 0; | 372 return 0; |
342 return padding * style.effectiveZoom(); | 373 return padding * style.effectiveZoom(); |
343 } | 374 } |
344 | 375 |
345 // | 376 // |
346 // Following values are come from default of GTK+ | 377 // Following values are come from default of GTK+ |
347 // | 378 // |
348 static const int progressAnimationFrames = 10; | 379 static const int progressAnimationFrames = 10; |
349 static const double progressAnimationInterval = 0.125; | 380 static const double progressAnimationInterval = 0.125; |
350 | 381 |
351 double LayoutThemeDefault::animationRepeatIntervalForProgressBar() const { | 382 double LayoutThemeDefault::animationRepeatIntervalForProgressBar() const { |
352 return progressAnimationInterval; | 383 return progressAnimationInterval; |
353 } | 384 } |
354 | 385 |
355 double LayoutThemeDefault::animationDurationForProgressBar() const { | 386 double LayoutThemeDefault::animationDurationForProgressBar() const { |
356 return progressAnimationInterval * progressAnimationFrames * | 387 return progressAnimationInterval * progressAnimationFrames * |
357 2; // "2" for back and forth | 388 2; // "2" for back and forth |
358 } | 389 } |
359 | 390 |
360 } // namespace blink | 391 } // namespace blink |
OLD | NEW |