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

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:27:13 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 4b91bee2c141a7de9ee8788952f7032af30dba1c
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Feb 20 18:57:29 2004 +0000

    Tests:
    
            Reviewed by dave.
    
            * Blot/BlotDocument.m:
            (-[BlotDocument dataRepresentationOfType:]): call renamed HTMLString on WebHTMLRepresentation
    
    WebCore:
    
    	Fixed: <rdar://problem/3563402>: when copying HTML, relative URLs should be made absolute
    
    	- Added isSubresourceURLAttribute to ElementImpl which is overridden by subclasses determine if an attribute refers to a subresource.
    	- Added isURLAttribute to ElementImpl which is overridden by subclasses determine if an attribute refers to any kind of URL.
    
            Reviewed by Dave.
    
            * khtml/html/html_baseimpl.cpp:
            (HTMLBodyElementImpl::isSubresourceURLAttribute):
            (HTMLFrameElementImpl::isSubresourceURLAttribute):
            (HTMLIFrameElementImpl::openURL):
            (HTMLIFrameElementImpl::isSubresourceURLAttribute):
            * khtml/html/html_baseimpl.h:
            * khtml/html/html_formimpl.cpp:
            (HTMLFormElementImpl::isURLAttribute):
            * khtml/html/html_formimpl.h:
            * khtml/html/html_headimpl.cpp:
            (HTMLLinkElementImpl::isSubresourceURLAttribute):
            (HTMLScriptElementImpl::id):
            (HTMLScriptElementImpl::isSubresourceURLAttribute):
            * khtml/html/html_headimpl.h:
            * khtml/html/html_imageimpl.cpp:
            (HTMLImageElementImpl::isSubresourceURLAttribute):
            (HTMLAreaElementImpl::getRegion):
            (HTMLAreaElementImpl::isSubresourceURLAttribute):
            * khtml/html/html_imageimpl.h:
            * khtml/html/html_inlineimpl.cpp:
            (HTMLAnchorElementImpl::isURLAttribute):
            * khtml/html/html_inlineimpl.h:
            * khtml/html/html_objectimpl.cpp:
            (HTMLEmbedElementImpl::isSubresourceURLAttribute):
            (HTMLObjectElementImpl::isSubresourceURLAttribute):
            (HTMLParamElementImpl::parseHTMLAttribute):
            (HTMLParamElementImpl::isSubresourceURLAttribute):
            * khtml/html/html_objectimpl.h:
            * khtml/html/html_tableimpl.cpp:
            (HTMLTableElementImpl::isSubresourceURLAttribute):
            (HTMLTableCellElementImpl::attach):
            (HTMLTableCellElementImpl::isSubresourceURLAttribute):
            * khtml/html/html_tableimpl.h:
            * khtml/xml/dom2_rangeimpl.cpp:
            (RangeImpl::toHTMLWithOptions): take completeURLs and subresourceURLs arguments
            (RangeImpl::toHTML): call toHTMLWithOptions with default options
            * khtml/xml/dom2_rangeimpl.h:
            * khtml/xml/dom_elementimpl.cpp:
            (ElementImpl::isURLAttribute):
            (ElementImpl::isSubresourceURLAttribute):
            * khtml/xml/dom_elementimpl.h:
            * khtml/xml/dom_nodeimpl.cpp:
            (NodeImpl::recursive_toHTMLWithOptions): take completeURLs and subresourceURLs arguments
            (NodeImpl::recursive_toHTML): call recursive_toHTML with default options
            * khtml/xml/dom_nodeimpl.h:
            * kwq/WebCoreBridge.h:
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge selectedHTML:]): renamed to return subresource URL strings
    
    WebKit:
    
    	Fixed: <rdar://problem/3563402>: when copying HTML, relative URLs should be made absolute
    
            Reviewed by dave.
    
            * WebView.subproj/WebHTMLRepresentation.h:
            * WebView.subproj/WebHTMLRepresentation.m:
            (-[WebHTMLRepresentation HTMLString]): renamed from reconstructed source to be more analogous with other data get methods
            * WebView.subproj/WebHTMLView.m:
            (-[WebHTMLView _writeSelectionToPasteboard:]): call renamed selectedHTML on the bridge
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6101 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 84f6591..2af91d2 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,61 @@
+2004-02-19  Chris Blumenberg  <cblu at apple.com>
+
+	Fixed: <rdar://problem/3563402>: when copying HTML, relative URLs should be made absolute
+
+	- Added isSubresourceURLAttribute to ElementImpl which is overridden by subclasses determine if an attribute refers to a subresource.
+	- Added isURLAttribute to ElementImpl which is overridden by subclasses determine if an attribute refers to any kind of URL.
+
+        Reviewed by Dave.
+
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLBodyElementImpl::isSubresourceURLAttribute):
+        (HTMLFrameElementImpl::isSubresourceURLAttribute):
+        (HTMLIFrameElementImpl::openURL):
+        (HTMLIFrameElementImpl::isSubresourceURLAttribute):
+        * khtml/html/html_baseimpl.h:
+        * khtml/html/html_formimpl.cpp:
+        (HTMLFormElementImpl::isURLAttribute):
+        * khtml/html/html_formimpl.h:
+        * khtml/html/html_headimpl.cpp:
+        (HTMLLinkElementImpl::isSubresourceURLAttribute):
+        (HTMLScriptElementImpl::id):
+        (HTMLScriptElementImpl::isSubresourceURLAttribute):
+        * khtml/html/html_headimpl.h:
+        * khtml/html/html_imageimpl.cpp:
+        (HTMLImageElementImpl::isSubresourceURLAttribute):
+        (HTMLAreaElementImpl::getRegion):
+        (HTMLAreaElementImpl::isSubresourceURLAttribute):
+        * khtml/html/html_imageimpl.h:
+        * khtml/html/html_inlineimpl.cpp:
+        (HTMLAnchorElementImpl::isURLAttribute):
+        * khtml/html/html_inlineimpl.h:
+        * khtml/html/html_objectimpl.cpp:
+        (HTMLEmbedElementImpl::isSubresourceURLAttribute):
+        (HTMLObjectElementImpl::isSubresourceURLAttribute):
+        (HTMLParamElementImpl::parseHTMLAttribute):
+        (HTMLParamElementImpl::isSubresourceURLAttribute):
+        * khtml/html/html_objectimpl.h:
+        * khtml/html/html_tableimpl.cpp:
+        (HTMLTableElementImpl::isSubresourceURLAttribute):
+        (HTMLTableCellElementImpl::attach):
+        (HTMLTableCellElementImpl::isSubresourceURLAttribute):
+        * khtml/html/html_tableimpl.h:
+        * khtml/xml/dom2_rangeimpl.cpp:
+        (RangeImpl::toHTMLWithOptions): take completeURLs and subresourceURLs arguments
+        (RangeImpl::toHTML): call toHTMLWithOptions with default options
+        * khtml/xml/dom2_rangeimpl.h:
+        * khtml/xml/dom_elementimpl.cpp:
+        (ElementImpl::isURLAttribute):
+        (ElementImpl::isSubresourceURLAttribute):
+        * khtml/xml/dom_elementimpl.h:
+        * khtml/xml/dom_nodeimpl.cpp:
+        (NodeImpl::recursive_toHTMLWithOptions): take completeURLs and subresourceURLs arguments
+        (NodeImpl::recursive_toHTML): call recursive_toHTML with default options
+        * khtml/xml/dom_nodeimpl.h:
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge selectedHTML:]): renamed to return subresource URL strings
+
 2004-02-17  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by Darin.
