diff --git a/Plugin/Plugin.h b/Plugin/Plugin.h index ce4aa92c..4da83ae6 100644 --- a/Plugin/Plugin.h +++ b/Plugin/Plugin.h @@ -43,6 +43,7 @@ THE SOFTWARE. NSUInteger _sifrVersion; NSString *_baseURL; NSDictionary *_attributes; + NSDictionary *_originalOpacityAttributes; } + (NSView *)plugInViewWithArguments:(NSDictionary *)arguments; @@ -54,6 +55,7 @@ THE SOFTWARE. @property (nonatomic, retain) WebView *webView; @property (retain) NSString *baseURL; @property (nonatomic, retain) NSDictionary *attributes; +@property (retain) NSDictionary *originalOpacityAttributes; - (IBAction)loadFlash:(id)sender; - (IBAction)loadH264:(id)sender; diff --git a/Plugin/Plugin.m b/Plugin/Plugin.m index c869dcac..ab0018c3 100644 --- a/Plugin/Plugin.m +++ b/Plugin/Plugin.m @@ -50,6 +50,7 @@ - (void) _convertTypesForFlashContainerAfterDelay; - (void) _convertToMP4Container; - (void) _convertToMP4ContainerAfterDelay; - (void) _prepareForConversion; +- (void) _revertToOriginalOpacityAttributes; - (void) _drawBackground; - (BOOL) _isOptionPressed; @@ -221,6 +222,25 @@ - (id) initWithArguments:(NSDictionary *)arguments selector: @selector( _loadInvisibleContentForWindow: ) name: kCTFLoadInvisibleFlashViewsForWindow object: nil ]; + + + // if a Flash view has style attributes that make it transparent, the CtF + // view will similarly be transparent; we want to make it temporarily + // visible, and then restore the original attributes so that we don't + // have any display issues once the Flash view is loaded + + // currently it only changes opacity for the CtF view and its immediate + // parent, but opacity could still be applied further up the line + + NSMutableDictionary *originalOpacityDict = [NSMutableDictionary dictionary]; + [originalOpacityDict setObject:[self.container getAttribute:@"wmode"] forKey:@"wmode"]; + [originalOpacityDict setObject:[self.container getAttribute:@"style"] forKey:@"self-style"]; + [originalOpacityDict setObject:[(DOMElement *)[self.container parentNode] getAttribute:@"style"] forKey:@"parent-style"]; + self.originalOpacityAttributes = originalOpacityDict; + + [self.container setAttribute:@"wmode" value:@"opaque"]; + [self.container setAttribute:@"style" value:@"opacity: 1.000 !important; -moz-opacity: 1 !important; filter: alpha(opacity=1) !important;"]; + [(DOMElement *)[self.container parentNode] setAttribute:@"style" value:@"opacity: 1.000 !important; -moz-opacity: 1 !important; filter: alpha(opacity=1) !important;"]; } return self; @@ -705,6 +725,8 @@ - (void) _convertElementForMP4: (DOMElement*) element - (void) _convertToMP4Container { + [self _revertToOriginalOpacityAttributes]; + // Delay this until the end of the event loop, because it may cause self to be deallocated [self _prepareForConversion]; [self performSelector:@selector(_convertToMP4ContainerAfterDelay) withObject:nil afterDelay:0.0]; @@ -748,6 +770,8 @@ - (void) _convertTypesForContainer - (void) _convertTypesForFlashContainer { + [self _revertToOriginalOpacityAttributes]; + // Delay this until the end of the event loop, because it may cause self to be deallocated [self _prepareForConversion]; [self performSelector:@selector(_convertTypesForFlashContainerAfterDelay) withObject:nil afterDelay:0.0]; @@ -788,10 +812,18 @@ - (void) _prepareForConversion [ self _abortAlert ]; } +- (void) _revertToOriginalOpacityAttributes +{ + [self.container setAttribute:@"wmode" value:[self.originalOpacityAttributes objectForKey:@"wmode"]]; + [self.container setAttribute:@"style" value:[self.originalOpacityAttributes objectForKey:@"self-style"]]; + [(DOMElement *)[self.container parentNode] setAttribute:@"style" value:[self.originalOpacityAttributes objectForKey:@"parent-style"]]; +} + @synthesize webView = _webView; @synthesize container = _container; @synthesize host = _host; @synthesize baseURL = _baseURL; @synthesize attributes = _attributes; +@synthesize originalOpacityAttributes = _originalOpacityAttributes; @end