[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:34:07 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 784ad4dd9b7b3ee31397467de9fe026c2c54f934
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Apr 12 20:46:13 2004 +0000

    WebCore:
    
    	- Fixed build failure by removing references to WebArchive in WebCore.
    	- For HTML copy/paste, relative URLs are now made absolute at paste time instead of at copy time. This allows relative URLs to be kept relative if the destination page has the same base URL as the source page.
    
            Reviewed by kocienda.
    
            * khtml/editing/htmlediting.cpp:
            (PasteMarkupCommand::PasteMarkupCommand): take the base URL of the clipping
            * khtml/editing/htmlediting.h:
            * khtml/editing/htmlediting_impl.cpp:
            (PasteMarkupCommandImpl::PasteMarkupCommandImpl): take the base URL of the clipping
            (PasteMarkupCommandImpl::doApply): if we have a base URL and it is different than the base URL of the document, fix the URLs in the new DOM tree
            * khtml/editing/htmlediting_impl.h:
            * khtml/xml/dom2_rangeimpl.cpp:
            (RangeImpl::toHTMLWithOptions): removed completeURLs param
            * khtml/xml/dom2_rangeimpl.h:
            * khtml/xml/dom_nodeimpl.cpp:
            (NodeImpl::recursive_toHTMLWithOptions): removed completeURLs param
            (NodeImpl::recursive_toHTML): ditto
            (NodeImpl::recursive_completeURLs): new
            * khtml/xml/dom_nodeimpl.h:
            * kwq/WebCoreBridge.h:
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge markupStringFromNode:subresourceURLStrings:]): call recursive_toHTML with less params
            (-[WebCoreBridge markupStringFromRange:subresourceURLStrings:]): ditto
            (-[WebCoreBridge replaceSelectionWithMarkupString:baseURLString:]): take a base URL
    
    WebKit:
    
    	Factored out WebArchive to DOM code so that it could be used by both [WebHTMLView _pasteFromPasteboard:] and [WebView insertWebArchive:replacingDOMRange:].
    
            Reviewed by kocienda.
    
            * WebView.subproj/WebDataSource.m:
            (-[WebDataSource _replaceSelectionWithMarkupString:baseURL:]): moved from WebHTMLView
            (-[WebDataSource _replaceSelectionWithImageResource:]): ditto
            (-[WebDataSource _replaceSelectionWithWebArchive:]): ditto
            * WebView.subproj/WebDataSourcePrivate.h:
            * WebView.subproj/WebHTMLView.m:
            (-[WebHTMLView _replaceSelectionWithMarkupString:]): renamed
            (-[WebHTMLView _pasteFromPasteboard:]): call renamed methods
            * WebView.subproj/WebView.m:
            (-[WebView insertMarkupString:replacingDOMRange:]): call renamed methods
            (-[WebView insertWebArchive:replacingDOMRange:]): have data source handle the archive instead of the bridge
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6353 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 23d20e6..32f82df 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,31 @@
+2004-04-12  Chris Blumenberg  <cblu at apple.com>
+
+	- Fixed build failure by removing references to WebArchive in WebCore.
+	- For HTML copy/paste, relative URLs are now made absolute at paste time instead of at copy time. This allows relative URLs to be kept relative if the destination page has the same base URL as the source page.
+
+        Reviewed by kocienda.
+
+        * khtml/editing/htmlediting.cpp:
+        (PasteMarkupCommand::PasteMarkupCommand): take the base URL of the clipping
+        * khtml/editing/htmlediting.h:
+        * khtml/editing/htmlediting_impl.cpp:
+        (PasteMarkupCommandImpl::PasteMarkupCommandImpl): take the base URL of the clipping
+        (PasteMarkupCommandImpl::doApply): if we have a base URL and it is different than the base URL of the document, fix the URLs in the new DOM tree
+        * khtml/editing/htmlediting_impl.h:
+        * khtml/xml/dom2_rangeimpl.cpp:
+        (RangeImpl::toHTMLWithOptions): removed completeURLs param
+        * khtml/xml/dom2_rangeimpl.h:
+        * khtml/xml/dom_nodeimpl.cpp:
+        (NodeImpl::recursive_toHTMLWithOptions): removed completeURLs param
+        (NodeImpl::recursive_toHTML): ditto
+        (NodeImpl::recursive_completeURLs): new
+        * khtml/xml/dom_nodeimpl.h:
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge markupStringFromNode:subresourceURLStrings:]): call recursive_toHTML with less params
+        (-[WebCoreBridge markupStringFromRange:subresourceURLStrings:]): ditto
+        (-[WebCoreBridge replaceSelectionWithMarkupString:baseURLString:]): take a base URL
+
 2004-04-12  Ken Kocienda  <kocienda at apple.com>
 
         Reviewed by Dave
