Bug 69697 - User defined stylesheet doesn't work
Summary: User defined stylesheet doesn't work
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: 4.0
Platform: unspecified Linux
: NOR major
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 74030 75519 76379 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-12-06 01:54 UTC by Malte S. Stretz
Modified: 2004-02-28 23:45 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Testcase which demonstrates the problem (185 bytes, text/html)
2004-02-19 16:49 UTC, Frerich Raabe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Malte S. Stretz 2003-12-06 01:54:15 UTC
Version:           4.0 (using KDE 3.1.94 (3.2 Beta 2), Gentoo)
Compiler:          gcc version 3.2.3 20030422 (Gentoo Linux 1.4 3.2.3-r3, propolice)
OS:          Linux (i686) release 2.4.20-gentoo-r8

To work around bug 59600, I tried to add a user defined stylesheet which just consists of the line
  a { background-image: none; }
This worked neither in KDE 3.2-beta2 nor in 3.1.4.

So I tried to find out if that feature worked at all and put the line
  p { color: red; }
That did work in KDE 3.1.4 but not in KDE 3.2-beta2.

I restarted Konqueror (even whole KDE) to get around bug 39962 but that didn't help.
Comment 1 Stephan Kulow 2004-02-02 21:41:13 UTC
*** Bug 74030 has been marked as a duplicate of this bug. ***
Comment 2 Frerich Raabe 2004-02-19 16:49:29 UTC
Created attachment 4779 [details]
Testcase which demonstrates the problem

This testcase demonstrates the problem; the background is set to red, my custom
stylesheet just contains "body { background-color: blue }".

I noticed that everything works expected (the page has a blue background, my
custom stylesheet overrides the page stylesheet) if the page stylesheet is
declared "inline". If exactly the same stylesheet is moved to an extra file,
and then referenced using <link rel="stylesheet" ...>, the background becomes
red.

Also, overriding the page stylesheet with the custom stylesheet only seems to
fail in case the page stylesheet defines the same propery (e.g.
body::background-color) as the custom stylesheet. If I change the custom
stylesheet to affect some other property (like, body::color), the two
stylesheets get merged nicely (no matter whether the page stylesheet is
declared inline or not).
Comment 3 Frerich Raabe 2004-02-20 15:05:32 UTC
CVS commit by raabe: 

- In DocLoader::requestStyleSheet, don't check whether a redirection from
  http: to file: is ok in case we are loading the user-defined stylesheet. The
  user-defined sheet may be stored on the local disk and that check would
  always make DocLoader::requestStyleSheet refuse to load the stylesheet.
CCMAIL:69697-done@bugs.kde.org


  M +2 -1      khtml_part.cpp   1.969
  M +6 -6      misc/loader.cpp   1.171
  M +1 -1      misc/loader.h   1.66


--- kdelibs/khtml/khtml_part.cpp  #1.968:1.969
@@ -121,5 +121,6 @@ namespace khtml {
         {
             m_part = part;
-            m_cachedSheet = dl->requestStyleSheet(url, QString::null );
+            m_cachedSheet = dl->requestStyleSheet(url, QString::null, "text/css",
+                                                  true /* "user sheet" */);
             if (m_cachedSheet)
                 m_cachedSheet->ref( this );

--- kdelibs/khtml/misc/loader.cpp  #1.170:1.171
@@ -925,14 +925,14 @@ bool DocLoader::needReload(const KURL &f
 }
 
-#define DOCLOADER_SECCHECK \
+#define DOCLOADER_SECCHECK(doRedirectCheck) \
     KURL fullURL (m_doc->completeURL( url.string() )); \
     if ( !fullURL.isValid() || \
          ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file" && fullURL.protocol() != "data") || \
-         ( kapp && m_doc && !kapp->authorizeURLAction("redirect", m_doc->URL(), fullURL))) \
+         doRedirectCheck && ( kapp && m_doc && !kapp->authorizeURLAction("redirect", m_doc->URL(), fullURL))) \
          return 0L;
 
 CachedImage *DocLoader::requestImage( const DOM::DOMString &url)
 {
-    DOCLOADER_SECCHECK;
+    DOCLOADER_SECCHECK(true);
 
     CachedImage* i = Cache::requestObject<CachedImage, CachedObject::Image>( this, fullURL, 0);
@@ -945,7 +945,7 @@ CachedImage *DocLoader::requestImage( co
 
 CachedCSSStyleSheet *DocLoader::requestStyleSheet( const DOM::DOMString &url, const QString& charset,
-                                                   const char *accept )
+                                                   const char *accept, bool userSheet )
 {
-    DOCLOADER_SECCHECK;
+    DOCLOADER_SECCHECK(!userSheet);
 
     CachedCSSStyleSheet* s = Cache::requestObject<CachedCSSStyleSheet, CachedObject::CSSStyleSheet>( this, fullURL, accept );
@@ -958,5 +958,5 @@ CachedCSSStyleSheet *DocLoader::requestS
 CachedScript *DocLoader::requestScript( const DOM::DOMString &url, const QString& charset)
 {
-    DOCLOADER_SECCHECK;
+    DOCLOADER_SECCHECK(true);
 
     CachedScript* s = Cache::requestObject<CachedScript, CachedObject::Script>( this, fullURL, 0 );

--- kdelibs/khtml/misc/loader.h  #1.65:1.66
@@ -322,5 +322,5 @@ namespace khtml
         CachedImage *requestImage( const DOM::DOMString &url);
         CachedCSSStyleSheet *requestStyleSheet( const DOM::DOMString &url, const QString& charset,
-                                                const char *accept = "text/css");
+                                                const char *accept = "text/css", bool userSheet = false );
         CachedScript *requestScript( const DOM::DOMString &url, const QString& charset);
 


Comment 4 Stephan Kulow 2004-02-20 15:13:43 UTC
*** Bug 75519 has been marked as a duplicate of this bug. ***
Comment 5 Germain Garand 2004-02-28 23:45:50 UTC
*** Bug 76379 has been marked as a duplicate of this bug. ***