From kde-commits Fri Sep 19 01:13:26 2008 From: Kevin Kofler Date: Fri, 19 Sep 2008 01:13:26 +0000 To: kde-commits Subject: branches/KDE/4.1/kdelibs/khtml Message-Id: <1221786806.238530.16967.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=122178681613328 SVN commit 862491 by kkofler: KHTML fix: Make "stop animations" work again in Konqueror (kde#157789 KDE 4 regression). (backport revision 862489 from trunk) CCBUG: 157789 M +7 -0 imload/animprovider.cpp M +10 -1 imload/animprovider.h M +4 -0 imload/decoders/gifloader.cpp M +14 -0 imload/image.cpp M +8 -0 imload/image.h M +3 -25 misc/loader.cpp M +0 -1 misc/loader.h --- branches/KDE/4.1/kdelibs/khtml/imload/animprovider.cpp #862490:862491 @@ -38,6 +38,8 @@ void AnimProvider::switchFrame() { + if (animationAdvice == KHTMLSettings::KAnimationDisabled) + return; shouldSwitchFrame = true; image->notifyPerformUpdate(); } @@ -47,6 +49,11 @@ ImageManager::animTimer()->destroyed(this); } +void AnimProvider::setShowAnimations(KHTMLSettings::KAnimationAdvice newAdvice) +{ + animationAdvice = newAdvice; } +} + // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on; --- branches/KDE/4.1/kdelibs/khtml/imload/animprovider.h #862490:862491 @@ -25,6 +25,8 @@ #ifndef ANIM_PROVIDER_H #define ANIM_PROVIDER_H +#include + class QPainter; namespace khtmlImLoad { @@ -44,11 +46,13 @@ PixmapPlane* curFrame; Image* image; bool shouldSwitchFrame; //Set by AnimTimer + KHTMLSettings::KAnimationAdvice animationAdvice; void nextFrame(); //Helper that goes to next frame or wraps around public: AnimProvider(PixmapPlane* plane, Image* img):frame0(plane), curFrame(plane), - image(img), shouldSwitchFrame(false) + image(img), shouldSwitchFrame(false), + animationAdvice(KHTMLSettings::KAnimationEnabled) {} void switchFrame(); @@ -62,6 +66,11 @@ //Must be implemented to paint the given region. Note that clipping to the //overall canvas will be performed already virtual void paint(int dx, int dy, QPainter* p, int sx, int sy, int width, int height) = 0; + + /** + Enables or disables animations + */ + void setShowAnimations(KHTMLSettings::KAnimationAdvice); }; } --- branches/KDE/4.1/kdelibs/khtml/imload/decoders/gifloader.cpp #862490:862491 @@ -212,7 +212,11 @@ ++frame; if (frame >= frameInfo.size()) + { + if (animationAdvice == KHTMLSettings::KAnimationLoopOnce) + animationAdvice = KHTMLSettings::KAnimationDisabled; frame = 0; + } nextFrame(); } --- branches/KDE/4.1/kdelibs/khtml/imload/image.cpp #862490:862491 @@ -48,6 +48,7 @@ inError = false; width = height = 0; + animationAdvice = KHTMLSettings::KAnimationEnabled; noUpdates(); } @@ -214,6 +215,9 @@ } else { + if (original && original->animProvider) + original->animProvider->setShowAnimations(animationAdvice); + fullyDecoded = true; owner->imageDone(this); } @@ -452,6 +456,16 @@ return original->parent->format.hasAlpha(); } +void Image::setShowAnimations(KHTMLSettings::KAnimationAdvice newAdvice) +{ + if (animationAdvice != newAdvice) + { + animationAdvice = newAdvice; + if (original && original->animProvider) + original->animProvider->setShowAnimations(newAdvice); + } } +} + // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on; --- branches/KDE/4.1/kdelibs/khtml/imload/image.h #862490:862491 @@ -30,6 +30,8 @@ #include #include #include + +#include #include "imageformat.h" @@ -92,6 +94,11 @@ (but see CanvasImage) */ QImage* qimage() const; + + /** + Enables or disables animations + */ + void setShowAnimations(KHTMLSettings::KAnimationAdvice); private: //Interface to the loader. friend class ImageLoader; @@ -165,6 +172,7 @@ int width, height; PixmapPlane* original; QMap, PixmapPlane*> scaled; + KHTMLSettings::KAnimationAdvice animationAdvice; }; --- branches/KDE/4.1/kdelibs/khtml/misc/loader.cpp #862490:862491 @@ -422,7 +422,7 @@ m_status = Unknown; imgSource = 0; setAccept( acceptHeader ); - m_showAnimations = dl->showAnimations(); + i->setShowAnimations(dl->showAnimations()); m_loading = true; if ( KHTMLGlobal::defaultHTMLSettings()->isAdFiltered( url.string() ) ) { @@ -807,30 +807,8 @@ void CachedImage::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations ) { - (void) showAnimations; -#if 0 - m_showAnimations = showAnimations; - if ( (m_showAnimations == KHTMLSettings::KAnimationDisabled) && imgSource ) { -#ifdef __GNUC__ -#warning QDataSource -#endif - // imgSource->cleanBuffer(); - delete p; - p = new QPixmap(m->framePixmap()); -#ifdef __GNUC__ -#warning QMovie requires different API now -#endif - //m->disconnectUpdate( this, SLOT( movieUpdated( const QRect &) )); - //m->disconnectStatus( this, SLOT( movieStatus( int ) )); - // m->disconnectResize( this, SLOT( movieResize( const QSize& ) ) ); - QTimer::singleShot(0, this, SLOT( deleteMovie())); - imgSource = 0; - } -#endif - -#ifdef __GNUC__ -#warning "Use largeimagelib to disable animation" -#endif + if (i) + i->setShowAnimations(showAnimations); } // void CachedImage::deleteMovie() --- branches/KDE/4.1/kdelibs/khtml/misc/loader.h #862490:862491 @@ -363,7 +363,6 @@ bool typeChecked : 1; bool isFullyTransparent : 1; bool monochrome : 1; - KHTMLSettings::KAnimationAdvice m_showAnimations : 2; friend class Cache; friend class ::KHTMLPart;