diff --git a/WebCore/khtml/html/html_baseimpl.cpp b/WebCore/khtml/html/html_baseimpl.cpp
index 3f3f16a..698156a 100644
--- a/WebCore/khtml/html/html_baseimpl.cpp
+++ b/WebCore/khtml/html/html_baseimpl.cpp
@@ -207,6 +207,11 @@ void HTMLBodyElementImpl::insertedIntoDocument()
     }
 }
 
+bool HTMLBodyElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_BACKGROUND;
+}
+
 // -------------------------------------------------------------------------
 
 HTMLFrameElementImpl::HTMLFrameElementImpl(DocumentPtr *doc)
@@ -489,6 +494,11 @@ DocumentImpl* HTMLFrameElementImpl::contentDocument() const
     return 0;
 }
 
+bool HTMLFrameElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_SRC;
+}
+
 // -------------------------------------------------------------------------
 
 HTMLFrameSetElementImpl::HTMLFrameSetElementImpl(DocumentPtr *doc)
@@ -625,7 +635,6 @@ void HTMLFrameSetElementImpl::recalcStyle( StyleChange ch )
     HTMLElementImpl::recalcStyle( ch );
 }
 
-
 // -------------------------------------------------------------------------
 
 HTMLHeadElementImpl::HTMLHeadElementImpl(DocumentPtr *doc)
@@ -753,3 +762,8 @@ void HTMLIFrameElementImpl::openURL()
     needWidgetUpdate = true;
     setChanged();
 }
+
+bool HTMLIFrameElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_SRC;
+}
diff --git a/WebCore/khtml/html/html_baseimpl.h b/WebCore/khtml/html/html_baseimpl.h
index f4db2a4..6a75738 100644
--- a/WebCore/khtml/html/html_baseimpl.h
+++ b/WebCore/khtml/html/html_baseimpl.h
@@ -62,6 +62,8 @@ public:
     virtual void insertedIntoDocument();
 
     void createLinkDecl();
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
 
 protected:
     CSSStyleDeclarationImpl* m_linkDecl;
@@ -94,6 +96,8 @@ public:
     virtual void setFocus(bool);
 
     DocumentImpl* contentDocument() const;
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
 
 #if APPLE_CHANGES
     QScrollView::ScrollBarMode scrollingMode() const { return scrolling; }
