Commit fada1d18 authored by oliver's avatar oliver
Browse files

2007-05-18 Oliver Hunt <oliver@apple.com>

WebCore:

        Reviewed by Sam

        No longer need to pass HTMLImageElement and HTMLImageLoader on to WebKit
        Need to expose CachedResourceClient constructor

        * WebCore.exp:
        * WebCore.xcodeproj/project.pbxproj:

WebKit:

        Reviewed by Sam.

        Fix for http://bugs.webkit.org/show_bug.cgi?id=13782 
        REGRESSION (r21528-r21533): Failing editing/selection/drag-in-iframe in pixel mode
        
        r21533 made used a DOMElement as the source for promise data, this meant it had to 
        clear the dragging pasteboard following the drag.  In DRT a drag is non-blocking
        so this resulted in us prematurely clearing the pasteboard.  
        
        This patch avoids this problem by referencing the source CachedImage rather than the
        DOMElement, so we don't need to worry about retaining an entire document forever, so
        we don't need to clear the dragging pasteboard following the drag.
        
        * Misc/WebNSPasteboardExtras.mm:
        (imageFromElement):
          Extract the underlying CachedImage from a DOMElement
        (-[NSPasteboard _web_writeImage:element:URL:title:archive:types:source:]):
          Use a CachedImage instead of a DOMElement
          
        * WebCoreSupport/WebDragClient.mm:
        (WebDragClient::startDrag):
        
        * WebKit.xcodeproj/project.pbxproj:
        
        * WebView/WebHTMLView.mm:
        (-[WebHTMLViewPrivate dealloc]):
        (-[WebHTMLViewPrivate clear]):
        (-[WebHTMLView pasteboardChangedOwner:]):
        (-[WebHTMLView pasteboard:provideDataForType:]):
        (-[WebHTMLView namesOfPromisedFilesDroppedAtDestination:]):
        (-[WebHTMLView WebCore::]):
        (-[WebHTMLView setPromisedDragTIFFDataSource:WebCore::]):
          Use CachedImage rather than DOMElement as promised data source
          
        * WebView/WebHTMLViewInternal.h:
        * WebView/WebHTMLViewPrivate.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21596 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9e91d431
2007-05-18 Oliver Hunt <oliver@apple.com>
Reviewed by Sam
No longer need to pass HTMLImageElement and HTMLImageLoader on to WebKit
Need to expose CachedResourceClient constructor
* WebCore.exp:
* WebCore.xcodeproj/project.pbxproj:
2007-05-18 David Hyatt <hyatt@apple.com>
 
