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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 return nativeTheme(); | 72 return nativeTheme(); |
73 } | 73 } |
74 | 74 |
75 LayoutTheme::LayoutTheme(Theme* platformTheme) | 75 LayoutTheme::LayoutTheme(Theme* platformTheme) |
76 : m_hasCustomFocusRingColor(false), m_platformTheme(platformTheme) {} | 76 : m_hasCustomFocusRingColor(false), m_platformTheme(platformTheme) {} |
77 | 77 |
78 void LayoutTheme::adjustStyle(ComputedStyle& style, Element* e) { | 78 void LayoutTheme::adjustStyle(ComputedStyle& style, Element* e) { |
79 ASSERT(style.hasAppearance()); | 79 ASSERT(style.hasAppearance()); |
80 | 80 |
81 // Force inline and table display styles to be inline-block (except for table-
which is block) | 81 // Force inline and table display styles to be inline-block (except for table- |
| 82 // which is block) |
82 ControlPart part = style.appearance(); | 83 ControlPart part = style.appearance(); |
83 if (style.display() == EDisplay::Inline || | 84 if (style.display() == EDisplay::Inline || |
84 style.display() == EDisplay::InlineTable || | 85 style.display() == EDisplay::InlineTable || |
85 style.display() == EDisplay::TableRowGroup || | 86 style.display() == EDisplay::TableRowGroup || |
86 style.display() == EDisplay::TableHeaderGroup || | 87 style.display() == EDisplay::TableHeaderGroup || |
87 style.display() == EDisplay::TableFooterGroup || | 88 style.display() == EDisplay::TableFooterGroup || |
88 style.display() == EDisplay::TableRow || | 89 style.display() == EDisplay::TableRow || |
89 style.display() == EDisplay::TableColumnGroup || | 90 style.display() == EDisplay::TableColumnGroup || |
90 style.display() == EDisplay::TableColumn || | 91 style.display() == EDisplay::TableColumn || |
91 style.display() == EDisplay::TableCell || | 92 style.display() == EDisplay::TableCell || |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 style.effectiveZoom()); | 162 style.effectiveZoom()); |
162 if (paddingBox != style.paddingBox()) | 163 if (paddingBox != style.paddingBox()) |
163 style.setPaddingBox(paddingBox); | 164 style.setPaddingBox(paddingBox); |
164 | 165 |
165 // Whitespace | 166 // Whitespace |
166 if (m_platformTheme->controlRequiresPreWhiteSpace(part)) | 167 if (m_platformTheme->controlRequiresPreWhiteSpace(part)) |
167 style.setWhiteSpace(PRE); | 168 style.setWhiteSpace(PRE); |
168 | 169 |
169 // Width / Height | 170 // Width / Height |
170 // The width and height here are affected by the zoom. | 171 // The width and height here are affected by the zoom. |
171 // FIXME: Check is flawed, since it doesn't take min-width/max-width int
o account. | 172 // FIXME: Check is flawed, since it doesn't take min-width/max-width |
| 173 // into account. |
172 LengthSize controlSize = m_platformTheme->controlSize( | 174 LengthSize controlSize = m_platformTheme->controlSize( |
173 part, style.font().getFontDescription(), | 175 part, style.font().getFontDescription(), |
174 LengthSize(style.width(), style.height()), style.effectiveZoom()); | 176 LengthSize(style.width(), style.height()), style.effectiveZoom()); |
175 if (controlSize.width() != style.width()) | 177 if (controlSize.width() != style.width()) |
176 style.setWidth(controlSize.width()); | 178 style.setWidth(controlSize.width()); |
177 if (controlSize.height() != style.height()) | 179 if (controlSize.height() != style.height()) |
178 style.setHeight(controlSize.height()); | 180 style.setHeight(controlSize.height()); |
179 | 181 |
180 // Min-Width / Min-Height | 182 // Min-Width / Min-Height |
181 LengthSize minControlSize = m_platformTheme->minimumControlSize( | 183 LengthSize minControlSize = m_platformTheme->minimumControlSize( |
(...skipping 18 matching lines...) Expand all Loading... |
200 } | 202 } |
201 case ProgressBarPart: | 203 case ProgressBarPart: |
202 adjustProgressBarBounds(style); | 204 adjustProgressBarBounds(style); |
203 break; | 205 break; |
204 default: | 206 default: |
205 break; | 207 break; |
206 } | 208 } |
207 } | 209 } |
208 | 210 |
209 if (!m_platformTheme) { | 211 if (!m_platformTheme) { |
210 // Call the appropriate style adjustment method based off the appearance val
ue. | 212 // Call the appropriate style adjustment method based off the appearance |
| 213 // value. |
211 switch (style.appearance()) { | 214 switch (style.appearance()) { |
212 case CheckboxPart: | 215 case CheckboxPart: |
213 return adjustCheckboxStyle(style); | 216 return adjustCheckboxStyle(style); |
214 case RadioPart: | 217 case RadioPart: |
215 return adjustRadioStyle(style); | 218 return adjustRadioStyle(style); |
216 case PushButtonPart: | 219 case PushButtonPart: |
217 case SquareButtonPart: | 220 case SquareButtonPart: |
218 case ButtonPart: | 221 case ButtonPart: |
219 return adjustButtonStyle(style); | 222 return adjustButtonStyle(style); |
220 case InnerSpinButtonPart: | 223 case InnerSpinButtonPart: |
221 return adjustInnerSpinButtonStyle(style); | 224 return adjustInnerSpinButtonStyle(style); |
222 default: | 225 default: |
223 break; | 226 break; |
224 } | 227 } |
225 } | 228 } |
226 | 229 |
227 // Call the appropriate style adjustment method based off the appearance value
. | 230 // Call the appropriate style adjustment method based off the appearance |
| 231 // value. |
228 switch (style.appearance()) { | 232 switch (style.appearance()) { |
229 case MenulistPart: | 233 case MenulistPart: |
230 return adjustMenuListStyle(style, e); | 234 return adjustMenuListStyle(style, e); |
231 case MenulistButtonPart: | 235 case MenulistButtonPart: |
232 return adjustMenuListButtonStyle(style, e); | 236 return adjustMenuListButtonStyle(style, e); |
233 case SliderHorizontalPart: | 237 case SliderHorizontalPart: |
234 case SliderVerticalPart: | 238 case SliderVerticalPart: |
235 case MediaFullscreenVolumeSliderPart: | 239 case MediaFullscreenVolumeSliderPart: |
236 case MediaSliderPart: | 240 case MediaSliderPart: |
237 case MediaVolumeSliderPart: | 241 case MediaVolumeSliderPart: |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 394 |
391 if (m_platformTheme) | 395 if (m_platformTheme) |
392 return box->size().height() + box->marginTop() + | 396 return box->size().height() + box->marginTop() + |
393 m_platformTheme->baselinePositionAdjustment( | 397 m_platformTheme->baselinePositionAdjustment( |
394 o->style()->appearance()) * | 398 o->style()->appearance()) * |
395 o->style()->effectiveZoom(); | 399 o->style()->effectiveZoom(); |
396 return (box->size().height() + box->marginTop()).toInt(); | 400 return (box->size().height() + box->marginTop()).toInt(); |
397 } | 401 } |
398 | 402 |
399 bool LayoutTheme::isControlContainer(ControlPart appearance) const { | 403 bool LayoutTheme::isControlContainer(ControlPart appearance) const { |
400 // There are more leaves than this, but we'll patch this function as we add su
pport for | 404 // There are more leaves than this, but we'll patch this function as we add |
401 // more controls. | 405 // support for more controls. |
402 return appearance != CheckboxPart && appearance != RadioPart; | 406 return appearance != CheckboxPart && appearance != RadioPart; |
403 } | 407 } |
404 | 408 |
405 bool LayoutTheme::isControlStyled(const ComputedStyle& style) const { | 409 bool LayoutTheme::isControlStyled(const ComputedStyle& style) const { |
406 switch (style.appearance()) { | 410 switch (style.appearance()) { |
407 case PushButtonPart: | 411 case PushButtonPart: |
408 case SquareButtonPart: | 412 case SquareButtonPart: |
409 case ButtonPart: | 413 case ButtonPart: |
410 case ProgressBarPart: | 414 case ProgressBarPart: |
411 return style.hasAuthorBackground() || style.hasAuthorBorder(); | 415 return style.hasAuthorBackground() || style.hasAuthorBorder(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 if (node->isFocused() && !node->shouldHaveFocusAppearance()) | 448 if (node->isFocused() && !node->shouldHaveFocusAppearance()) |
445 return false; | 449 return false; |
446 return true; | 450 return true; |
447 } | 451 } |
448 | 452 |
449 bool LayoutTheme::controlStateChanged(LayoutObject& o, | 453 bool LayoutTheme::controlStateChanged(LayoutObject& o, |
450 ControlState state) const { | 454 ControlState state) const { |
451 if (!o.styleRef().hasAppearance()) | 455 if (!o.styleRef().hasAppearance()) |
452 return false; | 456 return false; |
453 | 457 |
454 // Default implementation assumes the controls don't respond to changes in :ho
ver state | 458 // Default implementation assumes the controls don't respond to changes in |
| 459 // :hover state |
455 if (state == HoverControlState && !supportsHover(o.styleRef())) | 460 if (state == HoverControlState && !supportsHover(o.styleRef())) |
456 return false; | 461 return false; |
457 | 462 |
458 // Assume pressed state is only responded to if the control is enabled. | 463 // Assume pressed state is only responded to if the control is enabled. |
459 if (state == PressedControlState && !isEnabled(o)) | 464 if (state == PressedControlState && !isEnabled(o)) |
460 return false; | 465 return false; |
461 | 466 |
462 o.setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); | 467 o.setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); |
463 return true; | 468 return true; |
464 } | 469 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 Node* node = o.node(); | 578 Node* node = o.node(); |
574 if (!node || !node->isElementNode() || | 579 if (!node || !node->isElementNode() || |
575 !toElement(node)->isSpinButtonElement()) | 580 !toElement(node)->isSpinButtonElement()) |
576 return false; | 581 return false; |
577 SpinButtonElement* element = toSpinButtonElement(node); | 582 SpinButtonElement* element = toSpinButtonElement(node); |
578 return element->getUpDownState() == SpinButtonElement::Up; | 583 return element->getUpDownState() == SpinButtonElement::Up; |
579 } | 584 } |
580 | 585 |
581 void LayoutTheme::adjustCheckboxStyle(ComputedStyle& style) const { | 586 void LayoutTheme::adjustCheckboxStyle(ComputedStyle& style) const { |
582 // A summary of the rules for checkbox designed to match WinIE: | 587 // A summary of the rules for checkbox designed to match WinIE: |
583 // width/height - honored (WinIE actually scales its control for small widths,
but lets it overflow for small heights.) | 588 // width/height - honored (WinIE actually scales its control for small widths, |
584 // font-size - not honored (control has no text), but we use it to decide whic
h control size to use. | 589 // but lets it overflow for small heights.) |
| 590 // font-size - not honored (control has no text), but we use it to decide |
| 591 // which control size to use. |
585 setCheckboxSize(style); | 592 setCheckboxSize(style); |
586 | 593 |
587 // padding - not honored by WinIE, needs to be removed. | 594 // padding - not honored by WinIE, needs to be removed. |
588 style.resetPadding(); | 595 style.resetPadding(); |
589 | 596 |
590 // border - honored by WinIE, but looks terrible (just paints in the control b
ox and turns off the Windows XP theme) | 597 // border - honored by WinIE, but looks terrible (just paints in the control |
591 // for now, we will not honor it. | 598 // box and turns off the Windows XP theme) for now, we will not honor it. |
592 style.resetBorder(); | 599 style.resetBorder(); |
593 } | 600 } |
594 | 601 |
595 void LayoutTheme::adjustRadioStyle(ComputedStyle& style) const { | 602 void LayoutTheme::adjustRadioStyle(ComputedStyle& style) const { |
596 // A summary of the rules for checkbox designed to match WinIE: | 603 // A summary of the rules for checkbox designed to match WinIE: |
597 // width/height - honored (WinIE actually scales its control for small widths,
but lets it overflow for small heights.) | 604 // width/height - honored (WinIE actually scales its control for small widths, |
598 // font-size - not honored (control has no text), but we use it to decide whic
h control size to use. | 605 // but lets it overflow for small heights.) |
| 606 // font-size - not honored (control has no text), but we use it to decide |
| 607 // which control size to use. |
599 setRadioSize(style); | 608 setRadioSize(style); |
600 | 609 |
601 // padding - not honored by WinIE, needs to be removed. | 610 // padding - not honored by WinIE, needs to be removed. |
602 style.resetPadding(); | 611 style.resetPadding(); |
603 | 612 |
604 // border - honored by WinIE, but looks terrible (just paints in the control b
ox and turns off the Windows XP theme) | 613 // border - honored by WinIE, but looks terrible (just paints in the control |
605 // for now, we will not honor it. | 614 // box and turns off the Windows XP theme) for now, we will not honor it. |
606 style.resetBorder(); | 615 style.resetBorder(); |
607 } | 616 } |
608 | 617 |
609 void LayoutTheme::adjustButtonStyle(ComputedStyle& style) const {} | 618 void LayoutTheme::adjustButtonStyle(ComputedStyle& style) const {} |
610 | 619 |
611 void LayoutTheme::adjustInnerSpinButtonStyle(ComputedStyle&) const {} | 620 void LayoutTheme::adjustInnerSpinButtonStyle(ComputedStyle&) const {} |
612 | 621 |
613 void LayoutTheme::adjustMenuListStyle(ComputedStyle&, Element*) const {} | 622 void LayoutTheme::adjustMenuListStyle(ComputedStyle&, Element*) const {} |
614 | 623 |
615 double LayoutTheme::animationRepeatIntervalForProgressBar() const { | 624 double LayoutTheme::animationRepeatIntervalForProgressBar() const { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 IntSize size = Platform::current()->fallbackThemeEngine()->getSize( | 896 IntSize size = Platform::current()->fallbackThemeEngine()->getSize( |
888 WebFallbackThemeEngine::PartCheckbox); | 897 WebFallbackThemeEngine::PartCheckbox); |
889 float zoomLevel = style.effectiveZoom(); | 898 float zoomLevel = style.effectiveZoom(); |
890 size.setWidth(size.width() * zoomLevel); | 899 size.setWidth(size.width() * zoomLevel); |
891 size.setHeight(size.height() * zoomLevel); | 900 size.setHeight(size.height() * zoomLevel); |
892 setSizeIfAuto(style, size); | 901 setSizeIfAuto(style, size); |
893 | 902 |
894 // padding - not honored by WinIE, needs to be removed. | 903 // padding - not honored by WinIE, needs to be removed. |
895 style.resetPadding(); | 904 style.resetPadding(); |
896 | 905 |
897 // border - honored by WinIE, but looks terrible (just paints in the control b
ox and turns off the Windows XP theme) | 906 // border - honored by WinIE, but looks terrible (just paints in the control |
| 907 // box and turns off the Windows XP theme) |
898 // for now, we will not honor it. | 908 // for now, we will not honor it. |
899 style.resetBorder(); | 909 style.resetBorder(); |
900 } | 910 } |
901 | 911 |
902 void LayoutTheme::adjustRadioStyleUsingFallbackTheme( | 912 void LayoutTheme::adjustRadioStyleUsingFallbackTheme( |
903 ComputedStyle& style) const { | 913 ComputedStyle& style) const { |
904 // If the width and height are both specified, then we have nothing to do. | 914 // If the width and height are both specified, then we have nothing to do. |
905 if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto()) | 915 if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto()) |
906 return; | 916 return; |
907 | 917 |
908 IntSize size = Platform::current()->fallbackThemeEngine()->getSize( | 918 IntSize size = Platform::current()->fallbackThemeEngine()->getSize( |
909 WebFallbackThemeEngine::PartRadio); | 919 WebFallbackThemeEngine::PartRadio); |
910 float zoomLevel = style.effectiveZoom(); | 920 float zoomLevel = style.effectiveZoom(); |
911 size.setWidth(size.width() * zoomLevel); | 921 size.setWidth(size.width() * zoomLevel); |
912 size.setHeight(size.height() * zoomLevel); | 922 size.setHeight(size.height() * zoomLevel); |
913 setSizeIfAuto(style, size); | 923 setSizeIfAuto(style, size); |
914 | 924 |
915 // padding - not honored by WinIE, needs to be removed. | 925 // padding - not honored by WinIE, needs to be removed. |
916 style.resetPadding(); | 926 style.resetPadding(); |
917 | 927 |
918 // border - honored by WinIE, but looks terrible (just paints in the control b
ox and turns off the Windows XP theme) | 928 // border - honored by WinIE, but looks terrible (just paints in the control |
| 929 // box and turns off the Windows XP theme) |
919 // for now, we will not honor it. | 930 // for now, we will not honor it. |
920 style.resetBorder(); | 931 style.resetBorder(); |
921 } | 932 } |
922 | 933 |
923 } // namespace blink | 934 } // namespace blink |
OLD | NEW |