2013-02-16 21:57:21 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef nsRangeFrame_h___
|
|
|
|
#define nsRangeFrame_h___
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
2013-05-06 03:23:18 +04:00
|
|
|
#include "mozilla/Decimal.h"
|
2013-09-24 14:04:14 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2013-02-16 21:57:21 +04:00
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
#include "nsIAnonymousContentCreator.h"
|
2015-01-13 17:06:37 +03:00
|
|
|
#include "nsIDOMEventListener.h"
|
2013-02-16 21:57:21 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2014-02-19 03:35:07 +04:00
|
|
|
class nsDisplayRangeFocusRing;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
|
|
|
class nsRangeFrame : public nsContainerFrame,
|
|
|
|
public nsIAnonymousContentCreator
|
|
|
|
{
|
2013-02-16 21:57:21 +04:00
|
|
|
friend nsIFrame*
|
|
|
|
NS_NewRangeFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
2014-02-19 03:35:07 +04:00
|
|
|
friend class nsDisplayRangeFocusRing;
|
|
|
|
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsRangeFrame(nsStyleContext* aContext);
|
2013-02-16 21:57:21 +04:00
|
|
|
virtual ~nsRangeFrame();
|
|
|
|
|
2016-02-17 23:37:00 +03:00
|
|
|
typedef mozilla::CSSPseudoElementType CSSPseudoElementType;
|
2013-12-03 08:49:03 +04:00
|
|
|
typedef mozilla::dom::Element Element;
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsRangeFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
|
|
|
// nsIFrame overrides
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
2013-04-11 13:11:54 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsReflowStatus& aStatus) override;
|
2013-02-16 21:57:21 +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 {
|
2013-02-16 21:57:21 +04:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Range"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsLeaf() const override { return true; }
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2013-04-28 04:54:54 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual mozilla::a11y::AccType AccessibleType() override;
|
2013-04-28 04:54:54 +04:00
|
|
|
#endif
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
// nsIAnonymousContentCreator
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
|
2014-07-16 22:41:57 +04:00
|
|
|
virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aFilter) override;
|
2013-02-16 21:57:21 +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;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2014-08-24 18:34:51 +04:00
|
|
|
virtual mozilla::LogicalSize
|
2016-11-05 04:57:06 +03:00
|
|
|
ComputeAutoSize(nsRenderingContext* aRenderingContext,
|
|
|
|
mozilla::WritingMode aWM,
|
2014-08-24 18:34:51 +04:00
|
|
|
const mozilla::LogicalSize& aCBSize,
|
2016-11-05 04:57:06 +03:00
|
|
|
nscoord aAvailableISize,
|
2014-08-24 18:34:51 +04:00
|
|
|
const mozilla::LogicalSize& aMargin,
|
|
|
|
const mozilla::LogicalSize& aBorder,
|
|
|
|
const mozilla::LogicalSize& aPadding,
|
2016-11-05 04:57:06 +03:00
|
|
|
ComputeSizeFlags aFlags) override;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) override;
|
|
|
|
virtual nscoord GetPrefISize(nsRenderingContext *aRenderingContext) override;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override
|
2013-02-16 21:57:21 +04:00
|
|
|
{
|
|
|
|
return nsContainerFrame::IsFrameOfType(aFlags &
|
|
|
|
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
nsStyleContext* GetAdditionalStyleContext(int32_t aIndex) const override;
|
2014-02-19 03:35:07 +04:00
|
|
|
void SetAdditionalStyleContext(int32_t aIndex,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsStyleContext* aStyleContext) override;
|
2014-02-19 03:35:07 +04:00
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
/**
|
|
|
|
* Returns true if the slider's thumb moves horizontally, or else false if it
|
|
|
|
* moves vertically.
|
|
|
|
*/
|
2015-04-29 10:18:54 +03:00
|
|
|
bool IsHorizontal() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the slider is oriented along the inline axis.
|
|
|
|
*/
|
|
|
|
bool IsInlineOriented() const {
|
|
|
|
return IsHorizontal() != GetWritingMode().IsVertical();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the slider's thumb moves right-to-left for increasing
|
|
|
|
* values; only relevant when IsHorizontal() is true.
|
|
|
|
*/
|
|
|
|
bool IsRightToLeft() const {
|
|
|
|
MOZ_ASSERT(IsHorizontal());
|
|
|
|
mozilla::WritingMode wm = GetWritingMode();
|
|
|
|
return wm.IsVertical() ? wm.IsVerticalRL() : !wm.IsBidiLTR();
|
|
|
|
}
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2013-03-16 09:40:15 +04:00
|
|
|
double GetMin() const;
|
|
|
|
double GetMax() const;
|
|
|
|
double GetValue() const;
|
|
|
|
|
2013-04-17 03:50:26 +04:00
|
|
|
/**
|
|
|
|
* Returns the input element's value as a fraction of the difference between
|
|
|
|
* the input's minimum and its maximum (i.e. returns 0.0 when the value is
|
|
|
|
* the same as the minimum, and returns 1.0 when the value is the same as the
|
|
|
|
* maximum).
|
|
|
|
*/
|
|
|
|
double GetValueAsFractionOfRange();
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
/**
|
|
|
|
* Returns whether the frame and its child should use the native style.
|
|
|
|
*/
|
|
|
|
bool ShouldUseNativeStyle() const;
|
|
|
|
|
2013-10-02 07:46:03 +04:00
|
|
|
mozilla::Decimal GetValueAtEventPoint(mozilla::WidgetGUIEvent* aEvent);
|
2013-03-08 13:40:12 +04:00
|
|
|
|
2013-03-13 15:48:27 +04:00
|
|
|
/**
|
2013-03-27 03:04:41 +04:00
|
|
|
* Helper that's used when the value of the range changes to reposition the
|
|
|
|
* thumb, resize the range-progress element, and schedule a repaint. (This
|
|
|
|
* does not reflow, since the position and size of the thumb and
|
|
|
|
* range-progress element do not affect the position or size of any other
|
|
|
|
* frames.)
|
2013-03-13 15:48:27 +04:00
|
|
|
*/
|
2013-03-27 03:04:41 +04:00
|
|
|
void UpdateForValueChange();
|
2013-03-13 15:48:27 +04:00
|
|
|
|
2016-02-17 23:37:00 +03:00
|
|
|
virtual Element* GetPseudoElement(CSSPseudoElementType aType) override;
|
2013-12-03 03:57:50 +04:00
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
private:
|
|
|
|
|
2013-12-03 08:49:03 +04:00
|
|
|
nsresult MakeAnonymousDiv(Element** aResult,
|
2016-02-17 23:37:00 +03:00
|
|
|
CSSPseudoElementType aPseudoType,
|
2013-03-27 03:04:41 +04:00
|
|
|
nsTArray<ContentInfo>& aElements);
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
// Helper function which reflows the anonymous div frames.
|
2014-05-13 04:47:52 +04:00
|
|
|
void ReflowAnonymousContent(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput);
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2013-03-15 13:04:54 +04:00
|
|
|
void DoUpdateThumbPosition(nsIFrame* aThumbFrame,
|
|
|
|
const nsSize& aRangeSize);
|
|
|
|
|
2013-03-27 03:04:41 +04:00
|
|
|
void DoUpdateRangeProgressFrame(nsIFrame* aProgressFrame,
|
|
|
|
const nsSize& aRangeSize);
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
/**
|
2013-03-27 03:04:41 +04:00
|
|
|
* The div used to show the ::-moz-range-track pseudo-element.
|
2013-02-16 21:57:21 +04:00
|
|
|
* @see nsRangeFrame::CreateAnonymousContent
|
|
|
|
*/
|
2013-12-03 08:49:03 +04:00
|
|
|
nsCOMPtr<Element> mTrackDiv;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
|
|
|
/**
|
2013-03-27 03:04:41 +04:00
|
|
|
* The div used to show the ::-moz-range-progress pseudo-element, which is
|
|
|
|
* used to (optionally) style the specific chunk of track leading up to the
|
|
|
|
* thumb's current position.
|
|
|
|
* @see nsRangeFrame::CreateAnonymousContent
|
|
|
|
*/
|
2013-12-03 08:49:03 +04:00
|
|
|
nsCOMPtr<Element> mProgressDiv;
|
2013-03-27 03:04:41 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The div used to show the ::-moz-range-thumb pseudo-element.
|
2013-02-16 21:57:21 +04:00
|
|
|
* @see nsRangeFrame::CreateAnonymousContent
|
|
|
|
*/
|
2013-12-03 08:49:03 +04:00
|
|
|
nsCOMPtr<Element> mThumbDiv;
|
2014-02-19 03:35:07 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cached style context for -moz-focus-outer CSS pseudo-element style.
|
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> mOuterFocusStyle;
|
2015-01-13 17:06:37 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class DummyTouchListener final : public nsIDOMEventListener
|
2015-01-13 17:06:37 +03:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
~DummyTouchListener() {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override
|
2015-01-13 17:06:37 +03:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A no-op touch-listener used for APZ purposes (see nsRangeFrame::Init).
|
|
|
|
*/
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DummyTouchListener> mDummyTouchListener;
|
2013-02-16 21:57:21 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|