[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:29:02 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit f07d4eec9175058b4802ee8c99840f8296704705
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Mar 9 23:46:28 2004 +0000
Tests:
Updated blot to use new SPI's.
* Blot/BlotApp.m:
(-[BlotApp handleNewMessageEvent:withReplyEvent:]):
* Blot/BlotDocument.h:
* Blot/BlotDocument.m:
(-[BlotDocument dataRepresentationOfType:]):
(-[BlotDocument loadWebArchive:]):
* TestPlugin/TestPlugin.pbproj/project.pbxproj:
WebCore:
Implemented WebCore side of: <rdar://problem/3577508>: API: web archive related API's
Reviewed by rjw.
* WebCore-combined.exp:
* WebCore.exp:
* kwq/DOM.mm:
(+[DOMRange _rangeWithImpl:]): made internally accessible
(-[DOMRange _rangeImpl]): ditto
* kwq/DOMInternal.h:
* kwq/KWQStringList.h:
* kwq/KWQStringList.mm:
(QStringList::getNSArray): new
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge pasteMarkupString:]): renamed from pasteHTMLString since XML pasting may be possible
(-[WebCoreBridge selectedRange]): new
(-[WebCoreBridge _documentTypeString]): new
(-[WebCoreBridge _stringWithDocumentTypeStringAndMarkupString:]): new
(-[WebCoreBridge markupStringFromNode:subresourceURLStrings:]): new, needed for WebKit API's
(-[WebCoreBridge markupStringFromRange:subresourceURLStrings:]): new, needed for WebKit API's
WebKit:
Fixed: <rdar://problem/3577508>: API: web archive related API's
Implemented WebKit side of: <rdar://problem/3144033>: ability to save web sites (images and all)
Reviewed by rjw.
* WebCoreSupport.subproj/WebBridge.h:
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge receivedData:textEncodingName:]): renamed to take a textEncodingName instead of data source. The data source argument is only needed for the textEncodingName.
* WebKit.exp:
* WebView.subproj/WebDataSource.m:
(-[WebDataSource _subresourcesDictionary]): new
(+[WebDataSource _repTypesAllowImageTypeOmission:]): include "application/x-webarchive"
* WebView.subproj/WebDataSourcePrivate.h:
* WebView.subproj/WebDocumentInternal.h:
* WebView.subproj/WebDocumentPrivate.h:
* WebView.subproj/WebFrame.m:
(-[WebFrame loadWebArchive:]): renamed, code factored out to [WebResource _parseWebArchive:mainResource:subresources:]
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFrameView.m:
(+[WebFrameView _viewTypesAllowImageTypeOmission:]): include "application/x-webarchive"
* WebView.subproj/WebHTMLRepresentation.h:
* WebView.subproj/WebHTMLRepresentation.m:
(-[WebHTMLRepresentationPrivate dealloc]):
(-[WebHTMLRepresentation _isDisplayingWebArchive]): new
(-[WebHTMLRepresentation receivedData:withDataSource:]): don't feed data to WebCore if we're displaying a web archive since web archive can't be progressively loaded
(-[WebHTMLRepresentation loadWebArchive]): new, feeds web archive data to WebCore
(-[WebHTMLRepresentation finishedLoadingWithDataSource:]): call loadWebArchive if necessary
(-[WebHTMLRepresentation documentSource]): if displaying a web archive, return the HTML source from within the archive
(-[WebHTMLRepresentation _webArchiveWithMarkupString:subresourceURLStrings:]): new
(-[WebHTMLRepresentation markupStringFromNode:]): implementation of new API
(-[WebHTMLRepresentation markupStringFromRange:]): ditto
(-[WebHTMLRepresentation webArchiveFromNode:]): ditto
(-[WebHTMLRepresentation webArchiveFromRange:]): ditto
* WebView.subproj/WebHTMLRepresentationPrivate.h:
* WebView.subproj/WebHTMLView.m:
(+[WebHTMLView _selectionPasteboardTypes]): use renamed WebArchivePboardType
(-[WebHTMLView _selectedWebArchive:]): renamed, call renamed methods
(-[WebHTMLView _writeSelectionToPasteboard:]): call renamed methods
(-[WebHTMLView _haveSelection]): indentation tweak
(-[WebHTMLView _canDelete]): ditto
(-[WebHTMLView _canPaste]): ditto
(-[WebHTMLView _pasteMarkupFromPasteboard:]): renamed, call [WebResource _webArchiveWithMainResource:subresources:]
(-[WebHTMLView initWithFrame:]): use renamed WebArchivePboardType
(-[WebHTMLView paste:]): call renamed _pasteMarkupFromPasteboard
(-[WebHTMLView concludeDragOperation:]): call renamed _pasteMarkupFromPasteboard
* WebView.subproj/WebHTMLViewPrivate.h:
* WebView.subproj/WebMainResourceClient.m:
(-[WebMainResourceClient connection:didReceiveResponse:]): modify the MIME type for web archives since Foundation is not yet web archive aware. This is ifdef'd pre-Tiger code.
* WebView.subproj/WebResource.h:
* WebView.subproj/WebResource.m:
(+[WebResource _parseWebArchive:mainResource:subresources:]): new
(+[WebResource _webArchiveWithMainResource:subresources:]): new
* WebView.subproj/WebResourcePrivate.h:
WebBrowser:
Fixed: <rdar://problem/3144033>: ability to save web sites (images and all)
Reviewed by john.
* BrowserDocument.h: added _dataSourceToSave, _fileFormatAccessoryView, _ fileFormatPopUpButton and _isSavingWithSavePanel ivars
* BrowserDocument.m:
(-[BrowserDocument dealloc]): added ASSERTs
(-[BrowserDocument dataSourceToSave]): new
(-[BrowserDocument canSaveAsWebArchive]): new
(-[BrowserDocument isSavingWebArchive]): new
(-[BrowserDocument MIMETypeForSaving]): take web archives into account
(-[BrowserDocument filenameForSaving]): new
(-[BrowserDocument isSavingPlainText]): moved
(-[BrowserDocument setDataSourceToSave:]): instead of this being a wrapper method around setFileWrapperToSave:MIMEType:, have this set _dataSourceToSave since we need the data source for web archives to work
(-[BrowserDocument saveDocumentTo:]): don't call setFileWrapperToSave:MIMEType: if there is no file wrapper since this case is handled in the above methods
(-[BrowserDocument document:didSave:contextInfo:]): added more post-save clean-up
(-[BrowserDocument allowedFileTypes]): new
(-[BrowserDocument fileFormatPopUpButtonUpdated:]): new
(-[BrowserDocument prepareSavePanel:]): attach an accessory view to the save panel if necessary
(-[BrowserDocument dataRepresentationOfType:]): handle all cases of saving data
(-[BrowserDocument displayName]): rely on the _isSavingWithSavePanel instead of _fileWrapperToSave for choosing a filename
(-[BrowserDocument _isDisplayingCompletePage]): new, factored out from validateUserInterfaceItem:
(-[BrowserDocument validateUserInterfaceItem:]): for mailPage:, makes sure the representation supports web archives
(-[BrowserDocument _mailWebArchive:withApplicationAtPath:]): mail a web archive instead of a property list
(-[BrowserDocument mailPage:]): handle the case where the current page is a web archive, call renamed _mailWebArchive::
(-[BrowserDocument mailPageAddress:]): call renamed _mailWebArchive::
* PreferenceKeys.h: added keys for the pref of saving a web archive or raw source
* WebBrowser.pbproj/project.pbxproj:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6191 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 01a4f81..090b5c6 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,27 @@
+2004-03-09 Chris Blumenberg <cblu at apple.com>
+
+ Implemented WebCore side of: <rdar://problem/3577508>: API: web archive related API's
+
+ Reviewed by rjw.
+
+ * WebCore-combined.exp:
+ * WebCore.exp:
+ * kwq/DOM.mm:
+ (+[DOMRange _rangeWithImpl:]): made internally accessible
+ (-[DOMRange _rangeImpl]): ditto
+ * kwq/DOMInternal.h:
+ * kwq/KWQStringList.h:
+ * kwq/KWQStringList.mm:
+ (QStringList::getNSArray): new
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge pasteMarkupString:]): renamed from pasteHTMLString since XML pasting may be possible
+ (-[WebCoreBridge selectedRange]): new
+ (-[WebCoreBridge _documentTypeString]): new
+ (-[WebCoreBridge _stringWithDocumentTypeStringAndMarkupString:]): new
+ (-[WebCoreBridge markupStringFromNode:subresourceURLStrings:]): new, needed for WebKit API's
+ (-[WebCoreBridge markupStringFromRange:subresourceURLStrings:]): new, needed for WebKit API's
+
2004-03-09 David Hyatt <hyatt at apple.com>
Make the AXLinkUIElements attribute always return an array (never return nil).
diff --git a/WebCore/WebCore-combined.exp b/WebCore/WebCore-combined.exp
index 1e1dbb9..d2707d8 100644
--- a/WebCore/WebCore-combined.exp
+++ b/WebCore/WebCore-combined.exp
@@ -1,3 +1,4 @@
+.objc_class_name_DOMRange
.objc_class_name_WebCoreBridge
.objc_class_name_WebCoreCache
.objc_class_name_WebCoreCookieAdapter
diff --git a/WebCore/WebCore.exp b/WebCore/WebCore.exp
index 3b346d3..b8fa376 100644
--- a/WebCore/WebCore.exp
+++ b/WebCore/WebCore.exp
@@ -1,3 +1,4 @@
+.objc_class_name_DOMRange
.objc_class_name_WebCoreBridge
.objc_class_name_WebCoreCache
.objc_class_name_WebCoreCookieAdapter
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index 6b02538..710b851 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -283,49 +283,49 @@ static QString escapeHTML( const QString& in )
QString NodeImpl::recursive_toHTMLWithOptions(bool start, bool completeURLs, const DOM::RangeImpl *range, QStringList *subresourceURLs) const
{
- QString me = "";
+ QString me = "";
int exceptionCode;
- NodeImpl *startContainer = range ? range->startContainer(exceptionCode) : NULL;
- NodeImpl *endContainer = range ? range->endContainer(exceptionCode) : NULL;
- NodeImpl *n = startContainer;
- bool isNodeIncluded = range ? false : true;
- Id ident = id();
-
- // Determine if the HTML string of this node should be part of the end result.
- 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;
- while (ancestor) {
- if (this == ancestor) {
- isNodeIncluded = true;
- break;
- }
- ancestor = ancestor->parentNode();
- }
- if (isNodeIncluded) {
- break;
- }
- if (n == endContainer) {
- break;
- }
- NodeImpl *next = n->firstChild();
- if (!next) {
- next = n->nextSibling();
- }
- while (!next && n->parentNode()) {
- n = n->parentNode();
- next = n->nextSibling();
- }
- n = next;
- }
- }
-
- if (isNodeIncluded) {
- // Copy who I am into the me string
- if (nodeType() == Node::TEXT_NODE) {
- DOMString str = nodeValue().copy();
+ NodeImpl *startContainer = range ? range->startContainer(exceptionCode) : NULL;
+ NodeImpl *endContainer = range ? range->endContainer(exceptionCode) : NULL;
+ NodeImpl *n = startContainer;
+ bool isNodeIncluded = range ? false : true;
+ Id ident = id();
+
+ // Determine if the HTML string of this node should be part of the end result.
+ 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;
+ while (ancestor) {
+ if (this == ancestor) {
+ isNodeIncluded = true;
+ break;
+ }
+ ancestor = ancestor->parentNode();
+ }
+ if (isNodeIncluded) {
+ break;
+ }
+ if (n == endContainer) {
+ break;
+ }
+ NodeImpl *next = n->firstChild();
+ if (!next) {
+ next = n->nextSibling();
+ }
+ while (!next && n->parentNode()) {
+ n = n->parentNode();
+ next = n->nextSibling();
+ }
+ n = next;
+ }
+ }
+
+ if (isNodeIncluded) {
+ // Copy who I am into the me string
+ if (nodeType() == Node::TEXT_NODE) {
+ DOMString str = nodeValue().copy();
if (range) {
if (this == endContainer) {
str.truncate(range->endOffset(exceptionCode));
@@ -336,9 +336,9 @@ QString NodeImpl::recursive_toHTMLWithOptions(bool start, bool completeURLs, con
}
Id parentID = parentNode()->id();
me += (parentID == ID_SCRIPT || parentID == ID_TEXTAREA) ? str.string() : escapeHTML(str.string());
- } else {
- // If I am an element, not a text
- me += QChar('<') + nodeName().string();
+ } else if (nodeType() != Node::DOCUMENT_NODE) {
+ // If I am an element, not a text
+ me += QChar('<') + nodeName().string();
if (nodeType() == Node::ELEMENT_NODE) {
const ElementImpl *el = static_cast<const ElementImpl *>(this);
@@ -361,9 +361,9 @@ QString NodeImpl::recursive_toHTMLWithOptions(bool start, bool completeURLs, con
}
}
me += isHTMLElement() ? ">" : "/>";
- }
- }
-
+ }
+ }
+
if (!isHTMLElement() || endTag[ident] != FORBIDDEN) {
// print firstChild
if ((n = firstChild())) {
@@ -371,14 +371,14 @@ QString NodeImpl::recursive_toHTMLWithOptions(bool start, bool completeURLs, con
}
// Print my ending tag
if (isNodeIncluded && nodeType() != Node::TEXT_NODE) {
- me += "</" + nodeName().string() + ">";
- }
+ me += "</" + nodeName().string() + ">";
+ }
}
// print next sibling
if ((n = nextSibling())) {
me += n->recursive_toHTMLWithOptions(false, completeURLs, range, subresourceURLs);
- }
-
+ }
+
return me;
}
diff --git a/WebCore/kwq/DOM.mm b/WebCore/kwq/DOM.mm
index 3a29825..259a485 100644
--- a/WebCore/kwq/DOM.mm
+++ b/WebCore/kwq/DOM.mm
@@ -96,10 +96,6 @@ using DOM::TextImpl;
- (id)_init;
@end
- at interface DOMRange (WebCoreInternal)
-+ (DOMRange *)_rangeWithImpl:(RangeImpl *)impl;
- at end
-
//------------------------------------------------------------------------------------------
// Static functions and data
@@ -1486,11 +1482,6 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
[super dealloc];
}
-- (RangeImpl *)_rangeImpl
-{
- return reinterpret_cast<RangeImpl *>(_internal);
-}
-
- (DOMNode *)startContainer
{
int code = 0;
@@ -1698,6 +1689,11 @@ inline Document DocumentImpl::createInstance(DocumentImpl *impl)
return [[[self alloc] _initWithRangeImpl:impl] autorelease];
}
+- (RangeImpl *)_rangeImpl
+{
+ return reinterpret_cast<RangeImpl *>(_internal);
+}
+
@end
//------------------------------------------------------------------------------------------
diff --git a/WebCore/kwq/DOMInternal.h b/WebCore/kwq/DOMInternal.h
index 2d98e71..01ed7a9 100644
--- a/WebCore/kwq/DOMInternal.h
+++ b/WebCore/kwq/DOMInternal.h
@@ -29,6 +29,7 @@ namespace DOM {
class DocumentImpl;
class ElementImpl;
class NodeImpl;
+ class RangeImpl;
}
@interface DOMNode (WebCoreInternal)
@@ -44,3 +45,8 @@ namespace DOM {
@interface DOMDocument (WebCoreInternal)
+ (DOMDocument *)_documentWithImpl:(DOM::DocumentImpl *)impl;
@end
+
+ at interface DOMRange (WebCoreInternal)
++ (DOMRange *)_rangeWithImpl:(DOM::RangeImpl *)impl;
+- (DOM::RangeImpl *)_rangeImpl;
+ at end
diff --git a/WebCore/kwq/KWQStringList.h b/WebCore/kwq/KWQStringList.h
index 43f277b..290d628 100644
--- a/WebCore/kwq/KWQStringList.h
+++ b/WebCore/kwq/KWQStringList.h
@@ -29,6 +29,12 @@
#include "KWQString.h"
#include "KWQValueList.h"
+#ifdef __OBJC__
+ at class NSArray;
+#else
+class NSArray;
+#endif
+
class QStringList : public QValueList<QString> {
public:
static QStringList split(const QString &, const QString &, bool allowEmptyEntries = false);
@@ -37,6 +43,8 @@ public:
QString join(const QString &) const;
QString pop_front();
+
+ NSArray *getNSArray();
};
#endif
diff --git a/WebCore/kwq/KWQStringList.mm b/WebCore/kwq/KWQStringList.mm
index f035e84..da49d76 100644
--- a/WebCore/kwq/KWQStringList.mm
+++ b/WebCore/kwq/KWQStringList.mm
@@ -83,3 +83,12 @@ QString QStringList::pop_front()
remove(begin());
return front;
}
+
+NSArray *QStringList::getNSArray()
+{
+ NSMutableArray *array = [NSMutableArray array];
+ for (QStringList::Iterator it = begin(); it != end(); ++it) {
+ [array addObject:(*it).getNSString()];
+ }
+ return array;
+}
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 300ddf8..30eb397 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -54,6 +54,7 @@ typedef khtml::RenderPart KHTMLRenderPart;
@class DOMDocument;
@class DOMNode;
@class DOMElement;
+ at class DOMRange;
@class WebCoreSettings;
@protocol WebCoreDOMTreeCopier;
@@ -205,17 +206,17 @@ typedef enum {
- (BOOL)isSelectionEditable;
- (BOOL)moveCaretToPoint:(NSPoint)point;
-- (void)pasteHTMLString:(NSString *)HTMLString;
+- (void)pasteMarkupString:(NSString *)markupString;
- (void)pasteImageWithURL:(NSURL *)URL;
- (void)deleteSelection;
- (BOOL)haveSelection;
- (NSAttributedString *)selectedAttributedString;
-- (NSString *)selectedHTMLString:(NSArray **)subresourceURLStrings;
- (NSString *)selectedString;
-- (NSString *)HTMLString:(NSArray **)subresourceURLStrings;
+- (NSString *)markupStringFromNode:(DOMNode *)node subresourceURLStrings:(NSArray **)subresourceURLStrings;
+- (NSString *)markupStringFromRange:(DOMRange *)range subresourceURLStrings:(NSArray **)subresourceURLStrings;
- (void)selectAll;
- (void)deselectAll;
@@ -229,6 +230,7 @@ typedef enum {
- (int)selectionStartOffset;
- (DOMNode *)selectionEnd;
- (int)selectionEndOffset;
+- (DOMRange *)selectedRange;
- (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index ec9767d..856f7eb 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -407,9 +407,9 @@ static bool initializedKJS = FALSE;
return YES;
}
-- (void)pasteHTMLString:(NSString *)HTMLString
+- (void)pasteMarkupString:(NSString *)markupString
{
- _part->pasteHTMLString(QString::fromNSString(HTMLString));
+ _part->pasteHTMLString(QString::fromNSString(markupString));
}
- (void)pasteImageWithURL:(NSURL *)URL
@@ -424,59 +424,65 @@ static bool initializedKJS = FALSE;
- (BOOL)haveSelection
{
- return _part->selection().state() == KHTMLSelection::RANGE;
+ return _part->selection().state() == KHTMLSelection::RANGE;
}
-- (NSString *)selectedHTMLString:(NSArray **)subresourceURLStrings
+- (DOMRange *)selectedRange
+{
+ return [DOMRange _rangeWithImpl:_part->selection().toRange().handle()];
+}
+
+- (NSString *)_documentTypeString
+{
+ NSString *documentTypeString = nil;
+ DOM::DocumentImpl *doc = _part->xmlDocImpl();
+ if (doc) {
+ DocumentTypeImpl *doctype = doc->doctype();
+ if (doctype) {
+ documentTypeString = doctype->toString().string().getNSString();
+ }
+ }
+ return documentTypeString;
+}
+
+- (NSString *)_stringWithDocumentTypeStringAndMarkupString:(NSString *)markupString
+{
+ NSString *documentTypeString = [self _documentTypeString];
+ if (documentTypeString && markupString) {
+ return [NSString stringWithFormat:@"%@\n%@", documentTypeString, markupString];
+ } else if (documentTypeString) {
+ return documentTypeString;
+ } else if (markupString) {
+ return markupString;
+ } else {
+ return @"";
+ }
+}
+
+- (NSString *)markupStringFromNode:(DOMNode *)node subresourceURLStrings:(NSArray **)subresourceURLStrings
{
QStringList *subresourceURLs = NULL;
if (subresourceURLStrings) {
subresourceURLs = new QStringList();
}
- NSString *HTMLString = _part->selection().toRange().handle()->toHTMLWithOptions(true, subresourceURLs).string().getNSString();
+ NSString *markupString = [node _nodeImpl]->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()];
- }
+ *subresourceURLStrings = subresourceURLs->getNSArray();
}
- return HTMLString ? HTMLString : @"";
+ return [self _stringWithDocumentTypeStringAndMarkupString:markupString];
}
-- (NSString *)HTMLString:(NSArray **)subresourceURLStrings
+- (NSString *)markupStringFromRange:(DOMRange *)range subresourceURLStrings:(NSArray **)subresourceURLStrings
{
QStringList *subresourceURLs = NULL;
if (subresourceURLStrings) {
subresourceURLs = new QStringList();
}
- NSString *docTypeString = nil;
- NSString *HTMLString = nil;
- DOM::DocumentImpl *doc = _part->xmlDocImpl();
- if (doc) {
- DocumentTypeImpl *doctype = doc->doctype();
- if (doctype) {
- docTypeString = doctype->toString().string().getNSString();
- }
- ElementImpl *documentElement = doc->documentElement();
- if (documentElement) {
- HTMLString = documentElement->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()];
- }
- }
- }
- }
- if (docTypeString && HTMLString) {
- return [NSString stringWithFormat:@"%@\n%@", docTypeString, HTMLString];
- } else if (docTypeString) {
- return docTypeString;
- } else if (HTMLString) {
- return HTMLString;
- } else {
- return @"";
+ NSString *markupString = [range _rangeImpl]->toHTMLWithOptions(false, subresourceURLs).string().getNSString();
+ if (subresourceURLStrings) {
+ *subresourceURLStrings = subresourceURLs->getNSArray();
}
+ return [self _stringWithDocumentTypeStringAndMarkupString:markupString];
}
- (NSString *)selectedString
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 26ebf6c..30f3410 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,59 @@
+2004-03-09 Chris Blumenberg <cblu at apple.com>
+
+ Fixed: <rdar://problem/3577508>: API: web archive related API's
+ Implemented WebKit side of: <rdar://problem/3144033>: ability to save web sites (images and all)
+
+ Reviewed by rjw.
+
+ * WebCoreSupport.subproj/WebBridge.h:
+ * WebCoreSupport.subproj/WebBridge.m:
+ (-[WebBridge receivedData:textEncodingName:]): renamed to take a textEncodingName instead of data source. The data source argument is only needed for the textEncodingName.
+ * WebKit.exp:
+ * WebView.subproj/WebDataSource.m:
+ (-[WebDataSource _subresourcesDictionary]): new
+ (+[WebDataSource _repTypesAllowImageTypeOmission:]): include "application/x-webarchive"
+ * WebView.subproj/WebDataSourcePrivate.h:
+ * WebView.subproj/WebDocumentInternal.h:
+ * WebView.subproj/WebDocumentPrivate.h:
+ * WebView.subproj/WebFrame.m:
+ (-[WebFrame loadWebArchive:]): renamed, code factored out to [WebResource _parseWebArchive:mainResource:subresources:]
+ * WebView.subproj/WebFramePrivate.h:
+ * WebView.subproj/WebFrameView.m:
+ (+[WebFrameView _viewTypesAllowImageTypeOmission:]): include "application/x-webarchive"
+ * WebView.subproj/WebHTMLRepresentation.h:
+ * WebView.subproj/WebHTMLRepresentation.m:
+ (-[WebHTMLRepresentationPrivate dealloc]):
+ (-[WebHTMLRepresentation _isDisplayingWebArchive]): new
+ (-[WebHTMLRepresentation receivedData:withDataSource:]): don't feed data to WebCore if we're displaying a web archive since web archive can't be progressively loaded
+ (-[WebHTMLRepresentation loadWebArchive]): new, feeds web archive data to WebCore
+ (-[WebHTMLRepresentation finishedLoadingWithDataSource:]): call loadWebArchive if necessary
+ (-[WebHTMLRepresentation documentSource]): if displaying a web archive, return the HTML source from within the archive
+ (-[WebHTMLRepresentation _webArchiveWithMarkupString:subresourceURLStrings:]): new
+ (-[WebHTMLRepresentation markupStringFromNode:]): implementation of new API
+ (-[WebHTMLRepresentation markupStringFromRange:]): ditto
+ (-[WebHTMLRepresentation webArchiveFromNode:]): ditto
+ (-[WebHTMLRepresentation webArchiveFromRange:]): ditto
+ * WebView.subproj/WebHTMLRepresentationPrivate.h:
+ * WebView.subproj/WebHTMLView.m:
+ (+[WebHTMLView _selectionPasteboardTypes]): use renamed WebArchivePboardType
+ (-[WebHTMLView _selectedWebArchive:]): renamed, call renamed methods
+ (-[WebHTMLView _writeSelectionToPasteboard:]): call renamed methods
+ (-[WebHTMLView _haveSelection]): indentation tweak
+ (-[WebHTMLView _canDelete]): ditto
+ (-[WebHTMLView _canPaste]): ditto
+ (-[WebHTMLView _pasteMarkupFromPasteboard:]): renamed, call [WebResource _webArchiveWithMainResource:subresources:]
+ (-[WebHTMLView initWithFrame:]): use renamed WebArchivePboardType
+ (-[WebHTMLView paste:]): call renamed _pasteMarkupFromPasteboard
+ (-[WebHTMLView concludeDragOperation:]): call renamed _pasteMarkupFromPasteboard
+ * WebView.subproj/WebHTMLViewPrivate.h:
+ * WebView.subproj/WebMainResourceClient.m:
+ (-[WebMainResourceClient connection:didReceiveResponse:]): modify the MIME type for web archives since Foundation is not yet web archive aware. This is ifdef'd pre-Tiger code.
+ * WebView.subproj/WebResource.h:
+ * WebView.subproj/WebResource.m:
+ (+[WebResource _parseWebArchive:mainResource:subresources:]): new
+ (+[WebResource _webArchiveWithMainResource:subresources:]): new
+ * WebView.subproj/WebResourcePrivate.h:
+
2004-03-09 John Sullivan <sullivan at apple.com>
- fixed the following bugs:
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.h b/WebKit/WebCoreSupport.subproj/WebBridge.h
index 1fdea47..6a085bf 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.h
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.h
@@ -24,7 +24,7 @@
- (id)initWithWebFrame:(WebFrame *)webFrame;
- (void)close;
-- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource;
+- (void)receivedData:(NSData *)data textEncodingName:(NSString *)textEncodingName;
- (void)runOpenPanelForFileButtonWithResultListener:(id <WebOpenPanelResultListener>)resultListener;
- (BOOL)inNextKeyViewOutsideWebFrameViews;
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index e453c7a..53987d7 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -351,15 +351,13 @@
[[wv _UIDelegateForwarder] webView:wv setStatusText:status];
}
-- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)withDataSource
+- (void)receivedData:(NSData *)data textEncodingName:(NSString *)textEncodingName
{
- ASSERT([self dataSource] == withDataSource);
-
// Set the encoding. This only needs to be done once, but it's harmless to do it again later.
- NSString *encoding = [withDataSource _overrideEncoding];
+ NSString *encoding = [[self dataSource] _overrideEncoding];
BOOL userChosen = encoding != nil;
if (encoding == nil) {
- encoding = [[withDataSource response] textEncodingName];
+ encoding = textEncodingName;
}
[self setEncoding:encoding userChosen:userChosen];
diff --git a/WebKit/WebKit.exp b/WebKit/WebKit.exp
index e80fd73..fb01712 100644
--- a/WebKit/WebKit.exp
+++ b/WebKit/WebKit.exp
@@ -51,7 +51,7 @@ _WebHistoryItemsRemovedNotification
_WebHistoryLoadedNotification
_WebHistorySavedNotification
_WebHistoryItemChangedNotification
-_WebHTMLPboardType
+_WebArchivePboardType
_WebIconDatabaseDidAddIconNotification
_WebIconDatabaseDirectoryDefaultsKey
_WebIconLargeSize
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index 094a600..b9fd507 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -101,44 +101,9 @@
}
}
-- (id)_propertyListWithData:(NSData *)data subresourceURLStrings:(NSArray *)subresourceURLStrings
-{
- NSMutableDictionary *propertyList = [NSMutableDictionary dictionary];
- WebResource *resource = [[WebResource alloc] initWithData:data
- URL:[_private->response URL]
- MIMEType:[_private->response MIMEType]
- textEncodingName:[self _isDocumentHTML] ? @"UTF-8" : [_private->response textEncodingName]];
- [propertyList setObject:[resource _propertyListRepresentation] forKey:WebMainResourceKey];
- [resource release];
-
- NSEnumerator *enumerator = [subresourceURLStrings objectEnumerator];
- NSMutableArray *subresources = [[NSMutableArray alloc] init];
- NSString *URLString;
- while ((URLString = [enumerator nextObject]) != nil) {
- resource = [_private->subresources objectForKey:URLString];
- if (resource) {
- [subresources addObject:[resource _propertyListRepresentation]];
- } else {
- ERROR("Failed to copy subresource because data source does not have subresource for %@", URLString);
- }
- }
-
- if ([subresources count] > 0) {
- [propertyList setObject:subresources forKey:WebSubresourcesKey];
- }
-
- [subresources release];
-
- return propertyList;
-}
-
-- (id)propertyList
+- (NSDictionary *)_subresourcesDictionary
{
- if ([self isLoading] || [_private->resourceData length] == 0) {
- return nil;
- }
- NSData *data = [self _isDocumentHTML] ? [[[self _bridge] HTMLString:nil] dataUsingEncoding:NSUTF8StringEncoding] : _private->resourceData;
- return [self _propertyListWithData:data subresourceURLStrings:[_private->subresources allKeys]];
+ return _private->subresources;
}
- (NSURL *)unreachableURL
@@ -577,6 +542,7 @@
[WebHTMLRepresentation class], @"text/xml",
[WebHTMLRepresentation class], @"application/xml",
[WebHTMLRepresentation class], @"application/xhtml+xml",
+ [WebHTMLRepresentation class], @"application/x-webarchive",
[WebTextRepresentation class], @"text/",
[WebTextRepresentation class], @"application/x-javascript",
nil];
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index eff79eb..3d95e64 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -120,13 +120,11 @@
- (WebResource *)subresourceForURL:(NSURL *)URL;
- (void)addSubresource:(WebResource *)subresource;
- (void)addSubresources:(NSArray *)subresources;
-- (id)propertyList;
- (NSURL *)unreachableURL;
+- (NSDictionary *)_subresourcesDictionary;
- (NSFileWrapper *)_fileWrapperForURL:(NSURL *)URL;
-- (id)_propertyListWithData:(NSData *)data subresourceURLStrings:(NSArray *)subresourceURLStrings;
-
- (NSError *)_mainDocumentError;
- (NSString *)_stringWithData:(NSData *)data;
- (void)_startLoading;
diff --git a/WebKit/WebView.subproj/WebDocumentInternal.h b/WebKit/WebView.subproj/WebDocumentInternal.h
index 20dcffd..e9e5542 100644
--- a/WebKit/WebView.subproj/WebDocumentInternal.h
+++ b/WebKit/WebView.subproj/WebDocumentInternal.h
@@ -3,7 +3,7 @@
Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
*/
-#import <Cocoa/Cocoa.h>
+#import <WebKit/WebDocumentPrivate.h>
/*!
@protocol _web_WebDocumentTextSizing
diff --git a/WebKit/WebView.subproj/WebDocumentPrivate.h b/WebKit/WebView.subproj/WebDocumentPrivate.h
index 12e571b..de517bd 100644
--- a/WebKit/WebView.subproj/WebDocumentPrivate.h
+++ b/WebKit/WebView.subproj/WebDocumentPrivate.h
@@ -3,7 +3,24 @@
Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
*/
+#import <WebKit/WebDocument.h>
- at protocol WebDocumentImage
+ at class DOMDocument;
+ at class DOMNode;
+ at class DOMRange;
+
+ at protocol WebDocumentImage <NSObject>
- (NSImage *)image;
+ at end
+
+ at protocol WebDocumentMarkup <NSObject>
+
+- (DOMDocument *)DOMDocument;
+
+- (NSString *)markupStringFromNode:(DOMNode *)node;
+- (NSString *)markupStringFromRange:(DOMRange *)range;
+
+- (NSData *)webArchiveFromNode:(DOMNode *)node;
+- (NSData *)webArchiveFromRange:(DOMRange *)range;
+
@end
\ No newline at end of file
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index 2fc195a..2ee4f57 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -262,23 +262,17 @@ NSString *WebPageCacheDocumentViewKey = @"WebPageCacheDocumentViewKey";
[self _loadHTMLString:string baseURL:URL unreachableURL:unreachableURL];
}
-- (void)loadPropertyList:(id)propertyList
-{
- if ([propertyList isKindOfClass:[NSDictionary class]]) {
- NSDictionary *resourcePropertyList = [propertyList objectForKey:WebMainResourceKey];
- if (resourcePropertyList) {
- WebResource *resource = [[WebResource alloc] _initWithPropertyList:resourcePropertyList];
- if (resource) {
- NSURLRequest *request = [self _webDataRequestForData:[resource data]
- MIMEType:[resource MIMEType]
- textEncodingName:[resource textEncodingName]
- baseURL:[resource URL]
- unreachableURL:nil];
- [resource release];
- NSArray *subresourcePropertyLists = [propertyList objectForKey:WebSubresourcesKey];
- [self _loadRequest:request subresources:subresourcePropertyLists ? [WebResource _resourcesFromPropertyLists:subresourcePropertyLists] : nil];
- }
- }
+- (void)loadWebArchive:(NSData *)webArchive
+{
+ WebResource *mainResource;
+ NSArray *subresources;
+ if ([WebResource _parseWebArchive:webArchive mainResource:&mainResource subresources:&subresources]) {
+ NSURLRequest *request = [self _webDataRequestForData:[mainResource data]
+ MIMEType:[mainResource MIMEType]
+ textEncodingName:[mainResource textEncodingName]
+ baseURL:[mainResource URL]
+ unreachableURL:nil];
+ [self _loadRequest:request subresources:subresources];
}
}
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 5aac0e4..c1366fa 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -117,7 +117,7 @@ extern NSString *WebPageCacheDocumentViewKey;
@interface WebFrame (WebPrivate)
// API Considerations:
-- (void)loadPropertyList:(id)HTMLPropertyList;
+- (void)loadWebArchive:(NSData *)webArchive;
// unreachableURL represents a URL that couldn't be loaded; the HTML string acts as an error page for that URL
- (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)URL forUnreachableURL:(NSURL *)unreachableURL;
diff --git a/WebKit/WebView.subproj/WebFrameView.m b/WebKit/WebView.subproj/WebFrameView.m
index 7036708..07dd024 100644
--- a/WebKit/WebView.subproj/WebFrameView.m
+++ b/WebKit/WebView.subproj/WebFrameView.m
@@ -284,6 +284,7 @@ static NSMutableDictionary *viewTypes;
[WebHTMLView class], @"text/xml",
[WebHTMLView class], @"application/xml",
[WebHTMLView class], @"application/xhtml+xml",
+ [WebHTMLView class], @"application/x-webarchive",
[WebTextView class], @"text/",
[WebTextView class], @"application/x-javascript",
nil];
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentation.h b/WebKit/WebView.subproj/WebHTMLRepresentation.h
index 28b33fe..6315f1e 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentation.h
+++ b/WebKit/WebView.subproj/WebHTMLRepresentation.h
@@ -5,31 +5,27 @@
#import <Foundation/Foundation.h>
+#import <WebKit/WebDocumentPrivate.h>
+
@class WebHTMLRepresentationPrivate;
@class NSView;
- at class DOMDocument;
@class DOMNode;
@class DOMElement;
+ at protocol WebDocumentMarkup;
@protocol WebDocumentRepresentation;
@protocol WebDocumentSourceRepresentation;
/*!
@class WebHTMLRepresentation
*/
- at interface WebHTMLRepresentation : NSObject <WebDocumentRepresentation>
+ at interface WebHTMLRepresentation : NSObject <WebDocumentRepresentation, WebDocumentMarkup>
{
WebHTMLRepresentationPrivate *_private;
}
/*!
- @method DOMDocument
- @abstract return the DOM document for this data source.
-*/
-- (DOMDocument *)DOMDocument;
-
-/*!
@method setSelectionFrom:startOffset:to:endOffset
@abstract Set the text selection in the document.
@param start The node that include the starting selection point.
@@ -39,15 +35,6 @@
*/
- (void)setSelectionFrom:(DOMNode *)start startOffset:(int)startOffset to:(DOMNode *)end endOffset:(int)endOffset;
-//- (NSAttributedString *)selectedAttributedString;
-
-/*!
- @method documentSource
- @abstract Get the current HTML reconstructed from the current state of the DOM.
-*/
-- (NSString *)reconstructedDocumentSource;
-
-
- (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset;
- (DOMElement *)elementWithName:(NSString *)name inForm:(DOMElement *)form;
@@ -60,6 +47,4 @@
- (NSString *)searchForLabels:(NSArray *)labels beforeElement:(DOMElement *)element;
- (NSString *)matchLabels:(NSArray *)labels againstElement:(DOMElement *)element;
-- (NSString *)HTMLString;
-
@end
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentation.m b/WebKit/WebView.subproj/WebHTMLRepresentation.m
index d64e9b6..e9f812c 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentation.m
+++ b/WebKit/WebView.subproj/WebHTMLRepresentation.m
@@ -6,11 +6,15 @@
#import <WebKit/WebHTMLRepresentation.h>
#import <WebKit/DOM.h>
-#import <WebKit/WebDataSourcePrivate.h>
+#import <WebKit/WebAssertions.h>
#import <WebKit/WebBridge.h>
-#import <WebKit/WebKitStatisticsPrivate.h>
+#import <WebKit/WebDataSourcePrivate.h>
+#import <WebKit/WebDocumentPrivate.h>
#import <WebKit/WebFramePrivate.h>
-#import <WebKit/WebDocument.h>
+#import <WebKit/WebKitStatisticsPrivate.h>
+#import <WebKit/WebResourcePrivate.h>
+
+#import <Foundation/NSString_NSURLExtras.h>
#import <Foundation/NSURLResponse.h>
@interface WebHTMLRepresentationPrivate : NSObject
@@ -18,10 +22,18 @@
@public
WebDataSource *dataSource;
WebBridge *bridge;
+ NSData *parsedWebArchiveData;
}
@end
@implementation WebHTMLRepresentationPrivate
+
+- (void)dealloc
+{
+ [parsedWebArchiveData release];
+ [super dealloc];
+}
+
@end
@implementation WebHTMLRepresentation
@@ -57,23 +69,57 @@
_private->bridge = [[dataSource webFrame] _bridge];
}
+- (BOOL)_isDisplayingWebArchive
+{
+ return [[[_private->dataSource response] MIMEType] _web_isCaseInsensitiveEqualToString:@"application/x-webarchive"];
+}
+
- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource
{
- if ([dataSource webFrame])
- [_private->bridge receivedData:data withDataSource:dataSource];
+ if ([dataSource webFrame] && ![self _isDisplayingWebArchive]) {
+ [_private->bridge receivedData:data textEncodingName:[[_private->dataSource response] textEncodingName]];
+ }
}
- (void)receivedError:(NSError *)error withDataSource:(WebDataSource *)dataSource
{
}
+- (void)loadWebArchive
+{
+ WebResource *mainResource;
+ NSArray *subresources;
+ if (![WebResource _parseWebArchive:[_private->dataSource data] mainResource:&mainResource subresources:&subresources]) {
+ return;
+ }
+
+ NSData *data = [mainResource data];
+ [data retain];
+ [_private->parsedWebArchiveData release];
+ _private->parsedWebArchiveData = data;
+
+ [_private->dataSource addSubresources:subresources];
+ [_private->bridge closeURL];
+ [_private->bridge openURL:[mainResource URL]
+ reload:NO
+ contentType:[mainResource MIMEType]
+ refresh:NO
+ lastModified:nil
+ pageCache:nil];
+ [_private->bridge receivedData:data textEncodingName:[mainResource textEncodingName]];
+}
+
- (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
{
- // Telling the bridge we received some data and passing nil as the data is our
- // way to get work done that is normally done when the first bit of data is
- // received, even for the case of a document with no data (like about:blank).
- if ([dataSource webFrame])
- [_private->bridge receivedData:nil withDataSource:dataSource];
+ if ([dataSource webFrame]) {
+ if ([self _isDisplayingWebArchive]) {
+ [self loadWebArchive];
+ }
+ // Telling the bridge we received some data and passing nil as the data is our
+ // way to get work done that is normally done when the first bit of data is
+ // received, even for the case of a document with no data (like about:blank).
+ [_private->bridge addData:nil];
+ }
}
- (BOOL)canProvideDocumentSource
@@ -83,7 +129,11 @@
- (NSString *)documentSource
{
- return [WebBridge stringWithData:[_private->dataSource data] textEncoding:[_private->bridge textEncoding]];
+ if ([self _isDisplayingWebArchive]) {
+ return [[[NSString alloc] initWithData:_private->parsedWebArchiveData encoding:NSUTF8StringEncoding] autorelease];
+ } else {
+ return [WebBridge stringWithData:[_private->dataSource data] textEncoding:[_private->bridge textEncoding]];
+ }
}
- (NSString *)title
@@ -100,12 +150,6 @@
{
}
-- (NSString *)reconstructedDocumentSource
-{
- // FIXME implement
- return @"";
-}
-
- (NSAttributedString *)attributedText
{
// FIXME: Implement
@@ -162,9 +206,56 @@
return [_private->bridge matchLabels:labels againstElement:element];
}
-- (NSString *)HTMLString
+- (NSData *)_webArchiveWithMarkupString:(NSString *)markupString subresourceURLStrings:(NSArray *)subresourceURLStrings
+{
+ NSURLResponse *response = [_private->dataSource response];
+ WebResource *mainResource = [[WebResource alloc] initWithData:[markupString dataUsingEncoding:NSUTF8StringEncoding]
+ URL:[response URL]
+ MIMEType:[response MIMEType]
+ textEncodingName:@"UTF-8"];
+
+ NSDictionary *subresourcesDictionary = [_private->dataSource _subresourcesDictionary];
+ NSEnumerator *enumerator = [subresourceURLStrings objectEnumerator];
+ NSMutableArray *subresources = [[NSMutableArray alloc] init];
+ NSString *URLString;
+ while ((URLString = [enumerator nextObject]) != nil) {
+ WebResource *subresource = [subresourcesDictionary objectForKey:URLString];
+ if (subresource) {
+ [subresources addObject:subresource];
+ } else {
+ ERROR("Failed to copy subresource because data source does not have subresource for %@", URLString);
+ }
+ }
+
+ NSData *webArchive = [WebResource _webArchiveWithMainResource:mainResource subresources:subresources];
+ [mainResource release];
+ [subresources release];
+
+ return webArchive;
+}
+
+- (NSString *)markupStringFromNode:(DOMNode *)node
+{
+ return [_private->bridge markupStringFromNode:node subresourceURLStrings:nil];
+}
+
+- (NSString *)markupStringFromRange:(DOMRange *)range
{
- return [_private->bridge HTMLString:nil];
+ return [_private->bridge markupStringFromRange:range subresourceURLStrings:nil];
+}
+
+- (NSData *)webArchiveFromNode:(DOMNode *)node
+{
+ NSArray *subresourceURLStrings;
+ NSString *markupString = [_private->bridge markupStringFromNode:node subresourceURLStrings:&subresourceURLStrings];
+ return [self _webArchiveWithMarkupString:markupString subresourceURLStrings:subresourceURLStrings];
+}
+
+- (NSData *)webArchiveFromRange:(DOMRange *)range
+{
+ NSArray *subresourceURLStrings;
+ NSString *markupString = [_private->bridge markupStringFromRange:range subresourceURLStrings:&subresourceURLStrings];
+ return [self _webArchiveWithMarkupString:markupString subresourceURLStrings:subresourceURLStrings];
}
@end
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h b/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h
index c4ff384..c86b21b 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h
@@ -10,4 +10,5 @@
@interface WebHTMLRepresentation (WebPrivate)
- (WebBridge *)_bridge;
- (void)printDOMTree;
+- (NSData *)_webArchiveWithMarkupString:(NSString *)markupString subresourceURLStrings:(NSArray *)subresourceURLStrings;
@end
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 97ff763..6ff6e49 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -15,6 +15,7 @@
#import <WebKit/WebFramePrivate.h>
#import <WebKit/WebFrameViewPrivate.h>
#import <WebKit/WebHTMLViewPrivate.h>
+#import <WebKit/WebHTMLRepresentationPrivate.h>
#import <WebKit/WebNetscapePluginEmbeddedView.h>
#import <WebKit/WebKitLogging.h>
#import <WebKit/WebNSPasteboardExtras.h>
@@ -516,15 +517,15 @@ static WebHTMLView *lastHitView = nil;
+ (NSArray *)_selectionPasteboardTypes
{
- return [NSArray arrayWithObjects:WebHTMLPboardType, NSHTMLPboardType, NSRTFPboardType, NSRTFDPboardType, NSStringPboardType, nil];
+ return [NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType, NSRTFPboardType, NSRTFDPboardType, NSStringPboardType, nil];
}
-- (id)_selectedPropertyList:(NSString **)HTMLString
+- (NSData *)_selectedWebArchive:(NSString **)markupString
{
NSArray *subresourceURLStrings;
- *HTMLString = [[self _bridge] selectedHTMLString:&subresourceURLStrings];
- return [[self _dataSource] _propertyListWithData:[*HTMLString dataUsingEncoding:NSUTF8StringEncoding]
- subresourceURLStrings:subresourceURLStrings];
+ WebHTMLRepresentation *rep = [[self _dataSource] representation];
+ *markupString = [[self _bridge] markupStringFromRange:[[self _bridge] selectedRange] subresourceURLStrings:&subresourceURLStrings];
+ return [rep _webArchiveWithMarkupString:*markupString subresourceURLStrings:subresourceURLStrings];
}
- (void)_writeSelectionToPasteboard:(NSPasteboard *)pasteboard
@@ -532,10 +533,10 @@ static WebHTMLView *lastHitView = nil;
[pasteboard declareTypes:[[self class] _selectionPasteboardTypes] owner:nil];
// Put HTML on the pasteboard.
- NSString *HTMLString;
- NSDictionary *HTMLPropertyList = [self _selectedPropertyList:&HTMLString];
- [pasteboard setString:HTMLString forType:NSHTMLPboardType];
- [pasteboard setPropertyList:HTMLPropertyList forType:WebHTMLPboardType];
+ NSString *markupString;
+ NSData *webArchive = [self _selectedWebArchive:&markupString];
+ [pasteboard setString:markupString forType:NSHTMLPboardType];
+ [pasteboard setData:webArchive forType:WebArchivePboardType];
// Put attributed string on the pasteboard (RTF format).
NSAttributedString *attributedString = [self selectedAttributedString];
@@ -552,49 +553,43 @@ static WebHTMLView *lastHitView = nil;
- (BOOL)_haveSelection
{
- return [[self _bridge] haveSelection];
+ return [[self _bridge] haveSelection];
}
- (BOOL)_canDelete
{
- return [self _haveSelection] && [[self _bridge] isSelectionEditable];
+ return [self _haveSelection] && [[self _bridge] isSelectionEditable];
}
- (BOOL)_canPaste
{
- return [[self _bridge] isSelectionEditable];
+ return [[self _bridge] isSelectionEditable];
}
-- (void)_pasteHTMLFromPasteboard:(NSPasteboard *)pasteboard
+- (void)_pasteMarkupFromPasteboard:(NSPasteboard *)pasteboard
{
- NSArray *types = [pasteboard types];
- NSString *HTMLString = nil;
+ NSArray *types = [pasteboard types];
+ NSString *markupString = nil;
- if ([types containsObject:WebHTMLPboardType]) {
- NSDictionary *HTMLPropertyList = [pasteboard propertyListForType:WebHTMLPboardType];
- if ([HTMLPropertyList isKindOfClass:[NSDictionary class]]) {
- NSDictionary *resourcePropertyList = [HTMLPropertyList objectForKey:WebMainResourceKey];
- WebResource *resource = [[WebResource alloc] _initWithPropertyList:resourcePropertyList];
- if (resource && [WebView canShowMIMETypeAsHTML:[resource MIMEType]]) {
- HTMLString = [[[NSString alloc] initWithData:[resource data] encoding:NSUTF8StringEncoding] autorelease];
- [resource release];
- NSArray *propertyLists = [HTMLPropertyList objectForKey:WebSubresourcesKey];
- if (propertyLists) {
- [[self _dataSource] addSubresources:[WebResource _resourcesFromPropertyLists:propertyLists]];
- }
- }
+ if ([types containsObject:WebArchivePboardType]) {
+ NSData *webArchive = [pasteboard dataForType:WebArchivePboardType];
+ WebResource *mainResource;
+ NSArray *subresources;
+ if ([WebResource _parseWebArchive:webArchive mainResource:&mainResource subresources:&subresources]) {
+ markupString = [[[NSString alloc] initWithData:[mainResource data] encoding:NSUTF8StringEncoding] autorelease];
+ [[self _dataSource] addSubresources:subresources];
}
}
- if (!HTMLString && [types containsObject:NSHTMLPboardType]) {
- HTMLString = [pasteboard stringForType:NSHTMLPboardType];
+ if (!markupString && [types containsObject:NSHTMLPboardType]) {
+ markupString = [pasteboard stringForType:NSHTMLPboardType];
}
- if (!HTMLString && [types containsObject:NSStringPboardType]) {
- HTMLString = [pasteboard stringForType:NSStringPboardType];
+ if (!markupString && [types containsObject:NSStringPboardType]) {
+ markupString = [pasteboard stringForType:NSStringPboardType];
+ }
+ if (markupString) {
+ [[self _bridge] pasteMarkupString:markupString];
}
- if (HTMLString) {
- [[self _bridge] pasteHTMLString:HTMLString];
- }
}
-(NSImage *)_dragImageForLinkElement:(NSDictionary *)element
@@ -946,7 +941,7 @@ static WebHTMLView *lastHitView = nil;
_private->pluginController = [[WebPluginController alloc] initWithHTMLView:self];
_private->needsLayout = YES;
- [self registerForDraggedTypes:[NSArray arrayWithObjects:WebHTMLPboardType, NSHTMLPboardType, NSStringPboardType, nil]];
+ [self registerForDraggedTypes:[NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType, NSStringPboardType, nil]];
return self;
}
@@ -989,7 +984,7 @@ static WebHTMLView *lastHitView = nil;
- (void)paste:(id)sender
{
- [self _pasteHTMLFromPasteboard:[NSPasteboard generalPasteboard]];
+ [self _pasteMarkupFromPasteboard:[NSPasteboard generalPasteboard]];
}
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
@@ -1652,7 +1647,7 @@ static WebHTMLView *lastHitView = nil;
{
if ([self _dragOperationForDraggingInfo:sender] != NSDragOperationNone) {
// FIXME: We should delete the original selection if we're doing a move.
- [self _pasteHTMLFromPasteboard:[sender draggingPasteboard]];
+ [self _pasteMarkupFromPasteboard:[sender draggingPasteboard]];
} else {
// Since we're not handling the drag, forward this message to the WebView since it may want to handle it.
[[self _webView] concludeDragOperation:sender];
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.h b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
index 9d38189..ccab175 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
@@ -75,7 +75,7 @@
- (BOOL)_canDelete;
- (BOOL)_canPaste;
- (BOOL)_haveSelection;
-- (void)_pasteHTMLFromPasteboard:(NSPasteboard *)pasteboard;
+- (void)_pasteMarkupFromPasteboard:(NSPasteboard *)pasteboard;
- (void)_frameOrBoundsChanged;
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index 016832a..4b721e3 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -7,7 +7,7 @@
#import <Foundation/NSHTTPCookie.h>
#import <Foundation/NSError_NSURLExtras.h>
-
+#import <Foundation/NSString_NSURLExtras.h>
#import <Foundation/NSURLFileTypeMappings.h>
#import <Foundation/NSURLConnection.h>
#import <Foundation/NSURLConnectionPrivate.h>
@@ -279,7 +279,17 @@
ASSERT(![[dataSource _webView] defersCallbacks]);
LOG(Loading, "main content type: %@", [r MIMEType]);
-
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3
+ NSURL *URL = [r URL];
+ if ([[[URL path] pathExtension] _web_isCaseInsensitiveEqualToString:@"webarchive"]) {
+ r = [[[NSURLResponse alloc] initWithURL:URL
+ MIMEType:@"application/x-webarchive"
+ expectedContentLength:[r expectedContentLength]
+ textEncodingName:[r textEncodingName]] autorelease];
+ }
+#endif
+
// retain/release self in this delegate method since the additional processing can do
// anything including possibly releasing self; one example of this is 3266216
[self retain];
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index 016832a..4b721e3 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -7,7 +7,7 @@
#import <Foundation/NSHTTPCookie.h>
#import <Foundation/NSError_NSURLExtras.h>
-
+#import <Foundation/NSString_NSURLExtras.h>
#import <Foundation/NSURLFileTypeMappings.h>
#import <Foundation/NSURLConnection.h>
#import <Foundation/NSURLConnectionPrivate.h>
@@ -279,7 +279,17 @@
ASSERT(![[dataSource _webView] defersCallbacks]);
LOG(Loading, "main content type: %@", [r MIMEType]);
-
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3
+ NSURL *URL = [r URL];
+ if ([[[URL path] pathExtension] _web_isCaseInsensitiveEqualToString:@"webarchive"]) {
+ r = [[[NSURLResponse alloc] initWithURL:URL
+ MIMEType:@"application/x-webarchive"
+ expectedContentLength:[r expectedContentLength]
+ textEncodingName:[r textEncodingName]] autorelease];
+ }
+#endif
+
// retain/release self in this delegate method since the additional processing can do
// anything including possibly releasing self; one example of this is 3266216
[self retain];
diff --git a/WebKit/WebView.subproj/WebResource.h b/WebKit/WebView.subproj/WebResource.h
index 0ca2dbe..711d7cd 100644
--- a/WebKit/WebView.subproj/WebResource.h
+++ b/WebKit/WebView.subproj/WebResource.h
@@ -9,7 +9,7 @@
@class WebResourcePrivate;
-extern NSString *WebHTMLPboardType;
+extern NSString *WebArchivePboardType;
@interface WebResource : NSObject
{
diff --git a/WebKit/WebView.subproj/WebResource.m b/WebKit/WebView.subproj/WebResource.m
index 210bca9..f748db5 100644
--- a/WebKit/WebView.subproj/WebResource.m
+++ b/WebKit/WebView.subproj/WebResource.m
@@ -9,7 +9,7 @@
#import <Foundation/NSDictionary_NSURLExtras.h>
#import <Foundation/NSURL_NSURLExtras.h>
-NSString *WebHTMLPboardType = @"Apple Web Kit pasteboard type";
+NSString *WebArchivePboardType = @"Apple Web Archive pasteboard type";
NSString *WebMainResourceKey = @"WebMainResource";
NSString *WebResourceDataKey = @"WebResourceData";
NSString *WebResourceMIMETypeKey = @"WebResourceMIMEType";
@@ -128,6 +128,36 @@ NSString *WebSubresourcesKey = @"WebSubresources";
return propertyLists;
}
++ (BOOL)_parseWebArchive:(NSData *)webArchive mainResource:(WebResource **)mainResource subresources:(NSArray **)subresources
+{
+ NSDictionary *propertyList = [NSPropertyListSerialization propertyListFromData:webArchive
+ mutabilityOption:NSPropertyListImmutable
+ format:nil
+ errorDescription:nil];
+ if ([propertyList isKindOfClass:[NSDictionary class]]) {
+ NSDictionary *resourcePropertyList = [propertyList objectForKey:WebMainResourceKey];
+ if (resourcePropertyList) {
+ *mainResource = [[[WebResource alloc] _initWithPropertyList:resourcePropertyList] autorelease];
+ if (*mainResource) {
+ *subresources = [WebResource _resourcesFromPropertyLists:[propertyList objectForKey:WebSubresourcesKey]];
+ return YES;
+ }
+ }
+ }
+ return NO;
+}
+
++ (NSData *)_webArchiveWithMainResource:(WebResource *)mainResource subresources:(NSArray *)subresources
+{
+ NSMutableDictionary *propertyList = [NSMutableDictionary dictionary];
+ [propertyList setObject:[mainResource _propertyListRepresentation] forKey:WebMainResourceKey];
+ NSArray *propertyLists = [self _propertyListsFromResources:subresources];
+ if ([propertyLists count] > 0) {
+ [propertyList setObject:propertyLists forKey:WebSubresourcesKey];
+ }
+ return [NSPropertyListSerialization dataFromPropertyList:propertyList format:NSPropertyListXMLFormat_v1_0 errorDescription:nil];
+}
+
- (id)_initWithPropertyList:(id)propertyList
{
if (![propertyList isKindOfClass:[NSDictionary class]]) {
diff --git a/WebKit/WebView.subproj/WebResourcePrivate.h b/WebKit/WebView.subproj/WebResourcePrivate.h
index 939e4f0..5135669 100644
--- a/WebKit/WebView.subproj/WebResourcePrivate.h
+++ b/WebKit/WebView.subproj/WebResourcePrivate.h
@@ -19,6 +19,9 @@ extern NSString *WebSubresourcesKey;
+ (NSArray *)_resourcesFromPropertyLists:(NSArray *)propertyLists;
+ (NSArray *)_propertyListsFromResources:(NSArray *)resources;
++ (BOOL)_parseWebArchive:(NSData *)webArchive mainResource:(WebResource **)mainResource subresources:(NSArray **)subresources;
++ (NSData *)_webArchiveWithMainResource:(WebResource *)mainResource subresources:(NSArray *)subresources;
+
- (id)_initWithPropertyList:(id)propertyList;
- (id)_initWithCachedResponse:(NSCachedURLResponse *)response originalURL:(NSURL *)originalURL;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list