зеркало из https://github.com/mozilla/gecko-dev.git
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 --HG-- extra : rebase_source : 1bfafdb24f7d6df0ad2552b786b8af84b71cc28a
This commit is contained in:
Родитель
a8515958d7
Коммит
15b6b9d8df
|
@ -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:
|
||||
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];
|
||||
|
|
Загрузка…
Ссылка в новой задаче