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: */
|
2016-10-06 07:17:00 +03: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/. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This frame type is used for input type=date, time, month, week, and
|
|
|
|
* datetime-local.
|
|
|
|
*
|
|
|
|
* NOTE: some of the above-mentioned input types are still to-be-implemented.
|
|
|
|
* See nsCSSFrameConstructor::FindInputData, as well as bug 1286182 (date),
|
|
|
|
* bug 1306215 (month), bug 1306216 (week) and bug 1306217 (datetime-local).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsDateTimeControlFrame_h__
|
|
|
|
#define nsDateTimeControlFrame_h__
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
#include "nsIAnonymousContentCreator.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
struct DateTimeValue;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
class nsDateTimeControlFrame final : public nsContainerFrame,
|
|
|
|
public nsIAnonymousContentCreator
|
|
|
|
{
|
|
|
|
typedef mozilla::dom::DateTimeValue DateTimeValue;
|
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
explicit nsDateTimeControlFrame(ComputedStyle* aStyle);
|
2016-10-06 07:17:00 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
friend nsIFrame* NS_NewDateTimeControlFrame(nsIPresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle);
|
2016-10-06 07:17:00 +03:00
|
|
|
|
|
|
|
void ContentStatesChanged(mozilla::EventStates aStates) override;
|
2017-11-07 03:20:33 +03:00
|
|
|
void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
|
2016-10-06 07:17:00 +03:00
|
|
|
|
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsDateTimeControlFrame)
|
2016-10-06 07:17:00 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
|
|
|
nsresult GetFrameName(nsAString& aResult) const override {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("DateTimeControl"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool IsFrameOfType(uint32_t aFlags) const override
|
|
|
|
{
|
|
|
|
return nsContainerFrame::IsFrameOfType(aFlags &
|
|
|
|
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow
|
2017-06-09 22:14:53 +03:00
|
|
|
nscoord GetMinISize(gfxContext* aRenderingContext) override;
|
2016-10-06 07:17:00 +03:00
|
|
|
|
2017-06-09 22:14:53 +03:00
|
|
|
nscoord GetPrefISize(gfxContext* aRenderingContext) override;
|
2016-10-06 07:17:00 +03:00
|
|
|
|
|
|
|
void Reflow(nsPresContext* aPresContext,
|
|
|
|
ReflowOutput& aDesiredSize,
|
2017-07-25 14:02:35 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2016-10-06 07:17:00 +03:00
|
|
|
nsReflowStatus& aStatus) override;
|
|
|
|
|
|
|
|
// nsIAnonymousContentCreator
|
|
|
|
nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
|
|
|
|
void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
|
|
|
uint32_t aFilter) override;
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
2016-10-06 07:17:00 +03:00
|
|
|
int32_t aModType) override;
|
|
|
|
|
2018-11-03 02:29:42 +03:00
|
|
|
nsIContent* GetInputAreaContent() const { return mInputAreaContent; }
|
|
|
|
|
2017-06-29 18:47:00 +03:00
|
|
|
void OnValueChanged();
|
|
|
|
void OnMinMaxStepAttrChanged();
|
2016-10-06 07:17:00 +03:00
|
|
|
void HandleFocusEvent();
|
|
|
|
void HandleBlurEvent();
|
2017-06-19 08:13:00 +03:00
|
|
|
bool HasBadInput();
|
2016-10-06 07:17:00 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
class SyncDisabledStateEvent;
|
|
|
|
friend class SyncDisabledStateEvent;
|
|
|
|
class SyncDisabledStateEvent : public mozilla::Runnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit SyncDisabledStateEvent(nsDateTimeControlFrame* aFrame)
|
2017-06-12 22:34:10 +03:00
|
|
|
: mozilla::Runnable("nsDateTimeControlFrame::SyncDisabledStateEvent")
|
|
|
|
, mFrame(aFrame)
|
2016-10-06 07:17:00 +03:00
|
|
|
{}
|
|
|
|
|
|
|
|
NS_IMETHOD Run() override
|
|
|
|
{
|
|
|
|
nsDateTimeControlFrame* frame =
|
|
|
|
static_cast<nsDateTimeControlFrame*>(mFrame.GetFrame());
|
|
|
|
NS_ENSURE_STATE(frame);
|
|
|
|
|
|
|
|
frame->SyncDisabledState();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-03-01 20:03:14 +03:00
|
|
|
WeakFrame mFrame;
|
2016-10-06 07:17:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sync the disabled state of the anonymous children up with our content's.
|
|
|
|
*/
|
|
|
|
void SyncDisabledState();
|
|
|
|
|
|
|
|
// Anonymous child which is bound via XBL to an element that wraps the input
|
|
|
|
// area and reset button.
|
2017-12-05 20:05:51 +03:00
|
|
|
RefPtr<mozilla::dom::Element> mInputAreaContent;
|
2016-10-06 07:17:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsDateTimeControlFrame_h__
|