2015-05-03 22:32:37 +03: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 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/. */
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
#include "HTMLBodyElement.h"
|
2012-12-21 18:07:28 +04:00
|
|
|
#include "mozilla/dom/HTMLBodyElementBinding.h"
|
2017-01-27 03:51:01 +03:00
|
|
|
#include "mozilla/GenericSpecifiedValuesInlines.h"
|
2012-09-30 20:40:24 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1998-09-01 23:07:50 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1998-09-05 08:00:06 +04:00
|
|
|
#include "nsIPresShell.h"
|
1998-09-04 02:21:32 +04:00
|
|
|
#include "nsIDocument.h"
|
2004-04-13 01:56:09 +04:00
|
|
|
#include "nsHTMLStyleSheet.h"
|
2012-12-24 06:38:41 +04:00
|
|
|
#include "nsIEditor.h"
|
2004-01-26 22:22:05 +03:00
|
|
|
#include "nsMappedAttributes.h"
|
2000-03-11 03:37:07 +03:00
|
|
|
#include "nsIDocShell.h"
|
2001-10-24 04:01:09 +04:00
|
|
|
#include "nsRuleWalker.h"
|
2012-12-21 18:07:28 +04:00
|
|
|
#include "nsGlobalWindow.h"
|
1998-09-01 23:07:50 +04:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Body)
|
2011-08-24 23:49:25 +04:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
1998-09-04 02:21:32 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLBodyElement::~HTMLBodyElement()
|
1998-09-01 23:07:50 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-21 18:07:28 +04: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 17:13:33 +03:00
|
|
|
HTMLBodyElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-21 18:07:28 +04: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 17:13:33 +03:00
|
|
|
return HTMLBodyElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
1998-09-01 23:07:50 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(HTMLBodyElement, nsGenericHTMLElement,
|
|
|
|
nsIDOMHTMLBodyElement)
|
1998-09-01 23:07:50 +04:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLBodyElement)
|
1998-09-01 23:07:50 +04:00
|
|
|
|
2012-12-21 18:07:28 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetBackground(const nsAString& aBackground)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetBackground(aBackground, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetBackground(nsAString& aBackground)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString background;
|
2012-12-21 18:07:28 +04:00
|
|
|
GetBackground(background);
|
2015-02-13 04:27:39 +03:00
|
|
|
background.ToString(aBackground);
|
2012-12-21 18:07:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetVLink(const nsAString& aVLink)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetVLink(aVLink, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetVLink(nsAString& aVLink)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString vLink;
|
2012-12-21 18:07:28 +04:00
|
|
|
GetVLink(vLink);
|
2015-02-13 04:27:39 +03:00
|
|
|
vLink.ToString(aVLink);
|
2012-12-21 18:07:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetALink(const nsAString& aALink)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetALink(aALink, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetALink(nsAString& aALink)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString aLink;
|
2012-12-21 18:07:28 +04:00
|
|
|
GetALink(aLink);
|
2015-02-13 04:27:39 +03:00
|
|
|
aLink.ToString(aALink);
|
2012-12-21 18:07:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetLink(const nsAString& aLink)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetLink(aLink, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetLink(nsAString& aLink)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString link;
|
2012-12-21 18:07:28 +04:00
|
|
|
GetLink(link);
|
2015-02-13 04:27:39 +03:00
|
|
|
link.ToString(aLink);
|
2012-12-21 18:07:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetText(const nsAString& aText)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetText(aText, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetText(nsAString& aText)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString text;
|
2012-12-21 18:07:28 +04:00
|
|
|
GetText(text);
|
2015-02-13 04:27:39 +03:00
|
|
|
text.ToString(aText);
|
2012-12-21 18:07:28 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::SetBgColor(const nsAString& aBgColor)
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
SetBgColor(aBgColor, rv);
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2012-12-21 18:07:28 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HTMLBodyElement::GetBgColor(nsAString& aBgColor)
|
|
|
|
{
|
2015-02-13 04:27:39 +03:00
|
|
|
DOMString bgColor;
|
2012-12-21 18:07:28 +04:00
|
|
|
GetBgColor(bgColor);
|
2015-02-13 04:27:39 +03:00
|
|
|
bgColor.ToString(aBgColor);
|
2012-12-21 18:07:28 +04: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 16:27:00 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLBodyElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
1998-09-01 23:07:50 +04:00
|
|
|
{
|
2005-11-29 19:37:15 +03:00
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::bgcolor ||
|
|
|
|
aAttribute == nsGkAtoms::text ||
|
|
|
|
aAttribute == nsGkAtoms::link ||
|
|
|
|
aAttribute == nsGkAtoms::alink ||
|
|
|
|
aAttribute == nsGkAtoms::vlink) {
|
2010-07-17 12:09:14 +04:00
|
|
|
return aResult.ParseColor(aValue);
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::marginwidth ||
|
|
|
|
aAttribute == nsGkAtoms::marginheight ||
|
|
|
|
aAttribute == nsGkAtoms::topmargin ||
|
|
|
|
aAttribute == nsGkAtoms::bottommargin ||
|
|
|
|
aAttribute == nsGkAtoms::leftmargin ||
|
|
|
|
aAttribute == nsGkAtoms::rightmargin) {
|
2005-11-29 19:37:15 +03:00
|
|
|
return aResult.ParseIntWithBounds(aValue, 0);
|
|
|
|
}
|
1998-09-04 02:21:32 +04:00
|
|
|
}
|
1998-09-01 23:07:50 +04:00
|
|
|
|
2012-08-24 21:50:49 +04:00
|
|
|
return nsGenericHTMLElement::ParseBackgroundAttribute(aNamespaceID,
|
|
|
|
aAttribute, aValue,
|
|
|
|
aResult) ||
|
|
|
|
nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
2005-11-29 19:37:15 +03:00
|
|
|
aResult);
|
1998-09-01 23:07:50 +04:00
|
|
|
}
|
|
|
|
|
2013-11-19 23:21:29 +04:00
|
|
|
void
|
|
|
|
HTMLBodyElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
2017-01-27 03:51:01 +03:00
|
|
|
GenericSpecifiedValues* aData)
|
1998-09-01 23:07:50 +04:00
|
|
|
{
|
2017-03-29 22:10:00 +03:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Margin)) {
|
|
|
|
|
|
|
|
// This is the one place where we try to set the same property
|
|
|
|
// multiple times in presentation attributes. Servo does not support
|
|
|
|
// querying if a property is set (because that is O(n) behavior
|
|
|
|
// in ServoSpecifiedValues). Instead, we use the below values to keep
|
|
|
|
// track of whether we have already set a property, and if so, what value
|
|
|
|
// we set it to (which is used when handling margin
|
|
|
|
// attributes from the containing frame element)
|
|
|
|
|
|
|
|
int32_t bodyMarginWidth = -1;
|
|
|
|
int32_t bodyMarginHeight = -1;
|
|
|
|
int32_t bodyTopMargin = -1;
|
|
|
|
int32_t bodyBottomMargin = -1;
|
|
|
|
int32_t bodyLeftMargin = -1;
|
|
|
|
int32_t bodyRightMargin = -1;
|
|
|
|
|
|
|
|
// check the mode (fortunately, the GenericSpecifiedValues has a presContext for us to use!)
|
|
|
|
NS_ASSERTION(aData->mPresContext, "null presContext in MapAttributesIntoRule was unexpected");
|
|
|
|
nsCompatibility mode = aData->mPresContext->CompatibilityMode();
|
|
|
|
|
|
|
|
|
|
|
|
const nsAttrValue* value;
|
|
|
|
// if marginwidth/marginheight are set, reflect them as 'margin'
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::marginwidth);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyMarginWidth = value->GetIntegerValue();
|
|
|
|
if (bodyMarginWidth < 0) {
|
|
|
|
bodyMarginWidth = 0;
|
|
|
|
}
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)bodyMarginWidth);
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)bodyMarginWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::marginheight);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyMarginHeight = value->GetIntegerValue();
|
|
|
|
if (bodyMarginHeight < 0) {
|
|
|
|
bodyMarginHeight = 0;
|
|
|
|
}
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)bodyMarginHeight);
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)bodyMarginHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
// topmargin (IE-attribute)
|
|
|
|
if (bodyMarginHeight == -1) {
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::topmargin);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyTopMargin = value->GetIntegerValue();
|
|
|
|
if (bodyTopMargin < 0) {
|
|
|
|
bodyTopMargin = 0;
|
|
|
|
}
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)bodyTopMargin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// bottommargin (IE-attribute)
|
|
|
|
|
|
|
|
if (bodyMarginHeight == -1) {
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::bottommargin);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyBottomMargin = value->GetIntegerValue();
|
|
|
|
if (bodyBottomMargin < 0) {
|
|
|
|
bodyBottomMargin = 0;
|
|
|
|
}
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)bodyBottomMargin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// leftmargin (IE-attribute)
|
|
|
|
if (bodyMarginWidth == -1) {
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::leftmargin);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyLeftMargin = value->GetIntegerValue();
|
|
|
|
if (bodyLeftMargin < 0) {
|
|
|
|
bodyLeftMargin = 0;
|
|
|
|
}
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)bodyLeftMargin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// rightmargin (IE-attribute)
|
|
|
|
if (bodyMarginWidth == -1) {
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::rightmargin);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
bodyRightMargin = value->GetIntegerValue();
|
|
|
|
if (bodyRightMargin < 0) {
|
|
|
|
bodyRightMargin = 0;
|
|
|
|
}
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)bodyRightMargin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (frameMarginHeight >= 0 && bodyMarginHeight == -1) { // set in <frame> & not in <body>
|
|
|
|
if (eCompatibility_NavQuirks == mode) {
|
|
|
|
if (bodyMarginWidth == -1 && 0 > frameMarginWidth) { // nav quirk
|
|
|
|
frameMarginWidth = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bodyMarginWidth == -1 && frameMarginWidth >= 0) {
|
|
|
|
if (bodyLeftMargin == -1) {
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_left, (float)frameMarginWidth);
|
|
|
|
}
|
|
|
|
if (bodyRightMargin == -1) {
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_right, (float)frameMarginWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bodyMarginHeight == -1 && frameMarginHeight >= 0) {
|
|
|
|
if (bodyTopMargin == -1) {
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_top, (float)frameMarginHeight);
|
|
|
|
}
|
|
|
|
if (bodyBottomMargin == -1) {
|
|
|
|
aData->SetPixelValueIfUnset(eCSSProperty_margin_bottom, (float)frameMarginHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Display))) {
|
2001-06-01 02:19:43 +04:00
|
|
|
// When display if first asked for, go ahead and get our colors set up.
|
2017-01-27 03:51:01 +03:00
|
|
|
nsIPresShell *presShell = aData->PresContext()->GetPresShell();
|
1999-02-12 21:41:26 +03:00
|
|
|
if (presShell) {
|
2004-08-02 08:52:55 +04:00
|
|
|
nsIDocument *doc = presShell->GetDocument();
|
1999-02-12 21:41:26 +03:00
|
|
|
if (doc) {
|
2004-04-13 01:56:09 +04:00
|
|
|
nsHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet();
|
2004-01-14 02:14:49 +03:00
|
|
|
if (styleSheet) {
|
2004-04-13 20:45:59 +04:00
|
|
|
const nsAttrValue* value;
|
2004-02-11 03:09:59 +03:00
|
|
|
nscolor color;
|
2006-12-26 20:47:52 +03:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::link);
|
2004-04-13 20:45:59 +04:00
|
|
|
if (value && value->GetColorValue(color)) {
|
2004-02-11 03:09:59 +03:00
|
|
|
styleSheet->SetLinkColor(color);
|
2004-01-14 02:14:49 +03:00
|
|
|
}
|
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::alink);
|
2004-04-13 20:45:59 +04:00
|
|
|
if (value && value->GetColorValue(color)) {
|
2004-02-11 03:09:59 +03:00
|
|
|
styleSheet->SetActiveLinkColor(color);
|
2004-01-14 02:14:49 +03:00
|
|
|
}
|
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::vlink);
|
2004-04-13 20:45:59 +04:00
|
|
|
if (value && value->GetColorValue(color)) {
|
2004-02-11 03:09:59 +03:00
|
|
|
styleSheet->SetVisitedLinkColor(color);
|
1998-09-05 08:00:06 +04:00
|
|
|
}
|
1998-09-04 02:21:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
1998-09-04 02:21:32 +04:00
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Color))) {
|
|
|
|
if (!aData->PropertyIsSet(eCSSProperty_color) &&
|
|
|
|
aData->PresContext()->UseDocumentColors()) {
|
2001-06-01 02:19:43 +04:00
|
|
|
// color: color
|
2004-02-11 03:09:59 +03:00
|
|
|
nscolor color;
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::text);
|
2004-04-13 20:45:59 +04:00
|
|
|
if (value && value->GetColorValue(color))
|
2017-01-27 03:51:01 +03:00
|
|
|
aData->SetColorValue(eCSSProperty_color, color);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
1998-09-04 02:21:32 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
nsGenericHTMLElement::MapBackgroundAttributesInto(aAttributes, aData);
|
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
1998-09-01 23:07:50 +04:00
|
|
|
}
|
|
|
|
|
2005-01-12 22:45:38 +03:00
|
|
|
nsMapRuleToAttributesFunc
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLBodyElement::GetAttributeMappingFunction() const
|
1998-09-05 08:00:06 +04:00
|
|
|
{
|
2005-01-12 22:45:38 +03:00
|
|
|
return &MapAttributesIntoRule;
|
1998-09-05 08:00:06 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLBodyElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
1998-12-11 02:52:46 +03:00
|
|
|
{
|
2004-02-26 00:04:50 +03:00
|
|
|
static const MappedAttributeEntry attributes[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::link },
|
|
|
|
{ &nsGkAtoms::vlink },
|
|
|
|
{ &nsGkAtoms::alink },
|
|
|
|
{ &nsGkAtoms::text },
|
|
|
|
{ &nsGkAtoms::marginwidth },
|
|
|
|
{ &nsGkAtoms::marginheight },
|
2017-03-29 22:10:00 +03:00
|
|
|
{ &nsGkAtoms::topmargin },
|
|
|
|
{ &nsGkAtoms::rightmargin },
|
|
|
|
{ &nsGkAtoms::bottommargin },
|
|
|
|
{ &nsGkAtoms::leftmargin },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr },
|
2003-04-17 00:54:20 +04:00
|
|
|
};
|
|
|
|
|
2004-02-26 00:04:50 +03:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2003-04-17 00:54:20 +04:00
|
|
|
attributes,
|
|
|
|
sCommonAttributeMap,
|
|
|
|
sBackgroundAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
1999-01-15 02:14:02 +03:00
|
|
|
}
|
2006-07-29 04:04:40 +04:00
|
|
|
|
|
|
|
already_AddRefed<nsIEditor>
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLBodyElement::GetAssociatedEditor()
|
2006-07-29 04:04:40 +04:00
|
|
|
{
|
2012-12-24 06:38:41 +04:00
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditorInternal();
|
|
|
|
if (editor) {
|
|
|
|
return editor.forget();
|
2006-07-29 04:04:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure this is the actual body of the document
|
|
|
|
if (!IsCurrentBodyElement()) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-07-29 04:04:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// For designmode, try to get document's editor
|
2014-08-23 00:11:27 +04:00
|
|
|
nsPresContext* presContext = GetPresContext(eForComposedDoc);
|
2006-07-29 04:04:40 +04:00
|
|
|
if (!presContext) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-07-29 04:04:40 +04:00
|
|
|
}
|
|
|
|
|
2013-11-20 23:18:25 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = presContext->GetDocShell();
|
2013-02-14 02:39:30 +04:00
|
|
|
if (!docShell) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-07-29 04:04:40 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 02:39:30 +04:00
|
|
|
docShell->GetEditor(getter_AddRefs(editor));
|
2012-12-24 06:38:41 +04:00
|
|
|
return editor.forget();
|
2006-07-29 04:04:40 +04:00
|
|
|
}
|
2011-08-24 23:49:25 +04:00
|
|
|
|
2013-01-03 00:24:07 +04:00
|
|
|
bool
|
|
|
|
HTMLBodyElement::IsEventAttributeName(nsIAtom *aName)
|
|
|
|
{
|
|
|
|
return nsContentUtils::IsEventAttributeName(aName,
|
|
|
|
EventNameType_HTML |
|
|
|
|
EventNameType_HTMLBodyOrFramesetOnly);
|
|
|
|
}
|
|
|
|
|
2017-03-29 22:10:00 +03:00
|
|
|
nsresult
|
|
|
|
HTMLBodyElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
return mAttrsAndChildren.ForceMapped(this, OwnerDoc());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
HTMLBodyElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
|
const nsAttrValue* aValue,
|
2017-05-19 00:09:01 +03:00
|
|
|
const nsAttrValue* aOldValue, bool aNotify)
|
2017-03-29 22:10:00 +03:00
|
|
|
{
|
|
|
|
nsresult rv = nsGenericHTMLElement::AfterSetAttr(aNameSpaceID,
|
2017-05-19 00:09:01 +03:00
|
|
|
aName, aValue, aOldValue,
|
|
|
|
aNotify);
|
2017-03-29 22:10:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
// if the last mapped attribute was removed, don't clear the
|
|
|
|
// nsMappedAttributes, our style can still depend on the containing frame element
|
|
|
|
if (!aValue && IsAttributeMapped(aName)) {
|
|
|
|
nsresult rv = mAttrsAndChildren.ForceMapped(this, OwnerDoc());
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-24 23:49:25 +04:00
|
|
|
#define EVENT(name_, id_, type_, struct_) /* nothing; handled by the superclass */
|
2012-11-26 18:19:02 +04:00
|
|
|
// nsGenericHTMLElement::GetOnError returns
|
|
|
|
// already_AddRefed<EventHandlerNonNull> while other getters return
|
|
|
|
// EventHandlerNonNull*, so allow passing in the type to use here.
|
2012-12-21 18:07:28 +04:00
|
|
|
#define WINDOW_EVENT_HELPER(name_, type_) \
|
|
|
|
type_* \
|
|
|
|
HTMLBodyElement::GetOn##name_() \
|
2012-12-21 18:06:50 +04:00
|
|
|
{ \
|
2016-01-30 20:05:36 +03:00
|
|
|
if (nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow()) { \
|
|
|
|
nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win); \
|
2012-12-21 18:07:28 +04:00
|
|
|
return globalWin->GetOn##name_(); \
|
2012-12-21 18:06:50 +04:00
|
|
|
} \
|
2012-12-21 18:07:28 +04:00
|
|
|
return nullptr; \
|
2012-12-21 18:06:50 +04:00
|
|
|
} \
|
2012-12-21 18:07:28 +04:00
|
|
|
void \
|
2013-09-17 15:01:28 +04:00
|
|
|
HTMLBodyElement::SetOn##name_(type_* handler) \
|
2012-12-21 18:06:50 +04:00
|
|
|
{ \
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow(); \
|
2013-04-29 19:34:16 +04:00
|
|
|
if (!win) { \
|
2012-12-21 18:07:28 +04:00
|
|
|
return; \
|
2012-12-21 18:06:50 +04:00
|
|
|
} \
|
2012-12-21 18:07:28 +04:00
|
|
|
\
|
2016-01-30 20:05:36 +03:00
|
|
|
nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win); \
|
2013-09-17 15:01:28 +04:00
|
|
|
return globalWin->SetOn##name_(handler); \
|
2013-11-16 16:31:37 +04:00
|
|
|
}
|
2012-12-21 18:07:28 +04:00
|
|
|
#define WINDOW_EVENT(name_, id_, type_, struct_) \
|
|
|
|
WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
|
|
|
|
#define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
|
2013-10-08 19:51:15 +04:00
|
|
|
WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
|
2014-04-01 15:42:12 +04:00
|
|
|
#include "mozilla/EventNameList.h" // IWYU pragma: keep
|
2012-12-21 18:07:28 +04:00
|
|
|
#undef BEFOREUNLOAD_EVENT
|
2011-08-24 23:49:25 +04:00
|
|
|
#undef WINDOW_EVENT
|
2012-12-21 18:07:28 +04:00
|
|
|
#undef WINDOW_EVENT_HELPER
|
2011-08-24 23:49:25 +04:00
|
|
|
#undef EVENT
|
2012-12-21 18:06:50 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|