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

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

Issue 20061003: Move isValid/isCurrentColor from Color to StyleColor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #if ENABLE(INPUT_SPEECH) 61 #if ENABLE(INPUT_SPEECH)
62 #include "core/rendering/RenderInputSpeech.h" 62 #include "core/rendering/RenderInputSpeech.h"
63 #endif 63 #endif
64 64
65 // The methods in this file are shared by all themes on every platform. 65 // The methods in this file are shared by all themes on every platform.
66 66
67 namespace WebCore { 67 namespace WebCore {
68 68
69 using namespace HTMLNames; 69 using namespace HTMLNames;
70 70
71 static Color& customFocusRingColor() 71 static StyleColor& customFocusRingColor()
72 { 72 {
73 DEFINE_STATIC_LOCAL(Color, color, ()); 73 DEFINE_STATIC_LOCAL(StyleColor, color, ());
74 return color; 74 return color;
75 } 75 }
76 76
77 static WebKit::WebFallbackThemeEngine::State getWebFallbackThemeState(const Rend erTheme* theme, const RenderObject* o) 77 static WebKit::WebFallbackThemeEngine::State getWebFallbackThemeState(const Rend erTheme* theme, const RenderObject* o)
78 { 78 {
79 if (!theme->isEnabled(o)) 79 if (!theme->isEnabled(o))
80 return WebKit::WebFallbackThemeEngine::StateDisabled; 80 return WebKit::WebFallbackThemeEngine::StateDisabled;
81 if (theme->isPressed(o)) 81 if (theme->isPressed(o))
82 return WebKit::WebFallbackThemeEngine::StatePressed; 82 return WebKit::WebFallbackThemeEngine::StatePressed;
83 if (theme->isHovered(o)) 83 if (theme->isHovered(o))
84 return WebKit::WebFallbackThemeEngine::StateHover; 84 return WebKit::WebFallbackThemeEngine::StateHover;
85 85
86 return WebKit::WebFallbackThemeEngine::StateNormal; 86 return WebKit::WebFallbackThemeEngine::StateNormal;
87 } 87 }
88 88
89 RenderTheme::RenderTheme() 89 RenderTheme::RenderTheme()
90 #if USE(NEW_THEME) 90 #if USE(NEW_THEME)
91 : m_theme(platformTheme()) 91 : m_theme(platformTheme())
92 #endif 92 #endif
93 { 93 {
94 m_selectionColorsValid = 0;
94 } 95 }
95 96
96 void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyl e& uaStyle) 97 void RenderTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyl e& uaStyle)
97 { 98 {
98 // Force inline and table display styles to be inline-block (except for tabl e- which is block) 99 // Force inline and table display styles to be inline-block (except for tabl e- which is block)
99 ControlPart part = style->appearance(); 100 ControlPart part = style->appearance();
100 if (style->display() == INLINE || style->display() == INLINE_TABLE || style- >display() == TABLE_ROW_GROUP 101 if (style->display() == INLINE || style->display() == INLINE_TABLE || style- >display() == TABLE_ROW_GROUP
101 || style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_F OOTER_GROUP 102 || style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_F OOTER_GROUP
102 || style->display() == TABLE_ROW || style->display() == TABLE_COLUMN_GRO UP || style->display() == TABLE_COLUMN 103 || style->display() == TABLE_ROW || style->display() == TABLE_COLUMN_GRO UP || style->display() == TABLE_COLUMN
103 || style->display() == TABLE_CELL || style->display() == TABLE_CAPTION) 104 || style->display() == TABLE_CELL || style->display() == TABLE_CAPTION)
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 } 519 }
519 520
520 return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds ); 521 return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds );
521 } 522 }
522 523
523 String RenderTheme::formatMediaControlsCurrentTime(float currentTime, float /*du ration*/) const 524 String RenderTheme::formatMediaControlsCurrentTime(float currentTime, float /*du ration*/) const
524 { 525 {
525 return formatMediaControlsTime(currentTime); 526 return formatMediaControlsTime(currentTime);
526 } 527 }
527 528
529 namespace SelectionColors {
530 enum {
531 ActiveBackground = 1,
532 InactiveBackground = 2,
533 ActiveForeground = 4,
534 InactiveForeground = 8,
535 ActiveListBoxBackground = 16,
536 InactiveListBoxBackground = 32,
537 ActiveListBoxForeground = 64,
538 InactiveListBoxForeground = 128
539 };
540 };
541
528 Color RenderTheme::activeSelectionBackgroundColor() const 542 Color RenderTheme::activeSelectionBackgroundColor() const
529 { 543 {
530 if (!m_activeSelectionBackgroundColor.isValid()) 544 if (!(m_selectionColorsValid & SelectionColors::ActiveBackground)) {
531 m_activeSelectionBackgroundColor = platformActiveSelectionBackgroundColo r().blendWithWhite(); 545 m_activeSelectionBackgroundColor = platformActiveSelectionBackgroundColo r().blendWithWhite();
546 m_selectionColorsValid |= SelectionColors::ActiveBackground;
547 }
532 return m_activeSelectionBackgroundColor; 548 return m_activeSelectionBackgroundColor;
533 } 549 }
534 550
535 Color RenderTheme::inactiveSelectionBackgroundColor() const 551 Color RenderTheme::inactiveSelectionBackgroundColor() const
536 { 552 {
537 if (!m_inactiveSelectionBackgroundColor.isValid()) 553 if (!(m_selectionColorsValid & SelectionColors::InactiveBackground)) {
538 m_inactiveSelectionBackgroundColor = platformInactiveSelectionBackground Color().blendWithWhite(); 554 m_inactiveSelectionBackgroundColor = platformInactiveSelectionBackground Color().blendWithWhite();
555 m_selectionColorsValid |= SelectionColors::InactiveBackground;
556 }
539 return m_inactiveSelectionBackgroundColor; 557 return m_inactiveSelectionBackgroundColor;
540 } 558 }
541 559
542 Color RenderTheme::activeSelectionForegroundColor() const 560 Color RenderTheme::activeSelectionForegroundColor() const
543 { 561 {
544 if (!m_activeSelectionForegroundColor.isValid() && supportsSelectionForegrou ndColors()) 562 if (!(m_selectionColorsValid & SelectionColors::ActiveForeground) && support sSelectionForegroundColors()) {
545 m_activeSelectionForegroundColor = platformActiveSelectionForegroundColo r(); 563 m_activeSelectionForegroundColor = platformActiveSelectionForegroundColo r();
564 m_selectionColorsValid |= SelectionColors::ActiveForeground;
565 }
546 return m_activeSelectionForegroundColor; 566 return m_activeSelectionForegroundColor;
547 } 567 }
548 568
549 Color RenderTheme::inactiveSelectionForegroundColor() const 569 Color RenderTheme::inactiveSelectionForegroundColor() const
550 { 570 {
551 if (!m_inactiveSelectionForegroundColor.isValid() && supportsSelectionForegr oundColors()) 571 if (!(m_selectionColorsValid & SelectionColors::InactiveForeground) && suppo rtsSelectionForegroundColors()) {
552 m_inactiveSelectionForegroundColor = platformInactiveSelectionForeground Color(); 572 m_inactiveSelectionForegroundColor = platformInactiveSelectionForeground Color();
573 m_selectionColorsValid |= SelectionColors::InactiveForeground;
574 }
553 return m_inactiveSelectionForegroundColor; 575 return m_inactiveSelectionForegroundColor;
554 } 576 }
555 577
556 Color RenderTheme::activeListBoxSelectionBackgroundColor() const 578 Color RenderTheme::activeListBoxSelectionBackgroundColor() const
557 { 579 {
558 if (!m_activeListBoxSelectionBackgroundColor.isValid()) 580 if (!(m_selectionColorsValid & SelectionColors::ActiveListBoxBackground)) {
559 m_activeListBoxSelectionBackgroundColor = platformActiveListBoxSelection BackgroundColor(); 581 m_activeListBoxSelectionBackgroundColor = platformActiveListBoxSelection BackgroundColor();
582 m_selectionColorsValid |= SelectionColors::ActiveListBoxBackground;
583 }
560 return m_activeListBoxSelectionBackgroundColor; 584 return m_activeListBoxSelectionBackgroundColor;
561 } 585 }
562 586
563 Color RenderTheme::inactiveListBoxSelectionBackgroundColor() const 587 Color RenderTheme::inactiveListBoxSelectionBackgroundColor() const
564 { 588 {
565 if (!m_inactiveListBoxSelectionBackgroundColor.isValid()) 589 if (!(m_selectionColorsValid & SelectionColors::InactiveListBoxBackground)) {
566 m_inactiveListBoxSelectionBackgroundColor = platformInactiveListBoxSelec tionBackgroundColor(); 590 m_inactiveListBoxSelectionBackgroundColor = platformInactiveListBoxSelec tionBackgroundColor();
591 m_selectionColorsValid |= SelectionColors::InactiveListBoxBackground;
592 }
567 return m_inactiveListBoxSelectionBackgroundColor; 593 return m_inactiveListBoxSelectionBackgroundColor;
568 } 594 }
569 595
570 Color RenderTheme::activeListBoxSelectionForegroundColor() const 596 Color RenderTheme::activeListBoxSelectionForegroundColor() const
571 { 597 {
572 if (!m_activeListBoxSelectionForegroundColor.isValid() && supportsListBoxSel ectionForegroundColors()) 598 if (!(m_selectionColorsValid & SelectionColors::ActiveListBoxForeground) && supportsListBoxSelectionForegroundColors()) {
573 m_activeListBoxSelectionForegroundColor = platformActiveListBoxSelection ForegroundColor(); 599 m_activeListBoxSelectionForegroundColor = platformActiveListBoxSelection ForegroundColor();
600 m_selectionColorsValid |= SelectionColors::ActiveListBoxForeground;
601 }
574 return m_activeListBoxSelectionForegroundColor; 602 return m_activeListBoxSelectionForegroundColor;
575 } 603 }
576 604
577 Color RenderTheme::inactiveListBoxSelectionForegroundColor() const 605 Color RenderTheme::inactiveListBoxSelectionForegroundColor() const
578 { 606 {
579 if (!m_inactiveListBoxSelectionForegroundColor.isValid() && supportsListBoxS electionForegroundColors()) 607 if (!(m_selectionColorsValid & SelectionColors::InactiveListBoxForeground) & & supportsListBoxSelectionForegroundColors()) {
580 m_inactiveListBoxSelectionForegroundColor = platformInactiveListBoxSelec tionForegroundColor(); 608 m_inactiveListBoxSelectionForegroundColor = platformInactiveListBoxSelec tionForegroundColor();
609 m_selectionColorsValid |= SelectionColors::InactiveListBoxForeground;
610 }
581 return m_inactiveListBoxSelectionForegroundColor; 611 return m_inactiveListBoxSelectionForegroundColor;
582 } 612 }
583 613
584 Color RenderTheme::platformActiveSelectionBackgroundColor() const 614 Color RenderTheme::platformActiveSelectionBackgroundColor() const
585 { 615 {
586 // Use a blue color by default if the platform theme doesn't define anything . 616 // Use a blue color by default if the platform theme doesn't define anything .
587 return Color(0, 0, 255); 617 return Color(0, 0, 255);
588 } 618 }
589 619
590 Color RenderTheme::platformActiveSelectionForegroundColor() const 620 Color RenderTheme::platformActiveSelectionForegroundColor() const
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 // Code below excludes the background-repeat from comparison by resetting it 682 // Code below excludes the background-repeat from comparison by resetting it
653 FillLayer backgroundCopy = uaStyle.backgroundLayers; 683 FillLayer backgroundCopy = uaStyle.backgroundLayers;
654 FillLayer backgroundLayersCopy = *style.backgroundLayers(); 684 FillLayer backgroundLayersCopy = *style.backgroundLayers();
655 backgroundCopy.setRepeatX(NoRepeatFill); 685 backgroundCopy.setRepeatX(NoRepeatFill);
656 backgroundCopy.setRepeatY(NoRepeatFill); 686 backgroundCopy.setRepeatY(NoRepeatFill);
657 backgroundLayersCopy.setRepeatX(NoRepeatFill); 687 backgroundLayersCopy.setRepeatX(NoRepeatFill);
658 backgroundLayersCopy.setRepeatY(NoRepeatFill); 688 backgroundLayersCopy.setRepeatY(NoRepeatFill);
659 // Test the style to see if the UA border and background match. 689 // Test the style to see if the UA border and background match.
660 return style.border() != uaStyle.border 690 return style.border() != uaStyle.border
661 || backgroundLayersCopy != backgroundCopy 691 || backgroundLayersCopy != backgroundCopy
662 || style.visitedDependentColor(CSSPropertyBackgroundColor) != uaStyle.ba ckgroundColor; 692 || style.visitedDependentColor(CSSPropertyBackgroundColor).color() != ua Style.backgroundColor;
663 } 693 }
664 694
665 bool RenderTheme::isControlStyled(const RenderStyle* style, const CachedUAStyle& uaStyle) const 695 bool RenderTheme::isControlStyled(const RenderStyle* style, const CachedUAStyle& uaStyle) const
666 { 696 {
667 switch (style->appearance()) { 697 switch (style->appearance()) {
668 case PushButtonPart: 698 case PushButtonPart:
669 case SquareButtonPart: 699 case SquareButtonPart:
670 case ButtonPart: 700 case ButtonPart:
671 case ProgressBarPart: 701 case ProgressBarPart:
672 case MeterPart: 702 case MeterPart:
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 void RenderTheme::adjustSearchFieldDecorationStyle(RenderStyle*, Element*) const 1115 void RenderTheme::adjustSearchFieldDecorationStyle(RenderStyle*, Element*) const
1086 { 1116 {
1087 } 1117 }
1088 1118
1089 void RenderTheme::adjustSearchFieldResultsDecorationStyle(RenderStyle*, Element* ) const 1119 void RenderTheme::adjustSearchFieldResultsDecorationStyle(RenderStyle*, Element* ) const
1090 { 1120 {
1091 } 1121 }
1092 1122
1093 void RenderTheme::platformColorsDidChange() 1123 void RenderTheme::platformColorsDidChange()
1094 { 1124 {
1095 m_activeSelectionForegroundColor = Color(); 1125 m_selectionColorsValid = 0;
1096 m_inactiveSelectionForegroundColor = Color();
1097 m_activeSelectionBackgroundColor = Color();
1098 m_inactiveSelectionBackgroundColor = Color();
1099
1100 m_activeListBoxSelectionForegroundColor = Color();
1101 m_inactiveListBoxSelectionForegroundColor = Color();
1102 m_activeListBoxSelectionBackgroundColor = Color();
1103 m_inactiveListBoxSelectionForegroundColor = Color();
1104
1105 Page::scheduleForcedStyleRecalcForAllPages(); 1126 Page::scheduleForcedStyleRecalcForAllPages();
1106 } 1127 }
1107 1128
1108 Color RenderTheme::systemColor(CSSValueID cssValueId) const 1129 Color RenderTheme::systemColor(CSSValueID cssValueId) const
1109 { 1130 {
1110 switch (cssValueId) { 1131 switch (cssValueId) {
1111 case CSSValueActiveborder: 1132 case CSSValueActiveborder:
1112 return 0xFFFFFFFF; 1133 return 0xFFFFFFFF;
1113 case CSSValueActivecaption: 1134 case CSSValueActivecaption:
1114 return 0xFFCCCCCC; 1135 return 0xFFCCCCCC;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 return defaultTheme()->platformTapHighlightColor(); 1220 return defaultTheme()->platformTapHighlightColor();
1200 } 1221 }
1201 1222
1202 void RenderTheme::setCustomFocusRingColor(const Color& c) 1223 void RenderTheme::setCustomFocusRingColor(const Color& c)
1203 { 1224 {
1204 customFocusRingColor() = c; 1225 customFocusRingColor() = c;
1205 } 1226 }
1206 1227
1207 Color RenderTheme::focusRingColor() 1228 Color RenderTheme::focusRingColor()
1208 { 1229 {
1209 return customFocusRingColor().isValid() ? customFocusRingColor() : defaultTh eme()->platformFocusRingColor(); 1230 return customFocusRingColor().isValid() ? customFocusRingColor().color() : d efaultTheme()->platformFocusRingColor();
1210 } 1231 }
1211 1232
1212 String RenderTheme::fileListDefaultLabel(bool multipleFilesAllowed) const 1233 String RenderTheme::fileListDefaultLabel(bool multipleFilesAllowed) const
1213 { 1234 {
1214 if (multipleFilesAllowed) 1235 if (multipleFilesAllowed)
1215 return fileButtonNoFilesSelectedLabel(); 1236 return fileButtonNoFilesSelectedLabel();
1216 return fileButtonNoFileSelectedLabel(); 1237 return fileButtonNoFileSelectedLabel();
1217 } 1238 }
1218 1239
1219 String RenderTheme::fileListNameForWidth(const FileList* fileList, const Font& f ont, int width, bool multipleFilesAllowed) const 1240 String RenderTheme::fileListNameForWidth(const FileList* fileList, const Font& f ont, int width, bool multipleFilesAllowed) const
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 1402
1382 // padding - not honored by WinIE, needs to be removed. 1403 // padding - not honored by WinIE, needs to be removed.
1383 style->resetPadding(); 1404 style->resetPadding();
1384 1405
1385 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) 1406 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme)
1386 // for now, we will not honor it. 1407 // for now, we will not honor it.
1387 style->resetBorder(); 1408 style->resetBorder();
1388 } 1409 }
1389 1410
1390 } // namespace WebCore 1411 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698