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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 if (!style->hasAppearance()) | 101 if (!style->hasAppearance()) |
102 return; | 102 return; |
103 | 103 |
104 #if USE(NEW_THEME) | 104 #if USE(NEW_THEME) |
105 switch (part) { | 105 switch (part) { |
106 case CheckboxPart: | 106 case CheckboxPart: |
107 case InnerSpinButtonPart: | 107 case InnerSpinButtonPart: |
108 case RadioPart: | 108 case RadioPart: |
109 case PushButtonPart: | 109 case PushButtonPart: |
110 case SquareButtonPart: | 110 case SquareButtonPart: |
111 case DefaultButtonPart: | |
112 case ButtonPart: { | 111 case ButtonPart: { |
113 // Border | 112 // Border |
114 LengthBox borderBox(style->borderTopWidth(), style->borderRightWidth(),
style->borderBottomWidth(), style->borderLeftWidth()); | 113 LengthBox borderBox(style->borderTopWidth(), style->borderRightWidth(),
style->borderBottomWidth(), style->borderLeftWidth()); |
115 borderBox = m_theme->controlBorder(part, style->font(), borderBox, style
->effectiveZoom()); | 114 borderBox = m_theme->controlBorder(part, style->font(), borderBox, style
->effectiveZoom()); |
116 if (borderBox.top().value() != static_cast<int>(style->borderTopWidth())
) { | 115 if (borderBox.top().value() != static_cast<int>(style->borderTopWidth())
) { |
117 if (borderBox.top().value()) | 116 if (borderBox.top().value()) |
118 style->setBorderTopWidth(borderBox.top().value()); | 117 style->setBorderTopWidth(borderBox.top().value()); |
119 else | 118 else |
120 style->resetBorderTop(); | 119 style->resetBorderTop(); |
121 } | 120 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 182 |
184 // Call the appropriate style adjustment method based off the appearance val
ue. | 183 // Call the appropriate style adjustment method based off the appearance val
ue. |
185 switch (style->appearance()) { | 184 switch (style->appearance()) { |
186 #if !USE(NEW_THEME) | 185 #if !USE(NEW_THEME) |
187 case CheckboxPart: | 186 case CheckboxPart: |
188 return adjustCheckboxStyle(styleResolver, style, e); | 187 return adjustCheckboxStyle(styleResolver, style, e); |
189 case RadioPart: | 188 case RadioPart: |
190 return adjustRadioStyle(styleResolver, style, e); | 189 return adjustRadioStyle(styleResolver, style, e); |
191 case PushButtonPart: | 190 case PushButtonPart: |
192 case SquareButtonPart: | 191 case SquareButtonPart: |
193 case DefaultButtonPart: | |
194 case ButtonPart: | 192 case ButtonPart: |
195 return adjustButtonStyle(styleResolver, style, e); | 193 return adjustButtonStyle(styleResolver, style, e); |
196 case InnerSpinButtonPart: | 194 case InnerSpinButtonPart: |
197 return adjustInnerSpinButtonStyle(styleResolver, style, e); | 195 return adjustInnerSpinButtonStyle(styleResolver, style, e); |
198 #endif | 196 #endif |
199 case TextFieldPart: | 197 case TextFieldPart: |
200 return adjustTextFieldStyle(styleResolver, style, e); | 198 return adjustTextFieldStyle(styleResolver, style, e); |
201 case TextAreaPart: | 199 case TextAreaPart: |
202 return adjustTextAreaStyle(styleResolver, style, e); | 200 return adjustTextAreaStyle(styleResolver, style, e); |
203 case MenulistPart: | 201 case MenulistPart: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 return false; | 260 return false; |
263 | 261 |
264 ControlPart part = o->style()->appearance(); | 262 ControlPart part = o->style()->appearance(); |
265 | 263 |
266 #if USE(NEW_THEME) | 264 #if USE(NEW_THEME) |
267 switch (part) { | 265 switch (part) { |
268 case CheckboxPart: | 266 case CheckboxPart: |
269 case RadioPart: | 267 case RadioPart: |
270 case PushButtonPart: | 268 case PushButtonPart: |
271 case SquareButtonPart: | 269 case SquareButtonPart: |
272 case DefaultButtonPart: | |
273 case ButtonPart: | 270 case ButtonPart: |
274 case InnerSpinButtonPart: | 271 case InnerSpinButtonPart: |
275 m_theme->paint(part, controlStatesForRenderer(o), const_cast<GraphicsCon
text*>(paintInfo.context), r, o->style()->effectiveZoom(), o->view()->frameView(
)); | 272 m_theme->paint(part, controlStatesForRenderer(o), const_cast<GraphicsCon
text*>(paintInfo.context), r, o->style()->effectiveZoom(), o->view()->frameView(
)); |
276 return false; | 273 return false; |
277 default: | 274 default: |
278 break; | 275 break; |
279 } | 276 } |
280 #endif | 277 #endif |
281 | 278 |
282 // Call the appropriate paint method based off the appearance value. | 279 // Call the appropriate paint method based off the appearance value. |
283 switch (part) { | 280 switch (part) { |
284 #if !USE(NEW_THEME) | 281 #if !USE(NEW_THEME) |
285 case CheckboxPart: | 282 case CheckboxPart: |
286 return paintCheckbox(o, paintInfo, r); | 283 return paintCheckbox(o, paintInfo, r); |
287 case RadioPart: | 284 case RadioPart: |
288 return paintRadio(o, paintInfo, r); | 285 return paintRadio(o, paintInfo, r); |
289 case PushButtonPart: | 286 case PushButtonPart: |
290 case SquareButtonPart: | 287 case SquareButtonPart: |
291 case DefaultButtonPart: | |
292 case ButtonPart: | 288 case ButtonPart: |
293 return paintButton(o, paintInfo, r); | 289 return paintButton(o, paintInfo, r); |
294 case InnerSpinButtonPart: | 290 case InnerSpinButtonPart: |
295 return paintInnerSpinButton(o, paintInfo, r); | 291 return paintInnerSpinButton(o, paintInfo, r); |
296 #endif | 292 #endif |
297 case MenulistPart: | 293 case MenulistPart: |
298 return paintMenuList(o, paintInfo, r); | 294 return paintMenuList(o, paintInfo, r); |
299 case MeterPart: | 295 case MeterPart: |
300 case RelevancyLevelIndicatorPart: | 296 case RelevancyLevelIndicatorPart: |
301 case ContinuousCapacityLevelIndicatorPart: | 297 case ContinuousCapacityLevelIndicatorPart: |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 case ListboxPart: | 385 case ListboxPart: |
390 case TextAreaPart: | 386 case TextAreaPart: |
391 return paintTextArea(o, paintInfo, r); | 387 return paintTextArea(o, paintInfo, r); |
392 case MenulistButtonPart: | 388 case MenulistButtonPart: |
393 case SearchFieldPart: | 389 case SearchFieldPart: |
394 return true; | 390 return true; |
395 case CheckboxPart: | 391 case CheckboxPart: |
396 case RadioPart: | 392 case RadioPart: |
397 case PushButtonPart: | 393 case PushButtonPart: |
398 case SquareButtonPart: | 394 case SquareButtonPart: |
399 case DefaultButtonPart: | |
400 case ButtonPart: | 395 case ButtonPart: |
401 case MenulistPart: | 396 case MenulistPart: |
402 case MeterPart: | 397 case MeterPart: |
403 case RelevancyLevelIndicatorPart: | 398 case RelevancyLevelIndicatorPart: |
404 case ContinuousCapacityLevelIndicatorPart: | 399 case ContinuousCapacityLevelIndicatorPart: |
405 case DiscreteCapacityLevelIndicatorPart: | 400 case DiscreteCapacityLevelIndicatorPart: |
406 case RatingLevelIndicatorPart: | 401 case RatingLevelIndicatorPart: |
407 case ProgressBarPart: | 402 case ProgressBarPart: |
408 case SliderHorizontalPart: | 403 case SliderHorizontalPart: |
409 case SliderVerticalPart: | 404 case SliderVerticalPart: |
(...skipping 22 matching lines...) Expand all Loading... |
432 switch (o->style()->appearance()) { | 427 switch (o->style()->appearance()) { |
433 case MenulistButtonPart: | 428 case MenulistButtonPart: |
434 return paintMenuListButton(o, paintInfo, r); | 429 return paintMenuListButton(o, paintInfo, r); |
435 case TextFieldPart: | 430 case TextFieldPart: |
436 case TextAreaPart: | 431 case TextAreaPart: |
437 case ListboxPart: | 432 case ListboxPart: |
438 case CheckboxPart: | 433 case CheckboxPart: |
439 case RadioPart: | 434 case RadioPart: |
440 case PushButtonPart: | 435 case PushButtonPart: |
441 case SquareButtonPart: | 436 case SquareButtonPart: |
442 case DefaultButtonPart: | |
443 case ButtonPart: | 437 case ButtonPart: |
444 case MenulistPart: | 438 case MenulistPart: |
445 case MeterPart: | 439 case MeterPart: |
446 case RelevancyLevelIndicatorPart: | 440 case RelevancyLevelIndicatorPart: |
447 case ContinuousCapacityLevelIndicatorPart: | 441 case ContinuousCapacityLevelIndicatorPart: |
448 case DiscreteCapacityLevelIndicatorPart: | 442 case DiscreteCapacityLevelIndicatorPart: |
449 case RatingLevelIndicatorPart: | 443 case RatingLevelIndicatorPart: |
450 case ProgressBarPart: | 444 case ProgressBarPart: |
451 case SliderHorizontalPart: | 445 case SliderHorizontalPart: |
452 case SliderVerticalPart: | 446 case SliderVerticalPart: |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 return style.border() != border | 617 return style.border() != border |
624 || *style.backgroundLayers() != background | 618 || *style.backgroundLayers() != background |
625 || style.visitedDependentColor(CSSPropertyBackgroundColor) != background
Color; | 619 || style.visitedDependentColor(CSSPropertyBackgroundColor) != background
Color; |
626 } | 620 } |
627 | 621 |
628 bool RenderTheme::isControlStyled(const RenderStyle* style, const BorderData& bo
rder, const FillLayer& background, const Color& backgroundColor) const | 622 bool RenderTheme::isControlStyled(const RenderStyle* style, const BorderData& bo
rder, const FillLayer& background, const Color& backgroundColor) const |
629 { | 623 { |
630 switch (style->appearance()) { | 624 switch (style->appearance()) { |
631 case PushButtonPart: | 625 case PushButtonPart: |
632 case SquareButtonPart: | 626 case SquareButtonPart: |
633 case DefaultButtonPart: | |
634 case ButtonPart: | 627 case ButtonPart: |
635 case ProgressBarPart: | 628 case ProgressBarPart: |
636 case MeterPart: | 629 case MeterPart: |
637 case RelevancyLevelIndicatorPart: | 630 case RelevancyLevelIndicatorPart: |
638 case ContinuousCapacityLevelIndicatorPart: | 631 case ContinuousCapacityLevelIndicatorPart: |
639 case DiscreteCapacityLevelIndicatorPart: | 632 case DiscreteCapacityLevelIndicatorPart: |
640 case RatingLevelIndicatorPart: | 633 case RatingLevelIndicatorPart: |
641 return isBackgroundOrBorderStyled(*style, border, background, background
Color); | 634 return isBackgroundOrBorderStyled(*style, border, background, background
Color); |
642 | 635 |
643 case ListboxPart: | 636 case ListboxPart: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 result |= SpinUpState; | 693 result |= SpinUpState; |
701 } | 694 } |
702 if (isFocused(o) && o->style()->outlineStyleIsAuto()) | 695 if (isFocused(o) && o->style()->outlineStyleIsAuto()) |
703 result |= FocusState; | 696 result |= FocusState; |
704 if (isEnabled(o)) | 697 if (isEnabled(o)) |
705 result |= EnabledState; | 698 result |= EnabledState; |
706 if (isChecked(o)) | 699 if (isChecked(o)) |
707 result |= CheckedState; | 700 result |= CheckedState; |
708 if (isReadOnlyControl(o)) | 701 if (isReadOnlyControl(o)) |
709 result |= ReadOnlyState; | 702 result |= ReadOnlyState; |
710 if (isDefault(o)) | |
711 result |= DefaultState; | |
712 if (!isActive(o)) | 703 if (!isActive(o)) |
713 result |= WindowInactiveState; | 704 result |= WindowInactiveState; |
714 if (isIndeterminate(o)) | 705 if (isIndeterminate(o)) |
715 result |= IndeterminateState; | 706 result |= IndeterminateState; |
716 return result; | 707 return result; |
717 } | 708 } |
718 | 709 |
719 bool RenderTheme::isActive(const RenderObject* o) const | 710 bool RenderTheme::isActive(const RenderObject* o) const |
720 { | 711 { |
721 Node* node = o->node(); | 712 Node* node = o->node(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 | 806 |
816 bool RenderTheme::isSpinUpButtonPartHovered(const RenderObject* o) const | 807 bool RenderTheme::isSpinUpButtonPartHovered(const RenderObject* o) const |
817 { | 808 { |
818 Node* node = o->node(); | 809 Node* node = o->node(); |
819 if (!node || !node->isElementNode() || !toElement(node)->isSpinButtonElement
()) | 810 if (!node || !node->isElementNode() || !toElement(node)->isSpinButtonElement
()) |
820 return false; | 811 return false; |
821 SpinButtonElement* element = static_cast<SpinButtonElement*>(node); | 812 SpinButtonElement* element = static_cast<SpinButtonElement*>(node); |
822 return element->upDownState() == SpinButtonElement::Up; | 813 return element->upDownState() == SpinButtonElement::Up; |
823 } | 814 } |
824 | 815 |
825 bool RenderTheme::isDefault(const RenderObject* o) const | |
826 { | |
827 return false; | |
828 } | |
829 | |
830 #if !USE(NEW_THEME) | 816 #if !USE(NEW_THEME) |
831 | 817 |
832 void RenderTheme::adjustCheckboxStyle(StyleResolver*, RenderStyle* style, Elemen
t*) const | 818 void RenderTheme::adjustCheckboxStyle(StyleResolver*, RenderStyle* style, Elemen
t*) const |
833 { | 819 { |
834 // A summary of the rules for checkbox designed to match WinIE: | 820 // A summary of the rules for checkbox designed to match WinIE: |
835 // width/height - honored (WinIE actually scales its control for small width
s, but lets it overflow for small heights.) | 821 // width/height - honored (WinIE actually scales its control for small width
s, but lets it overflow for small heights.) |
836 // font-size - not honored (control has no text), but we use it to decide wh
ich control size to use. | 822 // font-size - not honored (control has no text), but we use it to decide wh
ich control size to use. |
837 setCheckboxSize(style); | 823 setCheckboxSize(style); |
838 | 824 |
839 // padding - not honored by WinIE, needs to be removed. | 825 // padding - not honored by WinIE, needs to be removed. |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 | 1201 |
1216 return StringTruncator::centerTruncate(string, width, font, StringTruncator:
:EnableRoundingHacks); | 1202 return StringTruncator::centerTruncate(string, width, font, StringTruncator:
:EnableRoundingHacks); |
1217 } | 1203 } |
1218 | 1204 |
1219 bool RenderTheme::shouldOpenPickerWithF4Key() const | 1205 bool RenderTheme::shouldOpenPickerWithF4Key() const |
1220 { | 1206 { |
1221 return false; | 1207 return false; |
1222 } | 1208 } |
1223 | 1209 |
1224 } // namespace WebCore | 1210 } // namespace WebCore |
OLD | NEW |