Changeset 18910 in webkit
- Timestamp:
- Jan 17, 2007, 10:45:57 AM (18 years ago)
- Location:
- trunk/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/ChangeLog
r18903 r18910 1 2007-01-17 Anders Carlsson <acarlsson@apple.com> 2 3 Reviewed by John Sullivan. 4 5 Move all code in WebNetscapePluginEmbeddedView down to WebBaseNetscapePluginView. 6 7 * Plugins/WebBaseNetscapePluginView.h: 8 * Plugins/WebBaseNetscapePluginView.mm: 9 (-[WebBaseNetscapePluginView initWithFrame:pluginPackage:URL:baseURL:MIMEType:attributeKeys:attributeValues:loadManually:DOMElement:]): 10 (-[WebBaseNetscapePluginView didStart]): 11 (-[WebBaseNetscapePluginView dataSource]): 12 (-[WebBaseNetscapePluginView dealloc]): 13 (-[WebBaseNetscapePluginView pluginView:receivedResponse:]): 14 (-[WebBaseNetscapePluginView pluginView:receivedData:]): 15 (-[WebBaseNetscapePluginView pluginView:receivedError:]): 16 (-[WebBaseNetscapePluginView pluginViewFinishedLoading:]): 17 (-[WebBaseNetscapePluginView _redeliverStream]): 18 * Plugins/WebNetscapePluginEmbeddedView.h: 19 * Plugins/WebNetscapePluginEmbeddedView.mm: 20 1 21 2007-01-17 Maciej Stachowiak <mjs@apple.com> 2 22 -
trunk/WebKit/Plugins/WebBaseNetscapePluginView.h
r18420 r18910 32 32 #import <WebKit/npfunctions.h> 33 33 #import <WebKit/npapi.h> 34 #import <WebKit/WebBasePluginPackage.h> 34 35 35 36 @class DOMElement; … … 38 39 @class WebNetscapePluginPackage; 39 40 @class WebNetscapePluginNullEventSender; 41 @class WebNetscapePluginStream; 40 42 @class WebView; 41 43 … … 48 50 } PluginPort; 49 51 50 @interface WebBaseNetscapePluginView : NSView 52 @interface WebBaseNetscapePluginView : NSView <WebPluginManualLoader> 51 53 { 52 54 WebNetscapePluginPackage *pluginPackage; 55 56 NSURL *sourceURL; 57 WebFrame *_webFrame; 58 59 BOOL _loadManually; 60 WebNetscapePluginStream *_manualStream; 61 unsigned _dataLengthReceived; 62 NSError *_error; 53 63 54 64 int mode; … … 110 120 + (WebBaseNetscapePluginView *)currentPluginView; 111 121 122 123 - (id)initWithFrame:(NSRect)r 124 pluginPackage:(WebNetscapePluginPackage *)thePluginPackage 125 URL:(NSURL *)URL 126 baseURL:(NSURL *)baseURL 127 MIMEType:(NSString *)MIME 128 attributeKeys:(NSArray *)keys 129 attributeValues:(NSArray *)values 130 loadManually:(BOOL)loadManually 131 DOMElement:(DOMElement *)anElement; 132 133 112 134 - (BOOL)start; 113 135 - (BOOL)isStarted; -
trunk/WebKit/Plugins/WebBaseNetscapePluginView.mm
r18441 r18910 51 51 #import <JavaScriptCore/Assertions.h> 52 52 #import <JavaScriptCore/npruntime_impl.h> 53 #import <WebCore/Document.h> 54 #import <WebCore/Element.h> 53 55 #import <WebCore/FrameLoader.h> 54 56 #import <WebCore/FrameMac.h> … … 83 85 - (void)_hideAGLWindow; 84 86 - (NSImage *)_aglOffscreenImageForDrawingInRect:(NSRect)drawingInRect; 87 - (void)_redeliverStream; 85 88 @end 86 89 … … 140 143 @interface WebBaseNetscapePluginView (ForwardDeclarations) 141 144 - (void)setWindowIfNecessary; 145 - (NPError)loadRequest:(NSMutableURLRequest *)request inTarget:(const char *)cTarget withNotifyData:(void *)notifyData sendNotification:(BOOL)sendNotification; 142 146 @end 143 147 144 148 @implementation WebBaseNetscapePluginView 149 150 - (id)initWithFrame:(NSRect)frame 151 pluginPackage:(WebNetscapePluginPackage *)thePluginPackage 152 URL:(NSURL *)theURL 153 baseURL:(NSURL *)theBaseURL 154 MIMEType:(NSString *)MIME 155 attributeKeys:(NSArray *)keys 156 attributeValues:(NSArray *)values 157 loadManually:(BOOL)loadManually 158 DOMElement:(DOMElement *)anElement 159 { 160 [super initWithFrame:frame]; 161 162 // load the plug-in if it is not already loaded 163 if (![thePluginPackage load]) { 164 [self release]; 165 return nil; 166 } 167 [self setPluginPackage:thePluginPackage]; 168 169 element = [anElement retain]; 170 171 sourceURL = [theURL retain]; 172 173 [self setMIMEType:MIME]; 174 [self setBaseURL:theBaseURL]; 175 [self setAttributeKeys:keys andValues:values]; 176 if (loadManually) 177 [self setMode:NP_FULL]; 178 else 179 [self setMode:NP_EMBED]; 180 181 _loadManually = loadManually; 182 183 return self; 184 } 145 185 146 186 + (void)initialize … … 1156 1196 - (void)didStart 1157 1197 { 1158 // Do nothing. Overridden by subclasses. 1198 if (_loadManually) { 1199 [self _redeliverStream]; 1200 return; 1201 } 1202 1203 // If the OBJECT/EMBED tag has no SRC, the URL is passed to us as "". 1204 // Check for this and don't start a load in this case. 1205 if (sourceURL != nil && ![sourceURL _web_isEmpty]) { 1206 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:sourceURL]; 1207 [request _web_setHTTPReferrer:core([self webFrame])->loader()->outgoingReferrer()]; 1208 [self loadRequest:request inTarget:nil withNotifyData:nil sendNotification:NO]; 1209 } 1159 1210 } 1160 1211 … … 1312 1363 - (WebDataSource *)dataSource 1313 1364 { 1314 // Do nothing. Overridden by subclasses.1315 return nil;1365 WebFrame *webFrame = kit(core(element)->document()->frame()); 1366 return [webFrame dataSource]; 1316 1367 } 1317 1368 … … 1451 1502 ASSERT(!isStarted); 1452 1503 1504 [sourceURL release]; 1505 [_manualStream release]; 1506 [_error release]; 1507 1453 1508 [pluginPackage release]; 1454 1509 [streams release]; … … 1731 1786 [self stop]; 1732 1787 } 1788 } 1789 1790 -(void)pluginView:(NSView *)pluginView receivedResponse:(NSURLResponse *)response 1791 { 1792 ASSERT(_loadManually); 1793 ASSERT(!_manualStream); 1794 1795 _manualStream = [[WebNetscapePluginStream alloc] init]; 1796 } 1797 1798 - (void)pluginView:(NSView *)pluginView receivedData:(NSData *)data 1799 { 1800 ASSERT(_loadManually); 1801 ASSERT(_manualStream); 1802 1803 _dataLengthReceived += [data length]; 1804 1805 if (![self isStarted]) 1806 return; 1807 1808 if ([_manualStream plugin] == NULL) { 1809 [_manualStream setRequestURL:[[[self dataSource] request] URL]]; 1810 [_manualStream setPlugin:[self plugin]]; 1811 ASSERT([_manualStream plugin]); 1812 [_manualStream startStreamWithResponse:[[self dataSource] response]]; 1813 } 1814 1815 if ([_manualStream plugin]) 1816 [_manualStream receivedData:data]; 1817 } 1818 1819 - (void)pluginView:(NSView *)pluginView receivedError:(NSError *)error 1820 { 1821 ASSERT(_loadManually); 1822 1823 [error retain]; 1824 [_error release]; 1825 _error = error; 1826 1827 if (![self isStarted]) { 1828 return; 1829 } 1830 1831 [_manualStream destroyStreamWithError:error]; 1832 } 1833 1834 - (void)pluginViewFinishedLoading:(NSView *)pluginView 1835 { 1836 ASSERT(_loadManually); 1837 ASSERT(_manualStream); 1838 1839 if ([self isStarted]) 1840 [_manualStream finishedLoadingWithData:[[self dataSource] data]]; 1733 1841 } 1734 1842 … … 2821 2929 } 2822 2930 2931 - (void)_redeliverStream 2932 { 2933 if ([self dataSource] && [self isStarted]) { 2934 // Deliver what has not been passed to the plug-in up to this point. 2935 if (_dataLengthReceived > 0) { 2936 NSData *data = [[[self dataSource] data] subdataWithRange:NSMakeRange(0, _dataLengthReceived)]; 2937 _dataLengthReceived = 0; 2938 [self pluginView:self receivedData:data]; 2939 if (![[self dataSource] isLoading]) { 2940 if (_error) 2941 [self pluginView:self receivedError:_error]; 2942 else 2943 [self pluginViewFinishedLoading:self]; 2944 } 2945 } 2946 } 2947 } 2948 2823 2949 @end 2824 2950 -
trunk/WebKit/Plugins/WebNetscapePluginEmbeddedView.h
r18430 r18910 30 30 31 31 #import <WebKit/WebBaseNetscapePluginView.h> 32 #import <WebKit/WebBasePluginPackage.h>33 32 34 33 @class WebFrame; 35 34 @class WebNetscapePluginStream; 36 35 37 @interface WebNetscapePluginEmbeddedView : WebBaseNetscapePluginView <WebPluginManualLoader>36 @interface WebNetscapePluginEmbeddedView : WebBaseNetscapePluginView 38 37 { 39 NSURL *URL;40 WebFrame *_webFrame;41 42 BOOL _loadManually;43 WebNetscapePluginStream *_manualStream;44 unsigned _dataLengthReceived;45 NSError *_error;46 38 } 47 48 - (id)initWithFrame:(NSRect)r49 pluginPackage:(WebNetscapePluginPackage *)thePluginPackage50 URL:(NSURL *)URL51 baseURL:(NSURL *)baseURL52 MIMEType:(NSString *)MIME53 attributeKeys:(NSArray *)keys54 attributeValues:(NSArray *)values55 loadManually:(BOOL)loadManually56 DOMElement:(DOMElement *)anElement;57 58 - (void)redeliverStream;59 60 39 @end -
trunk/WebKit/Plugins/WebNetscapePluginEmbeddedView.mm
r18725 r18910 42 42 #import "WebView.h" 43 43 #import <JavaScriptCore/Assertions.h> 44 #import <WebCore/Document.h>45 #import <WebCore/Element.h>46 44 #import <WebCore/FrameMac.h> 47 45 #import <WebCore/FrameLoader.h> … … 49 47 @implementation WebNetscapePluginEmbeddedView 50 48 51 - (id)initWithFrame:(NSRect)frame52 pluginPackage:(WebNetscapePluginPackage *)thePluginPackage53 URL:(NSURL *)theURL54 baseURL:(NSURL *)theBaseURL55 MIMEType:(NSString *)MIME56 attributeKeys:(NSArray *)keys57 attributeValues:(NSArray *)values58 loadManually:(BOOL)loadManually59 DOMElement:(DOMElement *)anElement60 {61 [super initWithFrame:frame];62 63 // load the plug-in if it is not already loaded64 if (![thePluginPackage load]) {65 [self release];66 return nil;67 }68 [self setPluginPackage:thePluginPackage];69 70 element = [anElement retain];71 72 URL = [theURL retain];73 74 [self setMIMEType:MIME];75 [self setBaseURL:theBaseURL];76 [self setAttributeKeys:keys andValues:values];77 if (loadManually)78 [self setMode:NP_FULL];79 else80 [self setMode:NP_EMBED];81 82 _loadManually = loadManually;83 84 return self;85 }86 87 - (void)dealloc88 {89 [URL release];90 [_manualStream release];91 [_error release];92 [super dealloc];93 }94 95 - (void)didStart96 {97 if (_loadManually) {98 [self redeliverStream];99 return;100 }101 102 // If the OBJECT/EMBED tag has no SRC, the URL is passed to us as "".103 // Check for this and don't start a load in this case.104 if (URL != nil && ![URL _web_isEmpty]) {105 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];106 [request _web_setHTTPReferrer:core([self webFrame])->loader()->outgoingReferrer()];107 [self loadRequest:request inTarget:nil withNotifyData:nil sendNotification:NO];108 }109 }110 111 - (WebDataSource *)dataSource112 {113 WebFrame *webFrame = kit(core(element)->document()->frame());114 return [webFrame dataSource];115 }116 117 -(void)pluginView:(NSView *)pluginView receivedResponse:(NSURLResponse *)response118 {119 ASSERT(_loadManually);120 ASSERT(!_manualStream);121 122 _manualStream = [[WebNetscapePluginStream alloc] init];123 }124 125 - (void)pluginView:(NSView *)pluginView receivedData:(NSData *)data126 {127 ASSERT(_loadManually);128 ASSERT(_manualStream);129 130 _dataLengthReceived += [data length];131 132 if (![self isStarted])133 return;134 135 if ([_manualStream plugin] == NULL) {136 [_manualStream setRequestURL:[[[self dataSource] request] URL]];137 [_manualStream setPlugin:[self plugin]];138 ASSERT([_manualStream plugin]);139 [_manualStream startStreamWithResponse:[[self dataSource] response]];140 }141 142 if ([_manualStream plugin])143 [_manualStream receivedData:data];144 }145 146 - (void)pluginView:(NSView *)pluginView receivedError:(NSError *)error147 {148 ASSERT(_loadManually);149 150 [error retain];151 [_error release];152 _error = error;153 154 if (![self isStarted]) {155 return;156 }157 158 [_manualStream destroyStreamWithError:error];159 }160 161 - (void)pluginViewFinishedLoading:(NSView *)pluginView162 {163 ASSERT(_loadManually);164 ASSERT(_manualStream);165 166 if ([self isStarted])167 [_manualStream finishedLoadingWithData:[[self dataSource] data]];168 }169 170 - (void)redeliverStream171 {172 if ([self dataSource] && [self isStarted]) {173 // Deliver what has not been passed to the plug-in up to this point.174 if (_dataLengthReceived > 0) {175 NSData *data = [[[self dataSource] data] subdataWithRange:NSMakeRange(0, _dataLengthReceived)];176 _dataLengthReceived = 0;177 [self pluginView:self receivedData:data];178 if (![[self dataSource] isLoading]) {179 if (_error)180 [self pluginView:self receivedError:_error];181 else182 [self pluginViewFinishedLoading:self];183 }184 }185 }186 }187 188 49 @end
Note:
See TracChangeset
for help on using the changeset viewer.