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