[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:54:58 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 61c347edb3447293b5444d432abefcc54133324c
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Oct 27 06:45:23 2002 +0000

    	- fixed a bug in the WebCore cache that caused it to not cache very much after
            a while, and also caused a crash I saw twice on my machine
    
    	Adjust total size of items in the LRU list, when the size of one of the
    	items that's in the list is changed.
    
            * khtml/misc/loader.h: Added a size parameter (default 0) to the CachedObject
    	constructor. Added a protected CachedObject::setSize() and made m_size private.
    	Added Cache::adjustSize() and Cache::checkLRUAndUncacheableListIntegrity().
            * khtml/misc/loader.cpp:
            (CachedObject::setSize): Added. This is now the only legal way to change
    	the size of a cached object, and it calls Cache::adjustSize.
            (CachedCSSStyleSheet::CachedCSSStyleSheet): Pass the length into the base
    	class's constructor instead of setting m_size.
            (CachedCSSStyleSheet::data): Call setSize() instead of setting m_size.
    	Also get the size back with size() rather than m_size.
            (CachedScript::CachedScript): Pass the length into the base class's
    	constructor instead of setting m_size.
            (CachedScript::data): Call setSize() instead of setting m_size. Also get
    	the size back with size() rather than m_size.
            (CachedImage::CachedImage): Don't set m_size to 0, since the base class's
    	constructor does that already.
            (CachedImage::clear): Use setSize() to set the size to 0 instead of setting
    	m_size directly.
            (CachedImage::data): Use setSize() instead of setting m_size directly.
            (Cache::checkLRUAndUncacheableListIntegrity): Useful debugging function.
    	Left in but ifdef'd out.
            (Cache::adjustSize): Added. Changes the "total LRU list size" by the
    	passed-in delta, but only if the passed-in object is in the LRU list.
    
            * kwq/KWQLineEdit.mm:
            * kwq/KWQTextField.h:
            * kwq/KWQTextField.mm:
    	Renamed the Objective C class KWQNSTextField to KWQTextField.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2484 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index a2552be..42fa4c4 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,5 +1,42 @@
 2002-10-26  Darin Adler  <darin at apple.com>
 
+	- fixed a bug in the WebCore cache that caused it to not cache very much after
+        a while, and also caused a crash I saw twice on my machine
+
+	Adjust total size of items in the LRU list, when the size of one of the
+	items that's in the list is changed.
+
+        * khtml/misc/loader.h: Added a size parameter (default 0) to the CachedObject
+	constructor. Added a protected CachedObject::setSize() and made m_size private.
+	Added Cache::adjustSize() and Cache::checkLRUAndUncacheableListIntegrity().
+        * khtml/misc/loader.cpp:
+        (CachedObject::setSize): Added. This is now the only legal way to change
+	the size of a cached object, and it calls Cache::adjustSize.
+        (CachedCSSStyleSheet::CachedCSSStyleSheet): Pass the length into the base
+	class's constructor instead of setting m_size.
+        (CachedCSSStyleSheet::data): Call setSize() instead of setting m_size.
+	Also get the size back with size() rather than m_size.
+        (CachedScript::CachedScript): Pass the length into the base class's
+	constructor instead of setting m_size.
+        (CachedScript::data): Call setSize() instead of setting m_size. Also get
+	the size back with size() rather than m_size.
+        (CachedImage::CachedImage): Don't set m_size to 0, since the base class's
+	constructor does that already.
+        (CachedImage::clear): Use setSize() to set the size to 0 instead of setting
+	m_size directly.
+        (CachedImage::data): Use setSize() instead of setting m_size directly.
+        (Cache::checkLRUAndUncacheableListIntegrity): Useful debugging function.
+	Left in but ifdef'd out.
+        (Cache::adjustSize): Added. Changes the "total LRU list size" by the
+	passed-in delta, but only if the passed-in object is in the LRU list.
+
+        * kwq/KWQLineEdit.mm:
+        * kwq/KWQTextField.h:
+        * kwq/KWQTextField.mm:
+	Renamed the Objective C class KWQNSTextField to KWQTextField.
+
+2002-10-26  Darin Adler  <darin at apple.com>
+
 	- removed forwarding headers that are not actually needed
 
         * ForwardingHeaders/kcmdlineargs.h: Removed.
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index a2552be..42fa4c4 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,5 +1,42 @@
 2002-10-26  Darin Adler  <darin at apple.com>
 
+	- fixed a bug in the WebCore cache that caused it to not cache very much after
+        a while, and also caused a crash I saw twice on my machine
+
+	Adjust total size of items in the LRU list, when the size of one of the
+	items that's in the list is changed.
+
+        * khtml/misc/loader.h: Added a size parameter (default 0) to the CachedObject
+	constructor. Added a protected CachedObject::setSize() and made m_size private.
+	Added Cache::adjustSize() and Cache::checkLRUAndUncacheableListIntegrity().
+        * khtml/misc/loader.cpp:
+        (CachedObject::setSize): Added. This is now the only legal way to change
+	the size of a cached object, and it calls Cache::adjustSize.
+        (CachedCSSStyleSheet::CachedCSSStyleSheet): Pass the length into the base
+	class's constructor instead of setting m_size.
+        (CachedCSSStyleSheet::data): Call setSize() instead of setting m_size.
+	Also get the size back with size() rather than m_size.
+        (CachedScript::CachedScript): Pass the length into the base class's
+	constructor instead of setting m_size.
+        (CachedScript::data): Call setSize() instead of setting m_size. Also get
+	the size back with size() rather than m_size.
+        (CachedImage::CachedImage): Don't set m_size to 0, since the base class's
+	constructor does that already.
+        (CachedImage::clear): Use setSize() to set the size to 0 instead of setting
+	m_size directly.
+        (CachedImage::data): Use setSize() instead of setting m_size directly.
+        (Cache::checkLRUAndUncacheableListIntegrity): Useful debugging function.
+	Left in but ifdef'd out.
+        (Cache::adjustSize): Added. Changes the "total LRU list size" by the
+	passed-in delta, but only if the passed-in object is in the LRU list.
+
+        * kwq/KWQLineEdit.mm:
+        * kwq/KWQTextField.h:
+        * kwq/KWQTextField.mm:
+	Renamed the Objective C class KWQNSTextField to KWQTextField.
+
+2002-10-26  Darin Adler  <darin at apple.com>
+
 	- removed forwarding headers that are not actually needed
 
         * ForwardingHeaders/kcmdlineargs.h: Removed.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index a2552be..42fa4c4 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,42 @@
 2002-10-26  Darin Adler  <darin at apple.com>
 
+	- fixed a bug in the WebCore cache that caused it to not cache very much after
+        a while, and also caused a crash I saw twice on my machine
+
+	Adjust total size of items in the LRU list, when the size of one of the
+	items that's in the list is changed.
+
+        * khtml/misc/loader.h: Added a size parameter (default 0) to the CachedObject
+	constructor. Added a protected CachedObject::setSize() and made m_size private.
+	Added Cache::adjustSize() and Cache::checkLRUAndUncacheableListIntegrity().
+        * khtml/misc/loader.cpp:
+        (CachedObject::setSize): Added. This is now the only legal way to change
+	the size of a cached object, and it calls Cache::adjustSize.
+        (CachedCSSStyleSheet::CachedCSSStyleSheet): Pass the length into the base
+	class's constructor instead of setting m_size.
+        (CachedCSSStyleSheet::data): Call setSize() instead of setting m_size.
+	Also get the size back with size() rather than m_size.
+        (CachedScript::CachedScript): Pass the length into the base class's
+	constructor instead of setting m_size.
+        (CachedScript::data): Call setSize() instead of setting m_size. Also get
+	the size back with size() rather than m_size.
+        (CachedImage::CachedImage): Don't set m_size to 0, since the base class's
+	constructor does that already.
+        (CachedImage::clear): Use setSize() to set the size to 0 instead of setting
+	m_size directly.
+        (CachedImage::data): Use setSize() instead of setting m_size directly.
+        (Cache::checkLRUAndUncacheableListIntegrity): Useful debugging function.
+	Left in but ifdef'd out.
+        (Cache::adjustSize): Added. Changes the "total LRU list size" by the
+	passed-in delta, but only if the passed-in object is in the LRU list.
+
+        * kwq/KWQLineEdit.mm:
+        * kwq/KWQTextField.h:
+        * kwq/KWQTextField.mm:
+	Renamed the Objective C class KWQNSTextField to KWQTextField.
+
+2002-10-26  Darin Adler  <darin at apple.com>
+
 	- removed forwarding headers that are not actually needed
 
         * ForwardingHeaders/kcmdlineargs.h: Removed.
diff --git a/WebCore/khtml/misc/loader.cpp b/WebCore/khtml/misc/loader.cpp
index 325805b..7248efe 100644
--- a/WebCore/khtml/misc/loader.cpp
+++ b/WebCore/khtml/misc/loader.cpp
@@ -155,6 +155,12 @@ void CachedObject::deref(CachedObjectClient *c)
         Cache::insertInLRUList(this);
 }
 
