Chromium Code Reviews| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 } | 80 } |
| 81 | 81 |
| 82 LayoutTheme::LayoutTheme() | 82 LayoutTheme::LayoutTheme() |
| 83 : m_hasCustomFocusRingColor(false) | 83 : m_hasCustomFocusRingColor(false) |
| 84 #if USE(NEW_THEME) | 84 #if USE(NEW_THEME) |
| 85 , m_platformTheme(platformTheme()) | 85 , m_platformTheme(platformTheme()) |
| 86 #endif | 86 #endif |
| 87 { | 87 { |
| 88 } | 88 } |
| 89 | 89 |
| 90 void LayoutTheme::adjustStyle(RenderStyle* style, Element* e, const CachedUAStyl e* uaStyle) | 90 void LayoutTheme::adjustStyle(RenderStyle& style, Element* e, const CachedUAStyl e* uaStyle) |
| 91 { | 91 { |
| 92 // Force inline and table display styles to be inline-block (except for tabl e- which is block) | 92 // Force inline and table display styles to be inline-block (except for tabl e- which is block) |
| 93 ControlPart part = style->appearance(); | 93 ControlPart part = style.appearance(); |
| 94 if (style->display() == INLINE || style->display() == INLINE_TABLE || style- >display() == TABLE_ROW_GROUP | 94 if (style.display() == INLINE || style.display() == INLINE_TABLE || style.di splay() == TABLE_ROW_GROUP |
| 95 || style->display() == TABLE_HEADER_GROUP || style->display() == TABLE_F OOTER_GROUP | 95 || style.display() == TABLE_HEADER_GROUP || style.display() == TABLE_FOO TER_GROUP |
| 96 || style->display() == TABLE_ROW || style->display() == TABLE_COLUMN_GRO UP || style->display() == TABLE_COLUMN | 96 || style.display() == TABLE_ROW || style.display() == TABLE_COLUMN_GROUP || style.display() == TABLE_COLUMN |
| 97 || style->display() == TABLE_CELL || style->display() == TABLE_CAPTION) | 97 || style.display() == TABLE_CELL || style.display() == TABLE_CAPTION) |
| 98 style->setDisplay(INLINE_BLOCK); | 98 style.setDisplay(INLINE_BLOCK); |
| 99 else if (style->display() == LIST_ITEM || style->display() == TABLE) | 99 else if (style.display() == LIST_ITEM || style.display() == TABLE) |
| 100 style->setDisplay(BLOCK); | 100 style.setDisplay(BLOCK); |
| 101 | 101 |
| 102 if (uaStyle && isControlStyled(style, uaStyle)) { | 102 if (uaStyle && isControlStyled(style, uaStyle)) { |
| 103 if (part == MenulistPart) { | 103 if (part == MenulistPart) { |
| 104 style->setAppearance(MenulistButtonPart); | 104 style.setAppearance(MenulistButtonPart); |
| 105 part = MenulistButtonPart; | 105 part = MenulistButtonPart; |
| 106 } else { | 106 } else { |
| 107 style->setAppearance(NoControlPart); | 107 style.setAppearance(NoControlPart); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 if (!style->hasAppearance()) | 111 if (!style.hasAppearance()) |
| 112 return; | 112 return; |
| 113 | 113 |
| 114 if (shouldUseFallbackTheme(style)) { | 114 if (shouldUseFallbackTheme(style)) { |
| 115 adjustStyleUsingFallbackTheme(style, e); | 115 adjustStyleUsingFallbackTheme(style, e); |
| 116 return; | 116 return; |
| 117 } | 117 } |
| 118 | 118 |
| 119 #if USE(NEW_THEME) | 119 #if USE(NEW_THEME) |
| 120 switch (part) { | 120 switch (part) { |
| 121 case CheckboxPart: | 121 case CheckboxPart: |
| 122 case InnerSpinButtonPart: | 122 case InnerSpinButtonPart: |
| 123 case RadioPart: | 123 case RadioPart: |
| 124 case PushButtonPart: | 124 case PushButtonPart: |
| 125 case SquareButtonPart: | 125 case SquareButtonPart: |
| 126 case ButtonPart: { | 126 case ButtonPart: { |
| 127 // Border | 127 // Border |
| 128 LengthBox borderBox(style->borderTopWidth(), style->borderRightWidth(), style->borderBottomWidth(), style->borderLeftWidth()); | 128 LengthBox borderBox(style.borderTopWidth(), style.borderRightWidth(), st yle.borderBottomWidth(), style.borderLeftWidth()); |
| 129 borderBox = m_platformTheme->controlBorder(part, style->font().fontDescr iption(), borderBox, style->effectiveZoom()); | 129 borderBox = m_platformTheme->controlBorder(part, style.font().fontDescri ption(), borderBox, style.effectiveZoom()); |
| 130 if (borderBox.top().value() != static_cast<int>(style->borderTopWidth()) ) { | 130 if (borderBox.top().value() != static_cast<int>(style.borderTopWidth())) { |
| 131 if (borderBox.top().value()) | 131 if (borderBox.top().value()) |
| 132 style->setBorderTopWidth(borderBox.top().value()); | 132 style.setBorderTopWidth(borderBox.top().value()); |
| 133 else | 133 else |
| 134 style->resetBorderTop(); | 134 style.resetBorderTop(); |
| 135 } | 135 } |
| 136 if (borderBox.right().value() != static_cast<int>(style->borderRightWidt h())) { | 136 if (borderBox.right().value() != static_cast<int>(style.borderRightWidth ())) { |
| 137 if (borderBox.right().value()) | 137 if (borderBox.right().value()) |
| 138 style->setBorderRightWidth(borderBox.right().value()); | 138 style.setBorderRightWidth(borderBox.right().value()); |
| 139 else | 139 else |
| 140 style->resetBorderRight(); | 140 style.resetBorderRight(); |
| 141 } | 141 } |
| 142 if (borderBox.bottom().value() != static_cast<int>(style->borderBottomWi dth())) { | 142 if (borderBox.bottom().value() != static_cast<int>(style.borderBottomWid th())) { |
| 143 style->setBorderBottomWidth(borderBox.bottom().value()); | 143 style.setBorderBottomWidth(borderBox.bottom().value()); |
| 144 if (borderBox.bottom().value()) | 144 if (borderBox.bottom().value()) |
| 145 style->setBorderBottomWidth(borderBox.bottom().value()); | 145 style.setBorderBottomWidth(borderBox.bottom().value()); |
| 146 else | 146 else |
| 147 style->resetBorderBottom(); | 147 style.resetBorderBottom(); |
| 148 } | 148 } |
| 149 if (borderBox.left().value() != static_cast<int>(style->borderLeftWidth( ))) { | 149 if (borderBox.left().value() != static_cast<int>(style.borderLeftWidth() )) { |
| 150 style->setBorderLeftWidth(borderBox.left().value()); | 150 style.setBorderLeftWidth(borderBox.left().value()); |
| 151 if (borderBox.left().value()) | 151 if (borderBox.left().value()) |
| 152 style->setBorderLeftWidth(borderBox.left().value()); | 152 style.setBorderLeftWidth(borderBox.left().value()); |
| 153 else | 153 else |
| 154 style->resetBorderLeft(); | 154 style.resetBorderLeft(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Padding | 157 // Padding |
| 158 LengthBox paddingBox = m_platformTheme->controlPadding(part, style->font ().fontDescription(), style->paddingBox(), style->effectiveZoom()); | 158 LengthBox paddingBox = m_platformTheme->controlPadding(part, style.font( ).fontDescription(), style.paddingBox(), style.effectiveZoom()); |
| 159 if (paddingBox != style->paddingBox()) | 159 if (paddingBox != style.paddingBox()) |
| 160 style->setPaddingBox(paddingBox); | 160 style.setPaddingBox(paddingBox); |
| 161 | 161 |
| 162 // Whitespace | 162 // Whitespace |
| 163 if (m_platformTheme->controlRequiresPreWhiteSpace(part)) | 163 if (m_platformTheme->controlRequiresPreWhiteSpace(part)) |
| 164 style->setWhiteSpace(PRE); | 164 style.setWhiteSpace(PRE); |
| 165 | 165 |
| 166 // Width / Height | 166 // Width / Height |
| 167 // The width and height here are affected by the zoom. | 167 // The width and height here are affected by the zoom. |
| 168 // FIXME: Check is flawed, since it doesn't take min-width/max-width int o account. | 168 // FIXME: Check is flawed, since it doesn't take min-width/max-width int o account. |
| 169 LengthSize controlSize = m_platformTheme->controlSize(part, style->font( ).fontDescription(), LengthSize(style->width(), style->height()), style->effecti veZoom()); | 169 LengthSize controlSize = m_platformTheme->controlSize(part, style.font() .fontDescription(), LengthSize(style.width(), style.height()), style.effectiveZo om()); |
| 170 if (controlSize.width() != style->width()) | 170 if (controlSize.width() != style.width()) |
| 171 style->setWidth(controlSize.width()); | 171 style.setWidth(controlSize.width()); |
| 172 if (controlSize.height() != style->height()) | 172 if (controlSize.height() != style.height()) |
| 173 style->setHeight(controlSize.height()); | 173 style.setHeight(controlSize.height()); |
| 174 | 174 |
| 175 // Min-Width / Min-Height | 175 // Min-Width / Min-Height |
| 176 LengthSize minControlSize = m_platformTheme->minimumControlSize(part, st yle->font().fontDescription(), style->effectiveZoom()); | 176 LengthSize minControlSize = m_platformTheme->minimumControlSize(part, st yle.font().fontDescription(), style.effectiveZoom()); |
| 177 if (minControlSize.width() != style->minWidth()) | 177 if (minControlSize.width() != style.minWidth()) |
| 178 style->setMinWidth(minControlSize.width()); | 178 style.setMinWidth(minControlSize.width()); |
| 179 if (minControlSize.height() != style->minHeight()) | 179 if (minControlSize.height() != style.minHeight()) |
| 180 style->setMinHeight(minControlSize.height()); | 180 style.setMinHeight(minControlSize.height()); |
| 181 | 181 |
| 182 // Font | 182 // Font |
| 183 FontDescription controlFont = m_platformTheme->controlFont(part, style-> font().fontDescription(), style->effectiveZoom()); | 183 FontDescription controlFont = m_platformTheme->controlFont(part, style.f ont().fontDescription(), style.effectiveZoom()); |
| 184 if (controlFont != style->font().fontDescription()) { | 184 if (controlFont != style.font().fontDescription()) { |
| 185 // Reset our line-height | 185 // Reset our line-height |
| 186 style->setLineHeight(RenderStyle::initialLineHeight()); | 186 style.setLineHeight(RenderStyle::initialLineHeight()); |
| 187 | 187 |
| 188 // Now update our font. | 188 // Now update our font. |
| 189 if (style->setFontDescription(controlFont)) | 189 if (style.setFontDescription(controlFont)) |
| 190 style->font().update(nullptr); | 190 style.font().update(nullptr); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 default: | 193 default: |
| 194 break; | 194 break; |
| 195 } | 195 } |
| 196 #endif | 196 #endif |
| 197 | 197 |
| 198 // Call the appropriate style adjustment method based off the appearance val ue. | 198 // Call the appropriate style adjustment method based off the appearance val ue. |
| 199 switch (style->appearance()) { | 199 switch (style.appearance()) { |
| 200 #if !USE(NEW_THEME) | 200 #if !USE(NEW_THEME) |
| 201 case CheckboxPart: | 201 case CheckboxPart: |
| 202 return adjustCheckboxStyle(style, e); | 202 return adjustCheckboxStyle(style, e); |
| 203 case RadioPart: | 203 case RadioPart: |
| 204 return adjustRadioStyle(style, e); | 204 return adjustRadioStyle(style, e); |
| 205 case PushButtonPart: | 205 case PushButtonPart: |
| 206 case SquareButtonPart: | 206 case SquareButtonPart: |
| 207 case ButtonPart: | 207 case ButtonPart: |
| 208 return adjustButtonStyle(style, e); | 208 return adjustButtonStyle(style, e); |
| 209 case InnerSpinButtonPart: | 209 case InnerSpinButtonPart: |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 224 return adjustSearchFieldDecorationStyle(style, e); | 224 return adjustSearchFieldDecorationStyle(style, e); |
| 225 case SearchFieldResultsDecorationPart: | 225 case SearchFieldResultsDecorationPart: |
| 226 return adjustSearchFieldResultsDecorationStyle(style, e); | 226 return adjustSearchFieldResultsDecorationStyle(style, e); |
| 227 default: | 227 default: |
| 228 break; | 228 break; |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool LayoutTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRe ct& r) | 232 bool LayoutTheme::paint(RenderObject* o, const PaintInfo& paintInfo, const IntRe ct& r) |
| 233 { | 233 { |
| 234 ControlPart part = o->style()->appearance(); | 234 ControlPart part = o->styleRef().appearance(); |
| 235 | 235 |
| 236 if (shouldUseFallbackTheme(o->style())) | 236 if (shouldUseFallbackTheme(o->styleRef())) |
| 237 return paintUsingFallbackTheme(o, paintInfo, r); | 237 return paintUsingFallbackTheme(o, paintInfo, r); |
| 238 | 238 |
| 239 #if USE(NEW_THEME) | 239 #if USE(NEW_THEME) |
| 240 switch (part) { | 240 switch (part) { |
| 241 case CheckboxPart: | 241 case CheckboxPart: |
| 242 case RadioPart: | 242 case RadioPart: |
| 243 case PushButtonPart: | 243 case PushButtonPart: |
| 244 case SquareButtonPart: | 244 case SquareButtonPart: |
| 245 case ButtonPart: | 245 case ButtonPart: |
| 246 case InnerSpinButtonPart: | 246 case InnerSpinButtonPart: |
| 247 m_platformTheme->paint(part, controlStatesForRenderer(o), const_cast<Gra phicsContext*>(paintInfo.context), r, o->style()->effectiveZoom(), o->view()->fr ameView()); | 247 m_platformTheme->paint(part, controlStatesForRenderer(o), const_cast<Gra phicsContext*>(paintInfo.context), r, o->styleRef().effectiveZoom(), o->view()-> frameView()); |
| 248 return false; | 248 return false; |
| 249 default: | 249 default: |
| 250 break; | 250 break; |
| 251 } | 251 } |
| 252 #endif | 252 #endif |
| 253 | 253 |
| 254 // Call the appropriate paint method based off the appearance value. | 254 // Call the appropriate paint method based off the appearance value. |
| 255 switch (part) { | 255 switch (part) { |
| 256 #if !USE(NEW_THEME) | 256 #if !USE(NEW_THEME) |
| 257 case CheckboxPart: | 257 case CheckboxPart: |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 backgroundCopy.setRepeatX(NoRepeatFill); | 553 backgroundCopy.setRepeatX(NoRepeatFill); |
| 554 backgroundCopy.setRepeatY(NoRepeatFill); | 554 backgroundCopy.setRepeatY(NoRepeatFill); |
| 555 backgroundLayersCopy.setRepeatX(NoRepeatFill); | 555 backgroundLayersCopy.setRepeatX(NoRepeatFill); |
| 556 backgroundLayersCopy.setRepeatY(NoRepeatFill); | 556 backgroundLayersCopy.setRepeatY(NoRepeatFill); |
| 557 // Test the style to see if the UA border and background match. | 557 // Test the style to see if the UA border and background match. |
| 558 return style.border() != uaStyle.border | 558 return style.border() != uaStyle.border |
| 559 || backgroundLayersCopy != backgroundCopy | 559 || backgroundLayersCopy != backgroundCopy |
| 560 || style.visitedDependentColor(CSSPropertyBackgroundColor) != uaStyle.ba ckgroundColor; | 560 || style.visitedDependentColor(CSSPropertyBackgroundColor) != uaStyle.ba ckgroundColor; |
| 561 } | 561 } |
| 562 | 562 |
| 563 bool LayoutTheme::isControlStyled(const RenderStyle* style, const CachedUAStyle* uaStyle) const | 563 bool LayoutTheme::isControlStyled(const RenderStyle& style, const CachedUAStyle* uaStyle) const |
|
dsinclair
2015/02/04 21:59:29
Make uaStyle a ref as well? We immediately ASSERT(
Julien - ping for review
2015/02/04 22:32:18
That's a good point. However it's unclear if uaSty
| |
| 564 { | 564 { |
| 565 ASSERT(uaStyle); | 565 ASSERT(uaStyle); |
| 566 | 566 |
| 567 switch (style->appearance()) { | 567 switch (style.appearance()) { |
| 568 case PushButtonPart: | 568 case PushButtonPart: |
| 569 case SquareButtonPart: | 569 case SquareButtonPart: |
| 570 case ButtonPart: | 570 case ButtonPart: |
| 571 case ProgressBarPart: | 571 case ProgressBarPart: |
| 572 case MeterPart: | 572 case MeterPart: |
| 573 case RelevancyLevelIndicatorPart: | 573 case RelevancyLevelIndicatorPart: |
| 574 case ContinuousCapacityLevelIndicatorPart: | 574 case ContinuousCapacityLevelIndicatorPart: |
| 575 case DiscreteCapacityLevelIndicatorPart: | 575 case DiscreteCapacityLevelIndicatorPart: |
| 576 case RatingLevelIndicatorPart: | 576 case RatingLevelIndicatorPart: |
| 577 return isBackgroundOrBorderStyled(*style, *uaStyle); | 577 return isBackgroundOrBorderStyled(style, *uaStyle); |
| 578 | 578 |
| 579 case MenulistPart: | 579 case MenulistPart: |
| 580 case SearchFieldPart: | 580 case SearchFieldPart: |
| 581 case TextAreaPart: | 581 case TextAreaPart: |
| 582 case TextFieldPart: | 582 case TextFieldPart: |
| 583 return isBackgroundOrBorderStyled(*style, *uaStyle) || style->boxShadow( ); | 583 return isBackgroundOrBorderStyled(style, *uaStyle) || style.boxShadow(); |
| 584 | 584 |
| 585 case SliderHorizontalPart: | 585 case SliderHorizontalPart: |
| 586 case SliderVerticalPart: | 586 case SliderVerticalPart: |
| 587 return style->boxShadow(); | 587 return style.boxShadow(); |
| 588 | 588 |
| 589 default: | 589 default: |
| 590 return false; | 590 return false; |
| 591 } | 591 } |
| 592 } | 592 } |
| 593 | 593 |
| 594 void LayoutTheme::adjustPaintInvalidationRect(const RenderObject* o, IntRect& r) | 594 void LayoutTheme::adjustPaintInvalidationRect(const RenderObject* o, IntRect& r) |
| 595 { | 595 { |
| 596 #if USE(NEW_THEME) | 596 #if USE(NEW_THEME) |
| 597 m_platformTheme->inflateControlPaintRect(o->style()->appearance(), controlSt atesForRenderer(o), r, o->style()->effectiveZoom()); | 597 m_platformTheme->inflateControlPaintRect(o->style()->appearance(), controlSt atesForRenderer(o), r, o->style()->effectiveZoom()); |
| 598 #endif | 598 #endif |
| 599 } | 599 } |
| 600 | 600 |
| 601 bool LayoutTheme::shouldDrawDefaultFocusRing(RenderObject* renderer) const | 601 bool LayoutTheme::shouldDrawDefaultFocusRing(RenderObject* renderer) const |
| 602 { | 602 { |
| 603 if (supportsFocusRing(renderer->style())) | 603 if (supportsFocusRing(renderer->styleRef())) |
| 604 return false; | 604 return false; |
| 605 Node* node = renderer->node(); | 605 Node* node = renderer->node(); |
| 606 if (!node) | 606 if (!node) |
| 607 return true; | 607 return true; |
| 608 if (!renderer->style()->hasAppearance() && !node->isLink()) | 608 if (!renderer->styleRef().hasAppearance() && !node->isLink()) |
| 609 return true; | 609 return true; |
| 610 // We can't use LayoutTheme::isFocused because outline:auto might be | 610 // We can't use LayoutTheme::isFocused because outline:auto might be |
| 611 // specified to non-:focus rulesets. | 611 // specified to non-:focus rulesets. |
| 612 if (node->focused() && !node->shouldHaveFocusAppearance()) | 612 if (node->focused() && !node->shouldHaveFocusAppearance()) |
| 613 return false; | 613 return false; |
| 614 return true; | 614 return true; |
| 615 } | 615 } |
| 616 | 616 |
| 617 bool LayoutTheme::supportsFocusRing(const RenderStyle* style) const | 617 bool LayoutTheme::supportsFocusRing(const RenderStyle& style) const |
| 618 { | 618 { |
| 619 return (style->hasAppearance() && style->appearance() != TextFieldPart && st yle->appearance() != TextAreaPart && style->appearance() != MenulistButtonPart & & style->appearance() != ListboxPart); | 619 return (style.hasAppearance() && style.appearance() != TextFieldPart && styl e.appearance() != TextAreaPart && style.appearance() != MenulistButtonPart && st yle.appearance() != ListboxPart); |
| 620 } | 620 } |
| 621 | 621 |
| 622 bool LayoutTheme::stateChanged(RenderObject* o, ControlState state) const | 622 bool LayoutTheme::stateChanged(RenderObject* o, ControlState state) const |
| 623 { | 623 { |
| 624 // Default implementation assumes the controls don't respond to changes in : hover state | 624 // Default implementation assumes the controls don't respond to changes in : hover state |
| 625 if (state == HoverControlState && !supportsHover(o->style())) | 625 if (state == HoverControlState && !supportsHover(o->styleRef())) |
| 626 return false; | 626 return false; |
| 627 | 627 |
| 628 // Assume pressed state is only responded to if the control is enabled. | 628 // Assume pressed state is only responded to if the control is enabled. |
| 629 if (state == PressedControlState && !isEnabled(o)) | 629 if (state == PressedControlState && !isEnabled(o)) |
| 630 return false; | 630 return false; |
| 631 | 631 |
| 632 o->setShouldDoFullPaintInvalidation(); | 632 o->setShouldDoFullPaintInvalidation(); |
| 633 return true; | 633 return true; |
| 634 } | 634 } |
| 635 | 635 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 { | 749 { |
| 750 Node* node = o->node(); | 750 Node* node = o->node(); |
| 751 if (!node || !node->isElementNode() || !toElement(node)->isSpinButtonElement ()) | 751 if (!node || !node->isElementNode() || !toElement(node)->isSpinButtonElement ()) |
| 752 return false; | 752 return false; |
| 753 SpinButtonElement* element = toSpinButtonElement(node); | 753 SpinButtonElement* element = toSpinButtonElement(node); |
| 754 return element->upDownState() == SpinButtonElement::Up; | 754 return element->upDownState() == SpinButtonElement::Up; |
| 755 } | 755 } |
| 756 | 756 |
| 757 #if !USE(NEW_THEME) | 757 #if !USE(NEW_THEME) |
| 758 | 758 |
| 759 void LayoutTheme::adjustCheckboxStyle(RenderStyle* style, Element*) const | 759 void LayoutTheme::adjustCheckboxStyle(RenderStyle& style, Element*) const |
| 760 { | 760 { |
| 761 // A summary of the rules for checkbox designed to match WinIE: | 761 // A summary of the rules for checkbox designed to match WinIE: |
| 762 // width/height - honored (WinIE actually scales its control for small width s, but lets it overflow for small heights.) | 762 // width/height - honored (WinIE actually scales its control for small width s, but lets it overflow for small heights.) |
| 763 // font-size - not honored (control has no text), but we use it to decide wh ich control size to use. | 763 // font-size - not honored (control has no text), but we use it to decide wh ich control size to use. |
| 764 setCheckboxSize(style); | 764 setCheckboxSize(style); |
| 765 | 765 |
| 766 // padding - not honored by WinIE, needs to be removed. | 766 // padding - not honored by WinIE, needs to be removed. |
| 767 style->resetPadding(); | 767 style.resetPadding(); |
| 768 | 768 |
| 769 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) | 769 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) |
| 770 // for now, we will not honor it. | 770 // for now, we will not honor it. |
| 771 style->resetBorder(); | 771 style.resetBorder(); |
| 772 } | 772 } |
| 773 | 773 |
| 774 void LayoutTheme::adjustRadioStyle(RenderStyle* style, Element*) const | 774 void LayoutTheme::adjustRadioStyle(RenderStyle& style, Element*) const |
| 775 { | 775 { |
| 776 // A summary of the rules for checkbox designed to match WinIE: | 776 // A summary of the rules for checkbox designed to match WinIE: |
| 777 // width/height - honored (WinIE actually scales its control for small width s, but lets it overflow for small heights.) | 777 // width/height - honored (WinIE actually scales its control for small width s, but lets it overflow for small heights.) |
| 778 // font-size - not honored (control has no text), but we use it to decide wh ich control size to use. | 778 // font-size - not honored (control has no text), but we use it to decide wh ich control size to use. |
| 779 setRadioSize(style); | 779 setRadioSize(style); |
| 780 | 780 |
| 781 // padding - not honored by WinIE, needs to be removed. | 781 // padding - not honored by WinIE, needs to be removed. |
| 782 style->resetPadding(); | 782 style.resetPadding(); |
| 783 | 783 |
| 784 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) | 784 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) |
| 785 // for now, we will not honor it. | 785 // for now, we will not honor it. |
| 786 style->resetBorder(); | 786 style.resetBorder(); |
| 787 } | 787 } |
| 788 | 788 |
| 789 void LayoutTheme::adjustButtonStyle(RenderStyle* style, Element*) const | 789 void LayoutTheme::adjustButtonStyle(RenderStyle& style, Element*) const |
| 790 { | 790 { |
| 791 } | 791 } |
| 792 | 792 |
| 793 void LayoutTheme::adjustInnerSpinButtonStyle(RenderStyle*, Element*) const | 793 void LayoutTheme::adjustInnerSpinButtonStyle(RenderStyle&, Element*) const |
| 794 { | 794 { |
| 795 } | 795 } |
| 796 #endif | 796 #endif |
| 797 | 797 |
| 798 void LayoutTheme::adjustMenuListStyle(RenderStyle*, Element*) const | 798 void LayoutTheme::adjustMenuListStyle(RenderStyle&, Element*) const |
| 799 { | 799 { |
| 800 } | 800 } |
| 801 | 801 |
| 802 IntSize LayoutTheme::meterSizeForBounds(const RenderMeter*, const IntRect& bound s) const | 802 IntSize LayoutTheme::meterSizeForBounds(const RenderMeter*, const IntRect& bound s) const |
| 803 { | 803 { |
| 804 return bounds.size(); | 804 return bounds.size(); |
| 805 } | 805 } |
| 806 | 806 |
| 807 bool LayoutTheme::supportsMeter(ControlPart) const | 807 bool LayoutTheme::supportsMeter(ControlPart) const |
| 808 { | 808 { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 832 double max = input->maximum(); | 832 double max = input->maximum(); |
| 833 ControlPart part = o->style()->appearance(); | 833 ControlPart part = o->style()->appearance(); |
| 834 // We don't support ticks on alternate sliders like MediaVolumeSliders. | 834 // We don't support ticks on alternate sliders like MediaVolumeSliders. |
| 835 if (part != SliderHorizontalPart && part != SliderVerticalPart) | 835 if (part != SliderHorizontalPart && part != SliderVerticalPart) |
| 836 return; | 836 return; |
| 837 bool isHorizontal = part == SliderHorizontalPart; | 837 bool isHorizontal = part == SliderHorizontalPart; |
| 838 | 838 |
| 839 IntSize thumbSize; | 839 IntSize thumbSize; |
| 840 RenderObject* thumbRenderer = input->userAgentShadowRoot()->getElementById(S hadowElementNames::sliderThumb())->renderer(); | 840 RenderObject* thumbRenderer = input->userAgentShadowRoot()->getElementById(S hadowElementNames::sliderThumb())->renderer(); |
| 841 if (thumbRenderer) { | 841 if (thumbRenderer) { |
| 842 RenderStyle* thumbStyle = thumbRenderer->style(); | 842 const RenderStyle& thumbStyle = thumbRenderer->styleRef(); |
| 843 int thumbWidth = thumbStyle->width().intValue(); | 843 int thumbWidth = thumbStyle.width().intValue(); |
| 844 int thumbHeight = thumbStyle->height().intValue(); | 844 int thumbHeight = thumbStyle.height().intValue(); |
| 845 thumbSize.setWidth(isHorizontal ? thumbWidth : thumbHeight); | 845 thumbSize.setWidth(isHorizontal ? thumbWidth : thumbHeight); |
| 846 thumbSize.setHeight(isHorizontal ? thumbHeight : thumbWidth); | 846 thumbSize.setHeight(isHorizontal ? thumbHeight : thumbWidth); |
| 847 } | 847 } |
| 848 | 848 |
| 849 IntSize tickSize = sliderTickSize(); | 849 IntSize tickSize = sliderTickSize(); |
| 850 float zoomFactor = o->style()->effectiveZoom(); | 850 float zoomFactor = o->style()->effectiveZoom(); |
| 851 FloatRect tickRect; | 851 FloatRect tickRect; |
| 852 int tickRegionSideMargin = 0; | 852 int tickRegionSideMargin = 0; |
| 853 int tickRegionWidth = 0; | 853 int tickRegionWidth = 0; |
| 854 IntRect trackBounds; | 854 IntRect trackBounds; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 900 double LayoutTheme::animationDurationForProgressBar(RenderProgress*) const | 900 double LayoutTheme::animationDurationForProgressBar(RenderProgress*) const |
| 901 { | 901 { |
| 902 return 0; | 902 return 0; |
| 903 } | 903 } |
| 904 | 904 |
| 905 bool LayoutTheme::shouldHaveSpinButton(HTMLInputElement* inputElement) const | 905 bool LayoutTheme::shouldHaveSpinButton(HTMLInputElement* inputElement) const |
| 906 { | 906 { |
| 907 return inputElement->isSteppable() && inputElement->type() != InputTypeNames ::range; | 907 return inputElement->isSteppable() && inputElement->type() != InputTypeNames ::range; |
| 908 } | 908 } |
| 909 | 909 |
| 910 void LayoutTheme::adjustMenuListButtonStyle(RenderStyle*, Element*) const | 910 void LayoutTheme::adjustMenuListButtonStyle(RenderStyle&, Element*) const |
| 911 { | 911 { |
| 912 } | 912 } |
| 913 | 913 |
| 914 void LayoutTheme::adjustSliderThumbStyle(RenderStyle* style, Element* element) c onst | 914 void LayoutTheme::adjustSliderThumbStyle(RenderStyle& style, Element* element) c onst |
| 915 { | 915 { |
| 916 adjustSliderThumbSize(style, element); | 916 adjustSliderThumbSize(style, element); |
| 917 } | 917 } |
| 918 | 918 |
| 919 void LayoutTheme::adjustSliderThumbSize(RenderStyle*, Element*) const | 919 void LayoutTheme::adjustSliderThumbSize(RenderStyle&, Element*) const |
| 920 { | 920 { |
| 921 } | 921 } |
| 922 | 922 |
| 923 void LayoutTheme::adjustSearchFieldStyle(RenderStyle*, Element*) const | 923 void LayoutTheme::adjustSearchFieldStyle(RenderStyle&, Element*) const |
| 924 { | 924 { |
| 925 } | 925 } |
| 926 | 926 |
| 927 void LayoutTheme::adjustSearchFieldCancelButtonStyle(RenderStyle*, Element*) con st | 927 void LayoutTheme::adjustSearchFieldCancelButtonStyle(RenderStyle&, Element*) con st |
| 928 { | 928 { |
| 929 } | 929 } |
| 930 | 930 |
| 931 void LayoutTheme::adjustSearchFieldDecorationStyle(RenderStyle*, Element*) const | 931 void LayoutTheme::adjustSearchFieldDecorationStyle(RenderStyle&, Element*) const |
| 932 { | 932 { |
| 933 } | 933 } |
| 934 | 934 |
| 935 void LayoutTheme::adjustSearchFieldResultsDecorationStyle(RenderStyle*, Element* ) const | 935 void LayoutTheme::adjustSearchFieldResultsDecorationStyle(RenderStyle&, Element* ) const |
| 936 { | 936 { |
| 937 } | 937 } |
| 938 | 938 |
| 939 void LayoutTheme::platformColorsDidChange() | 939 void LayoutTheme::platformColorsDidChange() |
| 940 { | 940 { |
| 941 Page::platformColorsChanged(); | 941 Page::platformColorsChanged(); |
| 942 } | 942 } |
| 943 | 943 |
| 944 static FontDescription& getCachedFontDescription(CSSValueID systemFontID) | 944 static FontDescription& getCachedFontDescription(CSSValueID systemFontID) |
| 945 { | 945 { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1132 bool LayoutTheme::supportsCalendarPicker(const AtomicString& type) const | 1132 bool LayoutTheme::supportsCalendarPicker(const AtomicString& type) const |
| 1133 { | 1133 { |
| 1134 return type == InputTypeNames::date | 1134 return type == InputTypeNames::date |
| 1135 || type == InputTypeNames::datetime | 1135 || type == InputTypeNames::datetime |
| 1136 || type == InputTypeNames::datetime_local | 1136 || type == InputTypeNames::datetime_local |
| 1137 || type == InputTypeNames::month | 1137 || type == InputTypeNames::month |
| 1138 || type == InputTypeNames::week; | 1138 || type == InputTypeNames::week; |
| 1139 } | 1139 } |
| 1140 #endif | 1140 #endif |
| 1141 | 1141 |
| 1142 bool LayoutTheme::shouldUseFallbackTheme(RenderStyle*) const | 1142 bool LayoutTheme::shouldUseFallbackTheme(const RenderStyle&) const |
| 1143 { | 1143 { |
| 1144 return false; | 1144 return false; |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 void LayoutTheme::adjustStyleUsingFallbackTheme(RenderStyle* style, Element* e) | 1147 void LayoutTheme::adjustStyleUsingFallbackTheme(RenderStyle& style, Element* e) |
| 1148 { | 1148 { |
| 1149 ControlPart part = style->appearance(); | 1149 ControlPart part = style.appearance(); |
| 1150 switch (part) { | 1150 switch (part) { |
| 1151 case CheckboxPart: | 1151 case CheckboxPart: |
| 1152 return adjustCheckboxStyleUsingFallbackTheme(style, e); | 1152 return adjustCheckboxStyleUsingFallbackTheme(style, e); |
| 1153 case RadioPart: | 1153 case RadioPart: |
| 1154 return adjustRadioStyleUsingFallbackTheme(style, e); | 1154 return adjustRadioStyleUsingFallbackTheme(style, e); |
| 1155 default: | 1155 default: |
| 1156 break; | 1156 break; |
| 1157 } | 1157 } |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 bool LayoutTheme::paintUsingFallbackTheme(RenderObject* o, const PaintInfo& i, c onst IntRect& r) | 1160 bool LayoutTheme::paintUsingFallbackTheme(RenderObject* o, const PaintInfo& i, c onst IntRect& r) |
| 1161 { | 1161 { |
| 1162 ControlPart part = o->style()->appearance(); | 1162 ControlPart part = o->style()->appearance(); |
| 1163 switch (part) { | 1163 switch (part) { |
| 1164 case CheckboxPart: | 1164 case CheckboxPart: |
| 1165 return paintCheckboxUsingFallbackTheme(o, i, r); | 1165 return paintCheckboxUsingFallbackTheme(o, i, r); |
| 1166 case RadioPart: | 1166 case RadioPart: |
| 1167 return paintRadioUsingFallbackTheme(o, i, r); | 1167 return paintRadioUsingFallbackTheme(o, i, r); |
| 1168 default: | 1168 default: |
| 1169 break; | 1169 break; |
| 1170 } | 1170 } |
| 1171 return true; | 1171 return true; |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 // static | 1174 // static |
| 1175 void LayoutTheme::setSizeIfAuto(RenderStyle* style, const IntSize& size) | 1175 void LayoutTheme::setSizeIfAuto(RenderStyle& style, const IntSize& size) |
| 1176 { | 1176 { |
| 1177 if (style->width().isIntrinsicOrAuto()) | 1177 if (style.width().isIntrinsicOrAuto()) |
| 1178 style->setWidth(Length(size.width(), Fixed)); | 1178 style.setWidth(Length(size.width(), Fixed)); |
| 1179 if (style->height().isAuto()) | 1179 if (style.height().isAuto()) |
| 1180 style->setHeight(Length(size.height(), Fixed)); | 1180 style.setHeight(Length(size.height(), Fixed)); |
| 1181 } | 1181 } |
| 1182 | 1182 |
| 1183 bool LayoutTheme::paintCheckboxUsingFallbackTheme(RenderObject* o, const PaintIn fo& i, const IntRect& r) | 1183 bool LayoutTheme::paintCheckboxUsingFallbackTheme(RenderObject* o, const PaintIn fo& i, const IntRect& r) |
| 1184 { | 1184 { |
| 1185 WebFallbackThemeEngine::ExtraParams extraParams; | 1185 WebFallbackThemeEngine::ExtraParams extraParams; |
| 1186 WebCanvas* canvas = i.context->canvas(); | 1186 WebCanvas* canvas = i.context->canvas(); |
| 1187 extraParams.button.checked = isChecked(o); | 1187 extraParams.button.checked = isChecked(o); |
| 1188 extraParams.button.indeterminate = isIndeterminate(o); | 1188 extraParams.button.indeterminate = isIndeterminate(o); |
| 1189 | 1189 |
| 1190 float zoomLevel = o->style()->effectiveZoom(); | 1190 float zoomLevel = o->style()->effectiveZoom(); |
| 1191 GraphicsContextStateSaver stateSaver(*i.context); | 1191 GraphicsContextStateSaver stateSaver(*i.context); |
| 1192 IntRect unzoomedRect = r; | 1192 IntRect unzoomedRect = r; |
| 1193 if (zoomLevel != 1) { | 1193 if (zoomLevel != 1) { |
| 1194 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1194 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1195 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1195 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1196 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1196 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1197 i.context->scale(zoomLevel, zoomLevel); | 1197 i.context->scale(zoomLevel, zoomLevel); |
| 1198 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1198 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEn gine::PartCheckbox, getWebFallbackThemeState(this, o), WebRect(unzoomedRect), &e xtraParams); | 1201 Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEn gine::PartCheckbox, getWebFallbackThemeState(this, o), WebRect(unzoomedRect), &e xtraParams); |
| 1202 return false; | 1202 return false; |
| 1203 } | 1203 } |
| 1204 | 1204 |
| 1205 void LayoutTheme::adjustCheckboxStyleUsingFallbackTheme(RenderStyle* style, Elem ent*) const | 1205 void LayoutTheme::adjustCheckboxStyleUsingFallbackTheme(RenderStyle& style, Elem ent*) const |
| 1206 { | 1206 { |
| 1207 // If the width and height are both specified, then we have nothing to do. | 1207 // If the width and height are both specified, then we have nothing to do. |
| 1208 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | 1208 if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto()) |
| 1209 return; | 1209 return; |
| 1210 | 1210 |
| 1211 IntSize size = Platform::current()->fallbackThemeEngine()->getSize(WebFallba ckThemeEngine::PartCheckbox); | 1211 IntSize size = Platform::current()->fallbackThemeEngine()->getSize(WebFallba ckThemeEngine::PartCheckbox); |
| 1212 float zoomLevel = style->effectiveZoom(); | 1212 float zoomLevel = style.effectiveZoom(); |
| 1213 size.setWidth(size.width() * zoomLevel); | 1213 size.setWidth(size.width() * zoomLevel); |
| 1214 size.setHeight(size.height() * zoomLevel); | 1214 size.setHeight(size.height() * zoomLevel); |
| 1215 setSizeIfAuto(style, size); | 1215 setSizeIfAuto(style, size); |
| 1216 | 1216 |
| 1217 // padding - not honored by WinIE, needs to be removed. | 1217 // padding - not honored by WinIE, needs to be removed. |
| 1218 style->resetPadding(); | 1218 style.resetPadding(); |
| 1219 | 1219 |
| 1220 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) | 1220 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) |
| 1221 // for now, we will not honor it. | 1221 // for now, we will not honor it. |
| 1222 style->resetBorder(); | 1222 style.resetBorder(); |
| 1223 } | 1223 } |
| 1224 | 1224 |
| 1225 bool LayoutTheme::paintRadioUsingFallbackTheme(RenderObject* o, const PaintInfo& i, const IntRect& r) | 1225 bool LayoutTheme::paintRadioUsingFallbackTheme(RenderObject* o, const PaintInfo& i, const IntRect& r) |
| 1226 { | 1226 { |
| 1227 WebFallbackThemeEngine::ExtraParams extraParams; | 1227 WebFallbackThemeEngine::ExtraParams extraParams; |
| 1228 WebCanvas* canvas = i.context->canvas(); | 1228 WebCanvas* canvas = i.context->canvas(); |
| 1229 extraParams.button.checked = isChecked(o); | 1229 extraParams.button.checked = isChecked(o); |
| 1230 extraParams.button.indeterminate = isIndeterminate(o); | 1230 extraParams.button.indeterminate = isIndeterminate(o); |
| 1231 | 1231 |
| 1232 float zoomLevel = o->style()->effectiveZoom(); | 1232 float zoomLevel = o->style()->effectiveZoom(); |
| 1233 GraphicsContextStateSaver stateSaver(*i.context); | 1233 GraphicsContextStateSaver stateSaver(*i.context); |
| 1234 IntRect unzoomedRect = r; | 1234 IntRect unzoomedRect = r; |
| 1235 if (zoomLevel != 1) { | 1235 if (zoomLevel != 1) { |
| 1236 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); | 1236 unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); |
| 1237 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); | 1237 unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); |
| 1238 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); | 1238 i.context->translate(unzoomedRect.x(), unzoomedRect.y()); |
| 1239 i.context->scale(zoomLevel, zoomLevel); | 1239 i.context->scale(zoomLevel, zoomLevel); |
| 1240 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); | 1240 i.context->translate(-unzoomedRect.x(), -unzoomedRect.y()); |
| 1241 } | 1241 } |
| 1242 | 1242 |
| 1243 Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEn gine::PartRadio, getWebFallbackThemeState(this, o), WebRect(unzoomedRect), &extr aParams); | 1243 Platform::current()->fallbackThemeEngine()->paint(canvas, WebFallbackThemeEn gine::PartRadio, getWebFallbackThemeState(this, o), WebRect(unzoomedRect), &extr aParams); |
| 1244 return false; | 1244 return false; |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 void LayoutTheme::adjustRadioStyleUsingFallbackTheme(RenderStyle* style, Element *) const | 1247 void LayoutTheme::adjustRadioStyleUsingFallbackTheme(RenderStyle& style, Element *) const |
| 1248 { | 1248 { |
| 1249 // If the width and height are both specified, then we have nothing to do. | 1249 // If the width and height are both specified, then we have nothing to do. |
| 1250 if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) | 1250 if (!style.width().isIntrinsicOrAuto() && !style.height().isAuto()) |
| 1251 return; | 1251 return; |
| 1252 | 1252 |
| 1253 IntSize size = Platform::current()->fallbackThemeEngine()->getSize(WebFallba ckThemeEngine::PartRadio); | 1253 IntSize size = Platform::current()->fallbackThemeEngine()->getSize(WebFallba ckThemeEngine::PartRadio); |
| 1254 float zoomLevel = style->effectiveZoom(); | 1254 float zoomLevel = style.effectiveZoom(); |
| 1255 size.setWidth(size.width() * zoomLevel); | 1255 size.setWidth(size.width() * zoomLevel); |
| 1256 size.setHeight(size.height() * zoomLevel); | 1256 size.setHeight(size.height() * zoomLevel); |
| 1257 setSizeIfAuto(style, size); | 1257 setSizeIfAuto(style, size); |
| 1258 | 1258 |
| 1259 // padding - not honored by WinIE, needs to be removed. | 1259 // padding - not honored by WinIE, needs to be removed. |
| 1260 style->resetPadding(); | 1260 style.resetPadding(); |
| 1261 | 1261 |
| 1262 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) | 1262 // border - honored by WinIE, but looks terrible (just paints in the control box and turns off the Windows XP theme) |
| 1263 // for now, we will not honor it. | 1263 // for now, we will not honor it. |
| 1264 style->resetBorder(); | 1264 style.resetBorder(); |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 } // namespace blink | 1267 } // namespace blink |
| OLD | NEW |