Changeset 232338 in webkit
- Timestamp:
- May 30, 2018 11:41:41 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r232337 r232338 1 2018-05-30 Carlos Eduardo Ramalho <cadubentzen@gmail.com> 2 3 [GTK] Hardcoded text color in input fields 4 https://bugs.webkit.org/show_bug.cgi?id=126907 5 6 Reviewed by Carlos Garcia Campos. 7 8 Set text color in input fields to foreground theme color. 9 Also, set "window.background" as base GtkStyleContext to mimic 10 GTK applications and fix some theme bugs. 11 12 No new tests required. ManualTests/gtk/theme.html already covers it. 13 14 * platform/gtk/RenderThemeGadget.cpp: 15 (WebCore::baseStyleContext): Added. 16 (WebCore::RenderThemeGadget::RenderThemeGadget): 17 Use "window.background" GtkStyleContext instead of 18 null parent for RenderThemeGadgets. 19 * rendering/RenderThemeGtk.cpp: 20 (WebCore::RenderThemeGtk::adjustButtonStyle const): 21 Set color as foreground theme color. 22 (WebCore::RenderThemeGtk::adjustTextFieldStyle const): Ditto. 23 (WebCore::RenderThemeGtk::adjustTextAreaStyle const): Ditto. 24 (WebCore::RenderThemeGtk::adjustSearchFieldStyle const): Ditto. 25 * rendering/RenderThemeGtk.h: adjustTextAreaStyle() overriden. 26 1 27 2018-05-30 Yusuke Suzuki <utatane.tea@gmail.com> 2 28 -
trunk/Source/WebCore/platform/gtk/RenderThemeGadget.cpp
r223728 r232338 31 31 #include "FloatRect.h" 32 32 #include "GRefPtrGtk.h" 33 #include <mutex> 33 34 34 35 namespace WebCore { … … 73 74 } 74 75 76 static GtkStyleContext* baseStyleContext() 77 { 78 // Leaking here on purpose for it not to be destroyed unsafely at exit time. 79 static GtkStyleContext* baseContext; 80 static std::once_flag onceFlag; 81 82 std::call_once(onceFlag, []() { 83 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new()); 84 gtk_widget_path_append_type(path.get(), GTK_TYPE_WINDOW); 85 gtk_widget_path_iter_set_object_name(path.get(), -1, "window"); 86 gtk_widget_path_iter_add_class(path.get(), -1, GTK_STYLE_CLASS_BACKGROUND); 87 88 baseContext = gtk_style_context_new(); 89 gtk_style_context_set_path(baseContext, path.get()); 90 gtk_style_context_set_parent(baseContext, nullptr); 91 }); 92 93 return baseContext; 94 } 95 75 96 RenderThemeGadget::RenderThemeGadget(const RenderThemeGadget::Info& info, RenderThemeGadget* parent, const Vector<RenderThemeGadget::Info> siblings, unsigned position) 76 97 { … … 83 104 } else 84 105 appendElementToPath(path.get(), info); 85 m_context = createStyleContext(path.get(), parent ? parent->context() : nullptr);106 m_context = createStyleContext(path.get(), parent ? parent->context() : baseStyleContext()); 86 107 } 87 108 -
trunk/Source/WebCore/rendering/RenderThemeGtk.cpp
r231557 r232338 494 494 #endif // GTK_CHECK_VERSION(3, 20, 0) 495 495 496 void RenderThemeGtk::adjustButtonStyle(StyleResolver&, RenderStyle& style, const Element*) const 497 { 496 enum StyleColorType { StyleColorBackground, StyleColorForeground }; 497 498 #if GTK_CHECK_VERSION(3, 20, 0) 499 static Color styleColor(RenderThemePart themePart, GtkStateFlags state, StyleColorType colorType) 500 { 501 RenderThemeGadget* gadget = nullptr; 502 switch (themePart) { 503 default: 504 ASSERT_NOT_REACHED(); 505 FALLTHROUGH; 506 case Entry: 507 gadget = &static_cast<RenderThemeEntry&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::Entry)).entry(); 508 break; 509 case EntrySelection: 510 gadget = static_cast<RenderThemeEntry&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::SelectedEntry)).selection(); 511 break; 512 case ListBox: 513 gadget = &static_cast<RenderThemeListView&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::ListView)).treeview(); 514 break; 515 case Button: 516 gadget = &static_cast<RenderThemeButton&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::Button)).button(); 517 break; 518 } 519 520 ASSERT(gadget); 521 gadget->setState(state); 522 return colorType == StyleColorBackground ? gadget->backgroundColor() : gadget->color(); 523 } 524 #else 525 static Color styleColor(RenderThemePart themePart, GtkStateFlags state, StyleColorType colorType) 526 { 527 GRefPtr<GtkStyleContext> context = createStyleContext(themePart); 528 gtk_style_context_set_state(context.get(), state); 529 530 GdkRGBA gdkRGBAColor; 531 if (colorType == StyleColorBackground) 532 gtk_style_context_get_background_color(context.get(), state, &gdkRGBAColor); 533 else 534 gtk_style_context_get_color(context.get(), state, &gdkRGBAColor); 535 return gdkRGBAColor; 536 } 537 #endif // GTK_CHECK_VERSION(3, 20, 0) 538 539 void RenderThemeGtk::adjustButtonStyle(StyleResolver&, RenderStyle& style, const Element* element) const 540 { 541 if (element) 542 style.setColor(styleColor(Button, element->isDisabledFormControl() ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL, StyleColorForeground)); 498 543 // Some layout tests check explicitly that buttons ignore line-height. 499 544 if (style.appearance() == PushButtonPart) … … 946 991 void RenderThemeGtk::adjustTextFieldStyle(StyleResolver&, RenderStyle& style, const Element* element) const 947 992 { 993 if (element) 994 style.setColor(styleColor(Entry, element->isDisabledFormControl() ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL, StyleColorForeground)); 995 948 996 if (!is<HTMLInputElement>(element) || !shouldHaveSpinButton(downcast<HTMLInputElement>(*element))) 949 997 return; … … 1081 1129 } 1082 1130 #endif 1131 1132 void RenderThemeGtk::adjustTextAreaStyle(StyleResolver&, RenderStyle& style, const Element* element) const 1133 { 1134 if (element) 1135 style.setColor(styleColor(Entry, element->isDisabledFormControl() ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL, StyleColorForeground)); 1136 } 1083 1137 1084 1138 bool RenderThemeGtk::paintTextArea(const RenderObject& o, const PaintInfo& i, const FloatRect& r) … … 1201 1255 #endif // GTK_CHECK_VERSION(3, 20, 0) 1202 1256 1203 void RenderThemeGtk::adjustSearchFieldStyle(StyleResolver&, RenderStyle& style, const Element*) const 1204 { 1257 void RenderThemeGtk::adjustSearchFieldStyle(StyleResolver&, RenderStyle& style, const Element* element) const 1258 { 1259 if (element) 1260 style.setColor(styleColor(Entry, element->isDisabledFormControl() ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL, StyleColorForeground)); 1205 1261 // We cannot give a proper rendering when border radius is active, unfortunately. 1206 1262 style.resetBorderRadius(); … … 1674 1730 } 1675 1731 1676 enum StyleColorType { StyleColorBackground, StyleColorForeground };1677 1678 #if GTK_CHECK_VERSION(3, 20, 0)1679 static Color styleColor(RenderThemePart themePart, GtkStateFlags state, StyleColorType colorType)1680 {1681 RenderThemeGadget* gadget = nullptr;1682 switch (themePart) {1683 default:1684 ASSERT_NOT_REACHED();1685 FALLTHROUGH;1686 case Entry:1687 gadget = &static_cast<RenderThemeEntry&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::Entry)).entry();1688 break;1689 case EntrySelection:1690 gadget = static_cast<RenderThemeEntry&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::SelectedEntry)).selection();1691 break;1692 case ListBox:1693 gadget = &static_cast<RenderThemeListView&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::ListView)).treeview();1694 break;1695 case Button:1696 gadget = &static_cast<RenderThemeButton&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::Button)).button();1697 break;1698 }1699 1700 ASSERT(gadget);1701 gadget->setState(state);1702 return colorType == StyleColorBackground ? gadget->backgroundColor() : gadget->color();1703 }1704 #else1705 static Color styleColor(RenderThemePart themePart, GtkStateFlags state, StyleColorType colorType)1706 {1707 GRefPtr<GtkStyleContext> context = createStyleContext(themePart);1708 gtk_style_context_set_state(context.get(), state);1709 1710 GdkRGBA gdkRGBAColor;1711 if (colorType == StyleColorBackground)1712 gtk_style_context_get_background_color(context.get(), state, &gdkRGBAColor);1713 else1714 gtk_style_context_get_color(context.get(), state, &gdkRGBAColor);1715 return gdkRGBAColor;1716 }1717 #endif // GTK_CHECK_VERSION(3, 20, 0)1718 1719 1732 Color RenderThemeGtk::platformActiveSelectionBackgroundColor() const 1720 1733 { -
trunk/Source/WebCore/rendering/RenderThemeGtk.h
r231557 r232338 119 119 void adjustTextFieldStyle(StyleResolver&, RenderStyle&, const Element*) const override; 120 120 bool paintTextField(const RenderObject&, const PaintInfo&, const FloatRect&) override; 121 122 void adjustTextAreaStyle(StyleResolver&, RenderStyle&, const Element*) const override; 121 123 bool paintTextArea(const RenderObject&, const PaintInfo&, const FloatRect&) override; 122 124
Note: See TracChangeset
for help on using the changeset viewer.