WebKit Bugzilla
Attachment 341088 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-20180523103230.patch (text/plain), 7.74 KB, created by
Carlos Bentzen
on 2018-05-23 06:30:53 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Bentzen
Created:
2018-05-23 06:30:53 PDT
Size:
7.74 KB
patch
obsolete
>Subversion Revision: 232093 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 40a00c9927694ae057b0670154bc85fe511ebd29..9f4551aa56d2edf72fb8ac4258251d13e9f81f4b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,30 @@ >+2018-05-23 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 the foreground theme color. >+ This prevents some errors such as dark text in dark background. >+ >+ No new tests required. ManualTests/gtk/theme.html already covers it. >+ >+ * platform/gtk/RenderThemeGadget.cpp: >+ (WebCore::createStyleContext): Add "webview" to allow GTK themers >+ to customize styling in webviews. >+ (WebCore::RenderThemeTextFieldGadget::RenderThemeTextFieldGadget): >+ Add "background" class to fix trouble with some themes that don't >+ define a foreground color in entries. >+ * rendering/RenderThemeGtk.cpp: >+ (WebCore::inputColor): Added. >+ (WebCore::RenderThemeGtk::adjustButtonStyle const): >+ set color from GTK theme. >+ (WebCore::RenderThemeGtk::adjustTextFieldStyle const): Ditto. >+ (WebCore::RenderThemeGtk::adjustTextAreaStyle const): Ditto. >+ (WebCore::RenderThemeGtk::adjustSearchFieldStyle const): Ditto. >+ * rendering/RenderThemeGtk.h: Override adjustTextAreaStyle() as well. >+ > 2018-05-22 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r232081. >diff --git a/Source/WebCore/platform/gtk/RenderThemeGadget.cpp b/Source/WebCore/platform/gtk/RenderThemeGadget.cpp >index 6a2903b87513b60e0f082921f3fcc36fab784b08..5dde5669b3b2064c79f0afa86919e9f765fcb354 100644 >--- a/Source/WebCore/platform/gtk/RenderThemeGadget.cpp >+++ b/Source/WebCore/platform/gtk/RenderThemeGadget.cpp >@@ -60,6 +60,8 @@ static GRefPtr<GtkStyleContext> createStyleContext(GtkWidgetPath* path, GtkStyle > GRefPtr<GtkStyleContext> context = adoptGRef(gtk_style_context_new()); > gtk_style_context_set_path(context.get(), path); > gtk_style_context_set_parent(context.get(), parent); >+ // Class to be used by GTK themers if they want custom styling inside webviews. >+ gtk_style_context_add_class(context.get(), "webview"); > return context; > } > >@@ -236,6 +238,11 @@ IntSize RenderThemeBoxGadget::preferredSize() const > RenderThemeTextFieldGadget::RenderThemeTextFieldGadget(const RenderThemeGadget::Info& info, RenderThemeGadget* parent, const Vector<RenderThemeGadget::Info> siblings, unsigned position) > : RenderThemeGadget(info, parent, siblings, position) > { >+ // This workaround is for some themes like HighConstrast lacking "color" gtk-css attribute in entries. >+ // When the widgets are drawn by GTK they go to this fallback theme. However here they were getting the default color. >+ // As a result, for example, HighConstrast theme was drawing white text in white background in text inputs. >+ if (m_context) >+ gtk_style_context_add_class(m_context.get(), "background"); > } > > IntSize RenderThemeTextFieldGadget::minimumSize() const >diff --git a/Source/WebCore/rendering/RenderThemeGtk.cpp b/Source/WebCore/rendering/RenderThemeGtk.cpp >index 96584aa56a8ae1f2acd4bbeefc8552ae62a9df6b..14b90bb86f9010bb636cc89f73f8992945d258f3 100644 >--- a/Source/WebCore/rendering/RenderThemeGtk.cpp >+++ b/Source/WebCore/rendering/RenderThemeGtk.cpp >@@ -493,8 +493,42 @@ 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) { >+ default: >+ ASSERT_NOT_REACHED(); >+ 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; >+ } >+ >+ 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()); >@@ -942,9 +976,11 @@ static IntSize spinButtonSize() > return IntSize(upPreferredSize.width() + downPreferredSize.width(), std::max(upPreferredSize.height(), downPreferredSize.height())); > } > >- > 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; > >@@ -959,6 +995,12 @@ void RenderThemeGtk::adjustTextFieldStyle(StyleResolver&, RenderStyle& style, co > style.setMinWidth(Length(minimumWidth, Fixed)); > } > >+void RenderThemeGtk::adjustTextAreaStyle(StyleResolver&, RenderStyle& style, const Element* element) const >+{ >+ if (element) >+ style.setColor(inputColor(element, Entry)); >+} >+ > bool RenderThemeGtk::paintTextField(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& rect) > { > if (is<HTMLInputElement>(renderObject.node()) && shouldHaveSpinButton(downcast<HTMLInputElement>(*renderObject.node()))) { >@@ -1200,11 +1242,14 @@ 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 > { > // We cannot give a proper rendering when border radius is active, unfortunately. > style.resetBorderRadius(); > style.setLineHeight(RenderStyle::initialLineHeight()); >+ >+ if (element) >+ style.setColor(inputColor(element, Entry)); > } > > bool RenderThemeGtk::paintSearchField(const RenderObject& o, const PaintInfo& i, const IntRect& rect) >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