2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-09-04 14:30:36 +04:00
|
|
|
/* 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 nsNumberControlFrame_h__
|
|
|
|
#define nsNumberControlFrame_h__
|
|
|
|
|
2014-02-24 18:41:56 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-09-04 14:30:36 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2020-01-14 22:01:05 +03:00
|
|
|
#include "nsTextControlFrame.h"
|
2013-09-04 14:30:36 +04:00
|
|
|
#include "nsIFormControlFrame.h"
|
|
|
|
#include "nsIAnonymousContentCreator.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2016-08-10 21:29:00 +03:00
|
|
|
class nsITextControlFrame;
|
2013-09-04 14:30:36 +04:00
|
|
|
class nsPresContext;
|
|
|
|
|
2011-06-21 18:13:12 +04:00
|
|
|
namespace mozilla {
|
2019-02-19 16:44:33 +03:00
|
|
|
enum class PseudoStyleType : uint8_t;
|
2019-04-16 10:24:49 +03:00
|
|
|
class PresShell;
|
2013-12-01 17:49:10 +04:00
|
|
|
class WidgetEvent;
|
2013-12-01 17:49:10 +04:00
|
|
|
class WidgetGUIEvent;
|
2011-06-21 18:13:12 +04:00
|
|
|
namespace dom {
|
|
|
|
class HTMLInputElement;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2011-06-21 18:13:12 +04:00
|
|
|
|
2013-09-04 14:30:36 +04:00
|
|
|
/**
|
|
|
|
* This frame type is used for <input type=number>.
|
2020-01-14 22:01:05 +03:00
|
|
|
*
|
|
|
|
* TODO(emilio): Maybe merge with nsTextControlFrame?
|
2013-09-04 14:30:36 +04:00
|
|
|
*/
|
2020-01-14 22:01:05 +03:00
|
|
|
class nsNumberControlFrame final : public nsTextControlFrame {
|
2019-04-16 10:24:49 +03:00
|
|
|
friend nsIFrame* NS_NewNumberControlFrame(mozilla::PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle);
|
2013-09-04 14:30:36 +04:00
|
|
|
|
2019-02-19 16:44:33 +03:00
|
|
|
typedef mozilla::PseudoStyleType PseudoStyleType;
|
2013-12-03 08:49:03 +04:00
|
|
|
typedef mozilla::dom::Element Element;
|
2011-06-21 18:13:12 +04:00
|
|
|
typedef mozilla::dom::HTMLInputElement HTMLInputElement;
|
2013-12-01 17:49:10 +04:00
|
|
|
typedef mozilla::WidgetEvent WidgetEvent;
|
2013-12-01 17:49:10 +04:00
|
|
|
typedef mozilla::WidgetGUIEvent WidgetGUIEvent;
|
2011-06-21 18:13:12 +04:00
|
|
|
|
2019-02-05 19:45:54 +03:00
|
|
|
explicit nsNumberControlFrame(ComputedStyle* aStyle,
|
|
|
|
nsPresContext* aPresContext);
|
2013-09-04 14:30:36 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsNumberControlFrame)
|
2013-09-04 14:30:36 +04:00
|
|
|
|
2020-01-14 22:01:05 +03:00
|
|
|
void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData&) override;
|
2013-09-04 14:30:36 +04:00
|
|
|
|
2013-12-11 07:19:26 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2020-01-14 22:01:05 +03:00
|
|
|
mozilla::a11y::AccType AccessibleType() override;
|
2013-12-11 07:19:26 +04:00
|
|
|
#endif
|
|
|
|
|
2013-09-04 14:30:36 +04:00
|
|
|
// nsIAnonymousContentCreator
|
2020-01-14 22:01:05 +03:00
|
|
|
nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
|
|
|
|
void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
|
|
|
uint32_t aFilter) override;
|
2013-09-04 14:30:36 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2020-01-14 22:01:05 +03:00
|
|
|
nsresult GetFrameName(nsAString& aResult) const override {
|
2020-07-01 11:29:29 +03:00
|
|
|
return MakeFrameName(u"NumberControl"_ns, aResult);
|
2013-09-04 14:30:36 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-12-05 20:20:34 +04:00
|
|
|
/**
|
|
|
|
* If the frame is the frame for an nsNumberControlFrame's anonymous text
|
|
|
|
* field, returns the nsNumberControlFrame. Else returns nullptr.
|
|
|
|
*/
|
|
|
|
static nsNumberControlFrame* GetNumberControlFrameForTextField(
|
|
|
|
nsIFrame* aFrame);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the frame is the frame for an nsNumberControlFrame's up or down spin
|
|
|
|
* button, returns the nsNumberControlFrame. Else returns nullptr.
|
|
|
|
*/
|
|
|
|
static nsNumberControlFrame* GetNumberControlFrameForSpinButton(
|
|
|
|
nsIFrame* aFrame);
|
|
|
|
|
2013-12-01 17:49:10 +04:00
|
|
|
enum SpinButtonEnum { eSpinButtonNone, eSpinButtonUp, eSpinButtonDown };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns one of the SpinButtonEnum values to depending on whether the
|
|
|
|
* pointer event is over the spin-up button, the spin-down button, or
|
|
|
|
* neither.
|
|
|
|
*/
|
|
|
|
int32_t GetSpinButtonForPointerEvent(WidgetGUIEvent* aEvent) const;
|
|
|
|
|
2013-12-05 20:20:34 +04:00
|
|
|
void SpinnerStateChanged() const;
|
|
|
|
|
|
|
|
bool SpinnerUpButtonIsDepressed() const;
|
|
|
|
bool SpinnerDownButtonIsDepressed() const;
|
|
|
|
|
2013-12-11 15:41:51 +04:00
|
|
|
/**
|
|
|
|
* Our element had HTMLInputElement::Select() called on it.
|
|
|
|
*/
|
2017-07-14 06:46:13 +03:00
|
|
|
void HandleSelectCall();
|
2013-12-11 15:41:51 +04:00
|
|
|
|
2013-12-05 20:20:34 +04:00
|
|
|
bool ShouldUseNativeStyleForSpinner() const;
|
|
|
|
|
2013-09-04 14:30:36 +04:00
|
|
|
private:
|
2020-01-14 22:01:05 +03:00
|
|
|
// See nsNumberControlFrame::CreateAnonymousContent for a description of
|
|
|
|
// these.
|
2013-12-03 08:49:03 +04:00
|
|
|
nsCOMPtr<Element> mOuterWrapper;
|
|
|
|
nsCOMPtr<Element> mSpinBox;
|
|
|
|
nsCOMPtr<Element> mSpinUp;
|
|
|
|
nsCOMPtr<Element> mSpinDown;
|
2013-09-04 14:30:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsNumberControlFrame_h__
|