Bumping manifests a=b2g-bump
[gecko.git] / layout / forms / nsRangeFrame.h
blob4d6f066f201b8f3192329d9b872d1934bf5401bd
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 "mozilla/Decimal.h"
11 #include "mozilla/EventForwards.h"
12 #include "nsContainerFrame.h"
13 #include "nsIAnonymousContentCreator.h"
14 #include "nsIDOMEventListener.h"
15 #include "nsCOMPtr.h"
17 class nsBaseContentList;
18 class nsDisplayRangeFocusRing;
20 class nsRangeFrame : public nsContainerFrame,
21 public nsIAnonymousContentCreator
23 friend nsIFrame*
24 NS_NewRangeFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
26 friend class nsDisplayRangeFocusRing;
28 explicit nsRangeFrame(nsStyleContext* aContext);
29 virtual ~nsRangeFrame();
31 typedef mozilla::dom::Element Element;
33 public:
34 NS_DECL_QUERYFRAME_TARGET(nsRangeFrame)
35 NS_DECL_QUERYFRAME
36 NS_DECL_FRAMEARENA_HELPERS
38 // nsIFrame overrides
39 virtual void Init(nsIContent* aContent,
40 nsContainerFrame* aParent,
41 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
43 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
45 void BuildDisplayList(nsDisplayListBuilder* aBuilder,
46 const nsRect& aDirtyRect,
47 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
49 virtual void Reflow(nsPresContext* aPresContext,
50 nsHTMLReflowMetrics& aDesiredSize,
51 const nsHTMLReflowState& aReflowState,
52 nsReflowStatus& aStatus) MOZ_OVERRIDE;
54 #ifdef DEBUG_FRAME_DUMP
55 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE {
56 return MakeFrameName(NS_LITERAL_STRING("Range"), aResult);
58 #endif
60 virtual bool IsLeaf() const MOZ_OVERRIDE { return true; }
62 #ifdef ACCESSIBILITY
63 virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
64 #endif
66 // nsIAnonymousContentCreator
67 virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
68 virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
69 uint32_t aFilter) MOZ_OVERRIDE;
71 virtual nsresult AttributeChanged(int32_t aNameSpaceID,
72 nsIAtom* aAttribute,
73 int32_t aModType) MOZ_OVERRIDE;
75 virtual mozilla::LogicalSize
76 ComputeAutoSize(nsRenderingContext *aRenderingContext,
77 mozilla::WritingMode aWritingMode,
78 const mozilla::LogicalSize& aCBSize,
79 nscoord aAvailableISize,
80 const mozilla::LogicalSize& aMargin,
81 const mozilla::LogicalSize& aBorder,
82 const mozilla::LogicalSize& aPadding,
83 bool aShrinkWrap) MOZ_OVERRIDE;
85 virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
86 virtual nscoord GetPrefISize(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
88 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
90 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
92 return nsContainerFrame::IsFrameOfType(aFlags &
93 ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
96 nsStyleContext* GetAdditionalStyleContext(int32_t aIndex) const MOZ_OVERRIDE;
97 void SetAdditionalStyleContext(int32_t aIndex,
98 nsStyleContext* aStyleContext) MOZ_OVERRIDE;
101 * Returns true if the slider's thumb moves horizontally, or else false if it
102 * moves vertically.
104 * aOverrideFrameSize If specified, this will be used instead of the size of
105 * the frame's rect (i.e. the frame's border-box size) if the frame's
106 * rect would have otherwise been examined. This should only be specified
107 * during reflow when the frame's [new] border-box size has not yet been
108 * stored in its mRect.
110 bool IsHorizontal(const nsSize *aFrameSizeOverride = nullptr) const;
112 double GetMin() const;
113 double GetMax() const;
114 double GetValue() const;
116 /**
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 * Returns whether the frame and its child should use the native style.
127 bool ShouldUseNativeStyle() const;
129 mozilla::Decimal GetValueAtEventPoint(mozilla::WidgetGUIEvent* aEvent);
132 * Helper that's used when the value of the range changes to reposition the
133 * thumb, resize the range-progress element, and schedule a repaint. (This
134 * does not reflow, since the position and size of the thumb and
135 * range-progress element do not affect the position or size of any other
136 * frames.)
138 void UpdateForValueChange();
140 virtual Element* GetPseudoElement(nsCSSPseudoElements::Type aType) MOZ_OVERRIDE;
142 private:
144 nsresult MakeAnonymousDiv(Element** aResult,
145 nsCSSPseudoElements::Type aPseudoType,
146 nsTArray<ContentInfo>& aElements);
148 // Helper function which reflows the anonymous div frames.
149 void ReflowAnonymousContent(nsPresContext* aPresContext,
150 nsHTMLReflowMetrics& aDesiredSize,
151 const nsHTMLReflowState& aReflowState);
153 void DoUpdateThumbPosition(nsIFrame* aThumbFrame,
154 const nsSize& aRangeSize);
156 void DoUpdateRangeProgressFrame(nsIFrame* aProgressFrame,
157 const nsSize& aRangeSize);
160 * The div used to show the ::-moz-range-track pseudo-element.
161 * @see nsRangeFrame::CreateAnonymousContent
163 nsCOMPtr<Element> mTrackDiv;
166 * The div used to show the ::-moz-range-progress pseudo-element, which is
167 * used to (optionally) style the specific chunk of track leading up to the
168 * thumb's current position.
169 * @see nsRangeFrame::CreateAnonymousContent
171 nsCOMPtr<Element> mProgressDiv;
174 * The div used to show the ::-moz-range-thumb pseudo-element.
175 * @see nsRangeFrame::CreateAnonymousContent
177 nsCOMPtr<Element> mThumbDiv;
180 * Cached style context for -moz-focus-outer CSS pseudo-element style.
182 nsRefPtr<nsStyleContext> mOuterFocusStyle;
184 class DummyTouchListener MOZ_FINAL : public nsIDOMEventListener
186 private:
187 ~DummyTouchListener() {}
189 public:
190 NS_DECL_ISUPPORTS
192 NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE
194 return NS_OK;
199 * A no-op touch-listener used for APZ purposes (see nsRangeFrame::Init).
201 nsRefPtr<DummyTouchListener> mDummyTouchListener;
204 #endif