WebCore:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 May 2006 09:30:22 +0000 (09:30 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 May 2006 09:30:22 +0000 (09:30 +0000)
2006-05-16  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Maciej.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=8921
        Use WebCore to render full-frame images.

        * WebCore.xcodeproj/project.pbxproj:
        Add ImageDocument.

        * bridge/mac/WebCoreFrameBridge.h:
        Add mainResourceURLResponse and imageTitleForFilename.

        * bridge/mac/WebCoreFrameBridge.mm:
        (+[WebCoreFrameBridge supportedNonImageMIMETypes]):
        This used to be supportedMIMETypes but WebKit requires that we handle the
        image MIME types separately.

        (+[WebCoreFrameBridge supportedImageMIMETypes]):
        Add image types from WebCoreImageRendererFactory.

        (-[WebCoreFrameBridge canProvideDocumentSource]):
        Return no for image types.

        * dom/xml_tokenizer.h:
        (WebCore::Tokenizer::wantsRawData):
        (WebCore::Tokenizer::writeRawData):
        New virtual functions which tokenizers can override if they want to get
        raw data (which isn't fed through the decoder)

        * html/HTMLImageElement.h:
        (WebCore::HTMLImageElement::setLoadManually):
        New function which calls HTMLImageLoader::setLoadManually

        * html/HTMLImageLoader.cpp:
        (WebCore::HTMLImageLoader::HTMLImageLoader):
        (WebCore::HTMLImageLoader::updateFromElement):
        Don't request the image from the loader if the load is set to be manual.

        * html/HTMLImageLoader.h:
        (WebCore::HTMLImageLoader::setLoadManually):
        New function which decides if the image data should be fed manually or loaded
        by the loader.

        * loader/DocLoader.h:
        Add HTMLImageLoader as a friend.

        * loader/ImageDocument.cpp: Added.
        (WebCore::ImageTokenizer::ImageTokenizer):
        (WebCore::ImageTokenizer::wantsRawData):
        (WebCore::ImageTokenizer::write):
        (WebCore::ImageTokenizer::writeRawData):
        (WebCore::ImageTokenizer::stopParsing):
        (WebCore::ImageTokenizer::finish):
        (WebCore::ImageTokenizer::isWaitingForScripts):
        (WebCore::ImageDocument::ImageDocument):
        (WebCore::ImageDocument::createTokenizer):
        * loader/ImageDocument.h: Added.
        Add new ImageDocument class which will feed its data to a created image element.

        * loader/TextDocument.h:
        Inherit from HTMLDocument here too, in case any broken web pages want to manipulate
        the DOM of any plain text documents.

        * page/Frame.cpp:
        (WebCore::Frame::begin):
        (WebCore::Frame::write):
        Don't create or use the decoder if the tokenizer is in "raw mode".

WebKit:

2006-05-16  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Maciej.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=8921
        Use WebCore to render full-frame images

        * WebCoreSupport/WebFrameBridge.m:
        (-[WebFrameBridge determineObjectFromMIMEType:URL:]):
        Remove WebImageView handling.

        (-[WebFrameBridge mainResourceURLResponse]):
        New function which returns the URL response for the main resource. This is used by the
        manual loading of images.

        (-[WebFrameBridge imageTitleForFilename:size:]):
        New function which returns a correctly translated image title given a filename and a size.

        * WebCoreSupport/WebImageRenderer.m:
        (-[WebImageRenderer _startOrContinueAnimationIfNecessary]):
        Remove WebImageView handling.

        * WebKit.xcodeproj/project.pbxproj:
        Remove WebImageRepresentation and WebImageView.

        * WebView/WebArchiver.h:
        * WebView/WebArchiver.m:
        (+[WebArchiver archiveMainResourceForFrame:]):
        New functions which returns a WebArchive with just the main resource, ignoring any subresources.

        * WebView/WebDataSource.m:
        (+[WebDataSource _repTypesAllowImageTypeOmission:]):
        Use MIME types from WebHTMLRepresentation instead of WebImageRepresentation.

        * WebView/WebFrameView.m:
        (+[WebFrameView _viewTypesAllowImageTypeOmission:]):
        Use MIME types from WebHTMLRepresentation instead of WebImageRepresentation.

        (+[WebHTMLRepresentation supportedMIMETypes]):
        Create an array of image and non-image MIME Types.

        (+[WebHTMLRepresentation supportedNonImageMIMETypes]):
        (+[WebHTMLRepresentation supportedImageMIMETypes]):
        New functions, separating the list of MIME types into image and non-image ones.

        * WebView/WebHTMLView.m:
        (+[WebHTMLView supportedImageMIMETypes]):
        (+[WebHTMLView supportedNonImageMIMETypes]):
        New functions which call down to WebHTMLRepresentation.

        (-[WebHTMLView _startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]):
        If the image element comes from an ImageDocument, just use an archive of the main resource
        instead of the generated HTML document.

        * WebView/WebHTMLViewPrivate.h:
        Declare new functions.

        * WebView/WebImageRepresentation.h: Removed.
        * WebView/WebImageRepresentation.m: Removed.
        * WebView/WebImageView.h: Removed.
        * WebView/WebImageView.m: Removed.

LayoutTests:

2006-05-16  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Maciej.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=8921
        Use WebCore to render full-frame images.

        * css2.1/t0801-c412-hz-box-00-b-a-expected.txt:
        * dom/xhtml/level2/html/frame-expected.checksum:
        * dom/xhtml/level2/html/frame-expected.png:
        * dom/xhtml/level2/html/frame-expected.txt:
        * dom/xhtml/level2/html/iframe-expected.checksum:
        * dom/xhtml/level2/html/iframe-expected.png:
        * dom/xhtml/level2/html/iframe-expected.txt:
        * tables/mozilla/bugs/bug50695-2-expected.txt:
        Update tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14414 268f45cc-cd09-0410-ab3c-d52691b4dbfc

37 files changed:
LayoutTests/ChangeLog
LayoutTests/css2.1/t0801-c412-hz-box-00-b-a-expected.txt
LayoutTests/dom/xhtml/level2/html/frame-expected.checksum
LayoutTests/dom/xhtml/level2/html/frame-expected.png
LayoutTests/dom/xhtml/level2/html/frame-expected.txt
LayoutTests/dom/xhtml/level2/html/iframe-expected.checksum
LayoutTests/dom/xhtml/level2/html/iframe-expected.png
LayoutTests/dom/xhtml/level2/html/iframe-expected.txt
LayoutTests/tables/mozilla/bugs/bug50695-2-expected.txt
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/dom/xml_tokenizer.h
WebCore/html/HTMLImageElement.h
WebCore/html/HTMLImageLoader.cpp
WebCore/html/HTMLImageLoader.h
WebCore/loader/DocLoader.h
WebCore/loader/ImageDocument.cpp [new file with mode: 0644]
WebCore/loader/ImageDocument.h [new file with mode: 0644]
WebCore/page/Frame.cpp
WebKit/ChangeLog
WebKit/WebCoreSupport/WebFrameBridge.m
WebKit/WebCoreSupport/WebImageRenderer.m
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView/WebArchiver.h
WebKit/WebView/WebArchiver.m
WebKit/WebView/WebDataSource.m
WebKit/WebView/WebFrameView.m
WebKit/WebView/WebHTMLRepresentation.h
WebKit/WebView/WebHTMLRepresentation.m
WebKit/WebView/WebHTMLView.m
WebKit/WebView/WebHTMLViewPrivate.h
WebKit/WebView/WebImageRepresentation.h [deleted file]
WebKit/WebView/WebImageRepresentation.m [deleted file]
WebKit/WebView/WebImageView.h [deleted file]
WebKit/WebView/WebImageView.m [deleted file]

index 32251a3..6539047 100644 (file)
@@ -1,3 +1,20 @@
+2006-05-16  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8921
+        Use WebCore to render full-frame images.
+
+        * css2.1/t0801-c412-hz-box-00-b-a-expected.txt:
+        * dom/xhtml/level2/html/frame-expected.checksum:
+        * dom/xhtml/level2/html/frame-expected.png:
+        * dom/xhtml/level2/html/frame-expected.txt:
+        * dom/xhtml/level2/html/iframe-expected.checksum:
+        * dom/xhtml/level2/html/iframe-expected.png:
+        * dom/xhtml/level2/html/iframe-expected.txt:
+        * tables/mozilla/bugs/bug50695-2-expected.txt:
+        Update tests.
+
 2006-05-16  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by andersca.
index f730877..ac99485 100644 (file)
@@ -12,4 +12,10 @@ layer at (0,0) size 800x276
             text run at (80,0) width 360: "X X X X X"
         RenderBlock {P} at (0,56) size 784x154
           RenderPartObject {OBJECT} at (0,0) size 300x150
+            layer at (0,0) size 600x135
+              RenderCanvas at (0,0) size 300x135
+            layer at (0,0) size 600x44
+              RenderBlock {HTML} at (0,0) size 300x44
+                RenderBody {BODY} at (0,0) size 300x44
+                  RenderImage {IMG} at (0,0) size 600x40
           RenderText {#text} at (0,0) size 0x0
index 6319fa2..6a36187 100644 (file)
@@ -1 +1 @@
-b9450a3e59fe332228de2775caf02a6e
\ No newline at end of file
+98bb7e11c17ebf4f2b4a6e0ce246f8b4
\ No newline at end of file
index 9e2927c..df2a469 100644 (file)
Binary files a/LayoutTests/dom/xhtml/level2/html/frame-expected.png and b/LayoutTests/dom/xhtml/level2/html/frame-expected.png differ
index e485796..646ca95 100644 (file)
@@ -5,4 +5,16 @@ layer at (0,0) size 800x600
     RenderFrameSet {frameset} at (0,0) size 800x600
       RenderFrameSet {frameset} at (0,0) size 159x600
         RenderFrame {frame} at (0,0) size 159x198
+          layer at (0,0) size 157x194
+            RenderCanvas at (0,0) size 157x194
+          layer at (0,0) size 157x18
+            RenderBlock {HTML} at (0,0) size 157x18
+              RenderBody {BODY} at (0,0) size 157x18
+                RenderImage {IMG} at (0,3) size 17x11
       RenderFrame {frame} at (163,0) size 637x600
+        layer at (0,0) size 635x596
+          RenderCanvas at (0,0) size 635x596
+        layer at (0,0) size 635x52
+          RenderBlock {HTML} at (0,0) size 635x52
+            RenderBody {BODY} at (0,0) size 635x52
+              RenderImage {IMG} at (0,0) size 315x48
index c3245da..0a2fa0a 100644 (file)
@@ -1 +1 @@
-0e025222ec84509671c451a6111ff44e
\ No newline at end of file
+d22fe9e9c656b78abd845529b36dbd41
\ No newline at end of file
index 25c80d6..0486098 100644 (file)
Binary files a/LayoutTests/dom/xhtml/level2/html/iframe-expected.png and b/LayoutTests/dom/xhtml/level2/html/iframe-expected.png differ
index a4f0a7d..3045bdd 100644 (file)
@@ -4,4 +4,10 @@ layer at (0,0) size 800x66
   RenderBlock {html} at (0,0) size 800x66
     RenderBody {body} at (8,8) size 784x50
       RenderPartObject {iframe} at (0,0) size 60x50
+        layer at (0,0) size 58x46
+          RenderCanvas at (0,0) size 58x46
+        layer at (0,0) size 58x18
+          RenderBlock {HTML} at (0,0) size 58x18
+            RenderBody {BODY} at (0,0) size 58x18
+              RenderImage {IMG} at (0,3) size 17x11
       RenderText {#text} at (0,0) size 0x0
index 5437dc5..01f548b 100644 (file)
@@ -5,4 +5,10 @@ layer at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x576
       RenderBlock {FORM} at (0,0) size 784x300
         RenderPartObject {IFRAME} at (0,0) size 300x300
+          layer at (0,0) size 300x300
+            RenderCanvas at (0,0) size 300x300
+          layer at (0,0) size 300x174
+            RenderBlock {HTML} at (0,0) size 300x174
+              RenderBody {BODY} at (0,0) size 300x174
+                RenderImage {IMG} at (0,0) size 250x170
         RenderText {#text} at (0,0) size 0x0
index 8c1966a..65d5a6f 100644 (file)
@@ -1,3 +1,72 @@
+2006-05-16  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8921
+        Use WebCore to render full-frame images.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Add ImageDocument.
+        
+        * bridge/mac/WebCoreFrameBridge.h:
+        Add mainResourceURLResponse and imageTitleForFilename.
+        
+        * bridge/mac/WebCoreFrameBridge.mm:
+        (+[WebCoreFrameBridge supportedNonImageMIMETypes]):
+        This used to be supportedMIMETypes but WebKit requires that we handle the
+        image MIME types separately.
+        
+        (+[WebCoreFrameBridge supportedImageMIMETypes]):
+        Add image types from WebCoreImageRendererFactory.
+        
+        (-[WebCoreFrameBridge canProvideDocumentSource]):
+        Return no for image types.
+        
+        * dom/xml_tokenizer.h:
+        (WebCore::Tokenizer::wantsRawData):
+        (WebCore::Tokenizer::writeRawData):
+        New virtual functions which tokenizers can override if they want to get
+        raw data (which isn't fed through the decoder)
+        
+        * html/HTMLImageElement.h:
+        (WebCore::HTMLImageElement::setLoadManually):
+        New function which calls HTMLImageLoader::setLoadManually
+        
+        * html/HTMLImageLoader.cpp:
+        (WebCore::HTMLImageLoader::HTMLImageLoader):
+        (WebCore::HTMLImageLoader::updateFromElement):
+        Don't request the image from the loader if the load is set to be manual.
+        
+        * html/HTMLImageLoader.h:
+        (WebCore::HTMLImageLoader::setLoadManually):
+        New function which decides if the image data should be fed manually or loaded
+        by the loader.
+        
+        * loader/DocLoader.h:
+        Add HTMLImageLoader as a friend.
+        
+        * loader/ImageDocument.cpp: Added.
+        (WebCore::ImageTokenizer::ImageTokenizer):
+        (WebCore::ImageTokenizer::wantsRawData):
+        (WebCore::ImageTokenizer::write):
+        (WebCore::ImageTokenizer::writeRawData):
+        (WebCore::ImageTokenizer::stopParsing):
+        (WebCore::ImageTokenizer::finish):
+        (WebCore::ImageTokenizer::isWaitingForScripts):
+        (WebCore::ImageDocument::ImageDocument):
+        (WebCore::ImageDocument::createTokenizer):
+        * loader/ImageDocument.h: Added.
+        Add new ImageDocument class which will feed its data to a created image element.
+
+        * loader/TextDocument.h:
+        Inherit from HTMLDocument here too, in case any broken web pages want to manipulate
+        the DOM of any plain text documents.
+        
+        * page/Frame.cpp:
+        (WebCore::Frame::begin):
+        (WebCore::Frame::write):
+        Don't create or use the decoder if the tokenizer is in "raw mode".
+        
 2006-05-16  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by andersca.
index 57c4b2e..cc3b471 100644 (file)
                1A762C780A074F2600989F5B /* JSXPathNSResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A762C700A074F2600989F5B /* JSXPathNSResolver.h */; };
                1A762C790A074F2600989F5B /* JSXPathResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A762C710A074F2600989F5B /* JSXPathResult.cpp */; };
                1A762C7A0A074F2600989F5B /* JSXPathResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A762C720A074F2600989F5B /* JSXPathResult.h */; };
+               1A820D910A13EBA600AF843C /* ImageDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A820D8F0A13EBA600AF843C /* ImageDocument.cpp */; settings = {COMPILER_FLAGS = "-xobjective-c++"; }; };
+               1A820D920A13EBA600AF843C /* ImageDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A820D900A13EBA600AF843C /* ImageDocument.h */; };
                550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
                550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; };
                550A0BCD085F604D007353D6 /* HTMLNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BCB085F604D007353D6 /* HTMLNames.cpp */; };
                1A762C700A074F2600989F5B /* JSXPathNSResolver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXPathNSResolver.h; sourceTree = "<group>"; };
                1A762C710A074F2600989F5B /* JSXPathResult.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSXPathResult.cpp; sourceTree = "<group>"; };
                1A762C720A074F2600989F5B /* JSXPathResult.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXPathResult.h; sourceTree = "<group>"; };
+               1A820D8F0A13EBA600AF843C /* ImageDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDocument.cpp; sourceTree = "<group>"; };
+               1A820D900A13EBA600AF843C /* ImageDocument.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ImageDocument.h; sourceTree = "<group>"; };
                2D90660B0665D937006B6F1A /* ClipboardMac.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ClipboardMac.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                2D90660C0665D937006B6F1A /* ClipboardMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ClipboardMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                4758C44308C5F217009BAF05 /* KCanvasPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasPath.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                                BCB16C110979C3BD00467741 /* DocLoader.h */,
                                93ABCE5D06E1A42E0085925B /* FormData.cpp */,
                                93ABCE5E06E1A42E0085925B /* FormData.h */,
