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

Side by Side Diff: Source/core/rendering/RenderTheme.cpp

Issue 361173002: [wip] simplify -webkit-appearance adjust step (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update Created 6 years, 5 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 | « Source/core/rendering/RenderTheme.h ('k') | Source/core/rendering/style/CachedUAStyle.h » ('j') | 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 * This file is part of the theme implementation for form controls in WebCore. 2 * This file is part of the theme implementation for form controls in WebCore.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc. 4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Computer, Inc.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 RenderTheme::RenderTheme() 81 RenderTheme::RenderTheme()
82 : m_hasCustomFocusRingColor(false) 82 : m_hasCustomFocusRingColor(false)
83 #if USE(NEW_THEME) 83 #if USE(NEW_THEME)
84 , m_platformTheme(platformTheme()) 84 , m_platformTheme(platformTheme())
85 #endif 85 #endif
86 { 86 {
87 } 87 }
88 88
89 void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyl e* uaStyle) 89 void RenderTheme::adjustStyle(RenderStyle* style, Element* e, bool uaStyleHasWeb kitAppearance, bool valuesUnchangedForWebkitAppearance)
90 { 90 {
91 // Force inline and table display styles to be inline-block (except for tabl e- which is block) 91 // Force inline and table display styles to be inline-block (except for tabl e- which is block)
92 ControlPart part = style->appearance(); 92 ControlPart part = style->appearance();
93 if (style->display() == INLINE || style->display() == INLINE_TABLE || style- >display() == TABLE_ROW_GROUP 93 if (style->display() == INLINE || style->display() == INLINE_TABLE || style- >display() == TABLE_ROW_GROUP
94 || style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_F OOTER_GROUP 94 || style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_F OOTER_GROUP
95 || style->display() == TABLE_ROW || style->display() == TABLE_COLUMN_GRO UP || style->display() == TABLE_COLUMN 95 || style->display() == TABLE_ROW || style->display() == TABLE_COLUMN_GRO UP || style->display() == TABLE_COLUMN
96 || style->display() == TABLE_CELL || style->display() == TABLE_CAPTION) 96 || style->display() == TABLE_CELL || style->display() == TABLE_CAPTION)
97 style->setDisplay(INLINE_BLOCK); 97 style->setDisplay(INLINE_BLOCK);
98 else if (style->display() == LIST_ITEM || style->display() == TABLE) 98 else if (style->display() == LIST_ITEM || style->display() == TABLE)
99 style->setDisplay(BLOCK); 99 style->setDisplay(BLOCK);
100 100
101 if (uaStyle && uaStyle->hasAppearance && isControlStyled(style, uaStyle)) { 101 if (uaStyleHasWebkitAppearance && isControlStyled(style, valuesUnchangedForW ebkitAppearance)) {
102 if (part == MenulistPart) { 102 if (part == MenulistPart) {
103 style->setAppearance(MenulistButtonPart); 103 style->setAppearance(MenulistButtonPart);
104 part = MenulistButtonPart; 104 part = MenulistButtonPart;
105 } else 105 } else
106 style->setAppearance(NoControlPart); 106 style->setAppearance(NoControlPart);
107 } 107 }
108 108
109 if (!style->hasAppearance()) 109 if (!style->hasAppearance())
110 return; 110 return;
111 111
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 #endif 544 #endif
545 } 545 }
546 546
547 bool RenderTheme::isControlContainer(ControlPart appearance) const 547 bool RenderTheme::isControlContainer(ControlPart appearance) const
548 { 548 {
549 // There are more leaves than this, but we'll patch this function as we add support for 549 // There are more leaves than this, but we'll patch this function as we add support for
550 // more controls. 550 // more controls.
551 return appearance != CheckboxPart && appearance != RadioPart; 551 return appearance != CheckboxPart && appearance != RadioPart;
552 } 552 }
553 553
554 static bool isBackgroundOrBorderStyled(const RenderStyle& style, const CachedUAS tyle& uaStyle) 554 bool RenderTheme::isControlStyled(const RenderStyle* style, bool valuesUnchanged ForWebkitAppearance) const
555 { 555 {
556 // Code below excludes the background-repeat from comparison by resetting it
557 FillLayer backgroundCopy = uaStyle.backgroundLayers;
558 FillLayer backgroundLayersCopy = style.backgroundLayers();
559 backgroundCopy.setRepeatX(NoRepeatFill);
560 backgroundCopy.setRepeatY(NoRepeatFill);
561 backgroundLayersCopy.setRepeatX(NoRepeatFill);
562 backgroundLayersCopy.setRepeatY(NoRepeatFill);
563 // Test the style to see if the UA border and background match.
564 return style.border() != uaStyle.border
565 || backgroundLayersCopy != backgroundCopy
566 || style.visitedDependentColor(CSSPropertyBackgroundColor) != uaStyle.ba ckgroundColor;
567 }
568
569 bool RenderTheme::isControlStyled(const RenderStyle* style, const CachedUAStyle* uaStyle) const
570 {
571 ASSERT(uaStyle);
572
573 switch (style->appearance()) { 556 switch (style->appearance()) {
574 case PushButtonPart: 557 case PushButtonPart:
575 case SquareButtonPart: 558 case SquareButtonPart:
576 case ButtonPart: 559 case ButtonPart:
577 case ProgressBarPart: 560 case ProgressBarPart:
578 case MeterPart: 561 case MeterPart:
579 case RelevancyLevelIndicatorPart: 562 case RelevancyLevelIndicatorPart:
580 case ContinuousCapacityLevelIndicatorPart: 563 case ContinuousCapacityLevelIndicatorPart:
581 case DiscreteCapacityLevelIndicatorPart: 564 case DiscreteCapacityLevelIndicatorPart:
582 case RatingLevelIndicatorPart: 565 case RatingLevelIndicatorPart:
583 return isBackgroundOrBorderStyled(*style, *uaStyle); 566 return !valuesUnchangedForWebkitAppearance;
584 567
585 case MenulistPart: 568 case MenulistPart:
586 case SearchFieldPart: 569 case SearchFieldPart:
587 case TextAreaPart: 570 case TextAreaPart:
588 case TextFieldPart: 571 case TextFieldPart:
589 return isBackgroundOrBorderStyled(*style, *uaStyle) || style->boxShadow( ); 572 return !valuesUnchangedForWebkitAppearance || style->boxShadow();
590 573
591 case SliderHorizontalPart: 574 case SliderHorizontalPart:
592 case SliderVerticalPart: 575 case SliderVerticalPart:
593 return style->boxShadow(); 576 return style->boxShadow();
594 577
595 default: 578 default:
596 return false; 579 return false;
597 } 580 }
598 } 581 }
599 582
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 1198
1216 // padding - not honored by WinIE, needs to be removed. 1199 // padding - not honored by WinIE, needs to be removed.
1217 style->resetPadding(); 1200 style->resetPadding();
1218 1201
1219 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) 1202 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme)
1220 // for now, we will not honor it. 1203 // for now, we will not honor it.
1221 style->resetBorder(); 1204 style->resetBorder();
1222 } 1205 }
1223 1206
1224 } // namespace blink 1207 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderTheme.h ('k') | Source/core/rendering/style/CachedUAStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698