diff --git a/WebCore/khtml/editing/htmlediting.cpp b/WebCore/khtml/editing/htmlediting.cpp
index bc6c59f..d3156a3 100644
--- a/WebCore/khtml/editing/htmlediting.cpp
+++ b/WebCore/khtml/editing/htmlediting.cpp
@@ -514,8 +514,8 @@ TextImpl *JoinTextNodesCommand::secondNode() const
 //------------------------------------------------------------------------------------------
 // PasteMarkupCommand
 
-PasteMarkupCommand::PasteMarkupCommand(DocumentImpl *document, const DOMString &markupString) 
-    : CompositeEditCommand(new PasteMarkupCommandImpl(document, markupString))
+PasteMarkupCommand::PasteMarkupCommand(DocumentImpl *document, const DOMString &markupString, const DOM::DOMString &baseURL) 
+    : CompositeEditCommand(new PasteMarkupCommandImpl(document, markupString, baseURL))
 {
 }
 
diff --git a/WebCore/khtml/editing/htmlediting.h b/WebCore/khtml/editing/htmlediting.h
index 3534756..cf158d1 100644
--- a/WebCore/khtml/editing/htmlediting.h
+++ b/WebCore/khtml/editing/htmlediting.h
@@ -321,7 +321,7 @@ private:
 class PasteMarkupCommand : public CompositeEditCommand
 {
 public:
-    PasteMarkupCommand(DOM::DocumentImpl *document, const DOM::DOMString &markupString);
+    PasteMarkupCommand(DOM::DocumentImpl *document, const DOM::DOMString &markupString, const DOM::DOMString &baseURL);
     virtual ~PasteMarkupCommand();
 
     DOM::DOMString markupString() const;
diff --git a/WebCore/khtml/editing/htmlediting_impl.cpp b/WebCore/khtml/editing/htmlediting_impl.cpp
index 3d2be27..29940a7 100644
--- a/WebCore/khtml/editing/htmlediting_impl.cpp
+++ b/WebCore/khtml/editing/htmlediting_impl.cpp
@@ -1418,8 +1418,8 @@ void JoinTextNodesCommandImpl::doUnapply()
 //------------------------------------------------------------------------------------------
 // PasteMarkupCommandImpl
 
-PasteMarkupCommandImpl::PasteMarkupCommandImpl(DocumentImpl *document, const DOMString &markupString) 
-    : CompositeEditCommandImpl(document), m_markupString(markupString)
+PasteMarkupCommandImpl::PasteMarkupCommandImpl(DocumentImpl *document, const DOMString &markupString, const DOM::DOMString &baseURL) 
+    : CompositeEditCommandImpl(document), m_markupString(markupString), m_baseURL(baseURL)
 {
     ASSERT(!m_markupString.isEmpty());
 }
@@ -1438,6 +1438,10 @@ void PasteMarkupCommandImpl::doApply()
     DocumentFragmentImpl *root = static_cast<HTMLElementImpl *>(document()->documentElement())->createContextualFragment(m_markupString);
     ASSERT(root);
     
+    if (!m_baseURL.isEmpty() && m_baseURL != document()->baseURL()) {
+        root->recursive_completeURLs(m_baseURL.string());
+    }
+    
     NodeImpl *firstChild = root->firstChild();
     NodeImpl *lastChild = root->lastChild();
     ASSERT(firstChild);
diff --git a/WebCore/khtml/editing/htmlediting_impl.h b/WebCore/khtml/editing/htmlediting_impl.h
index e152656..10bd78b 100644
--- a/WebCore/khtml/editing/htmlediting_impl.h
+++ b/WebCore/khtml/editing/htmlediting_impl.h
@@ -343,7 +343,7 @@ private:
 class PasteMarkupCommandImpl : public CompositeEditCommandImpl
 {
 public:
-    PasteMarkupCommandImpl(DOM::DocumentImpl *document, const DOM::DOMString &markupString);
+    PasteMarkupCommandImpl(DOM::DocumentImpl *document, const DOM::DOMString &markupString, const DOM::DOMString &baseURL);
     virtual ~PasteMarkupCommandImpl();
     
     virtual int commandID() const;
@@ -354,6 +354,7 @@ public:
 
 private:
     DOM::DOMString m_markupString;
+    DOM::DOMString m_baseURL;
 };
 
 //------------------------------------------------------------------------------------------
diff --git a/WebCore/khtml/xml/dom2_rangeimpl.cpp b/WebCore/khtml/xml/dom2_rangeimpl.cpp
index 57bc2e8..f39efef 100644
--- a/WebCore/khtml/xml/dom2_rangeimpl.cpp
+++ b/WebCore/khtml/xml/dom2_rangeimpl.cpp
@@ -843,31 +843,31 @@ DOMString RangeImpl::toString( int &exceptioncode )
     return text;
 }
 
