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"
|
2010-07-23 14:35:51 -07:00
|
|
|
#include "nsICapturePicker.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#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
|
|
|
|
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue);
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const MOZ_OVERRIDE;
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void SetFocus(bool aOn, bool aRepaint);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -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
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2012-09-14 09:10:08 -07:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-09-14 09:10:08 -07:00
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2010-12-14 10:00:57 -08:00
|
|
|
virtual void ContentStatesChanged(nsEventStates aStates);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool IsLeaf() const;
|
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;
|
2012-03-12 03:36:02 -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:
|
2012-03-12 03:36:02 -07:00
|
|
|
|
|
|
|
struct CaptureCallbackData {
|
|
|
|
nsICapturePicker* picker;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mode;
|
2012-03-12 03:36:02 -07:00
|
|
|
};
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetCaptureMode(const CaptureCallbackData& aData);
|
2012-03-12 03:36:02 -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
|
|
|
|
|
2012-05-07 09:27:24 -07:00
|
|
|
MouseListener(nsFileControlFrame* aFrame)
|
|
|
|
: 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)
|
|
|
|
{}
|
|
|
|
|
|
|
|
NS_IMETHOD Run() {
|
|
|
|
nsFileControlFrame* frame = static_cast<nsFileControlFrame*>(mFrame.GetFrame());
|
|
|
|
NS_ENSURE_STATE(frame);
|
|
|
|
|
|
|
|
frame->SyncDisabledState();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsWeakFrame mFrame;
|
|
|
|
};
|
|
|
|
|
2010-07-23 14:35:51 -07:00
|
|
|
class CaptureMouseListener: public MouseListener {
|
|
|
|
public:
|
2012-05-07 09:27:24 -07:00
|
|
|
CaptureMouseListener(nsFileControlFrame* aFrame)
|
|
|
|
: MouseListener(aFrame)
|
|
|
|
, mMode(0)
|
|
|
|
{}
|
|
|
|
|
2011-06-29 11:07:57 -07:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mMode;
|
2010-07-23 14:35:51 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class BrowseMouseListener: public MouseListener {
|
|
|
|
public:
|
2012-05-07 09:27:24 -07:00
|
|
|
BrowseMouseListener(nsFileControlFrame* aFrame)
|
|
|
|
: MouseListener(aFrame)
|
|
|
|
{}
|
|
|
|
|
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;
|
|
|
|
|
2010-07-23 14:35:51 -07:00
|
|
|
/**
|
|
|
|
* The capture button input.
|
|
|
|
* @see nsFileControlFrame::CreateAnonymousContent
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> mCapture;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Our mouse listener. This makes sure we don't get used after destruction.
|
|
|
|
*/
|
2010-07-23 14:35:51 -07:00
|
|
|
nsRefPtr<BrowseMouseListener> mMouseListener;
|
|
|
|
nsRefPtr<CaptureMouseListener> mCaptureMouseListener;
|
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
|
|
|
/**
|
|
|
|
* @return the text control frame, or null if not found
|
|
|
|
*/
|
2011-11-17 19:51:41 -08:00
|
|
|
nsTextControlFrame* GetTextControlFrame();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy an attribute from file content to text and button content.
|
|
|
|
* @param aNameSpaceID namespace of attr
|
|
|
|
* @param aAttribute attribute atom
|
2010-12-14 10:00:57 -08:00
|
|
|
* @param aWhichControls which controls to apply to (SYNC_TEXT or SYNC_FILE)
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void SyncAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
|
|
|
int32_t aWhichControls);
|
2010-12-14 10:00:57 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sync the disabled state of the content with anonymous children.
|
|
|
|
*/
|
|
|
|
void SyncDisabledState();
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|