2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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 "HTMLFontElement.h"
|
2012-12-21 14:07:28 +00:00
|
|
|
#include "mozilla/dom/HTMLFontElementBinding.h"
|
2012-09-30 16:40:24 +00:00
|
|
|
#include "nsAttrValueInlines.h"
|
2004-01-26 19:22:05 +00:00
|
|
|
#include "nsMappedAttributes.h"
|
2004-07-20 06:11:27 +00:00
|
|
|
#include "nsRuleData.h"
|
2013-01-31 23:11:49 +00:00
|
|
|
#include "nsContentUtils.h"
|
2014-06-06 06:09:23 +00:00
|
|
|
#include "nsCSSParser.h"
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2004-05-18 20:58:12 +00:00
|
|
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Font)
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLFontElement::~HTMLFontElement()
|
1998-09-02 00:56:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:07:28 +00:00
|
|
|
JSObject*
|
2014-04-08 22:27:17 +00:00
|
|
|
HTMLFontElement::WrapNode(JSContext *aCx)
|
2012-12-21 14:07:28 +00:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return HTMLFontElementBinding::Wrap(aCx, this);
|
2012-12-21 14:07:28 +00:00
|
|
|
}
|
|
|
|
|
2012-12-21 14:06:50 +00:00
|
|
|
NS_IMPL_ELEMENT_CLONE(HTMLFontElement)
|
1998-09-02 00:56:01 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLFontElement::ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
1998-09-02 00:56:01 +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::size) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t size = nsContentUtils::ParseLegacyFontSize(aValue);
|
2012-04-19 08:09:16 +00:00
|
|
|
if (size) {
|
|
|
|
aResult.SetTo(size, &aValue);
|
|
|
|
return true;
|
2005-11-29 16:37:15 +00:00
|
|
|
}
|
2012-04-19 08:09:16 +00:00
|
|
|
return false;
|
2005-11-29 16:37:15 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::color) {
|
2010-07-17 08:09:14 +00:00
|
|
|
return aResult.ParseColor(aValue);
|
1998-11-24 02:39:36 +00:00
|
|
|
}
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
2004-03-04 02:06:28 +00:00
|
|
|
|
2005-11-29 16:37:15 +00:00
|
|
|
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
|
|
|
|
aResult);
|
1998-09-02 00:56:01 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 19:21:29 +00:00
|
|
|
void
|
|
|
|
HTMLFontElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
|
|
nsRuleData* aData)
|
1998-09-02 00:56:01 +00:00
|
|
|
{
|
2007-10-08 21:58:22 +00:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
|
1998-09-03 22:21:32 +00:00
|
|
|
// face: string list
|
2011-03-18 03:14:31 +00:00
|
|
|
nsCSSValue* family = aData->ValueForFontFamily();
|
|
|
|
if (family->GetUnit() == eCSSUnit_Null) {
|
2006-12-26 17:47:52 +00:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::face);
|
2004-04-13 16:45:59 +00:00
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
|
|
|
!value->IsEmptyString()) {
|
2014-06-06 06:09:23 +00:00
|
|
|
nsCSSParser parser;
|
|
|
|
parser.ParseFontFamilyListString(value->GetStringValue(),
|
|
|
|
nullptr, 0, *family);
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-05 09:00:04 +00:00
|
|
|
// size: int
|
2011-03-18 03:14:31 +00:00
|
|
|
nsCSSValue* fontSize = aData->ValueForFontSize();
|
|
|
|
if (fontSize->GetUnit() == eCSSUnit_Null) {
|
2012-05-05 09:00:04 +00:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::size);
|
|
|
|
if (value && value->Type() == nsAttrValue::eInteger) {
|
|
|
|
fontSize->SetIntValue(value->GetIntegerValue(), eCSSUnit_Enumerated);
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-31 22:19:43 +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:58:27 +00:00
|
|
|
aData->mPresContext->UseDocumentColors()) {
|
2001-05-31 22:19:43 +00:00
|
|
|
// color: color
|
2006-12-26 17:47:52 +00:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
|
2004-02-11 00:09:59 +00:00
|
|
|
nscolor color;
|
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
|
|
|
}
|
1999-04-15 21:23:05 +00:00
|
|
|
}
|
2011-08-03 18:30:58 +00:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TextReset) &&
|
|
|
|
aData->mPresContext->CompatibilityMode() == eCompatibility_NavQuirks) {
|
2003-06-15 02:06:25 +00:00
|
|
|
// Make <a><font color="red">text</font></a> give the text a red underline
|
2011-04-23 05:16:41 +00:00
|
|
|
// in quirks mode. The NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL flag only
|
2003-06-15 02:06:25 +00:00
|
|
|
// affects quirks mode rendering.
|
2006-12-26 17:47:52 +00:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::color);
|
2004-02-11 00:09:59 +00:00
|
|
|
nscolor color;
|
2004-04-13 16:45:59 +00:00
|
|
|
if (value && value->GetColorValue(color)) {
|
2011-04-23 05:16:41 +00:00
|
|
|
nsCSSValue* decoration = aData->ValueForTextDecorationLine();
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t newValue = NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL;
|
2011-03-18 03:14:31 +00:00
|
|
|
if (decoration->GetUnit() == eCSSUnit_Enumerated) {
|
|
|
|
newValue |= decoration->GetIntValue();
|
2003-06-15 02:06:25 +00:00
|
|
|
}
|
2011-03-18 03:14:31 +00:00
|
|
|
decoration->SetIntValue(newValue, eCSSUnit_Enumerated);
|
1998-09-03 22:21:32 +00:00
|
|
|
}
|
|
|
|
}
|
2000-12-23 10:56:31 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
|
1998-09-05 04:00:06 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLFontElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
1999-07-07 01:24:40 +00:00
|
|
|
{
|
2004-02-25 21:04:50 +00:00
|
|
|
static const MappedAttributeEntry attributes[] = {
|
2006-12-26 17:47:52 +00:00
|
|
|
{ &nsGkAtoms::face },
|
|
|
|
{ &nsGkAtoms::size },
|
|
|
|
{ &nsGkAtoms::color },
|
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,
|
|
|
|
};
|
|
|
|
|
2011-12-18 10:09:27 +00:00
|
|
|
return FindAttributeDependence(aAttribute, map);
|
1999-07-07 01:24:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-12 19:45:38 +00:00
|
|
|
nsMapRuleToAttributesFunc
|
2012-12-21 14:06:50 +00:00
|
|
|
HTMLFontElement::GetAttributeMappingFunction() const
|
1998-09-05 04:00:06 +00:00
|
|
|
{
|
2005-01-12 19:45:38 +00:00
|
|
|
return &MapAttributesIntoRule;
|
1998-09-02 00:56:01 +00:00
|
|
|
}
|
2012-12-21 14:06:50 +00:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|