Summary: | user defined stylesheet updates ignored | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | Daniel Naber <misc2006> |
Component: | khtml | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | minor | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Other | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
Proposed patch to implement this
Proposed patch to implement this |
Description
Daniel Naber
2002-03-31 12:49:31 UTC
There are a number of options: 1. Detect when the file has changed and rerender all documents. 2. Detect when the file has changed, and apply the new one for all subsequent document renderings. 3. Check the user stylesheet for changes on each document rendering (similar to 2). 4. Provide DCOP interface to provide notification of changes to user stylesheet. I'd prefer 2 & 4. Created attachment 4831 [details]
Proposed patch to implement this
This patch attempts to make KHTML check whether the user-defined stylesheet was
changed since the last URL was opened and reload it if necessary. This only
happens when the "Reload" button in Konqueror is pressed though, to avoid
calling stat too often.
The patch seems to work quite well with today's khtml CVS version, even though
I had some occasional crashes a few days ago. I can't reproduce the crashes at
all anymore, but I cannot tell whether they were fixed and what fixed them.
Hence, this patch is to be taken with a pinch of salt.
Created attachment 4835 [details]
Proposed patch to implement this
This is patch supersedes the previous one (ID 4831); the "slotStatDone" slot
was renamed to "slotUserSheetStatDone". Also, slotUserSheetStatDone now checks
for whether there was an error with the job (if so, call showError and bail
out). Finally, if slotUserSheetStatDone failed to retrieve the modification
time from the job's UDS entry, it'll always reload the stylesheet.
CVS commit by raabe: - In case the openURL call is a reload, do a stat on the user-defined stylesheet and reload it in case it changed in the meanwhile. CCMAIL:39962-done@bugs.kde.org M +9 -0 ChangeLog 1.213 M +40 -0 khtml_part.cpp 1.975 M +6 -1 khtml_part.h 1.250 M +2 -0 khtmlpart_p.h 1.52 --- kdelibs/khtml/ChangeLog #1.212:1.213 @@ -1,2 +1,11 @@ +2004-02-22 Frerich Raabe <raabe@kde.org> + + * khtml_part.cpp/.h (openURL): In case the call is a reload, do a stat + on the user-defined stylesheet and reload it in case it changed in + the meanwhile (#39962). + * khtmlpart_p.h (class KHTMLPartPrivate): Added + m_userStyleSheetLastModified variable which keeps track of the + mtime of the user-defined sheet. + 2004-02-20 Germain Garand <germain@ebooksfrance.org> --- kdelibs/khtml/khtml_part.cpp #1.974:1.975 @@ -633,4 +633,13 @@ bool KHTMLPart::openURL( const KURL &url d->m_jobspeed = 0; + + // If this was an explicit reload and the user style sheet should be used, + // do a stat to see whether the stylesheet was changed in the meanwhile. + if ( args.reload && !settings()->userStyleSheet().isEmpty() ) { + KURL url( settings()->userStyleSheet() ); + KIO::StatJob *job = KIO::stat( url, false /* don't show progress */ ); + connect( job, SIGNAL( result( KIO::Job * ) ), + this, SLOT( slotUserSheetStatDone( KIO::Job * ) ) ); + } emit started( 0L ); @@ -1872,4 +1881,35 @@ void KHTMLPart::slotJobDone( KIO::Job* / } +void KHTMLPart::slotUserSheetStatDone( KIO::Job *_job ) +{ + using namespace KIO; + + if ( _job->error() ) { + showError( _job ); + return; + } + + const UDSEntry entry = dynamic_cast<KIO::StatJob *>( _job )->statResult(); + UDSEntry::ConstIterator it = entry.begin(); + UDSEntry::ConstIterator end = entry.end(); + for ( ; it != end; ++it ) { + if ( ( *it ).m_uds == UDS_MODIFICATION_TIME ) { + break; + } + } + + // If the filesystem supports modification times, only reload the + // user-defined stylesheet if necessary - otherwise always reload. + if ( it != end ) { + const time_t lastModified = static_cast<time_t>( ( *it ).m_long ); + if ( d->m_userStyleSheetLastModified >= lastModified ) { + return; + } + d->m_userStyleSheetLastModified = lastModified; + } + + setUserStyleSheet( KURL( settings()->userStyleSheet() ) ); +} + void KHTMLPart::checkCompleted() { --- kdelibs/khtml/khtml_part.h #1.249:1.250 @@ -1303,4 +1303,9 @@ private slots: * @internal */ + void slotUserSheetStatDone( KIO::Job* ); + + /* + * @internal + */ void slotJobSpeed( KIO::Job*, unsigned long ); --- kdelibs/khtml/khtmlpart_p.h #1.51:1.52 @@ -207,4 +207,5 @@ public: m_statusBarWalletLabel = 0L; m_statusBarJSErrorLabel = 0L; + m_userStyleSheetLastModified = 0; } ~KHTMLPartPrivate() @@ -466,4 +467,5 @@ public: } + time_t m_userStyleSheetLastModified; }; |