Bug 1338870 - Don't call [super respondsToSelector:] because it doesn't do what you might think. r=spohl

From https://developer.apple.com/reference/objectivec/1418956-nsobject/1418583-respondstoselector :

> You cannot test whether an object inherits a method from its superclass by
> sending respondsToSelector: to the object using the super keyword. This method
> will still be testing the object as a whole, not just the superclass’s
> implementation. Therefore, sending respondsToSelector: to super is equivalent
> to sending it to self. Instead, you must invoke the NSObject class method
> instancesRespondToSelector: directly on the object’s superclass.

MozReview-Commit-ID: 8wTexCQWUPw

--HG--
extra : rebase_source : f392bfe75c0a5c270b12b0f4ea2abdc6f737d5c2
This commit is contained in:
Markus Stange 2017-02-17 13:21:21 -05:00
parent 4a88679614
commit dacb64b847

View File

@ -3188,7 +3188,9 @@ static const NSString* kStateCollectionBehavior = @"collectionBehavior";
if ([self drawsContentsIntoWindowFrame]) {
return aRect;
}
if ([super respondsToSelector:@selector(contentRectForFrameRect:styleMask:)]) {
// Call the instance method on super, if it exists (it's undocumented so we
// shouldn't rely on it), or fall back to the (documented) class method.
if ([NSWindow instancesRespondToSelector:@selector(contentRectForFrameRect:styleMask:)]) {
return [super contentRectForFrameRect:aRect styleMask:aMask];
} else {
return [NSWindow contentRectForFrameRect:aRect styleMask:aMask];
@ -3208,7 +3210,9 @@ static const NSString* kStateCollectionBehavior = @"collectionBehavior";
if ([self drawsContentsIntoWindowFrame]) {
return aRect;
}
if ([super respondsToSelector:@selector(frameRectForContentRect:styleMask:)]) {
// Call the instance method on super, if it exists (it's undocumented so we
// shouldn't rely on it), or fall back to the (documented) class method.
if ([NSWindow instancesRespondToSelector:@selector(frameRectForContentRect:styleMask:)]) {
return [super frameRectForContentRect:aRect styleMask:aMask];
} else {
return [NSWindow frameRectForContentRect:aRect styleMask:aMask];