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
|
|
|
|
|
|
|
#include "nsFileControlFrame.h"
|
|
|
|
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsXPCOM.h"
|
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsIFilePicker.h"
|
|
|
|
#include "nsIDOMMouseEvent.h"
|
|
|
|
#include "nsINodeInfo.h"
|
2007-05-14 02:11:38 -07:00
|
|
|
#include "nsIDOMEventTarget.h"
|
2012-06-05 19:08:30 -07:00
|
|
|
#include "nsIFile.h"
|
2010-09-05 11:00:05 -07:00
|
|
|
#include "nsHTMLInputElement.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsContentCreatorFunctions.h"
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsDisplayList.h"
|
2011-06-23 19:18:02 -07:00
|
|
|
#include "nsEventListenerManager.h"
|
2010-02-11 00:35:49 -08:00
|
|
|
|
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
#include "nsURIHashKey.h"
|
|
|
|
#include "nsNetCID.h"
|
|
|
|
#include "nsWeakReference.h"
|
2009-12-22 17:05:26 -08:00
|
|
|
#include "nsIVariant.h"
|
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 09:59:13 -07:00
|
|
|
#include "mozilla/Services.h"
|
2010-05-30 15:54:34 -07:00
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2010-09-05 11:00:05 -07:00
|
|
|
#include "nsDOMFile.h"
|
2011-04-21 10:35:52 -07:00
|
|
|
#include "nsEventStates.h"
|
2011-11-17 19:51:41 -08:00
|
|
|
#include "nsTextControlFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-05-31 23:06:38 -07:00
|
|
|
#include "nsIDOMDOMStringList.h"
|
|
|
|
#include "nsIDOMDragEvent.h"
|
2012-09-05 13:49:53 -07:00
|
|
|
#include "nsContentList.h"
|
2013-02-09 06:57:30 -08:00
|
|
|
#include "nsIDOMMutationEvent.h"
|
2011-05-31 23:06:38 -07:00
|
|
|
|
2012-10-15 15:44:34 -07:00
|
|
|
using namespace mozilla;
|
2010-10-25 05:17:38 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewFileControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsFileControlFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsFileControlFrame)
|
|
|
|
|
2013-03-22 10:15:13 -07:00
|
|
|
nsFileControlFrame::nsFileControlFrame(nsStyleContext* aContext)
|
|
|
|
: nsBlockFrame(aContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-01-19 10:31:32 -08:00
|
|
|
AddStateBits(NS_BLOCK_FLOAT_MGR);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-19 18:47:48 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFileControlFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2013-03-19 18:47:48 -07:00
|
|
|
nsBlockFrame::Init(aContent, aParent, aPrevInFlow);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-27 04:32:00 -07:00
|
|
|
mMouseListener = new DnDListener(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-23 21:21:15 -08:00
|
|
|
nsFileControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-01-10 13:55:38 -08:00
|
|
|
ENSURE_TRUE(mContent);
|
|
|
|
|
2013-03-22 10:15:13 -07:00
|
|
|
// Remove the events.
|
2011-11-28 20:39:21 -08:00
|
|
|
if (mContent) {
|
|
|
|
mContent->RemoveSystemEventListener(NS_LITERAL_STRING("drop"),
|
|
|
|
mMouseListener, false);
|
|
|
|
mContent->RemoveSystemEventListener(NS_LITERAL_STRING("dragover"),
|
|
|
|
mMouseListener, false);
|
2011-05-31 23:06:38 -07:00
|
|
|
}
|
|
|
|
|
2011-06-23 19:18:02 -07:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mTextContent);
|
2013-03-27 04:35:22 -07:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mBrowse);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mMouseListener->ForgetFrame();
|
2009-12-23 21:21:15 -08:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2011-05-06 13:04:44 -07:00
|
|
|
nsFileControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2013-02-09 07:09:14 -08:00
|
|
|
|
|
|
|
// Create and setup the file picking button.
|
|
|
|
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::input, nullptr,
|
|
|
|
kNameSpaceID_XHTML,
|
2011-06-14 00:56:49 -07:00
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
2013-02-09 07:09:14 -08:00
|
|
|
NS_NewHTMLElement(getter_AddRefs(mBrowse), nodeInfo.forget(),
|
|
|
|
dom::NOT_FROM_PARSER);
|
|
|
|
// NOTE: SetNativeAnonymous() has to be called before setting any attribute.
|
|
|
|
mBrowse->SetNativeAnonymous();
|
|
|
|
mBrowse->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
NS_LITERAL_STRING("button"), false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-09 02:48:20 -08:00
|
|
|
// Set the file picking button text depending on the current locale.
|
|
|
|
nsXPIDLString buttonValue;
|
|
|
|
nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
|
|
|
|
"Browse", buttonValue);
|
|
|
|
mBrowse->SetAttr(kNameSpaceID_None, nsGkAtoms::value, buttonValue, false);
|
|
|
|
|
2013-02-09 07:09:14 -08:00
|
|
|
// Make sure access key and tab order for the element actually redirect to the
|
|
|
|
// file picking button.
|
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> fileContent = do_QueryInterface(mContent);
|
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> browseControl = do_QueryInterface(mBrowse);
|
|
|
|
|
|
|
|
nsAutoString accessKey;
|
|
|
|
fileContent->GetAccessKey(accessKey);
|
|
|
|
browseControl->SetAccessKey(accessKey);
|
|
|
|
|
|
|
|
int32_t tabIndex;
|
|
|
|
fileContent->GetTabIndex(&tabIndex);
|
|
|
|
browseControl->SetTabIndex(tabIndex);
|
|
|
|
|
|
|
|
if (!aElements.AppendElement(mBrowse)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2013-02-09 07:09:14 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-09 07:09:14 -08:00
|
|
|
// Create and setup the text showing the selected files.
|
|
|
|
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::label, nullptr,
|
|
|
|
kNameSpaceID_XUL,
|
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
|
|
|
NS_TrustedNewXULElement(getter_AddRefs(mTextContent), nodeInfo.forget());
|
|
|
|
// NOTE: SetNativeAnonymous() has to be called before setting any attribute.
|
2009-01-31 04:34:01 -08:00
|
|
|
mTextContent->SetNativeAnonymous();
|
2013-02-09 06:57:30 -08:00
|
|
|
mTextContent->SetAttr(kNameSpaceID_None, nsGkAtoms::crop,
|
|
|
|
NS_LITERAL_STRING("center"), false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-09 07:09:14 -08:00
|
|
|
// Update the displayed text to reflect the current element's value.
|
2010-09-05 11:00:05 -07:00
|
|
|
nsAutoString value;
|
2013-02-09 07:09:14 -08:00
|
|
|
nsHTMLInputElement::FromContent(mContent)->GetDisplayFileName(value);
|
2013-02-09 06:57:30 -08:00
|
|
|
UpdateDisplayedValue(value, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-09 07:09:14 -08:00
|
|
|
if (!aElements.AppendElement(mTextContent)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2013-02-09 07:09:14 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-27 04:32:00 -07:00
|
|
|
// We should be able to interact with the element by doing drag and drop.
|
2011-11-28 20:39:21 -08:00
|
|
|
mContent->AddSystemEventListener(NS_LITERAL_STRING("drop"),
|
|
|
|
mMouseListener, false);
|
|
|
|
mContent->AddSystemEventListener(NS_LITERAL_STRING("dragover"),
|
|
|
|
mMouseListener, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-12-14 10:00:57 -08:00
|
|
|
SyncDisabledState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-11 09:34:01 -08:00
|
|
|
void
|
2010-10-15 08:34:35 -07:00
|
|
|
nsFileControlFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFilter)
|
2010-02-11 09:34:01 -08:00
|
|
|
{
|
|
|
|
aElements.MaybeAppendElement(mBrowse);
|
2013-03-27 04:35:22 -07:00
|
|
|
aElements.MaybeAppendElement(mTextContent);
|
2010-02-11 09:34:01 -08:00
|
|
|
}
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_HEAD(nsFileControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void
|
2011-09-28 23:19:26 -07:00
|
|
|
nsFileControlFrame::SetFocus(bool aOn, bool aRepaint)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-05-31 23:06:38 -07:00
|
|
|
/**
|
2013-03-27 04:32:00 -07:00
|
|
|
* This is called when we receive a drop or a dragover.
|
2011-05-31 23:06:38 -07:00
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2013-03-27 04:32:00 -07:00
|
|
|
nsFileControlFrame::DnDListener::HandleEvent(nsIDOMEvent* aEvent)
|
2011-05-31 23:06:38 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mFrame, "We should have been unregistered");
|
2011-06-29 11:07:57 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool defaultPrevented = false;
|
2012-08-04 00:44:00 -07:00
|
|
|
aEvent->GetPreventDefault(&defaultPrevented);
|
2011-05-31 23:06:38 -07:00
|
|
|
if (defaultPrevented) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-03-27 04:32:00 -07:00
|
|
|
|
2011-05-31 23:06:38 -07:00
|
|
|
nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent);
|
|
|
|
if (!dragEvent || !IsValidDropData(dragEvent)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-27 04:32:00 -07:00
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
2011-05-31 23:06:38 -07:00
|
|
|
if (eventType.EqualsLiteral("dragover")) {
|
|
|
|
// Prevent default if we can accept this drag data
|
|
|
|
aEvent->PreventDefault();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eventType.EqualsLiteral("drop")) {
|
|
|
|
aEvent->StopPropagation();
|
|
|
|
aEvent->PreventDefault();
|
|
|
|
|
|
|
|
nsIContent* content = mFrame->GetContent();
|
|
|
|
NS_ASSERTION(content, "The frame has no content???");
|
|
|
|
|
|
|
|
nsHTMLInputElement* inputElement = nsHTMLInputElement::FromContent(content);
|
|
|
|
NS_ASSERTION(inputElement, "No input element for this file upload control frame!");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
|
|
|
|
dragEvent->GetDataTransfer(getter_AddRefs(dataTransfer));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMFileList> fileList;
|
|
|
|
dataTransfer->GetFiles(getter_AddRefs(fileList));
|
2011-06-10 05:44:53 -07:00
|
|
|
|
2011-05-31 23:06:38 -07:00
|
|
|
inputElement->SetFiles(fileList, true);
|
2012-09-14 07:38:04 -07:00
|
|
|
nsContentUtils::DispatchTrustedEvent(content->OwnerDoc(), content,
|
|
|
|
NS_LITERAL_STRING("change"), true,
|
|
|
|
false);
|
2011-05-31 23:06:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
/* static */ bool
|
2013-03-27 04:32:00 -07:00
|
|
|
nsFileControlFrame::DnDListener::IsValidDropData(nsIDOMDragEvent* aEvent)
|
2011-05-31 23:06:38 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
|
|
|
|
aEvent->GetDataTransfer(getter_AddRefs(dataTransfer));
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ENSURE_TRUE(dataTransfer, false);
|
2011-05-31 23:06:38 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDOMStringList> types;
|
|
|
|
dataTransfer->GetTypes(getter_AddRefs(types));
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ENSURE_TRUE(types, false);
|
2011-05-31 23:06:38 -07:00
|
|
|
|
|
|
|
// We only support dropping files onto a file upload control
|
2011-09-28 23:19:26 -07:00
|
|
|
bool typeSupported;
|
2011-05-31 23:06:38 -07:00
|
|
|
types->Contains(NS_LITERAL_STRING("Files"), &typeSupported);
|
|
|
|
return typeSupported;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord
|
2011-04-07 18:04:40 -07:00
|
|
|
nsFileControlFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
|
|
|
|
// Our min width is our pref width
|
|
|
|
result = GetPrefWidth(aRenderingContext);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-12-14 10:00:57 -08:00
|
|
|
void
|
|
|
|
nsFileControlFrame::SyncDisabledState()
|
|
|
|
{
|
2011-05-31 18:46:57 -07:00
|
|
|
nsEventStates eventStates = mContent->AsElement()->State();
|
2010-12-14 10:00:57 -08:00
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
|
|
|
mBrowse->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, EmptyString(),
|
2011-10-17 07:59:28 -07:00
|
|
|
true);
|
2010-12-14 10:00:57 -08:00
|
|
|
} else {
|
2011-10-17 07:59:28 -07:00
|
|
|
mBrowse->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, true);
|
2010-12-14 10:00:57 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
2013-02-09 06:57:30 -08:00
|
|
|
nsFileControlFrame::AttributeChanged(int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-09 06:57:30 -08:00
|
|
|
if (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::tabindex) {
|
|
|
|
if (aModType == nsIDOMMutationEvent::REMOVAL) {
|
|
|
|
mBrowse->UnsetAttr(aNameSpaceID, aAttribute, true);
|
|
|
|
} else {
|
|
|
|
nsAutoString value;
|
|
|
|
mContent->GetAttr(aNameSpaceID, aAttribute, value);
|
|
|
|
mBrowse->SetAttr(aNameSpaceID, aAttribute, value, true);
|
2008-12-16 23:33:33 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-29 07:07:38 -08:00
|
|
|
return nsBlockFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-12-14 10:00:57 -08:00
|
|
|
void
|
|
|
|
nsFileControlFrame::ContentStatesChanged(nsEventStates aStates)
|
|
|
|
{
|
|
|
|
if (aStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
|
|
|
nsContentUtils::AddScriptRunner(new SyncDisabledStateEvent(this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFileControlFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("FileControl"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-02-09 06:57:30 -08:00
|
|
|
void
|
|
|
|
nsFileControlFrame::UpdateDisplayedValue(const nsAString& aValue, bool aNotify)
|
|
|
|
{
|
2013-02-07 05:58:05 -08:00
|
|
|
mTextContent->SetAttr(kNameSpaceID_None, nsGkAtoms::value, aValue, aNotify);
|
2013-02-09 06:57:30 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult
|
|
|
|
nsFileControlFrame::SetFormProperty(nsIAtom* aName,
|
|
|
|
const nsAString& aValue)
|
|
|
|
{
|
|
|
|
if (nsGkAtoms::value == aName) {
|
2013-02-09 06:57:30 -08:00
|
|
|
UpdateDisplayedValue(aValue, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return NS_OK;
|
2013-02-09 06:57:30 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFileControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2009-01-29 23:10:25 -08:00
|
|
|
// box-shadow
|
2013-02-16 13:51:02 -08:00
|
|
|
if (StyleBorder()->mBoxShadow) {
|
2013-02-14 03:08:08 -08:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayBoxShadowOuter(aBuilder, this));
|
2009-01-29 23:10:25 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Our background is inherited to the text input, and we don't really want to
|
|
|
|
// paint it or out padding and borders (which we never have anyway, per
|
|
|
|
// styles in forms.css) -- doing it just makes us look ugly in some cases and
|
|
|
|
// has no effect in others.
|
|
|
|
nsDisplayListCollection tempList;
|
2013-02-14 03:08:08 -08:00
|
|
|
nsBlockFrame::BuildDisplayList(aBuilder, aDirtyRect, tempList);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
tempList.BorderBackground()->DeleteAll();
|
2007-11-26 19:35:50 -08:00
|
|
|
|
2008-01-07 14:18:06 -08:00
|
|
|
// Clip height only
|
|
|
|
nsRect clipRect(aBuilder->ToReferenceFrame(this), GetSize());
|
2010-10-06 21:25:47 -07:00
|
|
|
clipRect.width = GetVisualOverflowRect().XMost();
|
2010-09-09 08:21:46 -07:00
|
|
|
nscoord radii[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
2013-02-14 03:08:08 -08:00
|
|
|
OverflowClip(aBuilder, tempList, aLists, clipRect, radii);
|
2007-11-26 19:35:50 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Disabled file controls don't pass mouse events to their children, so we
|
|
|
|
// put an invisible item in the display list above the children
|
|
|
|
// just to catch events
|
2011-05-31 18:46:57 -07:00
|
|
|
nsEventStates eventStates = mContent->AsElement()->State();
|
2010-10-20 04:26:32 -07:00
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED) && IsVisibleForPainting(aBuilder)) {
|
2013-02-14 03:08:08 -08:00
|
|
|
aLists.Content()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayEventReceiver(aBuilder, this));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:08:08 -08:00
|
|
|
DisplaySelectionOverlay(aBuilder, aLists.Content());
|
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
|
|
|
a11y::AccType
|
|
|
|
nsFileControlFrame::AccessibleType()
|
2007-09-27 18:09:14 -07:00
|
|
|
{
|
2012-12-17 17:25:52 -08:00
|
|
|
return a11y::eHTMLFileInputType;
|
2007-09-27 18:09:14 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Mouse listener implementation
|
|
|
|
|
2011-06-29 11:07:57 -07:00
|
|
|
NS_IMPL_ISUPPORTS1(nsFileControlFrame::MouseListener,
|
2008-04-06 05:28:34 -07:00
|
|
|
nsIDOMEventListener)
|