WebKit Bugzilla
Attachment 341565 Details for
Bug 126907
: [GTK] Hardcoded text color in input fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-126907-20180530110601.patch (text/plain), 10.71 KB, created by
Carlos Bentzen
on 2018-05-30 07:04:09 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Bentzen
Created:
2018-05-30 07:04:09 PDT
Size:
10.71 KB
patch
obsolete
>Subversion Revision: 232143 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f617f32939613c1141063afeb1b12111b4e669f8..ed53d4e96c90cd004df4c524f5370e2cf350e981 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,29 @@ >+2018-05-28 Carlos Eduardo Ramalho <cadubentzen@gmail.com> >+ >+ [GTK] Hardcoded text color in input fields >+ https://bugs.webkit.org/show_bug.cgi?id=126907 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Set text color in input fields to foreground theme color. >+ Also, set "window.background" as base GtkStyleContext to mimic >+ GTK applications and fix some theme bugs. >+ >+ No new tests required. ManualTests/gtk/theme.html already covers it. >+ >+ * platform/gtk/RenderThemeGadget.cpp: >+ (WebCore::baseStyleContext): Added. >+ (WebCore::RenderThemeGadget::RenderThemeGadget): >+ Use "window.background" GtkStyleContext instead of >+ null parent for RenderThemeGadgets. >+ * rendering/RenderThemeGtk.cpp: >+ (WebCore::RenderThemeGtk::adjustButtonStyle const): >+ Set color as foreground theme color. >+ (WebCore::RenderThemeGtk::adjustTextFieldStyle const): Ditto. >+ (WebCore::RenderThemeGtk::adjustTextAreaStyle const): Ditto. >+ (WebCore::RenderThemeGtk::adjustSearchFieldStyle const): Ditto. >+ * rendering/RenderThemeGtk.h: adjustTextAreaStyle() overriden. >+ > 2018-05-23 Keith Miller <keith_miller@apple.com> > > Expose $vm if window.internals is exposed >diff --git a/Source/WebCore/platform/gtk/RenderThemeGadget.cpp b/Source/WebCore/platform/gtk/RenderThemeGadget.cpp >index 6a2903b87513b60e0f082921f3fcc36fab784b08..f6098b052c47bd30c28072e096fc02149b15f1e7 100644 >--- a/Source/WebCore/platform/gtk/RenderThemeGadget.cpp >+++ b/Source/WebCore/platform/gtk/RenderThemeGadget.cpp >@@ -30,6 +30,7 @@ > > #include "FloatRect.h" > #include "GRefPtrGtk.h" >+#include <mutex> > > namespace WebCore { > >@@ -72,6 +73,26 @@ static void appendElementToPath(GtkWidgetPath* path, const RenderThemeGadget::In > gtk_widget_path_iter_add_class(path, -1, className); > } > >+static GtkStyleContext* baseStyleContext() >+{ >+ // Leaking here on purpose for it not to be destroyed unsafely at exit time. >+ static GtkStyleContext* baseContext; >+ static std::once_flag onceFlag; >+ >+ std::call_once(onceFlag, []() { >+ GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new()); >+ gtk_widget_path_append_type(path.get(), GTK_TYPE_WINDOW); >+ gtk_widget_path_iter_set_object_name(path.get(), -1, "window"); >+ gtk_widget_path_iter_add_class(path.get(), -1, GTK_STYLE_CLASS_BACKGROUND); >+ >+ baseContext = gtk_style_context_new(); >+ gtk_style_context_set_path(baseContext, path.get()); >+ gtk_style_context_set_parent(baseContext, nullptr); >+ }); >+ >+ return baseContext; >+} >+ > RenderThemeGadget::RenderThemeGadget(const RenderThemeGadget::Info& info, RenderThemeGadget* parent, const Vector<RenderThemeGadget::Info> siblings, unsigned position) > { > GRefPtr<GtkWidgetPath> path = parent ? adoptGRef(gtk_widget_path_copy(gtk_style_context_get_path(parent->context()))) : adoptGRef(gtk_widget_path_new()); >@@ -82,7 +103,7 @@ RenderThemeGadget::RenderThemeGadget(const RenderThemeGadget::Info& info, Render > gtk_widget_path_append_with_siblings(path.get(), siblingsPath.get(), position); > } else > appendElementToPath(path.get(), info); >- m_context = createStyleContext(path.get(), parent ? parent->context() : nullptr); >+ m_context = createStyleContext(path.get(), parent ? parent->context() : baseStyleContext()); > } > > RenderThemeGadget::~RenderThemeGadget() = default; >diff --git a/Source/WebCore/rendering/RenderThemeGtk.cpp b/Source/WebCore/rendering/RenderThemeGtk.cpp >index 96584aa56a8ae1f2acd4bbeefc8552ae62a9df6b..6f3519d07d5d11588db50805275f64e2651ec81b 100644 >--- a/Source/WebCore/rendering/RenderThemeGtk.cpp >+++ b/Source/WebCore/rendering/RenderThemeGtk.cpp >@@ -493,8 +493,53 @@ void RenderThemeGtk::adjustRepaintRect(const RenderObject& renderObject, FloatRe > } > #endif // GTK_CHECK_VERSION(3, 20, 0) > >-void RenderThemeGtk::adjustButtonStyle(StyleResolver&, RenderStyle& style, const Element*) const >+enum StyleColorType { StyleColorBackground, StyleColorForeground }; >+ >+#if GTK_CHECK_VERSION(3, 20, 0) >+static Color styleColor(RenderThemePart themePart, GtkStateFlags state, StyleColorType colorType) > { >+ RenderThemeGadget* gadget = nullptr; >+ switch (themePart) { >+ default: >+ ASSERT_NOT_REACHED(); >+ FALLTHROUGH; >+ case Entry: >+ gadget = &static_cast<RenderThemeEntry&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::Entry)).entry(); >+ break; >+ case EntrySelection: >+ gadget = static_cast<RenderThemeEntry&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::SelectedEntry)).selection(); >+ break; >+ case ListBox: >+ gadget = &static_cast<RenderThemeListView&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::ListView)).treeview(); >+ break; >+ case Button: >+ gadget = &static_cast<RenderThemeButton&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::Button)).button(); >+ break; >+ } >+ >+ ASSERT(gadget); >+ gadget->setState(state); >+ return colorType == StyleColorBackground ? gadget->backgroundColor() : gadget->color(); >+} >+#else >+static Color styleColor(RenderThemePart themePart, GtkStateFlags state, StyleColorType colorType) >+{ >+ GRefPtr<GtkStyleContext> context = createStyleContext(themePart); >+ gtk_style_context_set_state(context.get(), state); >+ >+ GdkRGBA gdkRGBAColor; >+ if (colorType == StyleColorBackground) >+ gtk_style_context_get_background_color(context.get(), state, &gdkRGBAColor); >+ else >+ gtk_style_context_get_color(context.get(), state, &gdkRGBAColor); >+ return gdkRGBAColor; >+} >+#endif // GTK_CHECK_VERSION(3, 20, 0) >+ >+void RenderThemeGtk::adjustButtonStyle(StyleResolver&, RenderStyle& style, const Element* element) const >+{ >+ if (element) >+ style.setColor(styleColor(Button, element->isDisabledFormControl() ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL, StyleColorForeground)); > // Some layout tests check explicitly that buttons ignore line-height. > if (style.appearance() == PushButtonPart) > style.setLineHeight(RenderStyle::initialLineHeight()); >@@ -945,6 +990,9 @@ static IntSize spinButtonSize() > > void RenderThemeGtk::adjustTextFieldStyle(StyleResolver&, RenderStyle& style, const Element* element) const > { >+ if (element) >+ style.setColor(styleColor(Entry, element->isDisabledFormControl() ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL, StyleColorForeground)); >+ > if (!is<HTMLInputElement>(element) || !shouldHaveSpinButton(downcast<HTMLInputElement>(*element))) > return; > >@@ -1081,6 +1129,12 @@ static void adjustSearchFieldIconStyle(RenderThemePart themePart, RenderStyle& s > } > #endif > >+void RenderThemeGtk::adjustTextAreaStyle(StyleResolver&, RenderStyle& style, const Element* element) const >+{ >+ if (element) >+ style.setColor(styleColor(Entry, element->isDisabledFormControl() ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL, StyleColorForeground)); >+} >+ > bool RenderThemeGtk::paintTextArea(const RenderObject& o, const PaintInfo& i, const FloatRect& r) > { > return paintTextField(o, i, r); >@@ -1200,8 +1254,10 @@ bool RenderThemeGtk::paintSearchFieldCancelButton(const RenderBox& renderObject, > } > #endif // GTK_CHECK_VERSION(3, 20, 0) > >-void RenderThemeGtk::adjustSearchFieldStyle(StyleResolver&, RenderStyle& style, const Element*) const >+void RenderThemeGtk::adjustSearchFieldStyle(StyleResolver&, RenderStyle& style, const Element* element) const > { >+ if (element) >+ style.setColor(styleColor(Entry, element->isDisabledFormControl() ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL, StyleColorForeground)); > // We cannot give a proper rendering when border radius is active, unfortunately. > style.resetBorderRadius(); > style.setLineHeight(RenderStyle::initialLineHeight()); >@@ -1673,49 +1729,6 @@ Seconds RenderThemeGtk::caretBlinkInterval() const > return 500_us * time; > } > >-enum StyleColorType { StyleColorBackground, StyleColorForeground }; >- >-#if GTK_CHECK_VERSION(3, 20, 0) >-static Color styleColor(RenderThemePart themePart, GtkStateFlags state, StyleColorType colorType) >-{ >- RenderThemeGadget* gadget = nullptr; >- switch (themePart) { >- default: >- ASSERT_NOT_REACHED(); >- FALLTHROUGH; >- case Entry: >- gadget = &static_cast<RenderThemeEntry&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::Entry)).entry(); >- break; >- case EntrySelection: >- gadget = static_cast<RenderThemeEntry&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::SelectedEntry)).selection(); >- break; >- case ListBox: >- gadget = &static_cast<RenderThemeListView&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::ListView)).treeview(); >- break; >- case Button: >- gadget = &static_cast<RenderThemeButton&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::Button)).button(); >- break; >- } >- >- ASSERT(gadget); >- gadget->setState(state); >- return colorType == StyleColorBackground ? gadget->backgroundColor() : gadget->color(); >-} >-#else >-static Color styleColor(RenderThemePart themePart, GtkStateFlags state, StyleColorType colorType) >-{ >- GRefPtr<GtkStyleContext> context = createStyleContext(themePart); >- gtk_style_context_set_state(context.get(), state); >- >- GdkRGBA gdkRGBAColor; >- if (colorType == StyleColorBackground) >- gtk_style_context_get_background_color(context.get(), state, &gdkRGBAColor); >- else >- gtk_style_context_get_color(context.get(), state, &gdkRGBAColor); >- return gdkRGBAColor; >-} >-#endif // GTK_CHECK_VERSION(3, 20, 0) >- > Color RenderThemeGtk::platformActiveSelectionBackgroundColor() const > { > return styleColor(EntrySelection, static_cast<GtkStateFlags>(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_FOCUSED), StyleColorBackground); >diff --git a/Source/WebCore/rendering/RenderThemeGtk.h b/Source/WebCore/rendering/RenderThemeGtk.h >index 81033e7e1c06a9412562288eea79fb3c5290003e..aef8fed72647431761ab53a291aa03569b5d909b 100644 >--- a/Source/WebCore/rendering/RenderThemeGtk.h >+++ b/Source/WebCore/rendering/RenderThemeGtk.h >@@ -118,6 +118,8 @@ private: > > void adjustTextFieldStyle(StyleResolver&, RenderStyle&, const Element*) const override; > bool paintTextField(const RenderObject&, const PaintInfo&, const FloatRect&) override; >+ >+ void adjustTextAreaStyle(StyleResolver&, RenderStyle&, const Element*) const override; > bool paintTextArea(const RenderObject&, const PaintInfo&, const FloatRect&) override; > > LengthBox popupInternalPaddingBox(const RenderStyle&) const override;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 126907
:
302499
|
340464
|
340489
|
340924
|
341088
|
341463
|
341468
|
341565
|
343018
|
343026
|
343033
|
343657
|
343659
|
343695
|
368142
|
368149
|
368150