-DOMString RangeImpl::toHTMLWithOptions(bool completeURLs, QStringList *subresourceURLs)
+DOMString RangeImpl::toHTMLWithOptions(QStringList *subresourceURLs)
 {
-	// Find the common containing block node of the start and end nodes.
-	RenderBlock *startBlock = m_startContainer->renderer()->containingBlock();
-	RenderBlock *endBlock = m_endContainer->renderer()->containingBlock();
-	NodeImpl *commonBlockNode = 0;
-	while (1) {
-		RenderBlock *newEndBlock = endBlock;
-		while (1) {
-			if (startBlock == newEndBlock) {
-				commonBlockNode = startBlock->element();
-				break;
-			}
-			if (newEndBlock->isRoot()) {
-				break;
-			}
-			newEndBlock = newEndBlock->containingBlock();
-		}
-		if (commonBlockNode) {
-			break;
-		}
-		startBlock = startBlock->containingBlock();
-	}
-	
-    return commonBlockNode->recursive_toHTMLWithOptions(true, completeURLs, this, subresourceURLs);
+    // Find the common containing block node of the start and end nodes.
+    RenderBlock *startBlock = m_startContainer->renderer()->containingBlock();
+    RenderBlock *endBlock = m_endContainer->renderer()->containingBlock();
+    NodeImpl *commonBlockNode = 0;
+    while (1) {
+        RenderBlock *newEndBlock = endBlock;
+        while (1) {
+            if (startBlock == newEndBlock) {
+                commonBlockNode = startBlock->element();
+                break;
+            }
+            if (newEndBlock->isRoot()) {
+                break;
+            }
+            newEndBlock = newEndBlock->containingBlock();
+        }
+        if (commonBlockNode) {
+            break;
+        }
+        startBlock = startBlock->containingBlock();
+    }
+    
+    return commonBlockNode->recursive_toHTMLWithOptions(true, this, subresourceURLs);
 }
 
 DOMString RangeImpl::toHTML(  )
diff --git a/WebCore/khtml/xml/dom2_rangeimpl.h b/WebCore/khtml/xml/dom2_rangeimpl.h
index 01a520b..07587c0 100644
--- a/WebCore/khtml/xml/dom2_rangeimpl.h
+++ b/WebCore/khtml/xml/dom2_rangeimpl.h
@@ -63,7 +63,7 @@ public:
     void insertNode( NodeImpl *newNode, int &exceptioncode );
     DOMString toString ( int &exceptioncode );
     DOMString toHTML (  );
-    DOMString toHTMLWithOptions(bool completeURLs=false, QStringList *subresourceURLs=NULL);
+    DOMString toHTMLWithOptions(QStringList *subresourceURLs=NULL);
 
     DocumentFragmentImpl *createContextualFragment ( DOMString &html, int &exceptioncode );
     
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index d849c73..05e04b0 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -283,7 +283,7 @@ static QString escapeHTML( const QString& in )
     return s;
 }
 
