2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//
|
|
|
|
// nsScrollbarFrame
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef nsScrollbarFrame_h__
|
|
|
|
#define nsScrollbarFrame_h__
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsBoxFrame.h"
|
|
|
|
|
|
|
|
class nsIScrollbarMediator;
|
|
|
|
|
|
|
|
nsIFrame* NS_NewScrollbarFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
2011-07-11 07:05:09 -07:00
|
|
|
class nsScrollbarFrame : public nsBoxFrame
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsScrollbarFrame(nsIPresShell* aShell, nsStyleContext* aContext):
|
2012-07-30 07:20:58 -07:00
|
|
|
nsBoxFrame(aShell, aContext), mScrollbarMediator(nullptr) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-07-11 07:05:09 -07:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsScrollbarFrame)
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE {
|
2007-03-22 10:30:00 -07:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("ScrollbarFrame"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// nsIFrame overrides
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_IMETHOD HandlePress(nsPresContext* aPresContext,
|
2013-10-01 20:46:03 -07:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD HandleMultiplePress(nsPresContext* aPresContext,
|
2013-10-01 20:46:03 -07:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
2012-09-14 09:10:08 -07:00
|
|
|
bool aControlHeld) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-08-02 20:39:02 -07:00
|
|
|
NS_IMETHOD HandleDrag(nsPresContext* aPresContext,
|
2013-10-01 20:46:03 -07:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus) MOZ_OVERRIDE;
|
2011-08-02 20:39:02 -07:00
|
|
|
|
|
|
|
NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
|
2013-10-01 20:46:03 -07:00
|
|
|
mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus) MOZ_OVERRIDE;
|
2011-08-02 20:39:02 -07:00
|
|
|
|
2014-05-24 15:20:40 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
2007-04-10 17:25:11 -07:00
|
|
|
|
2011-07-11 07:05:09 -07:00
|
|
|
void SetScrollbarMediatorContent(nsIContent* aMediator);
|
|
|
|
nsIScrollbarMediator* GetScrollbarMediator();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsBox methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Treat scrollbars as clipping their children; overflowing children
|
2009-04-05 17:31:50 -07:00
|
|
|
* will not be allowed to set an overflow rect on this
|
2007-03-22 10:30:00 -07:00
|
|
|
* frame. This means that when the scroll code decides to hide a
|
|
|
|
* scrollframe by setting its height or width to zero, that will
|
|
|
|
* hide the children too.
|
|
|
|
*/
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual bool DoesClipChildren() MOZ_OVERRIDE { return true; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult GetMargin(nsMargin& aMargin) MOZ_OVERRIDE;
|
2013-06-26 21:00:41 -07:00
|
|
|
|
2014-02-04 17:30:34 -08:00
|
|
|
/**
|
|
|
|
* The following three methods set the value of mIncrement when a
|
|
|
|
* scrollbar button is pressed.
|
|
|
|
*/
|
|
|
|
void SetIncrementToLine(int32_t aDirection);
|
|
|
|
void SetIncrementToPage(int32_t aDirection);
|
|
|
|
void SetIncrementToWhole(int32_t aDirection);
|
|
|
|
/**
|
|
|
|
* MoveToNewPosition() adds mIncrement to the current position and
|
|
|
|
* updates the curpos attribute.
|
2014-10-09 05:14:26 -07:00
|
|
|
* @returns The new position after clamping, in CSS Pixels
|
2014-02-04 17:30:34 -08:00
|
|
|
* @note This method might destroy the frame, pres shell, and other objects.
|
|
|
|
*/
|
|
|
|
int32_t MoveToNewPosition();
|
|
|
|
int32_t GetIncrement() { return mIncrement; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int32_t mIncrement; // Amount to scroll, in CSSPixels
|
|
|
|
bool mSmoothScroll;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIContent> mScrollbarMediator;
|
|
|
|
}; // class nsScrollbarFrame
|
|
|
|
|
|
|
|
#endif
|