layout/forms/nsFileControlFrame.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsFileControlFrame_h___
     7 #define nsFileControlFrame_h___
     9 #include "mozilla/Attributes.h"
    10 #include "nsBlockFrame.h"
    11 #include "nsIFormControlFrame.h"
    12 #include "nsIDOMEventListener.h"
    13 #include "nsIAnonymousContentCreator.h"
    14 #include "nsCOMPtr.h"
    16 class nsTextControlFrame;
    17 class nsIDOMDragEvent;
    19 class nsFileControlFrame : public nsBlockFrame,
    20                            public nsIFormControlFrame,
    21                            public nsIAnonymousContentCreator
    22 {
    23 public:
    24   nsFileControlFrame(nsStyleContext* aContext);
    26   virtual void Init(nsIContent* aContent,
    27                     nsIFrame*   aParent,
    28                     nsIFrame*   aPrevInFlow) MOZ_OVERRIDE;
    30   virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    31                                 const nsRect&           aDirtyRect,
    32                                 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
    34   NS_DECL_QUERYFRAME
    35   NS_DECL_FRAMEARENA_HELPERS
    37   // nsIFormControlFrame
    38   virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE;
    39   virtual void SetFocus(bool aOn, bool aRepaint) MOZ_OVERRIDE;
    41   virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
    43   virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
    45 #ifdef DEBUG_FRAME_DUMP
    46   virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
    47 #endif
    49   virtual nsresult AttributeChanged(int32_t         aNameSpaceID,
    50                                     nsIAtom*        aAttribute,
    51                                     int32_t         aModType) MOZ_OVERRIDE;
    52   virtual void ContentStatesChanged(mozilla::EventStates aStates) MOZ_OVERRIDE;
    53   virtual bool IsLeaf() const MOZ_OVERRIDE
    54   {
    55     return true;
    56   }
    58   // nsIAnonymousContentCreator
    59   virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
    60   virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
    61                                         uint32_t aFilter) MOZ_OVERRIDE;
    63 #ifdef ACCESSIBILITY
    64   virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
    65 #endif
    67   typedef bool (*AcceptAttrCallback)(const nsAString&, void*);
    69 protected:
    71   class MouseListener;
    72   friend class MouseListener;
    73   class MouseListener : public nsIDOMEventListener {
    74   public:
    75     NS_DECL_ISUPPORTS
    77     MouseListener(nsFileControlFrame* aFrame)
    78      : mFrame(aFrame)
    79     {}
    80     virtual ~MouseListener() {}
    82     void ForgetFrame() {
    83       mFrame = nullptr;
    84     }
    86   protected:
    87     nsFileControlFrame* mFrame;
    88   };
    90   class SyncDisabledStateEvent;
    91   friend class SyncDisabledStateEvent;
    92   class SyncDisabledStateEvent : public nsRunnable
    93   {
    94   public:
    95     SyncDisabledStateEvent(nsFileControlFrame* aFrame)
    96       : mFrame(aFrame)
    97     {}
    99     NS_IMETHOD Run() MOZ_OVERRIDE {
   100       nsFileControlFrame* frame = static_cast<nsFileControlFrame*>(mFrame.GetFrame());
   101       NS_ENSURE_STATE(frame);
   103       frame->SyncDisabledState();
   104       return NS_OK;
   105     }
   107   private:
   108     nsWeakFrame mFrame;
   109   };
   111   class DnDListener: public MouseListener {
   112   public:
   113     DnDListener(nsFileControlFrame* aFrame)
   114       : MouseListener(aFrame)
   115     {}
   117     NS_DECL_NSIDOMEVENTLISTENER
   119     static bool IsValidDropData(nsIDOMDragEvent* aEvent);
   120   };
   122   virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
   123   {
   124     return nsBlockFrame::IsFrameOfType(aFlags &
   125       ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
   126   }
   128   /**
   129    * The text box input.
   130    * @see nsFileControlFrame::CreateAnonymousContent
   131    */
   132   nsCOMPtr<nsIContent> mTextContent;
   133   /**
   134    * The browse button input.
   135    * @see nsFileControlFrame::CreateAnonymousContent
   136    */
   137   nsCOMPtr<nsIContent> mBrowse;
   139   /**
   140    * Drag and drop mouse listener.
   141    * This makes sure we don't get used after destruction.
   142    */
   143   nsRefPtr<DnDListener> mMouseListener;
   145 protected:
   146   /**
   147    * Sync the disabled state of the content with anonymous children.
   148    */
   149   void SyncDisabledState();
   151   /**
   152    * Updates the displayed value by using aValue.
   153    */
   154   void UpdateDisplayedValue(const nsAString& aValue, bool aNotify);
   155 };
   157 #endif // nsFileControlFrame_h___

mercurial