2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
1998-09-23 17:44:33 +00:00
|
|
|
|
|
|
|
#ifndef nsFileControlFrame_h___
|
|
|
|
#define nsFileControlFrame_h___
|
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2008-12-29 15:07:38 +00:00
|
|
|
#include "nsBlockFrame.h"
|
1998-09-23 17:44:33 +00:00
|
|
|
#include "nsIFormControlFrame.h"
|
2011-06-29 18:07:57 +00:00
|
|
|
#include "nsIDOMEventListener.h"
|
1999-06-30 22:17:43 +00:00
|
|
|
#include "nsIAnonymousContentCreator.h"
|
2000-08-03 23:39:33 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-06-30 22:17:43 +00:00
|
|
|
|
2011-11-18 03:51:41 +00:00
|
|
|
class nsTextControlFrame;
|
2014-11-18 15:58:08 +00:00
|
|
|
class nsIDOMDataTransfer;
|
2011-06-01 06:06:38 +00:00
|
|
|
|
2008-12-29 15:07:38 +00:00
|
|
|
class nsFileControlFrame : public nsBlockFrame,
|
1999-06-30 22:17:43 +00:00
|
|
|
public nsIFormControlFrame,
|
2002-03-31 10:14:01 +00:00
|
|
|
public nsIAnonymousContentCreator
|
1998-09-23 17:44:33 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit nsFileControlFrame(nsStyleContext* aContext);
|
1998-09-23 17:44:33 +00:00
|
|
|
|
2014-05-24 22:20:40 +00:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
2006-11-13 22:05:25 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2005-12-12 23:53:06 +00:00
|
|
|
// nsIFormControlFrame
|
2013-05-14 16:33:23 +00:00
|
|
|
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) MOZ_OVERRIDE;
|
|
|
|
virtual void SetFocus(bool aOn, bool aRepaint) MOZ_OVERRIDE;
|
1998-09-23 17:44:33 +00:00
|
|
|
|
2014-07-24 17:03:25 +00:00
|
|
|
virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2013-03-22 17:10:13 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
1998-09-23 17:44:33 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
2005-12-12 23:53:06 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 08:36:33 +00:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2014-04-03 04:18:36 +00:00
|
|
|
virtual void ContentStatesChanged(mozilla::EventStates aStates) MOZ_OVERRIDE;
|
2014-02-24 14:41:56 +00:00
|
|
|
virtual bool IsLeaf() const MOZ_OVERRIDE
|
2013-03-22 17:15:13 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
1999-01-22 15:32:57 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
// nsIAnonymousContentCreator
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
|
2014-07-16 18:41:57 +00:00
|
|
|
virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
2012-09-14 16:10:08 +00:00
|
|
|
uint32_t aFilter) MOZ_OVERRIDE;
|
1999-06-30 22:17:43 +00:00
|
|
|
|
2007-09-28 01:09:14 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 21:53:44 +00:00
|
|
|
virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
|
2013-03-22 17:10:13 +00:00
|
|
|
#endif
|
2007-09-28 01:09:14 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
typedef bool (*AcceptAttrCallback)(const nsAString&, void*);
|
2010-07-21 16:07:55 +00:00
|
|
|
|
1998-09-23 17:44:33 +00:00
|
|
|
protected:
|
2013-03-22 17:10:13 +00:00
|
|
|
|
2006-11-13 22:05:25 +00:00
|
|
|
class MouseListener;
|
|
|
|
friend class MouseListener;
|
2012-06-19 03:26:34 +00:00
|
|
|
class MouseListener : public nsIDOMEventListener {
|
2006-11-13 22:05:25 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2013-03-22 17:10:13 +00:00
|
|
|
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit MouseListener(nsFileControlFrame* aFrame)
|
2013-03-22 17:10:13 +00:00
|
|
|
: mFrame(aFrame)
|
2006-11-13 22:05:25 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
void ForgetFrame() {
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrame = nullptr;
|
2006-11-13 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2010-07-23 21:35:51 +00:00
|
|
|
protected:
|
2014-06-23 22:40:01 +00:00
|
|
|
virtual ~MouseListener() {}
|
|
|
|
|
2006-11-13 22:05:25 +00:00
|
|
|
nsFileControlFrame* mFrame;
|
|
|
|
};
|
2010-12-14 18:00:57 +00:00
|
|
|
|
|
|
|
class SyncDisabledStateEvent;
|
|
|
|
friend class SyncDisabledStateEvent;
|
|
|
|
class SyncDisabledStateEvent : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit SyncDisabledStateEvent(nsFileControlFrame* aFrame)
|
2010-12-14 18:00:57 +00:00
|
|
|
: mFrame(aFrame)
|
|
|
|
{}
|
|
|
|
|
2013-05-29 19:37:49 +00:00
|
|
|
NS_IMETHOD Run() MOZ_OVERRIDE {
|
2010-12-14 18:00:57 +00:00
|
|
|
nsFileControlFrame* frame = static_cast<nsFileControlFrame*>(mFrame.GetFrame());
|
|
|
|
NS_ENSURE_STATE(frame);
|
|
|
|
|
|
|
|
frame->SyncDisabledState();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsWeakFrame mFrame;
|
|
|
|
};
|
|
|
|
|
2013-03-27 11:32:00 +00:00
|
|
|
class DnDListener: public MouseListener {
|
2010-07-23 21:35:51 +00:00
|
|
|
public:
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit DnDListener(nsFileControlFrame* aFrame)
|
2013-03-22 17:10:13 +00:00
|
|
|
: MouseListener(aFrame)
|
2012-05-07 16:27:24 +00:00
|
|
|
{}
|
|
|
|
|
2011-06-29 18:07:57 +00:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2011-06-01 06:06:38 +00:00
|
|
|
|
2014-11-18 15:58:08 +00:00
|
|
|
static bool IsValidDropData(nsIDOMDataTransfer* aDOMDataTransfer);
|
|
|
|
static bool CanDropTheseFiles(nsIDOMDataTransfer* aDOMDataTransfer, bool aSupportsMultiple);
|
2010-07-23 21:35:51 +00:00
|
|
|
};
|
2010-08-27 15:49:06 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
2007-02-24 18:33:33 +00:00
|
|
|
{
|
2008-12-29 15:07:38 +00:00
|
|
|
return nsBlockFrame::IsFrameOfType(aFlags &
|
2007-02-24 18:33:33 +00:00
|
|
|
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2002-06-12 07:58:26 +00:00
|
|
|
/**
|
|
|
|
* The text box input.
|
|
|
|
* @see nsFileControlFrame::CreateAnonymousContent
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> mTextContent;
|
|
|
|
/**
|
|
|
|
* The browse button input.
|
|
|
|
* @see nsFileControlFrame::CreateAnonymousContent
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> mBrowse;
|
1998-09-23 17:44:33 +00:00
|
|
|
|
2006-11-13 22:05:25 +00:00
|
|
|
/**
|
2013-03-27 11:32:00 +00:00
|
|
|
* Drag and drop mouse listener.
|
|
|
|
* This makes sure we don't get used after destruction.
|
2006-11-13 22:05:25 +00:00
|
|
|
*/
|
2013-03-27 11:32:00 +00:00
|
|
|
nsRefPtr<DnDListener> mMouseListener;
|
2006-11-13 22:05:25 +00:00
|
|
|
|
2011-11-18 03:51:41 +00:00
|
|
|
protected:
|
2002-06-12 07:58:26 +00:00
|
|
|
/**
|
2013-02-09 14:57:30 +00:00
|
|
|
* Sync the disabled state of the content with anonymous children.
|
2002-06-12 07:58:26 +00:00
|
|
|
*/
|
2013-02-09 14:57:30 +00:00
|
|
|
void SyncDisabledState();
|
2010-12-14 18:00:57 +00:00
|
|
|
|
|
|
|
/**
|
2013-02-09 14:57:30 +00:00
|
|
|
* Updates the displayed value by using aValue.
|
2010-12-14 18:00:57 +00:00
|
|
|
*/
|
2013-02-09 14:57:30 +00:00
|
|
|
void UpdateDisplayedValue(const nsAString& aValue, bool aNotify);
|
1998-09-23 17:44:33 +00:00
|
|
|
};
|
|
|
|
|
2013-03-22 17:15:13 +00:00
|
|
|
#endif // nsFileControlFrame_h___
|