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/. */
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2008-01-09 01:36:46 +03:00
|
|
|
#include "nsMathMLElement.h"
|
2013-04-21 00:36:44 +04:00
|
|
|
#include "base/compiler_specific.h"
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2008-01-09 01:36:46 +03:00
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsCRT.h"
|
2014-05-24 22:46:38 +04:00
|
|
|
#include "nsLayoutStylesheetCache.h"
|
2008-01-09 01:36:46 +03:00
|
|
|
#include "nsRuleData.h"
|
|
|
|
#include "nsCSSValue.h"
|
2014-06-06 10:09:23 +04:00
|
|
|
#include "nsCSSParser.h"
|
2008-01-09 01:36:46 +03:00
|
|
|
#include "nsMappedAttributes.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsPresContext.h"
|
2008-04-11 21:29:06 +04:00
|
|
|
#include "mozAutoDocUpdate.h"
|
2012-12-27 20:12:05 +04:00
|
|
|
#include "nsIScriptError.h"
|
|
|
|
#include "nsContentUtils.h"
|
2013-09-07 17:01:08 +04:00
|
|
|
#include "nsIURI.h"
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2014-03-18 08:48:21 +04:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2014-04-03 08:18:36 +04:00
|
|
|
#include "mozilla/EventStates.h"
|
2017-01-27 03:51:01 +03:00
|
|
|
#include "mozilla/GenericSpecifiedValuesInlines.h"
|
2013-02-06 13:42:16 +04:00
|
|
|
#include "mozilla/dom/ElementBinding.h"
|
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
using namespace mozilla;
|
2012-11-15 02:10:08 +04:00
|
|
|
using namespace mozilla::dom;
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2008-01-09 01:36:46 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods:
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(nsMathMLElement, nsMathMLElementBase,
|
|
|
|
nsIDOMElement, nsIDOMNode, Link)
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2013-08-08 00:23:08 +04:00
|
|
|
static nsresult
|
2014-01-04 19:02:17 +04:00
|
|
|
WarnDeprecated(const char16_t* aDeprecatedAttribute,
|
|
|
|
const char16_t* aFavoredAttribute, nsIDocument* aDocument)
|
2012-12-27 20:12:05 +04:00
|
|
|
{
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *argv[] =
|
2012-12-27 20:12:05 +04:00
|
|
|
{ aDeprecatedAttribute, aFavoredAttribute };
|
|
|
|
return nsContentUtils::
|
2013-08-21 23:28:26 +04:00
|
|
|
ReportToConsole(nsIScriptError::warningFlag,
|
|
|
|
NS_LITERAL_CSTRING("MathML"), aDocument,
|
2012-12-27 20:12:05 +04:00
|
|
|
nsContentUtils::eMATHML_PROPERTIES,
|
|
|
|
"DeprecatedSupersededBy", argv, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
ReportLengthParseError(const nsString& aValue, nsIDocument* aDocument)
|
|
|
|
{
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *arg = aValue.get();
|
2012-12-27 20:12:05 +04:00
|
|
|
return nsContentUtils::
|
2013-08-21 23:28:26 +04:00
|
|
|
ReportToConsole(nsIScriptError::errorFlag,
|
|
|
|
NS_LITERAL_CSTRING("MathML"), aDocument,
|
2012-12-27 20:12:05 +04:00
|
|
|
nsContentUtils::eMATHML_PROPERTIES,
|
|
|
|
"LengthParsingError", &arg, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
ReportParseErrorNoTag(const nsString& aValue,
|
|
|
|
nsIAtom* aAtom,
|
|
|
|
nsIDocument* aDocument)
|
|
|
|
{
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *argv[] =
|
2012-12-27 20:12:05 +04:00
|
|
|
{ aValue.get(), aAtom->GetUTF16String() };
|
|
|
|
return nsContentUtils::
|
2013-08-21 23:28:26 +04:00
|
|
|
ReportToConsole(nsIScriptError::errorFlag,
|
|
|
|
NS_LITERAL_CSTRING("MathML"), aDocument,
|
2012-12-27 20:12:05 +04:00
|
|
|
nsContentUtils::eMATHML_PROPERTIES,
|
|
|
|
"AttributeParsingErrorNoTag", argv, 2);
|
|
|
|
}
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
nsMathMLElement::nsMathMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2014-03-15 23:00:17 +04:00
|
|
|
: nsMathMLElementBase(aNodeInfo),
|
|
|
|
ALLOW_THIS_IN_INITIALIZER_LIST(Link(this)),
|
|
|
|
mIncrementScriptLevel(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
nsMathMLElement::nsMathMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
2013-04-21 00:36:44 +04:00
|
|
|
: nsMathMLElementBase(aNodeInfo),
|
|
|
|
ALLOW_THIS_IN_INITIALIZER_LIST(Link(this)),
|
|
|
|
mIncrementScriptLevel(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-09 01:36:46 +03:00
|
|
|
nsresult
|
|
|
|
nsMathMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aCompileEventHandlers)
|
2008-01-09 01:36:46 +03:00
|
|
|
{
|
2012-12-07 18:35:14 +04:00
|
|
|
Link::ResetLinkState(false, Link::ElementHasHref());
|
2011-06-24 16:54:28 +04:00
|
|
|
|
2008-01-09 01:36:46 +03:00
|
|
|
nsresult rv = nsMathMLElementBase::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-11-14 07:24:41 +04:00
|
|
|
if (aDocument) {
|
|
|
|
aDocument->RegisterPendingLinkUpdate(this);
|
2014-09-18 14:54:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIDocument* doc = GetComposedDoc();
|
|
|
|
if (doc) {
|
|
|
|
if (!doc->GetMathMLEnabled()) {
|
2011-11-14 07:24:41 +04:00
|
|
|
// Enable MathML and setup the style sheet during binding, not element
|
|
|
|
// construction, because we could move a MathML element from the document
|
|
|
|
// that created it to another document.
|
2016-02-24 10:01:12 +03:00
|
|
|
auto cache = nsLayoutStylesheetCache::For(doc->GetStyleBackendType());
|
2014-09-18 14:54:00 +04:00
|
|
|
doc->SetMathMLEnabled();
|
2016-02-24 10:01:12 +03:00
|
|
|
doc->EnsureOnDemandBuiltInUASheet(cache->MathMLSheet());
|
2011-11-14 07:24:41 +04:00
|
|
|
|
|
|
|
// Rebuild style data for the presshell, because style system
|
|
|
|
// optimizations may have taken place assuming MathML was disabled.
|
|
|
|
// (See nsRuleNode::CheckSpecifiedProperties.)
|
2014-09-18 14:54:00 +04:00
|
|
|
nsCOMPtr<nsIPresShell> shell = doc->GetShell();
|
2011-11-14 07:24:41 +04:00
|
|
|
if (shell) {
|
2014-10-09 01:27:02 +04:00
|
|
|
shell->GetPresContext()->
|
|
|
|
PostRebuildAllStyleDataEvent(nsChangeHint(0), eRestyle_Subtree);
|
2011-11-14 07:24:41 +04:00
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-06-24 16:54:28 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsMathMLElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2011-06-24 16:54:28 +04:00
|
|
|
{
|
|
|
|
// If this link is ever reinserted into a document, it might
|
|
|
|
// be under a different xml:base, so forget the cached state now.
|
2012-12-07 18:35:14 +04:00
|
|
|
Link::ResetLinkState(false, Link::ElementHasHref());
|
2011-06-24 16:54:28 +04:00
|
|
|
|
|
|
|
nsMathMLElementBase::UnbindFromTree(aDeep, aNullParent);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLElement::ParseAttribute(int32_t aNamespaceID,
|
2008-01-09 01:36:46 +03:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult)
|
|
|
|
{
|
|
|
|
if (aNamespaceID == kNameSpaceID_None) {
|
2015-03-03 14:09:00 +03:00
|
|
|
if (IsMathMLElement(nsGkAtoms::math) && aAttribute == nsGkAtoms::mode) {
|
2012-12-27 20:12:05 +04:00
|
|
|
WarnDeprecated(nsGkAtoms::mode->GetUTF16String(),
|
|
|
|
nsGkAtoms::display->GetUTF16String(), OwnerDoc());
|
|
|
|
}
|
|
|
|
if (aAttribute == nsGkAtoms::color) {
|
|
|
|
WarnDeprecated(nsGkAtoms::color->GetUTF16String(),
|
|
|
|
nsGkAtoms::mathcolor_->GetUTF16String(), OwnerDoc());
|
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
if (aAttribute == nsGkAtoms::color ||
|
|
|
|
aAttribute == nsGkAtoms::mathcolor_ ||
|
|
|
|
aAttribute == nsGkAtoms::background ||
|
|
|
|
aAttribute == nsGkAtoms::mathbackground_) {
|
2010-07-17 12:09:14 +04:00
|
|
|
return aResult.ParseColor(aValue);
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsMathMLElementBase::ParseAttribute(aNamespaceID, aAttribute,
|
|
|
|
aValue, aResult);
|
|
|
|
}
|
|
|
|
|
2012-11-15 02:10:08 +04:00
|
|
|
static Element::MappedAttributeEntry sMtableStyles[] = {
|
2012-02-28 03:57:28 +04:00
|
|
|
{ &nsGkAtoms::width },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2012-02-28 03:57:28 +04:00
|
|
|
};
|
|
|
|
|
2012-11-15 02:10:08 +04:00
|
|
|
static Element::MappedAttributeEntry sTokenStyles[] = {
|
2008-01-09 01:36:46 +03:00
|
|
|
{ &nsGkAtoms::mathsize_ },
|
|
|
|
{ &nsGkAtoms::fontsize_ },
|
|
|
|
{ &nsGkAtoms::color },
|
|
|
|
{ &nsGkAtoms::fontfamily_ },
|
2013-12-02 20:49:54 +04:00
|
|
|
{ &nsGkAtoms::fontstyle_ },
|
|
|
|
{ &nsGkAtoms::fontweight_ },
|
|
|
|
{ &nsGkAtoms::mathvariant_},
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2008-01-09 01:36:46 +03:00
|
|
|
};
|
|
|
|
|
2012-11-15 02:10:08 +04:00
|
|
|
static Element::MappedAttributeEntry sEnvironmentStyles[] = {
|
2008-01-09 01:36:46 +03:00
|
|
|
{ &nsGkAtoms::scriptlevel_ },
|
|
|
|
{ &nsGkAtoms::scriptminsize_ },
|
|
|
|
{ &nsGkAtoms::scriptsizemultiplier_ },
|
|
|
|
{ &nsGkAtoms::background },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2008-01-09 01:36:46 +03:00
|
|
|
};
|
|
|
|
|
2012-11-15 02:10:08 +04:00
|
|
|
static Element::MappedAttributeEntry sCommonPresStyles[] = {
|
2010-05-13 06:38:28 +04:00
|
|
|
{ &nsGkAtoms::mathcolor_ },
|
|
|
|
{ &nsGkAtoms::mathbackground_ },
|
2012-07-30 18:20:58 +04:00
|
|
|
{ nullptr }
|
2010-05-13 06:38:28 +04:00
|
|
|
};
|
|
|
|
|
2013-05-30 03:26:40 +04:00
|
|
|
static Element::MappedAttributeEntry sDirStyles[] = {
|
|
|
|
{ &nsGkAtoms::dir },
|
|
|
|
{ nullptr }
|
|
|
|
};
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-01-09 01:36:46 +03:00
|
|
|
nsMathMLElement::IsAttributeMapped(const nsIAtom* aAttribute) const
|
|
|
|
{
|
2012-02-28 03:57:28 +04:00
|
|
|
static const MappedAttributeEntry* const mtableMap[] = {
|
|
|
|
sMtableStyles,
|
|
|
|
sCommonPresStyles
|
|
|
|
};
|
2008-01-09 01:36:46 +03:00
|
|
|
static const MappedAttributeEntry* const tokenMap[] = {
|
2010-05-13 06:38:28 +04:00
|
|
|
sTokenStyles,
|
2013-05-30 03:26:40 +04:00
|
|
|
sCommonPresStyles,
|
|
|
|
sDirStyles
|
2008-01-09 01:36:46 +03:00
|
|
|
};
|
|
|
|
static const MappedAttributeEntry* const mstyleMap[] = {
|
|
|
|
sTokenStyles,
|
2010-05-13 06:38:28 +04:00
|
|
|
sEnvironmentStyles,
|
2013-05-30 03:26:40 +04:00
|
|
|
sCommonPresStyles,
|
|
|
|
sDirStyles
|
2010-05-13 06:38:28 +04:00
|
|
|
};
|
|
|
|
static const MappedAttributeEntry* const commonPresMap[] = {
|
|
|
|
sCommonPresStyles
|
2008-01-09 01:36:46 +03:00
|
|
|
};
|
2013-05-30 03:26:40 +04:00
|
|
|
static const MappedAttributeEntry* const mrowMap[] = {
|
|
|
|
sCommonPresStyles,
|
|
|
|
sDirStyles
|
|
|
|
};
|
|
|
|
|
2008-01-09 01:36:46 +03:00
|
|
|
// We don't support mglyph (yet).
|
2015-03-03 14:09:00 +03:00
|
|
|
if (IsAnyOfMathMLElements(nsGkAtoms::ms_, nsGkAtoms::mi_, nsGkAtoms::mn_,
|
|
|
|
nsGkAtoms::mo_, nsGkAtoms::mtext_,
|
|
|
|
nsGkAtoms::mspace_))
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, tokenMap);
|
2015-03-03 14:09:00 +03:00
|
|
|
if (IsAnyOfMathMLElements(nsGkAtoms::mstyle_, nsGkAtoms::math))
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, mstyleMap);
|
2010-05-13 06:38:28 +04:00
|
|
|
|
2015-03-03 14:09:00 +03:00
|
|
|
if (IsMathMLElement(nsGkAtoms::mtable_))
|
2012-02-28 03:57:28 +04:00
|
|
|
return FindAttributeDependence(aAttribute, mtableMap);
|
|
|
|
|
2015-03-03 14:09:00 +03:00
|
|
|
if (IsMathMLElement(nsGkAtoms::mrow_))
|
2013-05-30 03:26:40 +04:00
|
|
|
return FindAttributeDependence(aAttribute, mrowMap);
|
|
|
|
|
2015-03-03 14:09:00 +03:00
|
|
|
if (IsAnyOfMathMLElements(nsGkAtoms::maction_,
|
|
|
|
nsGkAtoms::maligngroup_,
|
|
|
|
nsGkAtoms::malignmark_,
|
|
|
|
nsGkAtoms::menclose_,
|
|
|
|
nsGkAtoms::merror_,
|
|
|
|
nsGkAtoms::mfenced_,
|
|
|
|
nsGkAtoms::mfrac_,
|
|
|
|
nsGkAtoms::mover_,
|
|
|
|
nsGkAtoms::mpadded_,
|
|
|
|
nsGkAtoms::mphantom_,
|
|
|
|
nsGkAtoms::mprescripts_,
|
|
|
|
nsGkAtoms::mroot_,
|
|
|
|
nsGkAtoms::msqrt_,
|
|
|
|
nsGkAtoms::msub_,
|
|
|
|
nsGkAtoms::msubsup_,
|
|
|
|
nsGkAtoms::msup_,
|
|
|
|
nsGkAtoms::mtd_,
|
|
|
|
nsGkAtoms::mtr_,
|
|
|
|
nsGkAtoms::munder_,
|
|
|
|
nsGkAtoms::munderover_,
|
|
|
|
nsGkAtoms::none)) {
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(aAttribute, commonPresMap);
|
2010-05-13 06:38:28 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsMapRuleToAttributesFunc
|
|
|
|
nsMathMLElement::GetAttributeMappingFunction() const
|
|
|
|
{
|
|
|
|
// It doesn't really matter what our tag is here, because only attributes
|
|
|
|
// that satisfy IsAttributeMapped will be stored in the mapped attributes
|
|
|
|
// list and available to the mapping function
|
|
|
|
return &MapMathMLAttributesInto;
|
|
|
|
}
|
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
/* static */ bool
|
|
|
|
nsMathMLElement::ParseNamedSpaceValue(const nsString& aString,
|
|
|
|
nsCSSValue& aCSSValue,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags)
|
2012-05-16 02:30:14 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t i = 0;
|
2012-05-16 02:30:14 +04:00
|
|
|
// See if it is one of the 'namedspace' (ranging -7/18em, -6/18, ... 7/18em)
|
|
|
|
if (aString.EqualsLiteral("veryverythinmathspace")) {
|
|
|
|
i = 1;
|
|
|
|
} else if (aString.EqualsLiteral("verythinmathspace")) {
|
|
|
|
i = 2;
|
|
|
|
} else if (aString.EqualsLiteral("thinmathspace")) {
|
|
|
|
i = 3;
|
|
|
|
} else if (aString.EqualsLiteral("mediummathspace")) {
|
|
|
|
i = 4;
|
|
|
|
} else if (aString.EqualsLiteral("thickmathspace")) {
|
|
|
|
i = 5;
|
|
|
|
} else if (aString.EqualsLiteral("verythickmathspace")) {
|
|
|
|
i = 6;
|
|
|
|
} else if (aString.EqualsLiteral("veryverythickmathspace")) {
|
|
|
|
i = 7;
|
|
|
|
} else if (aFlags & PARSE_ALLOW_NEGATIVE) {
|
|
|
|
if (aString.EqualsLiteral("negativeveryverythinmathspace")) {
|
|
|
|
i = -1;
|
|
|
|
} else if (aString.EqualsLiteral("negativeverythinmathspace")) {
|
|
|
|
i = -2;
|
|
|
|
} else if (aString.EqualsLiteral("negativethinmathspace")) {
|
|
|
|
i = -3;
|
|
|
|
} else if (aString.EqualsLiteral("negativemediummathspace")) {
|
|
|
|
i = -4;
|
|
|
|
} else if (aString.EqualsLiteral("negativethickmathspace")) {
|
|
|
|
i = -5;
|
|
|
|
} else if (aString.EqualsLiteral("negativeverythickmathspace")) {
|
|
|
|
i = -6;
|
|
|
|
} else if (aString.EqualsLiteral("negativeveryverythickmathspace")) {
|
|
|
|
i = -7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (0 != i) {
|
|
|
|
aCSSValue.SetFloatValue(float(i)/float(18), eCSSUnit_EM);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The REC says:
|
|
|
|
//
|
|
|
|
// "Most presentation elements have attributes that accept values representing
|
|
|
|
// lengths to be used for size, spacing or similar properties. The syntax of a
|
|
|
|
// length is specified as
|
|
|
|
//
|
|
|
|
// number | number unit | namedspace
|
|
|
|
//
|
|
|
|
// There should be no space between the number and the unit of a length."
|
|
|
|
//
|
|
|
|
// "A trailing '%' represents a percent of the default value. The default
|
|
|
|
// value, or how it is obtained, is listed in the table of attributes for each
|
|
|
|
// element. [...] A number without a unit is intepreted as a multiple of the
|
|
|
|
// default value."
|
|
|
|
//
|
|
|
|
// "The possible units in MathML are:
|
|
|
|
//
|
|
|
|
// Unit Description
|
|
|
|
// em an em (font-relative unit traditionally used for horizontal lengths)
|
|
|
|
// ex an ex (font-relative unit traditionally used for vertical lengths)
|
|
|
|
// px pixels, or size of a pixel in the current display
|
|
|
|
// in inches (1 inch = 2.54 centimeters)
|
|
|
|
// cm centimeters
|
|
|
|
// mm millimeters
|
|
|
|
// pt points (1 point = 1/72 inch)
|
|
|
|
// pc picas (1 pica = 12 points)
|
|
|
|
// % percentage of default value"
|
|
|
|
//
|
|
|
|
// The numbers are defined that way:
|
|
|
|
// - unsigned-number: "a string of decimal digits with up to one decimal point
|
|
|
|
// (U+002E), representing a non-negative terminating decimal number (a type of
|
|
|
|
// rational number)"
|
|
|
|
// - number: "an optional prefix of '-' (U+002D), followed by an unsigned
|
|
|
|
// number, representing a terminating decimal number (a type of rational
|
|
|
|
// number)"
|
|
|
|
//
|
2011-09-29 10:19:26 +04:00
|
|
|
/* static */ bool
|
2008-01-09 01:36:46 +03:00
|
|
|
nsMathMLElement::ParseNumericValue(const nsString& aString,
|
|
|
|
nsCSSValue& aCSSValue,
|
2012-12-27 20:12:05 +04:00
|
|
|
uint32_t aFlags,
|
|
|
|
nsIDocument* aDocument)
|
2008-01-09 01:36:46 +03:00
|
|
|
{
|
|
|
|
nsAutoString str(aString);
|
|
|
|
str.CompressWhitespace(); // aString is const in this code...
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t stringLength = str.Length();
|
2012-12-27 20:12:05 +04:00
|
|
|
if (!stringLength) {
|
|
|
|
if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
|
|
|
|
ReportLengthParseError(aString, aDocument);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2012-12-27 20:12:05 +04:00
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
|
2016-05-27 02:48:00 +03:00
|
|
|
if (ParseNamedSpaceValue(str, aCSSValue, aFlags)) {
|
2012-05-16 02:30:14 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-01-09 01:36:46 +03:00
|
|
|
nsAutoString number, unit;
|
|
|
|
|
|
|
|
// see if the negative sign is there
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t i = 0;
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t c = str[0];
|
2008-01-09 01:36:46 +03:00
|
|
|
if (c == '-') {
|
|
|
|
number.Append(c);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Gather up characters that make up the number
|
2011-09-29 10:19:26 +04:00
|
|
|
bool gotDot = false;
|
2008-01-09 01:36:46 +03:00
|
|
|
for ( ; i < stringLength; i++) {
|
|
|
|
c = str[i];
|
2012-12-27 20:12:05 +04:00
|
|
|
if (gotDot && c == '.') {
|
|
|
|
if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
|
|
|
|
ReportLengthParseError(aString, aDocument);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false; // two dots encountered
|
2012-12-27 20:12:05 +04:00
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
else if (c == '.')
|
2011-10-17 18:59:28 +04:00
|
|
|
gotDot = true;
|
2008-01-09 01:36:46 +03:00
|
|
|
else if (!nsCRT::IsAsciiDigit(c)) {
|
|
|
|
str.Right(unit, stringLength - i);
|
|
|
|
// some authors leave blanks before the unit, but that shouldn't
|
|
|
|
// be allowed, so don't CompressWhitespace on 'unit'.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
number.Append(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert number to floating point
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult errorCode;
|
2008-01-09 01:36:46 +03:00
|
|
|
float floatValue = number.ToFloat(&errorCode);
|
2012-12-27 20:12:05 +04:00
|
|
|
if (NS_FAILED(errorCode)) {
|
|
|
|
if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
|
|
|
|
ReportLengthParseError(aString, aDocument);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2012-12-27 20:12:05 +04:00
|
|
|
}
|
|
|
|
if (floatValue < 0 && !(aFlags & PARSE_ALLOW_NEGATIVE)) {
|
|
|
|
if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
|
|
|
|
ReportLengthParseError(aString, aDocument);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2012-12-27 20:12:05 +04:00
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
|
|
|
|
nsCSSUnit cssUnit;
|
|
|
|
if (unit.IsEmpty()) {
|
2008-02-07 07:09:03 +03:00
|
|
|
if (aFlags & PARSE_ALLOW_UNITLESS) {
|
|
|
|
// no explicit unit, this is a number that will act as a multiplier
|
2012-12-27 20:12:05 +04:00
|
|
|
if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
|
|
|
|
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
2013-08-21 23:28:26 +04:00
|
|
|
NS_LITERAL_CSTRING("MathML"), aDocument,
|
2012-12-27 20:12:05 +04:00
|
|
|
nsContentUtils::eMATHML_PROPERTIES,
|
|
|
|
"UnitlessValuesAreDeprecated");
|
|
|
|
}
|
2013-01-07 07:24:13 +04:00
|
|
|
if (aFlags & CONVERT_UNITLESS_TO_PERCENT) {
|
|
|
|
aCSSValue.SetPercentValue(floatValue);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cssUnit = eCSSUnit_Number;
|
2008-02-07 07:09:03 +03:00
|
|
|
} else {
|
|
|
|
// We are supposed to have a unit, but there isn't one.
|
2008-01-09 01:36:46 +03:00
|
|
|
// If the value is 0 we can just call it "pixels" otherwise
|
|
|
|
// this is illegal.
|
2012-12-27 20:12:05 +04:00
|
|
|
if (floatValue != 0.0) {
|
|
|
|
if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
|
|
|
|
ReportLengthParseError(aString, aDocument);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2012-12-27 20:12:05 +04:00
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
cssUnit = eCSSUnit_Pixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (unit.EqualsLiteral("%")) {
|
|
|
|
aCSSValue.SetPercentValue(floatValue / 100.0f);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
else if (unit.EqualsLiteral("em")) cssUnit = eCSSUnit_EM;
|
|
|
|
else if (unit.EqualsLiteral("ex")) cssUnit = eCSSUnit_XHeight;
|
|
|
|
else if (unit.EqualsLiteral("px")) cssUnit = eCSSUnit_Pixel;
|
|
|
|
else if (unit.EqualsLiteral("in")) cssUnit = eCSSUnit_Inch;
|
|
|
|
else if (unit.EqualsLiteral("cm")) cssUnit = eCSSUnit_Centimeter;
|
|
|
|
else if (unit.EqualsLiteral("mm")) cssUnit = eCSSUnit_Millimeter;
|
|
|
|
else if (unit.EqualsLiteral("pt")) cssUnit = eCSSUnit_Point;
|
|
|
|
else if (unit.EqualsLiteral("pc")) cssUnit = eCSSUnit_Pica;
|
2016-05-23 10:18:34 +03:00
|
|
|
else if (unit.EqualsLiteral("q")) cssUnit = eCSSUnit_Quarter;
|
2012-12-27 20:12:05 +04:00
|
|
|
else { // unexpected unit
|
|
|
|
if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
|
|
|
|
ReportLengthParseError(aString, aDocument);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2012-12-27 20:12:05 +04:00
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
|
|
|
|
aCSSValue.SetFloatValue(floatValue, cssUnit);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsMathMLElement::MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
|
2017-04-10 10:28:48 +03:00
|
|
|
GenericSpecifiedValues* aData)
|
2008-01-09 01:36:46 +03:00
|
|
|
{
|
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Font)) {
|
2012-05-16 02:30:14 +04:00
|
|
|
// scriptsizemultiplier
|
|
|
|
//
|
|
|
|
// "Specifies the multiplier to be used to adjust font size due to changes
|
|
|
|
// in scriptlevel.
|
|
|
|
//
|
|
|
|
// values: number
|
|
|
|
// default: 0.71
|
|
|
|
//
|
2008-01-09 01:36:46 +03:00
|
|
|
const nsAttrValue* value =
|
|
|
|
aAttributes->GetAttr(nsGkAtoms::scriptsizemultiplier_);
|
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
2017-04-10 10:28:48 +03:00
|
|
|
!aData->PropertyIsSet(eCSSProperty__moz_script_size_multiplier)) {
|
2008-01-09 01:36:46 +03:00
|
|
|
nsAutoString str(value->GetStringValue());
|
|
|
|
str.CompressWhitespace();
|
|
|
|
// MathML numbers can't have leading '+'
|
|
|
|
if (str.Length() > 0 && str.CharAt(0) != '+') {
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult errorCode;
|
2008-01-09 01:36:46 +03:00
|
|
|
float floatValue = str.ToFloat(&errorCode);
|
|
|
|
// Negative scriptsizemultipliers are not parsed
|
|
|
|
if (NS_SUCCEEDED(errorCode) && floatValue >= 0.0f) {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetNumberValue(eCSSProperty__moz_script_size_multiplier, floatValue);
|
2012-12-27 20:12:05 +04:00
|
|
|
} else {
|
|
|
|
ReportParseErrorNoTag(str,
|
|
|
|
nsGkAtoms::scriptsizemultiplier_,
|
|
|
|
aData->mPresContext->Document());
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
// scriptminsize
|
|
|
|
//
|
|
|
|
// "Specifies the minimum font size allowed due to changes in scriptlevel.
|
|
|
|
// Note that this does not limit the font size due to changes to mathsize."
|
|
|
|
//
|
|
|
|
// values: length
|
|
|
|
// default: 8pt
|
|
|
|
//
|
|
|
|
// We don't allow negative values.
|
2013-01-07 07:24:13 +04:00
|
|
|
// Unitless and percent values give a multiple of the default value.
|
2012-05-16 02:30:14 +04:00
|
|
|
//
|
2008-01-09 01:36:46 +03:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::scriptminsize_);
|
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
2017-04-10 10:28:48 +03:00
|
|
|
!aData->PropertyIsSet(eCSSProperty__moz_script_min_size)) {
|
|
|
|
nsCSSValue scriptMinSize;
|
|
|
|
ParseNumericValue(value->GetStringValue(), scriptMinSize,
|
2013-01-07 07:24:13 +04:00
|
|
|
PARSE_ALLOW_UNITLESS | CONVERT_UNITLESS_TO_PERCENT,
|
2012-12-27 20:12:05 +04:00
|
|
|
aData->mPresContext->Document());
|
2013-01-07 07:24:13 +04:00
|
|
|
|
2017-04-10 10:28:48 +03:00
|
|
|
if (scriptMinSize.GetUnit() == eCSSUnit_Percent) {
|
|
|
|
scriptMinSize.SetFloatValue(8.0 * scriptMinSize.GetPercentValue(),
|
2013-01-07 07:24:13 +04:00
|
|
|
eCSSUnit_Point);
|
|
|
|
}
|
2017-04-10 10:28:48 +03:00
|
|
|
if (scriptMinSize.GetUnit() != eCSSUnit_Null) {
|
|
|
|
aData->SetLengthValue(eCSSProperty__moz_script_min_size, scriptMinSize);
|
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
// scriptlevel
|
|
|
|
//
|
|
|
|
// "Changes the scriptlevel in effect for the children. When the value is
|
|
|
|
// given without a sign, it sets scriptlevel to the specified value; when a
|
|
|
|
// sign is given, it increments ("+") or decrements ("-") the current
|
|
|
|
// value. (Note that large decrements can result in negative values of
|
|
|
|
// scriptlevel, but these values are considered legal.)"
|
|
|
|
//
|
|
|
|
// values: ( "+" | "-" )? unsigned-integer
|
|
|
|
// default: inherited
|
|
|
|
//
|
2008-01-09 01:36:46 +03:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::scriptlevel_);
|
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
2017-04-10 10:28:48 +03:00
|
|
|
!aData->PropertyIsSet(eCSSProperty__moz_script_level)) {
|
2008-01-09 01:36:46 +03:00
|
|
|
nsAutoString str(value->GetStringValue());
|
|
|
|
str.CompressWhitespace();
|
|
|
|
if (str.Length() > 0) {
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult errorCode;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t intValue = str.ToInteger(&errorCode);
|
2008-01-09 01:36:46 +03:00
|
|
|
if (NS_SUCCEEDED(errorCode)) {
|
|
|
|
// This is kind of cheesy ... if the scriptlevel has a sign,
|
|
|
|
// then it's a relative value and we store the nsCSSValue as an
|
|
|
|
// Integer to indicate that. Otherwise we store it as a Number
|
|
|
|
// to indicate that the scriptlevel is absolute.
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t ch = str.CharAt(0);
|
2008-01-09 01:36:46 +03:00
|
|
|
if (ch == '+' || ch == '-') {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetIntValue(eCSSProperty__moz_script_level, intValue);
|
2008-01-09 01:36:46 +03:00
|
|
|
} else {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetNumberValue(eCSSProperty__moz_script_level, intValue);
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
2012-12-27 20:12:05 +04:00
|
|
|
} else {
|
|
|
|
ReportParseErrorNoTag(str,
|
|
|
|
nsGkAtoms::scriptlevel_,
|
|
|
|
aData->mPresContext->Document());
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
// mathsize
|
|
|
|
//
|
|
|
|
// "Specifies the size to display the token content. The values 'small' and
|
|
|
|
// 'big' choose a size smaller or larger than the current font size, but
|
|
|
|
// leave the exact proportions unspecified; 'normal' is allowed for
|
|
|
|
// completeness, but since it is equivalent to '100%' or '1em', it has no
|
|
|
|
// effect."
|
|
|
|
//
|
|
|
|
// values: "small" | "normal" | "big" | length
|
|
|
|
// default: inherited
|
|
|
|
//
|
|
|
|
// fontsize
|
|
|
|
//
|
|
|
|
// "Specified the size for the token. Deprecated in favor of mathsize."
|
|
|
|
//
|
|
|
|
// values: length
|
|
|
|
// default: inherited
|
|
|
|
//
|
|
|
|
// In both cases, we don't allow negative values.
|
2013-01-07 07:24:13 +04:00
|
|
|
// Unitless values give a multiple of the default value.
|
2012-05-16 02:30:14 +04:00
|
|
|
//
|
2011-09-29 10:19:26 +04:00
|
|
|
bool parseSizeKeywords = true;
|
2008-01-09 01:36:46 +03:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::mathsize_);
|
|
|
|
if (!value) {
|
2011-10-17 18:59:28 +04:00
|
|
|
parseSizeKeywords = false;
|
2008-01-09 01:36:46 +03:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::fontsize_);
|
2012-12-27 20:12:05 +04:00
|
|
|
if (value) {
|
|
|
|
WarnDeprecated(nsGkAtoms::fontsize_->GetUTF16String(),
|
|
|
|
nsGkAtoms::mathsize_->GetUTF16String(),
|
|
|
|
aData->mPresContext->Document());
|
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
2017-04-10 10:28:48 +03:00
|
|
|
!aData->PropertyIsSet(eCSSProperty_font_size)) {
|
2008-01-09 01:36:46 +03:00
|
|
|
nsAutoString str(value->GetStringValue());
|
2017-04-10 10:28:48 +03:00
|
|
|
nsCSSValue fontSize;
|
|
|
|
if (!ParseNumericValue(str, fontSize, PARSE_SUPPRESS_WARNINGS |
|
2013-01-07 07:24:13 +04:00
|
|
|
PARSE_ALLOW_UNITLESS | CONVERT_UNITLESS_TO_PERCENT,
|
|
|
|
nullptr)
|
2012-12-27 20:12:05 +04:00
|
|
|
&& parseSizeKeywords) {
|
2008-01-09 01:36:46 +03:00
|
|
|
static const char sizes[3][7] = { "small", "normal", "big" };
|
2014-01-30 22:26:54 +04:00
|
|
|
static const int32_t values[MOZ_ARRAY_LENGTH(sizes)] = {
|
2008-01-09 01:36:46 +03:00
|
|
|
NS_STYLE_FONT_SIZE_SMALL, NS_STYLE_FONT_SIZE_MEDIUM,
|
|
|
|
NS_STYLE_FONT_SIZE_LARGE
|
|
|
|
};
|
|
|
|
str.CompressWhitespace();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
|
2008-01-09 01:36:46 +03:00
|
|
|
if (str.EqualsASCII(sizes[i])) {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetKeywordValue(eCSSProperty_font_size, values[i]);
|
2008-01-09 01:36:46 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-04-10 10:28:48 +03:00
|
|
|
} else if (fontSize.GetUnit() == eCSSUnit_Percent) {
|
|
|
|
aData->SetPercentValue(eCSSProperty_font_size,
|
|
|
|
fontSize.GetPercentValue());
|
|
|
|
} else if (fontSize.GetUnit() != eCSSUnit_Null) {
|
|
|
|
aData->SetLengthValue(eCSSProperty_font_size, fontSize);
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
// fontfamily
|
|
|
|
//
|
|
|
|
// "Should be the name of a font that may be available to a MathML renderer,
|
|
|
|
// or a CSS font specification; See Section 6.5 Using CSS with MathML and
|
|
|
|
// CSS for more information. Deprecated in favor of mathvariant."
|
|
|
|
//
|
|
|
|
// values: string
|
|
|
|
//
|
2008-01-09 01:36:46 +03:00
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::fontfamily_);
|
2012-12-27 20:12:05 +04:00
|
|
|
if (value) {
|
|
|
|
WarnDeprecated(nsGkAtoms::fontfamily_->GetUTF16String(),
|
|
|
|
nsGkAtoms::mathvariant_->GetUTF16String(),
|
|
|
|
aData->mPresContext->Document());
|
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
2017-04-10 10:28:48 +03:00
|
|
|
!aData->PropertyIsSet(eCSSProperty_font_family)) {
|
|
|
|
aData->SetFontFamily(value->GetStringValue());
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
2013-12-02 20:49:54 +04:00
|
|
|
|
|
|
|
// fontstyle
|
|
|
|
//
|
|
|
|
// "Specified the font style to use for the token. Deprecated in favor of
|
|
|
|
// mathvariant."
|
|
|
|
//
|
|
|
|
// values: "normal" | "italic"
|
|
|
|
// default: normal (except on <mi>)
|
|
|
|
//
|
|
|
|
// Note that the font-style property is reset in layout/style/ when
|
|
|
|
// -moz-math-variant is specified.
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::fontstyle_);
|
|
|
|
if (value) {
|
|
|
|
WarnDeprecated(nsGkAtoms::fontstyle_->GetUTF16String(),
|
|
|
|
nsGkAtoms::mathvariant_->GetUTF16String(),
|
|
|
|
aData->mPresContext->Document());
|
|
|
|
if (value->Type() == nsAttrValue::eString &&
|
2017-04-10 10:28:48 +03:00
|
|
|
!aData->PropertyIsSet(eCSSProperty_font_style)) {
|
2013-12-02 20:49:54 +04:00
|
|
|
nsAutoString str(value->GetStringValue());
|
|
|
|
str.CompressWhitespace();
|
|
|
|
if (str.EqualsASCII("normal")) {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetKeywordValue(eCSSProperty_font_style,
|
|
|
|
NS_STYLE_FONT_STYLE_NORMAL);
|
2013-12-02 20:49:54 +04:00
|
|
|
} else if (str.EqualsASCII("italic")) {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetKeywordValue(eCSSProperty_font_style,
|
|
|
|
NS_STYLE_FONT_STYLE_ITALIC);
|
2013-12-02 20:49:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// fontweight
|
|
|
|
//
|
|
|
|
// "Specified the font weight for the token. Deprecated in favor of
|
|
|
|
// mathvariant."
|
|
|
|
//
|
|
|
|
// values: "normal" | "bold"
|
|
|
|
// default: normal
|
|
|
|
//
|
|
|
|
// Note that the font-weight property is reset in layout/style/ when
|
|
|
|
// -moz-math-variant is specified.
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::fontweight_);
|
|
|
|
if (value) {
|
|
|
|
WarnDeprecated(nsGkAtoms::fontweight_->GetUTF16String(),
|
|
|
|
nsGkAtoms::mathvariant_->GetUTF16String(),
|
|
|
|
aData->mPresContext->Document());
|
|
|
|
if (value->Type() == nsAttrValue::eString &&
|
2017-04-10 10:28:48 +03:00
|
|
|
!aData->PropertyIsSet(eCSSProperty_font_weight)) {
|
2013-12-02 20:49:54 +04:00
|
|
|
nsAutoString str(value->GetStringValue());
|
|
|
|
str.CompressWhitespace();
|
|
|
|
if (str.EqualsASCII("normal")) {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetKeywordValue(eCSSProperty_font_weight,
|
|
|
|
NS_STYLE_FONT_WEIGHT_NORMAL);
|
2013-12-02 20:49:54 +04:00
|
|
|
} else if (str.EqualsASCII("bold")) {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetKeywordValue(eCSSProperty_font_weight,
|
|
|
|
NS_STYLE_FONT_WEIGHT_BOLD);
|
2013-12-02 20:49:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// mathvariant
|
|
|
|
//
|
|
|
|
// "Specifies the logical class of the token. Note that this class is more
|
|
|
|
// than styling, it typically conveys semantic intent;"
|
|
|
|
//
|
|
|
|
// values: "normal" | "bold" | "italic" | "bold-italic" | "double-struck" |
|
|
|
|
// "bold-fraktur" | "script" | "bold-script" | "fraktur" | "sans-serif" |
|
|
|
|
// "bold-sans-serif" | "sans-serif-italic" | "sans-serif-bold-italic" |
|
|
|
|
// "monospace" | "initial" | "tailed" | "looped" | "stretched"
|
|
|
|
// default: normal (except on <mi>)
|
|
|
|
//
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::mathvariant_);
|
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
2017-04-10 10:28:48 +03:00
|
|
|
!aData->PropertyIsSet(eCSSProperty__moz_math_variant)) {
|
2013-12-02 20:49:54 +04:00
|
|
|
nsAutoString str(value->GetStringValue());
|
|
|
|
str.CompressWhitespace();
|
|
|
|
static const char sizes[19][23] = {
|
|
|
|
"normal", "bold", "italic", "bold-italic", "script", "bold-script",
|
|
|
|
"fraktur", "double-struck", "bold-fraktur", "sans-serif",
|
|
|
|
"bold-sans-serif", "sans-serif-italic", "sans-serif-bold-italic",
|
|
|
|
"monospace", "initial", "tailed", "looped", "stretched"
|
|
|
|
};
|
2014-01-30 22:26:54 +04:00
|
|
|
static const int32_t values[MOZ_ARRAY_LENGTH(sizes)] = {
|
2013-12-02 20:49:54 +04:00
|
|
|
NS_MATHML_MATHVARIANT_NORMAL, NS_MATHML_MATHVARIANT_BOLD,
|
|
|
|
NS_MATHML_MATHVARIANT_ITALIC, NS_MATHML_MATHVARIANT_BOLD_ITALIC,
|
|
|
|
NS_MATHML_MATHVARIANT_SCRIPT, NS_MATHML_MATHVARIANT_BOLD_SCRIPT,
|
|
|
|
NS_MATHML_MATHVARIANT_FRAKTUR, NS_MATHML_MATHVARIANT_DOUBLE_STRUCK,
|
|
|
|
NS_MATHML_MATHVARIANT_BOLD_FRAKTUR, NS_MATHML_MATHVARIANT_SANS_SERIF,
|
|
|
|
NS_MATHML_MATHVARIANT_BOLD_SANS_SERIF,
|
|
|
|
NS_MATHML_MATHVARIANT_SANS_SERIF_ITALIC,
|
|
|
|
NS_MATHML_MATHVARIANT_SANS_SERIF_BOLD_ITALIC,
|
|
|
|
NS_MATHML_MATHVARIANT_MONOSPACE, NS_MATHML_MATHVARIANT_INITIAL,
|
|
|
|
NS_MATHML_MATHVARIANT_TAILED, NS_MATHML_MATHVARIANT_LOOPED,
|
|
|
|
NS_MATHML_MATHVARIANT_STRETCHED
|
|
|
|
};
|
|
|
|
for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
|
|
|
|
if (str.EqualsASCII(sizes[i])) {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetKeywordValue(eCSSProperty__moz_math_variant, values[i]);
|
2013-12-02 20:49:54 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
// mathbackground
|
|
|
|
//
|
|
|
|
// "Specifies the background color to be used to fill in the bounding box of
|
|
|
|
// the element and its children. The default, 'transparent', lets the
|
|
|
|
// background color, if any, used in the current rendering context to show
|
|
|
|
// through."
|
|
|
|
//
|
|
|
|
// values: color | "transparent"
|
|
|
|
// default: "transparent"
|
|
|
|
//
|
|
|
|
// background
|
|
|
|
//
|
|
|
|
// "Specified the background color to be used to fill in the bounding box of
|
|
|
|
// the element and its children. Deprecated in favor of mathbackground."
|
|
|
|
//
|
|
|
|
// values: color | "transparent"
|
|
|
|
// default: "transparent"
|
|
|
|
//
|
2008-01-09 01:36:46 +03:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Background)) {
|
|
|
|
const nsAttrValue* value =
|
|
|
|
aAttributes->GetAttr(nsGkAtoms::mathbackground_);
|
|
|
|
if (!value) {
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::background);
|
2012-12-27 20:12:05 +04:00
|
|
|
if (value) {
|
|
|
|
WarnDeprecated(nsGkAtoms::background->GetUTF16String(),
|
|
|
|
nsGkAtoms::mathbackground_->GetUTF16String(),
|
|
|
|
aData->mPresContext->Document());
|
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
2017-04-10 10:28:48 +03:00
|
|
|
if (value) {
|
2008-01-09 01:36:46 +03:00
|
|
|
nscolor color;
|
|
|
|
if (value->GetColorValue(color)) {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetColorValueIfUnset(eCSSProperty_background_color, color);
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
// mathcolor
|
|
|
|
//
|
|
|
|
// "Specifies the foreground color to use when drawing the components of this
|
|
|
|
// element, such as the content for token elements or any lines, surds, or
|
|
|
|
// other decorations. It also establishes the default mathcolor used for
|
|
|
|
// child elements when used on a layout element."
|
|
|
|
//
|
|
|
|
// values: color
|
|
|
|
// default: inherited
|
|
|
|
//
|
|
|
|
// color
|
|
|
|
//
|
|
|
|
// "Specified the color for the token. Deprecated in favor of mathcolor."
|
|
|
|
//
|
|
|
|
// values: color
|
|
|
|
// default: inherited
|
|
|
|
//
|
2008-01-09 01:36:46 +03:00
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Color)) {
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::mathcolor_);
|
|
|
|
if (!value) {
|
|
|
|
value = aAttributes->GetAttr(nsGkAtoms::color);
|
2012-12-27 20:12:05 +04:00
|
|
|
if (value) {
|
|
|
|
WarnDeprecated(nsGkAtoms::color->GetUTF16String(),
|
|
|
|
nsGkAtoms::mathcolor_->GetUTF16String(),
|
|
|
|
aData->mPresContext->Document());
|
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
nscolor color;
|
2017-04-10 10:28:48 +03:00
|
|
|
if (value && value->GetColorValue(color)) {
|
|
|
|
aData->SetColorValueIfUnset(eCSSProperty_color, color);
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
}
|
2012-02-28 03:57:28 +04:00
|
|
|
|
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Position)) {
|
2013-12-02 20:49:54 +04:00
|
|
|
// width
|
|
|
|
//
|
|
|
|
// "Specifies the desired width of the entire table and is intended for
|
|
|
|
// visual user agents. When the value is a percentage value, the value is
|
|
|
|
// relative to the horizontal space a MathML renderer has available for the
|
|
|
|
// math element. When the value is "auto", the MathML renderer should
|
|
|
|
// calculate the table width from its contents using whatever layout
|
|
|
|
// algorithm it chooses. "
|
|
|
|
//
|
|
|
|
// values: "auto" | length
|
|
|
|
// default: auto
|
|
|
|
//
|
2017-04-10 10:28:48 +03:00
|
|
|
if (!aData->PropertyIsSet(eCSSProperty_width)) {
|
2012-02-28 03:57:28 +04:00
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::width);
|
2017-04-10 10:28:48 +03:00
|
|
|
nsCSSValue width;
|
2012-02-28 03:57:28 +04:00
|
|
|
// This does not handle auto and unitless values
|
|
|
|
if (value && value->Type() == nsAttrValue::eString) {
|
2017-04-10 10:28:48 +03:00
|
|
|
ParseNumericValue(value->GetStringValue(), width, 0,
|
2012-12-27 20:12:05 +04:00
|
|
|
aData->mPresContext->Document());
|
2017-04-10 10:28:48 +03:00
|
|
|
if (width.GetUnit() == eCSSUnit_Percent) {
|
|
|
|
aData->SetPercentValue(eCSSProperty_width,
|
|
|
|
width.GetPercentValue());
|
|
|
|
} else if (width.GetUnit() != eCSSUnit_Null) {
|
|
|
|
aData->SetLengthValue(eCSSProperty_width, width);
|
|
|
|
}
|
2012-02-28 03:57:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-30 03:26:40 +04:00
|
|
|
// dir
|
|
|
|
//
|
|
|
|
// Overall Directionality of Mathematics Formulas:
|
|
|
|
// "The overall directionality for a formula, basically the direction of the
|
|
|
|
// Layout Schemata, is specified by the dir attribute on the containing math
|
|
|
|
// element (see Section 2.2 The Top-Level math Element). The default is ltr.
|
|
|
|
// [...] The overall directionality is usually set on the math, but may also
|
|
|
|
// be switched for individual subformula by using the dir attribute on mrow
|
|
|
|
// or mstyle elements."
|
|
|
|
//
|
|
|
|
// Bidirectional Layout in Token Elements:
|
|
|
|
// "Specifies the initial directionality for text within the token:
|
|
|
|
// ltr (Left To Right) or rtl (Right To Left). This attribute should only be
|
|
|
|
// needed in rare cases involving weak or neutral characters;
|
|
|
|
// see Section 3.1.5.1 Overall Directionality of Mathematics Formulas for
|
|
|
|
// further discussion. It has no effect on mspace."
|
|
|
|
//
|
|
|
|
// values: "ltr" | "rtl"
|
|
|
|
// default: inherited
|
|
|
|
//
|
|
|
|
if (aData->mSIDs & NS_STYLE_INHERIT_BIT(Visibility)) {
|
|
|
|
const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::dir);
|
|
|
|
if (value && value->Type() == nsAttrValue::eString &&
|
2017-04-10 10:28:48 +03:00
|
|
|
!aData->PropertyIsSet(eCSSProperty_direction)) {
|
2013-05-30 03:26:40 +04:00
|
|
|
nsAutoString str(value->GetStringValue());
|
|
|
|
static const char dirs[][4] = { "ltr", "rtl" };
|
2014-01-30 22:26:54 +04:00
|
|
|
static const int32_t dirValues[MOZ_ARRAY_LENGTH(dirs)] = {
|
2013-05-30 03:26:40 +04:00
|
|
|
NS_STYLE_DIRECTION_LTR, NS_STYLE_DIRECTION_RTL
|
|
|
|
};
|
|
|
|
for (uint32_t i = 0; i < ArrayLength(dirs); ++i) {
|
|
|
|
if (str.EqualsASCII(dirs[i])) {
|
2017-04-10 10:28:48 +03:00
|
|
|
aData->SetKeywordValue(eCSSProperty_direction, dirValues[i]);
|
2013-05-30 03:26:40 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
|
2011-06-24 16:54:28 +04:00
|
|
|
nsresult
|
2016-10-21 05:11:07 +03:00
|
|
|
nsMathMLElement::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
2011-06-24 16:54:28 +04:00
|
|
|
{
|
2016-10-21 05:11:07 +03:00
|
|
|
nsresult rv = Element::GetEventTargetParent(aVisitor);
|
2011-06-24 16:54:28 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2016-10-21 05:11:07 +03:00
|
|
|
return GetEventTargetParentForLinks(aVisitor);
|
2011-06-24 16:54:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2014-03-18 08:48:20 +04:00
|
|
|
nsMathMLElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
|
2011-06-24 16:54:28 +04:00
|
|
|
{
|
|
|
|
return PostHandleEventForLinks(aVisitor);
|
|
|
|
}
|
|
|
|
|
2008-01-09 01:36:46 +03:00
|
|
|
NS_IMPL_ELEMENT_CLONE(nsMathMLElement)
|
|
|
|
|
2014-04-03 08:18:36 +04:00
|
|
|
EventStates
|
2008-01-09 01:36:46 +03:00
|
|
|
nsMathMLElement::IntrinsicState() const
|
|
|
|
{
|
2011-06-24 16:54:28 +04:00
|
|
|
return Link::LinkState() | nsMathMLElementBase::IntrinsicState() |
|
2014-04-03 08:18:36 +04:00
|
|
|
(mIncrementScriptLevel ?
|
|
|
|
NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL : EventStates());
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLElement::IsNodeOfType(uint32_t aFlags) const
|
2008-01-09 01:36:46 +03:00
|
|
|
{
|
2010-04-30 17:12:06 +04:00
|
|
|
return !(aFlags & ~eCONTENT);
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsMathMLElement::SetIncrementScriptLevel(bool aIncrementScriptLevel,
|
|
|
|
bool aNotify)
|
2008-01-09 01:36:46 +03:00
|
|
|
{
|
|
|
|
if (aIncrementScriptLevel == mIncrementScriptLevel)
|
|
|
|
return;
|
|
|
|
mIncrementScriptLevel = aIncrementScriptLevel;
|
|
|
|
|
|
|
|
NS_ASSERTION(aNotify, "We always notify!");
|
|
|
|
|
2011-06-01 05:46:57 +04:00
|
|
|
UpdateState(true);
|
2008-01-09 01:36:46 +03:00
|
|
|
}
|
2011-06-24 16:54:28 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-11-20 02:21:16 +04:00
|
|
|
nsMathMLElement::IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse)
|
2011-06-24 16:54:28 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
if (IsLink(getter_AddRefs(uri))) {
|
|
|
|
if (aTabIndex) {
|
|
|
|
*aTabIndex = ((sTabFocusModel & eTabFocus_linksMask) == 0 ? -1 : 0);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-06-24 16:54:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aTabIndex) {
|
|
|
|
*aTabIndex = -1;
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-06-24 16:54:28 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-06-24 16:54:28 +04:00
|
|
|
nsMathMLElement::IsLink(nsIURI** aURI) const
|
|
|
|
{
|
|
|
|
// http://www.w3.org/TR/2010/REC-MathML3-20101021/chapter6.html#interf.link
|
|
|
|
// The REC says that the following elements should not be linking elements:
|
2015-03-03 14:09:00 +03:00
|
|
|
if (IsAnyOfMathMLElements(nsGkAtoms::mprescripts_, nsGkAtoms::none,
|
|
|
|
nsGkAtoms::malignmark_, nsGkAtoms::maligngroup_)) {
|
2012-07-30 18:20:58 +04:00
|
|
|
*aURI = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-06-24 16:54:28 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasHref = false;
|
2011-06-24 16:54:28 +04:00
|
|
|
const nsAttrValue* href = mAttrsAndChildren.GetAttr(nsGkAtoms::href,
|
|
|
|
kNameSpaceID_None);
|
|
|
|
if (href) {
|
|
|
|
// MathML href
|
|
|
|
// The REC says: "When user agents encounter MathML elements with both href
|
|
|
|
// and xlink:href attributes, the href attribute should take precedence."
|
2011-10-17 18:59:28 +04:00
|
|
|
hasHref = true;
|
2011-06-24 16:54:28 +04:00
|
|
|
} else {
|
|
|
|
// To be a clickable XLink for styling and interaction purposes, we require:
|
|
|
|
//
|
|
|
|
// xlink:href - must be set
|
|
|
|
// xlink:type - must be unset or set to "" or set to "simple"
|
|
|
|
// xlink:show - must be unset or set to "", "new" or "replace"
|
|
|
|
// xlink:actuate - must be unset or set to "" or "onRequest"
|
|
|
|
//
|
|
|
|
// For any other values, we're either not a *clickable* XLink, or the end
|
2011-10-17 18:59:28 +04:00
|
|
|
// result is poorly specified. Either way, we return false.
|
2011-06-24 16:54:28 +04:00
|
|
|
|
|
|
|
static nsIContent::AttrValuesArray sTypeVals[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{ &nsGkAtoms::_empty, &nsGkAtoms::simple, nullptr };
|
2011-06-24 16:54:28 +04:00
|
|
|
|
|
|
|
static nsIContent::AttrValuesArray sShowVals[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{ &nsGkAtoms::_empty, &nsGkAtoms::_new, &nsGkAtoms::replace, nullptr };
|
2011-06-24 16:54:28 +04:00
|
|
|
|
|
|
|
static nsIContent::AttrValuesArray sActuateVals[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{ &nsGkAtoms::_empty, &nsGkAtoms::onRequest, nullptr };
|
2011-06-24 16:54:28 +04:00
|
|
|
|
|
|
|
// Optimization: check for href first for early return
|
|
|
|
href = mAttrsAndChildren.GetAttr(nsGkAtoms::href,
|
|
|
|
kNameSpaceID_XLink);
|
|
|
|
if (href &&
|
|
|
|
FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::type,
|
|
|
|
sTypeVals, eCaseMatters) !=
|
|
|
|
nsIContent::ATTR_VALUE_NO_MATCH &&
|
|
|
|
FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::show,
|
|
|
|
sShowVals, eCaseMatters) !=
|
|
|
|
nsIContent::ATTR_VALUE_NO_MATCH &&
|
|
|
|
FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::actuate,
|
|
|
|
sActuateVals, eCaseMatters) !=
|
|
|
|
nsIContent::ATTR_VALUE_NO_MATCH) {
|
2011-10-17 18:59:28 +04:00
|
|
|
hasHref = true;
|
2011-06-24 16:54:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasHref) {
|
|
|
|
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
|
|
|
// Get absolute URI
|
|
|
|
nsAutoString hrefStr;
|
|
|
|
href->ToString(hrefStr);
|
|
|
|
nsContentUtils::NewURIWithDocumentCharset(aURI, hrefStr,
|
2011-10-18 14:53:36 +04:00
|
|
|
OwnerDoc(), baseURI);
|
2011-06-24 16:54:28 +04:00
|
|
|
// must promise out param is non-null if we return true
|
|
|
|
return !!*aURI;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*aURI = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-06-24 16:54:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsMathMLElement::GetLinkTarget(nsAString& aTarget)
|
|
|
|
{
|
|
|
|
const nsAttrValue* target = mAttrsAndChildren.GetAttr(nsGkAtoms::target,
|
|
|
|
kNameSpaceID_XLink);
|
|
|
|
if (target) {
|
|
|
|
target->ToString(aTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aTarget.IsEmpty()) {
|
|
|
|
|
|
|
|
static nsIContent::AttrValuesArray sShowVals[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{ &nsGkAtoms::_new, &nsGkAtoms::replace, nullptr };
|
2011-06-24 16:54:28 +04:00
|
|
|
|
|
|
|
switch (FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::show,
|
|
|
|
sShowVals, eCaseMatters)) {
|
|
|
|
case 0:
|
|
|
|
aTarget.AssignLiteral("_blank");
|
|
|
|
return;
|
|
|
|
case 1:
|
|
|
|
return;
|
|
|
|
}
|
2011-10-18 15:19:44 +04:00
|
|
|
OwnerDoc()->GetBaseTarget(aTarget);
|
2011-06-24 16:54:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIURI>
|
|
|
|
nsMathMLElement::GetHrefURI() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> hrefURI;
|
2012-07-30 18:20:58 +04:00
|
|
|
return IsLink(getter_AddRefs(hrefURI)) ? hrefURI.forget() : nullptr;
|
2011-06-24 16:54:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
2011-06-24 16:54:28 +04:00
|
|
|
nsIAtom* aPrefix, const nsAString& aValue,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNotify)
|
2011-06-24 16:54:28 +04:00
|
|
|
{
|
|
|
|
nsresult rv = nsMathMLElementBase::SetAttr(aNameSpaceID, aName, aPrefix,
|
|
|
|
aValue, aNotify);
|
|
|
|
|
|
|
|
// The ordering of the parent class's SetAttr call and Link::ResetLinkState
|
|
|
|
// is important here! The attribute is not set until SetAttr returns, and
|
|
|
|
// we will need the updated attribute value because notifying the document
|
|
|
|
// that content states have changed will call IntrinsicState, which will try
|
|
|
|
// to get updated information about the visitedness from Link.
|
|
|
|
if (aName == nsGkAtoms::href &&
|
|
|
|
(aNameSpaceID == kNameSpaceID_None ||
|
|
|
|
aNameSpaceID == kNameSpaceID_XLink)) {
|
2012-12-27 20:12:05 +04:00
|
|
|
if (aNameSpaceID == kNameSpaceID_XLink) {
|
2016-07-21 08:03:25 +03:00
|
|
|
WarnDeprecated(u"xlink:href", u"href", OwnerDoc());
|
2012-12-27 20:12:05 +04:00
|
|
|
}
|
2012-12-07 18:35:14 +04:00
|
|
|
Link::ResetLinkState(!!aNotify, true);
|
2011-06-24 16:54:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNotify)
|
2011-06-24 16:54:28 +04:00
|
|
|
{
|
|
|
|
nsresult rv = nsMathMLElementBase::UnsetAttr(aNameSpaceID, aAttr, aNotify);
|
|
|
|
|
|
|
|
// The ordering of the parent class's UnsetAttr call and Link::ResetLinkState
|
|
|
|
// is important here! The attribute is not unset until UnsetAttr returns, and
|
|
|
|
// we will need the updated attribute value because notifying the document
|
|
|
|
// that content states have changed will call IntrinsicState, which will try
|
|
|
|
// to get updated information about the visitedness from Link.
|
|
|
|
if (aAttr == nsGkAtoms::href &&
|
|
|
|
(aNameSpaceID == kNameSpaceID_None ||
|
|
|
|
aNameSpaceID == kNameSpaceID_XLink)) {
|
2012-12-07 18:35:14 +04:00
|
|
|
// Note: just because we removed a single href attr doesn't mean there's no href,
|
|
|
|
// since there are 2 possible namespaces.
|
|
|
|
Link::ResetLinkState(!!aNotify, Link::ElementHasHref());
|
2011-06-24 16:54:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2013-02-06 13:42:16 +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
|
|
|
nsMathMLElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-02-06 13:42:16 +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 ElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-02-06 13:42:16 +04:00
|
|
|
}
|