@@ -148,7 +152,7 @@ public:
     virtual void detach();
 
     virtual void recalcStyle( StyleChange ch );
-
+    
 protected:
     khtml::Length* m_rows;
     khtml::Length* m_cols;
@@ -205,6 +209,8 @@ public:
     virtual bool rendererIsNeeded(khtml::RenderStyle *);
     virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
     virtual void recalcStyle( StyleChange ch );
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
 
 protected:
     virtual void openURL();
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index 42d4f81..d1af261 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -696,6 +696,11 @@ void HTMLFormElementImpl::removeFormElement(HTMLGenericFormElementImpl *e)
     formElements.remove(e);
 }
 
+bool HTMLFormElementImpl::isURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_ACTION;
+}
+
 // -------------------------------------------------------------------------
 
 HTMLGenericFormElementImpl::HTMLGenericFormElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)
diff --git a/WebCore/khtml/html/html_formimpl.h b/WebCore/khtml/html/html_formimpl.h
index 5855123..147d263 100644
--- a/WebCore/khtml/html/html_formimpl.h
+++ b/WebCore/khtml/html/html_formimpl.h
@@ -97,8 +97,11 @@ public:
     void setMalformed(bool malformed) { m_malformed = malformed; }
     virtual bool isMalformed() { return m_malformed; }
     
+    virtual bool isURLAttribute(AttributeImpl *attr) const;
+    
 #if APPLE_CHANGES
     void submitClick();
+    bool formWouldHaveSecureSubmission(const DOMString &url);
 #endif
    
     static void i18nData();
@@ -122,9 +125,6 @@ public:
  private:
     QString oldIdAttr;
     QString oldNameAttr;
-#if APPLE_CHANGES
-    bool formWouldHaveSecureSubmission(const DOMString &url);
-#endif
 };
 
 // -------------------------------------------------------------------------
diff --git a/WebCore/khtml/html/html_headimpl.cpp b/WebCore/khtml/html/html_headimpl.cpp
index de6e4cc..3fc52a7 100644
--- a/WebCore/khtml/html/html_headimpl.cpp
+++ b/WebCore/khtml/html/html_headimpl.cpp
@@ -298,6 +298,11 @@ void HTMLLinkElementImpl::sheetLoaded()
         getDocument()->stylesheetLoaded();
 }
 
+bool HTMLLinkElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_HREF;
+}
+
 // -------------------------------------------------------------------------
 
 HTMLMetaElementImpl::HTMLMetaElementImpl(DocumentPtr *doc) : HTMLElementImpl(doc)
@@ -361,6 +366,11 @@ NodeImpl::Id HTMLScriptElementImpl::id() const
     return ID_SCRIPT;
 }
 
+bool HTMLScriptElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_SRC;
+}
+
 // -------------------------------------------------------------------------
 
 HTMLStyleElementImpl::HTMLStyleElementImpl(DocumentPtr *doc) : HTMLElementImpl(doc)
diff --git a/WebCore/khtml/html/html_headimpl.h b/WebCore/khtml/html/html_headimpl.h
index f870bab..abd0258 100644
--- a/WebCore/khtml/html/html_headimpl.h
+++ b/WebCore/khtml/html/html_headimpl.h
@@ -57,7 +57,7 @@ public:
     virtual void removedFromDocument();
 
     void process();
-
+    
 protected:
     DOMString m_href;
     DOMString m_target;
@@ -97,6 +97,8 @@ public:
     int disabledState() { return m_disabledState; }
     void setDisabledState(bool _disabled);
     
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
+    
 protected:
     khtml::CachedCSSStyleSheet *m_cachedSheet;
     CSSStyleSheetImpl *m_sheet;
@@ -140,6 +142,9 @@ public:
     ~HTMLScriptElementImpl();
 
     virtual Id id() const;
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
+    
 };
 
 // -------------------------------------------------------------------------
diff --git a/WebCore/khtml/html/html_imageimpl.cpp b/WebCore/khtml/html/html_imageimpl.cpp
index 832c0fd..a328810 100644
--- a/WebCore/khtml/html/html_imageimpl.cpp
+++ b/WebCore/khtml/html/html_imageimpl.cpp
@@ -294,6 +294,11 @@ QImage HTMLImageElementImpl::currentImage() const
     return QImage();
 }
 
+bool HTMLImageElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return (attr->id() == ATTR_SRC || (attr->id() == ATTR_USEMAP && attr->value().domString()[0] != '#'));
+}
+
 // -------------------------------------------------------------------------
 
 HTMLMapElementImpl::HTMLMapElementImpl(DocumentPtr *doc)
@@ -502,3 +507,8 @@ QRegion HTMLAreaElementImpl::getRegion(int width_, int height_) const
     return region;
 }
 
