зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1096093 - Have Cocoa widget backend cache overlay scrollbar metrics. r=mstange.
--HG-- extra : rebase_source : 04640fed0ff75c70950be7d81285b64bdf220a1c
This commit is contained in:
Родитель
e21dde0949
Коммит
e7c7c23dcb
|
@ -26,6 +26,10 @@ public:
|
|||
|
||||
static bool UseOverlayScrollbars();
|
||||
|
||||
virtual nsTArray<LookAndFeelInt> GetIntCacheImpl();
|
||||
virtual void SetIntCacheImpl(const nsTArray<LookAndFeelInt>& lookAndFeelIntCache);
|
||||
|
||||
virtual void RefreshImpl();
|
||||
protected:
|
||||
|
||||
// Apple hasn't defined a constant for scollbars with two arrows on each end, so we'll use this one.
|
||||
|
@ -34,6 +38,13 @@ protected:
|
|||
|
||||
static bool SystemWantsOverlayScrollbars();
|
||||
static bool AllowOverlayScrollbarsOverlap();
|
||||
|
||||
private:
|
||||
int32_t mUseOverlayScrollbars;
|
||||
bool mUseOverlayScrollbarsCached;
|
||||
|
||||
int32_t mAllowOverlayScrollbarsOverlap;
|
||||
bool mAllowOverlayScrollbarsOverlapCached;
|
||||
};
|
||||
|
||||
#endif // nsLookAndFeel_h_
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "gfxFont.h"
|
||||
#include "gfxFontConstants.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/widget/WidgetMessageUtils.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
@ -28,7 +29,12 @@ typedef NSInteger mozNSScrollerStyle;
|
|||
+ (mozNSScrollerStyle)preferredScrollerStyle;
|
||||
@end
|
||||
|
||||
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
|
||||
nsLookAndFeel::nsLookAndFeel()
|
||||
: nsXPLookAndFeel()
|
||||
, mUseOverlayScrollbars(-1)
|
||||
, mUseOverlayScrollbarsCached(false)
|
||||
, mAllowOverlayScrollbarsOverlap(-1)
|
||||
, mAllowOverlayScrollbarsOverlapCached(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -359,10 +365,18 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
|
|||
aResult = eScrollThumbStyle_Proportional;
|
||||
break;
|
||||
case eIntID_UseOverlayScrollbars:
|
||||
aResult = SystemWantsOverlayScrollbars() ? 1 : 0;
|
||||
if (!mUseOverlayScrollbarsCached) {
|
||||
mUseOverlayScrollbars = SystemWantsOverlayScrollbars() ? 1 : 0;
|
||||
mUseOverlayScrollbarsCached = true;
|
||||
}
|
||||
aResult = mUseOverlayScrollbars;
|
||||
break;
|
||||
case eIntID_AllowOverlayScrollbarsOverlap:
|
||||
aResult = AllowOverlayScrollbarsOverlap() ? 1 : 0;
|
||||
if (!mAllowOverlayScrollbarsOverlapCached) {
|
||||
mAllowOverlayScrollbarsOverlap = AllowOverlayScrollbarsOverlap() ? 1 : 0;
|
||||
mAllowOverlayScrollbarsOverlapCached = true;
|
||||
}
|
||||
aResult = mAllowOverlayScrollbarsOverlap;
|
||||
break;
|
||||
case eIntID_ScrollbarDisplayOnMouseMove:
|
||||
aResult = 0;
|
||||
|
@ -633,3 +647,51 @@ nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName,
|
|||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
|
||||
}
|
||||
|
||||
nsTArray<LookAndFeelInt>
|
||||
nsLookAndFeel::GetIntCacheImpl()
|
||||
{
|
||||
nsTArray<LookAndFeelInt> lookAndFeelIntCache =
|
||||
nsXPLookAndFeel::GetIntCacheImpl();
|
||||
|
||||
LookAndFeelInt useOverlayScrollbars;
|
||||
useOverlayScrollbars.id = eIntID_UseOverlayScrollbars;
|
||||
useOverlayScrollbars.value = GetInt(eIntID_UseOverlayScrollbars);
|
||||
lookAndFeelIntCache.AppendElement(useOverlayScrollbars);
|
||||
|
||||
LookAndFeelInt allowOverlayScrollbarsOverlap;
|
||||
allowOverlayScrollbarsOverlap.id = eIntID_AllowOverlayScrollbarsOverlap;
|
||||
allowOverlayScrollbarsOverlap.value = GetInt(eIntID_AllowOverlayScrollbarsOverlap);
|
||||
lookAndFeelIntCache.AppendElement(allowOverlayScrollbarsOverlap);
|
||||
|
||||
return lookAndFeelIntCache;
|
||||
}
|
||||
|
||||
void
|
||||
nsLookAndFeel::SetIntCacheImpl(const nsTArray<LookAndFeelInt>& lookAndFeelIntCache)
|
||||
{
|
||||
for (auto entry : lookAndFeelIntCache) {
|
||||
switch(entry.id) {
|
||||
case eIntID_UseOverlayScrollbars:
|
||||
mUseOverlayScrollbars = entry.value;
|
||||
mUseOverlayScrollbarsCached = true;
|
||||
break;
|
||||
case eIntID_AllowOverlayScrollbarsOverlap:
|
||||
mAllowOverlayScrollbarsOverlap = entry.value;
|
||||
mAllowOverlayScrollbarsOverlapCached = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsLookAndFeel::RefreshImpl()
|
||||
{
|
||||
// We should only clear the cache if we're in the main browser process.
|
||||
// Otherwise, we should wait for the parent to inform us of new values
|
||||
// to cache via LookAndFeel::SetIntCache.
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
mUseOverlayScrollbarsCached = false;
|
||||
mAllowOverlayScrollbarsOverlapCached = false;
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче