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/. */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
2008-12-29 18:07:38 +03:00
|
|
|
/* derived class of nsBlockFrame used for xul:label elements */
|
1998-12-18 20:54:54 +03:00
|
|
|
|
2008-12-29 18:07:38 +03:00
|
|
|
#include "nsXULLabelFrame.h"
|
|
|
|
#include "nsHTMLParts.h"
|
2002-02-21 16:39:39 +03:00
|
|
|
#include "nsINameSpaceManager.h"
|
2011-04-21 21:35:52 +04:00
|
|
|
#include "nsEventStateManager.h"
|
1998-12-18 20:54:54 +03:00
|
|
|
|
2005-10-27 01:46:39 +04:00
|
|
|
nsIFrame*
|
2009-01-19 21:31:33 +03:00
|
|
|
NS_NewXULLabelFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-12-18 20:54:54 +03:00
|
|
|
{
|
2008-12-29 18:07:38 +03:00
|
|
|
nsXULLabelFrame* it = new (aPresShell) nsXULLabelFrame(aContext);
|
2005-10-27 01:46:39 +04:00
|
|
|
|
2013-08-03 08:11:06 +04:00
|
|
|
it->SetFlags(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT);
|
2005-10-27 01:46:39 +04:00
|
|
|
|
|
|
|
return it;
|
1998-12-18 20:54:54 +03:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsXULLabelFrame)
|
|
|
|
|
2002-02-21 16:39:39 +03:00
|
|
|
// If you make changes to this function, check its counterparts
|
|
|
|
// in nsBoxFrame and nsTextBoxFrame
|
|
|
|
nsresult
|
2011-09-29 10:19:26 +04:00
|
|
|
nsXULLabelFrame::RegUnregAccessKey(bool aDoReg)
|
2002-02-21 16:39:39 +03:00
|
|
|
{
|
|
|
|
// if we have no content, we can't do anything
|
|
|
|
if (!mContent)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// To filter out <label>s without a control attribute.
|
|
|
|
// XXXjag a side-effect is that we filter out anonymous <label>s
|
|
|
|
// in e.g. <menu>, <menuitem>, <button>. These <label>s inherit
|
|
|
|
// |accesskey| and would otherwise register themselves, overwriting
|
|
|
|
// the content we really meant to be registered.
|
2006-12-26 20:47:52 +03:00
|
|
|
if (!mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::control))
|
2002-02-21 16:39:39 +03:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsAutoString accessKey;
|
2006-12-26 20:47:52 +03:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
if (accessKey.IsEmpty())
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// With a valid PresContext we can get the ESM
|
|
|
|
// and register the access key
|
2011-04-21 21:35:52 +04:00
|
|
|
nsEventStateManager *esm = PresContext()->EventStateManager();
|
2004-02-27 20:17:37 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t key = accessKey.First();
|
2004-02-27 20:17:37 +03:00
|
|
|
if (aDoReg)
|
2011-04-21 21:35:52 +04:00
|
|
|
esm->RegisterAccessKey(mContent, key);
|
2004-02-27 20:17:37 +03:00
|
|
|
else
|
2011-04-21 21:35:52 +04:00
|
|
|
esm->UnregisterAccessKey(mContent, key);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
2011-04-21 21:35:52 +04:00
|
|
|
return NS_OK;
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
|
1998-12-18 20:54:54 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIFrame
|
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2008-12-29 18:07:38 +03:00
|
|
|
nsXULLabelFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2002-02-21 16:39:39 +03:00
|
|
|
{
|
2013-03-20 05:47:48 +04:00
|
|
|
nsBlockFrame::Init(aContent, aParent, aPrevInFlow);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
// register access key
|
2013-03-20 05:47:48 +04:00
|
|
|
RegUnregAccessKey(true);
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsXULLabelFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2002-02-21 16:39:39 +03:00
|
|
|
{
|
|
|
|
// unregister access key
|
2011-10-17 18:59:28 +04:00
|
|
|
RegUnregAccessKey(false);
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBlockFrame::DestroyFrom(aDestructRoot);
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsXULLabelFrame::AttributeChanged(int32_t aNameSpaceID,
|
2008-12-29 18:07:38 +03:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2002-02-21 16:39:39 +03:00
|
|
|
{
|
2005-09-07 20:49:21 +04:00
|
|
|
nsresult rv = nsBlockFrame::AttributeChanged(aNameSpaceID,
|
2004-12-31 04:13:27 +03:00
|
|
|
aAttribute, aModType);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
// If the accesskey changed, register for the new value
|
|
|
|
// The old value has been unregistered in nsXULElement::SetAttr
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::accesskey || aAttribute == nsGkAtoms::control)
|
2011-10-17 18:59:28 +04:00
|
|
|
RegUnregAccessKey(true);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
2008-12-29 18:07:38 +03:00
|
|
|
nsXULLabelFrame::GetType() const
|
1999-02-14 06:47:33 +03:00
|
|
|
{
|
2008-12-29 18:07:38 +03:00
|
|
|
return nsGkAtoms::XULLabelFrame;
|
1999-02-14 06:47:33 +03:00
|
|
|
}
|
|
|
|
|
1998-12-18 20:54:54 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Diagnostics
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2008-12-29 18:07:38 +03:00
|
|
|
nsXULLabelFrame::GetFrameName(nsAString& aResult) const
|
1998-12-18 20:54:54 +03:00
|
|
|
{
|
2008-12-29 18:07:38 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("XULLabel"), aResult);
|
1998-12-18 20:54:54 +03:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|