+bool HTMLAreaElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_HREF;
+}
+
diff --git a/WebCore/khtml/html/html_imageimpl.h b/WebCore/khtml/html/html_imageimpl.h
index 574fa4c..6b3c27d 100644
--- a/WebCore/khtml/html/html_imageimpl.h
+++ b/WebCore/khtml/html/html_imageimpl.h
@@ -59,7 +59,9 @@ public:
     DOMString altText() const;
 
     DOMString imageMap() const { return usemap; }
-
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
+    
 protected:
     DOMString usemap;
     bool ismap;
@@ -89,6 +91,8 @@ public:
                        khtml::RenderObject::NodeInfo& info);
 
     virtual QRect getRect() const;
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
 
 protected:
     QRegion getRegion(int width_, int height) const;
diff --git a/WebCore/khtml/html/html_inlineimpl.cpp b/WebCore/khtml/html/html_inlineimpl.cpp
index ebd1a06..5360953 100644
--- a/WebCore/khtml/html/html_inlineimpl.cpp
+++ b/WebCore/khtml/html/html_inlineimpl.cpp
@@ -234,6 +234,11 @@ void HTMLAnchorElementImpl::accessKeyAction()
     click();
 }
 
+bool HTMLAnchorElementImpl::isURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_HREF;
+}
+
 // -------------------------------------------------------------------------
 
 HTMLBRElementImpl::HTMLBRElementImpl(DocumentPtr *doc) : HTMLElementImpl(doc)
diff --git a/WebCore/khtml/html/html_inlineimpl.h b/WebCore/khtml/html/html_inlineimpl.h
index 9dd48ec..3f2546f 100644
--- a/WebCore/khtml/html/html_inlineimpl.h
+++ b/WebCore/khtml/html/html_inlineimpl.h
@@ -45,6 +45,7 @@ public:
     virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     virtual void defaultEventHandler(EventImpl *evt);
     virtual void accessKeyAction();
+    virtual bool isURLAttribute(AttributeImpl *attr) const;
 protected:
     bool m_hasTarget : 1;
 };
diff --git a/WebCore/khtml/html/html_objectimpl.cpp b/WebCore/khtml/html/html_objectimpl.cpp
index 65812c4..6130213 100644
--- a/WebCore/khtml/html/html_objectimpl.cpp
+++ b/WebCore/khtml/html/html_objectimpl.cpp
@@ -332,6 +332,11 @@ void HTMLEmbedElementImpl::attach()
     }
 }
 
+bool HTMLEmbedElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_SRC;
+}
+
 // -------------------------------------------------------------------------
 
 HTMLObjectElementImpl::HTMLObjectElementImpl(DocumentPtr *doc) : HTMLElementImpl(doc)
@@ -485,6 +490,11 @@ void HTMLObjectElementImpl::recalcStyle( StyleChange ch )
     HTMLElementImpl::recalcStyle( ch );
 }
 
+bool HTMLObjectElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return (attr->id() == ATTR_DATA || (attr->id() == ATTR_USEMAP && attr->value().domString()[0] != '#'));
+}
+
 // -------------------------------------------------------------------------
 
 HTMLParamElementImpl::HTMLParamElementImpl(DocumentPtr *doc)
@@ -516,3 +526,17 @@ void HTMLParamElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
         break;
     }
 }
+
+bool HTMLParamElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    if (attr->id() == ATTR_VALUE) {
+        AttributeImpl *attr = attributes()->getAttributeItem(ATTR_NAME);
+        if (attr) {
+            DOMString value = attr->value().string().lower();
+            if (value == "src" || value == "movie" || value == "data") {
+                return true;
+            }
+        }
+    }
+    return false;
+}
diff --git a/WebCore/khtml/html/html_objectimpl.h b/WebCore/khtml/html/html_objectimpl.h
index 0ee4431..97103f0 100644
--- a/WebCore/khtml/html/html_objectimpl.h
+++ b/WebCore/khtml/html/html_objectimpl.h
@@ -89,6 +89,8 @@ public:
     virtual void attach();
     virtual bool rendererIsNeeded(khtml::RenderStyle *);
     virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
 
     QString url;
     QString pluginPage;
@@ -119,6 +121,8 @@ public:
     virtual void recalcStyle( StyleChange ch );
 
     DocumentImpl* contentDocument() const;
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
 
     QString serviceType;
     QString url;
@@ -142,6 +146,8 @@ public:
 
     QString name() const { return m_name.string(); }
     QString value() const { return m_value.string(); }
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
 
  protected:
     AtomicString m_name;
diff --git a/WebCore/khtml/html/html_tableimpl.cpp b/WebCore/khtml/html/html_tableimpl.cpp
index fb0c9e8..88c8ef2 100644
--- a/WebCore/khtml/html/html_tableimpl.cpp
+++ b/WebCore/khtml/html/html_tableimpl.cpp
@@ -590,6 +590,11 @@ void HTMLTableElementImpl::attach()
 	static_cast<RenderTable *>(m_render)->setCellPadding( padding );
 }
 
+bool HTMLTableElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_BACKGROUND;
+}
+
 // --------------------------------------------------------------------------
 
 bool HTMLTablePartElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