-QString NodeImpl::recursive_toHTMLWithOptions(bool start, bool completeURLs, const DOM::RangeImpl *range, QStringList *subresourceURLs) const
+QString NodeImpl::recursive_toHTMLWithOptions(bool start, const DOM::RangeImpl *range, QStringList *subresourceURLs) const
 {	
     QString me = "";
     
@@ -348,14 +348,10 @@ QString NodeImpl::recursive_toHTMLWithOptions(bool start, bool completeURLs, con
                 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 + "\"";
+                    DOMString value = attr->value();
+                    me += " " + getDocument()->attrName(attr->id()).string() + "=\"" + value.string() + "\"";
                     if (subresourceURLs && el->isSubresourceURLAttribute(attr)) {
-                        QString URL = getDocument()->completeURL(khtml::parseURL(originalValue).string());
+                        QString URL = getDocument()->completeURL(khtml::parseURL(value).string());
                         if (!subresourceURLs->contains(URL)) {
                             subresourceURLs->append(URL);
                         }
@@ -369,7 +365,7 @@ QString NodeImpl::recursive_toHTMLWithOptions(bool start, bool completeURLs, con
     if (!isHTMLElement() || endTag[ident] != FORBIDDEN) {
         // print firstChild
         if ((n = firstChild())) {
-            me += n->recursive_toHTMLWithOptions(false, completeURLs, range, subresourceURLs);
+            me += n->recursive_toHTMLWithOptions(false, range, subresourceURLs);
         }
         // Print my ending tag
         if (isNodeIncluded && nodeType() != Node::TEXT_NODE) {
@@ -378,7 +374,7 @@ QString NodeImpl::recursive_toHTMLWithOptions(bool start, bool completeURLs, con
     }
     // print next sibling
     if ((n = nextSibling())) {
-        me += n->recursive_toHTMLWithOptions(false, completeURLs, range, subresourceURLs);
+        me += n->recursive_toHTMLWithOptions(false, range, subresourceURLs);
     }
     
     return me;
@@ -389,6 +385,29 @@ QString NodeImpl::recursive_toHTML(bool start) const
     return recursive_toHTMLWithOptions(start);
 }
 
+void NodeImpl::recursive_completeURLs(QString baseURL)
+{
+    if (nodeType() == Node::ELEMENT_NODE) {
+        ElementImpl *el = static_cast<ElementImpl *>(this);
+        NamedAttrMapImpl *attrs = el->attributes();
+        unsigned long length = attrs->length();
+        for (unsigned int i=0; i<length; i++) {
+            AttributeImpl *attr = attrs->attributeItem(i);
+            if (el->isURLAttribute(attr)) {
+                el->setAttribute(attr->id(), KURL(baseURL, attr->value().string()).url());
+            }
+        }
+    }
+    
+    NodeImpl *n;
+    if ((n = firstChild())) {
+        n->recursive_completeURLs(baseURL);
+    }
+    if ((n = nextSibling())) {
+        n->recursive_completeURLs(baseURL);
+    }
+}
+
 bool NodeImpl::isContentEditable() const
 {
     return m_parent ? m_parent->isContentEditable() : false;
diff --git a/WebCore/khtml/xml/dom_nodeimpl.h b/WebCore/khtml/xml/dom_nodeimpl.h
index b4692fc..1b4774b 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.h
+++ b/WebCore/khtml/xml/dom_nodeimpl.h
@@ -251,8 +251,9 @@ public:
     virtual bool isInline() const;
     virtual QString toHTML() const;
     QString recursive_toHTML(bool start = false) const;
-	QString recursive_toHTMLWithOptions(bool start=false, bool completeURLs=false, const DOM::RangeImpl *range=NULL, QStringList *subresourceURLs=NULL) const;
-
+    QString recursive_toHTMLWithOptions(bool start=false, const DOM::RangeImpl *range=NULL, QStringList *subresourceURLs=NULL) const;
+    void recursive_completeURLs(QString baseURL);
+    
     virtual bool isContentEditable() const;
     virtual QRect getRect() const;
 
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 46c5ca6..81cd133 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -57,7 +57,6 @@ typedef khtml::RenderPart KHTMLRenderPart;
 @class DOMHTMLImageElement;
 @class DOMNode;
 @class DOMRange;
- at class WebArchive;
 @class WebCoreSettings;
 
 @protocol WebCoreDOMTreeCopier;
@@ -285,8 +284,7 @@ typedef enum {
 - (void)alterCurrentSelection:(WebSelectionAlteration)alteration direction:(WebSelectionDirection)direction granularity:(WebSelectionGranularity)granularity;
 - (void)replaceSelectionWithText:(NSString *)text;
 - (void)replaceSelectionWithNode:(DOMNode *)node;
-- (void)replaceSelectionWithMarkupString:(NSString *)markupString;
-- (void)replaceSelectionWithWebArchive:(WebArchive *)archive;
+- (void)replaceSelectionWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString;
 - (void)replaceSelectionWithNewline;
 - (void)deleteSelection;
 - (void)deleteKeyPressed;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index f3ddbad..870cc75 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -75,7 +75,6 @@
 #import "WebCoreSettings.h"
 
 #import <AppKit/NSView.h>
-#import <WebKit/WebArchive.h>
 
 using DOM::AtomicString;
 using DOM::DocumentImpl;
@@ -464,7 +463,7 @@ static bool initializedKJS = FALSE;
     if (subresourceURLStrings) {
         subresourceURLs = new QStringList();
     }
-    NSString *markupString = [node _nodeImpl]->recursive_toHTMLWithOptions(true, false, NULL, subresourceURLs).getNSString();
+    NSString *markupString = [node _nodeImpl]->recursive_toHTMLWithOptions(false, NULL, subresourceURLs).getNSString();
     if (subresourceURLStrings) {
         *subresourceURLStrings = subresourceURLs->getNSArray();
     }
@@ -477,7 +476,7 @@ static bool initializedKJS = FALSE;
     if (subresourceURLStrings) {
         subresourceURLs = new QStringList();
     }
-    NSString *markupString = [range _rangeImpl]->toHTMLWithOptions(false, subresourceURLs).string().getNSString();
+    NSString *markupString = [range _rangeImpl]->toHTMLWithOptions(subresourceURLs).string().getNSString();
     if (subresourceURLStrings) {
         *subresourceURLStrings = subresourceURLs->getNSArray();
     }
@@ -1367,20 +1366,15 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     TypingCommand::insertText(_part->xmlDocImpl(), s);
 }
 
-- (void)replaceSelectionWithMarkupString:(NSString *)markupString
+- (void)replaceSelectionWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString
 {
     if (!_part || !_part->xmlDocImpl() || !markupString)
         return;
     
-    PasteMarkupCommand cmd(_part->xmlDocImpl(), markupString);
+    PasteMarkupCommand cmd(_part->xmlDocImpl(), markupString, baseURLString);
     cmd.apply();
 }
 
-- (void)replaceSelectionWithWebArchive:(WebArchive *)archive
-{
-    ERROR("unimplemented");
-}
-
 - (void)replaceSelectionWithNewline
 {
     if (!_part || !_part->xmlDocImpl())
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index d150795..e850cec 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,21 @@
+2004-04-12  Chris Blumenberg  <cblu at apple.com>
+
+	Factored out WebArchive to DOM code so that it could be used by both [WebHTMLView _pasteFromPasteboard:] and [WebView insertWebArchive:replacingDOMRange:].
+
+        Reviewed by kocienda.
+
+        * WebView.subproj/WebDataSource.m:
+        (-[WebDataSource _replaceSelectionWithMarkupString:baseURL:]): moved from WebHTMLView
+        (-[WebDataSource _replaceSelectionWithImageResource:]): ditto
+        (-[WebDataSource _replaceSelectionWithWebArchive:]): ditto
+        * WebView.subproj/WebDataSourcePrivate.h:
+        * WebView.subproj/WebHTMLView.m:
+        (-[WebHTMLView _replaceSelectionWithMarkupString:]): renamed
+        (-[WebHTMLView _pasteFromPasteboard:]): call renamed methods
+        * WebView.subproj/WebView.m:
+        (-[WebView insertMarkupString:replacingDOMRange:]): call renamed methods
+        (-[WebView insertWebArchive:replacingDOMRange:]): have data source handle the archive instead of the bridge
+
 2004-04-12  Ken Kocienda  <kocienda at apple.com>
 
         Reviewed by Dave
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index be18bdc..da1300b 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -38,6 +38,7 @@
 #import <WebKit/WebHistoryItemPrivate.h>
 #import <WebKit/WebHTMLViewPrivate.h>
 #import <WebKit/WebTextRepresentation.h>
+#import <WebKit/WebImageRendererFactory.h>
 #import <WebKit/WebImageRepresentation.h>
 #import <WebKit/WebImageView.h>
 #import <Foundation/NSURLResponsePrivate.h>
@@ -152,6 +153,40 @@
     return webArchive;
 }
 
+- (void)_replaceSelectionWithMarkupString:(NSString *)markupString baseURL:(NSURL *)baseURL
+{
+    if ([markupString length] > 0) {
+        [[self _bridge] replaceSelectionWithMarkupString:markupString baseURLString:[baseURL _web_originalDataAsString]];
+    }
+}
+
+- (void)_replaceSelectionWithImageResource:(WebResource *)resource
+{
+    ASSERT(resource);
+    [self addSubresource:resource];
+    [self _replaceSelectionWithMarkupString:[NSString stringWithFormat:@"<IMG SRC=\"%@\">", [[resource URL] _web_originalDataAsString]] baseURL:nil];
+}
+
+- (BOOL)_replaceSelectionWithWebArchive:(WebArchive *)archive
+{
+    ASSERT(archive);
+    WebResource *mainResource = [archive mainResource];
+    if (mainResource) {
+        NSString *MIMEType = [mainResource MIMEType];
+        if ([WebView canShowMIMETypeAsHTML:MIMEType]) {
+            NSString *markupString = [[NSString alloc] initWithData:[mainResource data] encoding:NSUTF8StringEncoding];
+            [self addSubresources:[archive subresources]];
+            [self _replaceSelectionWithMarkupString:markupString baseURL:[mainResource URL]];
+            [markupString release];
+            return YES;
+        } else if ([[[WebImageRendererFactory sharedFactory] supportedMIMETypes] containsObject:MIMEType]) {
+            [self _replaceSelectionWithImageResource:mainResource];
+            return YES;
+        }
+    }
+    return NO;
+}
+
 - (WebView *)_webView
 {
     return _private->webView;
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index a8f57d0..91789a0 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -125,6 +125,9 @@
 // Other private methods
 - (NSFileWrapper *)_fileWrapperForURL:(NSURL *)URL;
 - (WebArchive *)_archiveWithMarkupString:(NSString *)markupString subresourceURLStrings:(NSArray *)subresourceURLStrings;
+- (void)_replaceSelectionWithMarkupString:(NSString *)markupString baseURL:(NSURL *)baseURL;
+- (BOOL)_replaceSelectionWithWebArchive:(WebArchive *)archive;
+- (void)_replaceSelectionWithImageResource:(WebResource *)resource;
 
 - (NSError *)_mainDocumentError;
 - (NSString *)_stringWithData:(NSData *)data;
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index d2a7a25..b52be11 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -19,7 +19,6 @@
 #import <WebKit/WebHTMLViewPrivate.h>
 #import <WebKit/WebHTMLRepresentationPrivate.h>
 #import <WebKit/WebImageRenderer.h>
-#import <WebKit/WebImageRendererFactory.h>
 #import <WebKit/WebKitLogging.h>
 #import <WebKit/WebKitNSStringExtras.h>
 #import <WebKit/WebNetscapePluginEmbeddedView.h>
@@ -579,18 +578,9 @@ static WebHTMLView *lastHitView = nil;
     return [[self _bridge] isSelectionEditable];
 }
 
-- (void)_pasteMarkupString:(NSString *)markupString
+- (void)_replaceSelectionWithMarkupString:(NSString *)markupString
 {
-    if ([markupString length] > 0) {
-        [[self _bridge] replaceSelectionWithMarkupString:markupString];
-    }
-}
-
-- (void)_pasteImageResource:(WebResource *)resource
-{
-    ASSERT(resource);
-    [[self _dataSource] addSubresource:resource];
-    [self _pasteMarkupString:[NSString stringWithFormat:@"<IMG SRC=\"%@\">", [[resource URL] _web_originalDataAsString]]];
+    [[self _dataSource] _replaceSelectionWithMarkupString:markupString baseURL:nil];
 }
 
 - (void)_pasteFromPasteboard:(NSPasteboard *)pasteboard
@@ -598,18 +588,11 @@ static WebHTMLView *lastHitView = nil;
     NSArray *types = [pasteboard types];
 
     if ([types containsObject:WebArchivePboardType]) {
-        WebArchive *archive = [[[WebArchive alloc] initWithData:[pasteboard dataForType:WebArchivePboardType]] autorelease];
-        WebResource *mainResource = [archive mainResource];
-        if (mainResource) {
-            NSString *MIMEType = [mainResource MIMEType];
-            if ([WebView canShowMIMETypeAsHTML:MIMEType]) {
-                NSString *markupString = [[NSString alloc] initWithData:[mainResource data] encoding:NSUTF8StringEncoding];
-                [[self _dataSource] addSubresources:[archive subresources]];
-                [self _pasteMarkupString:markupString];
-                [markupString release];
-                return;
-            } else if ([[[WebImageRendererFactory sharedFactory] supportedMIMETypes] containsObject:MIMEType]) {
-                [self _pasteImageResource:mainResource];
+        WebArchive *archive = [[WebArchive alloc] initWithData:[pasteboard dataForType:WebArchivePboardType]];
+        if (archive) {
+            BOOL didPaste = [[self _dataSource] _replaceSelectionWithWebArchive:archive];
+            [archive release];
+            if (didPaste) {
                 return;
             }
         }
@@ -618,37 +601,37 @@ static WebHTMLView *lastHitView = nil;
     NSURL *URL;
     
     if ([types containsObject:NSHTMLPboardType]) {
-        [self _pasteMarkupString:[pasteboard stringForType:NSHTMLPboardType]];
+        [self _replaceSelectionWithMarkupString:[pasteboard stringForType:NSHTMLPboardType]];
     } else if ([types containsObject:NSTIFFPboardType]) {
         WebResource *resource = [[WebResource alloc] initWithData:[pasteboard dataForType:NSTIFFPboardType]
                                                               URL:[NSURL _web_uniqueWebDataURLWithRelativeString:@"/image.tiff"]
                                                          MIMEType:@"image/tiff" 
                                                  textEncodingName:nil];
-        [self _pasteImageResource:resource];
+        [[self _dataSource] _replaceSelectionWithImageResource:resource];
         [resource release];
     } else if ([types containsObject:NSPICTPboardType]) {
         WebResource *resource = [[WebResource alloc] initWithData:[pasteboard dataForType:NSPICTPboardType]
                                                               URL:[NSURL _web_uniqueWebDataURLWithRelativeString:@"/image.pict"]
                                                          MIMEType:@"image/pict" 
                                                  textEncodingName:nil];
-        [self _pasteImageResource:resource];
+        [[self _dataSource] _replaceSelectionWithImageResource:resource];
         [resource release];
     } else if ((URL = [pasteboard _web_bestURL])) {
         NSString *URLString = [URL _web_originalDataAsString];
         NSString *linkLabel = [pasteboard stringForType:WebURLNamePboardType];
         linkLabel = [linkLabel length] > 0 ? linkLabel : URLString;
         NSString *markupString = [NSString stringWithFormat:@"<A HREF=\"%@\">%@</A>", URLString, linkLabel];
-        [self _pasteMarkupString:markupString];
+        [self _replaceSelectionWithMarkupString:markupString];
     } else if ([types containsObject:NSRTFDPboardType]) {
         // FIXME: Support RTFD to HTML (or DOM) conversion.
         ERROR("RTFD to HTML conversion not yet supported.");
-        [self _pasteMarkupString:[pasteboard stringForType:NSStringPboardType]]; 
+        [self _replaceSelectionWithMarkupString:[pasteboard stringForType:NSStringPboardType]]; 
     } else if ([types containsObject:NSRTFPboardType]) {
         // FIXME: Support RTF to HTML (or DOM) conversion.
         ERROR("RTF to HTML conversion not yet supported.");
-        [self _pasteMarkupString:[pasteboard stringForType:NSStringPboardType]];      
+        [self _replaceSelectionWithMarkupString:[pasteboard stringForType:NSStringPboardType]];      
     } else if ([types containsObject:NSStringPboardType]) {
-        [self _pasteMarkupString:[pasteboard stringForType:NSStringPboardType]];
+        [self _replaceSelectionWithMarkupString:[pasteboard stringForType:NSStringPboardType]];
     }
 }
 
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index a623b3f..068dbc0 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -2193,17 +2193,17 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
 
     WebBridge *bridge = [self _bridgeForCurrentSelection];
     [bridge setSelectedDOMRange:range];
-    [bridge replaceSelectionWithMarkupString:markupString];
+    [bridge replaceSelectionWithMarkupString:markupString baseURLString:nil];
 }
 
-- (void)insertWebArchive:(WebArchive *)webArchive replacingDOMRange:(DOMRange *)range
+- (void)insertWebArchive:(WebArchive *)archive replacingDOMRange:(DOMRange *)range
 {
     if (!range)
         return;
 
     WebBridge *bridge = [self _bridgeForCurrentSelection];
     [bridge setSelectedDOMRange:range];
-    [bridge replaceSelectionWithWebArchive:webArchive];
+    [[[bridge webFrame] dataSource] _replaceSelectionWithWebArchive:archive];
 }
 
 - (void)deleteDOMRange:(DOMRange *)range

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list