+void CachedObject::setSize(int size)
+{
+    Cache::adjustSize(this, size - m_size);
+    m_size = size;
+}
+
 // -------------------------------------------------------------------------------------------
 
 CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, KIO::CacheControl _cachePolicy, time_t _expireDate, const QString& charset)
@@ -173,12 +179,11 @@ CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, KI
 }
 
 CachedCSSStyleSheet::CachedCSSStyleSheet(const DOMString &url, const QString &stylesheet_data)
-    : CachedObject(url, CSSStyleSheet, KIO::CC_Verify, 0)
+    : CachedObject(url, CSSStyleSheet, KIO::CC_Verify, 0, stylesheet_data.length())
 {
     m_loading = false;
     m_status = Persistent;
     m_codec = 0;
-    m_size = stylesheet_data.length();
     m_sheet = DOMString(stylesheet_data);
 }
 
@@ -206,8 +211,8 @@ void CachedCSSStyleSheet::data( QBuffer &buffer, bool eof )
 {
     if(!eof) return;
     buffer.close();
-    m_size = buffer.buffer().size();
-    QString data = m_codec->toUnicode( buffer.buffer().data(), m_size );
+    setSize(buffer.buffer().size());
+    QString data = m_codec->toUnicode( buffer.buffer().data(), size() );
     m_sheet = DOMString(data);
     m_loading = false;
 
@@ -254,12 +259,11 @@ CachedScript::CachedScript(DocLoader* dl, const DOMString &url, KIO::CacheContro
 }
 
 CachedScript::CachedScript(const DOMString &url, const QString &script_data)
-    : CachedObject(url, Script, KIO::CC_Verify, 0)
+    : CachedObject(url, Script, KIO::CC_Verify, 0, script_data.length())
 {
     m_loading = false;
     m_status = Persistent;
     m_codec = 0;
-    m_size = script_data.length();
     m_script = DOMString(script_data);
 }
 
@@ -286,8 +290,8 @@ void CachedScript::data( QBuffer &buffer, bool eof )
 {
     if(!eof) return;
     buffer.close();
-    m_size = buffer.buffer().size();
-    QString data = m_codec->toUnicode( buffer.buffer().data(), m_size );
+    setSize(buffer.buffer().size());
+    QString data = m_codec->toUnicode( buffer.buffer().data(), size() );
     m_script = DOMString(data);
     m_loading = false;
     checkNotify();
@@ -501,7 +505,6 @@ CachedImage::CachedImage(DocLoader* dl, const DOMString &url, KIO::CacheControl
     monochrome = false;
     formatType = 0;
     m_status = Unknown;
-    m_size = 0;
     imgSource = 0;
 #if !APPLE_CHANGES
     setAccept( acceptHeader );
@@ -824,7 +827,7 @@ void CachedImage::clear()
 #if !APPLE_CHANGES
     typeChecked = false;
 #endif
-    m_size = 0;
+    setSize(0);
 
     // No need to delete imageSource - QMovie does it for us
     imgSource = 0;
@@ -884,7 +887,7 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
         }
 
         QSize s = pixmap_size();
-        m_size = s.width() * s.height() * 2;
+        setSize(s.width() * s.height() * 2);
     }
 #else // APPLE_CHANGES
     bool canDraw = false;
@@ -915,7 +918,7 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
             do_notify(*p, p->rect());
         }
         QSize s = pixmap_size();
