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"
|
2017-07-11 00:52:00 +03:00
|
|
|
#include "ErrorReporter.h"
|
2017-04-07 17:44:41 +03:00
|
|
|
#include "GeckoProfiler.h"
|
2016-06-07 22:13:24 +03:00
|
|
|
#include "gfxFontFamilyList.h"
|
2017-08-24 04:05:53 +03:00
|
|
|
#include "gfxFontFeatures.h"
|
2017-03-10 05:53:19 +03:00
|
|
|
#include "nsAnimationManager.h"
|
2016-05-25 21:16:26 +03:00
|
|
|
#include "nsAttrValueInlines.h"
|
2017-05-15 07:18:44 +03:00
|
|
|
#include "nsCSSCounterStyleRule.h"
|
2017-05-19 09:12:34 +03:00
|
|
|
#include "nsCSSFontFaceRule.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"
|
2017-05-19 09:12:34 +03:00
|
|
|
#include "nsCSSRules.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
#include "nsContentUtils.h"
|
2016-05-25 21:16:26 +03:00
|
|
|
#include "nsDOMTokenList.h"
|
2017-05-19 09:12:34 +03:00
|
|
|
#include "nsDeviceContext.h"
|
2016-08-12 07:28:40 +03:00
|
|
|
#include "nsIContentInlines.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
#include "nsIDOMNode.h"
|
2017-03-26 23:53:34 +03:00
|
|
|
#include "nsIDocumentInlines.h"
|
2017-07-23 18:37:46 +03:00
|
|
|
#include "nsILoadContext.h"
|
2016-08-12 05:01:52 +03:00
|
|
|
#include "nsIFrame.h"
|
2017-09-01 10:25:52 +03:00
|
|
|
#include "nsIMemoryReporter.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-04-18 19:59:43 +03:00
|
|
|
#include "nsIURI.h"
|
2017-08-17 19:24:28 +03:00
|
|
|
#include "nsIXULRuntime.h"
|
2017-04-08 01:49:44 +03:00
|
|
|
#include "nsFontMetrics.h"
|
2017-06-01 21:37:02 +03:00
|
|
|
#include "nsHTMLStyleSheet.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"
|
2017-03-27 14:49:21 +03:00
|
|
|
#include "nsSVGElement.h"
|
2016-07-19 04:02:55 +03:00
|
|
|
#include "nsTArray.h"
|
2017-04-12 11:33:44 +03:00
|
|
|
#include "nsTransitionManager.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
|
2017-04-10 06:17:51 +03:00
|
|
|
#include "mozilla/DeclarationBlockInlines.h"
|
2017-01-24 10:27:56 +03:00
|
|
|
#include "mozilla/EffectCompositor.h"
|
2017-03-27 13:42:59 +03:00
|
|
|
#include "mozilla/EffectSet.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
#include "mozilla/EventStates.h"
|
2017-06-11 08:27:45 +03:00
|
|
|
#include "mozilla/GeckoStyleContext.h"
|
2017-01-29 06:58:39 +03:00
|
|
|
#include "mozilla/Keyframe.h"
|
2017-04-08 01:49:44 +03:00
|
|
|
#include "mozilla/Mutex.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"
|
2017-07-19 03:30:53 +03:00
|
|
|
#include "mozilla/SizeOfState.h"
|
2016-11-01 02:30:43 +03:00
|
|
|
#include "mozilla/StyleAnimationValue.h"
|
2017-03-14 16:34:57 +03:00
|
|
|
#include "mozilla/SystemGroup.h"
|
2017-04-10 06:17:51 +03:00
|
|
|
#include "mozilla/ServoMediaList.h"
|
2017-05-26 01:04:13 +03:00
|
|
|
#include "mozilla/RWLock.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"
|
2017-03-26 23:53:34 +03:00
|
|
|
#include "mozilla/dom/HTMLTableCellElement.h"
|
2017-03-26 23:53:34 +03:00
|
|
|
#include "mozilla/dom/HTMLBodyElement.h"
|
2017-03-16 00:49:35 +03:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2017-04-08 01:49:44 +03:00
|
|
|
#include "mozilla/URLExtraData.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
|
2017-05-10 15:31:51 +03:00
|
|
|
#if defined(MOZ_MEMORY)
|
|
|
|
# include "mozmemory.h"
|
|
|
|
#endif
|
|
|
|
|
2016-08-12 05:01:52 +03:00
|
|
|
using namespace mozilla;
|
2017-07-11 00:52:00 +03:00
|
|
|
using namespace mozilla::css;
|
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"
|
2017-07-17 21:42:00 +03:00
|
|
|
SERVO_ARC_TYPE(StyleContext, ServoStyleContext)
|
2016-11-23 03:35:55 +03:00
|
|
|
#undef SERVO_ARC_TYPE
|
2016-08-16 08:08:46 +03:00
|
|
|
|
2017-04-19 18:04:38 +03:00
|
|
|
static Mutex* sServoFontMetricsLock = nullptr;
|
2017-08-19 01:56:01 +03:00
|
|
|
static Mutex* sServoWidgetLock = nullptr;
|
2017-05-26 01:04:13 +03:00
|
|
|
static RWLock* sServoLangFontPrefsLock = nullptr;
|
|
|
|
|
|
|
|
static
|
|
|
|
const nsFont*
|
2017-06-07 03:09:08 +03:00
|
|
|
ThreadSafeGetDefaultFontHelper(const nsPresContext* aPresContext,
|
|
|
|
nsIAtom* aLanguage, uint8_t aGenericId)
|
2017-05-26 01:04:13 +03:00
|
|
|
{
|
|
|
|
bool needsCache = false;
|
|
|
|
const nsFont* retval;
|
|
|
|
|
|
|
|
{
|
|
|
|
AutoReadLock guard(*sServoLangFontPrefsLock);
|
2017-06-07 03:09:08 +03:00
|
|
|
retval = aPresContext->GetDefaultFont(aGenericId, aLanguage, &needsCache);
|
2017-05-26 01:04:13 +03:00
|
|
|
}
|
|
|
|
if (!needsCache) {
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
AutoWriteLock guard(*sServoLangFontPrefsLock);
|
2017-06-07 03:09:08 +03:00
|
|
|
retval = aPresContext->GetDefaultFont(aGenericId, aLanguage, nullptr);
|
2017-05-26 01:04:13 +03:00
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AssertIsMainThreadOrServoLangFontPrefsCacheLocked()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread() || sServoLangFontPrefsLock->LockedForWritingByCurrentThread());
|
|
|
|
}
|
2017-04-19 18:04:38 +03:00
|
|
|
|
2016-12-29 10:04:32 +03:00
|
|
|
bool
|
|
|
|
Gecko_IsInDocument(RawGeckoNodeBorrowed aNode)
|
|
|
|
{
|
|
|
|
return aNode->IsInComposedDoc();
|
|
|
|
}
|
|
|
|
|
Bug 1353810 - add a --enable-rust-debug option; r=chmanchester
For people working on Rust code, compiling in debug mode (Cargo's "dev"
profile) is convenient: debug assertions are turned on, optimization is
turned off, and parallel compilation inside of rustc itself can be
used. These things make the build faster and the debugging experience
more pleasant.
To obtain that currently, one needs to --enable-debug at the Gecko
toplevel, which turns on debug assertions for the entire browser, which
makes things run unreasonably slowly. So it would be desirable to be
able to turn *off* debug mode for the entirety of the browser, but turn
on debug mode for the Rust code only.
Hence this added switch, --enable-rust-debug, which does what it
suggests and defaults to the value of --enable-debug. For our own
sanity and because we judge it a non-existent use case, we do not
support --enable-debug --disable-rust-debug.
2017-04-13 04:49:25 +03:00
|
|
|
#ifdef MOZ_DEBUG_RUST
|
2017-02-01 23:37:00 +03:00
|
|
|
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
|
|
|
|
|
2017-03-22 19:18:34 +03:00
|
|
|
/*
|
|
|
|
* Does this child count as significant for selector matching?
|
|
|
|
*
|
|
|
|
* See nsStyleUtil::IsSignificantChild for details.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
Gecko_IsSignificantChild(RawGeckoNodeBorrowed aNode, bool aTextIsSignificant,
|
|
|
|
bool aWhitespaceIsSignificant)
|
|
|
|
{
|
|
|
|
return nsStyleUtil::ThreadSafeIsSignificantChild(aNode->AsContent(),
|
|
|
|
aTextIsSignificant,
|
|
|
|
aWhitespaceIsSignificant);
|
|
|
|
}
|
|
|
|
|
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
|
2017-06-20 11:08:10 +03:00
|
|
|
Gecko_GetFlattenedTreeParentNode(RawGeckoNodeBorrowed aNode)
|
2015-11-25 04:14:39 +03:00
|
|
|
{
|
2017-06-20 11:08:10 +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
|
|
|
}
|
|
|
|
|
2017-06-18 20:39:57 +03:00
|
|
|
RawGeckoElementBorrowedOrNull
|
|
|
|
Gecko_GetBeforeOrAfterPseudo(RawGeckoElementBorrowed aElement, bool aIsBefore)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aElement);
|
|
|
|
MOZ_ASSERT(aElement->HasProperties());
|
|
|
|
|
|
|
|
return aIsBefore
|
|
|
|
? nsLayoutUtils::GetBeforePseudo(aElement)
|
|
|
|
: nsLayoutUtils::GetAfterPseudo(aElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<nsIContent*>*
|
|
|
|
Gecko_GetAnonymousContentForElement(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
nsIAnonymousContentCreator* ac = do_QueryFrame(aElement->GetPrimaryFrame());
|
|
|
|
if (!ac) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* array = new nsTArray<nsIContent*>();
|
|
|
|
nsContentUtils::AppendNativeAnonymousChildren(aElement, *array, 0);
|
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* aAnonContent)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aAnonContent);
|
|
|
|
delete aAnonContent;
|
|
|
|
}
|
|
|
|
|
2017-07-17 21:42:00 +03:00
|
|
|
void
|
2017-07-21 06:42:42 +03:00
|
|
|
Gecko_ServoStyleContext_Init(
|
|
|
|
ServoStyleContext* aContext,
|
|
|
|
const ServoStyleContext* aParentContext,
|
|
|
|
RawGeckoPresContextBorrowed aPresContext,
|
2017-07-21 07:44:02 +03:00
|
|
|
const ServoComputedData* aValues,
|
2017-07-21 06:42:42 +03:00
|
|
|
mozilla::CSSPseudoElementType aPseudoType,
|
|
|
|
nsIAtom* aPseudoTag)
|
2017-07-17 21:42:00 +03:00
|
|
|
{
|
2017-07-31 17:21:40 +03:00
|
|
|
auto* presContext = const_cast<nsPresContext*>(aPresContext);
|
2017-07-21 06:42:42 +03:00
|
|
|
new (KnownNotNull, aContext) ServoStyleContext(
|
2017-07-31 17:21:40 +03:00
|
|
|
presContext, aPseudoTag, aPseudoType,
|
2017-07-21 07:44:02 +03:00
|
|
|
ServoComputedDataForgotten(aValues));
|
2017-07-17 21:42:08 +03:00
|
|
|
}
|
|
|
|
|
2017-07-21 07:44:02 +03:00
|
|
|
ServoComputedData::ServoComputedData(
|
|
|
|
const ServoComputedDataForgotten aValue)
|
2017-07-21 06:42:42 +03:00
|
|
|
{
|
2017-07-17 21:42:08 +03:00
|
|
|
PodAssign(this, aValue.mPtr);
|
2017-07-17 21:42:00 +03:00
|
|
|
}
|
|
|
|
|
2017-07-21 07:44:02 +03:00
|
|
|
const nsStyleVariables*
|
|
|
|
ServoComputedData::GetStyleVariables() const
|
2017-07-17 21:42:12 +03:00
|
|
|
{
|
2017-07-27 12:33:29 +03:00
|
|
|
MOZ_CRASH("ServoComputedData::GetStyleVariables should never need to be "
|
|
|
|
"called");
|
2017-07-17 21:42:12 +03:00
|
|
|
}
|
|
|
|
|
2017-09-01 10:25:52 +03:00
|
|
|
MOZ_DEFINE_MALLOC_ENCLOSING_SIZE_OF(ServoStyleStructsMallocEnclosingSizeOf)
|
Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.
Here is an example of the output.
> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │ ├──12,772,544 B (12.26%) -- layout
> │ │ ├───4,483,744 B (04.30%) -- frames
> │ │ │ ├──1,653,552 B (01.59%) ── nsInlineFrame
> │ │ │ ├──1,415,760 B (01.36%) ── nsTextFrame
> │ │ │ ├────431,376 B (00.41%) ── nsBlockFrame
> │ │ │ ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │ │ │ ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │ │ │ ├────156,408 B (00.15%) ── nsBulletFrame
> │ │ │ ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │ │ │ ├─────27,656 B (00.03%) ── sundries
> │ │ │ ├─────23,520 B (00.02%) ── nsTableCellFrame
> │ │ │ ├─────16,704 B (00.02%) ── nsImageFrame
> │ │ │ ├─────15,488 B (00.01%) ── nsTableRowFrame
> │ │ │ ├─────13,776 B (00.01%) ── nsTableColFrame
> │ │ │ └─────13,376 B (00.01%) ── nsTableFrame
> │ │ ├───3,412,192 B (03.28%) -- servo-style-structs
> │ │ │ ├──1,288,224 B (01.24%) ── Display
> │ │ │ ├────742,400 B (00.71%) ── Position
> │ │ │ ├────308,736 B (00.30%) ── Font
> │ │ │ ├────226,512 B (00.22%) ── Background
> │ │ │ ├────218,304 B (00.21%) ── TextReset
> │ │ │ ├────214,896 B (00.21%) ── Text
> │ │ │ ├────130,560 B (00.13%) ── Border
> │ │ │ ├─────81,408 B (00.08%) ── UIReset
> │ │ │ ├─────61,440 B (00.06%) ── Padding
> │ │ │ ├─────38,176 B (00.04%) ── UserInterface
> │ │ │ ├─────29,232 B (00.03%) ── Margin
> │ │ │ ├─────21,824 B (00.02%) ── sundries
> │ │ │ ├─────20,080 B (00.02%) ── Color
> │ │ │ ├─────20,080 B (00.02%) ── Column
> │ │ │ └─────10,320 B (00.01%) ── Effects
> │ │ ├───2,227,680 B (02.14%) -- computed-values
> │ │ │ ├──1,182,928 B (01.14%) ── non-dom
> │ │ │ └──1,044,752 B (01.00%) ── dom
> │ │ ├───1,500,016 B (01.44%) ── text-runs
> │ │ ├─────492,640 B (00.47%) ── line-boxes
> │ │ ├─────326,688 B (00.31%) ── frame-properties
> │ │ ├─────301,760 B (00.29%) ── pres-shell
> │ │ ├──────27,648 B (00.03%) ── pres-contexts
> │ │ └─────────176 B (00.00%) ── style-sets
The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.
Other notable things done by the patch are as follows.
- It significantly changes the signatures of the methods measuring nsINode and
its subclasses, in order to handle the tallying of style structs separately
from element-nodes. Likewise for nsIFrame.
- It renames the 'layout/style-structs' sub-tree as
'layout/gecko-style-structs', to clearly distinguish it from the new
'layout/servo-style-structs' sub-tree.
- It adds some FFI functions to access various Rust-side data structures from
C++ code.
- There is a nasty hack used twice to measure Arcs, by stepping backwards from
an interior pointer to a base pointer. It works, but I want to replace it
with something better eventually. The "XXX WARNING" comments have details.
- It makes DMD print a line to the console if it sees a pointer it doesn't
recognise. This is useful for detecting when we are measuring an interior
pointer instead of a base pointer, which is bad but easy to do when Arcs are
involved.
- It removes the Rust code for measuring CVs, because it's now all done on the
C++ side.
MozReview-Commit-ID: BKebACLKtCi
--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 09:37:33 +03:00
|
|
|
|
|
|
|
void
|
2017-08-25 07:47:54 +03:00
|
|
|
ServoComputedData::AddSizeOfExcludingThis(nsWindowSizes& aSizes) const
|
Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.
Here is an example of the output.
> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │ ├──12,772,544 B (12.26%) -- layout
> │ │ ├───4,483,744 B (04.30%) -- frames
> │ │ │ ├──1,653,552 B (01.59%) ── nsInlineFrame
> │ │ │ ├──1,415,760 B (01.36%) ── nsTextFrame
> │ │ │ ├────431,376 B (00.41%) ── nsBlockFrame
> │ │ │ ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │ │ │ ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │ │ │ ├────156,408 B (00.15%) ── nsBulletFrame
> │ │ │ ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │ │ │ ├─────27,656 B (00.03%) ── sundries
> │ │ │ ├─────23,520 B (00.02%) ── nsTableCellFrame
> │ │ │ ├─────16,704 B (00.02%) ── nsImageFrame
> │ │ │ ├─────15,488 B (00.01%) ── nsTableRowFrame
> │ │ │ ├─────13,776 B (00.01%) ── nsTableColFrame
> │ │ │ └─────13,376 B (00.01%) ── nsTableFrame
> │ │ ├───3,412,192 B (03.28%) -- servo-style-structs
> │ │ │ ├──1,288,224 B (01.24%) ── Display
> │ │ │ ├────742,400 B (00.71%) ── Position
> │ │ │ ├────308,736 B (00.30%) ── Font
> │ │ │ ├────226,512 B (00.22%) ── Background
> │ │ │ ├────218,304 B (00.21%) ── TextReset
> │ │ │ ├────214,896 B (00.21%) ── Text
> │ │ │ ├────130,560 B (00.13%) ── Border
> │ │ │ ├─────81,408 B (00.08%) ── UIReset
> │ │ │ ├─────61,440 B (00.06%) ── Padding
> │ │ │ ├─────38,176 B (00.04%) ── UserInterface
> │ │ │ ├─────29,232 B (00.03%) ── Margin
> │ │ │ ├─────21,824 B (00.02%) ── sundries
> │ │ │ ├─────20,080 B (00.02%) ── Color
> │ │ │ ├─────20,080 B (00.02%) ── Column
> │ │ │ └─────10,320 B (00.01%) ── Effects
> │ │ ├───2,227,680 B (02.14%) -- computed-values
> │ │ │ ├──1,182,928 B (01.14%) ── non-dom
> │ │ │ └──1,044,752 B (01.00%) ── dom
> │ │ ├───1,500,016 B (01.44%) ── text-runs
> │ │ ├─────492,640 B (00.47%) ── line-boxes
> │ │ ├─────326,688 B (00.31%) ── frame-properties
> │ │ ├─────301,760 B (00.29%) ── pres-shell
> │ │ ├──────27,648 B (00.03%) ── pres-contexts
> │ │ └─────────176 B (00.00%) ── style-sets
The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.
Other notable things done by the patch are as follows.
- It significantly changes the signatures of the methods measuring nsINode and
its subclasses, in order to handle the tallying of style structs separately
from element-nodes. Likewise for nsIFrame.
- It renames the 'layout/style-structs' sub-tree as
'layout/gecko-style-structs', to clearly distinguish it from the new
'layout/servo-style-structs' sub-tree.
- It adds some FFI functions to access various Rust-side data structures from
C++ code.
- There is a nasty hack used twice to measure Arcs, by stepping backwards from
an interior pointer to a base pointer. It works, but I want to replace it
with something better eventually. The "XXX WARNING" comments have details.
- It makes DMD print a line to the console if it sees a pointer it doesn't
recognise. This is useful for detecting when we are measuring an interior
pointer instead of a base pointer, which is bad but easy to do when Arcs are
involved.
- It removes the Rust code for measuring CVs, because it's now all done on the
C++ side.
MozReview-Commit-ID: BKebACLKtCi
--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 09:37:33 +03:00
|
|
|
{
|
2017-09-01 10:25:52 +03:00
|
|
|
// Note: GetStyleFoo() returns a pointer to an nsStyleFoo that sits within a
|
|
|
|
// servo_arc::Arc, i.e. it is preceded by a word-sized refcount. So we need
|
|
|
|
// to measure it with a function that can handle an interior pointer. We use
|
|
|
|
// ServoStyleStructsEnclosingMallocSizeOf to clearly identify in DMD's
|
|
|
|
// output the memory measured here.
|
Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.
Here is an example of the output.
> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │ ├──12,772,544 B (12.26%) -- layout
> │ │ ├───4,483,744 B (04.30%) -- frames
> │ │ │ ├──1,653,552 B (01.59%) ── nsInlineFrame
> │ │ │ ├──1,415,760 B (01.36%) ── nsTextFrame
> │ │ │ ├────431,376 B (00.41%) ── nsBlockFrame
> │ │ │ ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │ │ │ ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │ │ │ ├────156,408 B (00.15%) ── nsBulletFrame
> │ │ │ ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │ │ │ ├─────27,656 B (00.03%) ── sundries
> │ │ │ ├─────23,520 B (00.02%) ── nsTableCellFrame
> │ │ │ ├─────16,704 B (00.02%) ── nsImageFrame
> │ │ │ ├─────15,488 B (00.01%) ── nsTableRowFrame
> │ │ │ ├─────13,776 B (00.01%) ── nsTableColFrame
> │ │ │ └─────13,376 B (00.01%) ── nsTableFrame
> │ │ ├───3,412,192 B (03.28%) -- servo-style-structs
> │ │ │ ├──1,288,224 B (01.24%) ── Display
> │ │ │ ├────742,400 B (00.71%) ── Position
> │ │ │ ├────308,736 B (00.30%) ── Font
> │ │ │ ├────226,512 B (00.22%) ── Background
> │ │ │ ├────218,304 B (00.21%) ── TextReset
> │ │ │ ├────214,896 B (00.21%) ── Text
> │ │ │ ├────130,560 B (00.13%) ── Border
> │ │ │ ├─────81,408 B (00.08%) ── UIReset
> │ │ │ ├─────61,440 B (00.06%) ── Padding
> │ │ │ ├─────38,176 B (00.04%) ── UserInterface
> │ │ │ ├─────29,232 B (00.03%) ── Margin
> │ │ │ ├─────21,824 B (00.02%) ── sundries
> │ │ │ ├─────20,080 B (00.02%) ── Color
> │ │ │ ├─────20,080 B (00.02%) ── Column
> │ │ │ └─────10,320 B (00.01%) ── Effects
> │ │ ├───2,227,680 B (02.14%) -- computed-values
> │ │ │ ├──1,182,928 B (01.14%) ── non-dom
> │ │ │ └──1,044,752 B (01.00%) ── dom
> │ │ ├───1,500,016 B (01.44%) ── text-runs
> │ │ ├─────492,640 B (00.47%) ── line-boxes
> │ │ ├─────326,688 B (00.31%) ── frame-properties
> │ │ ├─────301,760 B (00.29%) ── pres-shell
> │ │ ├──────27,648 B (00.03%) ── pres-contexts
> │ │ └─────────176 B (00.00%) ── style-sets
The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.
Other notable things done by the patch are as follows.
- It significantly changes the signatures of the methods measuring nsINode and
its subclasses, in order to handle the tallying of style structs separately
from element-nodes. Likewise for nsIFrame.
- It renames the 'layout/style-structs' sub-tree as
'layout/gecko-style-structs', to clearly distinguish it from the new
'layout/servo-style-structs' sub-tree.
- It adds some FFI functions to access various Rust-side data structures from
C++ code.
- There is a nasty hack used twice to measure Arcs, by stepping backwards from
an interior pointer to a base pointer. It works, but I want to replace it
with something better eventually. The "XXX WARNING" comments have details.
- It makes DMD print a line to the console if it sees a pointer it doesn't
recognise. This is useful for detecting when we are measuring an interior
pointer instead of a base pointer, which is bad but easy to do when Arcs are
involved.
- It removes the Rust code for measuring CVs, because it's now all done on the
C++ side.
MozReview-Commit-ID: BKebACLKtCi
--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 09:37:33 +03:00
|
|
|
#define STYLE_STRUCT(name_, cb_) \
|
|
|
|
static_assert(alignof(nsStyle##name_) <= sizeof(size_t), \
|
|
|
|
"alignment will break AddSizeOfExcludingThis()"); \
|
2017-09-01 10:25:52 +03:00
|
|
|
const void* p##name_ = GetStyle##name_(); \
|
2017-08-25 07:47:54 +03:00
|
|
|
if (!aSizes.mState.HaveSeenPtr(p##name_)) { \
|
2017-08-25 07:59:44 +03:00
|
|
|
aSizes.mServoStyleSizes.NS_STYLE_SIZES_FIELD(name_) += \
|
2017-09-01 10:25:52 +03:00
|
|
|
ServoStyleStructsMallocEnclosingSizeOf(p##name_); \
|
Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.
Here is an example of the output.
> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │ ├──12,772,544 B (12.26%) -- layout
> │ │ ├───4,483,744 B (04.30%) -- frames
> │ │ │ ├──1,653,552 B (01.59%) ── nsInlineFrame
> │ │ │ ├──1,415,760 B (01.36%) ── nsTextFrame
> │ │ │ ├────431,376 B (00.41%) ── nsBlockFrame
> │ │ │ ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │ │ │ ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │ │ │ ├────156,408 B (00.15%) ── nsBulletFrame
> │ │ │ ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │ │ │ ├─────27,656 B (00.03%) ── sundries
> │ │ │ ├─────23,520 B (00.02%) ── nsTableCellFrame
> │ │ │ ├─────16,704 B (00.02%) ── nsImageFrame
> │ │ │ ├─────15,488 B (00.01%) ── nsTableRowFrame
> │ │ │ ├─────13,776 B (00.01%) ── nsTableColFrame
> │ │ │ └─────13,376 B (00.01%) ── nsTableFrame
> │ │ ├───3,412,192 B (03.28%) -- servo-style-structs
> │ │ │ ├──1,288,224 B (01.24%) ── Display
> │ │ │ ├────742,400 B (00.71%) ── Position
> │ │ │ ├────308,736 B (00.30%) ── Font
> │ │ │ ├────226,512 B (00.22%) ── Background
> │ │ │ ├────218,304 B (00.21%) ── TextReset
> │ │ │ ├────214,896 B (00.21%) ── Text
> │ │ │ ├────130,560 B (00.13%) ── Border
> │ │ │ ├─────81,408 B (00.08%) ── UIReset
> │ │ │ ├─────61,440 B (00.06%) ── Padding
> │ │ │ ├─────38,176 B (00.04%) ── UserInterface
> │ │ │ ├─────29,232 B (00.03%) ── Margin
> │ │ │ ├─────21,824 B (00.02%) ── sundries
> │ │ │ ├─────20,080 B (00.02%) ── Color
> │ │ │ ├─────20,080 B (00.02%) ── Column
> │ │ │ └─────10,320 B (00.01%) ── Effects
> │ │ ├───2,227,680 B (02.14%) -- computed-values
> │ │ │ ├──1,182,928 B (01.14%) ── non-dom
> │ │ │ └──1,044,752 B (01.00%) ── dom
> │ │ ├───1,500,016 B (01.44%) ── text-runs
> │ │ ├─────492,640 B (00.47%) ── line-boxes
> │ │ ├─────326,688 B (00.31%) ── frame-properties
> │ │ ├─────301,760 B (00.29%) ── pres-shell
> │ │ ├──────27,648 B (00.03%) ── pres-contexts
> │ │ └─────────176 B (00.00%) ── style-sets
The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.
Other notable things done by the patch are as follows.
- It significantly changes the signatures of the methods measuring nsINode and
its subclasses, in order to handle the tallying of style structs separately
from element-nodes. Likewise for nsIFrame.
- It renames the 'layout/style-structs' sub-tree as
'layout/gecko-style-structs', to clearly distinguish it from the new
'layout/servo-style-structs' sub-tree.
- It adds some FFI functions to access various Rust-side data structures from
C++ code.
- There is a nasty hack used twice to measure Arcs, by stepping backwards from
an interior pointer to a base pointer. It works, but I want to replace it
with something better eventually. The "XXX WARNING" comments have details.
- It makes DMD print a line to the console if it sees a pointer it doesn't
recognise. This is useful for detecting when we are measuring an interior
pointer instead of a base pointer, which is bad but easy to do when Arcs are
involved.
- It removes the Rust code for measuring CVs, because it's now all done on the
C++ side.
MozReview-Commit-ID: BKebACLKtCi
--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 09:37:33 +03:00
|
|
|
}
|
|
|
|
#define STYLE_STRUCT_LIST_IGNORE_VARIABLES
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
#undef STYLE_STRUCT
|
|
|
|
#undef STYLE_STRUCT_LIST_IGNORE_VARIABLES
|
2017-08-21 09:07:16 +03:00
|
|
|
|
2017-08-25 07:47:54 +03:00
|
|
|
if (visited_style.mPtr && !aSizes.mState.HaveSeenPtr(visited_style.mPtr)) {
|
2017-08-21 09:07:16 +03:00
|
|
|
visited_style.mPtr->AddSizeOfIncludingThis(
|
2017-08-25 07:50:26 +03:00
|
|
|
aSizes, &aSizes.mLayoutComputedValuesVisited);
|
2017-08-21 09:07:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - custom_properties
|
|
|
|
// - writing_mode
|
|
|
|
// - rules
|
|
|
|
// - font_computation_data
|
Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.
Here is an example of the output.
> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │ ├──12,772,544 B (12.26%) -- layout
> │ │ ├───4,483,744 B (04.30%) -- frames
> │ │ │ ├──1,653,552 B (01.59%) ── nsInlineFrame
> │ │ │ ├──1,415,760 B (01.36%) ── nsTextFrame
> │ │ │ ├────431,376 B (00.41%) ── nsBlockFrame
> │ │ │ ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │ │ │ ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │ │ │ ├────156,408 B (00.15%) ── nsBulletFrame
> │ │ │ ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │ │ │ ├─────27,656 B (00.03%) ── sundries
> │ │ │ ├─────23,520 B (00.02%) ── nsTableCellFrame
> │ │ │ ├─────16,704 B (00.02%) ── nsImageFrame
> │ │ │ ├─────15,488 B (00.01%) ── nsTableRowFrame
> │ │ │ ├─────13,776 B (00.01%) ── nsTableColFrame
> │ │ │ └─────13,376 B (00.01%) ── nsTableFrame
> │ │ ├───3,412,192 B (03.28%) -- servo-style-structs
> │ │ │ ├──1,288,224 B (01.24%) ── Display
> │ │ │ ├────742,400 B (00.71%) ── Position
> │ │ │ ├────308,736 B (00.30%) ── Font
> │ │ │ ├────226,512 B (00.22%) ── Background
> │ │ │ ├────218,304 B (00.21%) ── TextReset
> │ │ │ ├────214,896 B (00.21%) ── Text
> │ │ │ ├────130,560 B (00.13%) ── Border
> │ │ │ ├─────81,408 B (00.08%) ── UIReset
> │ │ │ ├─────61,440 B (00.06%) ── Padding
> │ │ │ ├─────38,176 B (00.04%) ── UserInterface
> │ │ │ ├─────29,232 B (00.03%) ── Margin
> │ │ │ ├─────21,824 B (00.02%) ── sundries
> │ │ │ ├─────20,080 B (00.02%) ── Color
> │ │ │ ├─────20,080 B (00.02%) ── Column
> │ │ │ └─────10,320 B (00.01%) ── Effects
> │ │ ├───2,227,680 B (02.14%) -- computed-values
> │ │ │ ├──1,182,928 B (01.14%) ── non-dom
> │ │ │ └──1,044,752 B (01.00%) ── dom
> │ │ ├───1,500,016 B (01.44%) ── text-runs
> │ │ ├─────492,640 B (00.47%) ── line-boxes
> │ │ ├─────326,688 B (00.31%) ── frame-properties
> │ │ ├─────301,760 B (00.29%) ── pres-shell
> │ │ ├──────27,648 B (00.03%) ── pres-contexts
> │ │ └─────────176 B (00.00%) ── style-sets
The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.
Other notable things done by the patch are as follows.
- It significantly changes the signatures of the methods measuring nsINode and
its subclasses, in order to handle the tallying of style structs separately
from element-nodes. Likewise for nsIFrame.
- It renames the 'layout/style-structs' sub-tree as
'layout/gecko-style-structs', to clearly distinguish it from the new
'layout/servo-style-structs' sub-tree.
- It adds some FFI functions to access various Rust-side data structures from
C++ code.
- There is a nasty hack used twice to measure Arcs, by stepping backwards from
an interior pointer to a base pointer. It works, but I want to replace it
with something better eventually. The "XXX WARNING" comments have details.
- It makes DMD print a line to the console if it sees a pointer it doesn't
recognise. This is useful for detecting when we are measuring an interior
pointer instead of a base pointer, which is bad but easy to do when Arcs are
involved.
- It removes the Rust code for measuring CVs, because it's now all done on the
C++ side.
MozReview-Commit-ID: BKebACLKtCi
--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 09:37:33 +03:00
|
|
|
}
|
|
|
|
|
2017-07-17 21:42:00 +03:00
|
|
|
void
|
|
|
|
Gecko_ServoStyleContext_Destroy(ServoStyleContext* aContext)
|
|
|
|
{
|
|
|
|
aContext->~ServoStyleContext();
|
|
|
|
}
|
|
|
|
|
2017-06-28 09:56:13 +03:00
|
|
|
void
|
|
|
|
Gecko_ConstructStyleChildrenIterator(
|
|
|
|
RawGeckoElementBorrowed aElement,
|
|
|
|
RawGeckoStyleChildrenIteratorBorrowedMut aIterator)
|
2016-08-11 02:56:33 +03:00
|
|
|
{
|
2017-06-28 09:56:13 +03:00
|
|
|
MOZ_ASSERT(aElement);
|
|
|
|
MOZ_ASSERT(aIterator);
|
|
|
|
new (aIterator) StyleChildrenIterator(aElement);
|
2016-08-11 02:56:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-06-28 09:56:13 +03:00
|
|
|
Gecko_DestroyStyleChildrenIterator(
|
|
|
|
RawGeckoStyleChildrenIteratorBorrowedMut aIterator)
|
2016-08-11 02:56:33 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIterator);
|
2017-06-28 09:56:13 +03:00
|
|
|
|
|
|
|
aIterator->~StyleChildrenIterator();
|
2016-08-11 02:56:33 +03:00
|
|
|
}
|
|
|
|
|
2016-08-23 16:11:02 +03:00
|
|
|
RawGeckoNodeBorrowed
|
2017-06-28 09:56:13 +03:00
|
|
|
Gecko_GetNextStyleChild(RawGeckoStyleChildrenIteratorBorrowedMut aIterator)
|
2016-08-11 02:56:33 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIterator);
|
|
|
|
return aIterator->GetNextChild();
|
|
|
|
}
|
|
|
|
|
2017-07-23 18:37:46 +03:00
|
|
|
bool
|
|
|
|
Gecko_IsPrivateBrowsingEnabled(const nsIDocument* aDoc)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aDoc);
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsILoadContext* loadContext = aDoc->GetLoadContext();
|
|
|
|
return loadContext && loadContext->UsePrivateBrowsing();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Gecko_AreVisitedLinksEnabled()
|
|
|
|
{
|
|
|
|
return nsCSSRuleProcessor::VisitedLinksEnabled();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-06-28 23:09:32 +03:00
|
|
|
EventStates::ServoType
|
|
|
|
Gecko_DocumentState(const nsIDocument* aDocument)
|
|
|
|
{
|
|
|
|
return aDocument->ThreadSafeGetDocumentState().ServoValue();
|
|
|
|
}
|
|
|
|
|
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_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-07-08 10:07:06 +03:00
|
|
|
// Dirtiness tracking.
|
|
|
|
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
|
2017-07-19 04:04:34 +03:00
|
|
|
Gecko_NoteDirtyElement(RawGeckoElementBorrowed aElement)
|
2017-02-10 05:42:29 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2017-07-19 04:04:34 +03:00
|
|
|
const_cast<Element*>(aElement)->NoteDirtyForServo();
|
2017-07-19 02:17:02 +03:00
|
|
|
}
|
|
|
|
|
2017-08-31 10:42:26 +03:00
|
|
|
void
|
|
|
|
Gecko_NoteDirtySubtreeForInvalidation(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
const_cast<Element*>(aElement)->NoteDirtySubtreeForServo();
|
|
|
|
}
|
|
|
|
|
2017-07-19 02:17:02 +03:00
|
|
|
void
|
2017-07-19 04:04:34 +03:00
|
|
|
Gecko_NoteAnimationOnlyDirtyElement(RawGeckoElementBorrowed aElement)
|
2017-07-19 02:17:02 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2017-07-19 04:04:34 +03:00
|
|
|
const_cast<Element*>(aElement)->NoteAnimationOnlyDirtyForServo();
|
2017-07-19 02:17:02 +03:00
|
|
|
}
|
|
|
|
|
2017-05-14 19:39:22 +03:00
|
|
|
CSSPseudoElementType
|
2017-04-23 00:12:01 +03:00
|
|
|
Gecko_GetImplementedPseudo(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
2017-05-14 19:39:22 +03:00
|
|
|
return aElement->GetPseudoElementType();
|
2016-07-29 05:20:45 +03:00
|
|
|
}
|
|
|
|
|
2017-08-15 04:02:01 +03:00
|
|
|
uint32_t
|
2017-07-21 07:44:02 +03:00
|
|
|
Gecko_CalcStyleDifference(ServoStyleContextBorrowed aOldStyle,
|
|
|
|
ServoStyleContextBorrowed aNewStyle,
|
2017-09-04 15:50:13 +03:00
|
|
|
bool* aAnyStyleChanged,
|
|
|
|
bool* aOnlyResetStructsChanged)
|
2016-07-27 00:22:57 +03:00
|
|
|
{
|
2017-07-21 06:42:44 +03:00
|
|
|
MOZ_ASSERT(aOldStyle);
|
2017-07-21 06:42:42 +03:00
|
|
|
MOZ_ASSERT(aNewStyle);
|
2016-07-27 00:22:57 +03:00
|
|
|
|
2017-07-21 06:42:44 +03:00
|
|
|
uint32_t equalStructs;
|
|
|
|
uint32_t samePointerStructs; // unused
|
|
|
|
nsChangeHint result = const_cast<ServoStyleContext*>(aOldStyle)->
|
|
|
|
CalcStyleDifference(
|
|
|
|
const_cast<ServoStyleContext*>(aNewStyle),
|
|
|
|
&equalStructs,
|
|
|
|
&samePointerStructs,
|
2017-09-04 15:50:13 +03:00
|
|
|
NS_STYLE_INHERIT_MASK);
|
|
|
|
|
2017-05-20 06:17:40 +03:00
|
|
|
*aAnyStyleChanged = equalStructs != NS_STYLE_INHERIT_MASK;
|
2017-09-04 15:50:13 +03:00
|
|
|
|
|
|
|
const uint32_t kInheritStructsMask =
|
|
|
|
NS_STYLE_INHERIT_MASK & ~NS_STYLE_RESET_STRUCT_MASK;
|
|
|
|
|
|
|
|
*aOnlyResetStructsChanged =
|
|
|
|
(equalStructs & kInheritStructsMask) == kInheritStructsMask;
|
|
|
|
|
2016-07-27 00:22:57 +03:00
|
|
|
return result;
|
2016-07-29 05:20:45 +03:00
|
|
|
}
|
|
|
|
|
2017-05-07 17:36:47 +03:00
|
|
|
const ServoElementSnapshot*
|
|
|
|
Gecko_GetElementSnapshot(const ServoElementSnapshotTable* aTable,
|
|
|
|
const Element* aElement)
|
2016-11-02 09:11:24 +03:00
|
|
|
{
|
2017-05-07 17:36:47 +03:00
|
|
|
MOZ_ASSERT(aTable);
|
|
|
|
MOZ_ASSERT(aElement);
|
2016-08-25 01:38:49 +03:00
|
|
|
|
2017-05-07 17:36:47 +03:00
|
|
|
return aTable->Get(const_cast<Element*>(aElement));
|
2016-07-27 00:22:57 +03:00
|
|
|
}
|
|
|
|
|
2017-07-19 03:30:53 +03:00
|
|
|
bool
|
|
|
|
Gecko_HaveSeenPtr(SeenPtrs* aTable, const void* aPtr)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aTable);
|
|
|
|
// Empty Rust allocations are indicated by small values up to the alignment
|
|
|
|
// of the relevant type. We shouldn't see anything like that here.
|
|
|
|
MOZ_ASSERT(uintptr_t(aPtr) > 16);
|
|
|
|
|
|
|
|
return aTable->HaveSeenPtr(aPtr);
|
|
|
|
}
|
|
|
|
|
2017-04-27 12:54:26 +03:00
|
|
|
RawServoDeclarationBlockStrongBorrowedOrNull
|
|
|
|
Gecko_GetStyleAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
|
2016-07-19 04:02:55 +03:00
|
|
|
{
|
2017-04-27 12:54:26 +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-05-31 03:24:40 +03:00
|
|
|
void
|
|
|
|
Gecko_UnsetDirtyStyleAttr(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
DeclarationBlock* decl = aElement->GetInlineStyleDeclaration();
|
|
|
|
if (!decl) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (decl->IsGecko()) {
|
|
|
|
// XXX This can happen when nodes are adopted from a Gecko-style-backend
|
|
|
|
// document into a Servo-style-backend document. See bug 1330051.
|
|
|
|
NS_WARNING("stylo: requesting a Gecko declaration block?");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
decl->UnsetDirty();
|
|
|
|
}
|
|
|
|
|
2017-04-27 05:09:55 +03:00
|
|
|
RawServoDeclarationBlockStrongBorrowedOrNull
|
|
|
|
Gecko_GetSMILOverrideDeclarationBlock(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
2017-04-27 12:54:26 +03:00
|
|
|
// This function duplicates a lot of the code in
|
|
|
|
// Gecko_GetStyleAttrDeclarationBlock above because I haven't worked out a way
|
|
|
|
// to persuade hazard analysis that a pointer-to-lambda is ok yet.
|
|
|
|
MOZ_ASSERT(aElement, "Invalid GeckoElement");
|
|
|
|
|
|
|
|
DeclarationBlock* decl =
|
|
|
|
const_cast<dom::Element*>(aElement)->GetSMILOverrideStyleDeclaration();
|
|
|
|
if (!decl) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (decl->IsGecko()) {
|
|
|
|
// XXX This can happen when nodes are adopted from a Gecko-style-backend
|
|
|
|
// document into a Servo-style-backend document. See bug 1330051.
|
|
|
|
NS_WARNING("stylo: requesting a Gecko declaration block?");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return decl->AsServo()->RefRawStrong();
|
2017-04-27 05:09:55 +03:00
|
|
|
}
|
|
|
|
|
2017-06-01 21:37:02 +03:00
|
|
|
const RawServoDeclarationBlockStrong*
|
|
|
|
AsRefRawStrong(const RefPtr<RawServoDeclarationBlock>& aDecl)
|
2017-01-20 02:56:53 +03:00
|
|
|
{
|
|
|
|
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
|
|
|
|
sizeof(RawServoDeclarationBlockStrong),
|
|
|
|
"RefPtr should just be a pointer");
|
2017-06-01 21:37:02 +03:00
|
|
|
return reinterpret_cast<const RawServoDeclarationBlockStrong*>(&aDecl);
|
|
|
|
}
|
|
|
|
|
|
|
|
RawServoDeclarationBlockStrongBorrowedOrNull
|
|
|
|
Gecko_GetHTMLPresentationAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
2017-01-20 02:56:53 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-06-01 21:37:02 +03:00
|
|
|
return AsRefRawStrong(attrs->GetServoStyle());
|
2017-01-20 02:56:53 +03:00
|
|
|
}
|
|
|
|
|
2017-03-26 23:53:34 +03:00
|
|
|
RawServoDeclarationBlockStrongBorrowedOrNull
|
|
|
|
Gecko_GetExtraContentStyleDeclarations(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
if (!aElement->IsAnyOfHTMLElements(nsGkAtoms::td, nsGkAtoms::th)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
const HTMLTableCellElement* cell = static_cast<const HTMLTableCellElement*>(aElement);
|
|
|
|
if (nsMappedAttributes* attrs = cell->GetMappedAttributesInheritedFromTable()) {
|
2017-06-01 21:37:02 +03:00
|
|
|
return AsRefRawStrong(attrs->GetServoStyle());
|
2017-03-26 23:53:34 +03:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-06-01 21:37:02 +03:00
|
|
|
RawServoDeclarationBlockStrongBorrowedOrNull
|
|
|
|
Gecko_GetUnvisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
|
|
|
|
if (!sheet) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return AsRefRawStrong(sheet->GetServoUnvisitedLinkDecl());
|
|
|
|
}
|
|
|
|
|
2017-06-29 20:09:56 +03:00
|
|
|
ServoStyleSheet* Gecko_StyleSheet_Clone(
|
|
|
|
const ServoStyleSheet* aSheet,
|
|
|
|
const ServoStyleSheet* aNewParentSheet)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aSheet);
|
|
|
|
MOZ_ASSERT(aSheet->GetParentSheet(), "Should only be used for @import");
|
|
|
|
MOZ_ASSERT(aNewParentSheet, "Wat");
|
|
|
|
|
|
|
|
RefPtr<StyleSheet> newSheet =
|
|
|
|
aSheet->Clone(nullptr, nullptr, nullptr, nullptr);
|
|
|
|
|
|
|
|
// NOTE(emilio): This code runs in the StylesheetInner constructor, which
|
|
|
|
// means that the inner pointer of `aNewParentSheet` still points to the old
|
|
|
|
// one.
|
|
|
|
//
|
|
|
|
// So we _don't_ update neither the parent pointer of the stylesheet, nor the
|
|
|
|
// child list (yet). This is fixed up in that same constructor.
|
|
|
|
return static_cast<ServoStyleSheet*>(newSheet.forget().take());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_StyleSheet_AddRef(const ServoStyleSheet* aSheet)
|
|
|
|
{
|
2017-07-02 20:21:22 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2017-06-29 20:09:56 +03:00
|
|
|
const_cast<ServoStyleSheet*>(aSheet)->AddRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_StyleSheet_Release(const ServoStyleSheet* aSheet)
|
|
|
|
{
|
2017-07-02 20:21:22 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2017-06-29 20:09:56 +03:00
|
|
|
const_cast<ServoStyleSheet*>(aSheet)->Release();
|
|
|
|
}
|
|
|
|
|
2017-06-01 21:37:02 +03:00
|
|
|
RawServoDeclarationBlockStrongBorrowedOrNull
|
|
|
|
Gecko_GetVisitedLinkAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
|
|
|
|
if (!sheet) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return AsRefRawStrong(sheet->GetServoVisitedLinkDecl());
|
|
|
|
}
|
|
|
|
|
|
|
|
RawServoDeclarationBlockStrongBorrowedOrNull
|
|
|
|
Gecko_GetActiveLinkAttrDeclarationBlock(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
|
|
|
|
if (!sheet) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return AsRefRawStrong(sheet->GetServoActiveLinkDecl());
|
|
|
|
}
|
|
|
|
|
2017-06-23 11:05:37 +03:00
|
|
|
static CSSPseudoElementType
|
|
|
|
GetPseudoTypeFromElementForAnimation(const Element*& aElementOrPseudo) {
|
|
|
|
if (aElementOrPseudo->IsGeneratedContentContainerForBefore()) {
|
|
|
|
aElementOrPseudo = aElementOrPseudo->GetParent()->AsElement();
|
|
|
|
return CSSPseudoElementType::before;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aElementOrPseudo->IsGeneratedContentContainerForAfter()) {
|
|
|
|
aElementOrPseudo = aElementOrPseudo->GetParent()->AsElement();
|
|
|
|
return CSSPseudoElementType::after;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CSSPseudoElementType::NotPseudo;
|
|
|
|
}
|
|
|
|
|
2017-03-17 07:23:21 +03:00
|
|
|
bool
|
2017-01-24 10:27:56 +03:00
|
|
|
Gecko_GetAnimationRule(RawGeckoElementBorrowed aElement,
|
2017-03-17 07:23:21 +03:00
|
|
|
EffectCompositor::CascadeLevel aCascadeLevel,
|
2017-05-01 12:45:41 +03:00
|
|
|
RawServoAnimationValueMapBorrowedMut aAnimationValues)
|
2017-01-24 10:27:56 +03:00
|
|
|
{
|
2017-04-23 00:12:01 +03:00
|
|
|
MOZ_ASSERT(aElement);
|
2017-01-24 10:27:56 +03:00
|
|
|
|
|
|
|
nsIDocument* doc = aElement->GetComposedDoc();
|
|
|
|
if (!doc || !doc->GetShell()) {
|
2017-03-17 07:23:21 +03:00
|
|
|
return false;
|
2017-01-24 10:27:56 +03:00
|
|
|
}
|
|
|
|
nsPresContext* presContext = doc->GetShell()->GetPresContext();
|
2017-03-17 06:48:34 +03:00
|
|
|
if (!presContext || !presContext->IsDynamic()) {
|
|
|
|
// For print or print preview, ignore animations.
|
2017-03-17 07:23:21 +03:00
|
|
|
return false;
|
2017-01-24 10:27:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CSSPseudoElementType pseudoType =
|
2017-06-23 11:05:37 +03:00
|
|
|
GetPseudoTypeFromElementForAnimation(aElement);
|
2017-01-24 10:27:56 +03:00
|
|
|
|
2017-03-17 07:23:21 +03:00
|
|
|
return presContext->EffectCompositor()
|
2017-04-23 00:12:01 +03:00
|
|
|
->GetServoAnimationRule(aElement,
|
|
|
|
pseudoType,
|
2017-03-17 07:23:21 +03:00
|
|
|
aCascadeLevel,
|
|
|
|
aAnimationValues);
|
2017-01-24 10:27:56 +03:00
|
|
|
}
|
|
|
|
|
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,
|
2017-07-21 07:44:02 +03:00
|
|
|
ServoStyleContextBorrowedOrNull aOldComputedData,
|
|
|
|
ServoStyleContextBorrowedOrNull aComputedData,
|
2017-04-25 06:24:51 +03:00
|
|
|
UpdateAnimationsTasks aTasks)
|
2017-03-10 05:53:19 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aElement);
|
|
|
|
|
2017-06-19 06:22:13 +03:00
|
|
|
if (!aElement->IsInComposedDoc()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-10 05:53:19 +03:00
|
|
|
nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement);
|
2017-06-19 06:22:13 +03:00
|
|
|
if (!presContext || !presContext->IsDynamic()) {
|
2017-03-10 05:53:19 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-24 11:02:53 +03:00
|
|
|
nsAutoAnimationMutationBatch mb(aElement->OwnerDoc());
|
|
|
|
|
2017-06-19 06:22:13 +03:00
|
|
|
CSSPseudoElementType pseudoType =
|
2017-06-23 11:05:37 +03:00
|
|
|
GetPseudoTypeFromElementForAnimation(aElement);
|
2017-04-25 05:29:43 +03:00
|
|
|
|
2017-06-19 06:22:13 +03:00
|
|
|
if (aTasks & UpdateAnimationsTasks::CSSAnimations) {
|
|
|
|
presContext->AnimationManager()->
|
|
|
|
UpdateAnimations(const_cast<dom::Element*>(aElement), pseudoType,
|
2017-07-21 07:44:02 +03:00
|
|
|
aComputedData);
|
2017-06-19 06:22:13 +03:00
|
|
|
}
|
2017-04-25 05:29:43 +03:00
|
|
|
|
2017-07-21 07:44:02 +03:00
|
|
|
// aComputedData might be nullptr if the target element is now in a
|
2017-06-19 06:22:13 +03:00
|
|
|
// display:none subtree. We still call Gecko_UpdateAnimations in this case
|
|
|
|
// because we need to stop CSS animations in the display:none subtree.
|
|
|
|
// However, we don't need to update transitions since they are stopped by
|
|
|
|
// RestyleManager::AnimationsWithDestroyedFrame so we just return early
|
|
|
|
// here.
|
2017-07-21 07:44:02 +03:00
|
|
|
if (!aComputedData) {
|
2017-06-19 06:22:13 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-05-19 11:04:40 +03:00
|
|
|
|
2017-06-19 06:22:13 +03:00
|
|
|
if (aTasks & UpdateAnimationsTasks::CSSTransitions) {
|
2017-07-21 07:44:02 +03:00
|
|
|
MOZ_ASSERT(aOldComputedData);
|
2017-06-19 06:22:13 +03:00
|
|
|
presContext->TransitionManager()->
|
|
|
|
UpdateTransitions(const_cast<dom::Element*>(aElement), pseudoType,
|
2017-07-21 07:44:02 +03:00
|
|
|
aOldComputedData,
|
|
|
|
aComputedData);
|
2017-06-19 06:22:13 +03:00
|
|
|
}
|
2017-05-19 11:04:40 +03:00
|
|
|
|
2017-06-19 06:22:13 +03:00
|
|
|
if (aTasks & UpdateAnimationsTasks::EffectProperties) {
|
|
|
|
presContext->EffectCompositor()->UpdateEffectProperties(
|
2017-07-21 07:44:02 +03:00
|
|
|
aComputedData, const_cast<dom::Element*>(aElement), pseudoType);
|
2017-06-19 06:22:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aTasks & UpdateAnimationsTasks::CascadeResults) {
|
|
|
|
// This task will be scheduled if we detected any changes to !important
|
|
|
|
// rules. We post a restyle here so that we can update the cascade
|
|
|
|
// results in the pre-traversal of the next restyle.
|
|
|
|
presContext->EffectCompositor()
|
|
|
|
->RequestRestyle(const_cast<Element*>(aElement),
|
|
|
|
pseudoType,
|
|
|
|
EffectCompositor::RestyleType::Standard,
|
|
|
|
EffectCompositor::CascadeLevel::Animations);
|
2017-03-10 05:53:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-27 13:42:59 +03:00
|
|
|
bool
|
2017-04-23 00:12:01 +03:00
|
|
|
Gecko_ElementHasAnimations(RawGeckoElementBorrowed aElement)
|
2017-03-27 13:42:59 +03:00
|
|
|
{
|
|
|
|
CSSPseudoElementType pseudoType =
|
2017-06-23 11:05:37 +03:00
|
|
|
GetPseudoTypeFromElementForAnimation(aElement);
|
2017-03-27 13:42:59 +03:00
|
|
|
|
|
|
|
return !!EffectSet::GetEffectSet(aElement, pseudoType);
|
|
|
|
}
|
|
|
|
|
2017-03-10 05:53:19 +03:00
|
|
|
bool
|
2017-04-23 00:12:01 +03:00
|
|
|
Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElement)
|
2017-03-10 05:53:19 +03:00
|
|
|
{
|
2017-06-23 11:05:42 +03:00
|
|
|
CSSPseudoElementType pseudoType =
|
|
|
|
GetPseudoTypeFromElementForAnimation(aElement);
|
2017-03-10 05:53:19 +03:00
|
|
|
nsAnimationManager::CSSAnimationCollection* collection =
|
|
|
|
nsAnimationManager::CSSAnimationCollection
|
2017-06-23 11:05:42 +03:00
|
|
|
::GetAnimationCollection(aElement, pseudoType);
|
2017-03-10 05:53:19 +03:00
|
|
|
|
|
|
|
return collection && !collection->mAnimations.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2017-04-17 09:24:33 +03:00
|
|
|
bool
|
2017-04-23 00:12:01 +03:00
|
|
|
Gecko_ElementHasCSSTransitions(RawGeckoElementBorrowed aElement)
|
2017-04-17 09:24:33 +03:00
|
|
|
{
|
2017-06-23 11:05:42 +03:00
|
|
|
CSSPseudoElementType pseudoType =
|
|
|
|
GetPseudoTypeFromElementForAnimation(aElement);
|
2017-04-17 09:24:33 +03:00
|
|
|
nsTransitionManager::CSSTransitionCollection* collection =
|
|
|
|
nsTransitionManager::CSSTransitionCollection
|
2017-06-23 11:05:42 +03:00
|
|
|
::GetAnimationCollection(aElement, pseudoType);
|
2017-04-17 09:24:33 +03:00
|
|
|
|
|
|
|
return collection && !collection->mAnimations.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2017-04-17 09:29:31 +03:00
|
|
|
size_t
|
2017-04-23 00:12:01 +03:00
|
|
|
Gecko_ElementTransitions_Length(RawGeckoElementBorrowed aElement)
|
2017-04-17 09:29:31 +03:00
|
|
|
{
|
2017-06-23 11:05:42 +03:00
|
|
|
CSSPseudoElementType pseudoType =
|
|
|
|
GetPseudoTypeFromElementForAnimation(aElement);
|
2017-04-17 09:29:31 +03:00
|
|
|
nsTransitionManager::CSSTransitionCollection* collection =
|
|
|
|
nsTransitionManager::CSSTransitionCollection
|
2017-06-23 11:05:42 +03:00
|
|
|
::GetAnimationCollection(aElement, pseudoType);
|
2017-04-17 09:29:31 +03:00
|
|
|
|
|
|
|
return collection ? collection->mAnimations.Length() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CSSTransition*
|
2017-04-23 00:12:01 +03:00
|
|
|
GetCurrentTransitionAt(RawGeckoElementBorrowed aElement, size_t aIndex)
|
2017-04-17 09:29:31 +03:00
|
|
|
{
|
2017-06-23 11:05:42 +03:00
|
|
|
CSSPseudoElementType pseudoType =
|
|
|
|
GetPseudoTypeFromElementForAnimation(aElement);
|
2017-04-17 09:29:31 +03:00
|
|
|
nsTransitionManager::CSSTransitionCollection* collection =
|
|
|
|
nsTransitionManager::CSSTransitionCollection
|
2017-06-23 11:05:42 +03:00
|
|
|
::GetAnimationCollection(aElement, pseudoType);
|
2017-04-17 09:29:31 +03:00
|
|
|
if (!collection) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
nsTArray<RefPtr<CSSTransition>>& transitions = collection->mAnimations;
|
|
|
|
return aIndex < transitions.Length()
|
|
|
|
? transitions[aIndex].get()
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSPropertyID
|
|
|
|
Gecko_ElementTransitions_PropertyAt(RawGeckoElementBorrowed aElement,
|
|
|
|
size_t aIndex)
|
|
|
|
{
|
2017-04-23 00:12:01 +03:00
|
|
|
CSSTransition* transition = GetCurrentTransitionAt(aElement, aIndex);
|
2017-04-17 09:29:31 +03:00
|
|
|
return transition ? transition->TransitionProperty()
|
|
|
|
: nsCSSPropertyID::eCSSProperty_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
RawServoAnimationValueBorrowedOrNull
|
|
|
|
Gecko_ElementTransitions_EndValueAt(RawGeckoElementBorrowed aElement,
|
|
|
|
size_t aIndex)
|
|
|
|
{
|
|
|
|
CSSTransition* transition = GetCurrentTransitionAt(aElement,
|
|
|
|
aIndex);
|
|
|
|
return transition ? transition->ToValue().mServo.get() : nullptr;
|
|
|
|
}
|
|
|
|
|
2017-04-06 04:34:51 +03:00
|
|
|
double
|
|
|
|
Gecko_GetProgressFromComputedTiming(RawGeckoComputedTimingBorrowed aComputedTiming)
|
|
|
|
{
|
|
|
|
return aComputedTiming->mProgress.Value();
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
Gecko_GetPositionInSegment(RawGeckoAnimationPropertySegmentBorrowed aSegment,
|
|
|
|
double aProgress,
|
|
|
|
ComputedTimingFunction::BeforeFlag aBeforeFlag)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aSegment->mFromKey < aSegment->mToKey,
|
|
|
|
"The segment from key should be less than to key");
|
|
|
|
|
|
|
|
double positionInSegment =
|
|
|
|
(aProgress - aSegment->mFromKey) / (aSegment->mToKey - aSegment->mFromKey);
|
|
|
|
|
|
|
|
return ComputedTimingFunction::GetPortion(aSegment->mTimingFunction,
|
|
|
|
positionInSegment,
|
|
|
|
aBeforeFlag);
|
|
|
|
}
|
|
|
|
|
2017-04-06 04:34:51 +03:00
|
|
|
RawServoAnimationValueBorrowedOrNull
|
|
|
|
Gecko_AnimationGetBaseStyle(void* aBaseStyles, nsCSSPropertyID aProperty)
|
|
|
|
{
|
|
|
|
auto base =
|
|
|
|
static_cast<nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>*>
|
|
|
|
(aBaseStyles);
|
|
|
|
return base->GetWeak(aProperty);
|
|
|
|
}
|
|
|
|
|
2017-04-26 12:41:45 +03:00
|
|
|
void
|
|
|
|
Gecko_StyleTransition_SetUnsupportedProperty(StyleTransition* aTransition,
|
|
|
|
nsIAtom* aAtom)
|
|
|
|
{
|
|
|
|
nsCSSPropertyID id =
|
|
|
|
nsCSSProps::LookupProperty(nsDependentAtomString(aAtom),
|
|
|
|
CSSEnabledState::eForAllContent);
|
|
|
|
if (id == eCSSProperty_UNKNOWN || id == eCSSPropertyExtra_variable) {
|
|
|
|
aTransition->SetUnknownProperty(id, aAtom);
|
|
|
|
} else {
|
|
|
|
aTransition->SetProperty(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-09-15 23:54:59 +03:00
|
|
|
bool
|
|
|
|
Gecko_IsDocumentBody(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
nsIDocument* doc = aElement->GetUncomposedDoc();
|
|
|
|
return doc && doc->GetBodyElement() == aElement;
|
|
|
|
}
|
|
|
|
|
2017-08-19 01:56:01 +03:00
|
|
|
nscolor
|
|
|
|
Gecko_GetLookAndFeelSystemColor(int32_t aId,
|
|
|
|
RawGeckoPresContextBorrowed aPresContext)
|
2017-03-16 00:49:35 +03:00
|
|
|
{
|
|
|
|
bool useStandinsForNativeColors = aPresContext && !aPresContext->IsChrome();
|
|
|
|
nscolor result;
|
|
|
|
LookAndFeel::ColorID colorId = static_cast<LookAndFeel::ColorID>(aId);
|
2017-08-19 01:56:01 +03:00
|
|
|
MutexAutoLock guard(*sServoWidgetLock);
|
2017-03-16 00:49:35 +03:00
|
|
|
LookAndFeel::GetColor(colorId, useStandinsForNativeColors, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-03-17 00:10:22 +03:00
|
|
|
bool
|
|
|
|
Gecko_MatchStringArgPseudo(RawGeckoElementBorrowed aElement,
|
|
|
|
CSSPseudoClassType aType,
|
2017-09-27 17:48:46 +03:00
|
|
|
const char16_t* aIdent)
|
2017-03-17 00:10:22 +03:00
|
|
|
{
|
|
|
|
EventStates dummyMask; // mask is never read because we pass aDependence=nullptr
|
|
|
|
return nsCSSRuleProcessor::StringPseudoMatches(aElement, aType, aIdent,
|
2017-09-27 17:48:46 +03:00
|
|
|
aElement->OwnerDoc(),
|
|
|
|
dummyMask, nullptr);
|
2017-03-17 00:10:22 +03:00
|
|
|
}
|
|
|
|
|
2017-06-07 07:27:58 +03:00
|
|
|
bool
|
|
|
|
Gecko_MatchLang(RawGeckoElementBorrowed aElement,
|
|
|
|
nsIAtom* aOverrideLang,
|
|
|
|
bool aHasOverrideLang,
|
|
|
|
const char16_t* aValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!(aOverrideLang && !aHasOverrideLang),
|
|
|
|
"aHasOverrideLang should only be set when aOverrideLang is null");
|
|
|
|
|
|
|
|
if (!aHasOverrideLang) {
|
|
|
|
return nsCSSRuleProcessor::LangPseudoMatches(aElement, nullptr, false,
|
|
|
|
aValue, aElement->OwnerDoc());
|
|
|
|
}
|
|
|
|
|
2017-06-15 22:48:26 +03:00
|
|
|
return nsCSSRuleProcessor::LangPseudoMatches(aElement, aOverrideLang, true,
|
2017-06-07 07:27:58 +03:00
|
|
|
aValue, aElement->OwnerDoc());
|
|
|
|
}
|
|
|
|
|
2017-03-26 23:53:34 +03:00
|
|
|
nsIAtom*
|
|
|
|
Gecko_GetXMLLangValue(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
2017-06-15 22:48:26 +03:00
|
|
|
const nsAttrValue* attr =
|
|
|
|
aElement->GetParsedAttr(nsGkAtoms::lang, kNameSpaceID_XML);
|
|
|
|
|
|
|
|
if (!attr) {
|
|
|
|
return nullptr;
|
2017-03-26 23:53:34 +03:00
|
|
|
}
|
2017-06-15 22:48:26 +03:00
|
|
|
|
|
|
|
MOZ_ASSERT(attr->Type() == nsAttrValue::eAtom);
|
|
|
|
|
2017-09-26 01:33:21 +03:00
|
|
|
RefPtr<nsIAtom> atom = attr->GetAtomValue();
|
2017-06-15 22:48:26 +03:00
|
|
|
return atom.forget().take();
|
2017-03-26 23:53:34 +03:00
|
|
|
}
|
|
|
|
|
2017-06-28 19:04:49 +03:00
|
|
|
nsIDocument::DocumentTheme
|
2017-06-28 23:09:32 +03:00
|
|
|
Gecko_GetDocumentLWTheme(const nsIDocument* aDocument)
|
2017-06-28 19:04:49 +03:00
|
|
|
{
|
|
|
|
return aDocument->ThreadSafeGetDocumentLWTheme();
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-06-07 07:16:52 +03:00
|
|
|
template <typename Implementor>
|
|
|
|
static nsIAtom*
|
|
|
|
LangValue(Implementor* aElement)
|
|
|
|
{
|
2017-06-15 22:48:26 +03:00
|
|
|
// TODO(emilio): Deduplicate a bit with nsIContent::GetLang().
|
2017-06-07 07:16:52 +03:00
|
|
|
const nsAttrValue* attr =
|
|
|
|
aElement->GetParsedAttr(nsGkAtoms::lang, kNameSpaceID_XML);
|
|
|
|
if (!attr && aElement->SupportsLangAttr()) {
|
|
|
|
attr = aElement->GetParsedAttr(nsGkAtoms::lang);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!attr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-06-15 22:48:26 +03:00
|
|
|
MOZ_ASSERT(attr->Type() == nsAttrValue::eAtom);
|
2017-09-26 01:33:21 +03:00
|
|
|
RefPtr<nsIAtom> atom = attr->GetAtomValue();
|
2017-06-15 22:48:26 +03:00
|
|
|
return atom.forget().take();
|
2017-06-07 07:16:52 +03:00
|
|
|
}
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
template <typename Implementor, typename MatchFn>
|
|
|
|
static bool
|
|
|
|
DoMatch(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, MatchFn aMatch)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
2017-07-20 13:06:26 +03:00
|
|
|
if (MOZ_LIKELY(aNS)) {
|
|
|
|
int32_t ns = aNS == nsGkAtoms::_empty
|
|
|
|
? kNameSpaceID_None
|
|
|
|
: nsContentUtils::NameSpaceManager()->GetNameSpaceID(
|
|
|
|
aNS, aElement->IsInChromeDocument());
|
|
|
|
|
|
|
|
MOZ_ASSERT(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);
|
|
|
|
}
|
2017-07-20 13:06:26 +03:00
|
|
|
|
2016-06-30 23:37:52 +03:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2017-06-09 00:09:41 +03:00
|
|
|
#define WITH_COMPARATOR(ignore_case_, c_, expr_) \
|
|
|
|
if (ignore_case_) { \
|
|
|
|
const nsCaseInsensitiveStringComparator c_ \
|
|
|
|
= nsCaseInsensitiveStringComparator(); \
|
|
|
|
return expr_; \
|
|
|
|
} else { \
|
|
|
|
const nsDefaultStringComparator c_; \
|
|
|
|
return expr_; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-19 04:02:55 +03:00
|
|
|
template <typename Implementor>
|
|
|
|
static bool
|
|
|
|
AttrDashEquals(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
|
2017-06-09 00:09:41 +03:00
|
|
|
nsIAtom* aStr, bool aIgnoreCase)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
2017-06-09 00:09:41 +03:00
|
|
|
auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) {
|
2016-06-30 23:37:52 +03:00
|
|
|
nsAutoString str;
|
|
|
|
aValue->ToString(str);
|
2017-06-09 00:09:41 +03:00
|
|
|
WITH_COMPARATOR(aIgnoreCase, c,
|
|
|
|
nsStyleUtil::DashMatchCompare(str, nsDependentAtomString(aStr), c))
|
2016-06-30 23:37:52 +03:00
|
|
|
};
|
|
|
|
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,
|
2017-06-09 00:09:41 +03:00
|
|
|
nsIAtom* aStr, bool aIgnoreCase)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
2017-06-09 00:09:41 +03:00
|
|
|
auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) {
|
2016-06-30 23:37:52 +03:00
|
|
|
nsAutoString str;
|
|
|
|
aValue->ToString(str);
|
2017-06-09 00:09:41 +03:00
|
|
|
WITH_COMPARATOR(aIgnoreCase, c,
|
|
|
|
nsStyleUtil::ValueIncludes(str, nsDependentAtomString(aStr), c))
|
2016-06-30 23:37:52 +03:00
|
|
|
};
|
|
|
|
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,
|
2017-06-09 00:09:41 +03:00
|
|
|
nsIAtom* aStr, bool aIgnoreCase)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
2017-06-09 00:09:41 +03:00
|
|
|
auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) {
|
2016-06-30 23:37:52 +03:00
|
|
|
nsAutoString str;
|
|
|
|
aValue->ToString(str);
|
2017-06-09 00:09:41 +03:00
|
|
|
WITH_COMPARATOR(aIgnoreCase, c,
|
|
|
|
FindInReadable(nsDependentAtomString(aStr), str, c))
|
2016-06-30 23:37:52 +03:00
|
|
|
};
|
|
|
|
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,
|
2017-06-09 00:09:41 +03:00
|
|
|
nsIAtom* aStr, bool aIgnoreCase)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
2017-06-09 00:09:41 +03:00
|
|
|
auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) {
|
2016-06-30 23:37:52 +03:00
|
|
|
nsAutoString str;
|
|
|
|
aValue->ToString(str);
|
2017-06-09 00:09:41 +03:00
|
|
|
WITH_COMPARATOR(aIgnoreCase, c,
|
|
|
|
StringBeginsWith(str, nsDependentAtomString(aStr), c))
|
2016-06-30 23:37:52 +03:00
|
|
|
};
|
|
|
|
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,
|
2017-06-09 00:09:41 +03:00
|
|
|
nsIAtom* aStr, bool aIgnoreCase)
|
2016-06-30 23:37:52 +03:00
|
|
|
{
|
2017-06-09 00:09:41 +03:00
|
|
|
auto match = [aStr, aIgnoreCase](const nsAttrValue* aValue) {
|
2016-06-30 23:37:52 +03:00
|
|
|
nsAutoString str;
|
|
|
|
aValue->ToString(str);
|
2017-06-09 00:09:41 +03:00
|
|
|
WITH_COMPARATOR(aIgnoreCase, c,
|
|
|
|
StringEndsWith(str, nsDependentAtomString(aStr), c))
|
2016-06-30 23:37:52 +03:00
|
|
|
};
|
|
|
|
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
|
|
|
{
|
2017-06-27 20:55:03 +03:00
|
|
|
const nsAttrValue* attr = aElement->GetClasses();
|
2016-05-25 21:16:26 +03:00
|
|
|
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);
|
2017-09-26 01:33:21 +03:00
|
|
|
nsTArray<RefPtr<nsIAtom>>* atomArray = attr->GetAtomArrayValue();
|
2016-05-25 21:16:26 +03:00
|
|
|
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.
|
2017-09-26 01:33:21 +03:00
|
|
|
static_assert(sizeof(RefPtr<nsIAtom>) == sizeof(nsIAtom*), "Bad simplification");
|
|
|
|
static_assert(alignof(RefPtr<nsIAtom>) == alignof(nsIAtom*), "Bad simplification");
|
2016-05-25 21:16:26 +03:00
|
|
|
|
2017-09-26 01:33:21 +03:00
|
|
|
RefPtr<nsIAtom>* elements = atomArray->Elements();
|
2016-05-25 21:16:26 +03:00
|
|
|
nsIAtom** rawElements = reinterpret_cast<nsIAtom**>(elements);
|
|
|
|
*aClassList = rawElements;
|
|
|
|
return atomArray->Length();
|
|
|
|
}
|
|
|
|
|
2017-06-09 00:09:41 +03:00
|
|
|
#define SERVO_IMPL_ELEMENT_ATTR_MATCHING_FUNCTIONS(prefix_, implementor_) \
|
|
|
|
nsIAtom* prefix_##AtomAttrValue(implementor_ aElement, nsIAtom* aName) \
|
|
|
|
{ \
|
|
|
|
return AtomAttrValue(aElement, aName); \
|
|
|
|
} \
|
|
|
|
nsIAtom* prefix_##LangValue(implementor_ aElement) \
|
|
|
|
{ \
|
|
|
|
return LangValue(aElement); \
|
|
|
|
} \
|
|
|
|
bool prefix_##HasAttr(implementor_ aElement, nsIAtom* aNS, nsIAtom* aName) \
|
|
|
|
{ \
|
|
|
|
return HasAttr(aElement, aNS, aName); \
|
|
|
|
} \
|
|
|
|
bool prefix_##AttrEquals(implementor_ aElement, nsIAtom* aNS, \
|
|
|
|
nsIAtom* aName, nsIAtom* aStr, bool aIgnoreCase) \
|
|
|
|
{ \
|
|
|
|
return AttrEquals(aElement, aNS, aName, aStr, aIgnoreCase); \
|
|
|
|
} \
|
|
|
|
bool prefix_##AttrDashEquals(implementor_ aElement, nsIAtom* aNS, \
|
|
|
|
nsIAtom* aName, nsIAtom* aStr, bool aIgnoreCase) \
|
|
|
|
{ \
|
|
|
|
return AttrDashEquals(aElement, aNS, aName, aStr, aIgnoreCase); \
|
|
|
|
} \
|
|
|
|
bool prefix_##AttrIncludes(implementor_ aElement, nsIAtom* aNS, \
|
|
|
|
nsIAtom* aName, nsIAtom* aStr, bool aIgnoreCase) \
|
|
|
|
{ \
|
|
|
|
return AttrIncludes(aElement, aNS, aName, aStr, aIgnoreCase); \
|
|
|
|
} \
|
|
|
|
bool prefix_##AttrHasSubstring(implementor_ aElement, nsIAtom* aNS, \
|
|
|
|
nsIAtom* aName, nsIAtom* aStr, bool aIgnoreCase)\
|
|
|
|
{ \
|
|
|
|
return AttrHasSubstring(aElement, aNS, aName, aStr, aIgnoreCase); \
|
|
|
|
} \
|
|
|
|
bool prefix_##AttrHasPrefix(implementor_ aElement, nsIAtom* aNS, \
|
|
|
|
nsIAtom* aName, nsIAtom* aStr, bool aIgnoreCase) \
|
|
|
|
{ \
|
|
|
|
return AttrHasPrefix(aElement, aNS, aName, aStr, aIgnoreCase); \
|
|
|
|
} \
|
|
|
|
bool prefix_##AttrHasSuffix(implementor_ aElement, nsIAtom* aNS, \
|
|
|
|
nsIAtom* aName, nsIAtom* aStr, bool aIgnoreCase) \
|
|
|
|
{ \
|
|
|
|
return AttrHasSuffix(aElement, aNS, aName, aStr, aIgnoreCase); \
|
|
|
|
} \
|
|
|
|
uint32_t prefix_##ClassOrClassList(implementor_ aElement, nsIAtom** aClass, \
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2017-03-22 06:38:12 +03:00
|
|
|
nsIAtom*
|
|
|
|
Gecko_Atomize16(const nsAString* aString)
|
|
|
|
{
|
|
|
|
return NS_Atomize(*aString).take();
|
|
|
|
}
|
|
|
|
|
2016-05-18 22:05:36 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-04-25 09:50:44 +03:00
|
|
|
void
|
|
|
|
Gecko_EnsureMozBorderColors(nsStyleBorder* aBorder)
|
|
|
|
{
|
|
|
|
aBorder->EnsureBorderColors();
|
|
|
|
}
|
|
|
|
|
2016-06-07 22:13:24 +03:00
|
|
|
void
|
2017-10-03 07:27:45 +03:00
|
|
|
Gecko_nsTArray_FontFamilyName_AppendNamed(nsTArray<FontFamilyName>* aNames,
|
|
|
|
nsIAtom* aName,
|
|
|
|
bool aQuoted)
|
2016-06-07 22:13:24 +03:00
|
|
|
{
|
|
|
|
FontFamilyName family;
|
|
|
|
aName->ToString(family.mName);
|
2017-03-30 21:15:57 +03:00
|
|
|
if (aQuoted) {
|
|
|
|
family.mType = eFamily_named_quoted;
|
|
|
|
}
|
|
|
|
|
2017-10-03 07:27:45 +03:00
|
|
|
aNames->AppendElement(family);
|
2016-06-07 22:13:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-10-03 07:27:45 +03:00
|
|
|
Gecko_nsTArray_FontFamilyName_AppendGeneric(nsTArray<FontFamilyName>* aNames,
|
|
|
|
FontFamilyType aType)
|
|
|
|
{
|
|
|
|
aNames->AppendElement(FontFamilyName(aType));
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedFontList*
|
|
|
|
Gecko_SharedFontList_Create()
|
|
|
|
{
|
|
|
|
RefPtr<SharedFontList> fontlist = new SharedFontList();
|
|
|
|
return fontlist.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_DEFINE_MALLOC_SIZE_OF(GeckoSharedFontListMallocSizeOf)
|
|
|
|
|
|
|
|
size_t
|
|
|
|
Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(SharedFontList* aFontlist)
|
2016-06-07 22:13:24 +03:00
|
|
|
{
|
2017-10-03 07:27:45 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
return aFontlist->SizeOfIncludingThisIfUnshared(GeckoSharedFontListMallocSizeOf);
|
2016-06-07 22:13:24 +03:00
|
|
|
}
|
|
|
|
|
2017-10-03 07:27:45 +03:00
|
|
|
size_t
|
|
|
|
Gecko_SharedFontList_SizeOfIncludingThis(SharedFontList* aFontlist)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
return aFontlist->SizeOfIncludingThis(GeckoSharedFontListMallocSizeOf);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(mozilla::SharedFontList, SharedFontList);
|
|
|
|
|
2016-06-07 22:13:24 +03:00
|
|
|
void
|
|
|
|
Gecko_CopyFontFamilyFrom(nsFont* dst, const nsFont* src)
|
|
|
|
{
|
|
|
|
dst->fontlist = src->fontlist;
|
|
|
|
}
|
|
|
|
|
2017-03-22 06:38:12 +03:00
|
|
|
void
|
|
|
|
Gecko_nsFont_InitSystem(nsFont* aDest, int32_t aFontId,
|
|
|
|
const nsStyleFont* aFont, RawGeckoPresContextBorrowed aPresContext)
|
|
|
|
{
|
2017-06-07 03:09:08 +03:00
|
|
|
const nsFont* defaultVariableFont = ThreadSafeGetDefaultFontHelper(aPresContext, aFont->mLanguage,
|
|
|
|
kPresContext_DefaultVariableFont_ID);
|
2017-03-22 06:38:12 +03:00
|
|
|
|
|
|
|
// We have passed uninitialized memory to this function,
|
|
|
|
// initialize it. We can't simply return an nsFont because then
|
|
|
|
// we need to know its size beforehand. Servo cannot initialize nsFont
|
|
|
|
// itself, so this will do.
|
|
|
|
nsFont* system = new (aDest) nsFont(*defaultVariableFont);
|
|
|
|
|
2017-04-19 18:04:38 +03:00
|
|
|
MOZ_RELEASE_ASSERT(system);
|
|
|
|
|
|
|
|
*aDest = *defaultVariableFont;
|
2017-03-22 06:38:12 +03:00
|
|
|
LookAndFeel::FontID fontID = static_cast<LookAndFeel::FontID>(aFontId);
|
2017-06-07 23:57:42 +03:00
|
|
|
|
|
|
|
MutexAutoLock lock(*sServoFontMetricsLock);
|
2017-04-19 18:04:38 +03:00
|
|
|
nsRuleNode::ComputeSystemFont(aDest, fontID, aPresContext, defaultVariableFont);
|
2017-03-22 06:38:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_nsFont_Destroy(nsFont* aDest)
|
|
|
|
{
|
|
|
|
aDest->~nsFont();
|
|
|
|
}
|
|
|
|
|
2017-08-31 03:08:50 +03:00
|
|
|
gfxFontFeatureValueSet*
|
|
|
|
Gecko_ConstructFontFeatureValueSet()
|
|
|
|
{
|
|
|
|
return new gfxFontFeatureValueSet();
|
|
|
|
}
|
|
|
|
|
2017-08-24 04:05:53 +03:00
|
|
|
nsTArray<unsigned int>*
|
|
|
|
Gecko_AppendFeatureValueHashEntry(gfxFontFeatureValueSet* aFontFeatureValues,
|
|
|
|
nsIAtom* aFamily, uint32_t aAlternate, nsIAtom* aName)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
static_assert(sizeof(unsigned int) == sizeof(uint32_t),
|
|
|
|
"sizeof unsigned int and uint32_t must be the same");
|
|
|
|
return aFontFeatureValues->AppendFeatureValueHashEntry(
|
|
|
|
nsDependentAtomString(aFamily),
|
|
|
|
nsDependentAtomString(aName),
|
|
|
|
aAlternate
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_nsFont_SetFontFeatureValuesLookup(nsFont* aFont,
|
|
|
|
const RawGeckoPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
aFont->featureValueLookup = aPresContext->GetFontFeatureValuesLookup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_nsFont_ResetFontFeatureValuesLookup(nsFont* aFont)
|
|
|
|
{
|
|
|
|
aFont->featureValueLookup = nullptr;
|
|
|
|
}
|
|
|
|
|
2017-03-22 06:38:12 +03:00
|
|
|
|
2017-06-28 19:48:56 +03:00
|
|
|
void
|
|
|
|
Gecko_ClearAlternateValues(nsFont* aFont, size_t aLength)
|
|
|
|
{
|
|
|
|
aFont->alternateValues.Clear();
|
|
|
|
aFont->alternateValues.SetCapacity(aLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_AppendAlternateValues(nsFont* aFont, uint32_t aAlternateName, nsIAtom* aAtom)
|
|
|
|
{
|
|
|
|
aFont->alternateValues.AppendElement(gfxAlternateValue {
|
|
|
|
aAlternateName,
|
|
|
|
nsDependentAtomString(aAtom)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CopyAlternateValuesFrom(nsFont* aDest, const nsFont* aSrc)
|
|
|
|
{
|
|
|
|
aDest->alternateValues.Clear();
|
|
|
|
aDest->alternateValues.AppendElements(aSrc->alternateValues);
|
2017-08-24 04:05:53 +03:00
|
|
|
aDest->featureValueLookup = aSrc->featureValueLookup;
|
2017-06-28 19:48:56 +03:00
|
|
|
}
|
|
|
|
|
2017-04-11 11:32:20 +03:00
|
|
|
void
|
|
|
|
Gecko_SetImageOrientation(nsStyleVisibility* aVisibility,
|
2017-07-10 21:32:08 +03:00
|
|
|
uint8_t aOrientation, bool aFlip)
|
2017-04-11 11:32:20 +03:00
|
|
|
{
|
|
|
|
aVisibility->mImageOrientation =
|
2017-07-10 21:32:08 +03:00
|
|
|
nsStyleImageOrientation::CreateAsOrientationAndFlip(aOrientation, aFlip);
|
2017-04-11 11:32:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_SetImageOrientationAsFromImage(nsStyleVisibility* aVisibility)
|
|
|
|
{
|
|
|
|
aVisibility->mImageOrientation = nsStyleImageOrientation::CreateAsFromImage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
|
|
|
|
const nsStyleVisibility* aSrc)
|
|
|
|
{
|
|
|
|
aDst->mImageOrientation = aSrc->mImageOrientation;
|
|
|
|
}
|
|
|
|
|
2016-05-04 03:42:40 +03:00
|
|
|
void
|
2017-06-14 09:39:47 +03:00
|
|
|
Gecko_SetCounterStyleToName(CounterStylePtr* aPtr, nsIAtom* aName,
|
|
|
|
RawGeckoPresContextBorrowed aPresContext)
|
|
|
|
{
|
|
|
|
// Try resolving the counter style if possible, and keep it unresolved
|
|
|
|
// otherwise.
|
|
|
|
CounterStyleManager* manager = aPresContext->CounterStyleManager();
|
2017-09-26 01:33:21 +03:00
|
|
|
RefPtr<nsIAtom> name = already_AddRefed<nsIAtom>(aName);
|
2017-06-14 09:39:47 +03:00
|
|
|
if (CounterStyle* style = manager->GetCounterStyle(name)) {
|
|
|
|
*aPtr = style;
|
|
|
|
} else {
|
|
|
|
*aPtr = name.forget();
|
|
|
|
}
|
2016-05-04 03:42:40 +03:00
|
|
|
}
|
|
|
|
|
2017-05-27 16:33:25 +03:00
|
|
|
void
|
|
|
|
Gecko_SetCounterStyleToSymbols(CounterStylePtr* aPtr, uint8_t aSymbolsType,
|
|
|
|
nsACString const* const* aSymbols,
|
|
|
|
uint32_t aSymbolsCount)
|
|
|
|
{
|
|
|
|
nsTArray<nsString> symbols(aSymbolsCount);
|
|
|
|
for (uint32_t i = 0; i < aSymbolsCount; i++) {
|
|
|
|
symbols.AppendElement(NS_ConvertUTF8toUTF16(*aSymbols[i]));
|
|
|
|
}
|
|
|
|
*aPtr = new AnonymousCounterStyle(aSymbolsType, Move(symbols));
|
|
|
|
}
|
|
|
|
|
2017-05-27 16:33:25 +03:00
|
|
|
void
|
|
|
|
Gecko_SetCounterStyleToString(CounterStylePtr* aPtr, const nsACString* aSymbol)
|
|
|
|
{
|
|
|
|
*aPtr = new AnonymousCounterStyle(NS_ConvertUTF8toUTF16(*aSymbol));
|
|
|
|
}
|
|
|
|
|
2016-05-04 03:42:40 +03:00
|
|
|
void
|
2017-05-27 16:33:25 +03:00
|
|
|
Gecko_CopyCounterStyle(CounterStylePtr* aDst, const CounterStylePtr* aSrc)
|
2016-05-04 03:42:40 +03:00
|
|
|
{
|
2017-05-27 16:33:25 +03:00
|
|
|
*aDst = *aSrc;
|
2016-05-04 03:42:40 +03:00
|
|
|
}
|
|
|
|
|
2017-08-29 10:11:13 +03:00
|
|
|
nsIAtom*
|
|
|
|
Gecko_CounterStyle_GetName(const CounterStylePtr* aPtr)
|
|
|
|
{
|
|
|
|
if (!aPtr->IsResolved()) {
|
|
|
|
return aPtr->AsAtom();
|
|
|
|
}
|
|
|
|
return (*aPtr)->GetStyleName();
|
2017-08-30 11:04:17 +03:00
|
|
|
}
|
|
|
|
|
2017-08-29 10:11:13 +03:00
|
|
|
const AnonymousCounterStyle*
|
|
|
|
Gecko_CounterStyle_GetAnonymous(const CounterStylePtr* aPtr)
|
|
|
|
{
|
|
|
|
return aPtr->AsAnonymous();
|
2017-08-08 04:12:57 +03:00
|
|
|
}
|
|
|
|
|
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-03-30 10:54:48 +03:00
|
|
|
MOZ_ASSERT(mExtraData->GetReferrer());
|
|
|
|
MOZ_ASSERT(mExtraData->GetPrincipal());
|
2016-05-21 03:02:54 +03:00
|
|
|
|
2017-04-14 01:18:25 +03:00
|
|
|
NS_ConvertUTF8toUTF16 url(reinterpret_cast<const char*>(mURLString),
|
|
|
|
mURLStringLength);
|
2016-05-21 03:02:54 +03:00
|
|
|
|
2017-03-30 10:54:48 +03:00
|
|
|
RefPtr<css::URLValue> urlValue =
|
2017-04-14 01:18:25 +03:00
|
|
|
new css::URLValue(url, do_AddRef(mExtraData));
|
2017-02-10 04:43:52 +03:00
|
|
|
return urlValue.forget();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-04-28 16:38:27 +03:00
|
|
|
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::ImageValue, ImageValue);
|
|
|
|
|
2017-05-02 11:20:01 +03:00
|
|
|
static already_AddRefed<nsStyleImageRequest>
|
|
|
|
CreateStyleImageRequest(nsStyleImageRequest::Mode aModeFlags,
|
|
|
|
mozilla::css::ImageValue* aImageValue)
|
|
|
|
{
|
|
|
|
RefPtr<nsStyleImageRequest> req =
|
|
|
|
new nsStyleImageRequest(aModeFlags, aImageValue);
|
|
|
|
return req.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::css::ImageValue*
|
2017-09-15 23:11:37 +03:00
|
|
|
Gecko_ImageValue_Create(ServoBundledURI aURI, ServoRawOffsetArc<RustString> aURIString)
|
2017-05-02 11:20:01 +03:00
|
|
|
{
|
2017-05-19 09:12:34 +03:00
|
|
|
RefPtr<css::ImageValue> value(
|
2017-09-15 23:11:37 +03:00
|
|
|
new css::ImageValue(aURIString, do_AddRef(aURI.mExtraData)));
|
2017-05-02 11:20:01 +03:00
|
|
|
return value.forget().take();
|
|
|
|
}
|
|
|
|
|
2017-09-14 11:48:19 +03:00
|
|
|
MOZ_DEFINE_MALLOC_SIZE_OF(GeckoImageValueMallocSizeOf)
|
|
|
|
|
|
|
|
size_t
|
|
|
|
Gecko_ImageValue_SizeOfIncludingThis(mozilla::css::ImageValue* aImageValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
return aImageValue->SizeOfIncludingThis(GeckoImageValueMallocSizeOf);
|
|
|
|
}
|
|
|
|
|
2017-05-02 11:20:01 +03:00
|
|
|
void
|
|
|
|
Gecko_SetLayerImageImageValue(nsStyleImage* aImage,
|
|
|
|
mozilla::css::ImageValue* aImageValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage && aImageValue);
|
|
|
|
|
|
|
|
RefPtr<nsStyleImageRequest> req =
|
|
|
|
CreateStyleImageRequest(nsStyleImageRequest::Mode::Track, aImageValue);
|
|
|
|
aImage->SetImageRequest(req.forget());
|
|
|
|
}
|
|
|
|
|
2017-04-09 17:02:35 +03:00
|
|
|
void
|
|
|
|
Gecko_SetImageElement(nsStyleImage* aImage, nsIAtom* aAtom) {
|
|
|
|
MOZ_ASSERT(aImage);
|
|
|
|
aImage->SetElementId(do_AddRef(aAtom));
|
|
|
|
}
|
|
|
|
|
2016-05-27 01:18:09 +03:00
|
|
|
void
|
|
|
|
Gecko_CopyImageValueFrom(nsStyleImage* aImage, const nsStyleImage* aOther)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage);
|
|
|
|
MOZ_ASSERT(aOther);
|
|
|
|
|
|
|
|
*aImage = *aOther;
|
|
|
|
}
|
|
|
|
|
2017-03-25 21:48:47 +03:00
|
|
|
void
|
|
|
|
Gecko_InitializeImageCropRect(nsStyleImage* aImage)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage);
|
2017-03-26 20:06:12 +03:00
|
|
|
aImage->SetCropRect(MakeUnique<nsStyleSides>());
|
2017-03-25 21:48:47 +03:00
|
|
|
}
|
|
|
|
|
2016-11-21 09:34:17 +03:00
|
|
|
void
|
|
|
|
Gecko_SetCursorArrayLength(nsStyleUserInterface* aStyleUI, size_t aLen)
|
|
|
|
{
|
|
|
|
aStyleUI->mCursorImages.Clear();
|
|
|
|
aStyleUI->mCursorImages.SetLength(aLen);
|
|
|
|
}
|
|
|
|
|
2017-05-02 11:20:01 +03:00
|
|
|
void
|
|
|
|
Gecko_SetCursorImageValue(nsCursorImage* aCursor,
|
|
|
|
mozilla::css::ImageValue* aImageValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aCursor && aImageValue);
|
|
|
|
|
|
|
|
aCursor->mImage =
|
|
|
|
CreateStyleImageRequest(nsStyleImageRequest::Mode::Discard, aImageValue);
|
|
|
|
}
|
|
|
|
|
2016-11-21 09:34:17 +03:00
|
|
|
void
|
|
|
|
Gecko_CopyCursorArrayFrom(nsStyleUserInterface* aDest,
|
|
|
|
const nsStyleUserInterface* aSrc)
|
|
|
|
{
|
|
|
|
aDest->mCursorImages = aSrc->mCursorImages;
|
|
|
|
}
|
|
|
|
|
2017-05-02 11:20:01 +03:00
|
|
|
void
|
|
|
|
Gecko_SetContentDataImageValue(nsStyleContentData* aContent,
|
|
|
|
mozilla::css::ImageValue* aImageValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aContent && aImageValue);
|
|
|
|
|
|
|
|
RefPtr<nsStyleImageRequest> req =
|
|
|
|
CreateStyleImageRequest(nsStyleImageRequest::Mode::Track, aImageValue);
|
|
|
|
aContent->SetImageRequest(req.forget());
|
|
|
|
}
|
|
|
|
|
2017-05-22 17:32:05 +03:00
|
|
|
nsStyleContentData::CounterFunction*
|
|
|
|
Gecko_SetCounterFunction(nsStyleContentData* aContent, nsStyleContentType aType)
|
|
|
|
{
|
|
|
|
RefPtr<nsStyleContentData::CounterFunction>
|
|
|
|
counterFunc = new nsStyleContentData::CounterFunction();
|
|
|
|
nsStyleContentData::CounterFunction* ptr = counterFunc;
|
|
|
|
aContent->SetCounters(aType, counterFunc.forget());
|
|
|
|
return ptr;
|
2017-03-12 09:40:54 +03:00
|
|
|
}
|
|
|
|
|
2016-05-27 01:18:09 +03:00
|
|
|
nsStyleGradient*
|
|
|
|
Gecko_CreateGradient(uint8_t aShape,
|
|
|
|
uint8_t aSize,
|
|
|
|
bool aRepeating,
|
|
|
|
bool aLegacySyntax,
|
2017-07-01 09:30:48 +03:00
|
|
|
bool aMozLegacySyntax,
|
2016-05-27 01:18:09 +03:00
|
|
|
uint32_t aStopCount)
|
|
|
|
{
|
|
|
|
nsStyleGradient* result = new nsStyleGradient();
|
|
|
|
|
|
|
|
result->mShape = aShape;
|
|
|
|
result->mSize = aSize;
|
|
|
|
result->mRepeating = aRepeating;
|
|
|
|
result->mLegacySyntax = aLegacySyntax;
|
2017-07-01 09:30:48 +03:00
|
|
|
result->mMozLegacySyntax = aMozLegacySyntax;
|
2016-05-27 01:18:09 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-07-05 07:53:47 +03:00
|
|
|
const mozilla::css::URLValueData*
|
|
|
|
Gecko_GetURLValue(const nsStyleImage* aImage)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage && aImage->GetType() == eStyleImageType_Image);
|
|
|
|
return aImage->GetURLValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
Gecko_GetImageElement(const nsStyleImage* aImage)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage && aImage->GetType() == eStyleImageType_Element);
|
|
|
|
return const_cast<nsIAtom*>(aImage->GetElementId());
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsStyleGradient*
|
|
|
|
Gecko_GetGradientImageValue(const nsStyleImage* aImage)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage && aImage->GetType() == eStyleImageType_Gradient);
|
|
|
|
return aImage->GetGradientData();
|
|
|
|
}
|
|
|
|
|
2016-11-03 04:40:53 +03:00
|
|
|
void
|
|
|
|
Gecko_SetListStyleImageNone(nsStyleList* aList)
|
|
|
|
{
|
|
|
|
aList->mListStyleImage = nullptr;
|
|
|
|
}
|
|
|
|
|
2017-05-02 11:20:01 +03:00
|
|
|
void
|
|
|
|
Gecko_SetListStyleImageImageValue(nsStyleList* aList,
|
|
|
|
mozilla::css::ImageValue* aImageValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aList && aImageValue);
|
|
|
|
|
|
|
|
aList->mListStyleImage =
|
|
|
|
CreateStyleImageRequest(nsStyleImageRequest::Mode(0), aImageValue);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-08-09 04:30:25 +03:00
|
|
|
void Gecko_ResizeTArrayForStrings(nsTArray<nsString>* aArray, uint32_t aLength)
|
2017-05-18 20:56:21 +03:00
|
|
|
{
|
2017-08-09 04:30:25 +03:00
|
|
|
aArray->SetLength(aLength);
|
2017-05-18 20:56:21 +03:00
|
|
|
}
|
|
|
|
|
2017-08-09 04:30:25 +03:00
|
|
|
void
|
|
|
|
Gecko_SetStyleGridTemplate(UniquePtr<nsStyleGridTemplate>* aGridTemplate,
|
|
|
|
nsStyleGridTemplate* aValue)
|
2017-06-11 17:17:55 +03:00
|
|
|
{
|
2017-08-09 04:30:25 +03:00
|
|
|
aGridTemplate->reset(aValue);
|
2017-06-11 17:17:55 +03:00
|
|
|
}
|
|
|
|
|
2017-08-09 04:30:25 +03:00
|
|
|
nsStyleGridTemplate*
|
|
|
|
Gecko_CreateStyleGridTemplate(uint32_t aTrackSizes, uint32_t aNameSize)
|
2017-05-18 20:56:21 +03:00
|
|
|
{
|
2017-08-09 04:30:25 +03:00
|
|
|
nsStyleGridTemplate* result = new nsStyleGridTemplate;
|
|
|
|
result->mMinTrackSizingFunctions.SetLength(aTrackSizes);
|
|
|
|
result->mMaxTrackSizingFunctions.SetLength(aTrackSizes);
|
|
|
|
result->mLineNameLists.SetLength(aNameSize);
|
|
|
|
return result;
|
2017-05-18 20:56:21 +03:00
|
|
|
}
|
|
|
|
|
2017-04-08 10:17:34 +03:00
|
|
|
void
|
2017-08-09 04:30:25 +03:00
|
|
|
Gecko_CopyStyleGridTemplateValues(UniquePtr<nsStyleGridTemplate>* aGridTemplate,
|
2017-04-08 10:17:34 +03:00
|
|
|
const nsStyleGridTemplate* aOther)
|
|
|
|
{
|
2017-08-09 04:30:25 +03:00
|
|
|
if (aOther) {
|
|
|
|
*aGridTemplate = MakeUnique<nsStyleGridTemplate>(*aOther);
|
|
|
|
} else {
|
|
|
|
*aGridTemplate = nullptr;
|
|
|
|
}
|
2017-04-08 10:17:34 +03:00
|
|
|
}
|
|
|
|
|
2017-05-04 13:24:01 +03:00
|
|
|
mozilla::css::GridTemplateAreasValue*
|
|
|
|
Gecko_NewGridTemplateAreasValue(uint32_t aAreas, uint32_t aTemplates, uint32_t aColumns)
|
|
|
|
{
|
|
|
|
RefPtr<mozilla::css::GridTemplateAreasValue> value = new mozilla::css::GridTemplateAreasValue;
|
|
|
|
value->mNamedAreas.SetLength(aAreas);
|
|
|
|
value->mTemplates.SetLength(aTemplates);
|
|
|
|
value->mNColumns = aColumns;
|
|
|
|
return value.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::GridTemplateAreasValue, GridTemplateAreasValue);
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-13 07:11:52 +03:00
|
|
|
void
|
|
|
|
Gecko_ClearAndResizeCounterIncrements(nsStyleContent* aContent, uint32_t aHowMany)
|
|
|
|
{
|
|
|
|
aContent->AllocateCounterIncrements(aHowMany);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CopyCounterIncrementsFrom(nsStyleContent* aContent, const nsStyleContent* aOther)
|
|
|
|
{
|
|
|
|
uint32_t count = aOther->CounterIncrementCount();
|
|
|
|
|
|
|
|
aContent->AllocateCounterIncrements(count);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < count; ++i) {
|
|
|
|
const nsStyleCounterData& data = aOther->CounterIncrementAt(i);
|
|
|
|
aContent->SetCounterIncrementAt(i, data.mCounter, data.mValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_ClearAndResizeCounterResets(nsStyleContent* aContent, uint32_t aHowMany)
|
|
|
|
{
|
|
|
|
aContent->AllocateCounterResets(aHowMany);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CopyCounterResetsFrom(nsStyleContent* aContent, const nsStyleContent* aOther)
|
|
|
|
{
|
|
|
|
uint32_t count = aOther->CounterResetCount();
|
|
|
|
|
|
|
|
aContent->AllocateCounterResets(count);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < count; ++i) {
|
|
|
|
const nsStyleCounterData& data = aOther->CounterResetAt(i);
|
|
|
|
aContent->SetCounterResetAt(i, data.mCounter, data.mValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 =
|
2017-04-06 04:34:51 +03:00
|
|
|
static_cast<nsStyleAutoArray<StyleAnimation>*>(aArray);
|
2017-01-06 15:45:16 +03:00
|
|
|
|
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-03-19 15:36:16 +03:00
|
|
|
void
|
|
|
|
Gecko_ClearWillChange(nsStyleDisplay* aDisplay, size_t aLength)
|
|
|
|
{
|
|
|
|
aDisplay->mWillChange.Clear();
|
|
|
|
aDisplay->mWillChange.SetCapacity(aLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_AppendWillChange(nsStyleDisplay* aDisplay, nsIAtom* aAtom)
|
|
|
|
{
|
|
|
|
aDisplay->mWillChange.AppendElement(aAtom);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CopyWillChangeFrom(nsStyleDisplay* aDest, nsStyleDisplay* aSrc)
|
|
|
|
{
|
|
|
|
aDest->mWillChange.Clear();
|
|
|
|
aDest->mWillChange.AppendElements(aSrc->mWillChange);
|
|
|
|
}
|
|
|
|
|
2017-05-13 10:34:38 +03:00
|
|
|
enum class KeyframeSearchDirection {
|
|
|
|
Forwards,
|
|
|
|
Backwards,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class KeyframeInsertPosition {
|
|
|
|
Prepend,
|
|
|
|
LastForOffset,
|
|
|
|
};
|
|
|
|
|
|
|
|
static Keyframe*
|
|
|
|
GetOrCreateKeyframe(nsTArray<Keyframe>* aKeyframes,
|
|
|
|
float aOffset,
|
|
|
|
const nsTimingFunction* aTimingFunction,
|
|
|
|
KeyframeSearchDirection aSearchDirection,
|
|
|
|
KeyframeInsertPosition aInsertPosition)
|
2017-05-13 10:34:38 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aKeyframes, "The keyframe array should be valid");
|
|
|
|
MOZ_ASSERT(aTimingFunction, "The timing function should be valid");
|
|
|
|
MOZ_ASSERT(aOffset >= 0. && aOffset <= 1.,
|
|
|
|
"The offset should be in the range of [0.0, 1.0]");
|
|
|
|
|
|
|
|
size_t keyframeIndex;
|
2017-05-13 10:34:38 +03:00
|
|
|
switch (aSearchDirection) {
|
|
|
|
case KeyframeSearchDirection::Forwards:
|
|
|
|
if (nsAnimationManager::FindMatchingKeyframe(*aKeyframes,
|
|
|
|
aOffset,
|
|
|
|
*aTimingFunction,
|
|
|
|
keyframeIndex)) {
|
|
|
|
return &(*aKeyframes)[keyframeIndex];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KeyframeSearchDirection::Backwards:
|
|
|
|
if (nsAnimationManager::FindMatchingKeyframe(Reversed(*aKeyframes),
|
|
|
|
aOffset,
|
|
|
|
*aTimingFunction,
|
|
|
|
keyframeIndex)) {
|
|
|
|
return &(*aKeyframes)[aKeyframes->Length() - 1 - keyframeIndex];
|
|
|
|
}
|
|
|
|
keyframeIndex = aKeyframes->Length() - 1;
|
|
|
|
break;
|
2017-05-13 10:34:38 +03:00
|
|
|
}
|
|
|
|
|
2017-05-13 10:34:38 +03:00
|
|
|
Keyframe* keyframe =
|
|
|
|
aKeyframes->InsertElementAt(
|
|
|
|
aInsertPosition == KeyframeInsertPosition::Prepend
|
|
|
|
? 0
|
|
|
|
: keyframeIndex);
|
2017-05-13 10:34:38 +03:00
|
|
|
keyframe->mOffset.emplace(aOffset);
|
|
|
|
if (aTimingFunction->mType != nsTimingFunction::Type::Linear) {
|
|
|
|
keyframe->mTimingFunction.emplace();
|
|
|
|
keyframe->mTimingFunction->Init(*aTimingFunction);
|
|
|
|
}
|
|
|
|
|
|
|
|
return keyframe;
|
|
|
|
}
|
|
|
|
|
2017-05-13 10:34:38 +03:00
|
|
|
Keyframe*
|
|
|
|
Gecko_GetOrCreateKeyframeAtStart(nsTArray<Keyframe>* aKeyframes,
|
|
|
|
float aOffset,
|
|
|
|
const nsTimingFunction* aTimingFunction)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aKeyframes->IsEmpty() ||
|
|
|
|
aKeyframes->ElementAt(0).mOffset.value() >= aOffset,
|
|
|
|
"The offset should be less than or equal to the first keyframe's "
|
|
|
|
"offset if there are exisiting keyframes");
|
|
|
|
|
|
|
|
return GetOrCreateKeyframe(aKeyframes,
|
|
|
|
aOffset,
|
|
|
|
aTimingFunction,
|
|
|
|
KeyframeSearchDirection::Forwards,
|
|
|
|
KeyframeInsertPosition::Prepend);
|
|
|
|
}
|
|
|
|
|
|
|
|
Keyframe*
|
|
|
|
Gecko_GetOrCreateInitialKeyframe(nsTArray<Keyframe>* aKeyframes,
|
|
|
|
const nsTimingFunction* aTimingFunction)
|
|
|
|
{
|
|
|
|
return GetOrCreateKeyframe(aKeyframes,
|
|
|
|
0.,
|
|
|
|
aTimingFunction,
|
|
|
|
KeyframeSearchDirection::Forwards,
|
|
|
|
KeyframeInsertPosition::LastForOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
Keyframe*
|
|
|
|
Gecko_GetOrCreateFinalKeyframe(nsTArray<Keyframe>* aKeyframes,
|
|
|
|
const nsTimingFunction* aTimingFunction)
|
|
|
|
{
|
|
|
|
return GetOrCreateKeyframe(aKeyframes,
|
|
|
|
1.,
|
|
|
|
aTimingFunction,
|
|
|
|
KeyframeSearchDirection::Backwards,
|
|
|
|
KeyframeInsertPosition::LastForOffset);
|
|
|
|
}
|
|
|
|
|
2017-07-20 08:38:54 +03:00
|
|
|
PropertyValuePair*
|
|
|
|
Gecko_AppendPropertyValuePair(nsTArray<PropertyValuePair>* aProperties,
|
|
|
|
nsCSSPropertyID aProperty)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aProperties);
|
|
|
|
return aProperties->AppendElement(PropertyValuePair {aProperty});
|
|
|
|
}
|
|
|
|
|
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-04-12 15:52:38 +03:00
|
|
|
Gecko_CopyShapeSourceFrom(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-04-12 15:52:38 +03:00
|
|
|
Gecko_DestroyShapeSource(mozilla::StyleShapeSource* aShape)
|
2016-08-15 18:48:11 +03:00
|
|
|
{
|
2017-04-12 15:52:38 +03:00
|
|
|
aShape->~StyleShapeSource();
|
2016-08-15 18:48:11 +03:00
|
|
|
}
|
|
|
|
|
2017-02-10 04:43:52 +03:00
|
|
|
void
|
2017-04-12 15:52:38 +03:00
|
|
|
Gecko_StyleShapeSource_SetURLValue(mozilla::StyleShapeSource* aShape, ServoBundledURI aURI)
|
2017-02-10 04:43:52 +03:00
|
|
|
{
|
|
|
|
RefPtr<css::URLValue> url = aURI.IntoCssUrl();
|
2017-04-12 15:52:38 +03:00
|
|
|
aShape->SetURL(url.get());
|
2017-02-10 04:43:52 +03:00
|
|
|
}
|
|
|
|
|
2017-09-25 13:50:24 +03:00
|
|
|
void
|
|
|
|
Gecko_NewBasicShape(mozilla::StyleShapeSource* aShape,
|
|
|
|
mozilla::StyleBasicShapeType aType)
|
2016-08-15 18:48:11 +03:00
|
|
|
{
|
2017-09-25 13:50:24 +03:00
|
|
|
aShape->SetBasicShape(MakeUnique<mozilla::StyleBasicShape>(aType),
|
|
|
|
StyleGeometryBox::NoBox);
|
2016-08-15 18:48:11 +03:00
|
|
|
}
|
|
|
|
|
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();
|
2017-05-03 00:12:59 +03:00
|
|
|
aPaint->SetPaintServer(url.get());
|
2017-02-10 04:43:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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-05-24 04:15:47 +03:00
|
|
|
void
|
|
|
|
Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* aSvg, uint32_t aLen)
|
|
|
|
{
|
|
|
|
aSvg->mContextProps.Clear();
|
|
|
|
aSvg->mContextProps.SetLength(aLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* aDst, const nsStyleSVG* aSrc)
|
|
|
|
{
|
|
|
|
aDst->mContextProps = aSrc->mContextProps;
|
|
|
|
aDst->mContextPropsBits = aSrc->mContextPropsBits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2017-04-04 03:04:13 +03:00
|
|
|
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(URLExtraData, URLExtraData);
|
2017-03-30 10:54:48 +03:00
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2017-05-19 11:09:45 +03:00
|
|
|
nsCSSValueSharedList*
|
|
|
|
Gecko_NewNoneTransform()
|
|
|
|
{
|
|
|
|
RefPtr<nsCSSValueSharedList> list = new nsCSSValueSharedList;
|
|
|
|
list->mHead = new nsCSSValueList;
|
|
|
|
list->mHead->mValue.SetNoneValue();
|
|
|
|
return list.forget().take();
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2017-09-13 09:27:25 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetPixelLength(nsCSSValueBorrowedMut aCSSValue, float aLen)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null ||
|
|
|
|
aCSSValue->GetUnit() == eCSSUnit_Pixel);
|
|
|
|
aCSSValue->SetFloatValue(aLen, eCSSUnit_Pixel);
|
|
|
|
}
|
|
|
|
|
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
|
2017-03-28 03:52:14 +03:00
|
|
|
Gecko_CSSValue_SetString(nsCSSValueBorrowedMut aCSSValue,
|
|
|
|
const uint8_t* aString, uint32_t aLength,
|
|
|
|
nsCSSUnit aUnit)
|
2017-03-12 09:40:54 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
|
|
|
|
nsString string;
|
|
|
|
nsDependentCSubstring slice(reinterpret_cast<const char*>(aString),
|
|
|
|
aLength);
|
|
|
|
AppendUTF8toUTF16(slice, string);
|
2017-03-28 03:52:14 +03:00
|
|
|
aCSSValue->SetStringValue(string, aUnit);
|
2017-03-12 09:40:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-03-28 03:52:14 +03:00
|
|
|
Gecko_CSSValue_SetStringFromAtom(nsCSSValueBorrowedMut aCSSValue,
|
|
|
|
nsIAtom* aAtom, nsCSSUnit aUnit)
|
2017-02-18 02:15:55 +03:00
|
|
|
{
|
2017-03-28 03:52:14 +03:00
|
|
|
aCSSValue->SetStringValue(nsDependentAtomString(aAtom), aUnit);
|
2017-02-18 02:15:55 +03:00
|
|
|
}
|
|
|
|
|
2017-05-05 14:56:57 +03:00
|
|
|
void
|
2017-05-21 22:55:08 +03:00
|
|
|
Gecko_CSSValue_SetAtomIdent(nsCSSValueBorrowedMut aCSSValue, nsIAtom* aAtom)
|
2017-05-05 14:56:57 +03:00
|
|
|
{
|
2017-05-21 22:55:08 +03:00
|
|
|
aCSSValue->SetAtomIdentValue(already_AddRefed<nsIAtom>(aAtom));
|
2017-05-05 14:56:57 +03:00
|
|
|
}
|
|
|
|
|
2017-02-18 02:15:55 +03:00
|
|
|
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
|
2017-03-28 03:52:14 +03:00
|
|
|
Gecko_CSSValue_SetInt(nsCSSValueBorrowedMut aCSSValue,
|
|
|
|
int32_t aInteger, nsCSSUnit aUnit)
|
2017-02-18 02:15:55 +03:00
|
|
|
{
|
2017-03-28 03:52:14 +03:00
|
|
|
aCSSValue->SetIntValue(aInteger, aUnit);
|
2017-02-18 02:15:55 +03:00
|
|
|
}
|
|
|
|
|
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-05-09 15:36:03 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetPair(nsCSSValueBorrowedMut aCSSValue,
|
|
|
|
nsCSSValueBorrowed aXValue, nsCSSValueBorrowed aYValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
aCSSValue->SetPairValue(*aXValue, *aYValue);
|
|
|
|
}
|
|
|
|
|
2017-05-15 07:20:52 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetList(nsCSSValueBorrowedMut aCSSValue, uint32_t aLen)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
nsCSSValueList* item = aCSSValue->SetListValue();
|
|
|
|
for (uint32_t i = 1; i < aLen; ++i) {
|
|
|
|
item->mNext = new nsCSSValueList;
|
|
|
|
item = item->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_CSSValue_SetPairList(nsCSSValueBorrowedMut aCSSValue, uint32_t aLen)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
nsCSSValuePairList* item = aCSSValue->SetPairListValue();
|
|
|
|
for (uint32_t i = 1; i < aLen; ++i) {
|
|
|
|
item->mNext = new nsCSSValuePairList;
|
|
|
|
item = item->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-07 06:21:01 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSValue_InitSharedList(nsCSSValueBorrowedMut aCSSValue,
|
|
|
|
uint32_t aLen)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aLen > 0, "Must create at least one nsCSSValueList (mHead)");
|
|
|
|
|
|
|
|
nsCSSValueSharedList* list = new nsCSSValueSharedList;
|
|
|
|
aCSSValue->SetSharedListValue(list);
|
|
|
|
list->mHead = new nsCSSValueList;
|
|
|
|
nsCSSValueList* cur = list->mHead;
|
|
|
|
for (uint32_t i = 1; i < aLen; ++i) {
|
|
|
|
cur->mNext = new nsCSSValueList;
|
|
|
|
cur = cur->mNext;
|
|
|
|
}
|
|
|
|
}
|
2017-01-10 03:05:18 +03:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-04-22 02:10:50 +03:00
|
|
|
void
|
|
|
|
Gecko_nsStyleFont_FixupNoneGeneric(nsStyleFont* aFont,
|
|
|
|
RawGeckoPresContextBorrowed aPresContext)
|
|
|
|
{
|
2017-06-07 03:09:08 +03:00
|
|
|
const nsFont* defaultVariableFont = ThreadSafeGetDefaultFontHelper(aPresContext, aFont->mLanguage,
|
|
|
|
kPresContext_DefaultVariableFont_ID);
|
2017-04-22 02:10:50 +03:00
|
|
|
nsRuleNode::FixupNoneGeneric(&aFont->mFont, aPresContext,
|
|
|
|
aFont->mGenericID, defaultVariableFont);
|
|
|
|
}
|
|
|
|
|
2017-06-07 03:09:08 +03:00
|
|
|
void
|
|
|
|
Gecko_nsStyleFont_PrefillDefaultForGeneric(nsStyleFont* aFont,
|
|
|
|
RawGeckoPresContextBorrowed aPresContext,
|
|
|
|
uint8_t aGenericId)
|
|
|
|
{
|
|
|
|
const nsFont* defaultFont = ThreadSafeGetDefaultFontHelper(aPresContext, aFont->mLanguage,
|
|
|
|
aGenericId);
|
2017-08-19 00:42:13 +03:00
|
|
|
// In case of just the language changing, the parent could have had no generic,
|
|
|
|
// which Gecko just does regular cascading with. Do the same.
|
|
|
|
// This can only happen in the case where the language changed but the family did not
|
|
|
|
if (aGenericId != kGenericFont_NONE) {
|
|
|
|
aFont->mFont.fontlist = defaultFont->fontlist;
|
|
|
|
} else {
|
|
|
|
aFont->mFont.fontlist.SetDefaultFontType(defaultFont->fontlist.GetDefaultFontType());
|
|
|
|
}
|
2017-06-07 03:09:08 +03:00
|
|
|
}
|
|
|
|
|
2017-05-24 04:15:47 +03:00
|
|
|
void
|
|
|
|
Gecko_nsStyleFont_FixupMinFontSize(nsStyleFont* aFont,
|
|
|
|
RawGeckoPresContextBorrowed aPresContext)
|
|
|
|
{
|
|
|
|
nscoord minFontSize;
|
|
|
|
bool needsCache = false;
|
|
|
|
|
|
|
|
{
|
|
|
|
AutoReadLock guard(*sServoLangFontPrefsLock);
|
|
|
|
minFontSize = aPresContext->MinFontSize(aFont->mLanguage, &needsCache);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needsCache) {
|
|
|
|
AutoWriteLock guard(*sServoLangFontPrefsLock);
|
|
|
|
minFontSize = aPresContext->MinFontSize(aFont->mLanguage, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRuleNode::ApplyMinFontSize(aFont, aPresContext, minFontSize);
|
|
|
|
}
|
|
|
|
|
2017-04-04 21:11:27 +03:00
|
|
|
void
|
|
|
|
FontSizePrefs::CopyFrom(const LangGroupFontPrefs& prefs)
|
2017-03-18 05:48:20 +03:00
|
|
|
{
|
2017-04-04 21:11:27 +03:00
|
|
|
mDefaultVariableSize = prefs.mDefaultVariableFont.size;
|
|
|
|
mDefaultFixedSize = prefs.mDefaultFixedFont.size;
|
|
|
|
mDefaultSerifSize = prefs.mDefaultSerifFont.size;
|
|
|
|
mDefaultSansSerifSize = prefs.mDefaultSansSerifFont.size;
|
|
|
|
mDefaultMonospaceSize = prefs.mDefaultMonospaceFont.size;
|
|
|
|
mDefaultCursiveSize = prefs.mDefaultCursiveFont.size;
|
|
|
|
mDefaultFantasySize = prefs.mDefaultFantasyFont.size;
|
|
|
|
}
|
|
|
|
|
|
|
|
FontSizePrefs
|
|
|
|
Gecko_GetBaseSize(nsIAtom* aLanguage)
|
|
|
|
{
|
|
|
|
LangGroupFontPrefs prefs;
|
2017-09-26 01:33:21 +03:00
|
|
|
RefPtr<nsIAtom> langGroupAtom = StaticPresData::Get()->GetUncachedLangGroup(aLanguage);
|
2017-04-04 21:11:27 +03:00
|
|
|
|
|
|
|
prefs.Initialize(langGroupAtom);
|
|
|
|
FontSizePrefs sizes;
|
|
|
|
sizes.CopyFrom(prefs);
|
|
|
|
|
|
|
|
return sizes;
|
2017-03-18 05:48:20 +03:00
|
|
|
}
|
|
|
|
|
2017-06-05 09:00:27 +03:00
|
|
|
RawGeckoElementBorrowedOrNull
|
|
|
|
Gecko_GetBindingParent(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
nsIContent* parent = aElement->GetBindingParent();
|
|
|
|
return parent ? parent->AsElement() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
RawGeckoXBLBindingBorrowedOrNull
|
|
|
|
Gecko_GetXBLBinding(RawGeckoElementBorrowed aElement)
|
|
|
|
{
|
|
|
|
return aElement->GetXBLBinding();
|
|
|
|
}
|
|
|
|
|
|
|
|
RawServoStyleSetBorrowedOrNull
|
|
|
|
Gecko_XBLBinding_GetRawServoStyleSet(RawGeckoXBLBindingBorrowed aXBLBinding)
|
|
|
|
{
|
|
|
|
const ServoStyleSet* set = aXBLBinding->GetServoStyleSet();
|
|
|
|
return set ? set->RawSet() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Gecko_XBLBinding_InheritsStyle(RawGeckoXBLBindingBorrowed aXBLBinding)
|
|
|
|
{
|
|
|
|
return aXBLBinding->InheritsStyle();
|
|
|
|
}
|
|
|
|
|
2017-09-20 14:17:27 +03:00
|
|
|
static StaticRefPtr<UACacheReporter> gUACacheReporter;
|
Bug 1400078 - Measure the UA cache. r=njn.
ServoStyleSetSizes now has two uses, one for the Stylist, and one for the UA
cache, and so the patch removes 'Stylist' from the field names.
Example output from about:memory:
> +----1,359,608 B (00.55%) -- layout
> | +----756,488 B (00.31%) -- style-sheet-cache [2]
> | +----393,968 B (00.16%) -- servo-ua-cache
> | | +--234,496 B (00.10%) -- element-and-pseudos-maps
> | | +---59,648 B (00.02%) -- revalidation-selectors
> | | +---58,320 B (00.02%) -- invalidation-map
> | | +---30,752 B (00.01%) -- other
> | | +---10,752 B (00.00%) -- precomputed-pseudos
MozReview-Commit-ID: 8oxuJO0ojp
--HG--
extra : rebase_source : 7d86216967259b71df7280261d025cc65bf00ba4
2017-09-19 02:25:00 +03:00
|
|
|
|
2017-04-08 01:49:44 +03:00
|
|
|
void
|
|
|
|
InitializeServo()
|
|
|
|
{
|
|
|
|
URLExtraData::InitDummy();
|
|
|
|
Servo_Initialize(URLExtraData::Dummy());
|
|
|
|
|
2017-09-20 14:17:27 +03:00
|
|
|
gUACacheReporter = new UACacheReporter();
|
|
|
|
RegisterWeakMemoryReporter(gUACacheReporter);
|
Bug 1400078 - Measure the UA cache. r=njn.
ServoStyleSetSizes now has two uses, one for the Stylist, and one for the UA
cache, and so the patch removes 'Stylist' from the field names.
Example output from about:memory:
> +----1,359,608 B (00.55%) -- layout
> | +----756,488 B (00.31%) -- style-sheet-cache [2]
> | +----393,968 B (00.16%) -- servo-ua-cache
> | | +--234,496 B (00.10%) -- element-and-pseudos-maps
> | | +---59,648 B (00.02%) -- revalidation-selectors
> | | +---58,320 B (00.02%) -- invalidation-map
> | | +---30,752 B (00.01%) -- other
> | | +---10,752 B (00.00%) -- precomputed-pseudos
MozReview-Commit-ID: 8oxuJO0ojp
--HG--
extra : rebase_source : 7d86216967259b71df7280261d025cc65bf00ba4
2017-09-19 02:25:00 +03:00
|
|
|
|
2017-04-08 01:49:44 +03:00
|
|
|
sServoFontMetricsLock = new Mutex("Gecko_GetFontMetrics");
|
2017-08-19 01:56:01 +03:00
|
|
|
sServoWidgetLock = new Mutex("Servo::WidgetLock");
|
2017-05-26 01:04:13 +03:00
|
|
|
sServoLangFontPrefsLock = new RWLock("nsPresContext::GetDefaultFont");
|
2017-04-08 01:49:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShutdownServo()
|
|
|
|
{
|
2017-08-19 01:56:01 +03:00
|
|
|
MOZ_ASSERT(sServoFontMetricsLock);
|
|
|
|
MOZ_ASSERT(sServoWidgetLock);
|
|
|
|
MOZ_ASSERT(sServoLangFontPrefsLock);
|
|
|
|
|
2017-09-20 14:17:27 +03:00
|
|
|
UnregisterWeakMemoryReporter(gUACacheReporter);
|
|
|
|
gUACacheReporter = nullptr;
|
Bug 1400078 - Measure the UA cache. r=njn.
ServoStyleSetSizes now has two uses, one for the Stylist, and one for the UA
cache, and so the patch removes 'Stylist' from the field names.
Example output from about:memory:
> +----1,359,608 B (00.55%) -- layout
> | +----756,488 B (00.31%) -- style-sheet-cache [2]
> | +----393,968 B (00.16%) -- servo-ua-cache
> | | +--234,496 B (00.10%) -- element-and-pseudos-maps
> | | +---59,648 B (00.02%) -- revalidation-selectors
> | | +---58,320 B (00.02%) -- invalidation-map
> | | +---30,752 B (00.01%) -- other
> | | +---10,752 B (00.00%) -- precomputed-pseudos
MozReview-Commit-ID: 8oxuJO0ojp
--HG--
extra : rebase_source : 7d86216967259b71df7280261d025cc65bf00ba4
2017-09-19 02:25:00 +03:00
|
|
|
|
2017-04-08 01:49:44 +03:00
|
|
|
delete sServoFontMetricsLock;
|
2017-08-19 01:56:01 +03:00
|
|
|
delete sServoWidgetLock;
|
2017-05-26 01:04:13 +03:00
|
|
|
delete sServoLangFontPrefsLock;
|
2017-04-08 01:49:44 +03:00
|
|
|
Servo_Shutdown();
|
|
|
|
}
|
|
|
|
|
2017-04-30 08:15:42 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
void
|
|
|
|
AssertIsMainThreadOrServoFontMetricsLocked()
|
|
|
|
{
|
|
|
|
if (!NS_IsMainThread()) {
|
|
|
|
MOZ_ASSERT(sServoFontMetricsLock);
|
|
|
|
sServoFontMetricsLock->AssertCurrentThreadOwns();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2017-04-08 01:49:44 +03:00
|
|
|
GeckoFontMetrics
|
|
|
|
Gecko_GetFontMetrics(RawGeckoPresContextBorrowed aPresContext,
|
|
|
|
bool aIsVertical,
|
|
|
|
const nsStyleFont* aFont,
|
|
|
|
nscoord aFontSize,
|
|
|
|
bool aUseUserFontSet)
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(*sServoFontMetricsLock);
|
|
|
|
GeckoFontMetrics ret;
|
2017-04-30 09:51:29 +03:00
|
|
|
|
|
|
|
// Getting font metrics can require some main thread only work to be
|
|
|
|
// done, such as work that needs to touch non-threadsafe refcounted
|
|
|
|
// objects (like the DOM FontFace/FontFaceSet objects), network loads, etc.
|
|
|
|
//
|
|
|
|
// To handle this work, font code checks whether we are in a Servo traversal
|
|
|
|
// and if so, appends PostTraversalTasks to the current ServoStyleSet
|
|
|
|
// to be performed immediately after the traversal is finished. This
|
|
|
|
// works well for starting downloadable font loads, since we don't have
|
|
|
|
// those fonts available to get metrics for anyway. Platform fonts and
|
|
|
|
// ArrayBuffer-backed FontFace objects are handled synchronously.
|
|
|
|
|
2017-04-08 01:49:44 +03:00
|
|
|
nsPresContext* presContext = const_cast<nsPresContext*>(aPresContext);
|
2017-04-08 01:49:44 +03:00
|
|
|
presContext->SetUsesExChUnits(true);
|
2017-09-27 19:09:31 +03:00
|
|
|
RefPtr<nsFontMetrics> fm = nsRuleNode::GetMetricsFor(
|
|
|
|
presContext, aIsVertical, aFont, aFontSize, aUseUserFontSet,
|
|
|
|
nsRuleNode::FlushUserFontSet::No);
|
|
|
|
|
2017-04-08 01:49:44 +03:00
|
|
|
ret.mXSize = fm->XHeight();
|
|
|
|
gfxFloat zeroWidth = fm->GetThebesFontGroup()->GetFirstValidFont()->
|
|
|
|
GetMetrics(fm->Orientation()).zeroOrAveCharWidth;
|
|
|
|
ret.mChSize = ceil(aPresContext->AppUnitsPerDevPixel() * zeroWidth);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-04-25 11:29:46 +03:00
|
|
|
int32_t
|
|
|
|
Gecko_GetAppUnitsPerPhysicalInch(RawGeckoPresContextBorrowed aPresContext)
|
|
|
|
{
|
|
|
|
nsPresContext* presContext = const_cast<nsPresContext*>(aPresContext);
|
|
|
|
return presContext->DeviceContext()->AppUnitsPerPhysicalInch();
|
|
|
|
}
|
|
|
|
|
2017-06-29 20:09:56 +03:00
|
|
|
ServoStyleSheet*
|
2016-12-17 12:58:56 +03:00
|
|
|
Gecko_LoadStyleSheet(css::Loader* aLoader,
|
|
|
|
ServoStyleSheet* aParent,
|
2017-05-26 10:59:01 +03:00
|
|
|
css::LoaderReusableStyleSheets* aReusableSheets,
|
2017-07-28 01:03:42 +03:00
|
|
|
RawGeckoURLExtraData* aURLExtraData,
|
2016-12-17 12:58:56 +03:00
|
|
|
const uint8_t* aURLString,
|
|
|
|
uint32_t aURLStringLength,
|
2017-04-10 06:17:51 +03:00
|
|
|
RawServoMediaListStrong aMediaList)
|
2016-12-17 12:58:56 +03:00
|
|
|
{
|
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!");
|
2017-08-01 00:03:28 +03:00
|
|
|
MOZ_ASSERT(aURLExtraData, "Need URL extra data");
|
2016-12-17 12:58:56 +03:00
|
|
|
|
2017-06-29 20:09:56 +03:00
|
|
|
RefPtr<dom::MediaList> media = new ServoMediaList(aMediaList.Consume());
|
2016-12-17 12:58:56 +03:00
|
|
|
nsDependentCSubstring urlSpec(reinterpret_cast<const char*>(aURLString),
|
|
|
|
aURLStringLength);
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
2017-03-30 10:54:48 +03:00
|
|
|
nsresult rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nullptr,
|
2017-07-28 01:03:42 +03:00
|
|
|
aURLExtraData->BaseURI());
|
2017-01-03 13:35:15 +03:00
|
|
|
|
2017-06-29 20:09:56 +03:00
|
|
|
StyleSheet* previousFirstChild = aParent->GetFirstChild();
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = aLoader->LoadChildSheet(aParent, uri, media, nullptr, aReusableSheets);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FAILED(rv) ||
|
|
|
|
!aParent->GetFirstChild() ||
|
|
|
|
aParent->GetFirstChild() == previousFirstChild) {
|
2017-01-03 13:35:15 +03:00
|
|
|
// Servo and Gecko have different ideas of what a valid URL is, so we might
|
2017-07-28 01:03:42 +03:00
|
|
|
// get in here with a URL string that NS_NewURI can't handle. We may also
|
|
|
|
// reach here via an import cycle. For the import cycle case, we need some
|
|
|
|
// sheet object per spec, even if its empty. DevTools uses the URI to
|
|
|
|
// realize it has hit an import cycle, so we mark it complete to make the
|
|
|
|
// sheet readable from JS.
|
2017-06-29 20:09:56 +03:00
|
|
|
RefPtr<ServoStyleSheet> emptySheet =
|
|
|
|
aParent->CreateEmptyChildSheet(media.forget());
|
2017-07-28 01:03:42 +03:00
|
|
|
// Make a dummy URI if we don't have one because some methods assume
|
|
|
|
// non-null URIs.
|
|
|
|
if (!uri) {
|
|
|
|
NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:invalid"));
|
|
|
|
}
|
|
|
|
emptySheet->SetURIs(uri, uri, uri);
|
|
|
|
emptySheet->SetPrincipal(aURLExtraData->GetPrincipal());
|
|
|
|
emptySheet->SetComplete();
|
2017-06-29 20:09:56 +03:00
|
|
|
aParent->PrependStyleSheet(emptySheet);
|
|
|
|
return emptySheet.forget().take();
|
2017-01-03 13:35:15 +03:00
|
|
|
}
|
2016-12-17 12:58:56 +03:00
|
|
|
|
2017-06-29 20:09:56 +03:00
|
|
|
RefPtr<ServoStyleSheet> sheet =
|
|
|
|
static_cast<ServoStyleSheet*>(aParent->GetFirstChild());
|
|
|
|
return sheet.forget().take();
|
2016-12-17 12:58:56 +03:00
|
|
|
}
|
|
|
|
|
2017-04-13 07:24:02 +03:00
|
|
|
nsCSSKeyword
|
|
|
|
Gecko_LookupCSSKeyword(const uint8_t* aString, uint32_t aLength)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsDependentCSubstring keyword(reinterpret_cast<const char*>(aString), aLength);
|
|
|
|
return nsCSSKeywords::LookupKeyword(keyword);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
|
|
|
Gecko_CSSKeywordString(nsCSSKeyword aKeyword, uint32_t* aLength)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(aLength);
|
2017-06-20 12:19:05 +03:00
|
|
|
const nsCString& value = nsCSSKeywords::GetStringValue(aKeyword);
|
2017-04-13 07:24:02 +03:00
|
|
|
*aLength = value.Length();
|
|
|
|
return value.get();
|
|
|
|
}
|
|
|
|
|
2017-03-24 06:42:18 +03:00
|
|
|
nsCSSFontFaceRule*
|
2017-05-15 15:02:13 +03:00
|
|
|
Gecko_CSSFontFaceRule_Create(uint32_t aLine, uint32_t aColumn)
|
2017-03-24 06:42:18 +03:00
|
|
|
{
|
2017-05-15 15:02:13 +03:00
|
|
|
RefPtr<nsCSSFontFaceRule> rule = new nsCSSFontFaceRule(aLine, aColumn);
|
2017-03-24 06:42:18 +03:00
|
|
|
return rule.forget().take();
|
|
|
|
}
|
|
|
|
|
2017-05-23 03:21:09 +03:00
|
|
|
nsCSSFontFaceRule*
|
|
|
|
Gecko_CSSFontFaceRule_Clone(const nsCSSFontFaceRule* aRule)
|
|
|
|
{
|
|
|
|
RefPtr<css::Rule> rule = aRule->Clone();
|
|
|
|
return static_cast<nsCSSFontFaceRule*>(rule.forget().take());
|
|
|
|
}
|
|
|
|
|
2017-03-24 06:42:18 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSFontFaceRule_GetCssText(const nsCSSFontFaceRule* aRule,
|
|
|
|
nsAString* aResult)
|
|
|
|
{
|
2017-04-20 23:33:12 +03:00
|
|
|
// GetCSSText serializes nsCSSValues, which have a heap write
|
|
|
|
// hazard when dealing with color values (nsCSSKeywords::AddRefTable)
|
|
|
|
// We only serialize on the main thread; assert to convince the analysis
|
|
|
|
// and prevent accidentally calling this elsewhere
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2017-03-24 06:42:18 +03:00
|
|
|
aRule->GetCssText(*aResult);
|
|
|
|
}
|
|
|
|
|
2017-05-19 10:58:47 +03:00
|
|
|
void
|
|
|
|
Gecko_AddPropertyToSet(nsCSSPropertyIDSetBorrowedMut aPropertySet,
|
|
|
|
nsCSSPropertyID aProperty)
|
|
|
|
{
|
|
|
|
aPropertySet->AddProperty(aProperty);
|
|
|
|
}
|
|
|
|
|
2017-06-01 04:03:33 +03:00
|
|
|
int32_t
|
|
|
|
Gecko_RegisterNamespace(nsIAtom* aNamespace)
|
|
|
|
{
|
|
|
|
int32_t id;
|
|
|
|
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsAutoString str;
|
|
|
|
aNamespace->ToString(str);
|
|
|
|
nsresult rv = nsContentUtils::NameSpaceManager()->RegisterNameSpace(str, id);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2017-08-17 19:24:28 +03:00
|
|
|
bool
|
|
|
|
Gecko_ShouldCreateStyleThreadPool()
|
|
|
|
{
|
2017-09-16 03:16:34 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2017-08-17 19:24:28 +03:00
|
|
|
return !mozilla::BrowserTabsRemoteAutostart() || XRE_IsContentProcess();
|
|
|
|
}
|
|
|
|
|
2017-03-24 06:42:18 +03:00
|
|
|
NS_IMPL_FFI_REFCOUNTING(nsCSSFontFaceRule, CSSFontFaceRule);
|
|
|
|
|
2017-05-15 07:18:44 +03:00
|
|
|
nsCSSCounterStyleRule*
|
|
|
|
Gecko_CSSCounterStyle_Create(nsIAtom* aName)
|
|
|
|
{
|
|
|
|
RefPtr<nsCSSCounterStyleRule> rule = new nsCSSCounterStyleRule(aName, 0, 0);
|
|
|
|
return rule.forget().take();
|
|
|
|
}
|
|
|
|
|
2017-05-23 03:21:09 +03:00
|
|
|
nsCSSCounterStyleRule*
|
|
|
|
Gecko_CSSCounterStyle_Clone(const nsCSSCounterStyleRule* aRule)
|
|
|
|
{
|
|
|
|
RefPtr<css::Rule> rule = aRule->Clone();
|
|
|
|
return static_cast<nsCSSCounterStyleRule*>(rule.forget().take());
|
|
|
|
}
|
|
|
|
|
2017-05-15 07:18:44 +03:00
|
|
|
void
|
|
|
|
Gecko_CSSCounterStyle_GetCssText(const nsCSSCounterStyleRule* aRule,
|
|
|
|
nsAString* aResult)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
aRule->GetCssText(*aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_FFI_REFCOUNTING(nsCSSCounterStyleRule, CSSCounterStyleRule);
|
|
|
|
|
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-04-07 17:44:41 +03:00
|
|
|
void
|
|
|
|
Gecko_RegisterProfilerThread(const char* name)
|
|
|
|
{
|
|
|
|
char stackTop;
|
|
|
|
profiler_register_thread(name, &stackTop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_UnregisterProfilerThread()
|
|
|
|
{
|
|
|
|
profiler_unregister_thread();
|
|
|
|
}
|
|
|
|
|
2017-04-18 19:59:43 +03:00
|
|
|
bool
|
|
|
|
Gecko_DocumentRule_UseForPresentation(RawGeckoPresContextBorrowed aPresContext,
|
|
|
|
const nsACString* aPattern,
|
|
|
|
css::URLMatchingFunction aURLMatchingFunction)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsIDocument *doc = aPresContext->Document();
|
|
|
|
nsIURI *docURI = doc->GetDocumentURI();
|
|
|
|
nsAutoCString docURISpec;
|
|
|
|
if (docURI) {
|
|
|
|
// If GetSpec fails (due to OOM) just skip these URI-specific CSS rules.
|
|
|
|
nsresult rv = docURI->GetSpec(docURISpec);
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return css::DocumentRule::UseForPresentation(doc, docURI, docURISpec,
|
|
|
|
*aPattern, aURLMatchingFunction);
|
|
|
|
}
|
|
|
|
|
2017-05-10 15:31:51 +03:00
|
|
|
void
|
|
|
|
Gecko_SetJemallocThreadLocalArena(bool enabled)
|
|
|
|
{
|
|
|
|
#if defined(MOZ_MEMORY)
|
2017-08-30 12:04:47 +03:00
|
|
|
jemalloc_thread_local_arena(enabled);
|
2017-05-10 15:31:51 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
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
|
2017-07-11 00:52:00 +03:00
|
|
|
|
|
|
|
ErrorReporter*
|
|
|
|
Gecko_CreateCSSErrorReporter(ServoStyleSheet* sheet,
|
|
|
|
Loader* loader,
|
|
|
|
nsIURI* uri)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
return new ErrorReporter(sheet, loader, uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_DestroyCSSErrorReporter(ErrorReporter* reporter)
|
|
|
|
{
|
|
|
|
delete reporter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Gecko_ReportUnexpectedCSSError(ErrorReporter* reporter,
|
|
|
|
const char* message,
|
|
|
|
const char* param,
|
|
|
|
uint32_t paramLen,
|
2017-08-01 01:40:47 +03:00
|
|
|
const char* prefix,
|
|
|
|
const char* prefixParam,
|
|
|
|
uint32_t prefixParamLen,
|
|
|
|
const char* suffix,
|
2017-07-11 00:52:00 +03:00
|
|
|
const char* source,
|
|
|
|
uint32_t sourceLen,
|
|
|
|
uint32_t lineNumber,
|
2017-08-01 01:40:47 +03:00
|
|
|
uint32_t colNumber)
|
2017-07-11 00:52:00 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2017-08-01 01:40:47 +03:00
|
|
|
if (prefix) {
|
|
|
|
if (prefixParam) {
|
|
|
|
nsDependentCSubstring paramValue(prefixParam, prefixParamLen);
|
|
|
|
nsAutoString wideParam = NS_ConvertUTF8toUTF16(paramValue);
|
|
|
|
reporter->ReportUnexpectedUnescaped(prefix, wideParam);
|
|
|
|
} else {
|
|
|
|
reporter->ReportUnexpected(prefix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-29 20:24:32 +03:00
|
|
|
if (param) {
|
|
|
|
nsDependentCSubstring paramValue(param, paramLen);
|
|
|
|
nsAutoString wideParam = NS_ConvertUTF8toUTF16(paramValue);
|
|
|
|
reporter->ReportUnexpectedUnescaped(message, wideParam);
|
|
|
|
} else {
|
|
|
|
reporter->ReportUnexpected(message);
|
|
|
|
}
|
|
|
|
|
2017-08-01 01:40:47 +03:00
|
|
|
if (suffix) {
|
|
|
|
reporter->ReportUnexpected(suffix);
|
2017-07-26 15:54:25 +03:00
|
|
|
}
|
2017-07-11 00:52:00 +03:00
|
|
|
nsDependentCSubstring sourceValue(source, sourceLen);
|
|
|
|
reporter->OutputError(lineNumber, colNumber, sourceValue);
|
|
|
|
}
|