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

mjs mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:12:28 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 2ecdb776bf8e146a1c7ff7dfdc26767c683ff3ac
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Dec 7 00:27:57 2002 +0000

            Reviewed by: Darin
    
    	- fixed 3077227 - netflix "top 100" page JavaScript runs so
    	slowly, it seems like a hang
    
    	I fixed this by adding hash tables of image and form elements by
    	name and id. This allows scans of the whole document to be avoided
    	in many cases.
    
    	This also results in a small speedup (~1%) on cvs-js-ibench.
    
            * khtml/dom/html_document.cpp:
            * khtml/ecma/kjs_html.cpp:
            (KJS::HTMLDocument::hasProperty):
            (KJS::HTMLDocument::tryGet):
            * khtml/html/html_documentimpl.cpp:
            (HTMLDocumentImpl::addNamedImageOrForm):
            (HTMLDocumentImpl::removeNamedImageOrForm):
            (HTMLDocumentImpl::haveNamedImageOrForm):
            * khtml/html/html_documentimpl.h:
            * khtml/html/html_formimpl.cpp:
            (HTMLFormElementImpl::attach):
            (HTMLFormElementImpl::detach):
            (HTMLFormElementImpl::parseAttribute):
            * khtml/html/html_formimpl.h:
            * khtml/html/html_imageimpl.cpp:
            (HTMLImageElementImpl::parseAttribute):
            (HTMLImageElementImpl::attach):
            (HTMLImageElementImpl::detach):
            * khtml/html/html_imageimpl.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2962 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 970c1cb..85b54d4 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,36 @@
+2002-12-06  Maciej Stachowiak  <mjs at apple.com>
+
+        Reviewed by: Darin
+
+	- fixed 3077227 - netflix "top 100" page JavaScript runs so
+	slowly, it seems like a hang
+
+	I fixed this by adding hash tables of image and form elements by
+	name and id. This allows scans of the whole document to be avoided
+	in many cases.
+
+	This also results in a small speedup (~1%) on cvs-js-ibench.
+
+        * khtml/dom/html_document.cpp:
+        * khtml/ecma/kjs_html.cpp:
+        (KJS::HTMLDocument::hasProperty):
+        (KJS::HTMLDocument::tryGet):
+        * khtml/html/html_documentimpl.cpp:
+        (HTMLDocumentImpl::addNamedImageOrForm):
+        (HTMLDocumentImpl::removeNamedImageOrForm):
+        (HTMLDocumentImpl::haveNamedImageOrForm):
+        * khtml/html/html_documentimpl.h:
+        * khtml/html/html_formimpl.cpp:
+        (HTMLFormElementImpl::attach):
+        (HTMLFormElementImpl::detach):
+        (HTMLFormElementImpl::parseAttribute):
+        * khtml/html/html_formimpl.h:
+        * khtml/html/html_imageimpl.cpp:
+        (HTMLImageElementImpl::parseAttribute):
+        (HTMLImageElementImpl::attach):
+        (HTMLImageElementImpl::detach):
+        * khtml/html/html_imageimpl.h:
+
 2002-12-06  David Hyatt  <hyatt at apple.com>
 
 	Hack to make i-bench paint every fourth page.  We can tune
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 970c1cb..85b54d4 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,36 @@
+2002-12-06  Maciej Stachowiak  <mjs at apple.com>
+
+        Reviewed by: Darin
+
+	- fixed 3077227 - netflix "top 100" page JavaScript runs so
+	slowly, it seems like a hang
+
+	I fixed this by adding hash tables of image and form elements by
+	name and id. This allows scans of the whole document to be avoided
+	in many cases.
+
+	This also results in a small speedup (~1%) on cvs-js-ibench.
+
+        * khtml/dom/html_document.cpp:
+        * khtml/ecma/kjs_html.cpp:
+        (KJS::HTMLDocument::hasProperty):
+        (KJS::HTMLDocument::tryGet):
+        * khtml/html/html_documentimpl.cpp:
+        (HTMLDocumentImpl::addNamedImageOrForm):
+        (HTMLDocumentImpl::removeNamedImageOrForm):
+        (HTMLDocumentImpl::haveNamedImageOrForm):
+        * khtml/html/html_documentimpl.h:
+        * khtml/html/html_formimpl.cpp:
+        (HTMLFormElementImpl::attach):
+        (HTMLFormElementImpl::detach):
+        (HTMLFormElementImpl::parseAttribute):
+        * khtml/html/html_formimpl.h:
+        * khtml/html/html_imageimpl.cpp:
+        (HTMLImageElementImpl::parseAttribute):
+        (HTMLImageElementImpl::attach):
+        (HTMLImageElementImpl::detach):
+        * khtml/html/html_imageimpl.h:
+
 2002-12-06  David Hyatt  <hyatt at apple.com>
 
 	Hack to make i-bench paint every fourth page.  We can tune
