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