[webkit-gtk] Dark Theme and Web input

Andrea Giammarchi andrea.giammarchi at gmail.com
Sun Jul 30 13:28:30 PDT 2017


> Do you have any suggestion for what specifically we should do?

I guess setting up a top level `input { color: ButtonText; }` style any
page can overwrite through its own content has been explored already, right
?

I can inject JS upfront too via WebKitGTK+ before any page is loaded, maybe
that could be an entry point to pre-style web pages?

something like the following:

```js
// GJS example based on imports.gi.WebKit2
webView.connect('load-changed', (webView, loadEvent, data) => {
  switch (loadEvent) {
    case WebKit2.LoadEvent.COMMITTED:
      webView.run_javascript(
        `(function(document){'use strict';
          document.addEventListener(
            'DOMContentLoaded',
            e => {
              const html = document.documentElement;
              const style = document.createElement('style');
              style.textContent = 'input { color: ButtonText; }';
              html.insertBefore(style, html.firstChild);
            },
            {once: true}
          );
        }(this.document));`,
        null,
        (webView, result) => {
          webView.run_javascript_finish(result);
        }
      );
      break;
  }
});
```

Will have a look at the C++ source too, thanks


On Sun, Jul 30, 2017 at 8:56 PM, Michael Catanzaro <mcatanzaro at igalia.com>
wrote:

> On Sun, Jul 30, 2017 at 8:14 PM, Andrea Giammarchi <
> andrea.giammarchi at gmail.com> wrote:
>
> Is there any plan to make WebKit smart enough to have native dark theme
> inputs that are readable by default?
>
>
> Nope. We all know this is broken, but don't know what to change. Do you
> have any suggestion for what specifically we should do?
>
> The relevant code is mostly in Source/WebCore/rendering/
> RenderThemeGtk.cpp.
>
> Michael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-gtk/attachments/20170730/7a41cc30/attachment.html>


More information about the webkit-gtk mailing list