+                               1A820D8F0A13EBA600AF843C /* ImageDocument.cpp */,
+                               1A820D900A13EBA600AF843C /* ImageDocument.h */,
                                BCB16C130979C3BD00467741 /* loader.cpp */,
                                BCB16C140979C3BD00467741 /* loader.h */,
                                BCB16C150979C3BD00467741 /* Request.cpp */,
                                1A494BFB0A122F4400FDAFC1 /* JSHTMLElement.h in Headers */,
                                1A494E350A12358B00FDAFC1 /* JSHTMLDocument.h in Headers */,
                                1A494EDF0A123F4C00FDAFC1 /* JSDocumentFragment.h in Headers */,
+                               1A820D920A13EBA600AF843C /* ImageDocument.h in Headers */,
                                A871DB250A150BD600B12A68 /* HTMLTableSectionElement.h in Headers */,
                                A871DB270A150BD600B12A68 /* HTMLTableElement.h in Headers */,
                                A871DB2A0A150BD600B12A68 /* HTMLTableCellElement.h in Headers */,
                                1A494BFA0A122F4400FDAFC1 /* JSHTMLElement.cpp in Sources */,
                                1A494E340A12358B00FDAFC1 /* JSHTMLDocument.cpp in Sources */,
                                1A494EDE0A123F4C00FDAFC1 /* JSDocumentFragment.cpp in Sources */,
