📄 loader.h
字号:
void clear(); private slots: /** * gets called, whenever a QMovie changes frame */ void movieUpdated( const QRect &rect ); void movieStatus(int); void movieResize(const QSize&); void deleteMovie(); private: void do_notify(const QPixmap& p, const QRect& r); QMovie* m; QPixmap* p; QPixmap* bg; QRgb bgColor; mutable QPixmap* pixPart; ImageSource* imgSource; const char* formatType; // Is the name of the movie format type int width; int height; // Is set if movie format type ( incremental/animation) was checked bool typeChecked : 1; bool isFullyTransparent : 1; bool errorOccured : 1; bool monochrome : 1; KHTMLSettings::KAnimationAdvice m_showAnimations : 2; friend class Cache;#if APPLE_CHANGES public: int dataSize() const { return m_dataSize; } private: int m_dataSize;#endif };#ifndef KHTML_NO_XBL class CachedXBLDocument : public CachedObject { public: CachedXBLDocument(DocLoader* dl, const DOM::DOMString &url, KIO::CacheControl cachePolicy, time_t _expireDate); virtual ~CachedXBLDocument(); XBL::XBLDocumentImpl* document() const { return m_document; } virtual void ref(CachedObjectClient *consumer); virtual void deref(CachedObjectClient *consumer); virtual void data( QBuffer &buffer, bool eof ); virtual void error( int err, const char *text ); virtual bool schedule() const { return true; } void checkNotify(); protected: XBL::XBLDocumentImpl* m_document; QTextCodec* m_codec; };#endif /** * @internal * * Manages the loading of scripts/images/stylesheets for a particular document */ class DocLoader { public: DocLoader(KHTMLPart*, DOM::DocumentImpl*); ~DocLoader(); CachedImage *requestImage( const DOM::DOMString &url); CachedCSSStyleSheet *requestStyleSheet( const DOM::DOMString &url, const QString& charset); CachedScript *requestScript( const DOM::DOMString &url, const QString& charset);#ifndef KHTML_NO_XBL CachedXBLDocument* requestXBLDocument(const DOM::DOMString &url);#endif bool autoloadImages() const { return m_bautoloadImages; } KIO::CacheControl cachePolicy() const { return m_cachePolicy; } KHTMLSettings::KAnimationAdvice showAnimations() const { return m_showAnimations; } time_t expireDate() const { return m_expireDate; } KHTMLPart* part() const { return m_part; } DOM::DocumentImpl* doc() const { return m_doc; } void setExpireDate( time_t ); void setAutoloadImages( bool ); void setCachePolicy( KIO::CacheControl cachePolicy ); void setShowAnimations( KHTMLSettings::KAnimationAdvice ); void removeCachedObject( CachedObject*) const; private: bool needReload(const KURL &fullUrl); friend class Cache; friend class DOM::DocumentImpl; QStringList m_reloadedURLs; mutable QPtrList<CachedObject> m_docObjects; time_t m_expireDate; KIO::CacheControl m_cachePolicy; bool m_bautoloadImages : 1; KHTMLSettings::KAnimationAdvice m_showAnimations : 2; KHTMLPart* m_part; DOM::DocumentImpl* m_doc; }; /** * @internal */ class Request { public: Request(DocLoader* dl, CachedObject *_object, bool _incremental); ~Request(); bool incremental; QBuffer m_buffer; CachedObject *object; DocLoader* m_docLoader; }; /** * @internal */ class Loader : public QObject { Q_OBJECT public: Loader(); ~Loader(); void load(DocLoader* dl, CachedObject *object, bool incremental = true); int numRequests( DocLoader* dl ) const; void cancelRequests( DocLoader* dl ); // may return 0L KIO::Job *jobForRequest( const DOM::DOMString &url ) const;#if APPLE_CHANGES KWQLoader *kwq;#endif signals: void requestStarted( khtml::DocLoader* dl, khtml::CachedObject* obj ); void requestDone( khtml::DocLoader* dl, khtml::CachedObject *obj ); void requestFailed( khtml::DocLoader* dl, khtml::CachedObject *obj ); protected slots: void slotFinished( KIO::Job * );#if APPLE_CHANGES void slotData( KIO::Job *, const char *data, int size ); void slotReceivedResponse ( KIO::Job *, KWIQResponse *response );#else void slotData( KIO::Job *, const QByteArray & );#endif private: void servePendingRequests(); QPtrList<Request> m_requestsPending; QPtrDict<Request> m_requestsLoading;#ifdef HAVE_LIBJPEG KJPEGFormatType m_jpegloader;#endif }; /** * @internal * * Provides a cache/loader for objects needed for displaying the html page. * At the moment these are stylesheets, scripts and images */ class Cache { friend class DocLoader; public: /** * init the cache in case it's not already. This needs to get called once * before using it. */ static void init(); /** * Ask the cache for some url. Will return a cachedObject, and * load the requested data in case it's not cahced * if the DocLoader is zero, the url must be full-qualified. * Otherwise, it is automatically base-url expanded */ static CachedImage *requestImage( DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0); static CachedImage *requestImage( DocLoader* l, const KURL &url, bool reload=false, time_t _expireDate=0); /** * Ask the cache for some url. Will return a cachedObject, and * load the requested data in case it's not cached */ static CachedCSSStyleSheet *requestStyleSheet( DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0, const QString& charset = QString::null);#ifndef KHTML_NO_XBL // Ask the cache for an XBL document. static CachedXBLDocument* requestXBLDocument(DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0);#endif /** * Pre-loads a stylesheet into the cache. */ static void preloadStyleSheet(const QString &url, const QString &stylesheet_data); /** * Ask the cache for some url. Will return a cachedObject, and * load the requested data in case it's not cahced */ static CachedScript *requestScript( DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0, const QString& charset=QString::null); /** * Pre-loads a script into the cache. */ static void preloadScript(const QString &url, const QString &script_data); /** * sets the size of the cache. This will only hod approximately, since the size some * cached objects (like stylesheets) take up in memory is not exaclty known. */ static void setSize( int bytes ); /** * returns the size of the cache */ static int size() { return maxSize; }; /** * prints some statistics to stdout */ static void statistics(); /** * clean up cache */ static void flush(bool force=false); /** * clears the cache * Warning: call this only at the end of your program, to clean * up memory (useful for finding memory holes) */ static void clear(); static Loader *loader() { return m_loader; } static QPixmap *nullPixmap; static QPixmap *brokenPixmap; static void removeCacheEntry( CachedObject *object );#if APPLE_CHANGES struct TypeStatistic { int count; int size; TypeStatistic() : count(0), size(0) { } }; struct Statistics { TypeStatistic images; TypeStatistic movies; TypeStatistic styleSheets; TypeStatistic scripts;#ifndef KHTML_NO_XBL TypeStatistic xblDocs;#endif TypeStatistic other; }; static Statistics getStatistics(); static void flushAll(); static void setCacheDisabled(bool);#endif static void insertInLRUList(CachedObject *); static void removeFromLRUList(CachedObject *); static bool adjustSize(CachedObject *, int sizeDelta); static LRUList* getLRUListFor(CachedObject* o); static void checkLRUAndUncacheableListIntegrity(); protected: static QDict<CachedObject> *cache; static QPtrList<DocLoader>* docloader; static int maxSize; static int flushCount; static Loader *m_loader; static unsigned long s_ulRefCnt; static void moveToHeadOfLRUList(CachedObject *); static LRUList *m_LRULists; static int m_totalSizeOfLRULists; static CachedObject *m_headOfUncacheableList; static int m_countOfLRUAndUncacheableLists; };};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -