2017-10-27 17:33:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
|
2016-07-29 11:41:38 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2018-03-16 19:55:32 +00:00
|
|
|
class FileList;
|
2016-07-29 11:41:38 +00:00
|
|
|
class BlobImpl;
|
2018-03-13 20:24:00 +00:00
|
|
|
class DataTransfer;
|
2016-07-29 11:41:38 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2011-06-01 06:06:38 +00:00
|
|
|
|
2018-09-06 01:23:14 +00:00
|
|
|
class nsFileControlFrame final : public nsBlockFrame,
|
|
|
|
public nsIFormControlFrame,
|
|
|
|
public nsIAnonymousContentCreator {
|
1998-09-23 17:44:33 +00:00
|
|
|
public:
|
2018-10-06 17:31:51 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsFileControlFrame)
|
|
|
|
|
2019-02-05 16:45:54 +00:00
|
|
|
explicit nsFileControlFrame(ComputedStyle* aStyle,
|
|
|
|
nsPresContext* aPresContext);
|
1998-09-23 17:44:33 +00:00
|
|
|
|
2014-05-24 22:20:40 +00:00
|
|
|
virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
2006-11-13 22:05:25 +00:00
|
|
|
|
2018-10-06 17:31:51 +00:00
|
|
|
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
|
|
|
|
const ReflowInput& aReflowInput,
|
|
|
|
nsReflowStatus& aStatus) override;
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2005-12-12 23:53:06 +00:00
|
|
|
// nsIFormControlFrame
|
2017-10-02 22:05:19 +00:00
|
|
|
virtual nsresult SetFormProperty(nsAtom* aName,
|
|
|
|
const nsAString& aValue) override;
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void SetFocus(bool aOn, bool aRepaint) override;
|
1998-09-23 17:44:33 +00:00
|
|
|
|
2018-10-06 17:31:51 +00:00
|
|
|
nscoord GetMinISize(gfxContext* aRenderingContext) override;
|
|
|
|
nscoord GetPrefISize(gfxContext* aRenderingContext) override;
|
2013-03-22 17:10:13 +00:00
|
|
|
|
2017-11-07 00:20:33 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) override;
|
1998-09-23 17:44:33 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
2005-12-12 23:53:06 +00:00
|
|
|
|
2018-10-06 17:31:51 +00:00
|
|
|
nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
|
|
|
int32_t aModType) override;
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void ContentStatesChanged(mozilla::EventStates aStates) override;
|
1999-01-22 15:32:57 +00:00
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
// nsIAnonymousContentCreator
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult CreateAnonymousContent(
|
|
|
|
nsTArray<ContentInfo>& aElements) override;
|
2014-07-16 18:41:57 +00:00
|
|
|
virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint32_t aFilter) override;
|
1999-06-30 22:17:43 +00:00
|
|
|
|
2007-09-28 01:09:14 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual mozilla::a11y::AccType AccessibleType() 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:
|
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) : mFrame(aFrame) {}
|
2006-11-13 22:05:25 +00:00
|
|
|
|
|
|
|
void ForgetFrame() { mFrame = nullptr; }
|
|
|
|
|
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;
|
2016-04-26 00:23:21 +00:00
|
|
|
class SyncDisabledStateEvent : public mozilla::Runnable {
|
2010-12-14 18:00:57 +00:00
|
|
|
public:
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit SyncDisabledStateEvent(nsFileControlFrame* aFrame)
|
2017-06-12 19:34:10 +00:00
|
|
|
: mozilla::Runnable("nsFileControlFrame::SyncDisabledStateEvent"),
|
|
|
|
mFrame(aFrame) {}
|
2010-12-14 18:00:57 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD Run() 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:
|
2017-03-01 17:03:14 +00:00
|
|
|
WeakFrame mFrame;
|
2010-12-14 18:00:57 +00:00
|
|
|
};
|
|
|
|
|
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) : MouseListener(aFrame) {}
|
2012-05-07 16:27:24 +00:00
|
|
|
|
2018-11-21 03:59:02 +00:00
|
|
|
// nsIDOMEventListener
|
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
|
|
|
NS_IMETHOD HandleEvent(mozilla::dom::Event* aEvent) override;
|
2011-06-01 06:06:38 +00:00
|
|
|
|
2018-03-16 19:55:32 +00:00
|
|
|
nsresult GetBlobImplForWebkitDirectory(mozilla::dom::FileList* aFileList,
|
2016-07-29 11:41:38 +00:00
|
|
|
mozilla::dom::BlobImpl** aBlobImpl);
|
|
|
|
|
2018-03-13 20:24:00 +00:00
|
|
|
bool IsValidDropData(mozilla::dom::DataTransfer* aDataTransfer);
|
|
|
|
bool CanDropTheseFiles(mozilla::dom::DataTransfer* aDataTransfer,
|
|
|
|
bool aSupportsMultiple);
|
2010-07-23 21:35:51 +00:00
|
|
|
};
|
2010-08-27 15:49:06 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
2008-12-29 15:07:38 +00:00
|
|
|
return nsBlockFrame::IsFrameOfType(
|
2007-02-24 18:33:33 +00:00
|
|
|
aFlags & ~(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
|
|
|
|
*/
|
2017-12-05 17:05:51 +00:00
|
|
|
RefPtr<Element> mTextContent;
|
2002-06-12 07:58:26 +00:00
|
|
|
/**
|
2016-06-29 16:18:42 +00:00
|
|
|
* The button to open a file or directory picker.
|
2002-06-12 07:58:26 +00:00
|
|
|
* @see nsFileControlFrame::CreateAnonymousContent
|
|
|
|
*/
|
2017-12-05 17:05:51 +00:00
|
|
|
RefPtr<Element> mBrowseFilesOrDirs;
|
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
|
|
|
*/
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<DnDListener> mMouseListener;
|
2006-11-13 22:05:25 +00:00
|
|
|
|
2011-11-18 03:51:41 +00:00
|
|
|
protected:
|
2018-10-06 17:31:51 +00:00
|
|
|
/**
|
|
|
|
* Crop aText to fit inside aWidth using the styles of aFrame.
|
|
|
|
* @return true if aText was modified
|
|
|
|
*/
|
|
|
|
static bool CropTextToWidth(gfxContext& aRenderingContext,
|
|
|
|
const nsIFrame* aFrame, nscoord aWidth,
|
|
|
|
nsString& aText);
|
|
|
|
|
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___
|