mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1212527 - Set background color to NSColor before calling showDefinitionForAttributedString on 10.11. r=mstange
When calling showDefinitionforAttributedString on OSX 10.11, it always return error due to the following exception. Exception: decodeObjectForKey: class "TitlebarAndBackgroundColor" not loaded or does not exist So before calling it, we set temporary color value, then restore color after calling it. MozReview-Commit-ID: 1YeY6X1W6AV
This commit is contained in:
parent
ec73f39513
commit
ebcb916262
@ -2880,6 +2880,36 @@ nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent, bool aCanTriggerSwipe
|
||||
}
|
||||
}
|
||||
|
||||
// When using 10.11, calling showDefinitionForAttributedString causes the
|
||||
// following exception on LookupViewService. (rdar://26476091)
|
||||
//
|
||||
// Exception: decodeObjectForKey: class "TitlebarAndBackgroundColor" not
|
||||
// loaded or does not exist
|
||||
//
|
||||
// So we set temporary color that is NSColor before calling it.
|
||||
|
||||
class MOZ_RAII AutoBackgroundSetter final {
|
||||
public:
|
||||
explicit AutoBackgroundSetter(NSView* aView) {
|
||||
if (nsCocoaFeatures::OnElCapitanOrLater() &&
|
||||
[[aView window] isKindOfClass:[ToolbarWindow class]]) {
|
||||
mWindow = (ToolbarWindow*)[aView window];
|
||||
[mWindow setTemporaryBackgroundColor];
|
||||
} else {
|
||||
mWindow = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
~AutoBackgroundSetter() {
|
||||
if (mWindow) {
|
||||
[mWindow restoreBackgroundColor];
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ToolbarWindow* mWindow;
|
||||
};
|
||||
|
||||
void
|
||||
nsChildView::LookUpDictionary(
|
||||
const nsAString& aText,
|
||||
@ -2904,6 +2934,8 @@ nsChildView::LookUpDictionary(
|
||||
pt.y += [font ascender];
|
||||
}
|
||||
}
|
||||
|
||||
AutoBackgroundSetter setter(mView);
|
||||
[mView showDefinitionForAttributedString:attrStr atPoint:pt];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
|
@ -241,6 +241,8 @@ typedef struct _nsCocoaWindowList {
|
||||
- (void)placeFullScreenButton:(NSRect)aRect;
|
||||
- (NSPoint)windowButtonsPositionWithDefaultPosition:(NSPoint)aDefaultPosition;
|
||||
- (NSPoint)fullScreenButtonPositionWithDefaultPosition:(NSPoint)aDefaultPosition;
|
||||
- (void)setTemporaryBackgroundColor;
|
||||
- (void)restoreBackgroundColor;
|
||||
@end
|
||||
|
||||
class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa
|
||||
|
@ -3401,6 +3401,16 @@ static const NSString* kStateCollectionBehavior = @"collectionBehavior";
|
||||
return mBackgroundColor;
|
||||
}
|
||||
|
||||
- (void)setTemporaryBackgroundColor
|
||||
{
|
||||
[super setBackgroundColor:[NSColor whiteColor]];
|
||||
}
|
||||
|
||||
- (void)restoreBackgroundColor
|
||||
{
|
||||
[super setBackgroundColor:mBackgroundColor];
|
||||
}
|
||||
|
||||
- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect
|
||||
{
|
||||
[self setTitlebarNeedsDisplayInRect:aRect sync:NO];
|
||||
|
Loading…
Reference in New Issue
Block a user