+                               1A820D910A13EBA600AF843C /* ImageDocument.cpp in Sources */,
                                A871DB260A150BD600B12A68 /* HTMLTableSectionElement.cpp in Sources */,
                                A871DB280A150BD600B12A68 /* HTMLTableElement.cpp in Sources */,
                                A871DB290A150BD600B12A68 /* HTMLTableColElement.cpp in Sources */,
index 34deaa7..82e4e57 100644 (file)
@@ -186,7 +186,8 @@ typedef enum {
 - (id)initMainFrameWithPage:(WebCorePageBridge *)page;
 - (id)initSubframeWithRenderer:(WebCoreRenderPart *)renderer;
 
-+ (NSArray *)supportedMIMETypes;
++ (NSArray *)supportedNonImageMIMETypes;
++ (NSArray *)supportedImageMIMETypes;
 
 - (void)initializeSettings:(WebCoreSettings *)settings;
 
@@ -664,6 +665,9 @@ typedef enum {
 
 - (WebCoreKeyboardUIMode)keyboardUIMode;
 
+- (NSURLResponse*)mainResourceURLResponse;
+- (NSString*)imageTitleForFilename:(NSString*)filename size:(NSSize)size;
+
 @end
 
 // This interface definition allows those who hold a WebCoreFrameBridge * to call all the methods
index 5b98b6f..275da1b 100644 (file)
@@ -48,6 +48,7 @@
 #import "FrameMac.h"
 #import "Page.h"
 #import "SelectionController.h"
+#import "WebCoreImageRendererFactory.h"
 #import "WebCorePageBridge.h"
 #import "WebCoreSettings.h"
 #import "WebCoreViewFactory.h"
@@ -57,6 +58,7 @@
 #import "HTMLDocument.h"
 #import "htmlediting.h"
 #import "HTMLNames.h"
+#import "Image.h"
 #import "kjs_proxy.h"
 #import "kjs_window.h"
 #import "markup.h"
@@ -360,9 +362,9 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     return bridge(m_frame->tree()->find(name));
 }
 
-+ (NSArray *)supportedMIMETypes
++ (NSArray *)supportedNonImageMIMETypes
 {
-    return [NSArray arrayWithObjects:
+    return [NSArray arrayWithObjects:        
         @"text/html",
         @"text/xml",
         @"text/xsl",
@@ -380,6 +382,17 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
         nil];
 }
 
++ (NSArray *)supportedImageMIMETypes
+{
+    static NSMutableArray *mimeTypes = nil;
+    if (mimeTypes == nil) {
+        mimeTypes = [[[WebCoreImageRendererFactory sharedFactory] supportedMIMETypes] mutableCopy];
+        [mimeTypes removeObject:@"application/pdf"];
+        [mimeTypes removeObject:@"application/postscript"];
+    }
+    return mimeTypes;
+}
+
 + (WebCoreFrameBridge *)bridgeForDOMDocument:(DOMDocument *)document
 {
     return bridge([document _document]->frame());
@@ -2461,7 +2474,8 @@ static NSCharacterSet *_getPostSmartSet(void)
 {
     String mimeType = m_frame->resourceRequest().m_responseMIMEType;
     
-    if (WebCore::DOMImplementation::isTextMIMEType(mimeType))
+    if (WebCore::DOMImplementation::isTextMIMEType(mimeType) ||
+        Image::supportsType(mimeType))
         return NO;
     
     return YES;
index ed9f309..8454a1d 100644 (file)
@@ -53,6 +53,9 @@ public:
     virtual bool processingData() const { return false; }
     virtual int executingScript() const { return 0; }
 
+    virtual bool wantsRawData() const { return false; }
+    virtual bool writeRawData(const char* data, int len) { return false; }
+    
 protected:
     // The tokenizer has buffers, so parsing may continue even after
     // it stops receiving data. We use m_parserStopped to stop the tokenizer
index e744efc..4950171 100644 (file)
@@ -64,6 +64,8 @@ public:
 
     CachedImage* cachedImage() const { return m_imageLoader.image(); }
     
+    void setLoadManually (bool loadManually) { m_imageLoader.setLoadManually(loadManually); }
+
     String name() const;
     void setName(const String&);
 
index 9b0d4be..d4e39ad 100644 (file)
@@ -44,6 +44,7 @@ HTMLImageLoader::HTMLImageLoader(Element* elt)
     , m_image(0)
     , m_firedLoad(true)
     , m_imageComplete(true)
+    , m_loadManually(false)
 {
 }
 
@@ -74,9 +75,14 @@ void HTMLImageLoader::updateFromElement()
     
     // Treat a lack of src or empty string for src as no image at all.
     CachedImage *newImage = 0;
-    if (!attr.isEmpty())
-        newImage = doc->docLoader()->requestImage(parseURL(attr));
-
+    if (!attr.isEmpty()) {
+        if (m_loadManually) {
+            newImage = new CachedImage(doc->docLoader(), parseURL(attr), KIO::CC_Verify, 0);
+            doc->docLoader()->m_docObjects.set(newImage->url(), newImage);
+        } else
+            newImage = doc->docLoader()->requestImage(parseURL(attr));
+    }
+    
     CachedImage *oldImage = m_image;
     if (newImage != oldImage) {
 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
index efb81b7..215d2cd 100644 (file)
@@ -44,6 +44,8 @@ public:
     bool imageComplete() const { return m_imageComplete; }
     CachedImage* image() const { return m_image; }
 
+    void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
+
     // CachedObjectClient API
     virtual void notifyFinished(CachedObject*);
 
@@ -55,6 +57,7 @@ private:
     CachedImage* m_image;
     bool m_firedLoad : 1;
     bool m_imageComplete : 1;
+    bool m_loadManually : 1;
 };
 
 } //namespace
index 79f5d73..18a9d86 100644 (file)
@@ -45,7 +45,8 @@ namespace WebCore {
     class CachedXSLStyleSheet;
     class Document;
     class Frame;
-
+    class HTMLImageLoader;
+    
     /**
      * Manages the loading of scripts/images/stylesheets for a particular document
      */
@@ -88,6 +89,7 @@ namespace WebCore {
 
         friend class Cache;
         friend class WebCore::Document;
+        friend class WebCore::HTMLImageLoader;
 
         DeprecatedStringList m_reloadedURLs;
         mutable HashMap<String, CachedObject*> m_docObjects;
diff --git a/WebCore/loader/ImageDocument.cpp b/WebCore/loader/ImageDocument.cpp
new file mode 100644 (file)
index 0000000..8de61b0
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#include "ImageDocument.h"
+
+#include "CachedImage.h"
+#include "Element.h"
+#include "HTMLNames.h"
+#include "SegmentedString.h"
+#include "Text.h"
+#include "HTMLImageElement.h"
+#include "xml_tokenizer.h"
+
+#ifdef __APPLE__
+#include <Cocoa/Cocoa.h>
+#include "FrameMac.h"
+#include "WebCoreFrameBridge.h"
+#endif 
+
+namespace WebCore {
+    
+using namespace HTMLNames;
+    
+class ImageTokenizer : public Tokenizer {
+public:
+    ImageTokenizer(Document* doc) : m_doc(doc), m_imageElement(0) {}
+        
+    virtual bool write(const SegmentedString&, bool appendData);
+    virtual void stopParsing();
+    virtual void finish();
+    virtual bool isWaitingForScripts() const;
+    
+    virtual bool wantsRawData() const { return true; }
+    virtual bool writeRawData(const char *data, int len);
+
+    void createDocumentStructure();
+private:
+    Document* m_doc;
+    HTMLImageElement* m_imageElement;
+    DeprecatedByteArray m_buffer;
+};
+    
+bool ImageTokenizer::write(const SegmentedString& s, bool appendData)
+{
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
+void ImageTokenizer::createDocumentStructure()
+{
+    ExceptionCode ec;
+    
+    RefPtr<Element> rootElement = m_doc->createElementNS(xhtmlNamespaceURI, "html", ec);
+    m_doc->appendChild(rootElement, ec);
+    
+    RefPtr<Element> body = m_doc->createElementNS(xhtmlNamespaceURI, "body", ec);
+    body->setAttribute(styleAttr, "margin: 0px;");
+    
+    rootElement->appendChild(body, ec);
+    
+    RefPtr<Element> imageElement = m_doc->createElementNS(xhtmlNamespaceURI, "img", ec);
+    
+    m_imageElement = static_cast<HTMLImageElement *>(imageElement.get());
+    m_imageElement->setAttribute(styleAttr, "-webkit-user-select: none");        
+    m_imageElement->setLoadManually(true);
+    m_imageElement->setSrc(m_doc->URL());
+    
+    body->appendChild(imageElement, ec);    
+}
+
+bool ImageTokenizer::writeRawData(const char *data, int len)
+{
+    if (!m_imageElement)
+        createDocumentStructure();
+
+    unsigned oldSize = m_buffer.size();
+    m_buffer.resize(oldSize + len);
+    memcpy(m_buffer.data() + oldSize, data, len);
+
+    m_imageElement->cachedImage()->data(m_buffer, false);
+
+    return false;
+}
+
+void ImageTokenizer::stopParsing()
+{
+    Tokenizer::stopParsing();
+   
+    m_imageElement->cachedImage()->error();
+}
+
+void ImageTokenizer::finish()
+{
+    if (!m_parserStopped) {
+        m_imageElement->cachedImage()->data(m_buffer, true);
+
+        // FIXME: For platforms other than Mac OS X, the title needs to be set in this function
+        
+#ifdef __APPLE__
+        WebCoreFrameBridge *bridge = Mac(m_doc->frame())->bridge();
+        NSURLResponse *response = [bridge mainResourceURLResponse];
+        NSData *data = [NSData dataWithBytes:m_buffer.data() length:m_buffer.size()];
+        m_imageElement->cachedImage()->setAllData([data retain]);
+        m_imageElement->cachedImage()->setResponse(response);
+
+        if (m_imageElement->cachedImage()->imageSize().width() > 0) {
+            NSSize size = NSMakeSize(m_imageElement->cachedImage()->imageSize().width(), 
+                                     m_imageElement->cachedImage()->imageSize().height());
+            m_doc->setTitle([bridge imageTitleForFilename:[response suggestedFilename]
+                                                     size:size]);
+        }
+    }
+#endif
+
+    m_doc->finishedParsing();    
+    
+}
+    
+bool ImageTokenizer::isWaitingForScripts() const
+{
+    // An image document is never waiting for scripts
+    return false;
+}
+    
+ImageDocument::ImageDocument(DOMImplementation *_implementation, FrameView *v)
+    : HTMLDocument(_implementation, v)
+{
+}
+    
+Tokenizer* ImageDocument::createTokenizer()
+{
+    return new ImageTokenizer(this);
+}
+    
+}
diff --git a/WebCore/loader/ImageDocument.h b/WebCore/loader/ImageDocument.h
new file mode 100644 (file)
index 0000000..544e578
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+#ifndef ImageDocument_h
+#define ImageDocument_h
+
+#include "HTMLDocument.h"
+
+namespace WebCore {
+    
+class DOMImplementation;
+class FrameView;
+    
+class ImageDocument : public HTMLDocument
+{
+public:
+    ImageDocument(DOMImplementation*, FrameView* = 0);
+
+    virtual Tokenizer* createTokenizer();
+};
+    
+}
+
+#endif // ImageDocument_h
index b5a42be..2bbf6de 100644 (file)
@@ -50,6 +50,7 @@
 #include "HTMLGenericFormElement.h"
 #include "HTMLNames.h"
 #include "HTMLObjectElement.h"
+#include "ImageDocument.h"
 #include "MouseEventWithHitTestResults.h"
 #include "NodeList.h"
 #include "Plugin.h"
@@ -600,7 +601,9 @@ void Frame::begin(const KURL& url)
   if (DOMImplementation::isXMLMIMEType(d->m_request.m_responseMIMEType))
     d->m_doc = DOMImplementation::instance()->createDocument(d->m_view.get());
   else if (DOMImplementation::isTextMIMEType(d->m_request.m_responseMIMEType))
-    d->m_doc = DOMImplementation::instance()->createTextDocument(d->m_view.get());
+    d->m_doc = new TextDocument(DOMImplementation::instance(), d->m_view.get());
+ else if (Image::supportsType(d->m_request.m_responseMIMEType))
+    d->m_doc = new ImageDocument(DOMImplementation::instance(), d->m_view.get());
   else
     d->m_doc = DOMImplementation::instance()->createHTMLDocument(d->m_view.get());
 
@@ -631,6 +634,19 @@ void Frame::begin(const KURL& url)
 
 void Frame::write(const char* str, int len)
 {
+    if (len == 0)
+        return;
+    
+    if (len == -1)
+        len = strlen(str);
+
+    if (Tokenizer* t = d->m_doc->tokenizer()) {
+        if (t->wantsRawData()) {
+            t->writeRawData(str, len);
+            return;
+        }
+    }
+    
     if (!d->m_decoder) {
         d->m_decoder = new Decoder;
         if (!d->m_encoding.isNull())
@@ -642,12 +658,6 @@ void Frame::write(const char* str, int len)
         if (d->m_doc)
             d->m_doc->setDecoder(d->m_decoder.get());
     }
-  if (len == 0)
-    return;
-
-  if (len == -1)
-    len = strlen(str);
-
   DeprecatedString decoded = d->m_decoder->decode(str, len);
 
   if (decoded.isEmpty())
@@ -663,8 +673,10 @@ void Frame::write(const char* str, int len)
       d->m_doc->recalcStyle(Node::Force);
   }
 
-  if (Tokenizer* t = d->m_doc->tokenizer())
+  if (Tokenizer* t = d->m_doc->tokenizer()) {
+      ASSERT(!t->wantsRawData());
       t->write(decoded, true);
+  }
 }
 
 void Frame::write(const DeprecatedString& str)
index 2c6c066..e93a6d3 100644 (file)
@@ -1,3 +1,65 @@
+2006-05-16  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=8921
+        Use WebCore to render full-frame images
+        
+        * WebCoreSupport/WebFrameBridge.m:
+        (-[WebFrameBridge determineObjectFromMIMEType:URL:]):
+        Remove WebImageView handling.
+        
+        (-[WebFrameBridge mainResourceURLResponse]):
+        New function which returns the URL response for the main resource. This is used by the
+        manual loading of images.
+        
+        (-[WebFrameBridge imageTitleForFilename:size:]):
+        New function which returns a correctly translated image title given a filename and a size.
+        
+        * WebCoreSupport/WebImageRenderer.m:
+        (-[WebImageRenderer _startOrContinueAnimationIfNecessary]):
+        Remove WebImageView handling.
+        
+        * WebKit.xcodeproj/project.pbxproj:
+        Remove WebImageRepresentation and WebImageView.
+        
+        * WebView/WebArchiver.h:
+        * WebView/WebArchiver.m:
+        (+[WebArchiver archiveMainResourceForFrame:]):
+        New functions which returns a WebArchive with just the main resource, ignoring any subresources.
+        
+        * WebView/WebDataSource.m:
+        (+[WebDataSource _repTypesAllowImageTypeOmission:]):
+        Use MIME types from WebHTMLRepresentation instead of WebImageRepresentation.
+        
+        * WebView/WebFrameView.m:
+        (+[WebFrameView _viewTypesAllowImageTypeOmission:]):
+        Use MIME types from WebHTMLRepresentation instead of WebImageRepresentation.
+        
+        (+[WebHTMLRepresentation supportedMIMETypes]):
+        Create an array of image and non-image MIME Types.
+        
+        (+[WebHTMLRepresentation supportedNonImageMIMETypes]):
+        (+[WebHTMLRepresentation supportedImageMIMETypes]):
+        New functions, separating the list of MIME types into image and non-image ones.
+        
+        * WebView/WebHTMLView.m:
+        (+[WebHTMLView supportedImageMIMETypes]):
+        (+[WebHTMLView supportedNonImageMIMETypes]):
+        New functions which call down to WebHTMLRepresentation.
+        
+        (-[WebHTMLView _startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]):
+        If the image element comes from an ImageDocument, just use an archive of the main resource
+        instead of the generated HTML document.
+        
+        * WebView/WebHTMLViewPrivate.h:
+        Declare new functions.
+        
+        * WebView/WebImageRepresentation.h: Removed.
+        * WebView/WebImageRepresentation.m: Removed.
+        * WebView/WebImageView.h: Removed.
+        * WebView/WebImageView.m: Removed.
+        
 2006-05-15  Tim Omernick  <timo@apple.com>
 
         Reviewed by John Sullivan.
index d39d421..9202e87 100644 (file)
@@ -43,7 +43,6 @@
 #import "WebHTMLRepresentationPrivate.h"
 #import "WebHTMLViewInternal.h"
 #import "WebHistoryItemPrivate.h"
-#import "WebImageView.h"
 #import "WebJavaPlugIn.h"
 #import "WebJavaScriptTextInputPanel.h"
 #import "WebKitErrorsPrivate.h"
@@ -1133,9 +1132,6 @@ static BOOL loggedObjectCacheSize = NO;
             return ObjectElementNone;
     }
     
-    if ([viewClass isSubclassOfClass:[WebImageView class]])
-        return ObjectElementImage;
-    
     // If we're a supported type other than a plugin, we want to make a frame.
     // Ultimately we should just use frames for all mime types (plugins and HTML/XML/text documents),
     // but for now we're burdened with making a distinction between the two.
@@ -1624,4 +1620,14 @@ static id <WebFormDelegate> formDelegate(WebFrameBridge *self)
     [super closeURL];
 }
 
+- (NSURLResponse*)mainResourceURLResponse
+{
+    return [[_frame dataSource] response];
+}
+
+- (NSString*)imageTitleForFilename:(NSString*)filename size:(NSSize)size
+{
+    return [NSString stringWithFormat:UI_STRING("%@ %.0f×%.0f pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename, size.width, size.height];
+}
+
 @end
index 21d042d..11273c0 100644 (file)
@@ -33,7 +33,6 @@
 #import <WebKit/WebHTMLView.h>
 #import <WebKit/WebImageData.h>
 #import <WebKit/WebImageRendererFactory.h>
-#import <WebKit/WebImageView.h>
 #import <WebKit/WebNSObjectExtras.h>
 #import <WebKitSystemInterface.h>
 
     // Only animate if we're drawing into a WebHTMLView or WebImageView.  This fixes problems
     // like <rdar://problem/3966973>, which describes a third party application that renders thumbnails of
     // the page into a alternate view.
-    if (([targetView isKindOfClass:[WebHTMLView class]] || [targetView isKindOfClass:[WebImageView class]]) 
+    if ([targetView isKindOfClass:[WebHTMLView class]] 
             && [imageData shouldAnimate] && [MIMEType isEqual:@"image/gif"]) {
         [imageData addAnimatingRenderer:self inView:targetView];
         [imageData animate];
index d9bca02..696120b 100644 (file)
                939810560824BF01008DF038 /* WebHTMLRepresentationPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F5A55DC702BAA2E8018635CC /* WebHTMLRepresentationPrivate.h */; };
                939810570824BF01008DF038 /* WebHTMLView.h in Headers */ = {isa = PBXBuildFile; fileRef = 35081D9402B6D4D80ACA2ACA /* WebHTMLView.h */; settings = {ATTRIBUTES = (Private, ); }; };
                939810580824BF01008DF038 /* WebHTMLViewPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 35081D9602B6D4D80ACA2ACA /* WebHTMLViewPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               939810590824BF01008DF038 /* WebImageRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 35081D9802B6D4D80ACA2ACA /* WebImageRepresentation.h */; };
-               9398105A0824BF01008DF038 /* WebImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = 35081D9A02B6D4D80ACA2ACA /* WebImageView.h */; settings = {ATTRIBUTES = (); }; };
                9398105B0824BF01008DF038 /* WebFrameLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5152FAE5033FC52200CA2ACD /* WebFrameLoadDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
                9398105C0824BF01008DF038 /* WebMainResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D538E802441F2601A80181 /* WebMainResourceLoader.h */; };
                9398105D0824BF01008DF038 /* WebPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 3944606E020F50ED0ECA1767 /* WebPreferences.h */; settings = {ATTRIBUTES = (Public, ); }; };
                939810F20824BF01008DF038 /* WebFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = F5143A370221DCCE01A80181 /* WebFrame.m */; };
                939810F30824BF01008DF038 /* WebHTMLRepresentation.m in Sources */ = {isa = PBXBuildFile; fileRef = 35081D9302B6D4D80ACA2ACA /* WebHTMLRepresentation.m */; };
                939810F40824BF01008DF038 /* WebHTMLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 35081D9502B6D4D80ACA2ACA /* WebHTMLView.m */; };
