Permalink
Browse files

Re-added feature to change opacity of parent, but with additional che…

…cks that prevent style from being reapplied indefinitely, since changing the style seems to reload the view in older versions of Safari (thanks @lapcat)

Signed-off-by: Jonathan 'Wolf' Rentzsch <jwr.git@redshed.net>
  • Loading branch information...
1 parent 7503af2 commit 74584371bdb1391afb3655b8c3113f5cda5afe0f Simone Manganelli committed with May 2, 2009
Showing with 31 additions and 4 deletions.
  1. +31 −4 Plugin/Plugin.m
View
@@ -271,14 +271,21 @@ - (id) initWithArguments:(NSDictionary *)arguments
// Should we apply this to the parent?
// That seems to be problematic.
+ // well, in my experience w/CSS, to get a layout to work a lot of the
+ // time, you need to create parent objects and apply styles to parents,
+ // so it seemed reasonable to check both self and parent for potential
+ // problems with opacity
+
NSMutableDictionary *originalOpacityDict = [NSMutableDictionary dictionary];
NSString *opacityResetString = @"; opacity: 1.000 !important; -moz-opacity: 1 !important; filter: alpha(opacity=1) !important;";
NSString *originalWmode = [self.container getAttribute:@"wmode"];
NSString *originalStyle = [self.container getAttribute:@"style"];
+ NSString *originalParentWmode = [(DOMElement *)[self.container parentNode] getAttribute:@"wmode"];
+ NSString *originalParentStyle = [(DOMElement *)[self.container parentNode] getAttribute:@"style"];
if (originalWmode != nil && [originalWmode length] > 0u && ![originalWmode isEqualToString:@"opaque"]) {
- [originalOpacityDict setObject:originalWmode forKey:@"wmode"];
+ [originalOpacityDict setObject:originalWmode forKey:@"self-wmode"];
[self.container setAttribute:@"wmode" value:@"opaque"];
}
@@ -287,6 +294,16 @@ - (id) initWithArguments:(NSDictionary *)arguments
[self.container setAttribute:@"style" value:[originalStyle stringByAppendingString:opacityResetString]];
}
+ if (originalParentWmode != nil && [originalParentWmode length] > 0u && ![originalParentWmode isEqualToString:@"opaque"]) {
+ [originalOpacityDict setObject:originalParentWmode forKey:@"parent-wmode"];
+ [(DOMElement *)[self.container parentNode] setAttribute:@"wmode" value:@"opaque"];
+ }
+
+ if (originalParentStyle != nil && [originalParentStyle length] > 0u && ![originalParentStyle hasSuffix:opacityResetString]) {
+ [originalOpacityDict setObject:originalParentStyle forKey:@"parent-style"];
+ [(DOMElement *)[self.container parentNode] setAttribute:@"style" value:[originalParentStyle stringByAppendingString:opacityResetString]];
+ }
+
self.originalOpacityAttributes = originalOpacityDict;
}
@@ -937,15 +954,25 @@ - (void) _prepareForConversion
- (void) _revertToOriginalOpacityAttributes
{
- NSString *wmode = [self.originalOpacityAttributes objectForKey:@"wmode"];
- if (wmode != nil ) {
- [self.container setAttribute:@"wmode" value:wmode];
+ NSString *selfWmode = [self.originalOpacityAttributes objectForKey:@"self-wmode"];
+ if (selfWmode != nil ) {
+ [self.container setAttribute:@"wmode" value:selfWmode];
}
NSString *selfStyle = [self.originalOpacityAttributes objectForKey:@"self-style"];
if (selfStyle != nil ) {
[self.container setAttribute:@"style" value:selfStyle];
}
+
+ NSString *parentWmode = [self.originalOpacityAttributes objectForKey:@"parent-wmode"];
+ if (parentWmode != nil ) {
+ [(DOMElement *)[self.container parentNode] setAttribute:@"wmode" value:parentWmode];
+ }
+
+ NSString *parentStyle = [self.originalOpacityAttributes objectForKey:@"parent-style"];
+ if (parentStyle != nil ) {
+ [(DOMElement *)[self.container parentNode] setAttribute:@"style" value:parentStyle];
+ }
}
@synthesize webView = _webView;

0 comments on commit 7458437

Please sign in to comment.