Skip to content

Commit

Permalink
CtF view and its immediate parent are given an opacity of 1 to make s…
Browse files Browse the repository at this point in the history
…ure they're visible to the user; original opacity is restored when the Flash view is loaded; opacity could still cause problems if grandparent or further-removed ancestor of CtF view has applied opacity

Signed-off-by: Jonathan 'Wolf' Rentzsch <[email protected]>
  • Loading branch information
Simone Manganelli authored and rentzsch committed Apr 22, 2009
1 parent a1a8669 commit 9687059
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Plugin/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ THE SOFTWARE.
NSUInteger _sifrVersion;
NSString *_baseURL;
NSDictionary *_attributes;
NSDictionary *_originalOpacityAttributes;
}

+ (NSView *)plugInViewWithArguments:(NSDictionary *)arguments;
Expand All @@ -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;
Expand Down
32 changes: 32 additions & 0 deletions Plugin/Plugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ - (void) _convertTypesForFlashContainerAfterDelay;
- (void) _convertToMP4Container;
- (void) _convertToMP4ContainerAfterDelay;
- (void) _prepareForConversion;
- (void) _revertToOriginalOpacityAttributes;

- (void) _drawBackground;
- (BOOL) _isOptionPressed;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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

0 comments on commit 9687059

Please sign in to comment.