-        m_size = s.width() * s.height() * 2;
+        setSize(s.width() * s.height() * 2);
     }
 #endif // APPLE_CHANGES
 }
@@ -1660,6 +1663,43 @@ void Cache::flush(bool force)
 #endif
 }
 
+#if 0
+
+void Cache::checkLRUAndUncacheableListIntegrity()
+{
+    int count = 0;
+    
+    {
+        int size = 0;
+        CachedObject *prev = 0;
+        for (CachedObject *o = m_headOfLRUList; o; o = o->m_nextInLRUList) {
+            ASSERT(o->allowInLRUList());
+            ASSERT(o->status() != CachedObject::Uncacheable);
+            ASSERT(o->m_prevInLRUList == prev);
+            size += o->size();
+            prev = o;
+            ++count;
+        }
+        ASSERT(m_tailOfLRUList == prev);
+        ASSERT(m_totalSizeOfLRUList == size);
+    }
+    
+    {
+        CachedObject *prev = 0;
+        for (CachedObject *o = m_headOfUncacheableList; o; o = o->m_nextInLRUList) {
+            ASSERT(o->allowInLRUList());
+            ASSERT(o->status() == CachedObject::Uncacheable);
+            ASSERT(o->m_prevInLRUList == prev);
+            prev = o;
+            ++count;
+        }
+    }
+    
+    ASSERT(m_countOfLRUAndUncacheableLists == count);
+}
+
+#endif
+
 void Cache::setSize( int bytes )
 {
     maxSize = bytes;
@@ -1790,6 +1830,19 @@ void Cache::insertInLRUList(CachedObject *object)
         m_totalSizeOfLRUList += object->size();
 }
 
