[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 08:31:56 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 8639aa3d5d72b746218c8a754616a7c0501e37be
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Apr 1 18:06:14 2004 +0000

            Reviewed by John.
    
            - cleaned up image map code and made it work with XML documents
    
            * khtml/html/html_documentimpl.h: Removed getMap and mapMap.
            * khtml/html/html_documentimpl.cpp: Removed getMap; moved to base class.
    
            * khtml/html/html_imageimpl.cpp:
            (HTMLMapElementImpl::~HTMLMapElementImpl): Call new removeImageMap function instead
            of manipulating the mapMap field directly.
            (HTMLMapElementImpl::parseHTMLAttribute): Rewrite name changing code for simplicity
            and to avoid running off the end of the bufffer.
            Also remove image map before changing name so it doesn't end up in the map twice
            under both the old and new names.
            * khtml/html/html_imageimpl.h: Use a DOMString instead of QString for the name, since
            the public API already uses a DOMString.
    
            * khtml/rendering/render_image.cpp: (RenderImage::nodeAtPoint): Call the new
            getImageMap instead of the old getMap.
    
            * khtml/xml/dom_docimpl.h: Added addImageMap, removeImageMap, getImageMap, and m_imageMapsByName.
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::addImageMap): Added. Stores the image map under its name, unless there's
            already another map of the same.
            (DocumentImpl::removeImageMap): Added. Removes the image map if it's already filed by
            name. Avoid pitfall of removing another image map that has the same name.
            (DocumentImpl::getImageMap): Added. Simplified version of logic from getMap in HTMLDocumentImpl.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6297 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 036ef1c..dd3660d 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,35 @@
 2004-04-01  Darin Adler  <darin at apple.com>
 
+        Reviewed by John.
+
+        - cleaned up image map code and made it work with XML documents
+
+        * khtml/html/html_documentimpl.h: Removed getMap and mapMap.
+        * khtml/html/html_documentimpl.cpp: Removed getMap; moved to base class.
+
+        * khtml/html/html_imageimpl.cpp:
+        (HTMLMapElementImpl::~HTMLMapElementImpl): Call new removeImageMap function instead
+        of manipulating the mapMap field directly.
+        (HTMLMapElementImpl::parseHTMLAttribute): Rewrite name changing code for simplicity
+        and to avoid running off the end of the bufffer.
+        Also remove image map before changing name so it doesn't end up in the map twice
+        under both the old and new names.
+        * khtml/html/html_imageimpl.h: Use a DOMString instead of QString for the name, since
+        the public API already uses a DOMString.
+
+        * khtml/rendering/render_image.cpp: (RenderImage::nodeAtPoint): Call the new
+        getImageMap instead of the old getMap.
+
+        * khtml/xml/dom_docimpl.h: Added addImageMap, removeImageMap, getImageMap, and m_imageMapsByName.
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::addImageMap): Added. Stores the image map under its name, unless there's
+        already another map of the same.
+        (DocumentImpl::removeImageMap): Added. Removes the image map if it's already filed by
+        name. Avoid pitfall of removing another image map that has the same name.
+        (DocumentImpl::getImageMap): Added. Simplified version of logic from getMap in HTMLDocumentImpl.
+
+2004-04-01  Darin Adler  <darin at apple.com>
+
         Reviewed by Ken.
 
         - fixed <rdar://problem/3608978>: dual <map> means you can't select the enter site button at jurassicpark.com (same problem in MacIE, works in Netscape)
diff --git a/WebCore/khtml/html/html_documentimpl.cpp b/WebCore/khtml/html/html_documentimpl.cpp
index c847e09..de4bb87 100644
--- a/WebCore/khtml/html/html_documentimpl.cpp
+++ b/WebCore/khtml/html/html_documentimpl.cpp
@@ -292,26 +292,6 @@ void HTMLDocumentImpl::slotHistoryChanged()
     m_render->repaint();
 }
 
