texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Gavin D. Smith
Date: Wed, 30 Nov 2022 13:36:39 -0500 (EST)

branch: old/qt-info
commit a86a4c0102ba246a5d9da73c0c4f9fad919fa689
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Fri Apr 12 15:47:13 2019 +0100

    call setRunsOnSubFrames
---
 ChangeLog                    | 16 +++++++++-
 js/docbrowser/mainwindow.cpp |  3 +-
 js/info.js                   | 70 ++++++++------------------------------------
 3 files changed, 29 insertions(+), 60 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c8af806f2b..d055b5c81a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
+2019-04-12  Gavin Smith  <gavinsmith0123@gmail.com>
+
+       Remove wc_controlled conditional.
+
+       * js/info.js
+       (resolve_page): Do not check wc_controlled or call init_iframe.
+       (init_iframe): Do not take an argument that is the containing 
+       iframe.
+
+       We can make info.js run in subframes using 
+       QWebEngineScript::setRunsOnSubFrames.  Hence the system can be 
+       the same in the C++ program as in the browser when info.js is 
+       directly referenced in all the HTML files.
+
 2019-04-11  Gavin Smith  <gavinsmith0123@gmail.com>
-       
+
        * js/info.js: Don't run init code or set event handlers if the 
        location is "about:blank".  QWebEngine seems to add scripts even 
        into this page, which has bad results, e.g. with event handlers 
diff --git a/js/docbrowser/mainwindow.cpp b/js/docbrowser/mainwindow.cpp
index 1a14ce8dfb..d788a5b0ba 100644
--- a/js/docbrowser/mainwindow.cpp
+++ b/js/docbrowser/mainwindow.cpp
@@ -116,7 +116,7 @@ MainWindow::setup_profile (QWebEngineProfile *profile)
 
   QWebEngineScript s1;
   s1.setSourceCode(script + script2);
-  // s1.setRunsOnSubFrames(true);
+  s1.setRunsOnSubFrames(true);
   s1.setInjectionPoint(QWebEngineScript::DocumentCreation);
   s1.setWorldId(QWebEngineScript::MainWorld);
   profile->scripts()->insert(s1);
@@ -152,6 +152,7 @@ MainWindow::setup_profile (QWebEngineProfile *profile)
 
     QWebEngineScript s;
     s.setSourceCode(insert_css);
+    s.setRunsOnSubFrames(true);
     s.setInjectionPoint(QWebEngineScript::DocumentReady);
     s.setWorldId(QWebEngineScript::MainWorld);
     profile->scripts()->insert(s);
diff --git a/js/info.js b/js/info.js
index 41a46e10ca..d329fe9f87 100644
--- a/js/info.js
+++ b/js/info.js
@@ -914,14 +914,6 @@ var user_config = window["INFO_CONFIG"];
               iframe.classList.add ("node");
               iframe.setAttribute ("src", linkid_to_url (pageid));
 
-              if (wc_controlled)
-                {
-                  /* Make the JavaScript functionality work inside the iframe.
-                     In this case, we do not use a Remote_store object. */
-                  var x = init_iframe(iframe);
-                  iframe.onload = x.on_load;
-                }
-
               div.appendChild (iframe);
               iframe.addEventListener ("load", function () {
                 store.dispatch ({ type: "iframe-ready", id: pageid });
@@ -1334,59 +1326,27 @@ var user_config = window["INFO_CONFIG"];
       IFRAME is the iframe element in the containing page if we are injecting 
       Javascript. */
   function
-  init_iframe (iframe)
+  init_iframe ()
   {
-    var w; // the iframe-level window object
-
     /* Initialize the DOM for generic pages loaded in the context of an
        iframe.  */
     function
     on_load ()
     {
-      if (typeof iframe != 'undefined')
-        {
-          /* Injected case. */
-
-          w = iframe.contentWindow;
-
-          /* This function is in the scope of the top-level window, not the
-             iframe.  All attributes of window need to be accessed via the w
-             variable.  This applies even for types, so we need to write
-             'instanceof w.Element' instead of just 'instanceof Element'! */
-          /* We don't pass in the window as as an argument to init_iframe,
-             because contentWindow isn't defined immediately after the iframe
-             element is created. */
-          /* Since window.store is the top-level state, creating a Remote_store
-             may not be necessary. */
-
-          /* Add these event listeners which are not otherwise added. */
-          w.addEventListener ("message", on_message, false);
-          w.addEventListener ("beforeunload", on_unload, false);
-          w.addEventListener ("click",
-                              function (event) { on_click(event, w) },
-                              false);
-          w.addEventListener ("keyup", on_keyup, false);
-        }
-      else
-        {
-          /* Non-injected case. */
-          w = window;
-        }
-
-      fix_links (w.document.links);
+      fix_links (document.links);
       var links = {};
-      var linkid = basename (w.location.pathname, /[.]x?html$/);
-      links[linkid] = navigation_links (w.document);
+      var linkid = basename (location.pathname, /[.]x?html$/);
+      links[linkid] = navigation_links (document);
       store.dispatch (actions.cache_links (links));
 
       if (linkid_contains_index (linkid))
         {
           /* Scan links that should be added to the index.  */
-          var index_links = w.document.querySelectorAll ("td[valign=top] a");
+          var index_links = document.querySelectorAll ("td[valign=top] a");
           store.dispatch (actions.cache_index_links (index_links));
         }
 
-      add_icons (w.document);
+      add_icons (document);
 
       /* Call user hook.  */
       if (config.hooks.on_iframe_load)
@@ -1399,19 +1359,19 @@ var user_config = window["INFO_CONFIG"];
     {
       var data = event.data;
       if (data.message_kind === "highlight")
-        remove_highlight (w.document.body);
+        remove_highlight (document.body);
       else if (data.message_kind === "search")
         {
-          var found = search (w.document.body, data.regexp);
+          var found = search (document.body, data.regexp);
           store.dispatch ({ type: "search-result", found: found });
         }
       else if (data.message_kind === "scroll-to")
         {
           /* Scroll to the anchor corresponding to HASH.  */
           if (data.hash)
-            w.location.replace (data.hash);
+            location.replace (data.hash);
           else
-            w.scroll (0, 0);
+            scroll (0, 0);
         }
     }
 
@@ -1427,14 +1387,11 @@ var user_config = window["INFO_CONFIG"];
 
   /** Handle click events.  */
   function
-  on_click (event, win)
+  on_click (event)
   {
-    if (typeof win == "undefined")
-      win = window;
-
     for (var target = event.target; target !== null; target = 
target.parentNode)
       {
-        if ((target instanceof win.Element) && target.matches ("a"))
+        if ((target instanceof Element) && target.matches ("a"))
           {
             var href = target.getAttribute ("href");
             if (href)
@@ -2101,6 +2058,3 @@ init ();
 
 // } (window["Modernizr"], window["INFO_CONFIG"]));
 /* See comment at top of file */
-
-/* Shared with qtinfo.js. */
-var wc_controlled;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]