@@ -968,6 +973,11 @@ void HTMLTableCellElementImpl::attach()
     HTMLTablePartElementImpl::attach();
 }
 
+bool HTMLTableCellElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return attr->id() == ATTR_BACKGROUND;
+}
+
 // -------------------------------------------------------------------------
 
 HTMLTableColElementImpl::HTMLTableColElementImpl(DocumentPtr *doc, ushort i)
diff --git a/WebCore/khtml/html/html_tableimpl.h b/WebCore/khtml/html/html_tableimpl.h
index 6dac9ff..ef23e56 100644
--- a/WebCore/khtml/html/html_tableimpl.h
+++ b/WebCore/khtml/html/html_tableimpl.h
@@ -106,6 +106,8 @@ public:
     CSSStyleDeclarationImpl* getSharedCellDecl();
 
     virtual void attach();
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
 
 protected:
     HTMLTableSectionElementImpl *head;
@@ -211,6 +213,8 @@ public:
 
     // used by table cells to share style decls created by the enclosing table.
     virtual CSSStyleDeclarationImpl* additionalAttributeStyleDecl();
+    
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
 
 protected:
     int _row;
diff --git a/WebCore/khtml/xml/dom2_rangeimpl.cpp b/WebCore/khtml/xml/dom2_rangeimpl.cpp
index 081e965..57bc2e8 100644
--- a/WebCore/khtml/xml/dom2_rangeimpl.cpp
+++ b/WebCore/khtml/xml/dom2_rangeimpl.cpp
@@ -843,7 +843,7 @@ DOMString RangeImpl::toString( int &exceptioncode )
     return text;
 }
 
-DOMString RangeImpl::toHTML(  )
+DOMString RangeImpl::toHTMLWithOptions(bool completeURLs, QStringList *subresourceURLs)
 {
 	// Find the common containing block node of the start and end nodes.
 	RenderBlock *startBlock = m_startContainer->renderer()->containingBlock();
@@ -867,7 +867,12 @@ DOMString RangeImpl::toHTML(  )
 		startBlock = startBlock->containingBlock();
 	}
 	
-    return commonBlockNode->recursive_toHTMLWithRange(true, this);
+    return commonBlockNode->recursive_toHTMLWithOptions(true, completeURLs, this, subresourceURLs);
+}
+
+DOMString RangeImpl::toHTML(  )
+{
+    return toHTMLWithOptions();
 }
 
 DocumentFragmentImpl *RangeImpl::createContextualFragment ( DOMString &html, int &exceptioncode )
diff --git a/WebCore/khtml/xml/dom2_rangeimpl.h b/WebCore/khtml/xml/dom2_rangeimpl.h
index 6387418..a197574 100644
--- a/WebCore/khtml/xml/dom2_rangeimpl.h
+++ b/WebCore/khtml/xml/dom2_rangeimpl.h
@@ -63,6 +63,7 @@ public:
     void insertNode( NodeImpl *newNode, int &exceptioncode );
     DOMString toString ( int &exceptioncode );
     DOMString toHTML (  );
+    DOMString toHTMLWithOptions(bool completeURLs=false, QStringList *subresourceURLs=NULL);
 
     DocumentFragmentImpl *createContextualFragment ( DOMString &html, int &exceptioncode );
     
diff --git a/WebCore/khtml/xml/dom_elementimpl.cpp b/WebCore/khtml/xml/dom_elementimpl.cpp
index 650b1d5..915f127 100644
--- a/WebCore/khtml/xml/dom_elementimpl.cpp
+++ b/WebCore/khtml/xml/dom_elementimpl.cpp
@@ -362,6 +362,16 @@ void ElementImpl::createAttributeMap() const
     namedAttrMap->ref();
 }
 