-               939810F50824BF01008DF038 /* WebImageRepresentation.m in Sources */ = {isa = PBXBuildFile; fileRef = 35081D9902B6D4D80ACA2ACA /* WebImageRepresentation.m */; };
-               939810F60824BF01008DF038 /* WebImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 35081D9B02B6D4D80ACA2ACA /* WebImageView.m */; };
                939810F70824BF01008DF038 /* WebMainResourceLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = F5D538EC02441FDD01A80181 /* WebMainResourceLoader.m */; };
                939810F80824BF01008DF038 /* WebPreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = F5AEBB3D024A527601C1A526 /* WebPreferences.m */; };
                939810F90824BF01008DF038 /* WebRenderNode.m in Sources */ = {isa = PBXBuildFile; fileRef = F5F81C3A02B67C26018635CA /* WebRenderNode.m */; };
                ED7F6D8B0980683500C235ED /* WebNSDataExtrasPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               1AF77F6B0A193B680058FFAF /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               1AF77F6C0A193B680058FFAF /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
 /* Begin PBXFileReference section */
                1C68F640095B5FC100C2984E /* webInspector */ = {isa = PBXFileReference; lastKnownFileType = folder; name = webInspector; path = WebInspector/webInspector; sourceTree = SOURCE_ROOT; };
                1C68F65C095B5FC100C2984E /* WebInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebInspector.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                35081D9402B6D4D80ACA2ACA /* WebHTMLView.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebHTMLView.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                35081D9502B6D4D80ACA2ACA /* WebHTMLView.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebHTMLView.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                35081D9602B6D4D80ACA2ACA /* WebHTMLViewPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebHTMLViewPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               35081D9802B6D4D80ACA2ACA /* WebImageRepresentation.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebImageRepresentation.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               35081D9902B6D4D80ACA2ACA /* WebImageRepresentation.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebImageRepresentation.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               35081D9A02B6D4D80ACA2ACA /* WebImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebImageView.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               35081D9B02B6D4D80ACA2ACA /* WebImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebImageView.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                35081DAE02B6D4F50ACA2ACA /* WebDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDocument.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                35F3577F0198AAB80ACA1520 /* English */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                3944606B020F50ED0ECA1767 /* WebDynamicScrollBarsView.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDynamicScrollBarsView.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                                6550B7C5099EFAE90090D781 /* WebArchiver.h */,
                                6550B7C6099EFAE90090D781 /* WebArchiver.m */,
                                F52CA6BD02DF9D0F018635CA /* HTML */,