Fix for <rdar://problem/5214338> REGRESSION: / mishandled in
......@@ -235,6 +235,7 @@ __ZN7WebCore13HitTestResultD1Ev
__ZN7WebCore13KeyboardEventC1ERKNS_12AtomicStringEbbPNS_9DOMWindowERKNS_6StringEjbbbbb
__ZN7WebCore13ResourceError19unpackPlatformErrorEv
__ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
__ZN7WebCore14CachedResource5derefEPNS_20CachedResourceClientE
__ZN7WebCore14DocumentLoader12setCommittedEb
__ZN7WebCore14DocumentLoader13attachToFrameEv
__ZN7WebCore14DocumentLoader15detachFromFrameEv
......
......@@ -2230,9 +2230,9 @@
A8EA7CB60A192B9C00A8EF5F /* HTMLBlockquoteElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA7CA80A192B9C00A8EF5F /* HTMLBlockquoteElement.cpp */; };
A8EA7CB70A192B9C00A8EF5F /* HTMLDivElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA7CA90A192B9C00A8EF5F /* HTMLDivElement.h */; };
A8EA7CB80A192B9C00A8EF5F /* HTMLHeadingElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA7CAA0A192B9C00A8EF5F /* HTMLHeadingElement.h */; };
A8EA7D2B0A19385500A8EF5F /* HTMLImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA7D230A19385500A8EF5F /* HTMLImageLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
A8EA7D2B0A19385500A8EF5F /* HTMLImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA7D230A19385500A8EF5F /* HTMLImageLoader.h */; settings = {ATTRIBUTES = (); }; };
A8EA7D2C0A19385500A8EF5F /* HTMLMapElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA7D240A19385500A8EF5F /* HTMLMapElement.h */; };
A8EA7D2D0A19385500A8EF5F /* HTMLImageElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA7D250A19385500A8EF5F /* HTMLImageElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
A8EA7D2D0A19385500A8EF5F /* HTMLImageElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA7D250A19385500A8EF5F /* HTMLImageElement.h */; settings = {ATTRIBUTES = (); }; };
A8EA7D2E0A19385500A8EF5F /* HTMLAreaElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8EA7D260A19385500A8EF5F /* HTMLAreaElement.h */; };
A8EA7D2F0A19385500A8EF5F /* HTMLAreaElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA7D270A19385500A8EF5F /* HTMLAreaElement.cpp */; };
A8EA7D300A19385500A8EF5F /* HTMLImageLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8EA7D280A19385500A8EF5F /* HTMLImageLoader.cpp */; };
2007-05-18 Oliver Hunt <oliver@apple.com>
Reviewed by Sam.
Fix for http://bugs.webkit.org/show_bug.cgi?id=13782
REGRESSION (r21528-r21533): Failing editing/selection/drag-in-iframe in pixel mode
r21533 made used a DOMElement as the source for promise data, this meant it had to
clear the dragging pasteboard following the drag. In DRT a drag is non-blocking
so this resulted in us prematurely clearing the pasteboard.
This patch avoids this problem by referencing the source CachedImage rather than the
DOMElement, so we don't need to worry about retaining an entire document forever, so
we don't need to clear the dragging pasteboard following the drag.
* Misc/WebNSPasteboardExtras.mm:
(imageFromElement):
Extract the underlying CachedImage from a DOMElement
(-[NSPasteboard _web_writeImage:element:URL:title:archive:types:source:]):
Use a CachedImage instead of a DOMElement
* WebCoreSupport/WebDragClient.mm:
(WebDragClient::startDrag):
* WebKit.xcodeproj/project.pbxproj:
* WebView/WebHTMLView.mm:
(-[WebHTMLViewPrivate dealloc]):
(-[WebHTMLViewPrivate clear]):
(-[WebHTMLView pasteboardChangedOwner:]):
(-[WebHTMLView pasteboard:provideDataForType:]):
(-[WebHTMLView namesOfPromisedFilesDroppedAtDestination:]):
(-[WebHTMLView WebCore::]):
(-[WebHTMLView setPromisedDragTIFFDataSource:WebCore::]):
Use CachedImage rather than DOMElement as promised data source
* WebView/WebHTMLViewInternal.h:
* WebView/WebHTMLViewPrivate.h:
2007-05-18 Tristan O'Tierney <tristan@apple.com>
 
