2015-11-25 04:14:39 +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: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#include "mozilla/ServoBindings.h"
|
|
|
|
|
2016-08-11 02:56:33 +03:00
|
|
|
#include "ChildIterator.h"
|
2016-06-07 22:13:24 +03:00
|
|
|
#include "gfxFontFamilyList.h"
|
2017-03-10 05:53:19 +03:00
|
|
|
#include "nsAnimationManager.h"
|
2016-05-25 21:16:26 +03:00
|
|
|
#include "nsAttrValueInlines.h"
|
2017-02-21 16:21:07 +03:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2017-01-10 03:05:18 +03:00
|
|
|
#include "nsCSSProps.h"
|
2016-12-17 12:58:56 +03:00
|
|
|
#include "nsCSSParser.h"
|
2017-01-24 10:27:56 +03:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
#include "nsCSSRuleProcessor.h"
|
|
|
|
#include "nsContentUtils.h"
|
2016-05-25 21:16:26 +03:00
|
|
|
#include "nsDOMTokenList.h"
|
2016-08-12 07:28:40 +03:00
|
|
|
#include "nsIContentInlines.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIDocument.h"
|
2016-08-12 05:01:52 +03:00
|
|
|
#include "nsIFrame.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
#include "nsINode.h"
|
2017-02-10 05:42:29 +03:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIPresShellInlines.h"
|
2016-05-21 03:02:54 +03:00
|
|
|
#include "nsIPrincipal.h"
|
2017-01-20 02:56:53 +03:00
|
|
|
#include "nsMappedAttributes.h"
|
2017-01-15 01:33:40 +03:00
|
|
|
#include "nsMediaFeatures.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
#include "nsNameSpaceManager.h"
|
2016-12-17 12:58:56 +03:00
|
|
|
#include "nsNetUtil.h"
|
2016-08-22 16:01:41 +03:00
|
|
|
#include "nsRuleNode.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
#include "nsString.h"
|
2016-04-02 03:04:59 +03:00
|
|
|
#include "nsStyleStruct.h"
|
2016-06-30 23:37:52 +03:00
|
|
|
#include "nsStyleUtil.h"
|
2016-07-19 04:02:55 +03:00
|
|
|
#include "nsTArray.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
|
2017-01-24 10:27:56 +03:00
|
|
|
#include "mozilla/EffectCompositor.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
#include "mozilla/EventStates.h"
|
2017-01-29 06:58:39 +03:00
|
|
|
#include "mozilla/Keyframe.h"
|
2017-01-24 10:27:56 +03:00
|
|
|
#include "mozilla/ServoAnimationRule.h"
|
2016-07-19 04:02:55 +03:00
|
|
|
#include "mozilla/ServoElementSnapshot.h"
|
2016-08-12 05:01:52 +03:00
|
|
|
#include "mozilla/ServoRestyleManager.h"
|
2016-11-01 02:30:43 +03:00
|
|
|
#include "mozilla/StyleAnimationValue.h"
|
2016-10-18 07:29:03 +03:00
|
|
|
#include "mozilla/DeclarationBlockInlines.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
#include "mozilla/dom/Element.h"
|
2016-12-01 21:40:04 +03:00
|
|
|
#include "mozilla/dom/ElementInlines.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
|
2016-08-12 05:01:52 +03:00
|
|
|
using namespace mozilla;
|
2016-08-11 02:56:33 +03:00
|
|
|
using namespace mozilla::dom;
|
2016-08-12 05:01:52 +03:00
|
|
|
|
2016-11-23 03:35:55 +03:00
|
|
|
#define SERVO_ARC_TYPE(name_, type_) \
|
|
|
|
already_AddRefed<type_> \
|
|
|
|
type_##Strong::Consume() { \
|
|
|
|
RefPtr<type_> result; \
|
|
|
|
result.swap(mPtr); \
|
|
|
|
return result.forget(); \
|
2016-08-23 03:32:20 +03:00
|
|
|
}
|
2016-11-23 03:35:55 +03:00
|
|
|
#include "mozilla/ServoArcTypeList.h"
|
|
|
|
#undef SERVO_ARC_TYPE
|
2016-08-16 08:08:46 +03:00
|
|
|
|
2015-11-25 04:14:39 +03:00
|
|
|
uint32_t
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_ChildrenCount(RawGeckoNodeBorrowed aNode)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aNode->GetChildCount();
|
|
|
|
}
|
|
|
|
|
2016-03-03 07:27:07 +03:00
|
|
|
bool
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_NodeIsElement(RawGeckoNodeBorrowed aNode)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aNode->IsElement();
|
|
|
|
}
|
|
|
|
|
2016-12-29 10:04:32 +03:00
|
|
|
bool
|
|
|
|
Gecko_IsInDocument(RawGeckoNodeBorrowed aNode)
|
|
|
|
{
|
|
|
|
return aNode->IsInComposedDoc();
|
|
|
|
}
|
|
|
|
|
2017-02-01 23:37:00 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
bool
|
|
|
|
Gecko_FlattenedTreeParentIsParent(RawGeckoNodeBorrowed aNode)
|
|
|
|
{
|
|
|
|
// Servo calls this in debug builds to verify the result of its own
|
|
|
|
// flattened_tree_parent_is_parent() function.
|
|
|
|
return FlattenedTreeParentIsParent<nsIContent::eForStyle>(aNode);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoNodeBorrowedOrNull
|
|
|
|
Gecko_GetParentNode(RawGeckoNodeBorrowed aNode)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
2017-02-01 23:37:00 +03:00
|
|
|
MOZ_ASSERT(!FlattenedTreeParentIsParent<nsIContent::eForStyle>(aNode),
|
|
|
|
"Should have taken the inline path");
|
|
|
|
MOZ_ASSERT(aNode->IsContent(), "Slow path only applies to content");
|
|
|
|
const nsIContent* c = aNode->AsContent();
|
|
|
|
return c->GetFlattenedTreeParentNodeInternal(nsIContent::eForStyle);
|
2015-11-25 04:14:39 +03:00
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoNodeBorrowedOrNull
|
|
|
|
Gecko_GetFirstChild(RawGeckoNodeBorrowed aNode)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aNode->GetFirstChild();
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoNodeBorrowedOrNull
|
|
|
|
Gecko_GetLastChild(RawGeckoNodeBorrowed aNode)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aNode->GetLastChild();
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoNodeBorrowedOrNull
|
|
|
|
Gecko_GetPrevSibling(RawGeckoNodeBorrowed aNode)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aNode->GetPreviousSibling();
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoNodeBorrowedOrNull
|
|
|
|
Gecko_GetNextSibling(RawGeckoNodeBorrowed aNode)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aNode->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoElementBorrowedOrNull
|
|
|
|
Gecko_GetParentElement(RawGeckoElementBorrowed aElement)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
2016-12-01 09:55:49 +03:00
|
|
|
return aElement->GetFlattenedTreeParentElementForStyle();
|
2015-11-25 04:14:39 +03:00
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoElementBorrowedOrNull
|
|
|
|
Gecko_GetFirstChildElement(RawGeckoElementBorrowed aElement)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aElement->GetFirstElementChild();
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoElementBorrowedOrNull Gecko_GetLastChildElement(RawGeckoElementBorrowed aElement)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aElement->GetLastElementChild();
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoElementBorrowedOrNull
|
|
|
|
Gecko_GetPrevSiblingElement(RawGeckoElementBorrowed aElement)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aElement->GetPreviousElementSibling();
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoElementBorrowedOrNull
|
|
|
|
Gecko_GetNextSiblingElement(RawGeckoElementBorrowed aElement)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aElement->GetNextElementSibling();
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoElementBorrowedOrNull
|
|
|
|
Gecko_GetDocumentElement(RawGeckoDocumentBorrowed aDoc)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aDoc->GetDocumentElement();
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
StyleChildrenIteratorOwnedOrNull
|
|
|
|
Gecko_MaybeCreateStyleChildrenIterator(RawGeckoNodeBorrowed aNode)
|
2016-08-11 02:56:33 +03:00
|
|
|
{
|
|
|
|
if (!aNode->IsElement()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-10-18 07:29:03 +03:00
|
|
|
const Element* el = aNode->AsElement();
|
2016-08-11 02:56:33 +03:00
|
|
|
return StyleChildrenIterator::IsNeeded(el) ? new StyleChildrenIterator(el)
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_DropStyleChildrenIterator(StyleChildrenIteratorOwned aIterator)
|
2016-08-11 02:56:33 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIterator);
|
|
|
|
delete aIterator;
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoNodeBorrowed
|
2016-10-18 07:29:03 +03:00
|
|
|
Gecko_GetNextStyleChild(StyleChildrenIteratorBorrowedMut aIterator)
|
2016-08-11 02:56:33 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIterator);
|
|
|
|
return aIterator->GetNextChild();
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
EventStates::ServoType
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_ElementState(RawGeckoElementBorrowed aElement)
|
2016-02-24 04:51:47 +03:00
|
|
|
{
|
2016-07-19 04:02:55 +03:00
|
|
|
return aElement->StyleState().ServoValue();
|
2016-02-24 04:51:47 +03:00
|
|
|
}
|
|
|
|
|
2016-03-03 07:27:07 +03:00
|
|
|
bool
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_IsLink(RawGeckoElementBorrowed aElement)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return nsCSSRuleProcessor::IsLink(aElement);
|
|
|
|
}
|
|
|
|
|
2016-03-03 07:27:07 +03:00
|
|
|
bool
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_IsTextNode(RawGeckoNodeBorrowed aNode)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aNode->NodeInfo()->NodeType() == nsIDOMNode::TEXT_NODE;
|
|
|
|
}
|
|
|
|
|
2016-03-03 07:27:07 +03:00
|
|
|
bool
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_IsVisitedLink(RawGeckoElementBorrowed aElement)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aElement->StyleState().HasState(NS_EVENT_STATE_VISITED);
|
|
|
|
}
|
|
|
|
|
2016-03-03 07:27:07 +03:00
|
|
|
bool
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_IsUnvisitedLink(RawGeckoElementBorrowed aElement)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aElement->StyleState().HasState(NS_EVENT_STATE_UNVISITED);
|
|
|
|
}
|
|
|
|
|
2016-03-03 07:27:07 +03:00
|
|
|
bool
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_IsRootElement(RawGeckoElementBorrowed aElement)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
|
|
|
return aElement->OwnerDoc()->GetRootElement() == aElement;
|
|
|
|
}
|
|
|
|
|
2017-01-06 13:12:08 +03:00
|
|
|
bool
|
|
|
|
Gecko_MatchesElement(CSSPseudoClassType aType,
|
|
|
|
RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
return nsCSSPseudoClasses::MatchesElement(aType, aElement).value();
|
|
|
|
}
|
|
|
|
|
2016-05-18 22:05:36 +03:00
|
|
|
nsIAtom*
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_LocalName(RawGeckoElementBorrowed aElement)
|
2016-05-18 22:05:36 +03:00
|
|
|
{
|
|
|
|
return aElement->NodeInfo()->NameAtom();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_Namespace(RawGeckoElementBorrowed aElement)
|
2016-05-18 22:05:36 +03:00
|
|
|
{
|
|
|
|
int32_t id = aElement->NodeInfo()->NamespaceID();
|
2016-08-06 00:21:54 +03:00
|
|
|
return nsContentUtils::NameSpaceManager()->NameSpaceURIAtomForServo(id);
|
2016-05-18 22:05:36 +03:00
|
|
|
}
|
|
|
|
|
2016-05-25 21:16:26 +03:00
|
|
|
nsIAtom*
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_GetElementId(RawGeckoElementBorrowed aElement)
|
2016-05-25 21:16:26 +03:00
|
|
|
{
|
|
|
|
const nsAttrValue* attr = aElement->GetParsedAttr(nsGkAtoms::id);
|
|
|
|
return attr ? attr->GetAtomValue() : nullptr;
|
|
|
|
}
|
|
|
|
|
2016-07-08 10:07:06 +03:00
|
|
|
// Dirtiness tracking.
|
|
|
|
uint32_t
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_GetNodeFlags(RawGeckoNodeBorrowed aNode)
|
2016-07-08 10:07:06 +03:00
|
|
|
{
|
|
|
|
return aNode->GetFlags();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_SetNodeFlags(RawGeckoNodeBorrowed aNode, uint32_t aFlags)
|
2016-07-08 10:07:06 +03:00
|
|
|
{
|
2016-10-18 07:29:03 +03:00
|
|
|
const_cast<nsINode*>(aNode)->SetFlags(aFlags);
|
2016-07-08 10:07:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_UnsetNodeFlags(RawGeckoNodeBorrowed aNode, uint32_t aFlags)
|
2016-07-08 10:07:06 +03:00
|
|
|
{
|
2016-10-18 07:29:03 +03:00
|
|
|
const_cast<nsINode*>(aNode)->UnsetFlags(aFlags);
|
2016-07-08 10:07:06 +03:00
|
|
|
}
|
|
|
|
|
2017-02-10 05:42:29 +03:00
|
|
|
void
|
|
|
|
Gecko_SetOwnerDocumentNeedsStyleFlush(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
if (nsIPresShell* shell = aElement->OwnerDoc()->GetShell()) {
|
|
|
|
shell->SetNeedStyleFlush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-29 05:20:45 +03:00
|
|
|
nsStyleContext*
|
2016-08-23 16:11:02 +03:00
|
|
|
Gecko_GetStyleContext(RawGeckoNodeBorrowed aNode, nsIAtom* aPseudoTagOrNull)
|
2016-07-29 05:20:45 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aNode->IsContent());
|
2016-08-12 05:01:52 +03:00
|
|
|
nsIFrame* relevantFrame =
|
|
|
|
ServoRestyleManager::FrameForPseudoElement(aNode->AsContent(),
|
|
|
|
aPseudoTagOrNull);
|
2017-02-21 16:21:07 +03:00
|
|
|
if (relevantFrame) {
|
|
|
|
return relevantFrame->StyleContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aPseudoTagOrNull) {
|
2016-07-29 05:20:45 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-02-21 16:21:07 +03:00
|
|
|
// FIXME(emilio): Is there a shorter path?
|
|
|
|
nsCSSFrameConstructor* fc =
|
|
|
|
aNode->OwnerDoc()->GetShell()->GetPresContext()->FrameConstructor();
|
|
|
|
|
|
|
|
// NB: This is only called for CalcStyleDifference, and we handle correctly
|
|
|
|
// the display: none case since Servo still has the older style.
|
|
|
|
return fc->GetDisplayContentsStyleFor(aNode->AsContent());
|
2016-07-29 05:20:45 +03:00
|
|
|
}
|
|
|
|
|
2016-07-27 00:22:57 +03:00
|
|
|
nsChangeHint
|
2016-07-29 05:20:45 +03:00
|
|
|
Gecko_CalcStyleDifference(nsStyleContext* aOldStyleContext,
|
2016-08-16 08:10:05 +03:00
|
|
|
ServoComputedValuesBorrowed aComputedValues)
|
2016-07-27 00:22:57 +03:00
|
|
|
{
|
2016-07-29 05:20:45 +03:00
|
|
|
MOZ_ASSERT(aOldStyleContext);
|
|
|
|
MOZ_ASSERT(aComputedValues);
|
2016-07-27 00:22:57 +03:00
|
|
|
|
|
|
|
// Pass the safe thing, which causes us to miss a potential optimization. See
|
|
|
|
// bug 1289863.
|
|
|
|
nsChangeHint forDescendants = nsChangeHint_Hints_NotHandledForDescendants;
|
|
|
|
|
|
|
|
// Eventually, we should compute things out of these flags like
|
|
|
|
// ElementRestyler::RestyleSelf does and pass the result to the caller to
|
|
|
|
// potentially halt traversal. See bug 1289868.
|
|
|
|
uint32_t equalStructs, samePointerStructs;
|
|
|
|
nsChangeHint result =
|
2016-07-29 05:20:45 +03:00
|
|
|
aOldStyleContext->CalcStyleDifference(aComputedValues,
|
|
|
|
forDescendants,
|
|
|
|
&equalStructs,
|
|
|
|
&samePointerStructs);
|
|
|
|
|
2016-07-27 00:22:57 +03:00
|
|
|
return result;
|
2016-07-29 05:20:45 +03:00
|
|
|
}
|
|
|
|
|
2017-02-16 06:36:57 +03:00
|
|
|
nsChangeHint
|
|
|
|
Gecko_HintsHandledForDescendants(nsChangeHint aHint)
|
|
|
|
{
|
|
|
|
return aHint & ~NS_HintsNotHandledForDescendantsIn(aHint);
|
|
|
|
}
|
|
|
|
|
2016-11-02 09:11:24 +03:00
|
|
|
ServoElementSnapshotOwned
|
|
|
|
Gecko_CreateElementSnapshot(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
2017-01-05 02:05:54 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2016-11-02 09:11:24 +03:00
|
|
|
return new ServoElementSnapshot(aElement);
|
|
|
|
}
|
2016-08-25 01:38:49 +03:00
|
|
|
|
2016-11-02 09:11:24 +03:00
|
|
|
void
|
|
|
|
Gecko_DropElementSnapshot(ServoElementSnapshotOwned aSnapshot)
|
|
|
|
{
|
2017-01-05 02:05:54 +03:00
|
|
|
// Proxy deletes have a lot of overhead, so Servo tries hard to only drop
|
|
|
|
// snapshots on the main thread. However, there are certain cases where
|
|
|
|
// it's unavoidable (i.e. synchronously dropping the style data for the
|
|
|
|
// descendants of a new display:none root).
|
|
|
|
if (MOZ_UNLIKELY(!NS_IsMainThread())) {
|
|
|
|
nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction([=]() { delete aSnapshot; });
|
|
|
|
NS_DispatchToMainThread(task.forget());
|
|
|
|
} else {
|
|
|
|
delete aSnapshot;
|
|
|
|
}
|
2016-07-27 00:22:57 +03:00
|
|
|
}
|
|
|
|
|
2016-10-18 07:29:03 +03:00
|
|
|
RawServoDeclarationBlockStrongBorrowedOrNull
|
2017-01-20 02:56:53 +03:00
|
|
|
Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
|
2016-07-19 04:02:55 +03:00
|
|
|
{
|
2017-01-12 03:03:16 +03:00
|
|
|
DeclarationBlock* decl = aElement->GetInlineStyleDeclaration();
|
2016-10-18 07:29:03 +03:00
|
|
|
if (!decl) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (decl->IsGecko()) {
|
2017-01-12 03:03:16 +03:00
|
|
|
// XXX This can happen when nodes are adopted from a Gecko-style-backend
|
|
|
|
// document into a Servo-style-backend document. See bug 1330051.
|
2016-10-18 07:29:03 +03:00
|
|
|
NS_WARNING("stylo: requesting a Gecko declaration block?");
|
|
|
|
return nullptr;
|
|
|
|
}
|
2017-02-23 04:19:04 +03:00
|
|
|
return decl->AsServo()->RefRawStrong();
|
2016-07-19 04:02:55 +03:00
|
|
|
}
|
|
|
|
|
2017-01-20 02:56:53 +03:00
|
|
|
RawServoDeclarationBlockStrongBorrowedOrNull
|
|
|
|
Gecko_GetHTMLPresentationAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
|
|
|
|
sizeof(RawServoDeclarationBlockStrong),
|
|
|
|
"RefPtr should just be a pointer");
|
|
|
|
const nsMappedAttributes* attrs = aElement->GetMappedAttributes();
|
|
|
|
if (!attrs) {
|
2017-02-23 04:19:04 +03:00
|
|
|
auto* svg = nsSVGElement::FromContentOrNull(aElement);
|
2017-02-23 04:19:04 +03:00
|
|
|
if (svg) {
|
|
|
|
if (auto decl = svg->GetContentDeclarationBlock()) {
|
|
|
|
return decl->AsServo()->RefRawStrong();
|
|
|
|
}
|
|
|
|
}
|
2017-01-20 02:56:53 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const RefPtr<RawServoDeclarationBlock>& servo = attrs->GetServoStyle();
|
|
|
|
return reinterpret_cast<const RawServoDeclarationBlockStrong*>(&servo);
|
|
|
|
}
|
|
|
|
|
2017-01-24 10:27:56 +03:00
|
|
|
RawServoDeclarationBlockStrong
|
|
|
|
Gecko_GetAnimationRule(RawGeckoElementBorrowed aElement,
|
2017-01-24 10:33:10 +03:00
|
|
|
nsIAtom* aPseudoTag,
|
|
|
|
EffectCompositor::CascadeLevel aCascadeLevel)
|
2017-01-24 10:27:56 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aElement, "Invalid GeckoElement");
|
|
|
|
|
|
|
|
const RawServoDeclarationBlockStrong emptyDeclarationBlock{ nullptr };
|
|
|
|
nsIDocument* doc = aElement->GetComposedDoc();
|
|
|
|
if (!doc || !doc->GetShell()) {
|
|
|
|
return emptyDeclarationBlock;
|
|
|
|
}
|
|
|
|
nsPresContext* presContext = doc->GetShell()->GetPresContext();
|
|
|
|
if (!presContext) {
|
|
|
|
return emptyDeclarationBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSSPseudoElementType pseudoType =
|
|
|
|
aPseudoTag
|
|
|
|
? nsCSSPseudoElements::GetPseudoType(
|
|
|
|
aPseudoTag,
|
|
|
|
nsCSSProps::EnabledState::eIgnoreEnabledState)
|
|
|
|
: CSSPseudoElementType::NotPseudo;
|
|
|
|
if (pseudoType != CSSPseudoElementType::NotPseudo &&
|
|
|
|
pseudoType != CSSPseudoElementType::before &&
|
|
|
|
pseudoType != CSSPseudoElementType::after) {
|
|
|
|
return emptyDeclarationBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
ServoAnimationRule* rule =
|
2017-01-24 10:33:10 +03:00
|
|
|
presContext->EffectCompositor()
|
|
|
|
->GetServoAnimationRule(aElement, pseudoType, aCascadeLevel);
|
2017-01-24 10:27:56 +03:00
|
|
|
if (!rule) {
|
|
|
|
return emptyDeclarationBlock;
|
|
|
|
}
|
|
|
|
return rule->GetValues();
|
|
|
|
}
|
|
|
|
|
2017-03-10 05:53:17 +03:00
|
|
|
bool
|
|
|
|
Gecko_StyleAnimationsEquals(RawGeckoStyleAnimationListBorrowed aA,
|
|
|
|
RawGeckoStyleAnimationListBorrowed aB)
|
|
|
|
{
|
|
|
|
return *aA == *aB;
|
|
|
|
}
|
|
|
|
|
2017-03-10 05:53:19 +03:00
|
|
|
void
|
|
|
|
Gecko_UpdateAnimations(RawGeckoElementBorrowed aElement,
|
|
|
|
nsIAtom* aPseudoTagOrNull,
|
2017-03-10 05:53:19 +03:00
|
|
|
ServoComputedValuesBorrowedOrNull aComputedValues,
|
2017-03-10 05:53:19 +03:00
|
|
|
ServoComputedValuesBorrowedOrNull aParentComputedValues)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aElement);
|
|
|
|
|
|
|
|
nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement);
|
|
|
|
if (!presContext) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (presContext->IsDynamic() && aElement->IsInComposedDoc()) {
|
|
|
|
presContext->AnimationManager()->
|
|
|
|
UpdateAnimations(const_cast<dom::Element*>(aElement), aPseudoTagOrNull,
|
|
|
|
aComputedValues, aParentComputedValues);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-10 05:53:19 +03:00
|
|
|
bool
|
|
|
|
Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElement,
|
|
|
|
nsIAtom* aPseudoTagOrNull)
|
|
|
|
{
|
|
|
|
if (aPseudoTagOrNull &&
|
|
|
|
aPseudoTagOrNull != nsGkAtoms::cssPseudoElementBeforeProperty &&
|
|
|
|
aPseudoTagOrNull != nsGkAtoms::cssPseudoElementAfterProperty) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSSPseudoElementType pseudoType =
|
|
|
|
nsCSSPseudoElements::GetPseudoType(aPseudoTagOrNull,
|
|
|
|
CSSEnabledState::eForAllContent);
|
|
|
|
nsAnimationManager::CSSAnimationCollection* collection =
|
|
|
|
nsAnimationManager::CSSAnimationCollection
|
|
|
|
::GetAnimationCollection(aElement, pseudoType);
|
|
|
|
|
|
|
|
return collection && !collection->mAnimations.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2016-08-22 16:01:41 +03:00
|
|
|
void
|
|
|
|
Gecko_FillAllBackgroundLists(nsStyleImageLayers* aLayers, uint32_t aMaxLen)
|
|
|
|
{
|
|
|
|
nsRuleNode::FillAllBackgroundLists(*aLayers, aMaxLen);
|
|
|
|
}
|
|
|
|
|
2016-09-06 13:20:30 +03:00
|
|
|
void
|
|
|
|
Gecko_FillAllMaskLists(nsStyleImageLayers* aLayers, uint32_t aMaxLen)
|
|
|
|
{
|
|
|
|
nsRuleNode::FillAllMaskLists(*aLayers, aMaxLen);
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
template <typename Implementor>
|
|
|
|
static nsIAtom*
|
|
|
|
AtomAttrValue(Implementor* aElement, nsIAtom* aName)
|
|
|
|
{
|
|
|
|
const nsAttrValue* attr = aElement->GetParsedAttr(aName);
|
|
|
|
return attr ? attr->GetAtomValue() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Implementor, typename MatchFn>
|
|
|
|
static bool
|
|
|
|
DoMatch(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, MatchFn aMatch)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
|
|
|
if (aNS) {
|
2016-06-28 17:24:48 +03:00
|
|
|
int32_t ns = nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNS,
|
|
|
|
aElement->IsInChromeDocument());
|
2016-06-30 23:37:52 +03:00
|
|
|
NS_ENSURE_TRUE(ns != kNameSpaceID_Unknown, false);
|
|
|
|
const nsAttrValue* value = aElement->GetParsedAttr(aName, ns);
|
|
|
|
return value && aMatch(value);
|
|
|
|
}
|
|
|
|
// No namespace means any namespace - we have to check them all. :-(
|
2016-07-23 00:11:41 +03:00
|
|
|
BorrowedAttrInfo attrInfo;
|
2016-07-22 05:43:38 +03:00
|
|
|
for (uint32_t i = 0; (attrInfo = aElement->GetAttrInfoAt(i)); ++i) {
|
|
|
|
if (attrInfo.mName->LocalName() != aName) {
|
2016-06-30 23:37:52 +03:00
|
|
|
continue;
|
|
|
|
}
|
2016-07-22 05:43:38 +03:00
|
|
|
if (aMatch(attrInfo.mValue)) {
|
2016-06-30 23:37:52 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
template <typename Implementor>
|
|
|
|
static bool
|
|
|
|
HasAttr(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
|
|
|
auto match = [](const nsAttrValue* aValue) { return true; };
|
|
|
|
return DoMatch(aElement, aNS, aName, match);
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
template <typename Implementor>
|
|
|
|
static bool
|
2016-07-19 00:53:45 +03:00
|
|
|
AttrEquals(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, nsIAtom* aStr,
|
2016-07-19 04:02:55 +03:00
|
|
|
bool aIgnoreCase)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
|
|
|
auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) {
|
|
|
|
return aValue->Equals(aStr, aIgnoreCase ? eIgnoreCase : eCaseMatters);
|
|
|
|
};
|
|
|
|
return DoMatch(aElement, aNS, aName, match);
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
template <typename Implementor>
|
|
|
|
static bool
|
|
|
|
AttrDashEquals(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
|
2016-07-19 00:53:45 +03:00
|
|
|
nsIAtom* aStr)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
|
|
|
auto match = [aStr](const nsAttrValue* aValue) {
|
|
|
|
nsAutoString str;
|
|
|
|
aValue->ToString(str);
|
|
|
|
const nsDefaultStringComparator c;
|
|
|
|
return nsStyleUtil::DashMatchCompare(str, nsDependentAtomString(aStr), c);
|
|
|
|
};
|
|
|
|
return DoMatch(aElement, aNS, aName, match);
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
template <typename Implementor>
|
|
|
|
static bool
|
|
|
|
AttrIncludes(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
|
2016-07-19 00:53:45 +03:00
|
|
|
nsIAtom* aStr)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
|
|
|
auto match = [aStr](const nsAttrValue* aValue) {
|
|
|
|
nsAutoString str;
|
|
|
|
aValue->ToString(str);
|
|
|
|
const nsDefaultStringComparator c;
|
|
|
|
return nsStyleUtil::ValueIncludes(str, nsDependentAtomString(aStr), c);
|
|
|
|
};
|
|
|
|
return DoMatch(aElement, aNS, aName, match);
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
template <typename Implementor>
|
|
|
|
static bool
|
|
|
|
AttrHasSubstring(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
|
2016-07-19 00:53:45 +03:00
|
|
|
nsIAtom* aStr)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
|
|
|
auto match = [aStr](const nsAttrValue* aValue) {
|
|
|
|
nsAutoString str;
|
|
|
|
aValue->ToString(str);
|
|
|
|
return FindInReadable(str, nsDependentAtomString(aStr));
|
|
|
|
};
|
|
|
|
return DoMatch(aElement, aNS, aName, match);
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
template <typename Implementor>
|
|
|
|
static bool
|
|
|
|
AttrHasPrefix(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
|
2016-07-19 00:53:45 +03:00
|
|
|
nsIAtom* aStr)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
|
|
|
auto match = [aStr](const nsAttrValue* aValue) {
|
|
|
|
nsAutoString str;
|
|
|
|
aValue->ToString(str);
|
|
|
|
return StringBeginsWith(str, nsDependentAtomString(aStr));
|
|
|
|
};
|
|
|
|
return DoMatch(aElement, aNS, aName, match);
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
template <typename Implementor>
|
|
|
|
static bool
|
|
|
|
AttrHasSuffix(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
|
2016-07-19 00:53:45 +03:00
|
|
|
nsIAtom* aStr)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
|
|
|
auto match = [aStr](const nsAttrValue* aValue) {
|
|
|
|
nsAutoString str;
|
|
|
|
aValue->ToString(str);
|
|
|
|
return StringEndsWith(str, nsDependentAtomString(aStr));
|
|
|
|
};
|
|
|
|
return DoMatch(aElement, aNS, aName, match);
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
/**
|
|
|
|
* Gets the class or class list (if any) of the implementor. The calling
|
|
|
|
* convention here is rather hairy, and is optimized for getting Servo the
|
|
|
|
* information it needs for hot calls.
|
|
|
|
*
|
|
|
|
* The return value indicates the number of classes. If zero, neither outparam
|
|
|
|
* is valid. If one, the class_ outparam is filled with the atom of the class.
|
|
|
|
* If two or more, the classList outparam is set to point to an array of atoms
|
|
|
|
* representing the class list.
|
|
|
|
*
|
|
|
|
* The array is borrowed and the atoms are not addrefed. These values can be
|
|
|
|
* invalidated by any DOM mutation. Use them in a tight scope.
|
|
|
|
*/
|
|
|
|
template <typename Implementor>
|
|
|
|
static uint32_t
|
|
|
|
ClassOrClassList(Implementor* aElement, nsIAtom** aClass, nsIAtom*** aClassList)
|
2016-05-25 21:16:26 +03:00
|
|
|
{
|
|
|
|
const nsAttrValue* attr = aElement->GetParsedAttr(nsGkAtoms::_class);
|
|
|
|
if (!attr) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// For class values with only whitespace, Gecko just stores a string. For the
|
|
|
|
// purposes of the style system, there is no class in this case.
|
|
|
|
if (attr->Type() == nsAttrValue::eString) {
|
|
|
|
MOZ_ASSERT(nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(
|
|
|
|
attr->GetStringValue()).IsEmpty());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Single tokens are generally stored as an atom. Check that case.
|
|
|
|
if (attr->Type() == nsAttrValue::eAtom) {
|
|
|
|
*aClass = attr->GetAtomValue();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// At this point we should have an atom array. It is likely, but not
|
|
|
|
// guaranteed, that we have two or more elements in the array.
|
|
|
|
MOZ_ASSERT(attr->Type() == nsAttrValue::eAtomArray);
|
|
|
|
nsTArray<nsCOMPtr<nsIAtom>>* atomArray = attr->GetAtomArrayValue();
|
|
|
|
uint32_t length = atomArray->Length();
|
|
|
|
|
|
|
|
// Special case: zero elements.
|
|
|
|
if (length == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special case: one element.
|
|
|
|
if (length == 1) {
|
|
|
|
*aClass = atomArray->ElementAt(0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// General case: Two or more elements.
|
|
|
|
//
|
|
|
|
// Note: We could also expose this array as an array of nsCOMPtrs, since
|
|
|
|
// bindgen knows what those look like, and eliminate the reinterpret_cast.
|
|
|
|
// But it's not obvious that that would be preferable.
|
|
|
|
static_assert(sizeof(nsCOMPtr<nsIAtom>) == sizeof(nsIAtom*), "Bad simplification");
|
|
|
|
static_assert(alignof(nsCOMPtr<nsIAtom>) == alignof(nsIAtom*), "Bad simplification");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAtom>* elements = atomArray->Elements();
|
|
|
|
nsIAtom** rawElements = reinterpret_cast<nsIAtom**>(elements);
|
|
|
|
*aClassList = rawElements;
|
|
|
|
return atomArray->Length();
|
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
#define SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \
|
2016-08-23 16:11:02 +03:00
|
|
|
nsIAtom* prefix_##AtomAttrValue(implementor_ aElement, nsIAtom* aName) \
|
2016-07-19 04:02:55 +03:00
|
|
|
{ \
|
|
|
|
return AtomAttrValue(aElement, aName); \
|
|
|
|
} \
|
2016-08-23 16:11:02 +03:00
|
|
|
bool prefix_##HasAttr(implementor_ aElement, nsIAtom* aNS, nsIAtom* aName) \
|
2016-07-19 04:02:55 +03:00
|
|
|
{ \
|
|
|
|
return HasAttr(aElement, aNS, aName); \
|
|
|
|
} \
|
2016-08-23 16:11:02 +03:00
|
|
|
bool prefix_##AttrEquals(implementor_ aElement, nsIAtom* aNS, \
|
2016-07-19 04:02:55 +03:00
|
|
|
nsIAtom* aName, nsIAtom* aStr, bool aIgnoreCase) \
|
|
|
|
{ \
|
|
|
|
return AttrEquals(aElement, aNS, aName, aStr, aIgnoreCase); \
|
|
|
|
} \
|
2016-08-23 16:11:02 +03:00
|
|
|
bool prefix_##AttrDashEquals(implementor_ aElement, nsIAtom* aNS, \
|
2016-07-19 04:02:55 +03:00
|
|
|
nsIAtom* aName, nsIAtom* aStr) \
|
|
|
|
{ \
|
|
|
|
return AttrDashEquals(aElement, aNS, aName, aStr); \
|
|
|
|
} \
|
2016-08-23 16:11:02 +03:00
|
|
|
bool prefix_##AttrIncludes(implementor_ aElement, nsIAtom* aNS, \
|
2016-07-19 04:02:55 +03:00
|
|
|
nsIAtom* aName, nsIAtom* aStr) \
|
|
|
|
{ \
|
|
|
|
return AttrIncludes(aElement, aNS, aName, aStr); \
|
|
|
|
} \
|
2016-08-23 16:11:02 +03:00
|
|
|
bool prefix_##AttrHasSubstring(implementor_ aElement, nsIAtom* aNS, \
|
2016-07-19 04:02:55 +03:00
|
|
|
nsIAtom* aName, nsIAtom* aStr) \
|
|
|
|
{ \
|
|
|
|
return AttrHasSubstring(aElement, aNS, aName, aStr); \
|
|
|
|
} \
|
2016-08-23 16:11:02 +03:00
|
|
|
bool prefix_##AttrHasPrefix(implementor_ aElement, nsIAtom* aNS, \
|
2016-07-19 04:02:55 +03:00
|
|
|
nsIAtom* aName, nsIAtom* aStr) \
|
|
|
|
{ \
|
|
|
|
return AttrHasPrefix(aElement, aNS, aName, aStr); \
|
|
|
|
} \
|
2016-08-23 16:11:02 +03:00
|
|
|
bool prefix_##AttrHasSuffix(implementor_ aElement, nsIAtom* aNS, \
|
2016-07-19 04:02:55 +03:00
|
|
|
nsIAtom* aName, nsIAtom* aStr) \
|
|
|
|
{ \
|
|
|
|
return AttrHasSuffix(aElement, aNS, aName, aStr); \
|
|
|
|
} \
|
2016-08-23 16:11:02 +03:00
|
|
|
uint32_t prefix_##ClassOrClassList(implementor_ aElement, nsIAtom** aClass, \
|
2016-07-19 04:02:55 +03:00
|
|
|
nsIAtom*** aClassList) \
|
|
|
|
{ \
|
|
|
|
return ClassOrClassList(aElement, aClass, aClassList); \
|
2016-06-24 06:35:12 +03:00
|
|
|
}
|
2016-07-19 04:02:55 +03:00
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_, RawGeckoElementBorrowed)
|
2016-11-02 09:11:24 +03:00
|
|
|
SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS(Gecko_Snapshot, const ServoElementSnapshot*)
|
2016-07-19 04:02:55 +03:00
|
|
|
|
|
|
|
#undef SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS
|
2016-06-24 06:35:12 +03:00
|
|
|
|
2016-05-18 22:05:36 +03:00
|
|
|
nsIAtom*
|
|
|
|
Gecko_Atomize(const char* aString, uint32_t aLength)
|
|
|
|
{
|
|
|
|
return NS_Atomize(nsDependentCSubstring(aString, aLength)).take();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_AddRefAtom(nsIAtom* aAtom)
|
|
|
|
{
|
|
|
|
NS_ADDREF(aAtom);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_ReleaseAtom(nsIAtom* aAtom)
|
|
|
|
{
|
|
|
|
NS_RELEASE(aAtom);
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint16_t*
|
|
|
|
Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength)
|
|
|
|
{
|
|
|
|
static_assert(sizeof(char16_t) == sizeof(uint16_t), "Servo doesn't know what a char16_t is");
|
|
|
|
MOZ_ASSERT(aAtom);
|
|
|
|
*aLength = aAtom->GetLength();
|
|
|
|
|
|
|
|
// We need to manually cast from char16ptr_t to const char16_t* to handle the
|
|
|
|
// MOZ_USE_CHAR16_WRAPPER we use on WIndows.
|
|
|
|
return reinterpret_cast<const uint16_t*>(static_cast<const char16_t*>(aAtom->GetUTF16String()));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength)
|
|
|
|
{
|
|
|
|
// XXXbholley: We should be able to do this without converting, I just can't
|
|
|
|
// find the right thing to call.
|
2016-10-04 11:16:50 +03:00
|
|
|
nsDependentAtomString atomStr(aAtom);
|
2016-05-19 09:54:58 +03:00
|
|
|
NS_ConvertUTF8toUTF16 inStr(nsDependentCSubstring(aString, aLength));
|
2016-05-18 22:05:36 +03:00
|
|
|
return atomStr.Equals(inStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength)
|
|
|
|
{
|
|
|
|
// XXXbholley: We should be able to do this without converting, I just can't
|
|
|
|
// find the right thing to call.
|
2016-10-04 11:16:50 +03:00
|
|
|
nsDependentAtomString atomStr(aAtom);
|
2016-05-19 09:54:58 +03:00
|
|
|
NS_ConvertUTF8toUTF16 inStr(nsDependentCSubstring(aString, aLength));
|
2016-05-18 22:05:36 +03:00
|
|
|
return nsContentUtils::EqualsIgnoreASCIICase(atomStr, inStr);
|
|
|
|
}
|
|
|
|
|
2016-06-07 22:13:24 +03:00
|
|
|
void
|
|
|
|
Gecko_FontFamilyList_Clear(FontFamilyList* aList) {
|
|
|
|
aList->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_FontFamilyList_AppendNamed(FontFamilyList* aList, nsIAtom* aName)
|
|
|
|
{
|
|
|
|
// Servo doesn't record whether the name was quoted or unquoted, so just
|
|
|
|
// assume unquoted for now.
|
|
|
|
FontFamilyName family;
|
|
|
|
aName->ToString(family.mName);
|
|
|
|
aList->Append(family);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_FontFamilyList_AppendGeneric(FontFamilyList* aList, FontFamilyType aType)
|
|
|
|
{
|
|
|
|
aList->Append(FontFamilyName(aType));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src)
|
|
|
|
{
|
|
|
|
dst->fontlist = src->fontlist;
|
|
|
|
}
|
|
|
|
|
2016-05-04 03:42:40 +03:00
|
|
|
void
|
|
|
|
Gecko_SetListStyleType(nsStyleList* style_struct, uint32_t type)
|
|
|
|
{
|
|
|
|
// Builtin counter styles are static and use no-op refcounting, and thus are
|
|
|
|
// safe to use off-main-thread.
|
|
|
|
style_struct->SetCounterStyle(CounterStyleManager::GetBuiltinStyle(type));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CopyListStyleTypeFrom(nsStyleList* dst, const nsStyleList* src)
|
|
|
|
{
|
|
|
|
dst->SetCounterStyle(src->GetCounterStyle());
|
|
|
|
}
|
|
|
|
|
2016-05-21 03:02:54 +03:00
|
|
|
NS_IMPL_HOLDER_FFI_REFCOUNTING(nsIPrincipal, Principal)
|
|
|
|
NS_IMPL_HOLDER_FFI_REFCOUNTING(nsIURI, URI)
|
|
|
|
|
2017-02-10 04:43:52 +03:00
|
|
|
already_AddRefed<css::URLValue>
|
|
|
|
ServoBundledURI::IntoCssUrl()
|
|
|
|
{
|
|
|
|
if (!mURLString) {
|
|
|
|
return nullptr;
|
2016-12-21 02:13:00 +03:00
|
|
|
}
|
|
|
|
|
2017-02-10 04:43:52 +03:00
|
|
|
MOZ_ASSERT(mBaseURI);
|
|
|
|
MOZ_ASSERT(mReferrer);
|
|
|
|
MOZ_ASSERT(mPrincipal);
|
2016-05-21 03:02:54 +03:00
|
|
|
|
|
|
|
nsString url;
|
2017-02-10 04:43:52 +03:00
|
|
|
nsDependentCSubstring urlString(reinterpret_cast<const char*>(mURLString),
|
|
|
|
mURLStringLength);
|
2016-05-21 03:02:54 +03:00
|
|
|
AppendUTF8toUTF16(urlString, url);
|
|
|
|
RefPtr<nsStringBuffer> urlBuffer = nsCSSValue::BufferFromString(url);
|
|
|
|
|
2017-02-10 04:43:52 +03:00
|
|
|
RefPtr<css::URLValue> urlValue = new css::URLValue(urlBuffer,
|
|
|
|
do_AddRef(mBaseURI),
|
|
|
|
do_AddRef(mReferrer),
|
|
|
|
do_AddRef(mPrincipal));
|
|
|
|
return urlValue.forget();
|
|
|
|
}
|
|
|
|
|
2017-02-23 04:19:04 +03:00
|
|
|
GeckoParserExtraData::GeckoParserExtraData(nsIURI* aBaseURI,
|
|
|
|
nsIURI* aReferrer,
|
|
|
|
nsIPrincipal* aPrincipal)
|
|
|
|
: mBaseURI(new ThreadSafeURIHolder(aBaseURI)),
|
|
|
|
mReferrer(new ThreadSafeURIHolder(aReferrer)),
|
|
|
|
mPrincipal(new ThreadSafePrincipalHolder(aPrincipal))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-05-27 01:18:09 +03:00
|
|
|
void
|
|
|
|
Gecko_SetNullImageValue(nsStyleImage* aImage)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage);
|
|
|
|
aImage->SetNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_SetGradientImageValue(nsStyleImage* aImage, nsStyleGradient* aGradient)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage);
|
|
|
|
aImage->SetGradientData(aGradient);
|
|
|
|
}
|
|
|
|
|
2016-11-03 04:40:53 +03:00
|
|
|
static already_AddRefed<nsStyleImageRequest>
|
|
|
|
CreateStyleImageRequest(nsStyleImageRequest::Mode aModeFlags,
|
2017-03-13 07:08:29 +03:00
|
|
|
ServoBundledURI aURI)
|
2016-11-02 11:58:32 +03:00
|
|
|
{
|
2017-03-13 07:08:29 +03:00
|
|
|
MOZ_ASSERT(aURI.mURLString);
|
|
|
|
MOZ_ASSERT(aURI.mBaseURI);
|
|
|
|
MOZ_ASSERT(aURI.mReferrer);
|
|
|
|
MOZ_ASSERT(aURI.mPrincipal);
|
2016-11-02 11:58:32 +03:00
|
|
|
|
|
|
|
nsString url;
|
2017-03-13 07:08:29 +03:00
|
|
|
nsDependentCSubstring urlString(reinterpret_cast<const char*>(aURI.mURLString),
|
|
|
|
aURI.mURLStringLength);
|
2016-11-02 11:58:32 +03:00
|
|
|
AppendUTF8toUTF16(urlString, url);
|
|
|
|
RefPtr<nsStringBuffer> urlBuffer = nsCSSValue::BufferFromString(url);
|
|
|
|
|
|
|
|
RefPtr<nsStyleImageRequest> req =
|
2017-03-13 07:08:29 +03:00
|
|
|
new nsStyleImageRequest(aModeFlags, urlBuffer, do_AddRef(aURI.mBaseURI),
|
|
|
|
do_AddRef(aURI.mReferrer), do_AddRef(aURI.mPrincipal));
|
2016-11-03 04:40:53 +03:00
|
|
|
return req.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-03-13 07:08:29 +03:00
|
|
|
Gecko_SetUrlImageValue(nsStyleImage* aImage, ServoBundledURI aURI)
|
2016-11-03 04:40:53 +03:00
|
|
|
{
|
|
|
|
RefPtr<nsStyleImageRequest> req =
|
2017-03-13 07:08:29 +03:00
|
|
|
CreateStyleImageRequest(nsStyleImageRequest::Mode::Track, aURI);
|
2016-11-02 11:58:32 +03:00
|
|
|
aImage->SetImageRequest(req.forget());
|
|
|
|
}
|
|
|
|
|
2016-05-27 01:18:09 +03:00
|
|
|
void
|
|
|
|
Gecko_CopyImageValueFrom(nsStyleImage* aImage, const nsStyleImage* aOther)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage);
|
|
|
|
MOZ_ASSERT(aOther);
|
|
|
|
|
|
|
|
*aImage = *aOther;
|
|
|
|
}
|
|
|
|
|
2016-11-21 09:34:17 +03:00
|
|
|
void
|
|
|
|
Gecko_SetCursorArrayLength(nsStyleUserInterface* aStyleUI, size_t aLen)
|
|
|
|
{
|
|
|
|
aStyleUI->mCursorImages.Clear();
|
|
|
|
aStyleUI->mCursorImages.SetLength(aLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-03-13 07:08:29 +03:00
|
|
|
Gecko_SetCursorImage(nsCursorImage* aCursor, ServoBundledURI aURI)
|
2016-11-21 09:34:17 +03:00
|
|
|
{
|
|
|
|
aCursor->mImage =
|
2017-03-13 07:08:29 +03:00
|
|
|
CreateStyleImageRequest(nsStyleImageRequest::Mode::Discard, aURI);
|
2016-11-21 09:34:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CopyCursorArrayFrom(nsStyleUserInterface* aDest,
|
|
|
|
const nsStyleUserInterface* aSrc)
|
|
|
|
{
|
|
|
|
aDest->mCursorImages = aSrc->mCursorImages;
|
|
|
|
}
|
|
|
|
|
2016-05-27 01:18:09 +03:00
|
|
|
nsStyleGradient*
|
|
|
|
Gecko_CreateGradient(uint8_t aShape,
|
|
|
|
uint8_t aSize,
|
|
|
|
bool aRepeating,
|
|
|
|
bool aLegacySyntax,
|
|
|
|
uint32_t aStopCount)
|
|
|
|
{
|
|
|
|
nsStyleGradient* result = new nsStyleGradient();
|
|
|
|
|
|
|
|
result->mShape = aShape;
|
|
|
|
result->mSize = aSize;
|
|
|
|
result->mRepeating = aRepeating;
|
|
|
|
result->mLegacySyntax = aLegacySyntax;
|
|
|
|
|
|
|
|
result->mAngle.SetNoneValue();
|
|
|
|
result->mBgPosX.SetNoneValue();
|
|
|
|
result->mBgPosY.SetNoneValue();
|
|
|
|
result->mRadiusX.SetNoneValue();
|
|
|
|
result->mRadiusY.SetNoneValue();
|
|
|
|
|
|
|
|
nsStyleGradientStop dummyStop;
|
|
|
|
dummyStop.mLocation.SetNoneValue();
|
|
|
|
dummyStop.mColor = NS_RGB(0, 0, 0);
|
|
|
|
dummyStop.mIsInterpolationHint = 0;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < aStopCount; i++) {
|
|
|
|
result->mStops.AppendElement(dummyStop);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-11-03 04:40:53 +03:00
|
|
|
void
|
|
|
|
Gecko_SetListStyleImageNone(nsStyleList* aList)
|
|
|
|
{
|
|
|
|
aList->mListStyleImage = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_SetListStyleImage(nsStyleList* aList,
|
2017-02-10 04:43:52 +03:00
|
|
|
ServoBundledURI aURI)
|
2016-11-03 04:40:53 +03:00
|
|
|
{
|
|
|
|
aList->mListStyleImage =
|
2017-03-13 07:08:29 +03:00
|
|
|
CreateStyleImageRequest(nsStyleImageRequest::Mode(0), aURI);
|
2016-11-03 04:40:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CopyListStyleImageFrom(nsStyleList* aList, const nsStyleList* aSource)
|
|
|
|
{
|
|
|
|
aList->mListStyleImage = aSource->mListStyleImage;
|
|
|
|
}
|
|
|
|
|
2016-07-14 11:59:37 +03:00
|
|
|
void
|
2016-07-15 18:26:48 +03:00
|
|
|
Gecko_EnsureTArrayCapacity(void* aArray, size_t aCapacity, size_t aElemSize)
|
|
|
|
{
|
2016-08-12 07:54:14 +03:00
|
|
|
auto base =
|
|
|
|
reinterpret_cast<nsTArray_base<nsTArrayInfallibleAllocator,
|
|
|
|
nsTArray_CopyWithMemutils>*>(aArray);
|
|
|
|
|
2016-07-14 11:59:37 +03:00
|
|
|
base->EnsureCapacity<nsTArrayInfallibleAllocator>(aCapacity, aElemSize);
|
|
|
|
}
|
|
|
|
|
2016-08-12 07:54:14 +03:00
|
|
|
void
|
|
|
|
Gecko_ClearPODTArray(void* aArray, size_t aElementSize, size_t aElementAlign)
|
|
|
|
{
|
|
|
|
auto base =
|
|
|
|
reinterpret_cast<nsTArray_base<nsTArrayInfallibleAllocator,
|
|
|
|
nsTArray_CopyWithMemutils>*>(aArray);
|
|
|
|
|
|
|
|
base->template ShiftData<nsTArrayInfallibleAllocator>(0, base->Length(), 0,
|
|
|
|
aElementSize, aElementAlign);
|
|
|
|
}
|
|
|
|
|
2016-08-12 05:01:52 +03:00
|
|
|
void
|
2017-01-28 02:05:16 +03:00
|
|
|
Gecko_ClearAndResizeStyleContents(nsStyleContent* aContent, uint32_t aHowMany)
|
2016-08-12 05:01:52 +03:00
|
|
|
{
|
2017-01-28 02:05:16 +03:00
|
|
|
aContent->AllocateContents(aHowMany);
|
2016-08-12 05:01:52 +03:00
|
|
|
}
|
|
|
|
|
2016-08-16 22:07:17 +03:00
|
|
|
void
|
|
|
|
Gecko_CopyStyleContentsFrom(nsStyleContent* aContent, const nsStyleContent* aOther)
|
|
|
|
{
|
|
|
|
uint32_t count = aOther->ContentCount();
|
|
|
|
|
|
|
|
aContent->AllocateContents(count);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < count; ++i) {
|
|
|
|
aContent->ContentAt(i) = aOther->ContentAt(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-15 18:26:48 +03:00
|
|
|
void
|
2016-10-11 12:55:15 +03:00
|
|
|
Gecko_EnsureImageLayersLength(nsStyleImageLayers* aLayers, size_t aLen,
|
|
|
|
nsStyleImageLayers::LayerType aLayerType)
|
2016-07-15 18:26:48 +03:00
|
|
|
{
|
2016-10-11 12:55:15 +03:00
|
|
|
size_t oldLength = aLayers->mLayers.Length();
|
|
|
|
|
2016-07-14 11:59:48 +03:00
|
|
|
aLayers->mLayers.EnsureLengthAtLeast(aLen);
|
|
|
|
|
2016-10-11 12:55:15 +03:00
|
|
|
for (size_t i = oldLength; i < aLen; ++i) {
|
|
|
|
aLayers->mLayers[i].Initialize(aLayerType);
|
|
|
|
}
|
2016-07-14 11:59:48 +03:00
|
|
|
}
|
|
|
|
|
2017-01-06 15:45:16 +03:00
|
|
|
void
|
|
|
|
Gecko_EnsureStyleAnimationArrayLength(void* aArray, size_t aLen)
|
|
|
|
{
|
|
|
|
auto base =
|
|
|
|
reinterpret_cast<nsStyleAutoArray<StyleAnimation>*>(aArray);
|
|
|
|
|
2017-01-31 11:09:18 +03:00
|
|
|
size_t oldLength = base->Length();
|
|
|
|
|
2017-01-06 15:45:16 +03:00
|
|
|
base->EnsureLengthAtLeast(aLen);
|
2017-01-31 11:09:18 +03:00
|
|
|
|
|
|
|
for (size_t i = oldLength; i < aLen; ++i) {
|
|
|
|
(*base)[i].SetInitialValues();
|
|
|
|
}
|
2017-01-06 15:45:16 +03:00
|
|
|
}
|
|
|
|
|
2017-03-03 02:35:33 +03:00
|
|
|
void
|
|
|
|
Gecko_EnsureStyleTransitionArrayLength(void* aArray, size_t aLen)
|
|
|
|
{
|
|
|
|
auto base =
|
|
|
|
reinterpret_cast<nsStyleAutoArray<StyleTransition>*>(aArray);
|
|
|
|
|
|
|
|
size_t oldLength = base->Length();
|
|
|
|
|
|
|
|
base->EnsureLengthAtLeast(aLen);
|
|
|
|
|
|
|
|
for (size_t i = oldLength; i < aLen; ++i) {
|
|
|
|
(*base)[i].SetInitialValues();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-29 06:58:39 +03:00
|
|
|
Keyframe*
|
|
|
|
Gecko_AnimationAppendKeyframe(RawGeckoKeyframeListBorrowedMut aKeyframes,
|
|
|
|
float aOffset,
|
|
|
|
const nsTimingFunction* aTimingFunction)
|
|
|
|
{
|
|
|
|
Keyframe* keyframe = aKeyframes->AppendElement();
|
|
|
|
keyframe->mOffset.emplace(aOffset);
|
|
|
|
if (aTimingFunction &&
|
|
|
|
aTimingFunction->mType != nsTimingFunction::Type::Linear) {
|
|
|
|
keyframe->mTimingFunction.emplace();
|
|
|
|
keyframe->mTimingFunction->Init(*aTimingFunction);
|
|
|
|
}
|
|
|
|
|
|
|
|
return keyframe;
|
|
|
|
}
|
|
|
|
|
2016-07-15 18:26:48 +03:00
|
|
|
void
|
|
|
|
Gecko_ResetStyleCoord(nsStyleUnit* aUnit, nsStyleUnion* aValue)
|
|
|
|
{
|
|
|
|
nsStyleCoord::Reset(*aUnit, *aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_SetStyleCoordCalcValue(nsStyleUnit* aUnit, nsStyleUnion* aValue, nsStyleCoord::CalcValue aCalc)
|
|
|
|
{
|
|
|
|
// Calc units should be cleaned up first
|
|
|
|
MOZ_ASSERT(*aUnit != nsStyleUnit::eStyleUnit_Calc);
|
|
|
|
nsStyleCoord::Calc* calcRef = new nsStyleCoord::Calc();
|
|
|
|
calcRef->mLength = aCalc.mLength;
|
|
|
|
calcRef->mPercent = aCalc.mPercent;
|
|
|
|
calcRef->mHasPercent = aCalc.mHasPercent;
|
|
|
|
*aUnit = nsStyleUnit::eStyleUnit_Calc;
|
|
|
|
aValue->mPointer = calcRef;
|
|
|
|
calcRef->AddRef();
|
|
|
|
}
|
|
|
|
|
2016-08-15 18:48:11 +03:00
|
|
|
void
|
2017-02-21 18:26:17 +03:00
|
|
|
Gecko_CopyClipPathValueFrom(mozilla::StyleShapeSource* aDst, const mozilla::StyleShapeSource* aSrc)
|
2016-08-15 18:48:11 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aDst);
|
|
|
|
MOZ_ASSERT(aSrc);
|
|
|
|
|
|
|
|
*aDst = *aSrc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-02-21 18:26:17 +03:00
|
|
|
Gecko_DestroyClipPath(mozilla::StyleShapeSource* aClip)
|
2016-08-15 18:48:11 +03:00
|
|
|
{
|
2017-02-21 18:26:17 +03:00
|
|
|
aClip->~StyleShapeSource();
|
2016-08-15 18:48:11 +03:00
|
|
|
}
|
|
|
|
|
2017-02-10 04:43:52 +03:00
|
|
|
void
|
2017-02-21 18:26:17 +03:00
|
|
|
Gecko_StyleClipPath_SetURLValue(mozilla::StyleShapeSource* aClip, ServoBundledURI aURI)
|
2017-02-10 04:43:52 +03:00
|
|
|
{
|
|
|
|
RefPtr<css::URLValue> url = aURI.IntoCssUrl();
|
|
|
|
aClip->SetURL(url.get());
|
|
|
|
}
|
|
|
|
|
2016-08-15 18:48:11 +03:00
|
|
|
mozilla::StyleBasicShape*
|
|
|
|
Gecko_NewBasicShape(mozilla::StyleBasicShapeType aType)
|
|
|
|
{
|
|
|
|
RefPtr<StyleBasicShape> ptr = new mozilla::StyleBasicShape(aType);
|
|
|
|
return ptr.forget().take();
|
|
|
|
}
|
|
|
|
|
2016-10-17 09:16:16 +03:00
|
|
|
void
|
|
|
|
Gecko_ResetFilters(nsStyleEffects* effects, size_t new_len)
|
|
|
|
{
|
|
|
|
effects->mFilters.Clear();
|
|
|
|
effects->mFilters.SetLength(new_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CopyFiltersFrom(nsStyleEffects* aSrc, nsStyleEffects* aDest)
|
|
|
|
{
|
|
|
|
aDest->mFilters = aSrc->mFilters;
|
|
|
|
}
|
|
|
|
|
2017-02-10 04:43:52 +03:00
|
|
|
void
|
|
|
|
Gecko_nsStyleFilter_SetURLValue(nsStyleFilter* aEffects, ServoBundledURI aURI)
|
|
|
|
{
|
|
|
|
RefPtr<css::URLValue> url = aURI.IntoCssUrl();
|
|
|
|
aEffects->SetURL(url.get());
|
|
|
|
}
|
|
|
|
|
2017-02-10 04:43:52 +03:00
|
|
|
void
|
|
|
|
Gecko_nsStyleSVGPaint_CopyFrom(nsStyleSVGPaint* aDest, const nsStyleSVGPaint* aSrc)
|
|
|
|
{
|
|
|
|
*aDest = *aSrc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_nsStyleSVGPaint_SetURLValue(nsStyleSVGPaint* aPaint, ServoBundledURI aURI)
|
|
|
|
{
|
|
|
|
RefPtr<css::URLValue> url = aURI.IntoCssUrl();
|
|
|
|
aPaint->SetPaintServer(url.get(), NS_RGB(0, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Gecko_nsStyleSVGPaint_Reset(nsStyleSVGPaint* aPaint)
|
|
|
|
{
|
|
|
|
aPaint->SetNone();
|
|
|
|
}
|
|
|
|
|
2017-02-10 04:43:52 +03:00
|
|
|
void
|
|
|
|
Gecko_nsStyleSVG_SetDashArrayLength(nsStyleSVG* aSvg, uint32_t aLen)
|
|
|
|
{
|
|
|
|
aSvg->mStrokeDasharray.Clear();
|
|
|
|
aSvg->mStrokeDasharray.SetLength(aLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_nsStyleSVG_CopyDashArray(nsStyleSVG* aDst, const nsStyleSVG* aSrc)
|
|
|
|
{
|
|
|
|
aDst->mStrokeDasharray = aSrc->mStrokeDasharray;
|
|
|
|
}
|
|
|
|
|
2017-02-10 04:43:52 +03:00
|
|
|
css::URLValue*
|
|
|
|
Gecko_NewURLValue(ServoBundledURI aURI)
|
|
|
|
{
|
|
|
|
RefPtr<css::URLValue> url = aURI.IntoCssUrl();
|
|
|
|
return url.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(css::URLValue, CSSURLValue);
|
|
|
|
|
2016-07-15 18:26:48 +03:00
|
|
|
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsStyleCoord::Calc, Calc);
|
|
|
|
|
2016-08-28 07:41:17 +03:00
|
|
|
nsCSSShadowArray*
|
|
|
|
Gecko_NewCSSShadowArray(uint32_t aLen)
|
|
|
|
{
|
|
|
|
RefPtr<nsCSSShadowArray> arr = new(aLen) nsCSSShadowArray(aLen);
|
|
|
|
return arr.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsCSSShadowArray, CSSShadowArray);
|
|
|
|
|
2016-10-13 14:45:01 +03:00
|
|
|
nsStyleQuoteValues*
|
|
|
|
Gecko_NewStyleQuoteValues(uint32_t aLen)
|
|
|
|
{
|
|
|
|
RefPtr<nsStyleQuoteValues> values = new nsStyleQuoteValues;
|
|
|
|
values->mQuotePairs.SetLength(aLen);
|
|
|
|
return values.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsStyleQuoteValues, QuoteValues);
|
|
|
|
|
2016-11-01 02:30:43 +03:00
|
|
|
nsCSSValueSharedList*
|
|
|
|
Gecko_NewCSSValueSharedList(uint32_t aLen)
|
|
|
|
{
|
|
|
|
RefPtr<nsCSSValueSharedList> list = new nsCSSValueSharedList;
|
|
|
|
if (aLen == 0) {
|
|
|
|
return list.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
list->mHead = new nsCSSValueList;
|
|
|
|
nsCSSValueList* cur = list->mHead;
|
|
|
|
for (uint32_t i = 0; i < aLen - 1; i++) {
|
|
|
|
cur->mNext = new nsCSSValueList;
|
|
|
|
cur = cur->mNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
return list.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetAbsoluteLength(nsCSSValueBorrowedMut aCSSValue, nscoord aLen)
|
|
|
|
{
|
2017-01-31 08:38:44 +03:00
|
|
|
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null || aCSSValue->IsLengthUnit());
|
|
|
|
// The call below could trigger refcounting if aCSSValue were a
|
|
|
|
// FontFamilyList, but we just asserted that it's not. So we can
|
|
|
|
// whitelist this for static analysis.
|
2016-11-01 02:30:43 +03:00
|
|
|
aCSSValue->SetIntegerCoordValue(aLen);
|
|
|
|
}
|
|
|
|
|
2017-02-03 08:41:29 +03:00
|
|
|
nscoord
|
|
|
|
Gecko_CSSValue_GetAbsoluteLength(nsCSSValueBorrowed aCSSValue)
|
|
|
|
{
|
|
|
|
// SetIntegerCoordValue() which is used in Gecko_CSSValue_SetAbsoluteLength()
|
|
|
|
// converts values by nsPresContext::AppUnitsToFloatCSSPixels() and stores
|
|
|
|
// values in eCSSUnit_Pixel unit. We need to convert the values back to app
|
|
|
|
// units by GetPixelLength().
|
|
|
|
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Pixel,
|
|
|
|
"The unit should be eCSSUnit_Pixel");
|
|
|
|
return aCSSValue->GetPixelLength();
|
|
|
|
}
|
|
|
|
|
2016-11-01 02:30:43 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetNumber(nsCSSValueBorrowedMut aCSSValue, float aNumber)
|
|
|
|
{
|
|
|
|
aCSSValue->SetFloatValue(aNumber, eCSSUnit_Number);
|
|
|
|
}
|
|
|
|
|
2017-02-03 08:41:29 +03:00
|
|
|
float
|
|
|
|
Gecko_CSSValue_GetNumber(nsCSSValueBorrowed aCSSValue)
|
|
|
|
{
|
|
|
|
return aCSSValue->GetFloatValue();
|
|
|
|
}
|
|
|
|
|
2016-11-01 02:30:43 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetKeyword(nsCSSValueBorrowedMut aCSSValue, nsCSSKeyword aKeyword)
|
|
|
|
{
|
2017-02-03 08:41:28 +03:00
|
|
|
aCSSValue->SetEnumValue(aKeyword);
|
2016-11-01 02:30:43 +03:00
|
|
|
}
|
|
|
|
|
2017-02-03 08:41:29 +03:00
|
|
|
nsCSSKeyword
|
|
|
|
Gecko_CSSValue_GetKeyword(nsCSSValueBorrowed aCSSValue)
|
|
|
|
{
|
|
|
|
return aCSSValue->GetKeywordValue();
|
|
|
|
}
|
|
|
|
|
2016-11-01 02:30:43 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut aCSSValue, float aPercent)
|
|
|
|
{
|
2017-02-03 08:41:28 +03:00
|
|
|
aCSSValue->SetPercentValue(aPercent);
|
2016-11-01 02:30:43 +03:00
|
|
|
}
|
|
|
|
|
2017-02-03 08:41:29 +03:00
|
|
|
float
|
|
|
|
Gecko_CSSValue_GetPercentage(nsCSSValueBorrowed aCSSValue)
|
|
|
|
{
|
|
|
|
return aCSSValue->GetPercentValue();
|
|
|
|
}
|
|
|
|
|
2016-11-01 02:30:43 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetAngle(nsCSSValueBorrowedMut aCSSValue, float aRadians)
|
|
|
|
{
|
|
|
|
aCSSValue->SetFloatValue(aRadians, eCSSUnit_Radian);
|
|
|
|
}
|
|
|
|
|
2017-02-03 08:41:29 +03:00
|
|
|
float
|
|
|
|
Gecko_CSSValue_GetAngle(nsCSSValueBorrowed aCSSValue)
|
|
|
|
{
|
|
|
|
// Unfortunately nsCSSValue.GetAngleValueInRadians() returns double,
|
|
|
|
// so we use GetAngleValue() instead.
|
|
|
|
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Radian,
|
|
|
|
"The unit should be eCSSUnit_Radian");
|
|
|
|
return aCSSValue->GetAngleValue();
|
|
|
|
}
|
|
|
|
|
2016-11-01 02:30:43 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut aCSSValue, nsStyleCoord::CalcValue aCalc)
|
|
|
|
{
|
|
|
|
aCSSValue->SetCalcValue(&aCalc);
|
|
|
|
}
|
|
|
|
|
2017-02-03 08:41:29 +03:00
|
|
|
nsStyleCoord::CalcValue
|
|
|
|
Gecko_CSSValue_GetCalc(nsCSSValueBorrowed aCSSValue)
|
|
|
|
{
|
|
|
|
return aCSSValue->GetCalcValue();
|
|
|
|
}
|
|
|
|
|
2016-11-01 02:30:43 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut aCSSValue, int32_t aLen)
|
|
|
|
{
|
|
|
|
nsCSSValue::Array* arr = nsCSSValue::Array::Create(aLen);
|
|
|
|
aCSSValue->SetArrayValue(arr, eCSSUnit_Function);
|
|
|
|
}
|
|
|
|
|
2017-02-18 02:15:55 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetString(nsCSSValueBorrowedMut aCSSValue, const nsString aString)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
|
|
|
|
aCSSValue->SetStringValue(aString, eCSSUnit_String);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetArray(nsCSSValueBorrowedMut aCSSValue, int32_t aLength)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
|
|
|
|
RefPtr<nsCSSValue::Array> array
|
|
|
|
= nsCSSValue::Array::Create(aLength);
|
|
|
|
aCSSValue->SetArrayValue(array, eCSSUnit_Array);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetURL(nsCSSValueBorrowedMut aCSSValue,
|
|
|
|
ServoBundledURI aURI)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
|
|
|
|
RefPtr<css::URLValue> url = aURI.IntoCssUrl();
|
|
|
|
aCSSValue->SetURLValue(url.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetLocal(nsCSSValueBorrowedMut aCSSValue, const nsString aFamily)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
|
|
|
|
aCSSValue->SetStringValue(aFamily, eCSSUnit_Local_Font);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetInteger(nsCSSValueBorrowedMut aCSSValue, int32_t aInteger)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null ||
|
|
|
|
aCSSValue->GetUnit() == eCSSUnit_Integer);
|
|
|
|
aCSSValue->SetIntValue(aInteger, eCSSUnit_Integer);
|
|
|
|
}
|
|
|
|
|
2016-11-01 02:30:43 +03:00
|
|
|
nsCSSValueBorrowedMut
|
|
|
|
Gecko_CSSValue_GetArrayItem(nsCSSValueBorrowedMut aCSSValue, int32_t aIndex)
|
|
|
|
{
|
|
|
|
return &aCSSValue->GetArrayValue()->Item(aIndex);
|
|
|
|
}
|
2017-02-03 08:41:29 +03:00
|
|
|
|
|
|
|
nsCSSValueBorrowed
|
|
|
|
Gecko_CSSValue_GetArrayItemConst(nsCSSValueBorrowed aCSSValue, int32_t aIndex)
|
|
|
|
{
|
|
|
|
return &aCSSValue->GetArrayValue()->Item(aIndex);
|
|
|
|
}
|
2016-11-01 02:30:43 +03:00
|
|
|
|
2017-01-10 03:05:18 +03:00
|
|
|
|
|
|
|
bool
|
|
|
|
Gecko_PropertyId_IsPrefEnabled(nsCSSPropertyID id)
|
|
|
|
{
|
|
|
|
return nsCSSProps::IsEnabled(id);
|
|
|
|
}
|
|
|
|
|
2017-01-15 19:07:38 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_Drop(nsCSSValueBorrowedMut aCSSValue)
|
|
|
|
{
|
|
|
|
aCSSValue->~nsCSSValue();
|
|
|
|
}
|
|
|
|
|
2017-02-13 03:02:29 +03:00
|
|
|
void
|
|
|
|
Gecko_nsStyleFont_SetLang(nsStyleFont* aFont, nsIAtom* aAtom)
|
|
|
|
{
|
|
|
|
already_AddRefed<nsIAtom> atom = already_AddRefed<nsIAtom>(aAtom);
|
|
|
|
aFont->mLanguage = atom;
|
|
|
|
aFont->mExplicitLanguage = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont, const nsStyleFont* aSource)
|
|
|
|
{
|
|
|
|
aFont->mLanguage = aSource->mLanguage;
|
|
|
|
}
|
|
|
|
|
2016-12-17 12:58:56 +03:00
|
|
|
void
|
|
|
|
Gecko_LoadStyleSheet(css::Loader* aLoader,
|
|
|
|
ServoStyleSheet* aParent,
|
2016-12-29 20:33:47 +03:00
|
|
|
RawServoImportRuleBorrowed aImportRule,
|
2016-12-17 12:58:56 +03:00
|
|
|
const uint8_t* aURLString,
|
|
|
|
uint32_t aURLStringLength,
|
|
|
|
const uint8_t* aMediaString,
|
|
|
|
uint32_t aMediaStringLength)
|
|
|
|
{
|
2017-01-31 08:33:41 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2016-12-17 12:58:56 +03:00
|
|
|
MOZ_ASSERT(aLoader, "Should've catched this before");
|
|
|
|
MOZ_ASSERT(aParent, "Only used for @import, so parent should exist!");
|
|
|
|
MOZ_ASSERT(aURLString, "Invalid URLs shouldn't be loaded!");
|
|
|
|
RefPtr<nsMediaList> media = new nsMediaList();
|
|
|
|
if (aMediaStringLength) {
|
|
|
|
MOZ_ASSERT(aMediaString);
|
|
|
|
// TODO(emilio, bug 1325878): This is not great, though this is going away
|
|
|
|
// soon anyway, when we can have a Servo-backed nsMediaList.
|
|
|
|
nsDependentCSubstring medium(reinterpret_cast<const char*>(aMediaString),
|
|
|
|
aMediaStringLength);
|
|
|
|
nsCSSParser mediumParser(aLoader);
|
|
|
|
mediumParser.ParseMediaList(
|
|
|
|
NS_ConvertUTF8toUTF16(medium), nullptr, 0, media);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDependentCSubstring urlSpec(reinterpret_cast<const char*>(aURLString),
|
|
|
|
aURLStringLength);
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
2017-01-03 13:35:15 +03:00
|
|
|
nsresult rv = NS_NewURI(getter_AddRefs(uri), urlSpec);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// Servo and Gecko have different ideas of what a valid URL is, so we might
|
|
|
|
// get in here with a URL string that NS_NewURI can't handle. If so,
|
|
|
|
// silently do nothing. Eventually we should be able to assert that the
|
|
|
|
// NS_NewURI succeeds, here.
|
|
|
|
return;
|
|
|
|
}
|
2016-12-17 12:58:56 +03:00
|
|
|
|
2016-12-29 20:33:47 +03:00
|
|
|
aLoader->LoadChildSheet(aParent, uri, media, nullptr, aImportRule, nullptr);
|
2016-12-17 12:58:56 +03:00
|
|
|
}
|
|
|
|
|
2017-01-15 01:33:40 +03:00
|
|
|
const nsMediaFeature*
|
|
|
|
Gecko_GetMediaFeatures()
|
|
|
|
{
|
|
|
|
return nsMediaFeatures::features;
|
|
|
|
}
|
|
|
|
|
2016-11-01 02:30:43 +03:00
|
|
|
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
|
|
|
|
|
2016-04-02 03:04:59 +03:00
|
|
|
#define STYLE_STRUCT(name, checkdata_cb) \
|
|
|
|
\
|
|
|
|
void \
|
2017-01-04 22:52:26 +03:00
|
|
|
Gecko_Construct_Default_nsStyle##name(nsStyle##name* ptr, \
|
|
|
|
const nsPresContext* pres_context) \
|
|
|
|
{ \
|
|
|
|
new (ptr) nsStyle##name(pres_context); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void \
|
2016-04-02 03:04:59 +03:00
|
|
|
Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, \
|
|
|
|
const nsStyle##name* other) \
|
|
|
|
{ \
|
|
|
|
new (ptr) nsStyle##name(*other); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void \
|
|
|
|
Gecko_Destroy_nsStyle##name(nsStyle##name* ptr) \
|
|
|
|
{ \
|
|
|
|
ptr->~nsStyle##name(); \
|
|
|
|
}
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
void
|
|
|
|
Gecko_Construct_nsStyleVariables(nsStyleVariables* ptr)
|
|
|
|
{
|
|
|
|
new (ptr) nsStyleVariables();
|
|
|
|
}
|
|
|
|
|
2016-04-02 03:04:59 +03:00
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
|
|
|
|
#undef STYLE_STRUCT
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
#ifndef MOZ_STYLO
|
2016-08-19 14:44:43 +03:00
|
|
|
#define SERVO_BINDING_FUNC(name_, return_, ...) \
|
|
|
|
return_ name_(__VA_ARGS__) { \
|
|
|
|
MOZ_CRASH("stylo: shouldn't be calling " #name_ "in a non-stylo build"); \
|
|
|
|
}
|
|
|
|
#include "ServoBindingList.h"
|
|
|
|
#undef SERVO_BINDING_FUNC
|
2016-04-27 05:34:49 +03:00
|
|
|
#endif
|