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:16:51 +00:00
|
|
|
|
|
|
|
#include "nsFileControlFrame.h"
|
2000-05-02 03:40:44 +00:00
|
|
|
|
1998-09-23 17:16:51 +00:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIAtom.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1998-09-23 17:16:51 +00:00
|
|
|
#include "nsWidgetsCID.h"
|
1999-03-09 09:44:27 +00:00
|
|
|
#include "nsIComponentManager.h"
|
1998-09-23 17:16:51 +00:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2013-03-29 12:32:47 +00:00
|
|
|
#include "nsIDOMHTMLButtonElement.h"
|
1998-09-23 17:16:51 +00:00
|
|
|
#include "nsIFormControl.h"
|
1998-12-20 01:21:23 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
1999-02-18 00:13:39 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-06-30 22:17:43 +00:00
|
|
|
#include "nsIDOMElement.h"
|
2000-12-30 19:22:22 +00:00
|
|
|
#include "nsIDocument.h"
|
1999-08-21 00:09:24 +00:00
|
|
|
#include "nsIPresShell.h"
|
2002-09-03 23:36:13 +00:00
|
|
|
#include "nsXPCOM.h"
|
1999-09-15 05:31:31 +00:00
|
|
|
#include "nsISupportsPrimitives.h"
|
2005-11-28 23:56:44 +00:00
|
|
|
#include "nsPIDOMWindow.h"
|
2000-08-18 18:16:12 +00:00
|
|
|
#include "nsIFilePicker.h"
|
2000-08-25 13:25:50 +00:00
|
|
|
#include "nsIDOMMouseEvent.h"
|
2000-12-30 19:22:22 +00:00
|
|
|
#include "nsINodeInfo.h"
|
2012-06-06 02:08:30 +00:00
|
|
|
#include "nsIFile.h"
|
2013-03-28 19:41:32 +00:00
|
|
|
#include "mozilla/dom/HTMLInputElement.h"
|
2004-06-25 12:26:02 +00:00
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsContentCreatorFunctions.h"
|
2004-12-17 20:40:48 +00:00
|
|
|
#include "nsContentUtils.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2011-06-24 02:18:02 +00:00
|
|
|
#include "nsEventListenerManager.h"
|
2010-02-11 08:35:49 +00:00
|
|
|
|
|
|
|
#include "nsInterfaceHashtable.h"
|
|
|
|
#include "nsURIHashKey.h"
|
|
|
|
#include "nsNetCID.h"
|
|
|
|
#include "nsWeakReference.h"
|
2009-12-23 01:05:26 +00: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 16:59:13 +00:00
|
|
|
#include "mozilla/Services.h"
|
2010-05-30 22:54:34 +00:00
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2010-09-05 18:00:05 +00:00
|
|
|
#include "nsDOMFile.h"
|
2011-04-21 17:35:52 +00:00
|
|
|
#include "nsEventStates.h"
|
2011-11-18 03:51:41 +00:00
|
|
|
#include "nsTextControlFrame.h"
|
1998-09-23 17:16:51 +00:00
|
|
|
|
2011-06-01 06:06:38 +00:00
|
|
|
#include "nsIDOMDOMStringList.h"
|
|
|
|
#include "nsIDOMDragEvent.h"
|
2012-09-05 20:49:53 +00:00
|
|
|
#include "nsContentList.h"
|
2013-02-09 14:57:30 +00:00
|
|
|
#include "nsIDOMMutationEvent.h"
|
2013-04-04 12:01:08 +00:00
|
|
|
#include "nsTextNode.h"
|
2011-06-01 06:06:38 +00:00
|
|
|
|
2012-10-15 22:44:34 +00:00
|
|
|
using namespace mozilla;
|
2013-03-28 19:41:32 +00:00
|
|
|
using namespace mozilla::dom;
|
2010-10-25 12:17:38 +00:00
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewFileControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-09-23 17:16:51 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsFileControlFrame(aContext);
|
1998-09-23 17:16:51 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsFileControlFrame)
|
|
|
|
|
2013-03-22 17:15:13 +00:00
|
|
|
nsFileControlFrame::nsFileControlFrame(nsStyleContext* aContext)
|
|
|
|
: nsBlockFrame(aContext)
|
1998-09-23 17:16:51 +00:00
|
|
|
{
|
2009-01-19 18:31:32 +00:00
|
|
|
AddStateBits(NS_BLOCK_FLOAT_MGR);
|
1999-06-30 22:17:43 +00:00
|
|
|
}
|
|
|
|
|
1999-08-19 14:03:53 +00:00
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
void
|
2006-11-13 22:05:25 +00:00
|
|
|
nsFileControlFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2013-03-20 01:47:48 +00:00
|
|
|
nsBlockFrame::Init(aContent, aParent, aPrevInFlow);
|
2006-11-13 22:05:25 +00:00
|
|
|
|
2013-03-27 11:32:00 +00:00
|
|
|
mMouseListener = new DnDListener(this);
|
2006-11-13 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsFileControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2004-05-22 01:17:00 +00:00
|
|
|
{
|
2008-01-10 21:55:38 +00:00
|
|
|
ENSURE_TRUE(mContent);
|
|
|
|
|
2013-03-22 17:15:13 +00:00
|
|
|
// Remove the events.
|
2011-11-29 04:39:21 +00:00
|
|
|
if (mContent) {
|
|
|
|
mContent->RemoveSystemEventListener(NS_LITERAL_STRING("drop"),
|
|
|
|
mMouseListener, false);
|
|
|
|
mContent->RemoveSystemEventListener(NS_LITERAL_STRING("dragover"),
|
|
|
|
mMouseListener, false);
|
2011-06-01 06:06:38 +00:00
|
|
|
}
|
|
|
|
|
2011-06-24 02:18:02 +00:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mTextContent);
|
2013-03-27 11:35:22 +00:00
|
|
|
nsContentUtils::DestroyAnonymousContent(&mBrowse);
|
2006-11-13 22:05:25 +00:00
|
|
|
|
|
|
|
mMouseListener->ForgetFrame();
|
2009-12-24 05:21:15 +00:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot);
|
2002-12-20 05:40:37 +00:00
|
|
|
}
|
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
nsresult
|
2011-05-06 20:04:44 +00:00
|
|
|
nsFileControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
1999-06-30 22:17:43 +00:00
|
|
|
{
|
2003-07-28 21:25:13 +00:00
|
|
|
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
2000-05-10 13:13:39 +00:00
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2013-02-09 15:09:14 +00:00
|
|
|
|
|
|
|
// Create and setup the file picking button.
|
2013-03-29 12:32:47 +00:00
|
|
|
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::button, nullptr,
|
2013-02-09 15:09:14 +00:00
|
|
|
kNameSpaceID_XHTML,
|
2011-06-14 07:56:49 +00:00
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
2013-02-09 15:09:14 +00: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);
|
2001-02-19 21:50:04 +00:00
|
|
|
|
2013-02-09 10:48:20 +00:00
|
|
|
// Set the file picking button text depending on the current locale.
|
2013-03-29 12:32:47 +00:00
|
|
|
nsXPIDLString buttonTxt;
|
2013-02-09 10:48:20 +00:00
|
|
|
nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
|
2013-03-29 12:32:47 +00:00
|
|
|
"Browse", buttonTxt);
|
|
|
|
|
|
|
|
// Set the browse button text. It's a bit of a pain to do because we want to
|
|
|
|
// make sure we are not notifying.
|
2013-04-04 12:01:08 +00:00
|
|
|
nsRefPtr<nsTextNode> textContent =
|
|
|
|
new nsTextNode(mBrowse->NodeInfo()->NodeInfoManager());
|
2013-03-29 12:32:47 +00:00
|
|
|
|
|
|
|
textContent->SetText(buttonTxt, false);
|
|
|
|
|
2013-04-04 12:01:08 +00:00
|
|
|
nsresult rv = mBrowse->AppendChildTo(textContent, false);
|
2013-03-29 12:32:47 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2013-02-09 10:48:20 +00:00
|
|
|
|
2013-02-09 15:09:14 +00:00
|
|
|
// Make sure access key and tab order for the element actually redirect to the
|
|
|
|
// file picking button.
|
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> fileContent = do_QueryInterface(mContent);
|
2013-03-29 12:32:47 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLButtonElement> browseControl = do_QueryInterface(mBrowse);
|
2013-02-09 15:09:14 +00:00
|
|
|
|
|
|
|
nsAutoString accessKey;
|
|
|
|
fileContent->GetAccessKey(accessKey);
|
|
|
|
browseControl->SetAccessKey(accessKey);
|
|
|
|
|
|
|
|
int32_t tabIndex;
|
|
|
|
fileContent->GetTabIndex(&tabIndex);
|
|
|
|
browseControl->SetTabIndex(tabIndex);
|
|
|
|
|
|
|
|
if (!aElements.AppendElement(mBrowse)) {
|
2007-02-18 17:34:09 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2013-02-09 15:09:14 +00:00
|
|
|
}
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2013-02-09 15:09:14 +00: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 12:34:01 +00:00
|
|
|
mTextContent->SetNativeAnonymous();
|
2013-02-09 14:57:30 +00:00
|
|
|
mTextContent->SetAttr(kNameSpaceID_None, nsGkAtoms::crop,
|
|
|
|
NS_LITERAL_STRING("center"), false);
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2013-02-09 15:09:14 +00:00
|
|
|
// Update the displayed text to reflect the current element's value.
|
2010-09-05 18:00:05 +00:00
|
|
|
nsAutoString value;
|
2013-03-28 19:41:32 +00:00
|
|
|
HTMLInputElement::FromContent(mContent)->GetDisplayFileName(value);
|
2013-02-09 14:57:30 +00:00
|
|
|
UpdateDisplayedValue(value, false);
|
1999-06-30 22:17:43 +00:00
|
|
|
|
2013-02-09 15:09:14 +00:00
|
|
|
if (!aElements.AppendElement(mTextContent)) {
|
2007-02-18 17:34:09 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2013-02-09 15:09:14 +00:00
|
|
|
}
|
1999-06-30 22:17:43 +00:00
|
|
|
|
2013-03-27 11:32:00 +00:00
|
|
|
// We should be able to interact with the element by doing drag and drop.
|
2011-11-29 04:39:21 +00:00
|
|
|
mContent->AddSystemEventListener(NS_LITERAL_STRING("drop"),
|
|
|
|
mMouseListener, false);
|
|
|
|
mContent->AddSystemEventListener(NS_LITERAL_STRING("dragover"),
|
|
|
|
mMouseListener, false);
|
2007-02-18 17:34:09 +00:00
|
|
|
|
2010-12-14 18:00:57 +00:00
|
|
|
SyncDisabledState();
|
2000-01-13 23:34:01 +00:00
|
|
|
|
1999-06-30 22:17:43 +00:00
|
|
|
return NS_OK;
|
1998-09-23 17:16:51 +00:00
|
|
|
}
|
|
|
|
|
2010-02-11 17:34:01 +00:00
|
|
|
void
|
2010-10-15 15:34:35 +00:00
|
|
|
nsFileControlFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFilter)
|
2010-02-11 17:34:01 +00:00
|
|
|
{
|
|
|
|
aElements.MaybeAppendElement(mBrowse);
|
2013-03-27 11:35:22 +00:00
|
|
|
aElements.MaybeAppendElement(mTextContent);
|
2010-02-11 17:34:01 +00:00
|
|
|
}
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsFileControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
1998-09-23 17:16:51 +00:00
|
|
|
|
1998-10-22 23:00:37 +00:00
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsFileControlFrame::SetFocus(bool aOn, bool aRepaint)
|
1998-10-22 23:00:37 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-06-01 06:06:38 +00:00
|
|
|
/**
|
2013-03-27 11:32:00 +00:00
|
|
|
* This is called when we receive a drop or a dragover.
|
2011-06-01 06:06:38 +00:00
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2013-03-27 11:32:00 +00:00
|
|
|
nsFileControlFrame::DnDListener::HandleEvent(nsIDOMEvent* aEvent)
|
2011-06-01 06:06:38 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mFrame, "We should have been unregistered");
|
2011-06-29 18:07:57 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool defaultPrevented = false;
|
2013-05-25 21:05:36 +00:00
|
|
|
aEvent->GetDefaultPrevented(&defaultPrevented);
|
2011-06-01 06:06:38 +00:00
|
|
|
if (defaultPrevented) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-03-27 11:32:00 +00:00
|
|
|
|
2011-06-01 06:06:38 +00:00
|
|
|
nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent);
|
|
|
|
if (!dragEvent || !IsValidDropData(dragEvent)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-27 11:32:00 +00:00
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
2011-06-01 06:06:38 +00: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???");
|
|
|
|
|
2013-03-28 19:41:32 +00:00
|
|
|
HTMLInputElement* inputElement = HTMLInputElement::FromContent(content);
|
2011-06-01 06:06:38 +00:00
|
|
|
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 12:44:53 +00:00
|
|
|
|
2011-06-01 06:06:38 +00:00
|
|
|
inputElement->SetFiles(fileList, true);
|
2012-09-14 14:38:04 +00:00
|
|
|
nsContentUtils::DispatchTrustedEvent(content->OwnerDoc(), content,
|
|
|
|
NS_LITERAL_STRING("change"), true,
|
|
|
|
false);
|
2011-06-01 06:06:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
/* static */ bool
|
2013-03-27 11:32:00 +00:00
|
|
|
nsFileControlFrame::DnDListener::IsValidDropData(nsIDOMDragEvent* aEvent)
|
2011-06-01 06:06:38 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
|
|
|
|
aEvent->GetDataTransfer(getter_AddRefs(dataTransfer));
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_ENSURE_TRUE(dataTransfer, false);
|
2011-06-01 06:06:38 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDOMStringList> types;
|
|
|
|
dataTransfer->GetTypes(getter_AddRefs(types));
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_ENSURE_TRUE(types, false);
|
2011-06-01 06:06:38 +00:00
|
|
|
|
|
|
|
// We only support dropping files onto a file upload control
|
2011-09-29 06:19:26 +00:00
|
|
|
bool typeSupported;
|
2011-06-01 06:06:38 +00:00
|
|
|
types->Contains(NS_LITERAL_STRING("Files"), &typeSupported);
|
|
|
|
return typeSupported;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFileControlFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
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
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
|
|
|
|
// Our min width is our pref width
|
|
|
|
result = GetPrefWidth(aRenderingContext);
|
|
|
|
return result;
|
|
|
|
}
|
1998-09-23 17:16:51 +00:00
|
|
|
|
2010-12-14 18:00:57 +00:00
|
|
|
void
|
|
|
|
nsFileControlFrame::SyncDisabledState()
|
|
|
|
{
|
2011-06-01 01:46:57 +00:00
|
|
|
nsEventStates eventStates = mContent->AsElement()->State();
|
2010-12-14 18:00:57 +00:00
|
|
|
if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
|
|
|
mBrowse->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, EmptyString(),
|
2011-10-17 14:59:28 +00:00
|
|
|
true);
|
2010-12-14 18:00:57 +00:00
|
|
|
} else {
|
2011-10-17 14:59:28 +00:00
|
|
|
mBrowse->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, true);
|
2010-12-14 18:00:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-19 14:03:53 +00:00
|
|
|
NS_IMETHODIMP
|
2013-02-09 14:57:30 +00:00
|
|
|
nsFileControlFrame::AttributeChanged(int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType)
|
1999-08-19 14:03:53 +00:00
|
|
|
{
|
2013-02-09 14:57:30 +00: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-17 07:33:33 +00:00
|
|
|
}
|
1999-08-19 14:03:53 +00:00
|
|
|
}
|
|
|
|
|
2008-12-29 15:07:38 +00:00
|
|
|
return nsBlockFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
1999-08-19 14:03:53 +00:00
|
|
|
}
|
|
|
|
|
2010-12-14 18:00:57 +00:00
|
|
|
void
|
|
|
|
nsFileControlFrame::ContentStatesChanged(nsEventStates aStates)
|
|
|
|
{
|
|
|
|
if (aStates.HasState(NS_EVENT_STATE_DISABLED)) {
|
|
|
|
nsContentUtils::AddScriptRunner(new SyncDisabledStateEvent(this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsFileControlFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("FileControl"), aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1999-01-22 15:32:57 +00:00
|
|
|
|
2013-02-09 14:57:30 +00:00
|
|
|
void
|
|
|
|
nsFileControlFrame::UpdateDisplayedValue(const nsAString& aValue, bool aNotify)
|
|
|
|
{
|
2013-02-07 13:58:05 +00:00
|
|
|
mTextContent->SetAttr(kNameSpaceID_None, nsGkAtoms::value, aValue, aNotify);
|
2013-02-09 14:57:30 +00:00
|
|
|
}
|
|
|
|
|
2005-12-13 00:57:56 +00:00
|
|
|
nsresult
|
|
|
|
nsFileControlFrame::SetFormProperty(nsIAtom* aName,
|
|
|
|
const nsAString& aValue)
|
1999-01-25 22:16:27 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::value == aName) {
|
2013-02-09 14:57:30 +00:00
|
|
|
UpdateDisplayedValue(aValue, true);
|
1999-02-11 01:13:28 +00:00
|
|
|
}
|
2005-12-12 23:53:06 +00:00
|
|
|
return NS_OK;
|
2013-02-09 14:57:30 +00:00
|
|
|
}
|
1999-01-25 22:16:27 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsFileControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1999-02-11 01:13:28 +00:00
|
|
|
{
|
2013-05-17 17:40:14 +00:00
|
|
|
BuildDisplayListForInline(aBuilder, aDirtyRect, aLists);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2006-11-13 22:05:25 +00:00
|
|
|
|
2007-09-28 01:09:14 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 21:53:44 +00:00
|
|
|
a11y::AccType
|
|
|
|
nsFileControlFrame::AccessibleType()
|
2007-09-28 01:09:14 +00:00
|
|
|
{
|
2012-12-18 01:25:52 +00:00
|
|
|
return a11y::eHTMLFileInputType;
|
2007-09-28 01:09:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-11-13 22:05:25 +00:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Mouse listener implementation
|
|
|
|
|
2011-06-29 18:07:57 +00:00
|
|
|
NS_IMPL_ISUPPORTS1(nsFileControlFrame::MouseListener,
|
2008-04-06 12:28:34 +00:00
|
|
|
nsIDOMEventListener)
|