Skip to content

Commit

Permalink
Backed out changeset 1f6132caf111 (bug 879565) for warnings-as-errors…
Browse files Browse the repository at this point in the history
… bustage.

CLOSED TREE
  • Loading branch information
rvandermeulen committed Jul 1, 2013
1 parent b42dc41 commit c8b402f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 170 deletions.
119 changes: 36 additions & 83 deletions layout/generic/ScrollbarActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,16 @@
#include "nsAString.h"
#include "nsQueryFrame.h"
#include "nsComponentManagerUtils.h"
#include "mozilla/LookAndFeel.h"

namespace mozilla {
namespace layout {

NS_IMPL_ISUPPORTS1(ScrollbarActivity, nsIDOMEventListener)

void
ScrollbarActivity::QueryLookAndFeelVals()
{
// Fade animation constants
mScrollbarFadeBeginDelay =
LookAndFeel::GetInt(LookAndFeel::eIntID_ScrollbarFadeBeginDelay);
mScrollbarFadeDuration =
LookAndFeel::GetInt(LookAndFeel::eIntID_ScrollbarFadeDuration);
// Controls whether we keep the mouse move listener so we can display the
// scrollbars whenever the user moves the mouse within the scroll area.
mDisplayOnMouseMove =
LookAndFeel::GetInt(LookAndFeel::eIntID_ScrollbarDisplayOnMouseMove);
}

void
ScrollbarActivity::Destroy()
{
StopListeningForEvents(true);
StopListeningForEvents();
UnregisterFromRefreshDriver();
CancelFadeBeginTimer();
}
Expand Down Expand Up @@ -89,7 +74,7 @@ ScrollbarActivity::ActivityStopped()
NS_IMETHODIMP
ScrollbarActivity::HandleEvent(nsIDOMEvent* aEvent)
{
if (!mDisplayOnMouseMove && !mIsActive)
if (!mIsActive)
return NS_OK;

nsAutoString type;
Expand Down Expand Up @@ -168,78 +153,26 @@ ScrollbarActivity::HandleEventForScrollbar(const nsAString& aType,
void
ScrollbarActivity::StartListeningForEvents()
{
StartListeningForScrollbarEvents();
StartListeningForScrollAreaEvents();
}

void
ScrollbarActivity::StopListeningForEvents(bool aIsTeardown)
{
StopListeningForScrollbarEvents();
StopListeningForScrollAreaEvents(aIsTeardown);
}

void
ScrollbarActivity::StartListeningForScrollbarEvents()
{
if (mListeningForScrollbarEvents)
if (mListeningForEvents)
return;

nsIFrame* scrollArea = do_QueryFrame(mScrollableFrame);
nsCOMPtr<nsIDOMEventTarget> scrollAreaTarget = do_QueryInterface(
scrollArea->GetContent());
mHorizontalScrollbar = do_QueryInterface(GetHorizontalScrollbar());
mVerticalScrollbar = do_QueryInterface(GetVerticalScrollbar());

AddScrollbarEventListeners(mHorizontalScrollbar);
AddScrollbarEventListeners(mVerticalScrollbar);

mListeningForScrollbarEvents = true;
}

void
ScrollbarActivity::StopListeningForScrollbarEvents()
{
if (!mListeningForScrollAreaEvents)
return;

RemoveScrollbarEventListeners(mHorizontalScrollbar);
RemoveScrollbarEventListeners(mVerticalScrollbar);

mHorizontalScrollbar = nullptr;
mVerticalScrollbar = nullptr;
mListeningForScrollbarEvents = false;
}

void
ScrollbarActivity::StartListeningForScrollAreaEvents()
{
if (mListeningForScrollAreaEvents)
return;

nsIFrame* scrollArea = do_QueryFrame(mScrollableFrame);
nsCOMPtr<nsIDOMEventTarget> scrollAreaTarget
= do_QueryInterface(scrollArea->GetContent());
if (scrollAreaTarget) {
scrollAreaTarget->AddEventListener(NS_LITERAL_STRING("mousemove"), this,
true);
}
mListeningForScrollAreaEvents = true;
StartListeningForEventsOnScrollbar(mHorizontalScrollbar);
StartListeningForEventsOnScrollbar(mVerticalScrollbar);
mListeningForEvents = true;
}

void
ScrollbarActivity::StopListeningForScrollAreaEvents(bool aIsTeardown)
{
if ((mListeningForScrollAreaEvents && !mDisplayOnMouseMove) ||
(mListeningForScrollAreaEvents && mDisplayOnMouseMove && aIsTeardown)) {
nsIFrame* scrollArea = do_QueryFrame(mScrollableFrame);
nsCOMPtr<nsIDOMEventTarget> scrollAreaTarget = do_QueryInterface(scrollArea->GetContent());
if (scrollAreaTarget) {
scrollAreaTarget->RemoveEventListener(NS_LITERAL_STRING("mousemove"), this, true);
}
mListeningForScrollAreaEvents = false;
}
}

void
ScrollbarActivity::AddScrollbarEventListeners(nsIDOMEventTarget* aScrollbar)
ScrollbarActivity::StartListeningForEventsOnScrollbar(nsIDOMEventTarget* aScrollbar)
{
if (aScrollbar) {
aScrollbar->AddEventListener(NS_LITERAL_STRING("mousedown"), this, true);
Expand All @@ -250,7 +183,27 @@ ScrollbarActivity::AddScrollbarEventListeners(nsIDOMEventTarget* aScrollbar)
}

void
ScrollbarActivity::RemoveScrollbarEventListeners(nsIDOMEventTarget* aScrollbar)
ScrollbarActivity::StopListeningForEvents()
{
if (!mListeningForEvents)
return;

nsIFrame* scrollArea = do_QueryFrame(mScrollableFrame);
nsCOMPtr<nsIDOMEventTarget> scrollAreaTarget = do_QueryInterface(scrollArea->GetContent());

if (scrollAreaTarget) {
scrollAreaTarget->RemoveEventListener(NS_LITERAL_STRING("mousemove"), this, true);
}
StopListeningForEventsOnScrollbar(mHorizontalScrollbar);
StopListeningForEventsOnScrollbar(mVerticalScrollbar);

mHorizontalScrollbar = nullptr;
mVerticalScrollbar = nullptr;
mListeningForEvents = false;
}

void
ScrollbarActivity::StopListeningForEventsOnScrollbar(nsIDOMEventTarget* aScrollbar)
{
if (aScrollbar) {
aScrollbar->RemoveEventListener(NS_LITERAL_STRING("mousedown"), this, true);
Expand Down Expand Up @@ -289,7 +242,7 @@ ScrollbarActivity::EndFade()
}
SetIsActive(false);
UnregisterFromRefreshDriver();
StopListeningForEvents(false);
StopListeningForEvents();

NS_ASSERTION(!mIsActive, "should have gone inactive after fade end");
NS_ASSERTION(!mIsFading, "shouldn't be fading anymore");
Expand Down Expand Up @@ -419,11 +372,10 @@ ScrollbarActivity::SetIsFading(bool aNewFading)
void
ScrollbarActivity::StartFadeBeginTimer()
{
if (!mFadeBeginTimer) {
mFadeBeginTimer = do_CreateInstance("@mozilla.org/timer;1");
}
NS_ASSERTION(!mFadeBeginTimer, "timer already alive!");
mFadeBeginTimer = do_CreateInstance("@mozilla.org/timer;1");
mFadeBeginTimer->InitWithFuncCallback(FadeBeginTimerFired, this,
mScrollbarFadeBeginDelay,
kScrollbarFadeBeginDelay,
nsITimer::TYPE_ONE_SHOT);
}

Expand All @@ -432,6 +384,7 @@ ScrollbarActivity::CancelFadeBeginTimer()
{
if (mFadeBeginTimer) {
mFadeBeginTimer->Cancel();
mFadeBeginTimer = nullptr;
}
}

Expand Down
39 changes: 11 additions & 28 deletions layout/generic/ScrollbarActivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,10 @@ class ScrollbarActivity : public nsIDOMEventListener,
, mNestedActivityCounter(0)
, mIsActive(false)
, mIsFading(false)
, mListeningForScrollbarEvents(false)
, mListeningForScrollAreaEvents(false)
, mDisplayOnMouseMove(false)
, mListeningForEvents(false)
, mHScrollbarHovered(false)
, mVScrollbarHovered(false)
, mScrollbarFadeBeginDelay(0)
, mScrollbarFadeDuration(0)
{
QueryLookAndFeelVals();
}
{}

NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER
Expand All @@ -91,12 +85,14 @@ class ScrollbarActivity : public nsIDOMEventListener,
reinterpret_cast<ScrollbarActivity*>(aSelf)->BeginFade();
}

static const uint32_t kScrollbarFadeBeginDelay = 450; // milliseconds
static const uint32_t kScrollbarFadeDuration = 200; // milliseconds

protected:

bool IsActivityOngoing()
{ return mNestedActivityCounter > 0; }
bool IsStillFading(TimeStamp aTime);
void QueryLookAndFeelVals();

void HandleEventForScrollbar(const nsAString& aType,
nsIContent* aTarget,
Expand All @@ -111,17 +107,10 @@ class ScrollbarActivity : public nsIDOMEventListener,

void StartFadeBeginTimer();
void CancelFadeBeginTimer();

void StartListeningForEvents();
void StopListeningForEvents(bool aIsTeardown);

void StartListeningForScrollbarEvents();
void StopListeningForScrollbarEvents();
void StartListeningForScrollAreaEvents();
void StopListeningForScrollAreaEvents(bool aIsTeardown);
void AddScrollbarEventListeners(nsIDOMEventTarget* aScrollbar);
void RemoveScrollbarEventListeners(nsIDOMEventTarget* aScrollbar);

void StartListeningForEventsOnScrollbar(nsIDOMEventTarget* aScrollbar);
void StopListeningForEvents();
void StopListeningForEventsOnScrollbar(nsIDOMEventTarget* aScrollbar);
void RegisterWithRefreshDriver();
void UnregisterFromRefreshDriver();

Expand All @@ -133,8 +122,8 @@ class ScrollbarActivity : public nsIDOMEventListener,
nsIContent* GetHorizontalScrollbar() { return GetScrollbarContent(false); }
nsIContent* GetVerticalScrollbar() { return GetScrollbarContent(true); }

const TimeDuration FadeDuration() {
return TimeDuration::FromMilliseconds(mScrollbarFadeDuration);
static const TimeDuration FadeDuration() {
return TimeDuration::FromMilliseconds(kScrollbarFadeDuration);
}

nsIScrollbarOwner* mScrollableFrame;
Expand All @@ -145,15 +134,9 @@ class ScrollbarActivity : public nsIDOMEventListener,
int mNestedActivityCounter;
bool mIsActive;
bool mIsFading;
bool mListeningForScrollbarEvents;
bool mListeningForScrollAreaEvents;
bool mListeningForEvents;
bool mHScrollbarHovered;
bool mVScrollbarHovered;

// LookAndFeel values we load on creation
bool mDisplayOnMouseMove;
int mScrollbarFadeBeginDelay;
int mScrollbarFadeDuration;
};

} // namespace layout
Expand Down
12 changes: 0 additions & 12 deletions toolkit/themes/windows/global/xulscrollbars.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ scrollbar[orient="vertical"]
-moz-appearance: scrollbartrack-vertical;
}

@media all and (-moz-overlay-scrollbars) {
scrollbar {
position: relative;
z-index: 2147483647;
}

scrollbar:not([active="true"]),
scrollbar[disabled="true"] {
visibility: hidden;
}
}

/* ::::: borders for thumb and buttons ::::: */

thumb,
Expand Down
16 changes: 2 additions & 14 deletions widget/LookAndFeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class LookAndFeel
*/
eIntID_ScrollbarButtonAutoRepeatBehavior,
/**
* Delay before showing a tooltip.
* Dealy before showing a tooltip.
*/
eIntID_TooltipDelay,
/*
Expand All @@ -375,19 +375,7 @@ class LookAndFeel
* home button. Used on gaia to determine whether a home button
* is shown.
*/
eIntID_PhysicalHomeButton,

/*
* Controls whether overlay scrollbars display when the user moves
* the mouse in a scrollable frame.
*/
eIntID_ScrollbarDisplayOnMouseMove,

/*
* Overlay scrollbar animation constants.
*/
eIntID_ScrollbarFadeBeginDelay,
eIntID_ScrollbarFadeDuration
eIntID_PhysicalHomeButton
};

/**
Expand Down
9 changes: 0 additions & 9 deletions widget/cocoa/nsLookAndFeel.mm
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,6 @@ static nscolor GetColorFromNSColor(NSColor* aColor)
case eIntID_AllowOverlayScrollbarsOverlap:
aResult = AllowOverlayScrollbarsOverlap() ? 1 : 0;
break;
case eIntID_ScrollbarDisplayOnMouseMove:
aResult = 0;
break;
case eIntID_ScrollbarFadeBeginDelay:
aResult = 450;
break;
case eIntID_ScrollbarFadeDuration:
aResult = 200;
break;
case eIntID_TreeOpenDelay:
aResult = 1000;
break;
Expand Down
15 changes: 0 additions & 15 deletions widget/windows/nsLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,21 +482,6 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult)
case eIntID_SwipeAnimationEnabled:
aResult = 0;
break;
case eIntID_UseOverlayScrollbars:
aResult = (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro);
break;
case eIntID_AllowOverlayScrollbarsOverlap:
aResult = 0;
break;
case eIntID_ScrollbarDisplayOnMouseMove:
aResult = 1;
break;
case eIntID_ScrollbarFadeBeginDelay:
aResult = 2500;
break;
case eIntID_ScrollbarFadeDuration:
aResult = 350;
break;
default:
aResult = 0;
res = NS_ERROR_FAILURE;
Expand Down
9 changes: 0 additions & 9 deletions widget/xpwidgets/nsXPLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ nsLookAndFeelIntPref nsXPLookAndFeel::sIntPrefs[] =
{ "ui.useOverlayScrollbars",
eIntID_UseOverlayScrollbars,
false, 0 },
{ "ui.scrollbarDisplayOnMouseMove",
eIntID_ScrollbarDisplayOnMouseMove,
false, 0 },
{ "ui.scrollbarFadeBeginDelay",
eIntID_ScrollbarFadeBeginDelay,
false, 0 },
{ "ui.scrollbarFadeDuration",
eIntID_ScrollbarFadeDuration,
false, 0 },
{ "ui.showHideScrollbars",
eIntID_ShowHideScrollbars,
false, 0 },
Expand Down

0 comments on commit c8b402f

Please sign in to comment.