Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsRangeFrame_h___ |
michael@0 | 7 | #define nsRangeFrame_h___ |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/Attributes.h" |
michael@0 | 10 | #include "mozilla/Decimal.h" |
michael@0 | 11 | #include "mozilla/EventForwards.h" |
michael@0 | 12 | #include "nsContainerFrame.h" |
michael@0 | 13 | #include "nsIAnonymousContentCreator.h" |
michael@0 | 14 | #include "nsCOMPtr.h" |
michael@0 | 15 | |
michael@0 | 16 | class nsBaseContentList; |
michael@0 | 17 | class nsDisplayRangeFocusRing; |
michael@0 | 18 | |
michael@0 | 19 | class nsRangeFrame : public nsContainerFrame, |
michael@0 | 20 | public nsIAnonymousContentCreator |
michael@0 | 21 | { |
michael@0 | 22 | friend nsIFrame* |
michael@0 | 23 | NS_NewRangeFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
michael@0 | 24 | |
michael@0 | 25 | friend class nsDisplayRangeFocusRing; |
michael@0 | 26 | |
michael@0 | 27 | nsRangeFrame(nsStyleContext* aContext); |
michael@0 | 28 | virtual ~nsRangeFrame(); |
michael@0 | 29 | |
michael@0 | 30 | typedef mozilla::dom::Element Element; |
michael@0 | 31 | |
michael@0 | 32 | public: |
michael@0 | 33 | NS_DECL_QUERYFRAME_TARGET(nsRangeFrame) |
michael@0 | 34 | NS_DECL_QUERYFRAME |
michael@0 | 35 | NS_DECL_FRAMEARENA_HELPERS |
michael@0 | 36 | |
michael@0 | 37 | // nsIFrame overrides |
michael@0 | 38 | virtual void Init(nsIContent* aContent, |
michael@0 | 39 | nsIFrame* aParent, |
michael@0 | 40 | nsIFrame* aPrevInFlow) MOZ_OVERRIDE; |
michael@0 | 41 | |
michael@0 | 42 | virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; |
michael@0 | 43 | |
michael@0 | 44 | void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
michael@0 | 45 | const nsRect& aDirtyRect, |
michael@0 | 46 | const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
michael@0 | 47 | |
michael@0 | 48 | virtual nsresult Reflow(nsPresContext* aPresContext, |
michael@0 | 49 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 50 | const nsHTMLReflowState& aReflowState, |
michael@0 | 51 | nsReflowStatus& aStatus) MOZ_OVERRIDE; |
michael@0 | 52 | |
michael@0 | 53 | #ifdef DEBUG_FRAME_DUMP |
michael@0 | 54 | virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE { |
michael@0 | 55 | return MakeFrameName(NS_LITERAL_STRING("Range"), aResult); |
michael@0 | 56 | } |
michael@0 | 57 | #endif |
michael@0 | 58 | |
michael@0 | 59 | virtual bool IsLeaf() const MOZ_OVERRIDE { return true; } |
michael@0 | 60 | |
michael@0 | 61 | #ifdef ACCESSIBILITY |
michael@0 | 62 | virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; |
michael@0 | 63 | #endif |
michael@0 | 64 | |
michael@0 | 65 | // nsIAnonymousContentCreator |
michael@0 | 66 | virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE; |
michael@0 | 67 | virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, |
michael@0 | 68 | uint32_t aFilter) MOZ_OVERRIDE; |
michael@0 | 69 | |
michael@0 | 70 | virtual nsresult AttributeChanged(int32_t aNameSpaceID, |
michael@0 | 71 | nsIAtom* aAttribute, |
michael@0 | 72 | int32_t aModType) MOZ_OVERRIDE; |
michael@0 | 73 | |
michael@0 | 74 | virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext, |
michael@0 | 75 | nsSize aCBSize, nscoord aAvailableWidth, |
michael@0 | 76 | nsSize aMargin, nsSize aBorder, |
michael@0 | 77 | nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE; |
michael@0 | 78 | |
michael@0 | 79 | virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 80 | virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
michael@0 | 81 | |
michael@0 | 82 | virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
michael@0 | 83 | |
michael@0 | 84 | virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE |
michael@0 | 85 | { |
michael@0 | 86 | return nsContainerFrame::IsFrameOfType(aFlags & |
michael@0 | 87 | ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | nsStyleContext* GetAdditionalStyleContext(int32_t aIndex) const MOZ_OVERRIDE; |
michael@0 | 91 | void SetAdditionalStyleContext(int32_t aIndex, |
michael@0 | 92 | nsStyleContext* aStyleContext) MOZ_OVERRIDE; |
michael@0 | 93 | |
michael@0 | 94 | /** |
michael@0 | 95 | * Returns true if the slider's thumb moves horizontally, or else false if it |
michael@0 | 96 | * moves vertically. |
michael@0 | 97 | * |
michael@0 | 98 | * aOverrideFrameSize If specified, this will be used instead of the size of |
michael@0 | 99 | * the frame's rect (i.e. the frame's border-box size) if the frame's |
michael@0 | 100 | * rect would have otherwise been examined. This should only be specified |
michael@0 | 101 | * during reflow when the frame's [new] border-box size has not yet been |
michael@0 | 102 | * stored in its mRect. |
michael@0 | 103 | */ |
michael@0 | 104 | bool IsHorizontal(const nsSize *aFrameSizeOverride = nullptr) const; |
michael@0 | 105 | |
michael@0 | 106 | double GetMin() const; |
michael@0 | 107 | double GetMax() const; |
michael@0 | 108 | double GetValue() const; |
michael@0 | 109 | |
michael@0 | 110 | /** |
michael@0 | 111 | * Returns the input element's value as a fraction of the difference between |
michael@0 | 112 | * the input's minimum and its maximum (i.e. returns 0.0 when the value is |
michael@0 | 113 | * the same as the minimum, and returns 1.0 when the value is the same as the |
michael@0 | 114 | * maximum). |
michael@0 | 115 | */ |
michael@0 | 116 | double GetValueAsFractionOfRange(); |
michael@0 | 117 | |
michael@0 | 118 | /** |
michael@0 | 119 | * Returns whether the frame and its child should use the native style. |
michael@0 | 120 | */ |
michael@0 | 121 | bool ShouldUseNativeStyle() const; |
michael@0 | 122 | |
michael@0 | 123 | mozilla::Decimal GetValueAtEventPoint(mozilla::WidgetGUIEvent* aEvent); |
michael@0 | 124 | |
michael@0 | 125 | /** |
michael@0 | 126 | * Helper that's used when the value of the range changes to reposition the |
michael@0 | 127 | * thumb, resize the range-progress element, and schedule a repaint. (This |
michael@0 | 128 | * does not reflow, since the position and size of the thumb and |
michael@0 | 129 | * range-progress element do not affect the position or size of any other |
michael@0 | 130 | * frames.) |
michael@0 | 131 | */ |
michael@0 | 132 | void UpdateForValueChange(); |
michael@0 | 133 | |
michael@0 | 134 | virtual Element* GetPseudoElement(nsCSSPseudoElements::Type aType) MOZ_OVERRIDE; |
michael@0 | 135 | |
michael@0 | 136 | private: |
michael@0 | 137 | |
michael@0 | 138 | nsresult MakeAnonymousDiv(Element** aResult, |
michael@0 | 139 | nsCSSPseudoElements::Type aPseudoType, |
michael@0 | 140 | nsTArray<ContentInfo>& aElements); |
michael@0 | 141 | |
michael@0 | 142 | // Helper function which reflows the anonymous div frames. |
michael@0 | 143 | nsresult ReflowAnonymousContent(nsPresContext* aPresContext, |
michael@0 | 144 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 145 | const nsHTMLReflowState& aReflowState); |
michael@0 | 146 | |
michael@0 | 147 | void DoUpdateThumbPosition(nsIFrame* aThumbFrame, |
michael@0 | 148 | const nsSize& aRangeSize); |
michael@0 | 149 | |
michael@0 | 150 | void DoUpdateRangeProgressFrame(nsIFrame* aProgressFrame, |
michael@0 | 151 | const nsSize& aRangeSize); |
michael@0 | 152 | |
michael@0 | 153 | /** |
michael@0 | 154 | * The div used to show the ::-moz-range-track pseudo-element. |
michael@0 | 155 | * @see nsRangeFrame::CreateAnonymousContent |
michael@0 | 156 | */ |
michael@0 | 157 | nsCOMPtr<Element> mTrackDiv; |
michael@0 | 158 | |
michael@0 | 159 | /** |
michael@0 | 160 | * The div used to show the ::-moz-range-progress pseudo-element, which is |
michael@0 | 161 | * used to (optionally) style the specific chunk of track leading up to the |
michael@0 | 162 | * thumb's current position. |
michael@0 | 163 | * @see nsRangeFrame::CreateAnonymousContent |
michael@0 | 164 | */ |
michael@0 | 165 | nsCOMPtr<Element> mProgressDiv; |
michael@0 | 166 | |
michael@0 | 167 | /** |
michael@0 | 168 | * The div used to show the ::-moz-range-thumb pseudo-element. |
michael@0 | 169 | * @see nsRangeFrame::CreateAnonymousContent |
michael@0 | 170 | */ |
michael@0 | 171 | nsCOMPtr<Element> mThumbDiv; |
michael@0 | 172 | |
michael@0 | 173 | /** |
michael@0 | 174 | * Cached style context for -moz-focus-outer CSS pseudo-element style. |
michael@0 | 175 | */ |
michael@0 | 176 | nsRefPtr<nsStyleContext> mOuterFocusStyle; |
michael@0 | 177 | }; |
michael@0 | 178 | |
michael@0 | 179 | #endif |