-                               F52CA6BE02DF9D49018635CA /* Image */,
                                51E94C0706C02CA300A9B09E /* PDF */,
                                8373435A0624EE0D00F3B289 /* WebArchive.h */,
                                8373435B0624EE0D00F3B289 /* WebArchive.m */,
                        name = HTML;
                        sourceTree = "<group>";
                };
-               F52CA6BE02DF9D49018635CA /* Image */ = {
-                       isa = PBXGroup;
-                       children = (
-                               35081D9802B6D4D80ACA2ACA /* WebImageRepresentation.h */,
-                               35081D9902B6D4D80ACA2ACA /* WebImageRepresentation.m */,
-                               35081D9A02B6D4D80ACA2ACA /* WebImageView.h */,
-                               35081D9B02B6D4D80ACA2ACA /* WebImageView.m */,
-                       );
-                       name = Image;
-                       sourceTree = "<group>";
-               };
                F52CA6C002DF9D78018635CA /* Download */ = {
                        isa = PBXGroup;
                        children = (
                                939810560824BF01008DF038 /* WebHTMLRepresentationPrivate.h in Headers */,
                                939810570824BF01008DF038 /* WebHTMLView.h in Headers */,
                                939810580824BF01008DF038 /* WebHTMLViewPrivate.h in Headers */,
-                               939810590824BF01008DF038 /* WebImageRepresentation.h in Headers */,
-                               9398105A0824BF01008DF038 /* WebImageView.h in Headers */,
                                9398105B0824BF01008DF038 /* WebFrameLoadDelegate.h in Headers */,
                                9398105C0824BF01008DF038 /* WebMainResourceLoader.h in Headers */,
                                9398105D0824BF01008DF038 /* WebPreferences.h in Headers */,
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
+                       buildSettings = {
+                       };
+                       buildStyles = (
+                               1AF77F6B0A193B680058FFAF /* Development */,
+                               1AF77F6C0A193B680058FFAF /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                                939810F20824BF01008DF038 /* WebFrame.m in Sources */,
                                939810F30824BF01008DF038 /* WebHTMLRepresentation.m in Sources */,
                                939810F40824BF01008DF038 /* WebHTMLView.m in Sources */,
-                               939810F50824BF01008DF038 /* WebImageRepresentation.m in Sources */,
-                               939810F60824BF01008DF038 /* WebImageView.m in Sources */,
                                939810F70824BF01008DF038 /* WebMainResourceLoader.m in Sources */,
                                939810F80824BF01008DF038 /* WebPreferences.m in Sources */,
                                939810F90824BF01008DF038 /* WebRenderNode.m in Sources */,
index 2ba9790..c91ce5f 100644 (file)
@@ -41,5 +41,6 @@
 + (WebArchive *)archiveRange:(DOMRange *)range;
 + (WebArchive *)archiveSelectionInFrame:(WebFrame *)frame;
 + (WebArchive *)archiveFrame:(WebFrame *)frame;
++ (WebArchive *)archiveMainResourceForFrame:(WebFrame *)frame;
 
 @end
index e4d955c..3e4e581 100644 (file)
                                     subframeArchives:[self _subframeArchivesForFrame:frame]] autorelease];
 }
 
