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 "HTMLFontElement.h"
|
2012-12-21 18:07:28 +04:00
|
|
|
#include "mozilla/dom/HTMLFontElementBinding.h"
|
2017-01-27 03:51:01 +03:00
|
|
|
#include "mozilla/GenericSpecifiedValuesInlines.h"
|
2012-09-30 20:40:24 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
2004-01-26 22:22:05 +03:00
|
|
|
#include "nsMappedAttributes.h"
|
2013-02-01 03:11:49 +04:00
|
|
|
#include "nsContentUtils.h"
|
2014-06-06 10:09:23 +04:00
|
|
|
#include "nsCSSParser.h"
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2004-05-19 00:58:12 +04:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Font)
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFontElement::~HTMLFontElement()
|
1998-09-02 04:56:01 +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
|
|
|
HTMLFontElement::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 HTMLFontElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-21 18:07:28 +04:00
|
|
|
}
|
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLFontElement)
|
1998-09-02 04:56:01 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFontElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
1998-09-02 04:56:01 +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::size) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t size = nsContentUtils::ParseLegacyFontSize(aValue);
|
2012-04-19 12:09:16 +04:00
|
|
|
if (size) {
|
|
|
|
aResult.SetTo(size, &aValue);
|
|
|
|
return true;
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
2012-04-19 12:09:16 +04:00
|
|
|
return false;
|
2005-11-29 19:37:15 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::color) {
|
2010-07-17 12:09:14 +04:00
|
|
|
return aResult.ParseColor(aValue);
|
1998-11-24 05:39:36 +03:00
|
|
|
}
|
1998-09-04 02:21:32 +04:00
|
|
|
}
|
2004-03-04 05:06:28 +03:00
|
|
|
|
2005-11-29 19:37:15 +03:00
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
1998-09-02 04:56:01 +04:00
|
|
|
}
|
|
|
|
|
2013-11-19 23:21:29 +04:00
|
|
|
void
|
|
|
|
HTMLFontElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
2017-01-27 03:51:01 +03:00
|
|
|
GenericSpecifiedValues* aData)
|
1998-09-02 04:56:01 +04:00
|
|
|
{
|
2017-01-27 03:51:01 +03:00
|
|
|
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Font))) {
|
1998-09-04 02:21:32 +04:00
|
|
|
// face: string list
|
2017-01-27 03:51:01 +03:00
|
|
|
if (!aData->PropertyIsSet(eCSSProperty_font_family)) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::face);
|
2004-04-13 20:45:59 +04:00
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
|
|
|
!value->IsEmptyString()) {
|
2017-01-27 03:51:01 +03:00
|
|
|
aData->SetFontFamily(value->GetStringValue());
|
1998-09-04 02:21:32 +04:00
|
|
|
}
|
|
|
|
}
|
2012-05-05 13:00:04 +04:00
|
|
|
// size: int
|
2017-01-27 03:51:01 +03:00
|
|
|
if (!aData->PropertyIsSet(eCSSProperty_font_size)) {
|
2012-05-05 13:00:04 +04:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
|
2017-01-27 03:51:01 +03:00
|
|
|
if (value && value->Type() == nsAttrValue::eInteger)
|
|
|
|
aData->SetKeywordValue(eCSSProperty_font_size, value->GetIntegerValue());
|
1998-09-04 02:21:32 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +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
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
|
2004-02-11 03:09:59 +03:00
|
|
|
nscolor color;
|
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
|
|
|
}
|
1999-04-16 01:23:05 +04:00
|
|
|
}
|
2017-01-27 03:51:01 +03:00
|
|
|
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(TextReset)) &&
|
|
|
|
aData->PresContext()->CompatibilityMode() == eCompatibility_NavQuirks) {
|
2003-06-15 06:06:25 +04:00
|
|
|
// Make <a><font color="red">text</font></a> give the text a red underline
|
2011-04-23 09:16:41 +04:00
|
|
|
// in quirks mode. The NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL flag only
|
2003-06-15 06:06:25 +04:00
|
|
|
// affects quirks mode rendering.
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
|
2004-02-11 03:09:59 +03:00
|
|
|
nscolor color;
|
2004-04-13 20:45:59 +04:00
|
|
|
if (value && value->GetColorValue(color)) {
|
2017-01-27 03:51:01 +03:00
|
|
|
aData->SetTextDecorationColorOverride();
|
1998-09-04 02:21:32 +04:00
|
|
|
}
|
|
|
|
}
|
2000-12-23 13:56:31 +03:00
|
|
|
|
2017-01-27 03:51:01 +03:00
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
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
|
|
|
HTMLFontElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
1999-07-07 05:24:40 +04:00
|
|
|
{
|
2004-02-26 00:04:50 +03:00
|
|
|
static const MappedAttributeEntry attributes[] = {
|
2006-12-26 20:47:52 +03:00
|
|
|
{ &nsGkAtoms::face },
|
|
|
|
{ &nsGkAtoms::size },
|
|
|
|
{ &nsGkAtoms::color },
|
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,
|
|
|
|
};
|
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
1999-07-07 05:24:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-12 22:45:38 +03:00
|
|
|
nsMapRuleToAttributesFunc
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFontElement::GetAttributeMappingFunction() const
|
1998-09-05 08:00:06 +04:00
|
|
|
{
|
2005-01-12 22:45:38 +03:00
|
|
|
return &MapAttributesIntoRule;
|
1998-09-02 04:56:01 +04:00
|
|
|
}
|
2012-12-21 18:06:50 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|