2015-05-03 19:32:37 +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/. */
|
2011-10-11 05:50:08 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
#include "HTMLBodyElement.h"
|
2012-12-21 14:07:28 +00:00
|
|
|
#include "mozilla/dom/HTMLBodyElementBinding.h"
|
2012-09-30 16:40:24 +00:00
|
|
|
#include "nsAttrValueInlines.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1998-09-01 19:07:50 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
1998-09-05 04:00:06 +00:00
|
|
|
#include "nsIPresShell.h"
|
1998-09-03 22:21:32 +00:00
|
|
|
#include "nsIDocument.h"
|
2004-04-12 21:56:09 +00:00
|
|
|
#include "nsHTMLStyleSheet.h"
|
2012-12-24 02:38:41 +00:00
|
|
|
#include "nsIEditor.h"
|
2004-01-26 19:22:05 +00:00
|
|
|
#include "nsMappedAttributes.h"
|
2004-07-20 06:11:27 +00:00
|
|
|
#include "nsRuleData.h"
|
2000-03-11 00:37:07 +00:00
|
|
|
#include "nsIDocShell.h"
|
2001-10-24 00:01:09 +00:00
|
|
|
#include "nsRuleWalker.h"
|
2012-12-21 14:07:28 +00:00
|
|
|
#include "nsGlobalWindow.h"
|
1998-09-01 19:07:50 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Body)
|
2011-08-24 19:49:25 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
1998-09-03 22:21:32 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
BodyRule::BodyRule(HTMLBodyElement* aPart)
|
2013-06-12 07:00:09 +00:00
|
|
|
: mPart(aPart)
|
1998-09-03 22:21:32 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BodyRule::~BodyRule()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(BodyRule, nsIStyleRule)
|
1998-09-03 22:21:32 +00:00
|
|
|
|
2010-05-20 02:28:00 +00:00
|
|
|
/* virtual */ void
|
2001-05-31 22:19:43 +00:00
|
|
|
BodyRule::MapRuleInfoInto(nsRuleData* aData)
|
1999-04-15 21:23:05 +00:00
|
|
|
{
|
2011-03-18 03:14:31 +00:00
|
|
|
if (!(aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) || !mPart)
|
2010-05-20 02:28:00 +00:00
|
|
|
return; // We only care about margins.
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t bodyMarginWidth = -1;
|
|
|
|
int32_t bodyMarginHeight = -1;
|
|
|
|
int32_t bodyTopMargin = -1;
|
|
|
|
int32_t bodyBottomMargin = -1;
|
|
|
|
int32_t bodyLeftMargin = -1;
|
|
|
|
int32_t bodyRightMargin = -1;
|
2001-08-15 22:22:41 +00:00
|
|
|
|
|
|
|
// check the mode (fortunately, the ruleData has a presContext for us to use!)
|
|
|
|
NS_ASSERTION(aData->mPresContext, "null presContext in ruleNode was unexpected");
|
2003-12-24 21:51:50 +00:00
|
|
|
nsCompatibility mode = aData->mPresContext->CompatibilityMode();
|
2001-08-15 22:22:41 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2005-01-25 00:02:58 +00:00
|
|
|
const nsAttrValue* value;
|
2003-09-27 04:18:26 +00:00
|
|
|
if (mPart->GetAttrCount() > 0) {
|
2001-05-31 22:19:43 +00:00
|
|
|
// if marginwidth/marginheight are set, reflect them as 'margin'
|
2006-12-26 17:47:52 +00:00
|
|
|
value = mPart->GetParsedAttr(nsGkAtoms::marginwidth);
|
2005-01-25 00:02:58 +00:00
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyMarginWidth = value->GetIntegerValue();
|
2001-05-31 22:19:43 +00:00
|
|
|
if (bodyMarginWidth < 0) bodyMarginWidth = 0;
|
2015-01-17 04:16:02 +00:00
|
|
|
nsCSSValue* marginLeft = aData->ValueForMarginLeft();
|
2011-03-18 03:14:31 +00:00
|
|
|
if (marginLeft->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginLeft->SetFloatValue((float)bodyMarginWidth, eCSSUnit_Pixel);
|
2015-01-17 04:16:02 +00:00
|
|
|
nsCSSValue* marginRight = aData->ValueForMarginRight();
|
2011-03-18 03:14:31 +00:00
|
|
|
if (marginRight->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginRight->SetFloatValue((float)bodyMarginWidth, eCSSUnit_Pixel);
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
1999-04-15 21:23:05 +00:00
|
|
|
|
2006-12-26 17:47:52 +00:00
|
|
|
value = mPart->GetParsedAttr(nsGkAtoms::marginheight);
|
2005-01-25 00:02:58 +00:00
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyMarginHeight = value->GetIntegerValue();
|
2001-05-31 22:19:43 +00:00
|
|
|
if (bodyMarginHeight < 0) bodyMarginHeight = 0;
|
2011-03-18 03:14:31 +00:00
|
|
|
nsCSSValue* marginTop = aData->ValueForMarginTop();
|
|
|
|
if (marginTop->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginTop->SetFloatValue((float)bodyMarginHeight, eCSSUnit_Pixel);
|
|
|
|
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
|
|
|
|
if (marginBottom->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginBottom->SetFloatValue((float)bodyMarginHeight, eCSSUnit_Pixel);
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
2001-08-15 22:22:41 +00:00
|
|
|
|
|
|
|
// topmargin (IE-attribute)
|
2014-09-27 20:02:07 +00:00
|
|
|
value = mPart->GetParsedAttr(nsGkAtoms::topmargin);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyTopMargin = value->GetIntegerValue();
|
|
|
|
if (bodyTopMargin < 0) bodyTopMargin = 0;
|
|
|
|
nsCSSValue* marginTop = aData->ValueForMarginTop();
|
|
|
|
if (marginTop->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginTop->SetFloatValue((float)bodyTopMargin, eCSSUnit_Pixel);
|
|
|
|
}
|
2001-08-15 22:22:41 +00:00
|
|
|
|
2003-06-13 05:00:35 +00:00
|
|
|
// bottommargin (IE-attribute)
|
2014-09-27 20:02:07 +00:00
|
|
|
value = mPart->GetParsedAttr(nsGkAtoms::bottommargin);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyBottomMargin = value->GetIntegerValue();
|
|
|
|
if (bodyBottomMargin < 0) bodyBottomMargin = 0;
|
|
|
|
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
|
|
|
|
if (marginBottom->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginBottom->SetFloatValue((float)bodyBottomMargin, eCSSUnit_Pixel);
|
|
|
|
}
|
2003-06-13 05:00:35 +00:00
|
|
|
|
2001-08-15 22:22:41 +00:00
|
|
|
// leftmargin (IE-attribute)
|
2014-09-27 20:02:07 +00:00
|
|
|
value = mPart->GetParsedAttr(nsGkAtoms::leftmargin);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyLeftMargin = value->GetIntegerValue();
|
|
|
|
if (bodyLeftMargin < 0) bodyLeftMargin = 0;
|
2015-01-17 04:16:02 +00:00
|
|
|
nsCSSValue* marginLeft = aData->ValueForMarginLeft();
|
2014-09-27 20:02:07 +00:00
|
|
|
if (marginLeft->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginLeft->SetFloatValue((float)bodyLeftMargin, eCSSUnit_Pixel);
|
|
|
|
}
|
2003-06-13 05:00:35 +00:00
|
|
|
|
|
|
|
// rightmargin (IE-attribute)
|
2014-09-27 20:02:07 +00:00
|
|
|
value = mPart->GetParsedAttr(nsGkAtoms::rightmargin);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyRightMargin = value->GetIntegerValue();
|
|
|
|
if (bodyRightMargin < 0) bodyRightMargin = 0;
|
2015-01-17 04:16:02 +00:00
|
|
|
nsCSSValue* marginRight = aData->ValueForMarginRight();
|
2014-09-27 20:02:07 +00:00
|
|
|
if (marginRight->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginRight->SetFloatValue((float)bodyRightMargin, eCSSUnit_Pixel);
|
2001-08-15 22:22:41 +00:00
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
1999-04-15 21:23:05 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// if marginwidth or marginheight is set in the <frame> and not set in the <body>
|
|
|
|
// reflect them as margin in the <body>
|
|
|
|
if (bodyMarginWidth == -1 || bodyMarginHeight == -1) {
|
2013-11-20 19:18:25 +00:00
|
|
|
nsCOMPtr<nsIDocShell> docShell(aData->mPresContext->GetDocShell());
|
|
|
|
if (docShell) {
|
|
|
|
nscoord frameMarginWidth=-1; // default value
|
|
|
|
nscoord frameMarginHeight=-1; // default value
|
|
|
|
docShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
|
|
|
|
docShell->GetMarginHeight(&frameMarginHeight);
|
|
|
|
if ((frameMarginWidth >= 0) && (bodyMarginWidth == -1)) { // set in <frame> & not in <body>
|
|
|
|
if (eCompatibility_NavQuirks == mode) {
|
|
|
|
if ((bodyMarginHeight == -1) && (0 > frameMarginHeight)) // nav quirk
|
|
|
|
frameMarginHeight = 0;
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
2013-11-20 19:18:25 +00:00
|
|
|
}
|
|
|
|
if ((frameMarginHeight >= 0) && (bodyMarginHeight == -1)) { // set in <frame> & not in <body>
|
|
|
|
if (eCompatibility_NavQuirks == mode) {
|
|
|
|
if ((bodyMarginWidth == -1) && (0 > frameMarginWidth)) // nav quirk
|
|
|
|
frameMarginWidth = 0;
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
2013-11-20 19:18:25 +00:00
|
|
|
}
|
1999-01-09 04:31:51 +00:00
|
|
|
|
2013-11-20 19:18:25 +00:00
|
|
|
if ((bodyMarginWidth == -1) && (frameMarginWidth >= 0)) {
|
2015-01-17 04:16:02 +00:00
|
|
|
nsCSSValue* marginLeft = aData->ValueForMarginLeft();
|
2013-11-20 19:18:25 +00:00
|
|
|
if (marginLeft->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginLeft->SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
|
2015-01-17 04:16:02 +00:00
|
|
|
nsCSSValue* marginRight = aData->ValueForMarginRight();
|
2013-11-20 19:18:25 +00:00
|
|
|
if (marginRight->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginRight->SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
|
|
|
|
}
|
1999-01-09 04:31:51 +00:00
|
|
|
|
2013-11-20 19:18:25 +00:00
|
|
|
if ((bodyMarginHeight == -1) && (frameMarginHeight >= 0)) {
|
|
|
|
nsCSSValue* marginTop = aData->ValueForMarginTop();
|
|
|
|
if (marginTop->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginTop->SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
|
|
|
|
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
|
|
|
|
if (marginBottom->GetUnit() == eCSSUnit_Null)
|
|
|
|
marginBottom->SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-17 04:09:55 +00:00
|
|
|
/* virtual */ bool
|
|
|
|
BodyRule::MightMapInheritedStyleData()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2001-10-16 05:31:36 +00:00
|
|
|
#ifdef DEBUG
|
2010-05-20 02:28:00 +00:00
|
|
|
/* virtual */ void
|
2012-08-22 15:56:38 +00:00
|
|
|
BodyRule::List(FILE* out, int32_t aIndent) const
|
1998-09-03 22:21:32 +00:00
|
|
|
{
|
2014-11-27 06:29:44 +00:00
|
|
|
nsAutoCString indent;
|
2014-11-27 06:29:44 +00:00
|
|
|
for (int32_t index = aIndent; --index >= 0; ) {
|
2014-11-27 06:29:44 +00:00
|
|
|
indent.AppendLiteral(" ");
|
2014-11-27 06:29:44 +00:00
|
|
|
}
|
2014-11-27 06:29:44 +00:00
|
|
|
fprintf_stderr(out, "%s[body rule] {}\n", indent.get());
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
2001-10-16 05:31:36 +00:00
|
|
|
#endif
|
2000-03-31 07:08:36 +00:00
|
|
|
|
1998-09-03 22:21:32 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLBodyElement::~HTMLBodyElement()
|
1998-09-01 19:07:50 +00:00
|
|
|
{
|
2002-01-07 23:46:07 +00:00
|
|
|
if (mContentStyleRule) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mContentStyleRule->mPart = nullptr;
|
2002-01-07 23:46:07 +00:00
|
|
|
}
|
1998-09-01 19:07:50 +00:00
|
|
|
}
|
|
|
|
|
2012-12-21 14:07:28 +00:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
HTMLBodyElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-21 14:07:28 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return HTMLBodyElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-21 14:07:28 +00:00
|
|
|
}
|
1998-09-01 19:07:50 +00:00
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(HTMLBodyElement, nsGenericHTMLElement,
|
|
|
|
nsIDOMHTMLBodyElement)
|
1998-09-01 19:07:50 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLBodyElement)
|
1998-09-01 19:07:50 +00:00
|
|
|
|
2012-12-21 14:07:28 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetBackground(const nsAString& aBackground)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetBackground(aBackground, rv);
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 14:07:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetBackground(nsAString& aBackground)
|
|
|
|
{
|
2015-02-13 01:27:39 +00:00
|
|
|
DOMString background;
|
2012-12-21 14:07:28 +00:00
|
|
|
GetBackground(background);
|
2015-02-13 01:27:39 +00:00
|
|
|
background.ToString(aBackground);
|
2012-12-21 14:07:28 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetVLink(const nsAString& aVLink)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetVLink(aVLink, rv);
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 14:07:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetVLink(nsAString& aVLink)
|
|
|
|
{
|
2015-02-13 01:27:39 +00:00
|
|
|
DOMString vLink;
|
2012-12-21 14:07:28 +00:00
|
|
|
GetVLink(vLink);
|
2015-02-13 01:27:39 +00:00
|
|
|
vLink.ToString(aVLink);
|
2012-12-21 14:07:28 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetALink(const nsAString& aALink)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetALink(aALink, rv);
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 14:07:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetALink(nsAString& aALink)
|
|
|
|
{
|
2015-02-13 01:27:39 +00:00
|
|
|
DOMString aLink;
|
2012-12-21 14:07:28 +00:00
|
|
|
GetALink(aLink);
|
2015-02-13 01:27:39 +00:00
|
|
|
aLink.ToString(aALink);
|
2012-12-21 14:07:28 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetLink(const nsAString& aLink)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetLink(aLink, rv);
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 14:07:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetLink(nsAString& aLink)
|
|
|
|
{
|
2015-02-13 01:27:39 +00:00
|
|
|
DOMString link;
|
2012-12-21 14:07:28 +00:00
|
|
|
GetLink(link);
|
2015-02-13 01:27:39 +00:00
|
|
|
link.ToString(aLink);
|
2012-12-21 14:07:28 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetText(const nsAString& aText)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetText(aText, rv);
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 14:07:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetText(nsAString& aText)
|
|
|
|
{
|
2015-02-13 01:27:39 +00:00
|
|
|
DOMString text;
|
2012-12-21 14:07:28 +00:00
|
|
|
GetText(text);
|
2015-02-13 01:27:39 +00:00
|
|
|
text.ToString(aText);
|
2012-12-21 14:07:28 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetBgColor(const nsAString& aBgColor)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetBgColor(aBgColor, rv);
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 14:07:28 +00:00
|
|
|
}
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2012-12-21 14:07:28 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetBgColor(nsAString& aBgColor)
|
|
|
|
{
|
2015-02-13 01:27:39 +00:00
|
|
|
DOMString bgColor;
|
2012-12-21 14:07:28 +00:00
|
|
|
GetBgColor(bgColor);
|
2015-02-13 01:27:39 +00:00
|
|
|
bgColor.ToString(aBgColor);
|
2012-12-21 14:07:28 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 13:27:00 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLBodyElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
1998-09-01 19:07:50 +00:00
|
|
|
{
|
2005-11-29 16:37:15 +00:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::bgcolor ||
|
|
|
|
aAttribute == nsGkAtoms::text ||
|
|
|
|
aAttribute == nsGkAtoms::link ||
|
|
|
|
aAttribute == nsGkAtoms::alink ||
|
|
|
|
aAttribute == nsGkAtoms::vlink) {
|
2010-07-17 08:09:14 +00:00
|
|
|
return aResult.ParseColor(aValue);
|
2005-11-29 16:37:15 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::marginwidth ||
|
|
|
|
aAttribute == nsGkAtoms::marginheight ||
|
|
|
|
aAttribute == nsGkAtoms::topmargin ||
|
|
|
|
aAttribute == nsGkAtoms::bottommargin ||
|
|
|
|
aAttribute == nsGkAtoms::leftmargin ||
|
|
|
|
aAttribute == nsGkAtoms::rightmargin) {
|
2005-11-29 16:37:15 +00:00
|
|
|
return aResult.ParseIntWithBounds(aValue, 0);
|
|
|
|
}
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
1998-09-01 19:07:50 +00:00
|
|
|
|
2012-08-24 17:50:49 +00:00
|
|
|
return nsGenericHTMLElement::ParseBackgroundAttribute(aNamespaceID,
|
|
|
|
aAttribute, aValue,
|
|
|
|
aResult) ||
|
|
|
|
nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2005-11-29 16:37:15 +00:00
|
|
|
aResult);
|
1998-09-01 19:07:50 +00:00
|
|
|
}
|
|
|
|
|
2004-01-09 23:54:21 +00:00
|
|
|
void
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLBodyElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2002-01-07 23:46:07 +00:00
|
|
|
{
|
2005-04-05 23:54:35 +00:00
|
|
|
if (mContentStyleRule) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mContentStyleRule->mPart = nullptr;
|
2013-06-12 07:00:09 +00:00
|
|
|
mContentStyleRule = nullptr;
|
2002-01-07 23:46:07 +00:00
|
|
|
}
|
2005-04-05 23:54:35 +00:00
|
|
|
|
|
|
|
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
|
2002-01-07 23:46:07 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 19:21:29 +00:00
|
|
|
void
|
|
|
|
HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
|
|
nsRuleData* aData)
|
1998-09-01 19:07:50 +00:00
|
|
|
{
|
2007-10-08 21:58:22 +00:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Display)) {
|
2001-05-31 22:19:43 +00:00
|
|
|
// When display if first asked for, go ahead and get our colors set up.
|
2003-12-21 05:36:36 +00:00
|
|
|
nsIPresShell *presShell = aData->mPresContext->GetPresShell();
|
1999-02-12 18:41:26 +00:00
|
|
|
if (presShell) {
|
2004-08-02 04:52:55 +00:00
|
|
|
nsIDocument *doc = presShell->GetDocument();
|
1999-02-12 18:41:26 +00:00
|
|
|
if (doc) {
|
2004-04-12 21:56:09 +00:00
|
|
|
nsHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet();
|
2004-01-13 23:14:49 +00:00
|
|
|
if (styleSheet) {
|
2004-04-13 16:45:59 +00:00
|
|
|
const nsAttrValue* value;
|
2004-02-11 00:09:59 +00:00
|
|
|
nscolor color;
|
2006-12-26 17:47:52 +00:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::link);
|
2004-04-13 16:45:59 +00:00
|
|
|
if (value && value->GetColorValue(color)) {
|
2004-02-11 00:09:59 +00:00
|
|
|
styleSheet->SetLinkColor(color);
|
2004-01-13 23:14:49 +00:00
|
|
|
}
|
|
|
|
|
2006-12-26 17:47:52 +00:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::alink);
|
2004-04-13 16:45:59 +00:00
|
|
|
if (value && value->GetColorValue(color)) {
|
2004-02-11 00:09:59 +00:00
|
|
|
styleSheet->SetActiveLinkColor(color);
|
2004-01-13 23:14:49 +00:00
|
|
|
}
|
|
|
|
|
2006-12-26 17:47:52 +00:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::vlink);
|
2004-04-13 16:45:59 +00:00
|
|
|
if (value && value->GetColorValue(color)) {
|
2004-02-11 00:09:59 +00:00
|
|
|
styleSheet->SetVisitedLinkColor(color);
|
1998-09-05 04:00:06 +00:00
|
|
|
}
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
1998-09-03 22:21:32 +00:00
|
|
|
|
2007-10-08 21:58:22 +00:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
|
2011-03-18 03:14:31 +00:00
|
|
|
nsCSSValue *colorValue = aData->ValueForColor();
|
|
|
|
if (colorValue->GetUnit() == eCSSUnit_Null &&
|
2007-11-16 03:46:42 +00:00
|
|
|
aData->mPresContext->UseDocumentColors()) {
|
2001-05-31 22:19:43 +00:00
|
|
|
// color: color
|
2004-02-11 00:09:59 +00:00
|
|
|
nscolor color;
|
2006-12-26 17:47:52 +00:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::text);
|
2004-04-13 16:45:59 +00:00
|
|
|
if (value && value->GetColorValue(color))
|
2011-03-18 03:14:31 +00:00
|
|
|
colorValue->SetColorValue(color);
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
|
|
|
|
nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
1998-09-01 19:07:50 +00:00
|
|
|
}
|
|
|
|
|
2005-01-12 19:45:38 +00:00
|
|
|
nsMapRuleToAttributesFunc
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLBodyElement::GetAttributeMappingFunction() const
|
1998-09-05 04:00:06 +00:00
|
|
|
{
|
2005-01-12 19:45:38 +00:00
|
|
|
return &MapAttributesIntoRule;
|
1998-09-05 04:00:06 +00:00
|
|
|
}
|
|
|
|
|
1998-09-03 22:21:32 +00:00
|
|
|
NS_IMETHODIMP
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLBodyElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
1998-09-03 22:21:32 +00:00
|
|
|
{
|
2004-02-10 19:36:43 +00:00
|
|
|
nsGenericHTMLElement::WalkContentStyleRules(aRuleWalker);
|
1999-05-26 23:46:45 +00:00
|
|
|
|
2004-08-10 10:22:36 +00:00
|
|
|
if (!mContentStyleRule && IsInDoc()) {
|
2014-10-02 19:07:24 +00:00
|
|
|
// XXXbz should this use OwnerDoc() or GetComposedDoc()?
|
2004-10-11 16:14:27 +00:00
|
|
|
// sXBL/XBL2 issue!
|
2004-10-31 17:33:50 +00:00
|
|
|
mContentStyleRule = new BodyRule(this);
|
1998-12-02 00:34:06 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
if (aRuleWalker && mContentStyleRule) {
|
|
|
|
aRuleWalker->Forward(mContentStyleRule);
|
1999-05-26 23:46:45 +00:00
|
|
|
}
|
1998-12-02 00:34:06 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLBodyElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
1998-12-10 23:52:46 +00:00
|
|
|
{
|
2004-02-25 21:04:50 +00:00
|
|
|
static const MappedAttributeEntry attributes[] = {
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::link },
|
|
|
|
{ &nsGkAtoms::vlink },
|
|
|
|
{ &nsGkAtoms::alink },
|
|
|
|
{ &nsGkAtoms::text },
|
2003-07-11 21:16:12 +00:00
|
|
|
// These aren't mapped through attribute mapping, but they are
|
|
|
|
// mapped through a style rule, so it is attribute dependent style.
|
|
|
|
// XXXldb But we don't actually replace the body rule when we have
|
|
|
|
// dynamic changes...
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::marginwidth },
|
|
|
|
{ &nsGkAtoms::marginheight },
|
2012-07-30 14:20:58 +00:00
|
|
|
{ nullptr },
|
2003-04-16 20:54:20 +00:00
|
|
|
};
|
|
|
|
|
2004-02-25 21:04:50 +00:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2003-04-16 20:54:20 +00:00
|
|
|
attributes,
|
|
|
|
sCommonAttributeMap,
|
|
|
|
sBackgroundAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 10:09:27 +00:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
1999-01-14 23:14:02 +00:00
|
|
|
}
|
2006-07-29 00:04:40 +00:00
|
|
|
|
|
|
|
already_AddRefed<nsIEditor>
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLBodyElement::GetAssociatedEditor()
|
2006-07-29 00:04:40 +00:00
|
|
|
{
|
2012-12-24 02:38:41 +00:00
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditorInternal();
|
|
|
|
if (editor) {
|
|
|
|
return editor.forget();
|
2006-07-29 00:04:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure this is the actual body of the document
|
|
|
|
if (!IsCurrentBodyElement()) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2006-07-29 00:04:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// For designmode, try to get document's editor
|
2014-08-22 20:11:27 +00:00
|
|
|
nsPresContext* presContext = GetPresContext(eForComposedDoc);
|
2006-07-29 00:04:40 +00:00
|
|
|
if (!presContext) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2006-07-29 00:04:40 +00:00
|
|
|
}
|
|
|
|
|
2013-11-20 19:18:25 +00:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = presContext->GetDocShell();
|
2013-02-13 22:39:30 +00:00
|
|
|
if (!docShell) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2006-07-29 00:04:40 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 22:39:30 +00:00
|
|
|
docShell->GetEditor(getter_AddRefs(editor));
|
2012-12-24 02:38:41 +00:00
|
|
|
return editor.forget();
|
2006-07-29 00:04:40 +00:00
|
|
|
}
|
2011-08-24 19:49:25 +00:00
|
|
|
|
2013-01-02 20:24:07 +00:00
|
|
|
bool
|
|
|
|
HTMLBodyElement::IsEventAttributeName(nsIAtom *aName)
|
|
|
|
{
|
|
|
|
return nsContentUtils::IsEventAttributeName(aName,
|
|
|
|
EventNameType_HTML |
|
|
|
|
EventNameType_HTMLBodyOrFramesetOnly);
|
|
|
|
}
|
|
|
|
|
2011-08-24 19:49:25 +00:00
|
|
|
#define EVENT(name_, id_, type_, struct_) /* nothing; handled by the superclass */
|
2012-11-26 14:19:02 +00:00
|
|
|
// nsGenericHTMLElement::GetOnError returns
|
|
|
|
// already_AddRefed<EventHandlerNonNull> while other getters return
|
|
|
|
// EventHandlerNonNull*, so allow passing in the type to use here.
|
2012-12-21 14:07:28 +00:00
|
|
|
#define WINDOW_EVENT_HELPER(name_, type_) \
|
|
|
|
type_* \
|
|
|
|
HTMLBodyElement::GetOn##name_() \
|
2012-12-21 14:06:50 +00:00
|
|
|
{ \
|
|
|
|
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
|
2013-04-29 15:34:16 +00:00
|
|
|
if (win) { \
|
2012-12-21 14:07:28 +00:00
|
|
|
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
|
|
|
|
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
|
|
|
|
return globalWin->GetOn##name_(); \
|
2012-12-21 14:06:50 +00:00
|
|
|
} \
|
2012-12-21 14:07:28 +00:00
|
|
|
return nullptr; \
|
2012-12-21 14:06:50 +00:00
|
|
|
} \
|
2012-12-21 14:07:28 +00:00
|
|
|
void \
|
2013-09-17 11:01:28 +00:00
|
|
|
HTMLBodyElement::SetOn##name_(type_* handler) \
|
2012-12-21 14:06:50 +00:00
|
|
|
{ \
|
|
|
|
nsPIDOMWindow* win = OwnerDoc()->GetInnerWindow(); \
|
2013-04-29 15:34:16 +00:00
|
|
|
if (!win) { \
|
2012-12-21 14:07:28 +00:00
|
|
|
return; \
|
2012-12-21 14:06:50 +00:00
|
|
|
} \
|
2012-12-21 14:07:28 +00:00
|
|
|
\
|
|
|
|
nsCOMPtr<nsISupports> supports = do_QueryInterface(win); \
|
|
|
|
nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports); \
|
2013-09-17 11:01:28 +00:00
|
|
|
return globalWin->SetOn##name_(handler); \
|
2013-11-16 12:31:37 +00:00
|
|
|
}
|
2012-12-21 14:07:28 +00:00
|
|
|
#define WINDOW_EVENT(name_, id_, type_, struct_) \
|
|
|
|
WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
|
|
|
|
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
|
2013-10-08 15:51:15 +00:00
|
|
|
WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
|
2014-04-01 11:42:12 +00:00
|
|
|
#include "mozilla/EventNameList.h" // IWYU pragma: keep
|
2012-12-21 14:07:28 +00:00
|
|
|
#undef BEFOREUNLOAD_EVENT
|
2011-08-24 19:49:25 +00:00
|
|
|
#undef WINDOW_EVENT
|
2012-12-21 14:07:28 +00:00
|
|
|
#undef WINDOW_EVENT_HELPER
|
2011-08-24 19:49:25 +00:00
|
|
|
#undef EVENT
|
2012-12-21 14:06:50 +00:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|