michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsFileControlFrame_h___ michael@0: #define nsFileControlFrame_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsBlockFrame.h" michael@0: #include "nsIFormControlFrame.h" michael@0: #include "nsIDOMEventListener.h" michael@0: #include "nsIAnonymousContentCreator.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: class nsTextControlFrame; michael@0: class nsIDOMDragEvent; michael@0: michael@0: class nsFileControlFrame : public nsBlockFrame, michael@0: public nsIFormControlFrame, michael@0: public nsIAnonymousContentCreator michael@0: { michael@0: public: michael@0: nsFileControlFrame(nsStyleContext* aContext); michael@0: michael@0: virtual void Init(nsIContent* aContent, michael@0: nsIFrame* aParent, michael@0: nsIFrame* aPrevInFlow) MOZ_OVERRIDE; michael@0: michael@0: virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) MOZ_OVERRIDE; michael@0: michael@0: NS_DECL_QUERYFRAME michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: // nsIFormControlFrame michael@0: virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE; michael@0: virtual void SetFocus(bool aOn, bool aRepaint) MOZ_OVERRIDE; michael@0: michael@0: virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; michael@0: michael@0: virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; michael@0: michael@0: #ifdef DEBUG_FRAME_DUMP michael@0: virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: virtual nsresult AttributeChanged(int32_t aNameSpaceID, michael@0: nsIAtom* aAttribute, michael@0: int32_t aModType) MOZ_OVERRIDE; michael@0: virtual void ContentStatesChanged(mozilla::EventStates aStates) MOZ_OVERRIDE; michael@0: virtual bool IsLeaf() const MOZ_OVERRIDE michael@0: { michael@0: return true; michael@0: } michael@0: michael@0: // nsIAnonymousContentCreator michael@0: virtual nsresult CreateAnonymousContent(nsTArray& aElements) MOZ_OVERRIDE; michael@0: virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, michael@0: uint32_t aFilter) MOZ_OVERRIDE; michael@0: michael@0: #ifdef ACCESSIBILITY michael@0: virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: typedef bool (*AcceptAttrCallback)(const nsAString&, void*); michael@0: michael@0: protected: michael@0: michael@0: class MouseListener; michael@0: friend class MouseListener; michael@0: class MouseListener : public nsIDOMEventListener { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: MouseListener(nsFileControlFrame* aFrame) michael@0: : mFrame(aFrame) michael@0: {} michael@0: virtual ~MouseListener() {} michael@0: michael@0: void ForgetFrame() { michael@0: mFrame = nullptr; michael@0: } michael@0: michael@0: protected: michael@0: nsFileControlFrame* mFrame; michael@0: }; michael@0: michael@0: class SyncDisabledStateEvent; michael@0: friend class SyncDisabledStateEvent; michael@0: class SyncDisabledStateEvent : public nsRunnable michael@0: { michael@0: public: michael@0: SyncDisabledStateEvent(nsFileControlFrame* aFrame) michael@0: : mFrame(aFrame) michael@0: {} michael@0: michael@0: NS_IMETHOD Run() MOZ_OVERRIDE { michael@0: nsFileControlFrame* frame = static_cast(mFrame.GetFrame()); michael@0: NS_ENSURE_STATE(frame); michael@0: michael@0: frame->SyncDisabledState(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: private: michael@0: nsWeakFrame mFrame; michael@0: }; michael@0: michael@0: class DnDListener: public MouseListener { michael@0: public: michael@0: DnDListener(nsFileControlFrame* aFrame) michael@0: : MouseListener(aFrame) michael@0: {} michael@0: michael@0: NS_DECL_NSIDOMEVENTLISTENER michael@0: michael@0: static bool IsValidDropData(nsIDOMDragEvent* aEvent); michael@0: }; michael@0: michael@0: virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE michael@0: { michael@0: return nsBlockFrame::IsFrameOfType(aFlags & michael@0: ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); michael@0: } michael@0: michael@0: /** michael@0: * The text box input. michael@0: * @see nsFileControlFrame::CreateAnonymousContent michael@0: */ michael@0: nsCOMPtr mTextContent; michael@0: /** michael@0: * The browse button input. michael@0: * @see nsFileControlFrame::CreateAnonymousContent michael@0: */ michael@0: nsCOMPtr mBrowse; michael@0: michael@0: /** michael@0: * Drag and drop mouse listener. michael@0: * This makes sure we don't get used after destruction. michael@0: */ michael@0: nsRefPtr mMouseListener; michael@0: michael@0: protected: michael@0: /** michael@0: * Sync the disabled state of the content with anonymous children. michael@0: */ michael@0: void SyncDisabledState(); michael@0: michael@0: /** michael@0: * Updates the displayed value by using aValue. michael@0: */ michael@0: void UpdateDisplayedValue(const nsAString& aValue, bool aNotify); michael@0: }; michael@0: michael@0: #endif // nsFileControlFrame_h___