+void Cache::adjustSize(CachedObject *object, int delta)
+{
+    if (object->m_nextInLRUList == 0 && object->m_prevInLRUList == 0 && m_headOfLRUList != object) {
+        return;
+    }
+
+    if (object->status() == CachedObject::Uncacheable) {
+        return;
+    }
+    
+    m_totalSizeOfLRUList += delta;
+}
+
 // --------------------------------------
 
 void CachedObjectClient::setPixmap(const QPixmap &, const QRect&, CachedImage *) {}
diff --git a/WebCore/khtml/misc/loader.h b/WebCore/khtml/misc/loader.h
index af144d8..95d95d5 100644
--- a/WebCore/khtml/misc/loader.h
+++ b/WebCore/khtml/misc/loader.h
@@ -99,12 +99,12 @@ namespace khtml
 	    Uncacheable   // to big to be cached,
 	};  	          // will be destroyed as soon as possible
 
-	CachedObject(const DOM::DOMString &url, Type type, KIO::CacheControl _cachePolicy, time_t _expireDate)
+	CachedObject(const DOM::DOMString &url, Type type, KIO::CacheControl _cachePolicy, time_t _expireDate, int size = 0)
 	{
 	    m_url = url;
 	    m_type = type;
 	    m_status = Pending;
-	    m_size = 0;
+	    m_size = size;
 	    m_free = false;
 	    m_cachePolicy = _cachePolicy;
 	    m_request = 0;
@@ -172,6 +172,8 @@ namespace khtml
         void setAccept(const QString &_accept) { m_accept = _accept; }
 
     protected:
+        void setSize(int size);
+        
         QPtrList<CachedObjectClient> m_clients;
 
 	DOM::DOMString m_url;
@@ -182,7 +184,9 @@ namespace khtml
 #endif
 	Type m_type;
 	Status m_status;
+    private:
 	int m_size;
+    protected:
 	time_t m_expireDate;
 	KIO::CacheControl m_cachePolicy;
         bool m_free : 1;
@@ -533,6 +537,9 @@ namespace khtml
 
         static void insertInLRUList(CachedObject *);
         static void removeFromLRUList(CachedObject *);
+        static void adjustSize(CachedObject *, int sizeDelta);
+        
+        static void checkLRUAndUncacheableListIntegrity();
 
         protected:
 	static QDict<CachedObject> *cache;
diff --git a/WebCore/kwq/KWQLineEdit.mm b/WebCore/kwq/KWQLineEdit.mm
index bb75898..8838140 100644
--- a/WebCore/kwq/KWQLineEdit.mm
+++ b/WebCore/kwq/KWQLineEdit.mm
@@ -36,14 +36,14 @@ QLineEdit::QLineEdit()
     : m_returnPressed(this, SIGNAL(returnPressed()))
     , m_textChanged(this, SIGNAL(textChanged(const QString &)))
 {
-    NSView *view = [[KWQNSTextField alloc] initWithQLineEdit:this];
+    NSView *view = [[KWQTextField alloc] initWithQLineEdit:this];
     setView(view);
     [view release];
 }
 
 void QLineEdit::setEchoMode(EchoMode mode)
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     [textField setPasswordMode:mode == Password];
 }
 
