https://bugs.kde.org/show_bug.cgi?id=390452

--- Comment #4 from Caspar Schutijser <cas...@schutijser.com> ---
I looked at the QtWebkit source code and this piece of code caught my
attention:

  4729  void Document::initDNSPrefetch()
  4730  {
  4731      Settings* settings = this->settings();
  4732  
  4733      m_haveExplicitlyDisabledDNSPrefetch = false;
  4734      m_isDNSPrefetchEnabled = settings &&
settings->dnsPrefetchingEnabled() && securityOrigin()->protocol() == "http";
  4735  
  4736      // Inherit DNS prefetch opt-out from parent frame    
  4737      if (Document* parent = parentDocument()) {
  4738          if (!parent->isDNSPrefetchEnabled())
  4739              m_isDNSPrefetchEnabled = false;
  4740      }
  4741  }
  4742  
  4743  void Document::parseDNSPrefetchControlHeader(const String&
dnsPrefetchControl)
  4744  {
  4745      if (equalIgnoringCase(dnsPrefetchControl, "on") &&
!m_haveExplicitlyDisabledDNSPrefetch) {
  4746          m_isDNSPrefetchEnabled = true;
  4747          return;
  4748      }
  4749  
  4750      m_isDNSPrefetchEnabled = false;
  4751      m_haveExplicitlyDisabledDNSPrefetch = true;
  4752  }

Source:
https://github.com/qt/qtwebkit/blob/5.9/Source/WebCore/dom/Document.cpp#L4729

The way I read the code: when initializing the DNS prefetch code, the settings
regarding DNS prefetching are taken into account (line 4734), but when DNS
prefetching is turned on by the "website", for instance with a header or the
http-equiv meta tag, the settings are ignored and DNS prefetching is turned on
regardless (line 4746).

To verify my assumption, I applied the diff found at the bottom to the QtWebkit
code and observed stdout while running trojita. When opening one of those
emails in Trojita, this is what I see on stdout:

    initDNSPrefetch(): DNS prefetching disabled in settings
    initDNSPrefetch(): DNS prefetching disabled in settings
    Processing HTTP equiv:
    parseDNSPrefetchControlHeader(): turning DNS prefetching on

This seems to confirm my understanding of the code. So the way I see it, there
is no easy, straightforward way for us to disable this behavior in (Qt)Webkit.
Do you agree with my analysis?



Index: Source/WebCore/dom/Document.cpp
--- Source/WebCore/dom/Document.cpp.orig
+++ Source/WebCore/dom/Document.cpp
@@ -28,6 +28,8 @@
 #include "config.h"
 #include "Document.h"

+#include <iostream>
+
 #include "AXObjectCache.h"
 #include "AnimationController.h"
 #include "Attr.h"
@@ -2824,6 +2826,8 @@ void Document::processHttpEquiv(const String& equiv, c

     Frame* frame = this->frame();

+    cout << "Processing HTTP equiv:" << endl;
+
     if (equalIgnoringCase(equiv, "default-style")) {
         // The preferred style set has been overridden as per section 
         // 14.3.2 of the HTML4.0 specification.  We need to update the
@@ -4732,6 +4736,10 @@ void Document::initDNSPrefetch()

     m_haveExplicitlyDisabledDNSPrefetch = false;
     m_isDNSPrefetchEnabled = settings && settings->dnsPrefetchingEnabled() &&
securityOrigin()->protocol() == "http";
+    if (settings && settings->dnsPrefetchingEnabled())
+        cout << "initDNSPrefetch(): DNS prefetching enabled in settings" <<
endl;
+    else
+        cout << "initDNSPrefetch(): DNS prefetching disabled in settings" <<
endl;

     // Inherit DNS prefetch opt-out from parent frame    
     if (Document* parent = parentDocument()) {
@@ -4743,6 +4751,7 @@ void Document::initDNSPrefetch()
 void Document::parseDNSPrefetchControlHeader(const String& dnsPrefetchControl)
 {
     if (equalIgnoringCase(dnsPrefetchControl, "on") &&
!m_haveExplicitlyDisabledDNSPrefetch) {
+        cout << "parseDNSPrefetchControlHeader(): turning DNS prefetching on"
<< endl;
         m_isDNSPrefetchEnabled = true;
         return;
     }

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to