-HTMLMapElementImpl* HTMLDocumentImpl::getMap(const DOMString& _url)
-{
-    if (_url.isNull()) {
-        return 0;
-    }
-    
-    QString url = _url.string();
-    QString s;
-    int pos = url.find('#');
-    //kdDebug(0) << "map pos of #:" << pos << endl;
-    s = QString(_url.unicode() + pos + 1, _url.length() - pos - 1);
-
-    QMapConstIterator<QString,HTMLMapElementImpl*> it = mapMap.find(s);
-
-    if (it != mapMap.end())
-        return *it;
-    else
-        return 0;
-}
-
 void HTMLDocumentImpl::addNamedImageOrForm(const QString &name)
 {
     if (name.length() == 0) {
diff --git a/WebCore/khtml/html/html_documentimpl.h b/WebCore/khtml/html/html_documentimpl.h
index 1e22292..8ec22f1 100644
--- a/WebCore/khtml/html/html_documentimpl.h
+++ b/WebCore/khtml/html/html_documentimpl.h
@@ -28,23 +28,12 @@
 #include "xml/dom_docimpl.h"
 #include "misc/loader_client.h"
 
-#include <qmap.h>
-
 class KHTMLView;
 class QString;
 
 namespace DOM {
 
-    class HTMLCollection;
-    class NodeList;
-    class Element;
-    class HTMLElement;
     class HTMLElementImpl;
-    class DOMString;
-    class CSSStyleSheetImpl;
-    class HTMLMapElementImpl;
-    class HTMLImageElementImpl;
-    class HTMLFormElementImpl;
 
 class HTMLDocumentImpl : public DOM::DocumentImpl, public khtml::CachedObjectClient
 {
@@ -76,8 +65,6 @@ public:
 
     virtual ElementImpl *createElement ( const DOMString &tagName, int &exceptioncode );
 
-    HTMLMapElementImpl* getMap(const DOMString& url_);
-
     virtual void determineParseMode( const QString &str );
 
     void addNamedImageOrForm(const QString &name);
@@ -87,9 +74,6 @@ public:
 protected:
     HTMLElementImpl *bodyElement;
     HTMLElementImpl *htmlElement;
-    friend class HTMLMapElementImpl;
-    friend class HTMLImageElementImpl;
-    QMap<QString,HTMLMapElementImpl*> mapMap;
 
 protected slots:
     /**
diff --git a/WebCore/khtml/html/html_imageimpl.cpp b/WebCore/khtml/html/html_imageimpl.cpp
index 5b8f963..13e7945 100644
--- a/WebCore/khtml/html/html_imageimpl.cpp
+++ b/WebCore/khtml/html/html_imageimpl.cpp
@@ -308,8 +308,8 @@ HTMLMapElementImpl::HTMLMapElementImpl(DocumentPtr *doc)
 
 HTMLMapElementImpl::~HTMLMapElementImpl()
 {
-    if(getDocument() && getDocument()->isHTMLDocument())
-        static_cast<HTMLDocumentImpl*>(getDocument())->mapMap.remove(name);
+    if (getDocument())
+        getDocument()->removeImageMap(this);
 }
 
 NodeImpl::Id HTMLMapElementImpl::id() const
@@ -365,20 +365,12 @@ void HTMLMapElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
         if (getDocument()->htmlMode() != DocumentImpl::XHtml) break;
         // fall through
     case ATTR_NAME:
-    {
-        DOMString s = attr->value();
-        if(*s.unicode() == '#')
-            name = QString(s.unicode()+1, s.length()-1);
-        else
-            name = s.string();
-	// ### make this work for XML documents, e.g. in case of <html:map...>
-        if (getDocument()->isHTMLDocument()) {
-            QMap<QString, HTMLMapElementImpl*> &mapMap = static_cast<HTMLDocumentImpl*>(getDocument())->mapMap;
-            if (!mapMap.contains(name))
-                mapMap.insert(name, this);
-        }
+        getDocument()->removeImageMap(this);
+        name = attr->value();
+        if (name.length() != 0 && name[0] == '#')
+            name.remove(0, 1);
+        getDocument()->addImageMap(this);
         break;
-    }
     default:
         HTMLElementImpl::parseHTMLAttribute(attr);
     }
diff --git a/WebCore/khtml/html/html_imageimpl.h b/WebCore/khtml/html/html_imageimpl.h
index 4668a77..fc1b359 100644
--- a/WebCore/khtml/html/html_imageimpl.h
+++ b/WebCore/khtml/html/html_imageimpl.h
@@ -124,7 +124,7 @@ public:
                        khtml::RenderObject::NodeInfo& info);
 private:
 
-    QString name;
+    DOMString name;
 };
 
 
diff --git a/WebCore/khtml/rendering/render_image.cpp b/WebCore/khtml/rendering/render_image.cpp
index 719296f..b6617f5 100644
--- a/WebCore/khtml/rendering/render_image.cpp
+++ b/WebCore/khtml/rendering/render_image.cpp
@@ -516,8 +516,7 @@ bool RenderImage::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty,
         
         HTMLImageElementImpl* i = element()->id() == ID_IMG ? static_cast<HTMLImageElementImpl*>(element()) : 0;
         HTMLMapElementImpl* map;
-        if (i && i->getDocument()->isHTMLDocument() &&
-            (map = static_cast<HTMLDocumentImpl*>(i->getDocument())->getMap(i->imageMap()))) {
+        if (i && (map = i->getDocument()->getImageMap(i->imageMap()))) {
             // we're a client side image map
             inside = map->mapMouseEvent(_x - tx, _y - ty, contentWidth(), contentHeight(), info);
             info.setInnerNonSharedNode(element());
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 8aaca68..387252c 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -2512,6 +2512,42 @@ bool DocumentImpl::isValidName(const DOMString &name)
     return true;
 }
 
+void DocumentImpl::addImageMap(HTMLMapElementImpl *imageMap)
+{
+    // Add the image map, unless there's already another with that name.
+    // "First map wins" is the rule other browsers seem to implement.
+    QString name = imageMap->getName().string();
+    if (!m_imageMapsByName.contains(name))
+        m_imageMapsByName.insert(name, imageMap);
+}
+
+void DocumentImpl::removeImageMap(HTMLMapElementImpl *imageMap)
+{
+    // Remove the image map by name.
+    // But don't remove some other image map that just happens to have the same name.
+    QString name = imageMap->getName().string();
+    QMapIterator<QString, HTMLMapElementImpl *> it = m_imageMapsByName.find(name);
+    if (it != m_imageMapsByName.end() && *it == imageMap)
+        m_imageMapsByName.remove(it);
+}
+
+HTMLMapElementImpl *DocumentImpl::getImageMap(const DOMString &URL) const
+{
+    if (URL.isNull()) {
+        return 0;
+    }
+
+    QString s = URL.string();
+    int hashPos = s.find('#');
+    if (hashPos >= 0)
+        s = s.mid(hashPos + 1);
+
+    QMapConstIterator<QString, HTMLMapElementImpl *> it = m_imageMapsByName.find(s);
+    if (it == m_imageMapsByName.end())
+        return 0;
+    return *it;
+}
+
 #if APPLE_CHANGES
 
 void DocumentImpl::setDecoder(Decoder *decoder)
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index fce34fe..0124b00 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -92,6 +92,7 @@ namespace DOM {
     class GenericRONamedNodeMapImpl;
     class HTMLDocumentImpl;
     class HTMLElementImpl;
+    class HTMLMapElementImpl;
     class NodeFilter;
     class NodeFilterImpl;
     class NodeIteratorImpl;
@@ -488,6 +489,10 @@ public:
     void addElementById(const DOMString &elementId, ElementImpl *element);
     void removeElementById(const DOMString &elementId, ElementImpl *element);
 
+    void addImageMap(HTMLMapElementImpl *);
+    void removeImageMap(HTMLMapElementImpl *);
+    HTMLMapElementImpl *getImageMap(const DOMString &URL) const;
+
     HTMLElementImpl* body();
 
     DOMString toString() const;
@@ -599,6 +604,8 @@ protected:
     XBL::XBLBindingManager* m_bindingManager; // The access point through which documents and elements communicate with XBL.
 #endif
     
+    QMap<QString, HTMLMapElementImpl *> m_imageMapsByName;
+
 #if APPLE_CHANGES
 public:
     KWQSignal m_finishedParsing;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list