Reviewed by Brady E.
......
......@@ -30,13 +30,16 @@
#import "WebArchive.h"
#import "WebFrameBridge.h"
#import "WebHTMLViewPrivate.h"
#import "WebFrameInternal.h"
#import "WebHTMLViewInternal.h"
#import "WebNSURLExtras.h"
#import "WebResourcePrivate.h"
#import "WebURLsWithTitles.h"
#import "WebViewPrivate.h"
#import <JavaScriptCore/Assertions.h>
#import <WebCore/Element.h>
#import <WebCore/MimeTypeRegistry.h>
#import <WebCore/RenderImage.h>
#import <WebKit/DOMExtensions.h>
#import <WebKit/DOMPrivate.h>
#import <wtf/RetainPtr.h>
......@@ -242,6 +245,18 @@ static NSArray *_writableTypesForImageWithArchive (void)
}
CachedImage* imageFromElement(DOMElement *domElement) {
Element* element = core(domElement);
if (!element)
return 0;
RenderObject* renderer = element->renderer();
RenderImage* imageRenderer = static_cast<RenderImage*>(renderer);
if (!imageRenderer->cachedImage() || imageRenderer->cachedImage()->errorOccurred())
return 0;
return imageRenderer->cachedImage();
}
- (void)_web_writeImage:(NSImage *)image
element:(DOMElement *)element
URL:(NSURL *)URL
......@@ -259,8 +274,8 @@ static NSArray *_writableTypesForImageWithArchive (void)
if (image)
[self setData:[image TIFFRepresentation] forType:NSTIFFPboardType];
else if (source && element)
[source setPromisedDragTIFFDataSource:element];
else
[source setPromisedDragTIFFDataSource:imageFromElement(element)];
else if (element)
[self setData:[element _imageTIFFRepresentation] forType:NSTIFFPboardType];
}
......
......@@ -104,11 +104,6 @@ void WebDragClient::startDrag(DragImageRef dragImage, const IntPoint& at, const
[UIDelegate webView:m_webView dragImage:dragImage.get() at:(NSPoint)at offset:NSMakeSize(0, 0) event:event pasteboard:pasteboard source:htmlView.get() slideBack:YES forView:topHTMLView];
else
[topHTMLView dragImage:dragImage.get() at:(NSPoint)at offset:NSMakeSize(0, 0) event:event pasteboard:pasteboard source:htmlView.get() slideBack:YES];
// Forcibly clear the pasteboard at the end of drag, this stops us from writing
// delayed data (RTF/images, etc) on app quit, which we don't want to do given
// the life time for this data should only be the lifetime of the drag.
[pasteboard declareTypes:nil owner:nil];
}
DragImageRef WebDragClient::createDragImageForLink(KURL& url, const String& title, Frame* frame)
......
......@@ -1317,7 +1317,6 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
knownRegions = (
English,
......@@ -1332,7 +1331,6 @@
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
shouldCheckCompatibility = 1;
targets = (
9398100A0824BF01008DF038 /* WebKit */,
);
......
......@@ -70,6 +70,8 @@
#import <AppKit/NSAccessibility.h>
#import <ApplicationServices/ApplicationServices.h>
#import <dlfcn.h>
#import <WebCore/CachedImage.h>
#import <WebCore/CachedResourceClient.h>
#import <WebCore/ContextMenuController.h>
#import <WebCore/Document.h>
#import <WebCore/Editor.h>
......@@ -86,7 +88,6 @@
#import <WebCore/FrameView.h>
#import <WebCore/HitTestResult.h>
#import <WebCore/HTMLNames.h>
#import <WebCore/HTMLImageElement.h>
#import <WebCore/Image.h>
#import <WebCore/KeyboardEvent.h>
#import <WebCore/MimeTypeRegistry.h>
......@@ -94,7 +95,6 @@
#import <WebCore/PlatformKeyboardEvent.h>
#import <WebCore/PlatformMouseEvent.h>
#import <WebCore/Range.h>
#import <WebCore/RenderImage.h>
#import <WebCore/SelectionController.h>
#import <WebCore/SharedBuffer.h>
#import <WebCore/WebCoreObjCExtras.h>
......@@ -221,6 +221,9 @@ static BOOL forceWebHTMLViewHitTest;
static WebHTMLView *lastHitView;
// We need this to be able to safely reference the CachedImage for the promised drag data
static CachedResourceClient promisedDataClient;
@interface WebHTMLView (WebTextSizing) <_WebDocumentTextSizing>
@end
......@@ -309,7 +312,8 @@ struct WebHTMLViewInterpretKeyEventsParameters {
[firstResponderTextViewAtMouseDownTime release];
[dataSource release];
[highlighters release];
[promisedDragTIFFDataSource release];
if (promisedDragTIFFDataSource)
promisedDragTIFFDataSource->deref(&promisedDataClient);
[super dealloc];
}
......@@ -323,7 +327,8 @@ struct WebHTMLViewInterpretKeyEventsParameters {
[firstResponderTextViewAtMouseDownTime release];
[dataSource release];
[highlighters release];
[promisedDragTIFFDataSource release];
if (promisedDragTIFFDataSource)
promisedDragTIFFDataSource->deref(&promisedDataClient);
mouseDownEvent = nil;
keyDownEvent = nil;
......@@ -333,7 +338,7 @@ struct WebHTMLViewInterpretKeyEventsParameters {
firstResponderTextViewAtMouseDownTime = nil;
dataSource = nil;
highlighters = nil;
promisedDragTIFFDataSource = nil;
promisedDragTIFFDataSource = 0;
}
@end
......@@ -1292,7 +1297,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
- (void)pasteboardChangedOwner:(NSPasteboard *)pasteboard
{
[self setPromisedDragTIFFDataSource:nil];
[self setPromisedDragTIFFDataSource:0];
}
- (void)pasteboard:(NSPasteboard *)pasteboard provideDataForType:(NSString *)type
......@@ -1302,8 +1307,9 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
[pasteboard _web_writePromisedRTFDFromArchive:archive containsImage:[[pasteboard types] containsObject:NSTIFFPboardType]];
[archive release];
} else if ([type isEqual:NSTIFFPboardType] && [self promisedDragTIFFDataSource]) {
[pasteboard setData:[[self promisedDragTIFFDataSource] _imageTIFFRepresentation] forType:NSTIFFPboardType];
[self setPromisedDragTIFFDataSource:nil];
if (Image* image = [self promisedDragTIFFDataSource]->image())
[pasteboard setData:(NSData *)image->getTIFFRepresentation() forType:NSTIFFPboardType];
[self setPromisedDragTIFFDataSource:0];
}
}
......@@ -1763,19 +1769,6 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart)
return nil;
}
- (DOMElement *)promisedDragTIFFDataSource
{
return _private->promisedDragTIFFDataSource;
}
- (void)setPromisedDragTIFFDataSource:(DOMElement *)source
{
[source retain];
if (_private->promisedDragTIFFDataSource)
[_private->promisedDragTIFFDataSource release];
_private->promisedDragTIFFDataSource = source;
}
@end
@implementation NSView (WebHTMLViewFileInternal)
......@@ -2936,22 +2929,14 @@ done:
{
NSFileWrapper *wrapper = nil;
if (DOMElement *tiffSource = [self promisedDragTIFFDataSource]) {
Element *element = core(tiffSource);
if (!element->hasTagName(imgTag))
goto noPromisedData;
if (WebCore::CachedResource* tiffResource = [self promisedDragTIFFDataSource]) {
HTMLImageElement *imageElement = static_cast<HTMLImageElement *>(element);
if (!imageElement->cachedImage() || imageElement->cachedImage()->errorOccurred())
goto noPromisedData;
CachedResource *resource = imageElement->cachedImage();
SharedBuffer *buffer = resource->data();
SharedBuffer *buffer = tiffResource->data();
if (!buffer)
goto noPromisedData;
NSData *data = buffer->createNSData();
NSURLResponse *response = resource->response().nsURLResponse();
NSURLResponse *response = tiffResource->response().nsURLResponse();
wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease];
[wrapper setPreferredFilename:[response suggestedFilename]];
......@@ -5203,6 +5188,21 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
return parameters.eventWasHandled;
}
- (WebCore::CachedImage*)promisedDragTIFFDataSource
{
return _private->promisedDragTIFFDataSource;
}
- (void)setPromisedDragTIFFDataSource:(WebCore::CachedImage*)source
{
if (source)
source->ref(&promisedDataClient);
if (_private->promisedDragTIFFDataSource)
_private->promisedDragTIFFDataSource->deref(&promisedDataClient);
_private->promisedDragTIFFDataSource = source;
}
@end
@implementation WebHTMLView (WebNSTextInputSupport)
......
......@@ -36,6 +36,7 @@
namespace WebCore {
class KeyboardEvent;
class CachedImage;
}
struct WebHTMLViewInterpretKeyEventsParameters;
......@@ -90,7 +91,7 @@ struct WebHTMLViewInterpretKeyEventsParameters;
NSTextView *firstResponderTextViewAtMouseDownTime;
WebDataSource *dataSource;
DOMElement *promisedDragTIFFDataSource;
WebCore::CachedImage *promisedDragTIFFDataSource;
}
- (void)clear;
@end
......@@ -120,5 +121,7 @@ struct WebHTMLViewInterpretKeyEventsParameters;
- (void)setGrammarCheckingEnabled:(BOOL)flag;
- (void)toggleGrammarChecking:(id)sender;
#endif
- (WebCore::CachedImage*)promisedDragTIFFDataSource;
- (void)setPromisedDragTIFFDataSource:(WebCore::CachedImage*)source;
@end
......@@ -37,7 +37,7 @@
@class WebView;
@class WebFrame;
@class WebPluginController;
@protocol WebHTMLHighlighter
- (NSRect)highlightRectForLine:(NSRect)lineRect representedNode:(DOMNode *)node;
- (void)paintHighlightForBox:(NSRect)boxRect onLine:(NSRect)lineRect behindText:(BOOL)text entireLine:(BOOL)line representedNode:(DOMNode *)node;
......@@ -122,7 +122,4 @@
- (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue;
- (BOOL)markedTextMatchesAreHighlighted;
- (NSArray *)rectsForTextMatches;
- (DOMElement *)promisedDragTIFFDataSource;
- (void)setPromisedDragTIFFDataSource:(DOMElement *)source;
@end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment