Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/forms/nsDateTimeControlFrame.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
/**
8
 * This frame type is used for input type=date, time, month, week, and
9
 * datetime-local.
10
 *
11
 * NOTE: some of the above-mentioned input types are still to-be-implemented.
12
 * See nsCSSFrameConstructor::FindInputData, as well as bug 1286182 (date),
13
 * bug 1306215 (month), bug 1306216 (week) and bug 1306217 (datetime-local).
14
 */
15
16
#ifndef nsDateTimeControlFrame_h__
17
#define nsDateTimeControlFrame_h__
18
19
#include "mozilla/Attributes.h"
20
#include "nsContainerFrame.h"
21
#include "nsIAnonymousContentCreator.h"
22
#include "nsCOMPtr.h"
23
24
namespace mozilla {
25
namespace dom {
26
struct DateTimeValue;
27
} // namespace dom
28
} // namespace mozilla
29
30
class nsDateTimeControlFrame final : public nsContainerFrame,
31
                                     public nsIAnonymousContentCreator
32
{
33
  typedef mozilla::dom::DateTimeValue DateTimeValue;
34
35
  explicit nsDateTimeControlFrame(ComputedStyle* aStyle);
36
37
public:
38
  friend nsIFrame* NS_NewDateTimeControlFrame(nsIPresShell* aPresShell,
39
                                              ComputedStyle* aStyle);
40
41
  void ContentStatesChanged(mozilla::EventStates aStates) override;
42
  void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
43
44
  NS_DECL_QUERYFRAME
45
  NS_DECL_FRAMEARENA_HELPERS(nsDateTimeControlFrame)
46
47
#ifdef DEBUG_FRAME_DUMP
48
  nsresult GetFrameName(nsAString& aResult) const override {
49
    return MakeFrameName(NS_LITERAL_STRING("DateTimeControl"), aResult);
50
  }
51
#endif
52
53
  bool IsFrameOfType(uint32_t aFlags) const override
54
0
  {
55
0
    return nsContainerFrame::IsFrameOfType(aFlags &
56
0
      ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
57
0
  }
58
59
  // Reflow
60
  nscoord GetMinISize(gfxContext* aRenderingContext) override;
61
62
  nscoord GetPrefISize(gfxContext* aRenderingContext) override;
63
64
  void Reflow(nsPresContext* aPresContext,
65
              ReflowOutput& aDesiredSize,
66
              const ReflowInput& aReflowInput,
67
              nsReflowStatus& aStatus) override;
68
69
  // nsIAnonymousContentCreator
70
  nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
71
  void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
72
                                uint32_t aFilter) override;
73
74
  nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
75
                            int32_t aModType) override;
76
77
  void OnValueChanged();
78
  void OnMinMaxStepAttrChanged();
79
  void SetValueFromPicker(const DateTimeValue& aValue);
80
  void HandleFocusEvent();
81
  void HandleBlurEvent();
82
  void SetPickerState(bool aOpen);
83
  bool HasBadInput();
84
85
private:
86
  class SyncDisabledStateEvent;
87
  friend class SyncDisabledStateEvent;
88
  class SyncDisabledStateEvent : public mozilla::Runnable
89
  {
90
  public:
91
    explicit SyncDisabledStateEvent(nsDateTimeControlFrame* aFrame)
92
      : mozilla::Runnable("nsDateTimeControlFrame::SyncDisabledStateEvent")
93
      , mFrame(aFrame)
94
0
    {}
95
96
    NS_IMETHOD Run() override
97
0
    {
98
0
      nsDateTimeControlFrame* frame =
99
0
        static_cast<nsDateTimeControlFrame*>(mFrame.GetFrame());
100
0
      NS_ENSURE_STATE(frame);
101
0
102
0
      frame->SyncDisabledState();
103
0
      return NS_OK;
104
0
    }
105
106
  private:
107
    WeakFrame mFrame;
108
  };
109
110
  /**
111
   * Sync the disabled state of the anonymous children up with our content's.
112
   */
113
  void SyncDisabledState();
114
115
  // Anonymous child which is bound via XBL to an element that wraps the input
116
  // area and reset button.
117
  RefPtr<mozilla::dom::Element> mInputAreaContent;
118
};
119
120
#endif // nsDateTimeControlFrame_h__