WebKit Bugzilla
Attachment 341463 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-20180528220603.patch (text/plain), 7.76 KB, created by
Carlos Bentzen
on 2018-05-28 18:04:13 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Bentzen
Created:
2018-05-28 18:04:13 PDT
Size:
7.76 KB
patch
obsolete
>Subversion Revision: 232143 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f617f32939613c1141063afeb1b12111b4e669f8..4d510fad6ee27ea3985953c31b9cf04f292a6af3 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,30 @@ >+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::createBaseStyleContext): Added. >+ (WebCore::RenderThemeGadget::RenderThemeGadget): >+ Use window.background GtkStyleContext instead of >+ null parent for RenderThemeGadgets. >+ * rendering/RenderThemeGtk.cpp: >+ (WebCore::inputColor): Added. >+ (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..cc7caf57ec4e31b5bd41fd9f6523a3f43b6a0d84 100644 >--- a/Source/WebCore/platform/gtk/RenderThemeGadget.cpp >+++ b/Source/WebCore/platform/gtk/RenderThemeGadget.cpp >@@ -72,8 +72,24 @@ static void appendElementToPath(GtkWidgetPath* path, const RenderThemeGadget::In > gtk_widget_path_iter_add_class(path, -1, className); > } > >+static GRefPtr<GtkStyleContext> createBaseStyleContext() >+{ >+ 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); >+ >+ GRefPtr<GtkStyleContext> baseContext = adoptGRef(gtk_style_context_new()); >+ gtk_style_context_set_path(baseContext.get(), path.get()); >+ gtk_style_context_set_parent(baseContext.get(), nullptr); >+ >+ return baseContext; >+} >+ > RenderThemeGadget::RenderThemeGadget(const RenderThemeGadget::Info& info, RenderThemeGadget* parent, const Vector<RenderThemeGadget::Info> siblings, unsigned position) > { >+ static GRefPtr<GtkStyleContext> baseContext = createBaseStyleContext(); >+ > GRefPtr<GtkWidgetPath> path = parent ? adoptGRef(gtk_widget_path_copy(gtk_style_context_get_path(parent->context()))) : adoptGRef(gtk_widget_path_new()); > if (!siblings.isEmpty()) { > GRefPtr<GtkWidgetPath> siblingsPath = adoptGRef(gtk_widget_path_new()); >@@ -82,7 +98,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() : baseContext.get()); > } > > RenderThemeGadget::~RenderThemeGadget() = default; >diff --git a/Source/WebCore/rendering/RenderThemeGtk.cpp b/Source/WebCore/rendering/RenderThemeGtk.cpp >index 96584aa56a8ae1f2acd4bbeefc8552ae62a9df6b..86de550806bf9825ca6284b391cc617bd7bbc455 100644 >--- a/Source/WebCore/rendering/RenderThemeGtk.cpp >+++ b/Source/WebCore/rendering/RenderThemeGtk.cpp >@@ -493,8 +493,41 @@ void RenderThemeGtk::adjustRepaintRect(const RenderObject& renderObject, FloatRe > } > #endif // GTK_CHECK_VERSION(3, 20, 0) > >-void RenderThemeGtk::adjustButtonStyle(StyleResolver&, RenderStyle& style, const Element*) const >+#if GTK_CHECK_VERSION(3, 20, 0) >+static Color inputColor(const Element* element, RenderThemePart part) > { >+ RenderThemeGadget* gadget = nullptr; >+ switch (part) { >+ case Button: >+ gadget = &static_cast<RenderThemeButton&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::Button)).button(); >+ break; >+ case Entry: >+ gadget = &static_cast<RenderThemeEntry&>(RenderThemeWidget::getOrCreate(RenderThemeWidget::Type::Entry)).entry(); >+ break; >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+ >+ GtkStateFlags state = element->isDisabledFormControl() ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL; >+ gadget->setState(state); >+ return gadget->color(); >+} >+#else >+static Color inputColor(const Element* element, RenderThemePart part) >+{ >+ GRefPtr<GtkStyleContext> context = createStyleContext(part); >+ gtk_style_context_set_state(context.get(), element->isDisabledFormControl() ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL); >+ >+ GdkRGBA gdkRGBAColor; >+ gtk_style_context_get_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor); >+ return gdkRGBAColor; >+} >+#endif >+ >+void RenderThemeGtk::adjustButtonStyle(StyleResolver&, RenderStyle& style, const Element* element) const >+{ >+ if (element) >+ style.setColor(inputColor(element, Button)); > // Some layout tests check explicitly that buttons ignore line-height. > if (style.appearance() == PushButtonPart) > style.setLineHeight(RenderStyle::initialLineHeight()); >@@ -945,6 +978,9 @@ static IntSize spinButtonSize() > > void RenderThemeGtk::adjustTextFieldStyle(StyleResolver&, RenderStyle& style, const Element* element) const > { >+ if (element) >+ style.setColor(inputColor(element, Entry)); >+ > if (!is<HTMLInputElement>(element) || !shouldHaveSpinButton(downcast<HTMLInputElement>(*element))) > return; > >@@ -1081,6 +1117,12 @@ static void adjustSearchFieldIconStyle(RenderThemePart themePart, RenderStyle& s > } > #endif > >+void RenderThemeGtk::adjustTextAreaStyle(StyleResolver&, RenderStyle& style, const Element* element) const >+{ >+ if (element) >+ style.setColor(inputColor(element, Entry)); >+} >+ > bool RenderThemeGtk::paintTextArea(const RenderObject& o, const PaintInfo& i, const FloatRect& r) > { > return paintTextField(o, i, r); >@@ -1200,8 +1242,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(inputColor(element, Entry)); > // We cannot give a proper rendering when border radius is active, unfortunately. > style.resetBorderRadius(); > style.setLineHeight(RenderStyle::initialLineHeight()); >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