Skip to content

Commit 7503af2

Browse files
lapcatrentzsch
authored andcommitted
Fix hang when loading Walmart pages.
Signed-off-by: Jonathan 'Wolf' Rentzsch <[email protected]>
1 parent ef7824b commit 7503af2

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

Plugin/Plugin.m

+25-15
Original file line numberDiff line numberDiff line change
@@ -268,22 +268,26 @@ - (id) initWithArguments:(NSDictionary *)arguments
268268
// visible, and then restore the original attributes so that we don't
269269
// have any display issues once the Flash view is loaded
270270

271-
// currently it only changes opacity for the CtF view and its immediate
272-
// parent, but opacity could still be applied further up the line
271+
// Should we apply this to the parent?
272+
// That seems to be problematic.
273273

274274
NSMutableDictionary *originalOpacityDict = [NSMutableDictionary dictionary];
275-
[originalOpacityDict setObject:[self.container getAttribute:@"wmode"] forKey:@"wmode"];
276-
[originalOpacityDict setObject:[self.container getAttribute:@"style"] forKey:@"self-style"];
277-
[originalOpacityDict setObject:[(DOMElement *)[self.container parentNode] getAttribute:@"style"] forKey:@"parent-style"];
278-
self.originalOpacityAttributes = originalOpacityDict;
279-
280275
NSString *opacityResetString = @"; opacity: 1.000 !important; -moz-opacity: 1 !important; filter: alpha(opacity=1) !important;";
281-
NSString *newSelfStyleString = [[self.originalOpacityAttributes objectForKey:@"self-style"] stringByAppendingString:opacityResetString];
282-
NSString *newParentStyleString = [[self.originalOpacityAttributes objectForKey:@"parent-style"] stringByAppendingString:opacityResetString];
283276

284-
[self.container setAttribute:@"wmode" value:@"opaque"];
285-
[self.container setAttribute:@"style" value:newSelfStyleString];
286-
[(DOMElement *)[self.container parentNode] setAttribute:@"style" value:newParentStyleString];
277+
NSString *originalWmode = [self.container getAttribute:@"wmode"];
278+
NSString *originalStyle = [self.container getAttribute:@"style"];
279+
280+
if (originalWmode != nil && [originalWmode length] > 0u && ![originalWmode isEqualToString:@"opaque"]) {
281+
[originalOpacityDict setObject:originalWmode forKey:@"wmode"];
282+
[self.container setAttribute:@"wmode" value:@"opaque"];
283+
}
284+
285+
if (originalStyle != nil && [originalStyle length] > 0u && ![originalStyle hasSuffix:opacityResetString]) {
286+
[originalOpacityDict setObject:originalStyle forKey:@"self-style"];
287+
[self.container setAttribute:@"style" value:[originalStyle stringByAppendingString:opacityResetString]];
288+
}
289+
290+
self.originalOpacityAttributes = originalOpacityDict;
287291
}
288292

289293
return self;
@@ -933,9 +937,15 @@ - (void) _prepareForConversion
933937

934938
- (void) _revertToOriginalOpacityAttributes
935939
{
936-
[self.container setAttribute:@"wmode" value:[self.originalOpacityAttributes objectForKey:@"wmode"]];
937-
[self.container setAttribute:@"style" value:[self.originalOpacityAttributes objectForKey:@"self-style"]];
938-
[(DOMElement *)[self.container parentNode] setAttribute:@"style" value:[self.originalOpacityAttributes objectForKey:@"parent-style"]];
940+
NSString *wmode = [self.originalOpacityAttributes objectForKey:@"wmode"];
941+
if (wmode != nil ) {
942+
[self.container setAttribute:@"wmode" value:wmode];
943+
}
944+
945+
NSString *selfStyle = [self.originalOpacityAttributes objectForKey:@"self-style"];
946+
if (selfStyle != nil ) {
947+
[self.container setAttribute:@"style" value:selfStyle];
948+
}
939949
}
940950

941951
@synthesize webView = _webView;

0 commit comments

Comments
 (0)