++ (WebArchive *)archiveMainResourceForFrame:(WebFrame *)frame;
+{
+    return [[[WebArchive alloc] initWithMainResource:[[frame dataSource] mainResource]
+                                        subresources:nil
+                                    subframeArchives:nil] autorelease];
+}
+
 + (WebArchive *)_archiveCurrentStateForFrame:(WebFrame *)frame
 {
     if ([frame DOMDocument])
index 0bcacdf..7efe01c 100644 (file)
@@ -48,8 +48,6 @@
 #import <WebKit/WebIconDatabasePrivate.h>
 #import <WebKit/WebIconLoader.h>
 #import <WebKit/WebImageRendererFactory.h>
-#import <WebKit/WebImageRepresentation.h>
-#import <WebKit/WebImageView.h>
 #import <WebKit/WebKitErrorsPrivate.h>
 #import <WebKit/WebKitLogging.h>
 #import <WebKit/WebKitNSStringExtras.h>
@@ -711,7 +709,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     
     if (!repTypes) {
         repTypes = [[NSMutableDictionary alloc] init];
-        addTypesFromClass(repTypes, [WebHTMLRepresentation class], [WebHTMLRepresentation supportedMIMETypes]);
+        addTypesFromClass(repTypes, [WebHTMLRepresentation class], [WebHTMLRepresentation supportedNonImageMIMETypes]);
 
         // Since this is a "secret default" we don't both registering it.
         BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
@@ -720,7 +718,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     }
     
     if (!addedImageTypes && !allowImageTypeOmission) {
-        addTypesFromClass(repTypes, [WebImageRepresentation class], [WebImageRepresentation supportedMIMETypes]);
+        addTypesFromClass(repTypes, [WebHTMLRepresentation class], [WebHTMLRepresentation supportedImageMIMETypes]);
         addedImageTypes = YES;
     }
     
index 4cf199d..a620033 100644 (file)
@@ -40,7 +40,6 @@
 #import "WebHTMLViewPrivate.h"
 #import "WebImageRenderer.h"
 #import "WebImageRendererFactory.h"
-#import "WebImageView.h"
 #import "WebKeyGenerator.h"
 #import "WebKitErrorsPrivate.h"
 #import "WebKitStatisticsPrivate.h"
@@ -259,7 +258,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     
     if (!viewTypes) {
         viewTypes = [[NSMutableDictionary alloc] init];
-        addTypesFromClass(viewTypes, [WebHTMLView class], [WebHTMLView supportedMIMETypes]);
+        addTypesFromClass(viewTypes, [WebHTMLView class], [WebHTMLView supportedNonImageMIMETypes]);
 
         // Since this is a "secret default" we don't both registering it.
         BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
@@ -268,7 +267,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class class,
     }
     
     if (!addedImageTypes && !allowImageTypeOmission) {
-        addTypesFromClass(viewTypes, [WebImageView class], [WebImageView supportedMIMETypes]);
+        addTypesFromClass(viewTypes, [WebHTMLView class], [WebHTMLView supportedImageMIMETypes]);
         addedImageTypes = YES;
     }
     
index 03fcdb2..2098c47 100644 (file)
@@ -49,6 +49,8 @@
 }
 
 + (NSArray *)supportedMIMETypes;