diff --git a/WebCore/khtml/dom/html_document.cpp b/WebCore/khtml/dom/html_document.cpp
index a6ae03b..8a189e8 100644
--- a/WebCore/khtml/dom/html_document.cpp
+++ b/WebCore/khtml/dom/html_document.cpp
@@ -28,6 +28,10 @@
 #include "html/html_documentimpl.h"
 #include "html/html_miscimpl.h"
 #include "misc/htmlhashes.h"
+#include "dom/html_image.h"
+#include "dom/html_form.h"
+#include "html/html_imageimpl.h"
+#include "html/html_formimpl.h"
 
 using namespace DOM;
 
diff --git a/WebCore/khtml/ecma/kjs_html.cpp b/WebCore/khtml/ecma/kjs_html.cpp
index 94a0516..25fdee2 100644
--- a/WebCore/khtml/ecma/kjs_html.cpp
+++ b/WebCore/khtml/ecma/kjs_html.cpp
@@ -139,10 +139,10 @@ bool KJS::HTMLDocument::hasProperty(ExecState *exec, const Identifier &p) const
 #ifdef KJS_VERBOSE
   //kdDebug(6070) << "KJS::HTMLDocument::hasProperty " << p.qstring() << endl;
 #endif
-  if ((!static_cast<DOM::HTMLDocument>(node).images().namedItem(p.string()).isNull()) ||
-      (!static_cast<DOM::HTMLDocument>(node).forms().namedItem(p.string()).isNull()))
-    return true;
-  return DOMDocument::hasProperty(exec, p);
+  DOM::HTMLDocumentImpl *docImpl = static_cast<DOM::HTMLDocumentImpl *>(node.handle());
+
+  return (DOMDocument::hasProperty(exec, p) ||  
+	  docImpl->haveNamedImageOrForm(p.qstring()));
 }
 
 Value KJS::HTMLDocument::tryGet(ExecState *exec, const Identifier &propertyName) const
@@ -247,6 +247,12 @@ Value KJS::HTMLDocument::tryGet(ExecState *exec, const Identifier &propertyName)
 
   //kdDebug(6070) << "KJS::HTMLDocument::tryGet " << propertyName.qstring() << " not found, returning element" << endl;
   // image and form elements with the name p will be looked up last
+
+  DOM::HTMLDocumentImpl *docImpl = static_cast<DOM::HTMLDocumentImpl*>(node.handle());
+  if (!docImpl->haveNamedImageOrForm(propertyName.qstring())) {
+    return Undefined();
+  }
+
   DOM::HTMLCollection coll = doc.images();
   DOM::HTMLCollection coll2 = doc.forms();
   DOM::HTMLElement element = coll.namedItem(propertyName.string());
diff --git a/WebCore/khtml/html/html_documentimpl.cpp b/WebCore/khtml/html/html_documentimpl.cpp
index 3febadd..13f0a84 100644
--- a/WebCore/khtml/html/html_documentimpl.cpp
+++ b/WebCore/khtml/html/html_documentimpl.cpp
@@ -27,6 +27,8 @@
 #include "html/html_baseimpl.h"
 #include "html/htmltokenizer.h"
 #include "html/html_miscimpl.h"
+#include "html/html_imageimpl.h"
+#include "html/html_formimpl.h"
 
 #include "khtmlview.h"
 #include "khtml_part.h"
@@ -339,6 +341,37 @@ void HTMLDocumentImpl::close()
     }
 }
 
