2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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-10 22:50:08 -07:00
|
|
|
|
2012-12-21 06:06:50 -08:00
|
|
|
#include "HTMLFontElement.h"
|
2012-12-21 06:07:28 -08:00
|
|
|
#include "mozilla/dom/HTMLFontElementBinding.h"
|
2012-09-30 09:40:24 -07:00
|
|
|
#include "nsAttrValueInlines.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsMappedAttributes.h"
|
|
|
|
#include "nsRuleData.h"
|
2013-01-31 15:11:49 -08:00
|
|
|
#include "nsContentUtils.h"
|
2014-06-05 23:09:23 -07:00
|
|
|
#include "nsCSSParser.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Font)
|
|
|
|
|
2012-12-21 06:06:50 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-21 06:06:50 -08:00
|
|
|
HTMLFontElement::~HTMLFontElement()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-21 06:07:28 -08: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 07:13:33 -07:00
|
|
|
HTMLFontElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-21 06:07:28 -08: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 07:13:33 -07:00
|
|
|
return HTMLFontElementBinding::Wrap(aCx, this, aGivenProto);
|
2012-12-21 06:07:28 -08:00
|
|
|
}
|
|
|
|
|
2012-12-21 06:06:50 -08:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLFontElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-12-21 06:06:50 -08:00
|
|
|
HTMLFontElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
|
|
|
if (aAttribute == nsGkAtoms::size) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t size = nsContentUtils::ParseLegacyFontSize(aValue);
|
2012-04-19 01:09:16 -07:00
|
|
|
if (size) {
|
|
|
|
aResult.SetTo(size, &aValue);
|
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-04-19 01:09:16 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::color) {
|
2010-07-17 01:09:14 -07:00
|
|
|
return aResult.ParseColor(aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
|
|
|
}
|
|
|
|
|
2013-11-19 11:21:29 -08:00
|
|
|
void
|
|
|
|
HTMLFontElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
|
|
nsRuleData* aData)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-10-08 14:58:22 -07:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// face: string list
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* family = aData->ValueForFontFamily();
|
|
|
|
if (family->GetUnit() == eCSSUnit_Null) {
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::face);
|
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
|
|
|
!value->IsEmptyString()) {
|
2014-06-05 23:09:23 -07:00
|
|
|
nsCSSParser parser;
|
|
|
|
parser.ParseFontFamilyListString(value->GetStringValue(),
|
|
|
|
nullptr, 0, *family);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-05 02:00:04 -07:00
|
|
|
// size: int
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* fontSize = aData->ValueForFontSize();
|
|
|
|
if (fontSize->GetUnit() == eCSSUnit_Null) {
|
2012-05-05 02:00:04 -07:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
fontSize->SetIntValue(value->GetIntegerValue(), eCSSUnit_Enumerated);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-08 14:58:22 -07:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
|
2011-03-17 20:14:31 -07:00
|
|
|
nsCSSValue* colorValue = aData->ValueForColor();
|
|
|
|
if (colorValue->GetUnit() == eCSSUnit_Null &&
|
2007-11-15 19:58:27 -08:00
|
|
|
aData->mPresContext->UseDocumentColors()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// color: color
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
|
|
|
|
nscolor color;
|
|
|
|
if (value && value->GetColorValue(color)) {
|
2011-03-17 20:14:31 -07:00
|
|
|
colorValue->SetColorValue(color);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-03 11:30:58 -07:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset) &&
|
|
|
|
aData->mPresContext->CompatibilityMode() == eCompatibility_NavQuirks) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Make <a><font color="red">text</font></a> give the text a red underline
|
2011-04-22 22:16:41 -07:00
|
|
|
// in quirks mode. The NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL flag only
|
2007-03-22 10:30:00 -07:00
|
|
|
// affects quirks mode rendering.
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
|
|
|
|
nscolor color;
|
|
|
|
if (value && value->GetColorValue(color)) {
|
2011-04-22 22:16:41 -07:00
|
|
|
nsCSSValue* decoration = aData->ValueForTextDecorationLine();
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t newValue = NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL;
|
2011-03-17 20:14:31 -07:00
|
|
|
if (decoration->GetUnit() == eCSSUnit_Enumerated) {
|
|
|
|
newValue |= decoration->GetIntValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-03-17 20:14:31 -07:00
|
|
|
decoration->SetIntValue(newValue, eCSSUnit_Enumerated);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP_(bool)
|
2012-12-21 06:06:50 -08:00
|
|
|
HTMLFontElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
static const MappedAttributeEntry attributes[] = {
|
|
|
|
{ &nsGkAtoms::face },
|
|
|
|
{ &nsGkAtoms::size },
|
|
|
|
{ &nsGkAtoms::color },
|
2012-07-30 07:20:58 -07:00
|
|
|
{ nullptr }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
attributes,
|
|
|
|
sCommonAttributeMap,
|
|
|
|
};
|
|
|
|
|
2011-12-18 02:09:27 -08:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsMapRuleToAttributesFunc
|
2012-12-21 06:06:50 -08:00
|
|
|
HTMLFontElement::GetAttributeMappingFunction() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return &MapAttributesIntoRule;
|
|
|
|
}
|
2012-12-21 06:06:50 -08:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|