++ (NSArray *)supportedNonImageMIMETypes;
++ (NSArray *)supportedImageMIMETypes;
 
 - (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset;
 
index 23f170b..4f96f7e 100644 (file)
@@ -35,6 +35,7 @@
 #import <WebKit/WebDataSourceInternal.h>
 #import <WebKit/WebDocumentPrivate.h>
 #import <WebKit/WebFramePrivate.h>
+#import <WebKit/WebImageRendererFactory.h>
 #import <WebKit/WebKitNSStringExtras.h>
 #import <WebKit/WebKitStatisticsPrivate.h>
 #import <WebKit/WebNSObjectExtras.h>
 
 + (NSArray *)supportedMIMETypes
 {
-    return [WebCoreFrameBridge supportedMIMETypes];
+    static NSMutableArray *mimeTypes\v = nil;
+    
+    if (!mimeTypes) {
+        mimeTypes = [[self supportedNonImageMIMETypes] mutableCopy];
+        [mimeTypes addObjectsFromArray:[self supportedImageMIMETypes]];
+    }
+    
+    return mimeTypes;
+}
+
++ (NSArray *)supportedNonImageMIMETypes
+{
+    return [WebCoreFrameBridge supportedNonImageMIMETypes];
+}
+
++ (NSArray *)supportedImageMIMETypes
+{
+    [WebImageRendererFactory createSharedFactory];
+    return [WebCoreFrameBridge supportedImageMIMETypes];
 }
 
 - init
index 022a12d..b05f7b4 100644 (file)
@@ -698,6 +698,16 @@ void *_NSSoftLinkingGetFrameworkFuncPtr(NSString *inUmbrellaFrameworkName,
     return [WebHTMLRepresentation supportedMIMETypes];
 }
 
++ (NSArray *)supportedImageMIMETypes
+{
+    return [WebHTMLRepresentation supportedImageMIMETypes];
+}
+
++ (NSArray *)supportedNonImageMIMETypes
+{
+    return [WebHTMLRepresentation supportedNonImageMIMETypes];
+}
+
 + (NSArray *)unsupportedTextMIMETypes
 {
     return [NSArray arrayWithObjects:
@@ -1288,11 +1298,21 @@ static WebHTMLView *lastHitView = nil;
             ASSERT(imageElement != nil);
             [webView setSelectedDOMRange:[[[self _bridge] DOMDocument] _createRangeWithNode:imageElement] affinity:NSSelectionAffinityDownstream];
             _private->draggingImageURL = [imageURL retain];
+            
+            WebArchive *archive;
+            
+            // If the image element comes from an ImageDocument, we don't want to 
+            // create a web archive from the image element.
+            if ([[self _bridge] canSaveAsWebArchive])
+                archive = [imageElement webArchive];
+            else
+                archive = [WebArchiver archiveMainResourceForFrame:[self _frame]];
+            
             source = [pasteboard _web_declareAndWriteDragImage:nil
                                                        element:imageElement
                                                            URL:linkURL ? linkURL : imageURL
                                                          title:[element objectForKey:WebElementImageAltStringKey]
-                                                       archive:[imageElement webArchive]
+                                                       archive:archive
                                                         source:self];
         }
         [[webView _UIDelegateForwarder] webView:webView willPerformDragSourceAction:WebDragSourceActionImage fromPoint:mouseDownPoint withPasteboard:pasteboard];
index aa8d8e7..bb109d3 100644 (file)
@@ -40,6 +40,8 @@
 
 - (void)_reset;
 + (NSArray *)supportedMIMETypes;
++ (NSArray *)supportedImageMIMETypes;
++ (NSArray *)supportedNonImageMIMETypes;
 + (NSArray *)unsupportedTextMIMETypes;
 
 // Modifier (flagsChanged) tracking SPI
diff --git a/WebKit/WebView/WebImageRepresentation.h b/WebKit/WebView/WebImageRepresentation.h
deleted file mode 100644 (file)
index 5db713f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-@class WebDataSource;
-@class WebImageRenderer;
-
-@protocol WebDocumentRepresentation;
-
-@interface WebImageRepresentation : NSObject <WebDocumentRepresentation>
-{
-    WebDataSource *dataSource;
-    WebImageRenderer *image;
-    BOOL doneLoading;
-}
-+ (NSArray *)supportedMIMETypes;
-- (WebImageRenderer *)image;
-- (NSString *)filename;
-- (BOOL)doneLoading;
-- (NSData *)data;
-- (NSURL *)URL;
-@end
diff --git a/WebKit/WebView/WebImageRepresentation.m b/WebKit/WebView/WebImageRepresentation.m
deleted file mode 100644 (file)
index e1ac24c..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebImageRepresentation.h"
-
-#import <WebKit/WebArchive.h>
-#import <WebKit/WebDataSourcePrivate.h>
-#import <WebKit/WebImageRenderer.h>
-#import <WebKit/WebImageRendererFactory.h>
-#import <WebKit/WebLocalizableStrings.h>
-#import <WebKit/WebResource.h>
-
-#import <WebCore/WebCoreImageRenderer.h>
-
-#import <Foundation/NSURLRequest.h>
-
-@implementation WebImageRepresentation
-
-+ (NSArray *)supportedMIMETypes
-{
-    static NSMutableArray *imageMIMETypes = nil;
-    if (imageMIMETypes == nil) {
-        imageMIMETypes = [[[WebImageRendererFactory sharedFactory] supportedMIMETypes] mutableCopy];
-        [imageMIMETypes removeObject:@"application/pdf"];
-        [imageMIMETypes removeObject:@"application/postscript"];
-    }
-    return imageMIMETypes;
-}
-
-- (void)dealloc
-{
-    [image release];
-    [super dealloc];
-}
-
-- (WebImageRenderer *)image
-{
-    return image;
-}
-
-- (NSURL *)URL
-{
-    return [[dataSource request] URL];
-}
-
-- (BOOL)doneLoading
-{
-    return doneLoading;
-}
-
-- (void)setDataSource:(WebDataSource *)theDataSource
-{
-    dataSource = theDataSource;
-    image = [[[WebImageRendererFactory sharedFactory] imageRendererWithMIMEType:[[dataSource response] MIMEType]] retain];
-}
-
-- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)theDataSource
-{
-    NSData *allData = [dataSource data];
-    [image incrementalLoadWithBytes:[allData bytes] length:[allData length] complete:NO callback:0];
-}
-
-- (void)receivedError:(NSError *)error withDataSource:(WebDataSource *)theDataSource
-{
-    NSData *allData = [dataSource data];
-    if ([allData length] > 0) {
-        [image incrementalLoadWithBytes:[allData bytes] length:[allData length] complete:YES callback:0];
-    }
-    doneLoading = YES;
-}
-
-- (void)finishedLoadingWithDataSource:(WebDataSource *)theDataSource
-{
-    NSData *allData = [dataSource data];
-    [image incrementalLoadWithBytes:[allData bytes] length:[allData length] complete:YES callback:0];
-    doneLoading = YES;
-}
-
-- (BOOL)canProvideDocumentSource
-{
-    return NO;
-}
-
-- (NSString *)documentSource
-{
-    return nil;
-}
-
-- (NSString *)title
-{
-    NSString *filename = [self filename];
-    NSSize size = [image size];
-    if (!NSEqualSizes(size, NSZeroSize)) {
-        return [NSString stringWithFormat:UI_STRING("%@ %.0f×%.0f pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename, size.width, size.height];
-    }
-    return filename;
-}
-
-- (NSData *)data
-{
-    return [dataSource data];
-}
-
-- (NSString *)filename
-{
-    return [[dataSource response] suggestedFilename];
-}
-
-@end
diff --git a/WebKit/WebView/WebImageView.h b/WebKit/WebView/WebImageView.h
deleted file mode 100644 (file)
index eae7e76..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebDocumentInternal.h>
-
-@class WebImageRepresentation;
-
-@interface WebImageView : NSView <WebDocumentView, WebDocumentImage, WebDocumentElement>
-{
-    WebImageRepresentation *rep;
-    BOOL needsLayout;
-    BOOL ignoringMouseDraggedEvents;
-    NSEvent *mouseDownEvent;
-    unsigned int dragSourceActionMask;
-    WebDataSource *_dataSource;
-}
-+ (NSArray *)supportedMIMETypes;
-@end
diff --git a/WebKit/WebView/WebImageView.m b/WebKit/WebView/WebImageView.m
deleted file mode 100644 (file)
index c561cc9..0000000
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <WebKit/WebImageView.h>
-
-#import <WebKit/WebArchiver.h>
-#import <JavaScriptCore/Assertions.h>
-#import <WebKit/WebDataSourceInternal.h>
-#import <WebKit/WebDocument.h>
-#import <WebKit/WebFrameView.h>
-#import <WebKit/WebImageRenderer.h>
-#import <WebKit/WebImageRendererFactory.h>
-#import <WebKit/WebImageRepresentation.h>
-#import <WebKit/WebNSFileManagerExtras.h>
-#import <WebKit/WebNSObjectExtras.h>
-#import <WebKit/WebNSPasteboardExtras.h>
-#import <WebKit/WebNSViewExtras.h>
-#import <WebKit/WebFrameViewPrivate.h>
-#import <WebKit/WebViewInternal.h>
-#import <WebKit/WebUIDelegatePrivate.h>
-
-#import <WebCore/WebCoreImageRenderer.h>
-#import <WebCore/WebCoreFrameBridge.h>
-
-@implementation WebImageView
-
-+ (void)initialize
-{
-    [NSApp registerServicesMenuSendTypes:[NSArray arrayWithObject:NSTIFFPboardType] returnTypes:nil];
-}
-
-+ (NSArray *)supportedMIMETypes
-{
-    return [WebImageRepresentation supportedMIMETypes];
-}
-
-- (id)initWithFrame:(NSRect)frame
-{
-    self = [super initWithFrame:frame];
-    if (!self)
-        return nil;
-    [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
-    return self;
-}
-
-- (void)dealloc
-{
-    [[rep image] stopAnimation];
-    [rep release];
-    [mouseDownEvent release];
-    
-    [super dealloc];
-}
-
-- (void)finalize
-{
-    [[rep image] stopAnimation];
-    [super finalize];
-}
-
-- (BOOL)haveCompleteImage
-{
-    NSSize imageSize = [[rep image] size];
-    return [rep doneLoading] && imageSize.width > 0 && imageSize.width > 0;
-}
-
-- (BOOL)isFlipped 
-{
-    return YES;
-}
-
-- (BOOL)acceptsFirstResponder
-{
-    // Being first responder is useful for scrolling from the keyboard at least.
-    return YES;
-}
-
-- (NSRect)drawingRect
-{
-    NSSize imageSize = [[rep image] size];
-    return NSMakeRect(0, 0, imageSize.width, imageSize.height);
-}
-
-- (void)drawRect:(NSRect)rect
-{
-    if (needsLayout) {
-        [self layout];
-    }
-    
-    if ([[_dataSource _webView] drawsBackground]) {
-        [[NSColor whiteColor] set];
-        NSRectFill(rect);
-    }
-    
-    NSRect drawingRect = [self drawingRect];
-    [[rep image] drawImageInRect:drawingRect fromRect:drawingRect];
-}
-
-- (void)adjustFrameSize
-{
-    NSSize size = [[rep image] size];
-    
-    // When drawing on screen, ensure that the view always fills the content area 
-    // (so we draw over the entire previous page), and that the view is at least 
-    // as large as the image.. Otherwise we're printing, and we want the image to 
-    // fill the view so that the printed size doesn't depend on the window size.
-    if ([NSGraphicsContext currentContextDrawingToScreen]) {
-        NSSize clipViewSize = [[[[_dataSource webFrame] frameView] _contentView] frame].size;
-        size.width = MAX(size.width, clipViewSize.width);
-        size.height = MAX(size.height, clipViewSize.height);
-    }
-    
-    [super setFrameSize:size];
-}
-
-- (void)setFrameSize:(NSSize)size
-{
-    [self adjustFrameSize];
-}
-
-- (void)layout
-{
-    [self adjustFrameSize];    
-    needsLayout = NO;
-}
-
-- (void)setDataSource:(WebDataSource *)dataSource
-{
-    ASSERT(!rep);
-    rep = [[dataSource representation] retain];
-    _dataSource = dataSource;
-}
-
-- (void)dataSourceUpdated:(WebDataSource *)dataSource
-{
-    NSSize imageSize = [[rep image] size];
-    if (imageSize.width > 0 && imageSize.height > 0) {
-        [self setNeedsLayout:YES];
-        [self layout];
-        [self setNeedsDisplay:YES];
-    }
-}
-
-- (void)setNeedsLayout:(BOOL)flag
-{
-    needsLayout = flag;
-}
-
-- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
-{
-}
-
-- (void)viewDidMoveToHostWindow
-{
-}
-
-- (void)viewDidMoveToWindow
-{
-    if (![self window]){
-        [[rep image] stopAnimation];
-    }
-    
-    [super viewDidMoveToWindow];
-}
-
-- (WebView *)webView
-{
-    return [_dataSource _webView];
-}
-
-- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
-{
-    if ([item action] == @selector(copy:)){
-        return [self haveCompleteImage];
-    }
-
-    return YES;
-}
-
-- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
-{
-    if (sendType && [sendType isEqualToString:NSTIFFPboardType]){
-        return self;
-    }
-
-    return [super validRequestorForSendType:sendType returnType:returnType];
-}
-
-- (BOOL)writeImageToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
-{
-    WebFrame *frame = [_dataSource webFrame];
-    if ([self haveCompleteImage]) {
-        [pasteboard _web_writeImage:[rep image] element:nil URL:[rep URL] title:nil archive:[WebArchiver archiveFrame:frame] types:types];
-        return YES;
-    }
-    
-    return NO;
-}
-
-- (void)copy:(id)sender
-{
-    WebFrame *frame = [_dataSource webFrame];
-    NSArray *types = [NSPasteboard _web_writableTypesForImageIncludingArchive:([WebArchiver archiveFrame:frame] != nil)];
-    NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
-    [pasteboard declareTypes:types owner:nil];
-    [self writeImageToPasteboard:pasteboard types:types];
-}
-
-- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
-{
-    [pasteboard declareTypes:types owner:nil];
-    return [self writeImageToPasteboard:pasteboard types:types];
-}
-
-- (NSDictionary *)elementAtPoint:(NSPoint)point
-{
-    WebFrame *frame = [_dataSource webFrame];
-    ASSERT(frame);
-    
-    return [NSDictionary dictionaryWithObjectsAndKeys:
-        [[rep image] image],                    WebElementImageKey,
-        [NSValue valueWithRect:[self bounds]],  WebElementImageRectKey,
-        [rep URL],                              WebElementImageURLKey,
-        [NSNumber numberWithBool:NO],           WebElementIsSelectedKey,
-        frame,                                  WebElementFrameKey, nil];
-}
-
-- (NSDictionary *)elementAtPoint:(NSPoint)point allowShadowContent:(BOOL)allow
-{
-    return [self elementAtPoint:point];
-}
-
-- (NSMenu *)menuForEvent:(NSEvent *)theEvent
-{
-    WebView *webView = [self webView];
-    ASSERT(webView);
-    return [webView _menuForElement:[self elementAtPoint:NSZeroPoint] defaultItems:nil];
-}
-
-- (void)mouseDown:(NSEvent *)event
-{
-    ignoringMouseDraggedEvents = NO;
-    [mouseDownEvent release];
-    mouseDownEvent = [event retain];
-    
-    WebView *webView = [self webView];
-    NSPoint point = [webView convertPoint:[mouseDownEvent locationInWindow] fromView:nil];
-    dragSourceActionMask = [[webView _UIDelegateForwarder] webView:webView dragSourceActionMaskForPoint:point];
-    
-    [super mouseDown:event];
-}
-
-- (void)mouseDragged:(NSEvent *)mouseDraggedEvent
-{
-    if (ignoringMouseDraggedEvents || ![self haveCompleteImage] || !(dragSourceActionMask & WebDragSourceActionImage)) {
-        return;
-    }
-    
-    WebFrame *frame = [_dataSource webFrame];
-    NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
-    id source = [pasteboard _web_declareAndWriteDragImage:[rep image]
-                                                  element:nil
-                                                      URL:[rep URL]
-                                                    title:nil
-                                                  archive:[WebArchiver archiveFrame:frame]
-                                                   source:self];
-    
-    WebView *webView = [self webView];
-    NSPoint point = [webView convertPoint:[mouseDownEvent locationInWindow] fromView:nil];
-    [[webView _UIDelegateForwarder] webView:webView willPerformDragSourceAction:WebDragSourceActionImage fromPoint:point withPasteboard:pasteboard];
-    
-    [[self webView] _setInitiatedDrag:YES];
-    
-    // Retain this view during the drag because it may be released before the drag ends.
-    [self retain];
-    
-    [self _web_dragImage:[rep image]
-                 element:nil
-                    rect:[self drawingRect]
-                   event:mouseDraggedEvent
-              pasteboard:pasteboard
-                  source:source
-                  offset:NULL];
-}
-
-- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
-{
-    // FIXME: Report an error if we fail to create a file.
-    NSString *path = [[dropDestination path] stringByAppendingPathComponent:[rep filename]];
-    path = [[NSFileManager defaultManager] _webkit_pathWithUniqueFilenameForPath:path];
-    [[rep data] writeToFile:path atomically:NO];
-    return [NSArray arrayWithObject:[path lastPathComponent]];
-}
-
-- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
-{
-    // Prevent queued mouseDragged events from coming after the drag which can cause a double drag.
-    ignoringMouseDraggedEvents = YES;
-    
-    [[self webView] _setInitiatedDrag:NO];
-
-    // Balance the previous retain from when the drag started.
-    [self release];
-}
-
-- (NSImage *)image
-{
-    return [[rep image] image];
-}
-
-#pragma mark PRINTING
-
-- (void)drawPageBorderWithSize:(NSSize)borderSize
-{
-    ASSERT(NSEqualSizes(borderSize, [[[NSPrintOperation currentOperation] printInfo] paperSize]));
-    // FIXME: How to determine the number of pages required to print the whole image?
-    [[self webView] _drawHeaderAndFooter];
-}
-
-- (void)beginDocument
-{
-    [self adjustFrameSize];
-    [[self webView] _adjustPrintingMarginsForHeaderAndFooter];
-    [super beginDocument];
-}
-
-- (void)endDocument
-{
-    [super endDocument];
-    [self adjustFrameSize];
-}
-
-- (BOOL)canPrintHeadersAndFooters
-{
-    return YES;
-}
-
-@end