+void HTMLDocumentImpl::addNamedImageOrForm(const QString &name)
+{
+    if (name.length() == 0) {
+	return;
+    }
+ 
+    int oldCount = (int)namedImageAndFormCounts.find(name);
+    namedImageAndFormCounts.insert(name, (char *)(oldCount + 1));
+}
+
+void HTMLDocumentImpl::removeNamedImageOrForm(const QString &name)
+{ 
+    if (name.length() == 0) {
+	return;
+    }
+ 
+    int oldVal = (int)(namedImageAndFormCounts.find(name));
+    if (oldVal != 0) {
+	int newVal = oldVal - 1;
+	if (newVal == 0) {
+	    namedImageAndFormCounts.remove(name);
+	} else {
+	    namedImageAndFormCounts.insert(name, (char *)newVal);
+	}
+    }
+}
+
+bool HTMLDocumentImpl::haveNamedImageOrForm(const QString &name)
+{
+    return namedImageAndFormCounts.find(name) != NULL;
+}
 
 void HTMLDocumentImpl::determineParseMode( const QString &str )
 {
diff --git a/WebCore/khtml/html/html_documentimpl.h b/WebCore/khtml/html/html_documentimpl.h
index 4164bd6..3d0a485 100644
--- a/WebCore/khtml/html/html_documentimpl.h
+++ b/WebCore/khtml/html/html_documentimpl.h
@@ -43,6 +43,8 @@ namespace DOM {
     class DOMString;
     class CSSStyleSheetImpl;
     class HTMLMapElementImpl;
+    class HTMLImageElementImpl;
+    class HTMLFormElementImpl;
 
 class HTMLDocumentImpl : public DOM::DocumentImpl, public khtml::CachedObjectClient
 {
@@ -78,6 +80,10 @@ public:
     virtual void determineParseMode( const QString &str );
     virtual void close();
 
+    void addNamedImageOrForm(const QString &name);
+    void removeNamedImageOrForm(const QString &name);
+    bool haveNamedImageOrForm(const QString &name);
+
 protected:
     HTMLElementImpl *bodyElement;
     HTMLElementImpl *htmlElement;
@@ -93,7 +99,10 @@ protected slots:
 private:
     mutable DOMString m_domain;
     QTime m_startTime;
-    
+    // we actually store ints inside the pointer value itself; would use void *
+    // but that makes the template unhappy.
+    QDict<char> namedImageAndFormCounts;
+
 #if APPLE_CHANGES
     DOMString m_policyBaseURL;
 #endif
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index dc34d5e..dd1b931 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -89,6 +89,30 @@ NodeImpl::Id HTMLFormElementImpl::id() const
     return ID_FORM;
 }
 
+void HTMLFormElementImpl::attach()
+{
+    RenderStyle* style = getDocument()->styleSelector()->styleForElement(this);
+
+    if (style->display() != NONE && getDocument()->isHTMLDocument()) {
+	HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+	document->addNamedImageOrForm(oldNameAttr);
+	document->addNamedImageOrForm(oldIdAttr);
+    }
+
+    HTMLElementImpl::attach();
+}
+
+void HTMLFormElementImpl::detach()
+{
+    if (getDocument()->isHTMLDocument()) {
+	HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+	document->removeNamedImageOrForm(oldNameAttr);
+	document->removeNamedImageOrForm(oldIdAttr);
+    }
+
+    HTMLElementImpl::detach();
+}
+
 long HTMLFormElementImpl::length() const
 {
     int len = 0;
@@ -486,9 +510,36 @@ void HTMLFormElementImpl::parseAttribute(AttributeImpl *attr)
         setHTMLEventListener(EventImpl::RESET_EVENT,
 	    getDocument()->createHTMLEventListener(attr->value().string()));
         break;
-    case ATTR_ID:
     case ATTR_NAME:
+	{
+	    QString newNameAttr = attr->value().string();
+	    
+	    if (attached() && 
+		getDocument()->isHTMLDocument() &&
+		getDocument()->styleSelector()->styleForElement(this)->display() != NONE) {
+		
+		HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+		document->removeNamedImageOrForm(oldNameAttr);
+		document->addNamedImageOrForm(newNameAttr);
+	    }
+	    oldNameAttr = newNameAttr;
+	}
 	break;
+    case ATTR_ID:
+	{
+	    QString newIdAttr = attr->value().string();
+	    
+	    if (attached() && 
+		getDocument()->isHTMLDocument() &&
+		getDocument()->styleSelector()->styleForElement(this)->display() != NONE) {
+		
+		HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+		document->removeNamedImageOrForm(oldIdAttr);
+		document->addNamedImageOrForm(newIdAttr);
+	    }
+	    oldIdAttr = newIdAttr;
+	}
+	// fall through
     default:
         HTMLElementImpl::parseAttribute(attr);
     }
diff --git a/WebCore/khtml/html/html_formimpl.h b/WebCore/khtml/html/html_formimpl.h
index a49b059..237ab0d 100644
--- a/WebCore/khtml/html/html_formimpl.h
+++ b/WebCore/khtml/html/html_formimpl.h
@@ -64,6 +64,9 @@ public:
 
     virtual Id id() const;
 
+    virtual void attach();
+    virtual void detach();
+
     long length() const;
 
     QByteArray formData(bool& ok);
@@ -112,6 +115,9 @@ public:
     bool m_doingsubmit : 1;
     bool m_inreset : 1;
     bool m_malformed : 1;
+ private:
+    QString oldIdAttr;
+    QString oldNameAttr;
 };
 
 // -------------------------------------------------------------------------
diff --git a/WebCore/khtml/html/html_imageimpl.cpp b/WebCore/khtml/html/html_imageimpl.cpp
index efac205..56a3c8b 100644
--- a/WebCore/khtml/html/html_imageimpl.cpp
+++ b/WebCore/khtml/html/html_imageimpl.cpp
@@ -132,9 +132,39 @@ void HTMLImageElementImpl::parseAttribute(AttributeImpl *attr)
         setHTMLEventListener(EventImpl::LOAD_EVENT,
 	    getDocument()->createHTMLEventListener(attr->value().string()));
         break;
-    case ATTR_NAME:
     case ATTR_NOSAVE:
 	break;
+    case ATTR_NAME:
+	{
+	    QString newNameAttr = attr->value().string();
+	    
+	    if (attached() && 
+		getDocument()->isHTMLDocument() &&
+		getDocument()->styleSelector()->styleForElement(this)->display() != NONE) {
+		
+		HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+		document->removeNamedImageOrForm(oldNameAttr);
+		document->addNamedImageOrForm(newNameAttr);
+	    }
+	    
+	    oldNameAttr = newNameAttr;
+	}
+	break;
+    case ATTR_ID:
+	{
+	    QString newIdAttr = attr->value().string();
+	    
+	    if (attached() && 
+		getDocument()->isHTMLDocument() &&
+		getDocument()->styleSelector()->styleForElement(this)->display() != NONE) {
+		
+		HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+		document->removeNamedImageOrForm(oldIdAttr);
+		document->addNamedImageOrForm(newIdAttr);
+	    }
+	    oldIdAttr = newIdAttr;
+	}
+	// fall through
     default:
         HTMLElementImpl::parseAttribute(attr);
     }
