Re: Roadmap review



On Sun, 29 Jan 2017 18:34:23 -0600, Michael Catanzaro <mcatanzaro igalia com> wrote:
On Mon, 2017-01-30 at 00:27 +0200, Adrian Perez de Castro wrote:
Also, I wondering... Would it make sense to embed a GtkSourceView in an
Epiphany tab for this?

Maybe. Can it be made non-editable?

GtkSourceView syntax highlighting works almost instantly, so that would
surely be preferable.

Yes. The widget inherits from GtkTextView, which has an “editable” boolean
property:

  https://developer.gnome.org/gtk3/stable/GtkTextView.html#GtkTextView--editable

I took a quick peek at how “ephy-source://” is handled, and it could be that
including the “prism.js” script first and then the content, letting the script
detect which HTML elements need to be highlighted might have to do with the
sluggishness. I would do something like generating the following code:

  <html>
    <head>
          <link rel="stylesheet" type="text/css" href="ephy-resource:///prism.css">
        </head>
    <body>
          <pre id="highlight" style="display: none">${HTML_SOURCE}</pre>

          <!-- Do whatever is needed to turn of Prism's auto-detection
               of code block elements. -->
          <script type="text/javascript" src="ephy-resource://prism.js"></script>

          <script type="text/javascript">
                let el = document.getElementById('highlight');
                el.innerHTML = Prism.highlight(el.textContent, Prism.languages.html);
            el.style.hidden = "";  // Show the element.
          </script>
        </body>
  </html>

Note how the <pre> element is initially hidden, we do the syntax highlighting,
update the DOM, and then change the “display” style property *last*. This
completely avoids displaying elements while they are getting updated, which
saves relayout and redraws. My guess is that relayouts (which are expensive)
are the main culprit for highlighting being slow at the moment.

Cheers,

—
🎩 Adrián

P.S: I need to set that horrible thing called JHBuild to be able to try this
     kind of experiments myself with Epiphany's “master” branch. Often I get
     away with using the system-wide WebKitGTK+ but currently that's not
     working ;-)

Attachment: pgpC5kWG2B3Ih.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]