Bug 868498: Enable switching between overlay and regular scrollbars without browser restart on Mac OSX. r=roc

This commit is contained in:
Stephen Pohl 2013-07-16 08:58:44 -04:00
Родитель bfc9abde85
Коммит e5abe7e1ae
3 изменённых файлов: 34 добавлений и 6 удалений

Просмотреть файл

@ -726,7 +726,6 @@ GetBrowserRoot(nsIContent* aContent)
return nullptr;
}
NS_IMETHODIMP
nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -736,6 +735,8 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext,
DO_GLOBAL_REFLOW_COUNT("nsHTMLScrollFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
mInner.HandleScrollbarStyleSwitching();
ScrollReflowState state(this, aReflowState);
// sanity check: ensure that if we have no scrollbar, we treat it
// as hidden.
@ -774,10 +775,6 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext,
nsRect oldScrollAreaBounds = mInner.mScrollPort;
nsRect oldScrolledAreaBounds =
mInner.mScrolledFrame->GetScrollableOverflowRectRelativeToParent();
// Adjust to a multiple of device pixels to restore the invariant that
// oldScrollPosition is a multiple of device pixels. This could have been
// thrown out by a zoom change.
nsIntPoint ptDevPx;
nsPoint oldScrollPosition = mInner.GetScrollPosition();
state.mComputedBorder = aReflowState.mComputedBorderPadding -
@ -971,6 +968,23 @@ nsGfxScrollFrameInner::GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState
return GetDesiredScrollbarSizes(aState).LeftRight();
}
void
nsGfxScrollFrameInner::HandleScrollbarStyleSwitching()
{
// Check if we switched between scrollbar styles.
if (mScrollbarActivity &&
LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) == 0) {
mScrollbarActivity->Destroy();
mScrollbarActivity = nullptr;
mOuter->PresContext()->ThemeChanged();
}
else if (!mScrollbarActivity &&
LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) {
mScrollbarActivity = new ScrollbarActivity(do_QueryFrame(mOuter));
mOuter->PresContext()->ThemeChanged();
}
}
nsresult
nsXULScrollFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{

Просмотреть файл

@ -269,6 +269,8 @@ public:
void ScheduleSyntheticMouseMove();
static void ScrollActivityCallback(nsITimer *aTimer, void* anInstance);
void HandleScrollbarStyleSwitching();
// owning references to the nsIAnonymousContentCreator-built content
nsCOMPtr<nsIContent> mHScrollbarContent;
nsCOMPtr<nsIContent> mVScrollbarContent;

Просмотреть файл

@ -2808,7 +2808,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
object:nil];
// TODO: replace the string with the constant once we build with the 10.7 SDK
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(systemMetricsChanged)
selector:@selector(scrollbarSystemMetricChanged)
name:@"NSPreferredScrollerStyleDidChangeNotification"
object:nil];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
@ -2961,6 +2961,18 @@ NSEvent* gLastDragMouseDownEvent = nil;
mGeckoChild->NotifyThemeChanged();
}
- (void)scrollbarSystemMetricChanged
{
[self systemMetricsChanged];
if (mGeckoChild) {
nsIWidgetListener* listener = mGeckoChild->GetWidgetListener();
if (listener) {
listener->GetPresShell()->ReconstructFrames();
}
}
}
- (void)setNeedsPendingDisplay
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;