+bool ElementImpl::isURLAttribute(AttributeImpl *attr) const
+{
+    return isSubresourceURLAttribute(attr);
+    
+}
+bool ElementImpl::isSubresourceURLAttribute(AttributeImpl *attr) const
+{
+    return false;
+}
+
 void ElementImpl::defaultEventHandler(EventImpl *evt)
 {
     if (evt->id() == EventImpl::KEYPRESS_EVENT && isContentEditable()) {
diff --git a/WebCore/khtml/xml/dom_elementimpl.h b/WebCore/khtml/xml/dom_elementimpl.h
index 00c1538..5447cf2 100644
--- a/WebCore/khtml/xml/dom_elementimpl.h
+++ b/WebCore/khtml/xml/dom_elementimpl.h
@@ -215,7 +215,10 @@ public:
     virtual DOMString toString() const;
 
     virtual void defaultEventHandler(EventImpl *evt);
-
+    
+    virtual bool isURLAttribute(AttributeImpl *attr) const;
+    virtual bool isSubresourceURLAttribute(AttributeImpl *attr) const;
+    
 #ifndef NDEBUG
     virtual void dump(QTextStream *stream, QString ind = "") const;
 #endif
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index 69b1e22..8d1a67c 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -30,7 +30,8 @@
 #include "xml/dom_textimpl.h"
 #include "xml/dom2_eventsimpl.h"
 #include "xml/dom_docimpl.h"
-#include "xml/dom_nodeimpl.h"
+#include "xml/dom2_rangeimpl.h"
+#include "css/csshelper.h"
 #include "css/cssstyleselector.h"
 
 #include <kglobal.h>
@@ -278,18 +279,19 @@ static QString escapeHTML( const QString& in )
     return s;
 }
 
-QString NodeImpl::recursive_toHTMLWithRange(bool start, const DOM::Range &range) const
+QString NodeImpl::recursive_toHTMLWithOptions(bool start, bool completeURLs, const DOM::RangeImpl *range, QStringList *subresourceURLs) const
 {	
 	QString me = "";
-		
-	NodeImpl *startContainer = range.startContainer().handle();
-	NodeImpl *endContainer = range.endContainer().handle();
+    
+    int exceptionCode;
+	NodeImpl *startContainer = range ? range->startContainer(exceptionCode) : NULL;
+	NodeImpl *endContainer = range ? range->endContainer(exceptionCode) : NULL;
 	NodeImpl *n = startContainer;
-	bool isNodeIncluded = false;
+	bool isNodeIncluded = range ? false : true;
 	Id ident = id();
 	
 	// Determine if the HTML string of this node should be part of the end result.
-	if (!start || (start && (ident == ID_TABLE || ident == ID_OL || ident == ID_UL))) {	
+	if (range && (!start || (start && (ident == ID_TABLE || ident == ID_OL || ident == ID_UL)))) {	
 		// Check if this node is in the range or is an ancestor of a node in the range.
 		while (n) {
 			NodeImpl *ancestor = n;
@@ -322,37 +324,50 @@ QString NodeImpl::recursive_toHTMLWithRange(bool start, const DOM::Range &range)
 		// Copy who I am into the me string
 		if (nodeType() == Node::TEXT_NODE) {
 			DOMString str = nodeValue().copy();
-			if (this == endContainer) {
-				str.truncate(range.endOffset());
-			}
-			if (this == startContainer) {
-				str.remove(0, range.startOffset());
-			}
+            if (range) {
+                if (this == endContainer) {
+                    str.truncate(range->endOffset(exceptionCode));
+                }
+                if (this == startContainer) {
+                    str.remove(0, range->startOffset(exceptionCode));
+                }
+            }
 			me += escapeHTML(str.string());
 		} else {
 			// If I am an element, not a text
 			me += QChar('<') + nodeName().string();
-			// print attributes
-			if (nodeType() == Node::ELEMENT_NODE) {
-				const ElementImpl *el = static_cast<const ElementImpl *>(this);
-				NamedNodeMap attrs = el->attributes();
-				unsigned long lmap = attrs.length();
-				for (unsigned int j=0; j<lmap; j++) {
-					me += " " + attrs.item(j).nodeName().string() + "=\"" + attrs.item(j).nodeValue().string() + "\"";
-				}
-			}
-			// print ending bracket of start tag
-			if (isHTMLElement()) {
-				me += ">";
-			} else {
-				me += "/>";
-			}
+            if (nodeType() == Node::ELEMENT_NODE) {
+                const ElementImpl *el = static_cast<const ElementImpl *>(this);
+                
+                NamedAttrMapImpl *attrs = el->attributes();
+                unsigned long length = attrs->length();
+                for (unsigned int i=0; i<length; i++) {
+                    AttributeImpl *attr = attrs->attributeItem(i);
+                    QString originalValue = attr->value().string();
+                    QString newValue = originalValue;
+                    if (completeURLs && el->isURLAttribute(attr)) {
+                        newValue = getDocument()->completeURL(khtml::parseURL(originalValue).string());
+                    }
+                    me += " " + getDocument()->attrName(attr->id()).string() + "=\"" + newValue + "\"";
+                    if (subresourceURLs && el->isSubresourceURLAttribute(attr)) {
+                        QString URL = getDocument()->completeURL(khtml::parseURL(originalValue).string());
+                        if (!subresourceURLs->contains(URL)) {
+                            subresourceURLs->append(URL);
+                        }
+                    }
+                }
+            }
+            if (isHTMLElement()) {
+                me += ">";
+            } else {
+                me += "/>";
+            }
 		}
 	}
 	
     if ((n = firstChild())) {
         // print firstChild
-        me += n->recursive_toHTMLWithRange(false, range);
+        me += n->recursive_toHTMLWithOptions(false, completeURLs, range, subresourceURLs);
         // Print my ending tag
         if (isNodeIncluded && nodeType() != Node::TEXT_NODE) {
 			me += "</" + nodeName().string() + ">";
@@ -360,80 +375,15 @@ QString NodeImpl::recursive_toHTMLWithRange(bool start, const DOM::Range &range)
     }
     // print next sibling
     if ((n = nextSibling())) {
-        me += n->recursive_toHTMLWithRange(false, range);
+        me += n->recursive_toHTMLWithOptions(false, completeURLs, range, subresourceURLs);
 	}
 	
     return me;
 }
 
-
 QString NodeImpl::recursive_toHTML(bool start) const
 {
-    QString me = "";
-
-    // Copy who I am into the htmlText string
-    if ( nodeType() == Node::TEXT_NODE )
-        me = escapeHTML( nodeValue().string() );
-    else
-    {
-        // If I am an element, not a text
-        NodeImpl* temp = previousSibling();
-        if(temp)
-        {
-            if( !start && (temp->nodeType() != Node::TEXT_NODE && nodeType() != Node::TEXT_NODE ) )
-                me = QString("    ") + QChar('<') + nodeName().string();
-            else
-                me = QChar('<') + nodeName().string();
-        }
-        else
-            me = QChar('<') + nodeName().string();
-        // print attributes
-        if( nodeType() == Node::ELEMENT_NODE )
-        {
-            const ElementImpl *el = static_cast<const ElementImpl *>(this);
-            NamedNodeMap attrs = el->attributes();
-            unsigned long lmap = attrs.length();
-            for( unsigned int j=0; j<lmap; j++ )
-                me += " " + attrs.item(j).nodeName().string() + "=\"" + attrs.item(j).nodeValue().string() + "\"";
-        }
-        // print ending bracket of start tag
-        if( firstChild() == 0 ) {    // if element has no endtag
-	    if (isHTMLElement()) {
-		me +=">";
-	    } else {
-                me +="/>";
-	    }
-	} else                        // if element has endtag
-        {
-                NodeImpl* temp = nextSibling();
-                if(temp)
-                {
-                    if( (temp->nodeType() != Node::TEXT_NODE) )
-                        me += ">\n";
-                    else
-                        me += ">";
-                }
-                else
-                    me += ">";
-        }
-    }
-
-    NodeImpl* n;
-
-    if( (n = firstChild()) )
-    {
-        // print firstChild
-        me += n->recursive_toHTML( );
-
-        // Print my ending tag
-        if ( nodeType() != Node::TEXT_NODE )
-            me += "</" + nodeName().string() + ">\n";
-    }
-    // print next sibling
-    if( (n = nextSibling()) )
-        me += n->recursive_toHTML( );
-
-    return me;
+    return recursive_toHTMLWithOptions(start);
 }
 
 bool NodeImpl::isContentEditable() const
diff --git a/WebCore/khtml/xml/dom_nodeimpl.h b/WebCore/khtml/xml/dom_nodeimpl.h
index b4050c5..f97bc04 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.h
+++ b/WebCore/khtml/xml/dom_nodeimpl.h
@@ -54,6 +54,7 @@ class NamedNodeMapImpl;
 class DocumentImpl;
 class CSSStyleDeclarationImpl;
 class Range;
+class RangeImpl;
 class RegisteredEventListener;
 class EventImpl;
 
@@ -242,7 +243,7 @@ public:
     virtual bool isInline() const;
     virtual QString toHTML() const;
     QString recursive_toHTML(bool start = false) const;
-	QString recursive_toHTMLWithRange(bool start, const DOM::Range &range) const;
+	QString recursive_toHTMLWithOptions(bool start=false, bool completeURLs=false, const DOM::RangeImpl *range=NULL, QStringList *subresourceURLs=NULL) const;
 
     virtual bool isContentEditable() const;
     virtual QRect getRect() const;
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 738a68e..61b69ce 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -209,11 +209,13 @@ typedef enum {
 - (void)pasteImageWithURL:(NSURL *)URL;
 
 - (void)deleteSelection;
-
 - (BOOL)haveSelection;
-- (NSString *)selectedHTML;
-- (NSString *)selectedString;
+
 - (NSAttributedString *)selectedAttributedString;
+- (NSString *)selectedHTMLString:(NSArray **)subresourceURLStrings;
+- (NSString *)selectedString;
+
+- (NSString *)HTMLString:(NSArray **)subresourceURLStrings;
 
 - (void)selectAll;
 - (void)deselectAll;
@@ -248,8 +250,6 @@ typedef enum {
 
 - (id)accessibilityTree;
 
-- (NSString *)reconstructedSource;
-
 - (void)undoEditing:(id)arg;
 - (void)redoEditing:(id)arg;
 
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 5b2e3cb..4928611 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -415,9 +415,40 @@ static bool initializedKJS = FALSE;
 	return _part->selection().state() == KHTMLSelection::RANGE;
 }
 
-- (NSString *)selectedHTML
+- (NSString *)selectedHTMLString:(NSArray **)subresourceURLStrings
 {
-	return _part->selection().toRange().toHTML().string().getNSString();
+    QStringList *subresourceURLs = NULL;
+    if (subresourceURLStrings) {
+        subresourceURLs = new QStringList();
+    }
+	NSString *HTMLString = _part->selection().toRange().handle()->toHTMLWithOptions(true, subresourceURLs).string().getNSString();
+    if (subresourceURLStrings) {
+        *subresourceURLStrings = [NSMutableArray array];
+        for (QStringList::Iterator it = subresourceURLs->begin(); it != subresourceURLs->end(); ++it) {
+            [(NSMutableArray *)*subresourceURLStrings addObject:(*it).getNSString()];
+        }
+    }
+    return HTMLString ? HTMLString : @"";
+}
+
+- (NSString *)HTMLString:(NSArray **)subresourceURLStrings
+{
+    QStringList *subresourceURLs = NULL;
+    if (subresourceURLStrings) {
+        subresourceURLs = new QStringList();
+    }
+    NSString *HTMLString = nil;
+    DOM::DocumentImpl *doc = _part->xmlDocImpl();
+    if (doc) {
+        HTMLString = doc->recursive_toHTMLWithOptions(true, false, NULL, subresourceURLs).getNSString();
+        if (subresourceURLStrings) {
+            *subresourceURLStrings = [NSMutableArray array];
+            for (QStringList::Iterator it = subresourceURLs->begin(); it != subresourceURLs->end(); ++it) {
+                [(NSMutableArray *)*subresourceURLStrings addObject:(*it).getNSString()];
+            }
+        }
+    }
+    return HTMLString ? HTMLString : @"";
 }
 
 - (NSString *)selectedString
@@ -584,7 +615,7 @@ static BOOL nowPrinting(WebCoreBridge *self)
     }
     NSObject *copiedNode = [copier nodeWithName:node->nodeName().string().getNSString()
                                           value:node->nodeValue().string().getNSString()
-                                         source:node->recursive_toHTML(1).getNSString()
+                                         source:node->recursive_toHTML(true).getNSString()
                                        children:children];
     [children release];
     return copiedNode;
@@ -1194,19 +1225,6 @@ static HTMLFormElementImpl *formElementFromDOMElement(id <WebDOMElement>element)
     return _part->xmlDocImpl()->getOrCreateAccObjectCache()->accObject(root);
 }
 
-- (NSString *)reconstructedSource
-{
-    NSString *string = nil;
-    DOM::DocumentImpl *doc = _part->xmlDocImpl();
-    if (doc) {
-        string = [[doc->recursive_toHTML(1).getNSString() copy] autorelease];
-    }
-    if (string == nil) {
-        string = @"";
-    }
-    return string;
-}
-
 - (void)undoEditing:(id)arg
 {
     _part->undoEditing();
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 7174602..1d7d8ab 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,15 @@
+2004-02-20  Chris Blumenberg  <cblu at apple.com>
+
+	Fixed: <rdar://problem/3563402>: when copying HTML, relative URLs should be made absolute
+
+        Reviewed by dave.
+
+        * WebView.subproj/WebHTMLRepresentation.h:
+        * WebView.subproj/WebHTMLRepresentation.m:
+        (-[WebHTMLRepresentation HTMLString]): renamed from reconstructed source to be more analogous with other data get methods
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView _writeSelectionToPasteboard:]): call renamed selectedHTML on the bridge
+
 2004-02-19  John Sullivan  <sullivan at apple.com>
 
         - WebKit part of fix for <rdar://problem/3292380>: Cycle Tabs keyboard shortcut 
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentation.h b/WebKit/WebView.subproj/WebHTMLRepresentation.h
index db1b7d6..2cbd267 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentation.h
+++ b/WebKit/WebView.subproj/WebHTMLRepresentation.h
@@ -59,6 +59,6 @@
 - (NSString *)searchForLabels:(NSArray *)labels beforeElement:(id <WebDOMElement>)element;
 - (NSString *)matchLabels:(NSArray *)labels againstElement:(id <WebDOMElement>)element;
 
-- (NSString *)reconstructedSource;
+- (NSString *)HTMLString;
 
 @end
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentation.m b/WebKit/WebView.subproj/WebHTMLRepresentation.m
index 3cc10b6..7d35d10 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentation.m
+++ b/WebKit/WebView.subproj/WebHTMLRepresentation.m
@@ -162,9 +162,9 @@
     return [_private->bridge matchLabels:labels againstElement:element];
 }
 
-- (NSString *)reconstructedSource
+- (NSString *)HTMLString
 {		
-	return [_private->bridge reconstructedSource];
+	return [_private->bridge HTMLString:nil];
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index f123850..685f929 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -518,8 +518,8 @@ static WebHTMLView *lastHitView = nil;
     [pasteboard declareTypes:[[self class] _pasteboardTypes] owner:nil];
 
     // Put HTML on the pasteboard.
-    [pasteboard setString:[[self _bridge] selectedHTML] forType:NSHTMLPboardType];
-
+    [pasteboard setString:[[self _bridge] selectedHTMLString:nil] forType:NSHTMLPboardType];
+    
     // Put attributed string on the pasteboard (RTF format).
     NSAttributedString *attributedString = [self selectedAttributedString];
     NSRange range = NSMakeRange(0, [attributedString length]);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list