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"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
|
|
|
class nsBaseContentList;
|
|
|
|
|
|
|
|
class nsRangeFrame : public nsContainerFrame,
|
|
|
|
public nsIAnonymousContentCreator
|
|
|
|
{
|
2013-02-16 21:57:21 +04:00
|
|
|
friend nsIFrame*
|
|
|
|
NS_NewRangeFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
|
|
|
nsRangeFrame(nsStyleContext* aContext);
|
|
|
|
virtual ~nsRangeFrame();
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsRangeFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
|
|
|
// nsIFrame overrides
|
2013-04-11 13:11:54 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
2013-02-16 21:57:21 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2013-02-16 21:57:21 +04:00
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-02-16 21:57:21 +04:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE {
|
2013-02-16 21:57:21 +04:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Range"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
virtual bool IsLeaf() const MOZ_OVERRIDE { return true; }
|
|
|
|
|
2013-04-28 04:54:54 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
|
|
|
|
#endif
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
// nsIAnonymousContentCreator
|
|
|
|
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
|
|
|
|
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
|
|
|
uint32_t aFilter) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
2013-02-16 21:57:21 +04:00
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
|
|
|
virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
|
|
|
nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE;
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
2013-02-16 21:57:21 +04:00
|
|
|
{
|
|
|
|
return nsContainerFrame::IsFrameOfType(aFlags &
|
|
|
|
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
|
|
|
|
}
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
/**
|
|
|
|
* Returns true if the slider's thumb moves horizontally, or else false if it
|
|
|
|
* moves vertically.
|
|
|
|
*
|
|
|
|
* aOverrideFrameSize If specified, this will be used instead of the size of
|
|
|
|
* the frame's rect (i.e. the frame's border-box size) if the frame's
|
|
|
|
* rect would have otherwise been examined. This should only be specified
|
|
|
|
* during reflow when the frame's [new] border-box size has not yet been
|
|
|
|
* stored in its mRect.
|
|
|
|
*/
|
|
|
|
bool IsHorizontal(const nsSize *aFrameSizeOverride = nullptr) const;
|
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
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
private:
|
|
|
|
|
2013-03-27 03:04:41 +04:00
|
|
|
nsresult MakeAnonymousDiv(nsIContent** aResult,
|
|
|
|
nsCSSPseudoElements::Type aPseudoType,
|
|
|
|
nsTArray<ContentInfo>& aElements);
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
// Helper function which reflows the anonymous div frames.
|
|
|
|
nsresult ReflowAnonymousContent(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState);
|
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-02-16 21:57:21 +04:00
|
|
|
nsCOMPtr<nsIContent> 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
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> mProgressDiv;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The div used to show the ::-moz-range-thumb pseudo-element.
|
2013-02-16 21:57:21 +04:00
|
|
|
* @see nsRangeFrame::CreateAnonymousContent
|
|
|
|
*/
|
2013-02-16 21:57:21 +04:00
|
|
|
nsCOMPtr<nsIContent> mThumbDiv;
|
2013-02-16 21:57:21 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|