2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsFileControlFrame_h___
|
|
|
|
#define nsFileControlFrame_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2008-12-29 07:07:38 -08:00
|
|
|
#include "nsBlockFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIFormControlFrame.h"
|
2011-06-29 11:07:57 -07:00
|
|
|
#include "nsIDOMEventListener.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIAnonymousContentCreator.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2011-11-17 19:51:41 -08:00
|
|
|
class nsTextControlFrame;
|
2011-05-31 23:06:38 -07:00
|
|
|
class nsIDOMDragEvent;
|
|
|
|
|
2008-12-29 07:07:38 -08:00
|
|
|
class nsFileControlFrame : public nsBlockFrame,
|
2007-03-22 10:30:00 -07:00
|
|
|
public nsIFormControlFrame,
|
|
|
|
public nsIAnonymousContentCreator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsFileControlFrame(nsStyleContext* aContext);
|
|
|
|
|
2013-03-19 18:47:48 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIFormControlFrame
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE;
|
|
|
|
virtual void SetFocus(bool aOn, bool aRepaint) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2013-03-22 10:10:13 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 00:36:33 -08:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2014-04-02 21:18:36 -07:00
|
|
|
virtual void ContentStatesChanged(mozilla::EventStates aStates) MOZ_OVERRIDE;
|
2014-02-24 06:41:56 -08:00
|
|
|
virtual bool IsLeaf() const MOZ_OVERRIDE
|
2013-03-22 10:15:13 -07:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// nsIAnonymousContentCreator
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
|
2010-10-15 08:34:35 -07:00
|
|
|
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
2012-09-14 09:10:08 -07:00
|
|
|
uint32_t aFilter) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-27 18:09:14 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 14:53:44 -07:00
|
|
|
virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
|
2013-03-22 10:10:13 -07:00
|
|
|
#endif
|
2007-09-27 18:09:14 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
typedef bool (*AcceptAttrCallback)(const nsAString&, void*);
|
2010-07-21 09:07:55 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2013-03-22 10:10:13 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class MouseListener;
|
|
|
|
friend class MouseListener;
|
2012-06-18 20:26:34 -07:00
|
|
|
class MouseListener : public nsIDOMEventListener {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2013-03-22 10:10:13 -07:00
|
|
|
|
2012-05-07 09:27:24 -07:00
|
|
|
MouseListener(nsFileControlFrame* aFrame)
|
2013-03-22 10:10:13 -07:00
|
|
|
: mFrame(aFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
{}
|
2012-06-18 20:26:34 -07:00
|
|
|
virtual ~MouseListener() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void ForgetFrame() {
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrame = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-23 14:35:51 -07:00
|
|
|
protected:
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFileControlFrame* mFrame;
|
|
|
|
};
|
2010-12-14 10:00:57 -08:00
|
|
|
|
|
|
|
class SyncDisabledStateEvent;
|
|
|
|
friend class SyncDisabledStateEvent;
|
|
|
|
class SyncDisabledStateEvent : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SyncDisabledStateEvent(nsFileControlFrame* aFrame)
|
|
|
|
: mFrame(aFrame)
|
|
|
|
{}
|
|
|
|
|
2013-05-29 12:37:49 -07:00
|
|
|
NS_IMETHOD Run() MOZ_OVERRIDE {
|
2010-12-14 10:00:57 -08:00
|
|
|
nsFileControlFrame* frame = static_cast<nsFileControlFrame*>(mFrame.GetFrame());
|
|
|
|
NS_ENSURE_STATE(frame);
|
|
|
|
|
|
|
|
frame->SyncDisabledState();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsWeakFrame mFrame;
|
|
|
|
};
|
|
|
|
|
2013-03-27 04:32:00 -07:00
|
|
|
class DnDListener: public MouseListener {
|
2010-07-23 14:35:51 -07:00
|
|
|
public:
|
2013-03-27 04:32:00 -07:00
|
|
|
DnDListener(nsFileControlFrame* aFrame)
|
2013-03-22 10:10:13 -07:00
|
|
|
: MouseListener(aFrame)
|
2012-05-07 09:27:24 -07:00
|
|
|
{}
|
|
|
|
|
2011-06-29 11:07:57 -07:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2011-05-31 23:06:38 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsValidDropData(nsIDOMDragEvent* aEvent);
|
2010-07-23 14:35:51 -07:00
|
|
|
};
|
2010-08-27 08:49:06 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-12-29 07:07:38 -08:00
|
|
|
return nsBlockFrame::IsFrameOfType(aFlags &
|
2007-03-22 10:30:00 -07:00
|
|
|
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The text box input.
|
|
|
|
* @see nsFileControlFrame::CreateAnonymousContent
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> mTextContent;
|
|
|
|
/**
|
|
|
|
* The browse button input.
|
|
|
|
* @see nsFileControlFrame::CreateAnonymousContent
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> mBrowse;
|
|
|
|
|
|
|
|
/**
|
2013-03-27 04:32:00 -07:00
|
|
|
* Drag and drop mouse listener.
|
|
|
|
* This makes sure we don't get used after destruction.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-03-27 04:32:00 -07:00
|
|
|
nsRefPtr<DnDListener> mMouseListener;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-11-17 19:51:41 -08:00
|
|
|
protected:
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
2013-02-09 06:57:30 -08:00
|
|
|
* Sync the disabled state of the content with anonymous children.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-02-09 06:57:30 -08:00
|
|
|
void SyncDisabledState();
|
2010-12-14 10:00:57 -08:00
|
|
|
|
|
|
|
/**
|
2013-02-09 06:57:30 -08:00
|
|
|
* Updates the displayed value by using aValue.
|
2010-12-14 10:00:57 -08:00
|
|
|
*/
|
2013-02-09 06:57:30 -08:00
|
|
|
void UpdateDisplayedValue(const nsAString& aValue, bool aNotify);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2013-03-22 10:15:13 -07:00
|
|
|
#endif // nsFileControlFrame_h___
|