@@ -176,11 +206,28 @@ void HTMLImageElementImpl::attach()
         parentNode()->renderer()->addChild(m_render, nextRenderer());
         m_render->updateFromElement();
     }
+
+    if (getDocument()->isHTMLDocument() && _style->display() != NONE) {
+	HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+	document->addNamedImageOrForm(oldIdAttr);
+	document->addNamedImageOrForm(oldNameAttr);
+    }
     _style->deref();
 
     NodeBaseImpl::attach();
 }
 
+void HTMLImageElementImpl::detach()
+{
+    if (getDocument()->isHTMLDocument()) {
+	HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+	document->removeNamedImageOrForm(oldIdAttr);
+	document->removeNamedImageOrForm(oldNameAttr);
+    }
+
+    NodeBaseImpl::detach();
+}
+
 long HTMLImageElementImpl::width() const
 {
     if (!m_render) return getAttribute(ATTR_WIDTH).toInt();
diff --git a/WebCore/khtml/html/html_imageimpl.h b/WebCore/khtml/html/html_imageimpl.h
index f2b53eb..d42e13e 100644
--- a/WebCore/khtml/html/html_imageimpl.h
+++ b/WebCore/khtml/html/html_imageimpl.h
@@ -46,6 +46,7 @@ public:
     virtual void parseAttribute(AttributeImpl *);
 
     virtual void attach();
+    virtual void detach();
 
     long width() const;
     long height() const;
@@ -60,6 +61,8 @@ public:
 protected:
     DOMString usemap;
     bool ismap;
+    QString oldIdAttr;
+    QString oldNameAttr;
 };
 
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list