@@ -61,19 +61,19 @@ int QLineEdit::cursorPosition() const
 void QLineEdit::setFont(const QFont &font)
 {
     QWidget::setFont(font);
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     [textField setFont:font.getNSFont()];
 }
 
 void QLineEdit::setText(const QString &s)
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     [textField setStringValue:s.getNSString()];
 }
 
 QString QLineEdit::text()
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     NSMutableString *text = [[[textField stringValue] mutableCopy] autorelease];
     [text replaceOccurrencesOfString:@"\r\n" withString:@"\n" options:NSLiteralSearch range:NSMakeRange(0, [text length])];
     [text replaceOccurrencesOfString:@"\r" withString:@"\n" options:NSLiteralSearch range:NSMakeRange(0, [text length])];
@@ -82,19 +82,19 @@ QString QLineEdit::text()
 
 void QLineEdit::setMaxLength(int len)
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     [textField setMaximumLength:len];
 }
 
 bool QLineEdit::isReadOnly() const
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     return ![textField isEditable];
 }
 
 void QLineEdit::setReadOnly(bool flag)
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     return [textField setEditable:!flag];
 }
 
@@ -106,25 +106,25 @@ bool QLineEdit::frame() const
 
 int QLineEdit::maxLength() const
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     return [textField maximumLength];
 }
 
 void QLineEdit::selectAll()
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     return [textField selectText:nil];
 }
 
 bool QLineEdit::edited() const
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     return [textField edited];
 }
 
 void QLineEdit::setEdited(bool flag)
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     return [textField setEdited:flag];
 }
 
@@ -135,7 +135,7 @@ QSize QLineEdit::sizeForCharacterWidth(int numCharacters) const
         [nominalWidthString appendString:@"x"];
     }
         
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     NSString *value = [textField stringValue];
     [textField setStringValue:nominalWidthString];
     NSSize size = [[textField cell] cellSize];
@@ -146,7 +146,7 @@ QSize QLineEdit::sizeForCharacterWidth(int numCharacters) const
 
 int QLineEdit::baselinePosition() const
 {
-    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    KWQTextField *textField = (KWQTextField *)getView();
     NSRect bounds = [textField bounds];
     NSFont *font = [textField font];
     return (int)ceil([[textField cell] drawingRectForBounds:bounds].origin.y - bounds.origin.y
diff --git a/WebCore/kwq/KWQTextField.h b/WebCore/kwq/KWQTextField.h
index e190b24..0c8b106 100644
--- a/WebCore/kwq/KWQTextField.h
+++ b/WebCore/kwq/KWQTextField.h
@@ -28,7 +28,7 @@
 class QLineEdit;
 @class KWQTextFieldFormatter;
 
- at interface KWQNSTextField : NSTextField
+ at interface KWQTextField : NSTextField
 {
 @private
     QLineEdit *widget;
diff --git a/WebCore/kwq/KWQTextField.mm b/WebCore/kwq/KWQTextField.mm
index 8624744..0e5764d 100644
--- a/WebCore/kwq/KWQTextField.mm
+++ b/WebCore/kwq/KWQTextField.mm
@@ -56,7 +56,7 @@
 
 @end
 
- at implementation KWQNSTextField
+ at implementation KWQTextField
 
 - (void)setUpTextField:(NSTextField *)field
 {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list