2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-04-21 01:39:52 +04:00
|
|
|
|
1999-04-21 01:43:09 +04:00
|
|
|
#ifndef nsSliderFrame_h__
|
|
|
|
#define nsSliderFrame_h__
|
1999-04-21 01:39:52 +04:00
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2008-02-15 05:04:34 +03:00
|
|
|
#include "nsRepeatService.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsBoxFrame.h"
|
1999-04-21 01:39:52 +04:00
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2002-09-07 09:38:16 +04:00
|
|
|
#include "nsITimer.h"
|
2011-06-28 21:59:14 +04:00
|
|
|
#include "nsIDOMEventListener.h"
|
1999-04-21 01:39:52 +04:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
class nsITimer;
|
2000-04-26 08:00:29 +04:00
|
|
|
class nsSliderFrame;
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsIFrame* NS_NewSliderFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
1999-04-21 01:39:52 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsSliderMediator final : public nsIDOMEventListener
|
2000-04-26 08:00:29 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
nsSliderFrame* mSlider;
|
|
|
|
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsSliderMediator(nsSliderFrame* aSlider) { mSlider = aSlider; }
|
2000-04-26 08:00:29 +04:00
|
|
|
|
|
|
|
virtual void SetSlider(nsSliderFrame* aSlider) { mSlider = aSlider; }
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
|
2014-06-24 02:40:01 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsSliderMediator() {}
|
2008-02-15 05:04:34 +03:00
|
|
|
};
|
2000-04-26 08:00:29 +04:00
|
|
|
|
|
|
|
class nsSliderFrame : public nsBoxFrame
|
1999-04-21 01:39:52 +04:00
|
|
|
{
|
|
|
|
public:
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2014-02-05 05:30:34 +04:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsSliderFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2003-09-14 05:25:04 +04:00
|
|
|
friend class nsSliderMediator;
|
|
|
|
|
2015-01-06 12:27:56 +03:00
|
|
|
explicit nsSliderFrame(nsStyleContext* aContext);
|
1999-08-20 02:16:23 +04:00
|
|
|
virtual ~nsSliderFrame();
|
1999-04-21 01:39:52 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override {
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SliderFrame"), aResult);
|
1999-04-21 01:39:52 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 07:28:31 +03:00
|
|
|
virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 07:28:31 +03:00
|
|
|
virtual nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 07:28:35 +03:00
|
|
|
NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState) override;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
// nsIFrame overrides
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
|
1999-08-29 14:51:15 +04:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override;
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 12:36:33 +04:00
|
|
|
nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aModType) override;
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* asPrevInFlow) override;
|
1999-06-15 08:02:43 +04:00
|
|
|
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult HandleEvent(nsPresContext* aPresContext,
|
2014-02-18 12:36:33 +04:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsEventStatus* aEventStatus) override;
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2007-05-25 14:09:29 +04:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
// nsContainerFrame overrides
|
|
|
|
virtual void SetInitialChildList(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aChildList) override;
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void AppendFrames(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override;
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void InsertFrames(ChildListID aListID,
|
|
|
|
nsIFrame* aPrevFrame,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override;
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void RemoveFrame(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aOldFrame) override;
|
2014-05-28 23:36:58 +04:00
|
|
|
|
2012-07-09 20:55:35 +04:00
|
|
|
nsresult StartDrag(nsIDOMEvent* aEvent);
|
2014-08-04 09:00:00 +04:00
|
|
|
nsresult StopDrag();
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2015-12-09 07:05:13 +03:00
|
|
|
bool StartAPZDrag();
|
2015-09-29 00:00:25 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t GetCurrentPosition(nsIContent* content);
|
|
|
|
static int32_t GetMinPosition(nsIContent* content);
|
|
|
|
static int32_t GetMaxPosition(nsIContent* content);
|
|
|
|
static int32_t GetIncrement(nsIContent* content);
|
|
|
|
static int32_t GetPageIncrement(nsIContent* content);
|
|
|
|
static int32_t GetIntegerAttribute(nsIContent* content, nsIAtom* atom, int32_t defaultValue);
|
2000-03-31 11:02:06 +04:00
|
|
|
void EnsureOrient();
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD HandlePress(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsEventStatus* aEventStatus) override;
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aControlHeld) override
|
2013-10-02 07:46:03 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2011-08-03 07:39:02 +04:00
|
|
|
NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsEventStatus* aEventStatus) override
|
2013-10-02 07:46:03 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-08-03 07:39:02 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsEventStatus* aEventStatus) override;
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2015-04-13 06:03:02 +03:00
|
|
|
// Return the ratio the scrollbar thumb should move in proportion to the
|
|
|
|
// scrolled frame.
|
|
|
|
float GetThumbRatio() const;
|
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
private:
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetScrollToClick();
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* GetScrollbar();
|
2013-10-02 07:46:03 +04:00
|
|
|
bool ShouldScrollForEvent(mozilla::WidgetGUIEvent* aEvent);
|
|
|
|
bool ShouldScrollToClickForEvent(mozilla::WidgetGUIEvent* aEvent);
|
|
|
|
bool IsEventOverThumb(mozilla::WidgetGUIEvent* aEvent);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2007-04-10 02:39:57 +04:00
|
|
|
void PageUpDown(nscoord change);
|
2011-09-29 10:19:26 +04:00
|
|
|
void SetCurrentThumbPosition(nsIContent* aScrollbar, nscoord aNewPos, bool aIsSmooth,
|
2013-02-27 01:26:41 +04:00
|
|
|
bool aMaySnap);
|
|
|
|
void SetCurrentPosition(nsIContent* aScrollbar, int32_t aNewPos, bool aIsSmooth);
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetCurrentPositionInternal(nsIContent* aScrollbar, int32_t pos,
|
2013-02-27 01:26:41 +04:00
|
|
|
bool aIsSmooth);
|
2013-02-27 20:56:00 +04:00
|
|
|
void CurrentPositionChanged();
|
2012-07-09 20:55:35 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
void DragThumb(bool aGrabMouseEvents);
|
1999-06-15 08:02:43 +04:00
|
|
|
void AddListener();
|
|
|
|
void RemoveListener();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isDraggingThumb();
|
1999-06-15 08:02:43 +04:00
|
|
|
|
2008-02-15 05:04:34 +03:00
|
|
|
void StartRepeat() {
|
|
|
|
nsRepeatService::GetInstance()->Start(Notify, this);
|
|
|
|
}
|
|
|
|
void StopRepeat() {
|
|
|
|
nsRepeatService::GetInstance()->Stop(Notify, this);
|
|
|
|
}
|
|
|
|
void Notify();
|
|
|
|
static void Notify(void* aData) {
|
|
|
|
(static_cast<nsSliderFrame*>(aData))->Notify();
|
|
|
|
}
|
2014-02-05 05:30:34 +04:00
|
|
|
void PageScroll(nscoord aChange);
|
2008-02-15 05:04:34 +03:00
|
|
|
|
2009-05-12 14:13:09 +04:00
|
|
|
nsPoint mDestinationPoint;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsSliderMediator> mMediator;
|
2009-05-12 14:13:09 +04:00
|
|
|
|
1999-06-15 08:02:43 +04:00
|
|
|
float mRatio;
|
|
|
|
|
2004-08-28 15:41:02 +04:00
|
|
|
nscoord mDragStart;
|
1999-06-15 08:02:43 +04:00
|
|
|
nscoord mThumbStart;
|
1999-04-21 01:39:52 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mCurPos;
|
1999-06-23 21:00:17 +04:00
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
nscoord mChange;
|
|
|
|
|
2014-08-04 09:00:00 +04:00
|
|
|
bool mDragFinished;
|
|
|
|
|
2009-01-14 21:21:58 +03:00
|
|
|
// true if an attribute change has been caused by the user manipulating the
|
|
|
|
// slider. This allows notifications to tell how a slider's current position
|
|
|
|
// was changed.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mUserChanged;
|
2009-01-14 21:21:58 +03:00
|
|
|
|
2015-10-26 23:06:49 +03:00
|
|
|
// true if we've handed off the scrolling to APZ. This means that we should
|
|
|
|
// ignore scrolling events as the position will be updated by APZ. If we were
|
|
|
|
// to process these events then the scroll position update would conflict
|
|
|
|
// causing the scroll position to jump.
|
|
|
|
bool mScrollingWithAPZ;
|
|
|
|
|
2016-03-18 21:46:54 +03:00
|
|
|
// true if displayport suppression is active, for more performant
|
|
|
|
// scrollbar-dragging behaviour.
|
|
|
|
bool mSuppressionActive;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool gMiddlePref;
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t gSnapMultiplier;
|
1999-04-21 01:43:09 +04:00
|
|
|
}; // class nsSliderFrame
|
1999-04-21 01:39:52 +04:00
|
|
|
|
|
|
|
#endif
|