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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutThemeDefault.cpp

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
OLDNEW
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 19 matching lines...) Expand all
30 #include "core/style/ComputedStyle.h" 30 #include "core/style/ComputedStyle.h"
31 #include "platform/LayoutTestSupport.h" 31 #include "platform/LayoutTestSupport.h"
32 #include "platform/PlatformResourceLoader.h" 32 #include "platform/PlatformResourceLoader.h"
33 #include "platform/graphics/Color.h" 33 #include "platform/graphics/Color.h"
34 #include "public/platform/Platform.h" 34 #include "public/platform/Platform.h"
35 #include "public/platform/WebThemeEngine.h" 35 #include "public/platform/WebThemeEngine.h"
36 #include "wtf/text/StringBuilder.h" 36 #include "wtf/text/StringBuilder.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 enum PaddingType {
41 TopPadding,
42 RightPadding,
43 BottomPadding,
44 LeftPadding
45 };
46
47 static const int styledMenuListInternalPadding[4] = { 1, 4, 1, 4 };
48
49 // These values all match Safari/Win. 40 // These values all match Safari/Win.
50 static const float defaultControlFontPixelSize = 13; 41 static const float defaultControlFontPixelSize = 13;
51 static const float defaultCancelButtonSize = 9; 42 static const float defaultCancelButtonSize = 9;
52 static const float minCancelButtonSize = 5; 43 static const float minCancelButtonSize = 5;
53 static const float maxCancelButtonSize = 21; 44 static const float maxCancelButtonSize = 21;
54 static const int menuListArrowPaddingSize = 14; 45 static const int menuListArrowPaddingSize = 14;
55 46
56 static bool useMockTheme() 47 static bool useMockTheme()
57 { 48 {
58 return LayoutTestSupport::isMockThemeEnabledForTest(); 49 return LayoutTestSupport::isMockThemeEnabledForTest();
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 { 324 {
334 // Height is locked to auto on all browsers. 325 // Height is locked to auto on all browsers.
335 style.setLineHeight(ComputedStyle::initialLineHeight()); 326 style.setLineHeight(ComputedStyle::initialLineHeight());
336 } 327 }
337 328
338 void LayoutThemeDefault::adjustMenuListButtonStyle(ComputedStyle& style, Element * e) const 329 void LayoutThemeDefault::adjustMenuListButtonStyle(ComputedStyle& style, Element * e) const
339 { 330 {
340 adjustMenuListStyle(style, e); 331 adjustMenuListStyle(style, e);
341 } 332 }
342 333
343 int LayoutThemeDefault::popupInternalPaddingLeft(const ComputedStyle& style) con st 334 // The following internal paddings are in addition to the user-supplied padding.
335 // Matches the Firefox behavior.
336
337 int LayoutThemeDefault::popupInternalPaddingStart(const ComputedStyle& style) co nst
344 { 338 {
345 return menuListInternalPadding(style, LeftPadding); 339 return menuListInternalPadding(style, 4);
346 } 340 }
347 341
348 int LayoutThemeDefault::popupInternalPaddingRight(const ComputedStyle& style) co nst 342 int LayoutThemeDefault::popupInternalPaddingEnd(const ComputedStyle& style) cons t
349 { 343 {
350 return menuListInternalPadding(style, RightPadding); 344 return menuListInternalPadding(style, 4 + menuListArrowPaddingSize);
351 } 345 }
352 346
353 int LayoutThemeDefault::popupInternalPaddingTop(const ComputedStyle& style) cons t 347 int LayoutThemeDefault::popupInternalPaddingTop(const ComputedStyle& style) cons t
354 { 348 {
355 return menuListInternalPadding(style, TopPadding); 349 return menuListInternalPadding(style, 1);
356 } 350 }
357 351
358 int LayoutThemeDefault::popupInternalPaddingBottom(const ComputedStyle& style) c onst 352 int LayoutThemeDefault::popupInternalPaddingBottom(const ComputedStyle& style) c onst
359 { 353 {
360 return menuListInternalPadding(style, BottomPadding); 354 return menuListInternalPadding(style, 1);
361 } 355 }
362 356
363 // static 357 // static
364 void LayoutThemeDefault::setDefaultFontSize(int fontSize) 358 void LayoutThemeDefault::setDefaultFontSize(int fontSize)
365 { 359 {
366 LayoutThemeFontProvider::setDefaultFontSize(fontSize); 360 LayoutThemeFontProvider::setDefaultFontSize(fontSize);
367 } 361 }
368 362
369 int LayoutThemeDefault::menuListInternalPadding(const ComputedStyle& style, int paddingType) const 363 int LayoutThemeDefault::menuListInternalPadding(const ComputedStyle& style, int padding) const
370 { 364 {
371 if (style.appearance() == NoControlPart) 365 if (style.appearance() == NoControlPart)
372 return 0; 366 return 0;
373 // This internal padding is in addition to the user-supplied padding.
374 // Matches the FF behavior.
375 int padding = styledMenuListInternalPadding[paddingType];
376
377 // Reserve the space for right arrow here. The rest of the padding is
378 // set by adjustMenuListStyle, since PopMenuWin.cpp uses the padding from
379 // LayoutMenuList to lay out the individual items in the popup.
380 const int barType = style.direction() == LTR ? RightPadding : LeftPadding;
381 if (paddingType == barType)
382 padding += menuListArrowPaddingSize;
383
384 return padding * style.effectiveZoom(); 367 return padding * style.effectiveZoom();
385 } 368 }
386 369
387 // 370 //
388 // Following values are come from default of GTK+ 371 // Following values are come from default of GTK+
389 // 372 //
390 static const int progressAnimationFrames = 10; 373 static const int progressAnimationFrames = 10;
391 static const double progressAnimationInterval = 0.125; 374 static const double progressAnimationInterval = 0.125;
392 375
393 double LayoutThemeDefault::animationRepeatIntervalForProgressBar() const 376 double LayoutThemeDefault::animationRepeatIntervalForProgressBar() const
394 { 377 {
395 return progressAnimationInterval; 378 return progressAnimationInterval;
396 } 379 }
397 380
398 double LayoutThemeDefault::animationDurationForProgressBar() const 381 double LayoutThemeDefault::animationDurationForProgressBar() const
399 { 382 {
400 return progressAnimationInterval * progressAnimationFrames * 2; // "2" for b ack and forth 383 return progressAnimationInterval * progressAnimationFrames * 2; // "2" for b ack and forth
401 } 384 }
402 385
403 } // namespace blink 386 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutThemeDefault.h ('k') | third_party/WebKit/Source/core/layout/LayoutThemeMac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698