Changeset 252255 in webkit
- Timestamp:
- Nov 8, 2019 1:10:11 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252254 r252255 1 2019-11-08 Antti Koivisto <antti@apple.com> 2 3 StyleResolver state should store user agent appearance style as RenderStyle 4 https://bugs.webkit.org/show_bug.cgi?id=204008 5 6 Reviewed by Zalan Bujtas. 7 8 Generate and pass around user agent style as RenderStyle for apperance computation instead 9 of awkwardly passing around separate property values. 10 11 * css/StyleResolver.cpp: 12 (WebCore::StyleResolver::styleForElement): 13 (WebCore::StyleResolver::styleForKeyframe): 14 (WebCore::StyleResolver::pseudoStyleForElement): 15 (WebCore::StyleResolver::adjustRenderStyle): 16 (WebCore::StyleResolver::applyMatchedProperties): 17 (WebCore::StyleResolver::State::cacheBorderAndBackground): Deleted. 18 * css/StyleResolver.h: 19 (WebCore::StyleResolver::element const): 20 (WebCore::StyleResolver::State::userAgentAppearanceStyle const): 21 (WebCore::StyleResolver::State::setUserAgentAppearanceStyle): 22 (WebCore::StyleResolver::element): Deleted. 23 (WebCore::StyleResolver::State::hasUAAppearance const): Deleted. 24 (WebCore::StyleResolver::State::borderData const): Deleted. 25 (WebCore::StyleResolver::State::backgroundData const): Deleted. 26 (WebCore::StyleResolver::State::backgroundColor const): Deleted. 27 * rendering/RenderTheme.cpp: 28 (WebCore::RenderTheme::adjustStyle): 29 (WebCore::RenderTheme::isControlStyled const): 30 * rendering/RenderTheme.h: 31 * rendering/RenderThemeIOS.h: 32 * rendering/RenderThemeIOS.mm: 33 (WebCore::RenderThemeIOS::isControlStyled const): 34 * rendering/RenderThemeMac.h: 35 * rendering/RenderThemeMac.mm: 36 (WebCore::RenderThemeMac::isControlStyled const): 37 * style/StyleBuilder.cpp: 38 (WebCore::Style::Builder::Builder): 39 40 Allow providing style separately from StyleResolver state. 41 42 * style/StyleBuilder.h: 43 1 44 2019-11-08 Daniel Bates <dabates@apple.com> 2 45 -
trunk/Source/WebCore/css/StyleResolver.cpp
r252208 r252255 98 98 using namespace HTMLNames; 99 99 100 inline void StyleResolver::State::cacheBorderAndBackground()101 {102 m_hasUAAppearance = m_style->hasAppearance();103 if (m_hasUAAppearance) {104 m_borderData = m_style->border();105 m_backgroundData = m_style->backgroundLayers();106 m_backgroundColor = m_style->backgroundColor();107 }108 }109 110 100 inline void StyleResolver::State::clear() 111 101 { … … 113 103 m_parentStyle = nullptr; 114 104 m_ownedParentStyle = nullptr; 105 m_userAgentAppearanceStyle = nullptr; 115 106 } 116 107 … … 286 277 287 278 // Clean up our style object's display and text decorations (among other fixups). 288 adjustRenderStyle(*state.style(), *state.parentStyle(), parentBoxStyle, &element );279 adjustRenderStyle(*state.style(), *state.parentStyle(), parentBoxStyle, &element, state.userAgentAppearanceStyle()); 289 280 290 281 if (state.style()->hasViewportUnits()) … … 314 305 builder.applyAllProperties(); 315 306 316 adjustRenderStyle(*state.style(), *state.parentStyle(), nullptr, nullptr );307 adjustRenderStyle(*state.style(), *state.parentStyle(), nullptr, nullptr, state.userAgentAppearanceStyle()); 317 308 318 309 // Add all the animating properties to the keyframe. … … 470 461 471 462 // Clean up our style object's display and text decorations (among other fixups). 472 adjustRenderStyle(*state.style(), *m_state.parentStyle(), parentBoxStyle, nullptr );463 adjustRenderStyle(*state.style(), *m_state.parentStyle(), parentBoxStyle, nullptr, state.userAgentAppearanceStyle()); 473 464 474 465 if (state.style()->hasViewportUnits()) … … 780 771 #endif 781 772 782 void StyleResolver::adjustRenderStyle(RenderStyle& style, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const Element* element )773 void StyleResolver::adjustRenderStyle(RenderStyle& style, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const Element* element, const RenderStyle* userAgentAppearanceStyle) 783 774 { 784 775 // If the composed tree parent has display:contents, the parent box style will be different from the parent style. … … 1000 991 // Let the theme also have a crack at adjusting the style. 1001 992 if (style.hasAppearance()) 1002 RenderTheme::singleton().adjustStyle(*this, style, element, m_state.hasUAAppearance(), m_state.borderData(), m_state.backgroundData(), m_state.backgroundColor());993 RenderTheme::singleton().adjustStyle(*this, style, element, userAgentAppearanceStyle); 1003 994 1004 995 // If we have first-letter pseudo style, do not share this style. … … 1139 1130 1140 1131 if (elementTypeHasAppearanceFromUAStyle(element)) { 1141 // FIXME: This is such a hack.1142 1132 // Find out if there's a -webkit-appearance property in effect from the UA sheet. 1143 1133 // If so, we cache the border and background styles so that RenderTheme::adjustStyle() 1144 1134 // can look at them later to figure out if this is a styled form control or not. 1145 Style::Builder builder(*this, matchResult, { Style::CascadeLevel::UserAgent }, includedProperties); 1135 auto userAgentStyle = RenderStyle::clonePtr(style); 1136 Style::Builder builder(*userAgentStyle, *this, matchResult, { Style::CascadeLevel::UserAgent }); 1146 1137 builder.applyAllProperties(); 1147 1138 1148 state. cacheBorderAndBackground();1139 state.setUserAgentAppearanceStyle(WTFMove(userAgentStyle)); 1149 1140 } 1150 1141 -
trunk/Source/WebCore/css/StyleResolver.h
r252208 r252255 118 118 const RenderStyle* parentStyle() const { return m_state.parentStyle(); } 119 119 const RenderStyle* rootElementStyle() const { return m_state.rootElementStyle(); } 120 const Element* element() { return m_state.element(); }120 const Element* element() const { return m_state.element(); } 121 121 Document& document() { return m_document; } 122 122 const Document& document() const { return m_document; } … … 184 184 185 185 private: 186 void adjustRenderStyle(RenderStyle&, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const Element* );186 void adjustRenderStyle(RenderStyle&, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const Element*, const RenderStyle* userAgentStyle); 187 187 void adjustRenderStyleForSiteSpecificQuirks(RenderStyle&, const Element&); 188 188 … … 216 216 const RenderStyle* rootElementStyle() const { return m_rootElementStyle; } 217 217 218 void cacheBorderAndBackground(); 219 bool hasUAAppearance() const { return m_hasUAAppearance; } 220 BorderData borderData() const { return m_borderData; } 221 FillLayer backgroundData() const { return m_backgroundData; } 222 const Color& backgroundColor() const { return m_backgroundColor; } 218 const RenderStyle* userAgentAppearanceStyle() const { return m_userAgentAppearanceStyle.get(); } 219 void setUserAgentAppearanceStyle(std::unique_ptr<RenderStyle> style) { m_userAgentAppearanceStyle = WTFMove(style); } 223 220 224 221 const SelectorFilter* selectorFilter() const { return m_selectorFilter; } … … 233 230 const SelectorFilter* m_selectorFilter { nullptr }; 234 231 235 BorderData m_borderData; 236 FillLayer m_backgroundData { FillLayerType::Background }; 237 Color m_backgroundColor; 238 239 bool m_hasUAAppearance { false }; 232 std::unique_ptr<RenderStyle> m_userAgentAppearanceStyle; 240 233 }; 241 234 -
trunk/Source/WebCore/rendering/RenderTheme.cpp
r245072 r252255 79 79 } 80 80 81 void RenderTheme::adjustStyle(StyleResolver& styleResolver, RenderStyle& style, const Element* element, bool UAHasAppearance, const BorderData& border, const FillLayer& background, const Color& backgroundColor)81 void RenderTheme::adjustStyle(StyleResolver& styleResolver, RenderStyle& style, const Element* element, const RenderStyle* userAgentAppearanceStyle) 82 82 { 83 83 // Force inline and table display styles to be inline-block (except for table- which is block) … … 91 91 style.setDisplay(DisplayType::Block); 92 92 93 if ( UAHasAppearance && isControlStyled(style, border, background, backgroundColor)) {93 if (userAgentAppearanceStyle && isControlStyled(style, *userAgentAppearanceStyle)) { 94 94 switch (part) { 95 95 case MenulistPart: … … 731 731 } 732 732 733 bool RenderTheme::isControlStyled(const RenderStyle& style, const BorderData& border, const FillLayer& background, const Color& backgroundColor) const733 bool RenderTheme::isControlStyled(const RenderStyle& style, const RenderStyle& userAgentStyle) const 734 734 { 735 735 switch (style.appearance()) { … … 753 753 case TextAreaPart: 754 754 // Test the style to see if the UA border and background match. 755 return style.border() != border756 || style.backgroundLayers() != background757 || !style.backgroundColorEqualsToColorIgnoringVisited( backgroundColor);755 return style.border() != userAgentStyle.border() 756 || style.backgroundLayers() != userAgentStyle.backgroundLayers() 757 || !style.backgroundColorEqualsToColorIgnoringVisited(userAgentStyle.backgroundColor()); 758 758 default: 759 759 return false; -
trunk/Source/WebCore/rendering/RenderTheme.h
r246490 r252255 66 66 // selection of control size based off the font, the disabling of appearance when certain other properties like 67 67 // "border" are set, or if the appearance is not supported by the theme. 68 void adjustStyle(StyleResolver&, RenderStyle&, const Element*, bool UAHasAppearance, const BorderData&, const FillLayer&, const Color& backgroundColor);68 void adjustStyle(StyleResolver&, RenderStyle&, const Element*, const RenderStyle* userAgentAppearanceStyle); 69 69 70 70 // This method is called to paint the widget as a background of the RenderObject. A widget's foreground, e.g., the … … 117 117 118 118 // Whether or not the control has been styled enough by the author to disable the native appearance. 119 virtual bool isControlStyled(const RenderStyle&, const BorderData&, const FillLayer&, const Color& backgroundColor) const;119 virtual bool isControlStyled(const RenderStyle&, const RenderStyle& userAgentStyle) const; 120 120 121 121 // A general method asking if any control tinting is supported at all. -
trunk/Source/WebCore/rendering/RenderThemeIOS.h
r241825 r252255 67 67 int baselinePosition(const RenderBox&) const override; 68 68 69 bool isControlStyled(const RenderStyle&, const BorderData&, const FillLayer& background, const Color& backgroundColor) const override;69 bool isControlStyled(const RenderStyle&, const RenderStyle& userAgentStyle) const override; 70 70 71 71 // Methods for each appearance value. -
trunk/Source/WebCore/rendering/RenderThemeIOS.mm
r251896 r252255 448 448 } 449 449 450 bool RenderThemeIOS::isControlStyled(const RenderStyle& style, const BorderData& border, const FillLayer& background, const Color& backgroundColor) const450 bool RenderThemeIOS::isControlStyled(const RenderStyle& style, const RenderStyle& userAgentStyle) const 451 451 { 452 452 // Buttons and MenulistButtons are styled if they contain a background image. … … 455 455 456 456 if (style.appearance() == TextFieldPart || style.appearance() == TextAreaPart) 457 return style.backgroundLayers() != background;458 459 return RenderTheme::isControlStyled(style, border, background, backgroundColor);457 return style.backgroundLayers() != userAgentStyle.backgroundLayers(); 458 459 return RenderTheme::isControlStyled(style, userAgentStyle); 460 460 } 461 461 -
trunk/Source/WebCore/rendering/RenderThemeMac.h
r240628 r252255 50 50 void adjustRepaintRect(const RenderObject&, FloatRect&) final; 51 51 52 bool isControlStyled(const RenderStyle&, const BorderData&, const FillLayer&, const Color& backgroundColor) const final;52 bool isControlStyled(const RenderStyle&, const RenderStyle& userAgentStyle) const final; 53 53 54 54 bool supportsSelectionForegroundColors(OptionSet<StyleColor::Options>) const final; -
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r249217 r252255 883 883 } 884 884 885 bool RenderThemeMac::isControlStyled(const RenderStyle& style, const BorderData& border, 886 const FillLayer& background, const Color& backgroundColor) const 885 bool RenderThemeMac::isControlStyled(const RenderStyle& style, const RenderStyle& userAgentStyle) const 887 886 { 888 887 if (style.appearance() == TextFieldPart || style.appearance() == TextAreaPart || style.appearance() == ListboxPart) 889 return style.border() != border;888 return style.border() != userAgentStyle.border(); 890 889 891 890 // FIXME: This is horrible, but there is not much else that can be done. Menu lists cannot draw properly when … … 896 895 return true; 897 896 898 return RenderTheme::isControlStyled(style, border, background, backgroundColor);897 return RenderTheme::isControlStyled(style, userAgentStyle); 899 898 } 900 899 -
trunk/Source/WebCore/style/StyleBuilder.cpp
r252030 r252255 50 50 } 51 51 52 Builder::Builder(RenderStyle& style, const StyleResolver& resolver, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, PropertyCascade::IncludedProperties includedProperties) 53 : m_cascade(matchResult, cascadeLevels, includedProperties, directionFromStyle(style)) 54 , m_state(*this, style, *resolver.parentStyle(), resolver.rootElementStyle(), resolver.document(), resolver.element()) 55 { 56 ASSERT(resolver.parentStyle()); 57 } 58 52 59 Builder::Builder(StyleResolver& resolver, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, PropertyCascade::IncludedProperties includedProperties) 53 : m_cascade(matchResult, cascadeLevels, includedProperties, directionFromStyle(*resolver.style())) 54 , m_state(*this, *resolver.style(), *resolver.parentStyle(), resolver.rootElementStyle(), resolver.document(), resolver.element()) 60 : Builder(*resolver.style(), resolver, matchResult, cascadeLevels, includedProperties) 55 61 { 56 62 ASSERT(resolver.style()); 57 ASSERT(resolver.parentStyle());58 63 } 59 64 -
trunk/Source/WebCore/style/StyleBuilder.h
r251864 r252255 36 36 WTF_MAKE_FAST_ALLOCATED; 37 37 public: 38 Builder(RenderStyle&, const StyleResolver&, const MatchResult&, OptionSet<CascadeLevel>, PropertyCascade::IncludedProperties = PropertyCascade::IncludedProperties::All); 38 39 Builder(StyleResolver&, const MatchResult&, OptionSet<CascadeLevel>, PropertyCascade::IncludedProperties = PropertyCascade::IncludedProperties::All); 39 40 ~Builder();
Note: See TracChangeset
for help on using the changeset viewer.