Bug 853360 - Implement the coneGain part of the AudioPannerNode. r=roc
[gecko.git] / layout / forms / nsRangeFrame.h
blobeb3b350b4f3d79bbe82b40f65ac484a37880d0eb
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsRangeFrame_h___
7 #define nsRangeFrame_h___
9 #include "mozilla/Attributes.h"
10 #include "nsContainerFrame.h"
11 #include "nsIAnonymousContentCreator.h"
12 #include "nsCOMPtr.h"
14 class nsBaseContentList;
15 class nsGUIEvent;
17 class nsRangeFrame : public nsContainerFrame,
18 public nsIAnonymousContentCreator
20 friend nsIFrame*
21 NS_NewRangeFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
23 nsRangeFrame(nsStyleContext* aContext);
24 virtual ~nsRangeFrame();
26 public:
27 NS_DECL_QUERYFRAME_TARGET(nsRangeFrame)
28 NS_DECL_QUERYFRAME
29 NS_DECL_FRAMEARENA_HELPERS
31 // nsIFrame overrides
32 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
34 void BuildDisplayList(nsDisplayListBuilder* aBuilder,
35 const nsRect& aDirtyRect,
36 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
38 NS_IMETHOD Reflow(nsPresContext* aPresContext,
39 nsHTMLReflowMetrics& aDesiredSize,
40 const nsHTMLReflowState& aReflowState,
41 nsReflowStatus& aStatus) MOZ_OVERRIDE;
43 #ifdef DEBUG
44 NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE {
45 return MakeFrameName(NS_LITERAL_STRING("Range"), aResult);
47 #endif
49 virtual bool IsLeaf() const MOZ_OVERRIDE { return true; }
51 // nsIAnonymousContentCreator
52 virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
53 virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
54 uint32_t aFilter) MOZ_OVERRIDE;
56 NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
57 nsIAtom* aAttribute,
58 int32_t aModType) MOZ_OVERRIDE;
60 virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
61 nsSize aCBSize, nscoord aAvailableWidth,
62 nsSize aMargin, nsSize aBorder,
63 nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
65 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
66 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
68 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
70 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
72 return nsContainerFrame::IsFrameOfType(aFlags &
73 ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
76 /**
77 * Returns true if the slider's thumb moves horizontally, or else false if it
78 * moves vertically.
80 * aOverrideFrameSize If specified, this will be used instead of the size of
81 * the frame's rect (i.e. the frame's border-box size) if the frame's
82 * rect would have otherwise been examined. This should only be specified
83 * during reflow when the frame's [new] border-box size has not yet been
84 * stored in its mRect.
86 bool IsHorizontal(const nsSize *aFrameSizeOverride = nullptr) const;
88 double GetMin() const;
89 double GetMax() const;
90 double GetValue() const;
92 /**
93 * Returns whether the frame and its child should use the native style.
95 bool ShouldUseNativeStyle() const;
97 double GetValueAtEventPoint(nsGUIEvent* aEvent);
99 /**
100 * Helper to reposition the thumb and schedule a repaint when the value of
101 * the range changes. (This does not reflow, since the position and size of
102 * the thumb do not affect the position or size of any other frames.)
104 void UpdateThumbPositionForValueChange();
106 private:
108 // Helper function which reflows the anonymous div frames.
109 nsresult ReflowAnonymousContent(nsPresContext* aPresContext,
110 nsHTMLReflowMetrics& aDesiredSize,
111 const nsHTMLReflowState& aReflowState);
113 void DoUpdateThumbPosition(nsIFrame* aThumbFrame,
114 const nsSize& aRangeSize);
117 * Returns the input element's value as a fraction of the difference between
118 * the input's minimum and its maximum (i.e. returns 0.0 when the value is
119 * the same as the minimum, and returns 1.0 when the value is the same as the
120 * maximum).
122 double GetValueAsFractionOfRange();
125 * The div used to show the track.
126 * @see nsRangeFrame::CreateAnonymousContent
128 nsCOMPtr<nsIContent> mTrackDiv;
131 * The div used to show the thumb.
132 * @see nsRangeFrame::CreateAnonymousContent
134 nsCOMPtr<nsIContent> mThumbDiv;
137 #endif