зеркало из https://github.com/mozilla/gecko-dev.git
merge autoland to mozilla-central. r=merge a=merge
MozReview-Commit-ID: GUnN9pacyFH
This commit is contained in:
Коммит
924b0ba508
|
@ -6,7 +6,7 @@
|
|||
"DTD/xhtml1-strict.dtd">
|
||||
%htmlDTD;
|
||||
<!ENTITY % netErrorDTD
|
||||
SYSTEM "chrome://global/locale/netError.dtd">
|
||||
SYSTEM "chrome://browser/locale/netError.dtd">
|
||||
%netErrorDTD;
|
||||
<!ENTITY % globalDTD
|
||||
SYSTEM "chrome://global/locale/global.dtd">
|
||||
|
|
|
@ -4202,15 +4202,15 @@ BitIsPropagated(const Element* aElement)
|
|||
|
||||
template<typename Traits>
|
||||
void
|
||||
NoteDirtyContent(nsIContent* aContent)
|
||||
NoteDirtyElement(Element* aElement)
|
||||
{
|
||||
MOZ_ASSERT(aContent->IsInComposedDoc());
|
||||
nsIDocument* doc = aContent->GetComposedDoc();
|
||||
MOZ_ASSERT(aElement->IsInComposedDoc());
|
||||
nsIDocument* doc = aElement->GetComposedDoc();
|
||||
nsIPresShell* shell = doc->GetShell();
|
||||
NS_ENSURE_TRUE_VOID(shell);
|
||||
shell->EnsureStyleFlush();
|
||||
|
||||
Element* parent = aContent->GetFlattenedTreeParentElementForStyle();
|
||||
Element* parent = aElement->GetFlattenedTreeParentElementForStyle();
|
||||
if (!parent || !parent->HasServoData()) {
|
||||
// The bits only apply to styled elements.
|
||||
return;
|
||||
|
@ -4226,13 +4226,13 @@ NoteDirtyContent(nsIContent* aContent)
|
|||
}
|
||||
|
||||
void
|
||||
nsIContent::NoteDirtyForServo()
|
||||
Element::NoteDirtyForServo()
|
||||
{
|
||||
NoteDirtyContent<DirtyDescendantsBit>(this);
|
||||
NoteDirtyElement<DirtyDescendantsBit>(this);
|
||||
}
|
||||
|
||||
void
|
||||
nsIContent::NoteAnimationOnlyDirtyForServo()
|
||||
Element::NoteAnimationOnlyDirtyForServo()
|
||||
{
|
||||
NoteDirtyContent<AnimationOnlyDirtyDescendantsBit>(this);
|
||||
NoteDirtyElement<AnimationOnlyDirtyDescendantsBit>(this);
|
||||
}
|
||||
|
|
|
@ -468,6 +468,9 @@ public:
|
|||
|
||||
Directionality GetComputedDirectionality() const;
|
||||
|
||||
void NoteDirtyForServo();
|
||||
void NoteAnimationOnlyDirtyForServo();
|
||||
|
||||
bool HasDirtyDescendantsForServo() const
|
||||
{
|
||||
MOZ_ASSERT(IsStyledByServo());
|
||||
|
|
|
@ -2481,6 +2481,21 @@ Selection::Collapse(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
|
|||
return;
|
||||
}
|
||||
|
||||
if (aContainer.NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aOffset > aContainer.Length()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HasSameRoot(aContainer)) {
|
||||
// Return with no error
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> container = &aContainer;
|
||||
|
||||
RefPtr<nsFrameSelection> frameSelection = mFrameSelection;
|
||||
|
@ -2880,6 +2895,11 @@ Selection::Extend(nsINode& aContainer, uint32_t aOffset, ErrorResult& aRv)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!HasSameRoot(aContainer)) {
|
||||
// Return with no error
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult res;
|
||||
if (!IsValidSelectionPoint(mFrameSelection, &aContainer)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
@ -3169,6 +3189,16 @@ Selection::SelectAllChildrenJS(nsINode& aNode, ErrorResult& aRv)
|
|||
void
|
||||
Selection::SelectAllChildren(nsINode& aNode, ErrorResult& aRv)
|
||||
{
|
||||
if (aNode.NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HasSameRoot(aNode)) {
|
||||
// Return with no error
|
||||
return;
|
||||
}
|
||||
|
||||
if (mFrameSelection) {
|
||||
mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON);
|
||||
}
|
||||
|
@ -3971,6 +4001,12 @@ Selection::SetBaseAndExtent(nsINode& aAnchorNode, uint32_t aAnchorOffset,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!HasSameRoot(aAnchorNode) ||
|
||||
!HasSameRoot(aFocusNode)) {
|
||||
// Return with no error
|
||||
return;
|
||||
}
|
||||
|
||||
SelectionBatcher batch(this);
|
||||
|
||||
int32_t relativePosition =
|
||||
|
@ -4211,3 +4247,11 @@ AutoHideSelectionChanges::AutoHideSelectionChanges(const nsFrameSelection* aFram
|
|||
: AutoHideSelectionChanges(
|
||||
aFrame ? aFrame->GetSelection(SelectionType::eNormal) : nullptr)
|
||||
{}
|
||||
|
||||
bool
|
||||
Selection::HasSameRoot(nsINode& aNode)
|
||||
{
|
||||
nsINode* root = aNode.SubtreeRoot();
|
||||
nsIDocument* doc = GetParentObject();
|
||||
return doc == root || (root && doc == root->GetComposedDoc());
|
||||
}
|
||||
|
|
|
@ -282,6 +282,9 @@ private:
|
|||
// Note: DoAutoScroll might destroy arbitrary frames etc.
|
||||
nsresult DoAutoScroll(nsIFrame *aFrame, nsPoint& aPoint);
|
||||
|
||||
// We are not allowed to be in nodes whose root is not our document
|
||||
bool HasSameRoot(nsINode& aNode);
|
||||
|
||||
// XXX Please don't add additional uses of this method, it's only for
|
||||
// XXX supporting broken code (bug 1245883) in the following classes:
|
||||
friend class ::nsCopySupport;
|
||||
|
|
|
@ -18,10 +18,13 @@ enum UseCounter : int16_t {
|
|||
eUseCounter_##interface_##_##name_##_setter,
|
||||
#define USE_COUNTER_CSS_PROPERTY(name_, id_) \
|
||||
eUseCounter_property_##id_,
|
||||
#define USE_COUNTER_CUSTOM(name_, desc_) \
|
||||
eUseCounter_custom_##name_,
|
||||
#include "mozilla/dom/UseCounterList.h"
|
||||
#undef USE_COUNTER_DOM_METHOD
|
||||
#undef USE_COUNTER_DOM_ATTRIBUTE
|
||||
#undef USE_COUNTER_CSS_PROPERTY
|
||||
#undef USE_COUNTER_CUSTOM
|
||||
|
||||
#define DEPRECATED_OPERATION(op_) \
|
||||
eUseCounter_##op_,
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
//
|
||||
// (b) a comment, which is a line that begins with "//"
|
||||
//
|
||||
// (c) one of three possible use counter declarations:
|
||||
// (c) one of four possible use counter declarations:
|
||||
//
|
||||
// method <IDL interface name>.<IDL operation name>
|
||||
// attribute <IDL interface name>.<IDL attribute name>
|
||||
// property <CSS property method name>
|
||||
// custom <any valid identifier> <description>
|
||||
//
|
||||
// The |CSS property method name| should be identical to the |method|
|
||||
// argument to CSS_PROP and related macros. The method name is
|
||||
|
@ -24,10 +25,17 @@
|
|||
// removed and CamelCase naming is used. See nsCSSPropList.h for
|
||||
// further details.
|
||||
//
|
||||
// The <description> for custom counters will be appended to "When a document "
|
||||
// or "When a page ", so phrase it appropriately. For instance, "constructs a
|
||||
// Foo object" or "calls Document.bar('some value')". It may contain any
|
||||
// character.
|
||||
//
|
||||
// To actually cause use counters to be incremented, DOM methods
|
||||
// and attributes must have a [UseCounter] extended attribute in
|
||||
// the Web IDL file. CSS properties require no special treatment
|
||||
// beyond being listed below.
|
||||
// beyond being listed below. Custom counters are incremented when
|
||||
// SetDocumentAndPageUseCounter(eUseCounter_custom_MyName) is called on an
|
||||
// ns(I)Document object.
|
||||
//
|
||||
// You might reasonably ask why we have this file and we require
|
||||
// annotating things with [UseCounter] in the relevant WebIDL file as
|
||||
|
|
|
@ -37,6 +37,7 @@ def generate_list(f, counters):
|
|||
print_optional_macro_declare('USE_COUNTER_DOM_METHOD')
|
||||
print_optional_macro_declare('USE_COUNTER_DOM_ATTRIBUTE')
|
||||
print_optional_macro_declare('USE_COUNTER_CSS_PROPERTY')
|
||||
print_optional_macro_declare('USE_COUNTER_CUSTOM')
|
||||
|
||||
for counter in counters:
|
||||
if counter['type'] == 'method':
|
||||
|
@ -46,10 +47,14 @@ def generate_list(f, counters):
|
|||
elif counter['type'] == 'property':
|
||||
prop = counter['property_name']
|
||||
print('USE_COUNTER_CSS_PROPERTY(%s, %s)' % (prop, prop), file=f)
|
||||
elif counter['type'] == 'custom':
|
||||
desc = counter['desc'].replace('\\', r'\\').replace('"', r'\"')
|
||||
print('USE_COUNTER_CUSTOM(%s, "%s")' % (counter['name'], desc), file=f)
|
||||
|
||||
print_optional_macro_undeclare('USE_COUNTER_DOM_METHOD')
|
||||
print_optional_macro_undeclare('USE_COUNTER_DOM_ATTRIBUTE')
|
||||
print_optional_macro_undeclare('USE_COUNTER_CSS_PROPERTY')
|
||||
print_optional_macro_undeclare('USE_COUNTER_CUSTOM')
|
||||
|
||||
def generate_property_map(f, counters):
|
||||
print(AUTOGENERATED_WARNING_COMMENT, file=f)
|
||||
|
|
|
@ -980,9 +980,6 @@ public:
|
|||
|
||||
virtual bool OwnedOnlyByTheDOMTree() { return false; }
|
||||
|
||||
void NoteDirtyForServo();
|
||||
void NoteAnimationOnlyDirtyForServo();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Hook for implementing GetID. This is guaranteed to only be
|
||||
|
|
|
@ -38,6 +38,13 @@ def read_conf(conf_filename):
|
|||
yield { 'type': 'property',
|
||||
'property_name': property_name }
|
||||
continue
|
||||
m = re.match(r'custom ([A-Za-z0-9_]+) (.*)$', line)
|
||||
if m:
|
||||
name, desc = m.groups()
|
||||
yield { 'type': 'custom',
|
||||
'name': name,
|
||||
'desc': desc }
|
||||
continue
|
||||
raise ValueError('error parsing %s at line %d' % (conf_filename, line_num))
|
||||
|
||||
return parse_counters(stream)
|
||||
|
@ -67,5 +74,7 @@ def generate_histograms(filename):
|
|||
elif counter['type'] == 'property':
|
||||
prop = counter['property_name']
|
||||
append_counters('PROPERTY_%s' % prop.replace('-', '_').upper(), "used the '%s' property" % prop)
|
||||
elif counter['type'] == 'custom':
|
||||
append_counters(counter['name'].upper(), counter['desc'])
|
||||
|
||||
return items
|
||||
|
|
|
@ -23,8 +23,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=537046
|
|||
|
||||
/** Test for Bug 537046 **/
|
||||
|
||||
SimpleTest.expectAssertions(1);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() {
|
||||
var ed = document.getElementById("editor");
|
||||
|
|
|
@ -791,14 +791,18 @@ ServoRestyleManager::ProcessPostTraversal(
|
|||
ServoRestyleState& childrenRestyleState =
|
||||
thisFrameRestyleState ? *thisFrameRestyleState : aRestyleState;
|
||||
|
||||
RefPtr<ServoStyleContext> newContext = nullptr;
|
||||
RefPtr<ServoStyleContext> upToDateContext =
|
||||
(wasRestyled || !oldStyleContext)
|
||||
? aRestyleState.StyleSet().ResolveServoStyle(aElement)
|
||||
: oldStyleContext;
|
||||
|
||||
MOZ_ASSERT(upToDateContext);
|
||||
|
||||
if (wasRestyled && oldStyleContext) {
|
||||
MOZ_ASSERT(styleFrame || displayContentsStyle);
|
||||
newContext =
|
||||
aRestyleState.StyleSet().ResolveServoStyle(aElement);
|
||||
MOZ_ASSERT(oldStyleContext->ComputedData() != newContext->ComputedData());
|
||||
MOZ_ASSERT(oldStyleContext->ComputedData() != upToDateContext->ComputedData());
|
||||
|
||||
newContext->ResolveSameStructsAs(oldStyleContext);
|
||||
upToDateContext->ResolveSameStructsAs(oldStyleContext);
|
||||
|
||||
// We want to walk all the continuations here, even the ones with different
|
||||
// styles. In practice, the only reason we get continuations with different
|
||||
|
@ -812,13 +816,13 @@ ServoRestyleManager::ProcessPostTraversal(
|
|||
// initial continuations; ::first-line fixes that up after the fact.
|
||||
for (nsIFrame* f = styleFrame; f; f = f->GetNextContinuation()) {
|
||||
MOZ_ASSERT_IF(f != styleFrame, !f->GetAdditionalStyleContext(0));
|
||||
f->SetStyleContext(newContext);
|
||||
f->SetStyleContext(upToDateContext);
|
||||
}
|
||||
|
||||
if (MOZ_UNLIKELY(displayContentsStyle)) {
|
||||
MOZ_ASSERT(!styleFrame);
|
||||
PresContext()->FrameConstructor()->
|
||||
ChangeRegisteredDisplayContentsStyleFor(aElement, newContext);
|
||||
ChangeRegisteredDisplayContentsStyleFor(aElement, upToDateContext);
|
||||
}
|
||||
|
||||
if (styleFrame) {
|
||||
|
@ -856,9 +860,6 @@ ServoRestyleManager::ProcessPostTraversal(
|
|||
const bool traverseTextChildren = wasRestyled || descendantsNeedFrames;
|
||||
bool recreatedAnyContext = wasRestyled;
|
||||
if (traverseElementChildren || traverseTextChildren) {
|
||||
ServoStyleContext* upToDateContext =
|
||||
wasRestyled ? newContext : oldStyleContext;
|
||||
|
||||
StyleChildrenIterator it(aElement);
|
||||
TextPostTraversalState textState(*upToDateContext,
|
||||
displayContentsStyle && wasRestyled,
|
||||
|
|
|
@ -7551,8 +7551,15 @@ nsCSSFrameConstructor::LazilyStyleNewChildRange(nsIContent* aStartChild,
|
|||
{
|
||||
for (nsIContent* child = aStartChild; child != aEndChild;
|
||||
child = child->GetNextSibling()) {
|
||||
child->NoteDirtyForServo();
|
||||
if (child->IsElement()) {
|
||||
child->AsElement()->NoteDirtyForServo();
|
||||
}
|
||||
}
|
||||
|
||||
// NoteDirtyForServo() will ensure a style flush, but we don't invoke it for
|
||||
// text nodes. So since this range might include no elements, we still need
|
||||
// to manually ensure a style flush.
|
||||
mPresShell->EnsureStyleFlush();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -45,10 +45,6 @@ public:
|
|||
ACTIVITY_TOP,
|
||||
ACTIVITY_RIGHT,
|
||||
ACTIVITY_BOTTOM,
|
||||
ACTIVITY_MARGIN_LEFT,
|
||||
ACTIVITY_MARGIN_TOP,
|
||||
ACTIVITY_MARGIN_RIGHT,
|
||||
ACTIVITY_MARGIN_BOTTOM,
|
||||
ACTIVITY_BACKGROUND_POSITION,
|
||||
|
||||
ACTIVITY_SCALE,
|
||||
|
@ -80,10 +76,6 @@ public:
|
|||
case eCSSProperty_top: return ACTIVITY_TOP;
|
||||
case eCSSProperty_right: return ACTIVITY_RIGHT;
|
||||
case eCSSProperty_bottom: return ACTIVITY_BOTTOM;
|
||||
case eCSSProperty_margin_left: return ACTIVITY_MARGIN_LEFT;
|
||||
case eCSSProperty_margin_top: return ACTIVITY_MARGIN_TOP;
|
||||
case eCSSProperty_margin_right: return ACTIVITY_MARGIN_RIGHT;
|
||||
case eCSSProperty_margin_bottom: return ACTIVITY_MARGIN_BOTTOM;
|
||||
case eCSSProperty_background_position: return ACTIVITY_BACKGROUND_POSITION;
|
||||
case eCSSProperty_background_position_x: return ACTIVITY_BACKGROUND_POSITION;
|
||||
case eCSSProperty_background_position_y: return ACTIVITY_BACKGROUND_POSITION;
|
||||
|
@ -449,18 +441,14 @@ ActiveLayerTracker::IsStyleAnimated(nsDisplayListBuilder* aBuilder,
|
|||
}
|
||||
|
||||
/* static */ bool
|
||||
ActiveLayerTracker::IsOffsetOrMarginStyleAnimated(nsIFrame* aFrame)
|
||||
ActiveLayerTracker::IsOffsetStyleAnimated(nsIFrame* aFrame)
|
||||
{
|
||||
LayerActivity* layerActivity = GetLayerActivity(aFrame);
|
||||
if (layerActivity) {
|
||||
if (layerActivity->mRestyleCounts[LayerActivity::ACTIVITY_LEFT] >= 2 ||
|
||||
layerActivity->mRestyleCounts[LayerActivity::ACTIVITY_TOP] >= 2 ||
|
||||
layerActivity->mRestyleCounts[LayerActivity::ACTIVITY_RIGHT] >= 2 ||
|
||||
layerActivity->mRestyleCounts[LayerActivity::ACTIVITY_BOTTOM] >= 2 ||
|
||||
layerActivity->mRestyleCounts[LayerActivity::ACTIVITY_MARGIN_LEFT] >= 2 ||
|
||||
layerActivity->mRestyleCounts[LayerActivity::ACTIVITY_MARGIN_TOP] >= 2 ||
|
||||
layerActivity->mRestyleCounts[LayerActivity::ACTIVITY_MARGIN_RIGHT] >= 2 ||
|
||||
layerActivity->mRestyleCounts[LayerActivity::ACTIVITY_MARGIN_BOTTOM] >= 2) {
|
||||
layerActivity->mRestyleCounts[LayerActivity::ACTIVITY_BOTTOM] >= 2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
* Return true if any of aFrame's offset property styles should be considered
|
||||
* as being animated for constructing active layers.
|
||||
*/
|
||||
static bool IsOffsetOrMarginStyleAnimated(nsIFrame* aFrame);
|
||||
static bool IsOffsetStyleAnimated(nsIFrame* aFrame);
|
||||
/**
|
||||
* Return true if aFrame's background-position-x or background-position-y
|
||||
* property is animated.
|
||||
|
|
|
@ -1501,7 +1501,7 @@ nsDisplayListBuilder::IsAnimatedGeometryRoot(nsIFrame* aFrame,
|
|||
|
||||
if (nsLayoutUtils::IsPopup(aFrame))
|
||||
return AGR_YES;
|
||||
if (ActiveLayerTracker::IsOffsetOrMarginStyleAnimated(aFrame)) {
|
||||
if (ActiveLayerTracker::IsOffsetStyleAnimated(aFrame)) {
|
||||
const bool inBudget = AddToAGRBudget(aFrame);
|
||||
if (inBudget) {
|
||||
return AGR_YES;
|
||||
|
|
|
@ -44,6 +44,9 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_Clone, RawServoStyleSheetContentsStrong,
|
|||
SERVO_BINDING_FUNC(Servo_StyleSheet_SizeOfIncludingThis, size_t,
|
||||
mozilla::MallocSizeOf malloc_size_of,
|
||||
RawServoStyleSheetContentsBorrowed sheet)
|
||||
SERVO_BINDING_FUNC(Servo_StyleSheet_GetOrigin,
|
||||
mozilla::OriginFlags,
|
||||
RawServoStyleSheetContentsBorrowed sheet)
|
||||
SERVO_BINDING_FUNC(Servo_StyleSet_Init, RawServoStyleSetOwned, RawGeckoPresContextOwned pres_context)
|
||||
SERVO_BINDING_FUNC(Servo_StyleSet_Clear, void,
|
||||
RawServoStyleSetBorrowed set)
|
||||
|
@ -70,7 +73,9 @@ SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void,
|
|||
SERVO_BINDING_FUNC(Servo_StyleSet_FlushStyleSheets, void, RawServoStyleSetBorrowed set,
|
||||
RawGeckoElementBorrowedOrNull doc_elem)
|
||||
SERVO_BINDING_FUNC(Servo_StyleSet_NoteStyleSheetsChanged, void,
|
||||
RawServoStyleSetBorrowed set, bool author_style_disabled)
|
||||
RawServoStyleSetBorrowed set,
|
||||
bool author_style_disabled,
|
||||
mozilla::OriginFlags changed_origins)
|
||||
SERVO_BINDING_FUNC(Servo_StyleSet_GetKeyframesForName, bool,
|
||||
RawServoStyleSetBorrowed set,
|
||||
const nsACString* property,
|
||||
|
|
|
@ -36,6 +36,7 @@ struct ComputedTiming;
|
|||
struct Keyframe;
|
||||
struct PropertyValuePair;
|
||||
struct PropertyStyleAnimationValuePair;
|
||||
enum class OriginFlags : uint8_t;
|
||||
using ComputedKeyframeValues = nsTArray<PropertyStyleAnimationValuePair>;
|
||||
} // namespace mozilla
|
||||
namespace nsStyleTransformMatrix {
|
||||
|
|
|
@ -90,6 +90,7 @@ hide-types = [
|
|||
bitfield-enums = [
|
||||
"nsChangeHint",
|
||||
"nsRestyleHint",
|
||||
"OriginFlags",
|
||||
]
|
||||
constified-enums = [
|
||||
"UpdateAnimationsTasks",
|
||||
|
@ -137,6 +138,7 @@ whitelist-types = [
|
|||
"mozilla::dom::StyleChildrenIterator",
|
||||
"mozilla::HalfCorner",
|
||||
"mozilla::MallocSizeOf",
|
||||
"mozilla::OriginFlags",
|
||||
"mozilla::PropertyStyleAnimationValuePair",
|
||||
"mozilla::ServoTraversalFlags",
|
||||
"mozilla::StylePrefs",
|
||||
|
@ -367,6 +369,7 @@ structs-types = [
|
|||
"mozilla::css::URLValue",
|
||||
"mozilla::css::URLValueData",
|
||||
"mozilla::MallocSizeOf",
|
||||
"mozilla::OriginFlags",
|
||||
"mozilla::Side",
|
||||
"mozilla::UniquePtr",
|
||||
"nsIContent",
|
||||
|
|
|
@ -171,7 +171,9 @@ ServoStyleSet::MediumFeaturesChanged(bool aViewportChanged)
|
|||
Servo_StyleSet_MediumFeaturesChanged(mRawSet.get(), &viewportUnitsUsed);
|
||||
|
||||
if (rulesChanged) {
|
||||
ForceAllStyleDirty();
|
||||
// XXXheycam Should be able to tell which origin to pass in here
|
||||
// (bug 1389871).
|
||||
MarkOriginsDirty(OriginFlags::All);
|
||||
return eRestyle_Subtree;
|
||||
}
|
||||
|
||||
|
@ -217,7 +219,7 @@ ServoStyleSet::SetAuthorStyleDisabled(bool aStyleDisabled)
|
|||
}
|
||||
|
||||
mAuthorStyleDisabled = aStyleDisabled;
|
||||
ForceAllStyleDirty();
|
||||
MarkOriginsDirty(OriginFlags::Author);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -871,6 +873,10 @@ ServoStyleSet::StyleDocument(ServoTraversalFlags aBaseFlags)
|
|||
bool isInitial = !root->HasServoData();
|
||||
auto flags = aBaseFlags;
|
||||
|
||||
// If there were text nodes inserted into the document (but not elements),
|
||||
// there may be lazy frame construction to do even if no styling is required.
|
||||
postTraversalRequired |= root->HasFlag(NODE_DESCENDANTS_NEED_FRAMES);
|
||||
|
||||
// Allow the parallel traversal, unless we're traversing traversing one of
|
||||
// the native anonymous document style roots, which are tiny and not worth
|
||||
// parallelizing over.
|
||||
|
@ -1033,10 +1039,12 @@ ServoStyleSet::StyleSubtreeForReconstruct(Element* aRoot)
|
|||
}
|
||||
|
||||
void
|
||||
ServoStyleSet::ForceAllStyleDirty()
|
||||
ServoStyleSet::MarkOriginsDirty(OriginFlags aChangedOrigins)
|
||||
{
|
||||
SetStylistStyleSheetsDirty();
|
||||
Servo_StyleSet_NoteStyleSheetsChanged(mRawSet.get(), mAuthorStyleDisabled);
|
||||
Servo_StyleSet_NoteStyleSheetsChanged(mRawSet.get(),
|
||||
mAuthorStyleDisabled,
|
||||
aChangedOrigins);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1044,13 +1052,12 @@ ServoStyleSet::RecordStyleSheetChange(
|
|||
ServoStyleSheet* aSheet,
|
||||
StyleSheet::ChangeType aChangeType)
|
||||
{
|
||||
SetStylistStyleSheetsDirty();
|
||||
switch (aChangeType) {
|
||||
case StyleSheet::ChangeType::RuleAdded:
|
||||
case StyleSheet::ChangeType::RuleRemoved:
|
||||
case StyleSheet::ChangeType::RuleChanged:
|
||||
// FIXME(emilio): We can presumably do better in a bunch of these.
|
||||
return ForceAllStyleDirty();
|
||||
return MarkOriginsDirty(aSheet->GetOrigin());
|
||||
case StyleSheet::ChangeType::ApplicableStateChanged:
|
||||
case StyleSheet::ChangeType::Added:
|
||||
case StyleSheet::ChangeType::Removed:
|
||||
|
|
|
@ -58,6 +58,16 @@ enum class StylistState : uint8_t {
|
|||
StyleSheetsDirty,
|
||||
};
|
||||
|
||||
// Bitfield type to represent Servo stylesheet origins.
|
||||
enum class OriginFlags : uint8_t {
|
||||
UserAgent = 0x01,
|
||||
User = 0x02,
|
||||
Author = 0x04,
|
||||
All = 0x07,
|
||||
};
|
||||
|
||||
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(OriginFlags)
|
||||
|
||||
/**
|
||||
* The set of style sheets that apply to a document, backed by a Servo
|
||||
* Stylist. A ServoStyleSet contains ServoStyleSheets.
|
||||
|
@ -99,7 +109,7 @@ public:
|
|||
void RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot) {
|
||||
// FIXME(emilio): When we properly support shadow dom we'll need to do
|
||||
// better.
|
||||
ForceAllStyleDirty();
|
||||
MarkOriginsDirty(OriginFlags::All);
|
||||
}
|
||||
|
||||
bool StyleSheetsHaveChanged() const
|
||||
|
@ -288,13 +298,6 @@ public:
|
|||
*/
|
||||
void StyleSubtreeForReconstruct(dom::Element* aRoot);
|
||||
|
||||
/**
|
||||
* Records that the contents of style sheets have changed since the last
|
||||
* restyle. Calling this will ensure that the Stylist rebuilds its
|
||||
* selector maps.
|
||||
*/
|
||||
void ForceAllStyleDirty();
|
||||
|
||||
/**
|
||||
* Helper for correctly calling UpdateStylist without paying the cost of an
|
||||
* extra function call in the common no-rebuild-needed case.
|
||||
|
@ -493,6 +496,13 @@ private:
|
|||
// Subset of the pre-traverse steps that involve syncing up data
|
||||
void PreTraverseSync();
|
||||
|
||||
/**
|
||||
* Records that the contents of style sheets at the specified origin have
|
||||
* changed since the last. Calling this will ensure that the Stylist
|
||||
* rebuilds its selector maps.
|
||||
*/
|
||||
void MarkOriginsDirty(OriginFlags aChangedOrigins);
|
||||
|
||||
/**
|
||||
* Note that the stylist needs a style flush due to style sheet changes.
|
||||
*/
|
||||
|
|
|
@ -463,4 +463,10 @@ ServoStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
|||
return n;
|
||||
}
|
||||
|
||||
OriginFlags
|
||||
ServoStyleSheet::GetOrigin()
|
||||
{
|
||||
return Servo_StyleSheet_GetOrigin(Inner()->mContents);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -121,6 +121,9 @@ public:
|
|||
// completelness check.
|
||||
ServoCSSRuleList* GetCssRulesInternal();
|
||||
|
||||
// Returns the stylesheet's Servo origin as an OriginFlags value.
|
||||
OriginFlags GetOrigin();
|
||||
|
||||
protected:
|
||||
virtual ~ServoStyleSheet();
|
||||
|
||||
|
|
|
@ -211,8 +211,6 @@ nsDOMCSSAttributeDeclaration::SetPropertyValue(const nsCSSPropertyID aPropID,
|
|||
if (aPropID == eCSSProperty_opacity || aPropID == eCSSProperty_transform ||
|
||||
aPropID == eCSSProperty_left || aPropID == eCSSProperty_top ||
|
||||
aPropID == eCSSProperty_right || aPropID == eCSSProperty_bottom ||
|
||||
aPropID == eCSSProperty_margin_left || aPropID == eCSSProperty_margin_top ||
|
||||
aPropID == eCSSProperty_margin_right || aPropID == eCSSProperty_margin_bottom ||
|
||||
aPropID == eCSSProperty_background_position_x ||
|
||||
aPropID == eCSSProperty_background_position_y ||
|
||||
aPropID == eCSSProperty_background_position) {
|
||||
|
|
|
@ -208,6 +208,8 @@ support-files = flexbox_layout_testcases.js
|
|||
[test_flexbox_order_abspos.html]
|
||||
[test_flexbox_order_table.html]
|
||||
[test_flexbox_reflow_counts.html]
|
||||
[test_font_face_cascade.html]
|
||||
fail-if = !stylo # bug 1389937
|
||||
[test_font_face_parser.html]
|
||||
[test_font_family_parsing.html]
|
||||
[test_font_loading_api.html]
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE HTML>
|
||||
<title>Test that @font-face rules from different origins cascade correctly</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
|
||||
<script>
|
||||
let io = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIIOService);
|
||||
|
||||
let utils = SpecialPowers.wrap(window)
|
||||
.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor)
|
||||
.getInterface(SpecialPowers.Ci.nsIDOMWindowUtils);
|
||||
|
||||
function load_sheet(sheet_text, level) {
|
||||
if (level != "AGENT_SHEET" && level != "USER_SHEET" && level != "AUTHOR_SHEET") {
|
||||
throw "unknown level";
|
||||
}
|
||||
|
||||
let uri = io.newURI("data:text/css," + encodeURI(sheet_text));
|
||||
utils.loadSheet(uri, utils[level]);
|
||||
}
|
||||
|
||||
load_sheet(
|
||||
"@font-face { font-family: TestAgent; src: url(about:invalid); }",
|
||||
"AGENT_SHEET");
|
||||
|
||||
load_sheet(
|
||||
"@font-face { font-family: TestAuthor; src: url(about:invalid); }",
|
||||
"AUTHOR_SHEET");
|
||||
|
||||
load_sheet(
|
||||
"@font-face { font-family: TestUser; src: url(about:invalid); }",
|
||||
"USER_SHEET");
|
||||
|
||||
is([...document.fonts].map(f => f.family).join(" "),
|
||||
'"TestAuthor" "TestUser" "TestAgent"',
|
||||
"@font-face rules are returned in correct cascade order");
|
||||
</script>
|
|
@ -137,7 +137,7 @@ use style::selector_parser::SnapshotMap;
|
|||
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
|
||||
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
|
||||
use style::stylesheets::{Origin, Stylesheet, StylesheetInDocument, UserAgentStylesheets};
|
||||
use style::stylist::{ExtraStyleData, Stylist};
|
||||
use style::stylist::Stylist;
|
||||
use style::thread_state;
|
||||
use style::timer::Timer;
|
||||
use style::traversal::{DomTraversal, TraversalDriver};
|
||||
|
@ -1206,7 +1206,7 @@ impl LayoutThread {
|
|||
author: &author_guard,
|
||||
ua_or_user: &ua_or_user_guard,
|
||||
};
|
||||
let mut extra_data = ExtraStyleData;
|
||||
let mut extra_data = Default::default();
|
||||
let needs_dirtying = self.stylist.update(
|
||||
StylesheetIterator(data.document_stylesheets.iter()),
|
||||
&guards,
|
||||
|
|
|
@ -17,7 +17,7 @@ use properties::ComputedValues;
|
|||
use servo_arc::Arc;
|
||||
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
|
||||
use stylesheet_set::StylesheetSet;
|
||||
use stylesheets::{StylesheetContents, StylesheetInDocument};
|
||||
use stylesheets::{Origin, PerOrigin, StylesheetContents, StylesheetInDocument};
|
||||
use stylist::{ExtraStyleData, Stylist};
|
||||
|
||||
/// Little wrapper to a Gecko style sheet.
|
||||
|
@ -118,7 +118,7 @@ pub struct PerDocumentStyleDataImpl {
|
|||
pub stylesheets: StylesheetSet<GeckoStyleSheet>,
|
||||
|
||||
/// List of effective @font-face and @counter-style rules.
|
||||
pub extra_style_data: ExtraStyleData,
|
||||
pub extra_style_data: PerOrigin<ExtraStyleData>,
|
||||
}
|
||||
|
||||
/// The data itself is an `AtomicRefCell`, which guarantees the proper semantics
|
||||
|
@ -163,7 +163,7 @@ impl PerDocumentStyleDataImpl {
|
|||
}
|
||||
|
||||
let author_style_disabled = self.stylesheets.author_style_disabled();
|
||||
self.stylist.clear();
|
||||
|
||||
let iter = self.stylesheets.flush(document_element);
|
||||
self.stylist.rebuild(
|
||||
iter,
|
||||
|
@ -193,6 +193,11 @@ impl PerDocumentStyleDataImpl {
|
|||
self.stylist.clear();
|
||||
}
|
||||
|
||||
/// Clear the stylist's data for the specified origin.
|
||||
pub fn clear_stylist_origin(&mut self, origin: &Origin) {
|
||||
self.stylist.clear_origin(origin);
|
||||
}
|
||||
|
||||
/// Returns whether visited links are enabled.
|
||||
fn visited_links_enabled(&self) -> bool {
|
||||
unsafe { bindings::Gecko_AreVisitedLinksEnabled() }
|
||||
|
|
|
@ -15,6 +15,7 @@ use gecko_bindings::structs::mozilla::css::ImageValue;
|
|||
use gecko_bindings::structs::mozilla::css::URLValue;
|
||||
use gecko_bindings::structs::mozilla::css::URLValueData;
|
||||
use gecko_bindings::structs::mozilla::MallocSizeOf;
|
||||
use gecko_bindings::structs::mozilla::OriginFlags;
|
||||
use gecko_bindings::structs::mozilla::Side;
|
||||
use gecko_bindings::structs::mozilla::UniquePtr;
|
||||
use gecko_bindings::structs::nsIContent;
|
||||
|
@ -1956,6 +1957,11 @@ extern "C" {
|
|||
RawServoStyleSheetContentsBorrowed)
|
||||
-> usize;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSheet_GetOrigin(sheet:
|
||||
RawServoStyleSheetContentsBorrowed)
|
||||
-> OriginFlags;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_Init(pres_context: RawGeckoPresContextOwned)
|
||||
-> RawServoStyleSetOwned;
|
||||
|
@ -2006,7 +2012,9 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_StyleSet_NoteStyleSheetsChanged(set:
|
||||
RawServoStyleSetBorrowed,
|
||||
author_style_disabled: bool);
|
||||
author_style_disabled: bool,
|
||||
changed_origins:
|
||||
OriginFlags);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_GetKeyframesForName(set: RawServoStyleSetBorrowed,
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,6 +13,7 @@ mod ns_style_auto_array;
|
|||
pub mod ns_style_coord;
|
||||
mod ns_t_array;
|
||||
mod ns_timing_function;
|
||||
mod origin_flags;
|
||||
pub mod ownership;
|
||||
pub mod refptr;
|
||||
mod style_complex_color;
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/* 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/. */
|
||||
|
||||
//! Helper to iterate over `OriginFlags` bits.
|
||||
|
||||
use gecko_bindings::structs::OriginFlags;
|
||||
use gecko_bindings::structs::OriginFlags_Author;
|
||||
use gecko_bindings::structs::OriginFlags_User;
|
||||
use gecko_bindings::structs::OriginFlags_UserAgent;
|
||||
use stylesheets::Origin;
|
||||
|
||||
impl OriginFlags {
|
||||
/// Returns an iterator over the origins present in the `OriginFlags`,
|
||||
/// in order from highest priority (author) to lower (user agent).
|
||||
pub fn iter(self) -> OriginFlagsIter {
|
||||
OriginFlagsIter {
|
||||
origin_flags: self,
|
||||
cur: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterates over the origins present in an `OriginFlags`, in order from
|
||||
/// highest priority (author) to lower (user agent).
|
||||
pub struct OriginFlagsIter {
|
||||
origin_flags: OriginFlags,
|
||||
cur: usize,
|
||||
}
|
||||
|
||||
impl Iterator for OriginFlagsIter {
|
||||
type Item = Origin;
|
||||
|
||||
fn next(&mut self) -> Option<Origin> {
|
||||
loop {
|
||||
let (bit, origin) = match self.cur {
|
||||
0 => (OriginFlags_Author, Origin::Author),
|
||||
1 => (OriginFlags_User, Origin::User),
|
||||
2 => (OriginFlags_UserAgent, Origin::UserAgent),
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
self.cur += 1;
|
||||
|
||||
if (self.origin_flags & bit).0 != 0 {
|
||||
return Some(origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ impl ToMediaListKey for MediaRule {}
|
|||
|
||||
/// A struct that holds the result of a media query evaluation pass for the
|
||||
/// media queries that evaluated successfully.
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct EffectiveMediaQueryResults {
|
||||
/// The set of media lists that matched last time.
|
||||
|
|
|
@ -8,7 +8,7 @@ use dom::TElement;
|
|||
use invalidation::stylesheets::StylesheetInvalidationSet;
|
||||
use shared_lock::SharedRwLockReadGuard;
|
||||
use std::slice;
|
||||
use stylesheets::StylesheetInDocument;
|
||||
use stylesheets::{Origin, PerOrigin, StylesheetInDocument};
|
||||
use stylist::Stylist;
|
||||
|
||||
/// Entry for a StylesheetSet. We don't bother creating a constructor, because
|
||||
|
@ -49,14 +49,11 @@ where
|
|||
/// include recursive `@import` rules.
|
||||
entries: Vec<StylesheetSetEntry<S>>,
|
||||
|
||||
/// Whether the entries list above has changed since the last restyle.
|
||||
dirty: bool,
|
||||
/// Per-origin stylesheet invalidation data.
|
||||
invalidation_data: PerOrigin<InvalidationData>,
|
||||
|
||||
/// Has author style been disabled?
|
||||
author_style_disabled: bool,
|
||||
|
||||
/// The style invalidations that we still haven't processed.
|
||||
invalidations: StylesheetInvalidationSet,
|
||||
}
|
||||
|
||||
impl<S> StylesheetSet<S>
|
||||
|
@ -67,9 +64,8 @@ where
|
|||
pub fn new() -> Self {
|
||||
StylesheetSet {
|
||||
entries: vec![],
|
||||
dirty: false,
|
||||
invalidation_data: Default::default(),
|
||||
author_style_disabled: false,
|
||||
invalidations: StylesheetInvalidationSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +79,18 @@ where
|
|||
self.entries.retain(|entry| entry.sheet != *sheet);
|
||||
}
|
||||
|
||||
fn collect_invalidations_for(
|
||||
&mut self,
|
||||
stylist: &Stylist,
|
||||
sheet: &S,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
) {
|
||||
let origin = sheet.contents(guard).origin;
|
||||
let data = self.invalidation_data.borrow_mut_for_origin(&origin);
|
||||
data.invalidations.collect_invalidations_for(stylist, sheet, guard);
|
||||
data.dirty = true;
|
||||
}
|
||||
|
||||
/// Appends a new stylesheet to the current set.
|
||||
pub fn append_stylesheet(
|
||||
&mut self,
|
||||
|
@ -92,12 +100,7 @@ where
|
|||
) {
|
||||
debug!("StylesheetSet::append_stylesheet");
|
||||
self.remove_stylesheet_if_present(&sheet);
|
||||
self.invalidations.collect_invalidations_for(
|
||||
stylist,
|
||||
&sheet,
|
||||
guard
|
||||
);
|
||||
self.dirty = true;
|
||||
self.collect_invalidations_for(stylist, &sheet, guard);
|
||||
self.entries.push(StylesheetSetEntry { sheet });
|
||||
}
|
||||
|
||||
|
@ -110,13 +113,8 @@ where
|
|||
) {
|
||||
debug!("StylesheetSet::prepend_stylesheet");
|
||||
self.remove_stylesheet_if_present(&sheet);
|
||||
self.invalidations.collect_invalidations_for(
|
||||
stylist,
|
||||
&sheet,
|
||||
guard
|
||||
);
|
||||
self.collect_invalidations_for(stylist, &sheet, guard);
|
||||
self.entries.insert(0, StylesheetSetEntry { sheet });
|
||||
self.dirty = true;
|
||||
}
|
||||
|
||||
/// Insert a given stylesheet before another stylesheet in the document.
|
||||
|
@ -132,13 +130,8 @@ where
|
|||
let index = self.entries.iter().position(|entry| {
|
||||
entry.sheet == before_sheet
|
||||
}).expect("`before_sheet` stylesheet not found");
|
||||
self.invalidations.collect_invalidations_for(
|
||||
stylist,
|
||||
&sheet,
|
||||
guard
|
||||
);
|
||||
self.collect_invalidations_for(stylist, &sheet, guard);
|
||||
self.entries.insert(index, StylesheetSetEntry { sheet });
|
||||
self.dirty = true;
|
||||
}
|
||||
|
||||
/// Remove a given stylesheet from the set.
|
||||
|
@ -150,12 +143,7 @@ where
|
|||
) {
|
||||
debug!("StylesheetSet::remove_stylesheet");
|
||||
self.remove_stylesheet_if_present(&sheet);
|
||||
self.dirty = true;
|
||||
self.invalidations.collect_invalidations_for(
|
||||
stylist,
|
||||
&sheet,
|
||||
guard
|
||||
);
|
||||
self.collect_invalidations_for(stylist, &sheet, guard);
|
||||
}
|
||||
|
||||
/// Notes that the author style has been disabled for this document.
|
||||
|
@ -165,29 +153,35 @@ where
|
|||
return;
|
||||
}
|
||||
self.author_style_disabled = disabled;
|
||||
self.dirty = true;
|
||||
self.invalidations.invalidate_fully();
|
||||
self.invalidation_data.author.invalidations.invalidate_fully();
|
||||
self.invalidation_data.author.dirty = true;
|
||||
}
|
||||
|
||||
/// Returns whether the given set has changed from the last flush.
|
||||
pub fn has_changed(&self) -> bool {
|
||||
self.dirty
|
||||
self.invalidation_data
|
||||
.iter_origins()
|
||||
.any(|(d, _)| d.dirty)
|
||||
}
|
||||
|
||||
/// Flush the current set, unmarking it as dirty, and returns an iterator
|
||||
/// over the new stylesheet list.
|
||||
pub fn flush<E>(
|
||||
&mut self,
|
||||
document_element: Option<E>
|
||||
document_element: Option<E>,
|
||||
) -> StylesheetIterator<S>
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
debug!("StylesheetSet::flush");
|
||||
debug_assert!(self.dirty);
|
||||
debug_assert!(self.has_changed());
|
||||
|
||||
self.dirty = false;
|
||||
self.invalidations.flush(document_element);
|
||||
for (data, _) in self.invalidation_data.iter_mut_origins() {
|
||||
if data.dirty {
|
||||
data.invalidations.flush(document_element);
|
||||
data.dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
self.iter()
|
||||
}
|
||||
|
@ -202,7 +196,36 @@ where
|
|||
///
|
||||
/// FIXME(emilio): Make this more granular.
|
||||
pub fn force_dirty(&mut self) {
|
||||
self.dirty = true;
|
||||
self.invalidations.invalidate_fully();
|
||||
for (data, _) in self.invalidation_data.iter_mut_origins() {
|
||||
data.invalidations.invalidate_fully();
|
||||
data.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// Mark the stylesheets for the specified origin as dirty, because
|
||||
/// something external may have invalidated it.
|
||||
pub fn force_dirty_origin(&mut self, origin: &Origin) {
|
||||
let data = self.invalidation_data.borrow_mut_for_origin(origin);
|
||||
data.invalidations.invalidate_fully();
|
||||
data.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
struct InvalidationData {
|
||||
/// The stylesheet invalidations for this origin that we still haven't
|
||||
/// processed.
|
||||
invalidations: StylesheetInvalidationSet,
|
||||
|
||||
/// Whether the sheets for this origin in the `StylesheetSet`'s entry list
|
||||
/// has changed since the last restyle.
|
||||
dirty: bool,
|
||||
}
|
||||
|
||||
impl Default for InvalidationData {
|
||||
fn default() -> Self {
|
||||
InvalidationData {
|
||||
invalidations: StylesheetInvalidationSet::new(),
|
||||
dirty: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ mod loader;
|
|||
mod media_rule;
|
||||
mod memory;
|
||||
mod namespace_rule;
|
||||
mod origin;
|
||||
mod page_rule;
|
||||
mod rule_list;
|
||||
mod rule_parser;
|
||||
|
@ -43,6 +44,7 @@ pub use self::memory::{MallocSizeOf, MallocSizeOfFn, MallocSizeOfWithGuard};
|
|||
#[cfg(feature = "gecko")]
|
||||
pub use self::memory::{MallocSizeOfWithRepeats, SizeOfState};
|
||||
pub use self::namespace_rule::NamespaceRule;
|
||||
pub use self::origin::{Origin, PerOrigin, PerOriginClear};
|
||||
pub use self::page_rule::PageRule;
|
||||
pub use self::rule_parser::{State, TopLevelRuleParser};
|
||||
pub use self::rule_list::{CssRules, CssRulesHelpers};
|
||||
|
@ -82,22 +84,6 @@ impl UrlExtraData {
|
|||
#[cfg(feature = "gecko")]
|
||||
impl Eq for UrlExtraData {}
|
||||
|
||||
/// Each style rule has an origin, which determines where it enters the cascade.
|
||||
///
|
||||
/// http://dev.w3.org/csswg/css-cascade/#cascading-origins
|
||||
#[derive(Clone, PartialEq, Eq, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum Origin {
|
||||
/// http://dev.w3.org/csswg/css-cascade/#cascade-origin-ua
|
||||
UserAgent,
|
||||
|
||||
/// http://dev.w3.org/csswg/css-cascade/#cascade-origin-author
|
||||
Author,
|
||||
|
||||
/// http://dev.w3.org/csswg/css-cascade/#cascade-origin-user
|
||||
User,
|
||||
}
|
||||
|
||||
/// A CSS rule.
|
||||
///
|
||||
/// TODO(emilio): Lots of spec links should be around.
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
/* 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/. */
|
||||
|
||||
///! [CSS cascade origins](https://drafts.csswg.org/css-cascade/#cascading-origins).
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
/// Each style rule has an origin, which determines where it enters the cascade.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-cascade/#cascading-origins
|
||||
#[derive(Clone, PartialEq, Eq, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum Origin {
|
||||
/// https://drafts.csswg.org/css-cascade/#cascade-origin-us
|
||||
UserAgent,
|
||||
|
||||
/// https://drafts.csswg.org/css-cascade/#cascade-origin-user
|
||||
User,
|
||||
|
||||
/// https://drafts.csswg.org/css-cascade/#cascade-origin-author
|
||||
Author,
|
||||
}
|
||||
|
||||
/// An object that stores a `T` for each origin of the CSS cascade.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PerOrigin<T> {
|
||||
/// Data for `Origin::UserAgent`.
|
||||
pub user_agent: T,
|
||||
|
||||
/// Data for `Origin::User`.
|
||||
pub user: T,
|
||||
|
||||
/// Data for `Origin::Author`.
|
||||
pub author: T,
|
||||
}
|
||||
|
||||
impl<T> PerOrigin<T> {
|
||||
/// Returns a reference to the per-origin data for the specified origin.
|
||||
#[inline]
|
||||
pub fn borrow_for_origin(&self, origin: &Origin) -> &T {
|
||||
match *origin {
|
||||
Origin::UserAgent => &self.user_agent,
|
||||
Origin::User => &self.user,
|
||||
Origin::Author => &self.author,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the per-origin data for the specified
|
||||
/// origin.
|
||||
#[inline]
|
||||
pub fn borrow_mut_for_origin(&mut self, origin: &Origin) -> &mut T {
|
||||
match *origin {
|
||||
Origin::UserAgent => &mut self.user_agent,
|
||||
Origin::User => &mut self.user,
|
||||
Origin::Author => &mut self.author,
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterates over references to per-origin extra style data, from highest
|
||||
/// level (author) to lowest (user agent).
|
||||
pub fn iter_origins(&self) -> PerOriginIter<T> {
|
||||
PerOriginIter {
|
||||
data: &self,
|
||||
cur: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterates over mutable references to per-origin extra style data, from
|
||||
/// highest level (author) to lowest (user agent).
|
||||
pub fn iter_mut_origins(&mut self) -> PerOriginIterMut<T> {
|
||||
PerOriginIterMut {
|
||||
data: self,
|
||||
cur: 0,
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An object that can be cleared.
|
||||
pub trait PerOriginClear {
|
||||
/// Clears the object.
|
||||
fn clear(&mut self);
|
||||
}
|
||||
|
||||
impl<T> PerOriginClear for PerOrigin<T> where T: PerOriginClear {
|
||||
fn clear(&mut self) {
|
||||
self.user_agent.clear();
|
||||
self.user.clear();
|
||||
self.author.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterator over `PerOrigin<T>`, from highest level (author) to lowest
|
||||
/// (user agent).
|
||||
///
|
||||
/// We rely on this specific order for correctly looking up @font-face,
|
||||
/// @counter-style and @keyframes rules.
|
||||
pub struct PerOriginIter<'a, T: 'a> {
|
||||
data: &'a PerOrigin<T>,
|
||||
cur: usize,
|
||||
}
|
||||
|
||||
impl<'a, T> Iterator for PerOriginIter<'a, T> where T: 'a {
|
||||
type Item = (&'a T, Origin);
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let result = match self.cur {
|
||||
0 => (&self.data.author, Origin::Author),
|
||||
1 => (&self.data.user, Origin::User),
|
||||
2 => (&self.data.user_agent, Origin::UserAgent),
|
||||
_ => return None,
|
||||
};
|
||||
self.cur += 1;
|
||||
Some(result)
|
||||
}
|
||||
}
|
||||
|
||||
/// Like `PerOriginIter<T>`, but iterates over mutable references to the
|
||||
/// per-origin data.
|
||||
///
|
||||
/// We must use unsafe code here since it's not possible for the borrow
|
||||
/// checker to know that we are safely returning a different reference
|
||||
/// each time from `next()`.
|
||||
pub struct PerOriginIterMut<'a, T: 'a> {
|
||||
data: *mut PerOrigin<T>,
|
||||
cur: usize,
|
||||
_marker: PhantomData<&'a mut PerOrigin<T>>,
|
||||
}
|
||||
|
||||
impl<'a, T> Iterator for PerOriginIterMut<'a, T> where T: 'a {
|
||||
type Item = (&'a mut T, Origin);
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
let result = match self.cur {
|
||||
0 => (unsafe { &mut (*self.data).author }, Origin::Author),
|
||||
1 => (unsafe { &mut (*self.data).user }, Origin::User),
|
||||
2 => (unsafe { &mut (*self.data).user_agent }, Origin::UserAgent),
|
||||
_ => return None,
|
||||
};
|
||||
self.cur += 1;
|
||||
Some(result)
|
||||
}
|
||||
}
|
|
@ -40,7 +40,8 @@ use style_traits::viewport::ViewportConstraints;
|
|||
#[cfg(feature = "gecko")]
|
||||
use stylesheets::{CounterStyleRule, FontFaceRule};
|
||||
use stylesheets::{CssRule, StyleRule};
|
||||
use stylesheets::{StylesheetInDocument, Origin, UserAgentStylesheets};
|
||||
use stylesheets::{StylesheetInDocument, Origin, PerOrigin, PerOriginClear};
|
||||
use stylesheets::UserAgentStylesheets;
|
||||
use stylesheets::keyframes_rule::KeyframesAnimation;
|
||||
use stylesheets::viewport_rule::{self, MaybeNew, ViewportRule};
|
||||
use thread_state;
|
||||
|
@ -73,9 +74,6 @@ pub struct Stylist {
|
|||
/// Viewport constraints based on the current device.
|
||||
viewport_constraints: Option<ViewportConstraints>,
|
||||
|
||||
/// Effective media query results cached from the last rebuild.
|
||||
effective_media_query_results: EffectiveMediaQueryResults,
|
||||
|
||||
/// If true, the quirks-mode stylesheet is applied.
|
||||
#[cfg_attr(feature = "servo", ignore_heap_size_of = "defined in selectors")]
|
||||
quirks_mode: QuirksMode,
|
||||
|
@ -83,14 +81,10 @@ pub struct Stylist {
|
|||
/// If true, the device has changed, and the stylist needs to be updated.
|
||||
is_device_dirty: bool,
|
||||
|
||||
/// If true, the stylist is in a cleared state (e.g. just-constructed, or
|
||||
/// had clear() called on it with no following rebuild()).
|
||||
is_cleared: bool,
|
||||
|
||||
/// Selector maps for all of the style sheets in the stylist, after
|
||||
/// evalutaing media rules against the current device, split out per
|
||||
/// cascade level.
|
||||
cascade_data: CascadeData,
|
||||
cascade_data: PerOrigin<CascadeData>,
|
||||
|
||||
/// The rule tree, that stores the results of selector matching.
|
||||
rule_tree: RuleTree,
|
||||
|
@ -102,98 +96,10 @@ pub struct Stylist {
|
|||
/// FIXME(emilio): Use the rule tree!
|
||||
precomputed_pseudo_element_decls: PerPseudoElementMap<Vec<ApplicableDeclarationBlock>>,
|
||||
|
||||
/// A monotonically increasing counter to represent the order on which a
|
||||
/// style rule appears in a stylesheet, needed to sort them by source order.
|
||||
rules_source_order: u32,
|
||||
|
||||
/// The total number of times the stylist has been rebuilt.
|
||||
num_rebuilds: usize,
|
||||
}
|
||||
|
||||
/// This struct holds data which users of Stylist may want to extract
|
||||
/// from stylesheets which can be done at the same time as updating.
|
||||
#[cfg(feature = "gecko")]
|
||||
#[derive(Default)]
|
||||
pub struct ExtraStyleData {
|
||||
/// Extra data from user agent stylesheets
|
||||
user_agent: PerOriginExtraStyleData,
|
||||
/// Extra data from author stylesheets
|
||||
author: PerOriginExtraStyleData,
|
||||
/// Extra data from user stylesheets
|
||||
user: PerOriginExtraStyleData,
|
||||
}
|
||||
|
||||
/// This struct holds data which users of Stylist may want to extract
|
||||
/// from stylesheets which can be done at the same time as updating.
|
||||
#[cfg(feature = "gecko")]
|
||||
#[derive(Default)]
|
||||
pub struct PerOriginExtraStyleData {
|
||||
/// A list of effective font-face rules and their origin.
|
||||
pub font_faces: Vec<Arc<Locked<FontFaceRule>>>,
|
||||
/// A map of effective counter-style rules.
|
||||
pub counter_styles: PrecomputedHashMap<Atom, Arc<Locked<CounterStyleRule>>>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl ExtraStyleData {
|
||||
/// Clear the internal data.
|
||||
pub fn clear(&mut self) {
|
||||
self.user_agent.clear();
|
||||
self.author.clear();
|
||||
self.user.clear();
|
||||
}
|
||||
|
||||
/// Returns a reference to the per-origin extra style data for
|
||||
/// the specified origin.
|
||||
#[inline]
|
||||
pub fn borrow_mut_for_origin(&mut self, origin: &Origin) -> &mut PerOriginExtraStyleData {
|
||||
match *origin {
|
||||
Origin::UserAgent => &mut self.user_agent,
|
||||
Origin::Author => &mut self.author,
|
||||
Origin::User => &mut self.user,
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterates over the per-origin extra style data, from highest level (user)
|
||||
/// to lowest (user agent).
|
||||
pub fn iter_origins(&self) -> ExtraStyleDataIter {
|
||||
ExtraStyleDataIter {
|
||||
extra_style_data: &self,
|
||||
cur: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl PerOriginExtraStyleData {
|
||||
/// Clears the stored @font-face and @counter-style rules.
|
||||
fn clear(&mut self) {
|
||||
self.font_faces.clear();
|
||||
self.counter_styles.clear();
|
||||
}
|
||||
|
||||
/// Add the given @font-face rule.
|
||||
fn add_font_face(&mut self, rule: &Arc<Locked<FontFaceRule>>) {
|
||||
self.font_faces.push(rule.clone());
|
||||
}
|
||||
|
||||
/// Add the given @counter-style rule.
|
||||
fn add_counter_style(&mut self, guard: &SharedRwLockReadGuard,
|
||||
rule: &Arc<Locked<CounterStyleRule>>) {
|
||||
let name = rule.read_with(guard).mName.raw::<nsIAtom>().into();
|
||||
self.counter_styles.insert(name, rule.clone());
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[cfg(feature = "servo")]
|
||||
pub struct ExtraStyleData;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
impl ExtraStyleData {
|
||||
fn clear(&mut self) {}
|
||||
}
|
||||
|
||||
/// What cascade levels to include when styling elements.
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum RuleInclusion {
|
||||
|
@ -225,13 +131,10 @@ impl Stylist {
|
|||
viewport_constraints: None,
|
||||
device: device,
|
||||
is_device_dirty: true,
|
||||
is_cleared: true,
|
||||
quirks_mode: quirks_mode,
|
||||
effective_media_query_results: EffectiveMediaQueryResults::new(),
|
||||
|
||||
cascade_data: CascadeData::new(),
|
||||
cascade_data: Default::default(),
|
||||
precomputed_pseudo_element_decls: PerPseudoElementMap::default(),
|
||||
rules_source_order: 0,
|
||||
rule_tree: RuleTree::new(),
|
||||
num_rebuilds: 0,
|
||||
}
|
||||
|
@ -241,12 +144,12 @@ impl Stylist {
|
|||
|
||||
/// Returns the number of selectors.
|
||||
pub fn num_selectors(&self) -> usize {
|
||||
self.cascade_data.iter_origins().map(|d| d.num_selectors).sum()
|
||||
self.cascade_data.iter_origins().map(|(d, _)| d.num_selectors).sum()
|
||||
}
|
||||
|
||||
/// Returns the number of declarations.
|
||||
pub fn num_declarations(&self) -> usize {
|
||||
self.cascade_data.iter_origins().map(|d| d.num_declarations).sum()
|
||||
self.cascade_data.iter_origins().map(|(d, _)| d.num_declarations).sum()
|
||||
}
|
||||
|
||||
/// Returns the number of times the stylist has been rebuilt.
|
||||
|
@ -257,13 +160,13 @@ impl Stylist {
|
|||
/// Returns the number of revalidation_selectors.
|
||||
pub fn num_revalidation_selectors(&self) -> usize {
|
||||
self.cascade_data.iter_origins()
|
||||
.map(|d| d.selectors_for_cache_revalidation.len()).sum()
|
||||
.map(|(d, _)| d.selectors_for_cache_revalidation.len()).sum()
|
||||
}
|
||||
|
||||
/// Returns the number of entries in invalidation maps.
|
||||
pub fn num_invalidations(&self) -> usize {
|
||||
self.cascade_data.iter_origins()
|
||||
.map(|d| d.invalidation_map.len()).sum()
|
||||
.map(|(d, _)| d.invalidation_map.len()).sum()
|
||||
}
|
||||
|
||||
/// Invokes `f` with the `InvalidationMap` for each origin.
|
||||
|
@ -274,8 +177,8 @@ impl Stylist {
|
|||
pub fn each_invalidation_map<F>(&self, mut f: F)
|
||||
where F: FnMut(&InvalidationMap)
|
||||
{
|
||||
for origin_cascade_data in self.cascade_data.iter_origins() {
|
||||
f(&origin_cascade_data.invalidation_map)
|
||||
for (data, _) in self.cascade_data.iter_origins() {
|
||||
f(&data.invalidation_map)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,32 +189,46 @@ impl Stylist {
|
|||
/// device: Someone might have set this on us.
|
||||
/// quirks_mode: Again, someone might have set this on us.
|
||||
/// num_rebuilds: clear() followed by rebuild() should just increment this
|
||||
/// rule_tree: So we can re-use rule nodes across rebuilds.
|
||||
///
|
||||
/// We don't just use struct update syntax with Stylist::new(self.device)
|
||||
/// beause for some of our members we can clear them instead of creating new
|
||||
/// objects. This does cause unfortunate code duplication with
|
||||
/// Stylist::new.
|
||||
pub fn clear(&mut self) {
|
||||
if self.is_cleared {
|
||||
return
|
||||
}
|
||||
|
||||
self.is_cleared = true;
|
||||
|
||||
self.effective_media_query_results.clear();
|
||||
self.viewport_constraints = None;
|
||||
// preserve current device
|
||||
self.is_device_dirty = true;
|
||||
// preserve current quirks_mode value
|
||||
self.cascade_data.clear();
|
||||
self.precomputed_pseudo_element_decls.clear();
|
||||
self.rules_source_order = 0;
|
||||
// We want to keep rule_tree around across stylist rebuilds.
|
||||
// preserve num_rebuilds value, since it should stay across
|
||||
// clear()/rebuild() cycles.
|
||||
self.viewport_constraints = None;
|
||||
|
||||
// XXX(heycam) Why do this, if we are preserving the Device?
|
||||
self.is_device_dirty = true;
|
||||
}
|
||||
|
||||
/// rebuild the stylist for the given document stylesheets, and optionally
|
||||
/// Clear the stylist's state for the specified origin.
|
||||
pub fn clear_origin(&mut self, origin: &Origin) {
|
||||
self.cascade_data.borrow_mut_for_origin(origin).clear();
|
||||
|
||||
if *origin == Origin::UserAgent {
|
||||
// We only collect these declarations from UA sheets.
|
||||
self.precomputed_pseudo_element_decls.clear();
|
||||
}
|
||||
|
||||
// The stored `ViewportConstraints` contains data from rules across
|
||||
// all origins.
|
||||
self.viewport_constraints = None;
|
||||
|
||||
// XXX(heycam) Why do this, if we are preserving the Device?
|
||||
self.is_device_dirty = true;
|
||||
}
|
||||
|
||||
/// Returns whether any origin's `CascadeData` has been cleared.
|
||||
fn any_origin_cleared(&self) -> bool {
|
||||
self.cascade_data
|
||||
.iter_origins()
|
||||
.any(|(d, _)| d.is_cleared)
|
||||
}
|
||||
|
||||
/// Rebuild the stylist for the given document stylesheets, and optionally
|
||||
/// with a set of user agent stylesheets.
|
||||
///
|
||||
/// This method resets all the style data each time the stylesheets change
|
||||
|
@ -324,15 +241,35 @@ impl Stylist {
|
|||
ua_stylesheets: Option<&UserAgentStylesheets>,
|
||||
stylesheets_changed: bool,
|
||||
author_style_disabled: bool,
|
||||
extra_data: &mut ExtraStyleData
|
||||
extra_data: &mut PerOrigin<ExtraStyleData>
|
||||
) -> bool
|
||||
where
|
||||
I: Iterator<Item = &'a S> + Clone,
|
||||
S: StylesheetInDocument + ToMediaListKey + 'static,
|
||||
{
|
||||
debug_assert!(!self.is_cleared || self.is_device_dirty);
|
||||
debug_assert!(!self.any_origin_cleared() || self.is_device_dirty);
|
||||
|
||||
self.is_cleared = false;
|
||||
// Determine the origins that actually need updating.
|
||||
//
|
||||
// XXX(heycam): What is the relationship between `stylesheets_changed`
|
||||
// and the `is_cleared` fields on each origin's `CascadeData`? Can
|
||||
// we avoid passing in `stylesheets_changed`?
|
||||
let mut to_update: PerOrigin<bool> = Default::default();
|
||||
|
||||
// If we're provided with a list of UA and user style sheets, then
|
||||
// we must update those cascade levels. (Servo does this, but Gecko
|
||||
// just includes the UA and User sheets in `doc_stylesheets`.)
|
||||
if ua_stylesheets.is_some() {
|
||||
to_update.user_agent = true;
|
||||
to_update.user = true;
|
||||
}
|
||||
|
||||
for (data, origin) in self.cascade_data.iter_mut_origins() {
|
||||
if data.is_cleared {
|
||||
data.is_cleared = false;
|
||||
*to_update.borrow_mut_for_origin(&origin) = true;
|
||||
}
|
||||
}
|
||||
|
||||
if !(self.is_device_dirty || stylesheets_changed) {
|
||||
return false;
|
||||
|
@ -340,8 +277,9 @@ impl Stylist {
|
|||
|
||||
self.num_rebuilds += 1;
|
||||
|
||||
// Update viewport_constraints regardless of which origins'
|
||||
// `CascadeData` we're updating.
|
||||
self.viewport_constraints = None;
|
||||
|
||||
if viewport_rule::enabled() {
|
||||
// TODO(emilio): This doesn't look so efficient.
|
||||
//
|
||||
|
@ -362,29 +300,48 @@ impl Stylist {
|
|||
self.viewport_constraints =
|
||||
ViewportConstraints::maybe_new(&self.device,
|
||||
&cascaded_rule,
|
||||
self.quirks_mode)
|
||||
self.quirks_mode);
|
||||
|
||||
if let Some(ref constraints) = self.viewport_constraints {
|
||||
self.device.account_for_viewport_rule(constraints);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref constraints) = self.viewport_constraints {
|
||||
self.device.account_for_viewport_rule(constraints);
|
||||
// XXX(heycam): We should probably just move the `extra_data` to be
|
||||
// stored on the `Stylist` instead of Gecko's `PerDocumentStyleData`.
|
||||
// That would let us clear it inside `clear()` and `clear_origin()`.
|
||||
for (update, origin) in to_update.iter_origins() {
|
||||
if *update {
|
||||
extra_data.borrow_mut_for_origin(&origin).clear();
|
||||
}
|
||||
}
|
||||
|
||||
extra_data.clear();
|
||||
|
||||
if let Some(ua_stylesheets) = ua_stylesheets {
|
||||
for stylesheet in &ua_stylesheets.user_or_user_agent_stylesheets {
|
||||
debug_assert!(matches!(
|
||||
stylesheet.contents(guards.ua_or_user).origin,
|
||||
Origin::UserAgent | Origin::User));
|
||||
self.add_stylesheet(stylesheet, guards.ua_or_user, extra_data);
|
||||
}
|
||||
|
||||
if self.quirks_mode != QuirksMode::NoQuirks {
|
||||
let stylesheet = &ua_stylesheets.quirks_mode_stylesheet;
|
||||
debug_assert!(matches!(
|
||||
stylesheet.contents(guards.ua_or_user).origin,
|
||||
Origin::UserAgent | Origin::User));
|
||||
self.add_stylesheet(&ua_stylesheets.quirks_mode_stylesheet,
|
||||
guards.ua_or_user, extra_data);
|
||||
}
|
||||
}
|
||||
|
||||
// Only use author stylesheets if author styles are enabled.
|
||||
// Only add stylesheets for origins we are updating, and only add
|
||||
// Author level sheets if author style is not disabled.
|
||||
let sheets_to_add = doc_stylesheets.filter(|s| {
|
||||
!author_style_disabled || s.origin(guards.author) != Origin::Author
|
||||
match s.contents(guards.author).origin {
|
||||
Origin::UserAgent => to_update.user_agent,
|
||||
Origin::Author => to_update.author && !author_style_disabled,
|
||||
Origin::User => to_update.user,
|
||||
}
|
||||
});
|
||||
|
||||
for stylesheet in sheets_to_add {
|
||||
|
@ -404,13 +361,13 @@ impl Stylist {
|
|||
ua_stylesheets: Option<&UserAgentStylesheets>,
|
||||
stylesheets_changed: bool,
|
||||
author_style_disabled: bool,
|
||||
extra_data: &mut ExtraStyleData
|
||||
extra_data: &mut PerOrigin<ExtraStyleData>
|
||||
) -> bool
|
||||
where
|
||||
I: Iterator<Item = &'a S> + Clone,
|
||||
S: StylesheetInDocument + ToMediaListKey + 'static,
|
||||
{
|
||||
debug_assert!(!self.is_cleared || self.is_device_dirty);
|
||||
debug_assert!(!self.any_origin_cleared() || self.is_device_dirty);
|
||||
|
||||
// We have to do a dirtiness check before clearing, because if
|
||||
// we're not actually dirty we need to no-op here.
|
||||
|
@ -426,7 +383,7 @@ impl Stylist {
|
|||
&mut self,
|
||||
stylesheet: &S,
|
||||
guard: &SharedRwLockReadGuard,
|
||||
_extra_data: &mut ExtraStyleData
|
||||
_extra_data: &mut PerOrigin<ExtraStyleData>
|
||||
)
|
||||
where
|
||||
S: StylesheetInDocument + ToMediaListKey + 'static,
|
||||
|
@ -436,13 +393,14 @@ impl Stylist {
|
|||
return;
|
||||
}
|
||||
|
||||
self.effective_media_query_results.saw_effective(stylesheet);
|
||||
|
||||
let origin = stylesheet.origin(guard);
|
||||
|
||||
let origin_cascade_data =
|
||||
self.cascade_data.borrow_mut_for_origin(&origin);
|
||||
|
||||
origin_cascade_data
|
||||
.effective_media_query_results
|
||||
.saw_effective(stylesheet);
|
||||
|
||||
for rule in stylesheet.effective_rules(&self.device, guard) {
|
||||
match *rule {
|
||||
CssRule::Style(ref locked) => {
|
||||
|
@ -467,7 +425,7 @@ impl Stylist {
|
|||
.expect("Unexpected tree pseudo-element?")
|
||||
.push(ApplicableDeclarationBlock::new(
|
||||
StyleSource::Style(locked.clone()),
|
||||
self.rules_source_order,
|
||||
origin_cascade_data.rules_source_order,
|
||||
CascadeLevel::UANormal,
|
||||
selector.specificity()
|
||||
));
|
||||
|
@ -490,7 +448,7 @@ impl Stylist {
|
|||
selector.clone(),
|
||||
hashes.clone(),
|
||||
locked.clone(),
|
||||
self.rules_source_order
|
||||
origin_cascade_data.rules_source_order
|
||||
);
|
||||
|
||||
map.insert(rule, self.quirks_mode);
|
||||
|
@ -515,18 +473,22 @@ impl Stylist {
|
|||
self.quirks_mode);
|
||||
}
|
||||
}
|
||||
self.rules_source_order += 1;
|
||||
origin_cascade_data.rules_source_order += 1;
|
||||
}
|
||||
CssRule::Import(ref lock) => {
|
||||
let import_rule = lock.read_with(guard);
|
||||
self.effective_media_query_results.saw_effective(import_rule);
|
||||
origin_cascade_data
|
||||
.effective_media_query_results
|
||||
.saw_effective(import_rule);
|
||||
|
||||
// NOTE: effective_rules visits the inner stylesheet if
|
||||
// appropriate.
|
||||
}
|
||||
CssRule::Media(ref lock) => {
|
||||
let media_rule = lock.read_with(guard);
|
||||
self.effective_media_query_results.saw_effective(media_rule);
|
||||
origin_cascade_data
|
||||
.effective_media_query_results
|
||||
.saw_effective(media_rule);
|
||||
}
|
||||
CssRule::Keyframes(ref keyframes_rule) => {
|
||||
let keyframes_rule = keyframes_rule.read_with(guard);
|
||||
|
@ -567,18 +529,18 @@ impl Stylist {
|
|||
pub fn might_have_attribute_dependency(&self,
|
||||
local_name: &LocalName)
|
||||
-> bool {
|
||||
if self.is_cleared || self.is_device_dirty {
|
||||
if self.any_origin_cleared() || self.is_device_dirty {
|
||||
// We can't tell what attributes are in our style rules until
|
||||
// we rebuild.
|
||||
true
|
||||
} else if *local_name == local_name!("style") {
|
||||
self.cascade_data
|
||||
.iter_origins()
|
||||
.any(|d| d.style_attribute_dependency)
|
||||
.any(|(d, _)| d.style_attribute_dependency)
|
||||
} else {
|
||||
self.cascade_data
|
||||
.iter_origins()
|
||||
.any(|d| {
|
||||
.any(|(d, _)| {
|
||||
d.attribute_dependencies
|
||||
.might_contain_hash(local_name.get_hash())
|
||||
})
|
||||
|
@ -588,9 +550,9 @@ impl Stylist {
|
|||
/// Returns whether the given ElementState bit might be relied upon by a
|
||||
/// selector of some rule in the stylist.
|
||||
pub fn might_have_state_dependency(&self, state: ElementState) -> bool {
|
||||
if self.is_cleared || self.is_device_dirty {
|
||||
// If self.is_cleared is true, we can't tell what states our style
|
||||
// rules rely on until we rebuild.
|
||||
if self.any_origin_cleared() || self.is_device_dirty {
|
||||
// We can't tell what states our style rules rely on until
|
||||
// we rebuild.
|
||||
true
|
||||
} else {
|
||||
self.has_state_dependency(state)
|
||||
|
@ -602,7 +564,7 @@ impl Stylist {
|
|||
pub fn has_state_dependency(&self, state: ElementState) -> bool {
|
||||
self.cascade_data
|
||||
.iter_origins()
|
||||
.any(|d| d.state_dependencies.intersects(state))
|
||||
.any(|(d, _)| d.state_dependencies.intersects(state))
|
||||
}
|
||||
|
||||
/// Computes the style for a given "precomputed" pseudo-element, taking the
|
||||
|
@ -852,6 +814,12 @@ impl Stylist {
|
|||
self.quirks_mode)
|
||||
}
|
||||
|
||||
fn has_rules_for_pseudo(&self, pseudo: &PseudoElement) -> bool {
|
||||
self.cascade_data
|
||||
.iter_origins()
|
||||
.any(|(d, _)| d.has_rules_for_pseudo(pseudo))
|
||||
}
|
||||
|
||||
/// Computes the cascade inputs for a lazily-cascaded pseudo-element.
|
||||
///
|
||||
/// See the documentation on lazy pseudo-elements in
|
||||
|
@ -868,7 +836,7 @@ impl Stylist {
|
|||
let pseudo = pseudo.canonical();
|
||||
debug_assert!(pseudo.is_lazy());
|
||||
|
||||
if !self.cascade_data.has_rules_for_pseudo(&pseudo) {
|
||||
if !self.has_rules_for_pseudo(&pseudo) {
|
||||
return CascadeInputs::default()
|
||||
}
|
||||
|
||||
|
@ -1031,8 +999,14 @@ impl Stylist {
|
|||
let effective_now =
|
||||
stylesheet.is_effective_for_device(&self.device, guard);
|
||||
|
||||
let origin = stylesheet.origin(guard);
|
||||
let origin_cascade_data =
|
||||
self.cascade_data.borrow_for_origin(&origin);
|
||||
|
||||
let effective_then =
|
||||
self.effective_media_query_results.was_effective(stylesheet);
|
||||
origin_cascade_data
|
||||
.effective_media_query_results
|
||||
.was_effective(stylesheet);
|
||||
|
||||
if effective_now != effective_then {
|
||||
debug!(" > Stylesheet changed -> {}, {}",
|
||||
|
@ -1071,7 +1045,9 @@ impl Stylist {
|
|||
import_rule.stylesheet
|
||||
.is_effective_for_device(&self.device, guard);
|
||||
let effective_then =
|
||||
self.effective_media_query_results.was_effective(import_rule);
|
||||
origin_cascade_data
|
||||
.effective_media_query_results
|
||||
.was_effective(import_rule);
|
||||
if effective_now != effective_then {
|
||||
debug!(" > @import rule changed {} -> {}",
|
||||
effective_then, effective_now);
|
||||
|
@ -1088,7 +1064,9 @@ impl Stylist {
|
|||
let effective_now =
|
||||
mq.evaluate(&self.device, self.quirks_mode);
|
||||
let effective_then =
|
||||
self.effective_media_query_results.was_effective(media_rule);
|
||||
origin_cascade_data
|
||||
.effective_media_query_results
|
||||
.was_effective(media_rule);
|
||||
if effective_now != effective_then {
|
||||
debug!(" > @media rule changed {} -> {}",
|
||||
effective_then, effective_now);
|
||||
|
@ -1324,7 +1302,7 @@ impl Stylist {
|
|||
pub fn may_have_rules_for_id(&self, id: &Atom) -> bool {
|
||||
self.cascade_data
|
||||
.iter_origins()
|
||||
.any(|d| d.mapped_ids.might_contain_hash(id.get_hash()))
|
||||
.any(|(d, _)| d.mapped_ids.might_contain_hash(id.get_hash()))
|
||||
}
|
||||
|
||||
/// Return whether the device is dirty, that is, whether the screen size or
|
||||
|
@ -1339,7 +1317,7 @@ impl Stylist {
|
|||
pub fn get_animation(&self, name: &Atom) -> Option<&KeyframesAnimation> {
|
||||
self.cascade_data
|
||||
.iter_origins()
|
||||
.filter_map(|d| d.animations.get(name))
|
||||
.filter_map(|(d, _)| d.animations.get(name))
|
||||
.next()
|
||||
}
|
||||
|
||||
|
@ -1364,8 +1342,8 @@ impl Stylist {
|
|||
// the lookups, which means that the bitvecs are comparable. We verify
|
||||
// this in the caller by asserting that the bitvecs are same-length.
|
||||
let mut results = BitVec::new();
|
||||
for origin_cascade_data in self.cascade_data.iter_origins() {
|
||||
origin_cascade_data.selectors_for_cache_revalidation.lookup(
|
||||
for (data, _) in self.cascade_data.iter_origins() {
|
||||
data.selectors_for_cache_revalidation.lookup(
|
||||
*element, self.quirks_mode, &mut |selector_and_hashes| {
|
||||
results.push(matches_selector(&selector_and_hashes.selector,
|
||||
selector_and_hashes.selector_offset,
|
||||
|
@ -1431,6 +1409,44 @@ impl Stylist {
|
|||
}
|
||||
}
|
||||
|
||||
/// This struct holds data which users of Stylist may want to extract
|
||||
/// from stylesheets which can be done at the same time as updating.
|
||||
#[derive(Default)]
|
||||
pub struct ExtraStyleData {
|
||||
/// A list of effective font-face rules and their origin.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub font_faces: Vec<Arc<Locked<FontFaceRule>>>,
|
||||
|
||||
/// A map of effective counter-style rules.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub counter_styles: PrecomputedHashMap<Atom, Arc<Locked<CounterStyleRule>>>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl ExtraStyleData {
|
||||
/// Add the given @font-face rule.
|
||||
fn add_font_face(&mut self, rule: &Arc<Locked<FontFaceRule>>) {
|
||||
self.font_faces.push(rule.clone());
|
||||
}
|
||||
|
||||
/// Add the given @counter-style rule.
|
||||
fn add_counter_style(&mut self, guard: &SharedRwLockReadGuard,
|
||||
rule: &Arc<Locked<CounterStyleRule>>) {
|
||||
let name = rule.read_with(guard).mName.raw::<nsIAtom>().into();
|
||||
self.counter_styles.insert(name, rule.clone());
|
||||
}
|
||||
}
|
||||
|
||||
impl PerOriginClear for ExtraStyleData {
|
||||
fn clear(&mut self) {
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
self.font_faces.clear();
|
||||
self.counter_styles.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// SelectorMapEntry implementation for use in our revalidation selector map.
|
||||
#[derive(Clone, Debug)]
|
||||
struct RevalidationSelectorAndHashes {
|
||||
|
@ -1599,111 +1615,11 @@ impl<'a> SelectorVisitor for StylistSelectorVisitor<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Data resulting from performing the CSS cascade.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Debug)]
|
||||
struct CascadeData {
|
||||
/// Rules from user agent stylesheets
|
||||
user_agent: PerOriginCascadeData,
|
||||
/// Rules from author stylesheets
|
||||
author: PerOriginCascadeData,
|
||||
/// Rules from user stylesheets
|
||||
user: PerOriginCascadeData,
|
||||
}
|
||||
|
||||
impl CascadeData {
|
||||
fn new() -> Self {
|
||||
CascadeData {
|
||||
user_agent: PerOriginCascadeData::new(),
|
||||
author: PerOriginCascadeData::new(),
|
||||
user: PerOriginCascadeData::new(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn borrow_mut_for_origin(&mut self, origin: &Origin) -> &mut PerOriginCascadeData {
|
||||
match *origin {
|
||||
Origin::UserAgent => &mut self.user_agent,
|
||||
Origin::Author => &mut self.author,
|
||||
Origin::User => &mut self.user,
|
||||
}
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
self.user_agent.clear();
|
||||
self.author.clear();
|
||||
self.user.clear();
|
||||
}
|
||||
|
||||
fn has_rules_for_pseudo(&self, pseudo: &PseudoElement) -> bool {
|
||||
self.iter_origins().any(|d| d.has_rules_for_pseudo(pseudo))
|
||||
}
|
||||
|
||||
fn iter_origins(&self) -> CascadeDataIter {
|
||||
CascadeDataIter {
|
||||
cascade_data: &self,
|
||||
cur: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterator over `PerOriginCascadeData`, from highest level (user) to lowest
|
||||
/// (user agent).
|
||||
///
|
||||
/// We rely on this specific order for correctly looking up animations
|
||||
/// (prioritizing rules at higher cascade levels), among other things.
|
||||
struct CascadeDataIter<'a> {
|
||||
cascade_data: &'a CascadeData,
|
||||
cur: usize,
|
||||
}
|
||||
|
||||
impl<'a> Iterator for CascadeDataIter<'a> {
|
||||
type Item = &'a PerOriginCascadeData;
|
||||
|
||||
fn next(&mut self) -> Option<&'a PerOriginCascadeData> {
|
||||
let result = match self.cur {
|
||||
0 => &self.cascade_data.user,
|
||||
1 => &self.cascade_data.author,
|
||||
2 => &self.cascade_data.user_agent,
|
||||
_ => return None,
|
||||
};
|
||||
self.cur += 1;
|
||||
Some(result)
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterator over `PerOriginExtraStyleData`, from highest level (user) to lowest
|
||||
/// (user agent).
|
||||
///
|
||||
/// We rely on this specific order for correctly looking up the @font-face
|
||||
/// and @counter-style rules.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub struct ExtraStyleDataIter<'a> {
|
||||
extra_style_data: &'a ExtraStyleData,
|
||||
cur: usize,
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl<'a> Iterator for ExtraStyleDataIter<'a> {
|
||||
type Item = (&'a PerOriginExtraStyleData, Origin);
|
||||
|
||||
fn next(&mut self) -> Option<(&'a PerOriginExtraStyleData, Origin)> {
|
||||
let result = match self.cur {
|
||||
0 => (&self.extra_style_data.user, Origin::User),
|
||||
1 => (&self.extra_style_data.author, Origin::Author),
|
||||
2 => (&self.extra_style_data.user_agent, Origin::UserAgent),
|
||||
_ => return None,
|
||||
};
|
||||
self.cur += 1;
|
||||
Some(result)
|
||||
}
|
||||
}
|
||||
|
||||
/// Data resulting from performing the CSS cascade that is specific to a given
|
||||
/// origin.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Debug)]
|
||||
struct PerOriginCascadeData {
|
||||
struct CascadeData {
|
||||
/// Rules from stylesheets at this `CascadeData`'s origin.
|
||||
element_map: SelectorMap<Rule>,
|
||||
|
||||
|
@ -1751,14 +1667,26 @@ struct PerOriginCascadeData {
|
|||
#[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")]
|
||||
selectors_for_cache_revalidation: SelectorMap<RevalidationSelectorAndHashes>,
|
||||
|
||||
/// Effective media query results cached from the last rebuild.
|
||||
effective_media_query_results: EffectiveMediaQueryResults,
|
||||
|
||||
/// A monotonically increasing counter to represent the order on which a
|
||||
/// style rule appears in a stylesheet, needed to sort them by source order.
|
||||
rules_source_order: u32,
|
||||
|
||||
/// The total number of selectors.
|
||||
num_selectors: usize,
|
||||
|
||||
/// The total number of declarations.
|
||||
num_declarations: usize,
|
||||
|
||||
/// If true, the `CascadeData` is in a cleared state (e.g. just-constructed,
|
||||
/// or had `clear()` called on it with no following `rebuild()` on the
|
||||
/// `Stylist`).
|
||||
is_cleared: bool,
|
||||
}
|
||||
|
||||
impl PerOriginCascadeData {
|
||||
impl CascadeData {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
element_map: SelectorMap::new(),
|
||||
|
@ -1770,8 +1698,11 @@ impl PerOriginCascadeData {
|
|||
state_dependencies: ElementState::empty(),
|
||||
mapped_ids: NonCountingBloomFilter::new(),
|
||||
selectors_for_cache_revalidation: SelectorMap::new(),
|
||||
effective_media_query_results: EffectiveMediaQueryResults::new(),
|
||||
rules_source_order: 0,
|
||||
num_selectors: 0,
|
||||
num_declarations: 0,
|
||||
is_cleared: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1783,7 +1714,17 @@ impl PerOriginCascadeData {
|
|||
}
|
||||
}
|
||||
|
||||
fn has_rules_for_pseudo(&self, pseudo: &PseudoElement) -> bool {
|
||||
self.pseudos_map.get(pseudo).is_some()
|
||||
}
|
||||
}
|
||||
|
||||
impl PerOriginClear for CascadeData {
|
||||
fn clear(&mut self) {
|
||||
if self.is_cleared {
|
||||
return;
|
||||
}
|
||||
|
||||
self.element_map = SelectorMap::new();
|
||||
self.pseudos_map = Default::default();
|
||||
self.animations = Default::default();
|
||||
|
@ -1793,12 +1734,17 @@ impl PerOriginCascadeData {
|
|||
self.state_dependencies = ElementState::empty();
|
||||
self.mapped_ids.clear();
|
||||
self.selectors_for_cache_revalidation = SelectorMap::new();
|
||||
self.effective_media_query_results.clear();
|
||||
self.rules_source_order = 0;
|
||||
self.num_selectors = 0;
|
||||
self.num_declarations = 0;
|
||||
self.is_cleared = true;
|
||||
}
|
||||
}
|
||||
|
||||
fn has_rules_for_pseudo(&self, pseudo: &PseudoElement) -> bool {
|
||||
self.pseudos_map.get(pseudo).is_some()
|
||||
impl Default for CascadeData {
|
||||
fn default() -> Self {
|
||||
CascadeData::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,10 @@ use style::gecko_bindings::structs::{nsCSSFontFaceRule, nsCSSCounterStyleRule};
|
|||
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, PropertyValuePair};
|
||||
use style::gecko_bindings::structs::IterationCompositeOperation;
|
||||
use style::gecko_bindings::structs::MallocSizeOf;
|
||||
use style::gecko_bindings::structs::OriginFlags;
|
||||
use style::gecko_bindings::structs::OriginFlags_Author;
|
||||
use style::gecko_bindings::structs::OriginFlags_User;
|
||||
use style::gecko_bindings::structs::OriginFlags_UserAgent;
|
||||
use style::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
||||
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
|
||||
use style::gecko_bindings::structs::SeenPtrs;
|
||||
|
@ -114,6 +118,7 @@ use style::stylesheets::{FontFeatureValuesRule, ImportRule, KeyframesRule, Mallo
|
|||
use style::stylesheets::{MallocSizeOfWithRepeats, MediaRule};
|
||||
use style::stylesheets::{NamespaceRule, Origin, PageRule, SizeOfState, StyleRule, SupportsRule};
|
||||
use style::stylesheets::StylesheetContents;
|
||||
use style::stylesheets::StylesheetInDocument;
|
||||
use style::stylesheets::StylesheetLoader as StyleStylesheetLoader;
|
||||
use style::stylesheets::keyframes_rule::{Keyframe, KeyframeSelector, KeyframesStepValue};
|
||||
use style::stylesheets::supports_rule::parse_condition_or_declaration;
|
||||
|
@ -845,12 +850,10 @@ pub extern "C" fn Servo_StyleSet_AppendStyleSheet(
|
|||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||
let mut data = &mut *data;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
data.stylesheets.append_stylesheet(
|
||||
&data.stylist,
|
||||
unsafe { GeckoStyleSheet::new(sheet) },
|
||||
&guard
|
||||
);
|
||||
data.clear_stylist();
|
||||
let sheet = unsafe { GeckoStyleSheet::new(sheet) };
|
||||
let origin = sheet.contents(&guard).origin;
|
||||
data.stylesheets.append_stylesheet(&data.stylist, sheet, &guard);
|
||||
data.clear_stylist_origin(&origin);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -894,12 +897,10 @@ pub extern "C" fn Servo_StyleSet_PrependStyleSheet(
|
|||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||
let mut data = &mut *data;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
data.stylesheets.prepend_stylesheet(
|
||||
&data.stylist,
|
||||
unsafe { GeckoStyleSheet::new(sheet) },
|
||||
&guard,
|
||||
);
|
||||
data.clear_stylist();
|
||||
let sheet = unsafe { GeckoStyleSheet::new(sheet) };
|
||||
let origin = sheet.contents(&guard).origin;
|
||||
data.stylesheets.prepend_stylesheet(&data.stylist, sheet, &guard);
|
||||
data.clear_stylist_origin(&origin);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -912,13 +913,15 @@ pub extern "C" fn Servo_StyleSet_InsertStyleSheetBefore(
|
|||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||
let mut data = &mut *data;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let sheet = unsafe { GeckoStyleSheet::new(sheet) };
|
||||
let origin = sheet.contents(&guard).origin;
|
||||
data.stylesheets.insert_stylesheet_before(
|
||||
&data.stylist,
|
||||
unsafe { GeckoStyleSheet::new(sheet) },
|
||||
sheet,
|
||||
unsafe { GeckoStyleSheet::new(before_sheet) },
|
||||
&guard,
|
||||
);
|
||||
data.clear_stylist();
|
||||
data.clear_stylist_origin(&origin);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -930,12 +933,10 @@ pub extern "C" fn Servo_StyleSet_RemoveStyleSheet(
|
|||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||
let mut data = &mut *data;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
data.stylesheets.remove_stylesheet(
|
||||
&data.stylist,
|
||||
unsafe { GeckoStyleSheet::new(sheet) },
|
||||
&guard,
|
||||
);
|
||||
data.clear_stylist();
|
||||
let sheet = unsafe { GeckoStyleSheet::new(sheet) };
|
||||
let origin = sheet.contents(&guard).origin;
|
||||
data.stylesheets.remove_stylesheet(&data.stylist, sheet, &guard);
|
||||
data.clear_stylist_origin(&origin);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -954,11 +955,14 @@ pub extern "C" fn Servo_StyleSet_FlushStyleSheets(
|
|||
pub extern "C" fn Servo_StyleSet_NoteStyleSheetsChanged(
|
||||
raw_data: RawServoStyleSetBorrowed,
|
||||
author_style_disabled: bool,
|
||||
changed_origins: OriginFlags,
|
||||
) {
|
||||
let mut data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
|
||||
data.stylesheets.force_dirty();
|
||||
for origin in changed_origins.iter() {
|
||||
data.stylesheets.force_dirty_origin(&origin);
|
||||
data.clear_stylist_origin(&origin);
|
||||
}
|
||||
data.stylesheets.set_author_style_disabled(author_style_disabled);
|
||||
data.clear_stylist();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -1008,6 +1012,17 @@ pub extern "C" fn Servo_StyleSheet_SizeOfIncludingThis(
|
|||
.malloc_size_of_children(&guard, malloc_size_of)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSheet_GetOrigin(
|
||||
sheet: RawServoStyleSheetContentsBorrowed
|
||||
) -> OriginFlags {
|
||||
match StylesheetContents::as_arc(&sheet).origin {
|
||||
Origin::UserAgent => OriginFlags_UserAgent,
|
||||
Origin::User => OriginFlags_User,
|
||||
Origin::Author => OriginFlags_Author,
|
||||
}
|
||||
}
|
||||
|
||||
fn read_locked_arc<T, R, F>(raw: &<Locked<T> as HasFFI>::FFIType, func: F) -> R
|
||||
where Locked<T>: HasArcFFI, F: FnOnce(&T) -> R
|
||||
{
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,182 +0,0 @@
|
|||
[collapseToStartEnd.html]
|
||||
type: testharness
|
||||
[Range 12 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 12 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 13 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 13 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 14 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 14 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 21 [foreignDoc.head, 1, foreignDoc.head, 1\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 21 [foreignDoc.head, 1, foreignDoc.head, 1\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 22 [foreignDoc.body, 0, foreignDoc.body, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 22 [foreignDoc.body, 0, foreignDoc.body, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 34 [foreignDoc.documentElement, 1, foreignDoc.body, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 34 [foreignDoc.documentElement, 1, foreignDoc.body, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 41 [foreignDoc, 0, foreignDoc, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 41 [foreignDoc, 0, foreignDoc, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 42 [foreignDoc, 1, foreignComment, 2\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 42 [foreignDoc, 1, foreignComment, 2\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 43 [foreignDoc.body, 0, foreignTextNode, 36\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 43 [foreignDoc.body, 0, foreignTextNode, 36\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 44 [xmlDoc, 0, xmlDoc, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 44 [xmlDoc, 0, xmlDoc, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 45 [xmlDoc, 1, xmlComment, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 45 [xmlDoc, 1, xmlComment, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 47 [detachedForeignTextNode, 7, detachedForeignTextNode, 7\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 47 [detachedForeignTextNode, 7, detachedForeignTextNode, 7\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 48 [detachedForeignTextNode, 0, detachedForeignTextNode, 8\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 48 [detachedForeignTextNode, 0, detachedForeignTextNode, 8\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 49 [detachedXmlTextNode, 7, detachedXmlTextNode, 7\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 49 [detachedXmlTextNode, 7, detachedXmlTextNode, 7\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 50 [detachedXmlTextNode, 0, detachedXmlTextNode, 8\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 50 [detachedXmlTextNode, 0, detachedXmlTextNode, 8\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 53 [detachedForeignComment, 0, detachedForeignComment, 1\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 53 [detachedForeignComment, 0, detachedForeignComment, 1\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 54 [detachedForeignComment, 4, detachedForeignComment, 4\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 54 [detachedForeignComment, 4, detachedForeignComment, 4\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 55 [detachedXmlComment, 2, detachedXmlComment, 6\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 55 [detachedXmlComment, 2, detachedXmlComment, 6\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 57 [foreignDocfrag, 0, foreignDocfrag, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 57 [foreignDocfrag, 0, foreignDocfrag, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 58 [xmlDocfrag, 0, xmlDocfrag, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 58 [xmlDocfrag, 0, xmlDocfrag, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 9 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 9 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 10 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 1\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 10 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 1\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 11 [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 11 [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 25 [detachedPara1, 0, detachedPara1, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 25 [detachedPara1, 0, detachedPara1, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 26 [detachedPara1, 0, detachedPara1, 1\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 26 [detachedPara1, 0, detachedPara1, 1\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 46 [detachedTextNode, 0, detachedTextNode, 8\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 46 [detachedTextNode, 0, detachedTextNode, 8\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 51 [detachedComment, 3, detachedComment, 4\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 51 [detachedComment, 3, detachedComment, 4\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 52 [detachedComment, 5, detachedComment, 5\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 52 [detachedComment, 5, detachedComment, 5\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 56 [docfrag, 0, docfrag, 0\] collapseToStart()]
|
||||
expected: FAIL
|
||||
|
||||
[Range 56 [docfrag, 0, docfrag, 0\] collapseToEnd()]
|
||||
expected: FAIL
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,50 +0,0 @@
|
|||
[isCollapsed.html]
|
||||
type: testharness
|
||||
[Range 9 [detachedPara1.firstChild, 0, detachedPara1.firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 10 [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 12 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 13 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 19 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 25 [detachedPara1, 0, detachedPara1, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 33 [foreignDoc.documentElement, 1, foreignDoc.body, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 41 [foreignDoc, 1, foreignComment, 2\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 42 [foreignDoc.body, 0, foreignTextNode, 36\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 44 [xmlDoc, 1, xmlComment, 0\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 45 [detachedTextNode, 0, detachedTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 47 [detachedForeignTextNode, 0, detachedForeignTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 49 [detachedXmlTextNode, 0, detachedXmlTextNode, 8\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 50 [detachedComment, 3, detachedComment, 4\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 52 [detachedForeignComment, 0, detachedForeignComment, 1\]]
|
||||
expected: FAIL
|
||||
|
||||
[Range 54 [detachedXmlComment, 2, detachedXmlComment, 6\]]
|
||||
expected: FAIL
|
||||
|
|
@ -1,191 +0,0 @@
|
|||
[removeAllRanges.html]
|
||||
type: testharness
|
||||
[Range 12 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 13 [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 14 [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 20 [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 21 [foreignDoc.head, 1, foreignDoc.head, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 22 [foreignDoc.body, 0, foreignDoc.body, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 34 [foreignDoc.documentElement, 1, foreignDoc.body, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 41 [foreignDoc, 0, foreignDoc, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 42 [foreignDoc, 1, foreignComment, 2\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 43 [foreignDoc.body, 0, foreignTextNode, 36\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 44 [xmlDoc, 0, xmlDoc, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 45 [xmlDoc, 1, xmlComment, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 47 [detachedForeignTextNode, 7, detachedForeignTextNode, 7\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 48 [detachedForeignTextNode, 0, detachedForeignTextNode, 8\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 49 [detachedXmlTextNode, 7, detachedXmlTextNode, 7\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 50 [detachedXmlTextNode, 0, detachedXmlTextNode, 8\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 53 [detachedForeignComment, 0, detachedForeignComment, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 54 [detachedForeignComment, 4, detachedForeignComment, 4\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 55 [detachedXmlComment, 2, detachedXmlComment, 6\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 57 [foreignDocfrag, 0, foreignDocfrag, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[Range 58 [xmlDocfrag, 0, xmlDocfrag, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignPara1.firstChild, 0, foreignPara1.firstChild, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignDoc.documentElement, 0, foreignDoc.documentElement, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignDoc.head, 1, foreignDoc.head, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignDoc.head, 1, foreignDoc.head, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignDoc.body, 0, foreignDoc.body, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignDoc.body, 0, foreignDoc.body, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignDoc.documentElement, 1, foreignDoc.body, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignDoc.documentElement, 1, foreignDoc.body, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignDoc, 0, foreignDoc, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignDoc, 0, foreignDoc, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignDoc, 1, foreignComment, 2\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignDoc, 1, foreignComment, 2\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignDoc.body, 0, foreignTextNode, 36\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignDoc.body, 0, foreignTextNode, 36\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [xmlDoc, 0, xmlDoc, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [xmlDoc, 0, xmlDoc, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [xmlDoc, 1, xmlComment, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [xmlDoc, 1, xmlComment, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [detachedForeignTextNode, 7, detachedForeignTextNode, 7\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [detachedForeignTextNode, 7, detachedForeignTextNode, 7\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [detachedForeignTextNode, 0, detachedForeignTextNode, 8\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [detachedForeignTextNode, 0, detachedForeignTextNode, 8\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [detachedXmlTextNode, 7, detachedXmlTextNode, 7\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [detachedXmlTextNode, 7, detachedXmlTextNode, 7\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [detachedXmlTextNode, 0, detachedXmlTextNode, 8\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [detachedXmlTextNode, 0, detachedXmlTextNode, 8\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [detachedForeignComment, 0, detachedForeignComment, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [detachedForeignComment, 0, detachedForeignComment, 1\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [detachedForeignComment, 4, detachedForeignComment, 4\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [detachedForeignComment, 4, detachedForeignComment, 4\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [detachedXmlComment, 2, detachedXmlComment, 6\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [detachedXmlComment, 2, detachedXmlComment, 6\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [foreignDocfrag, 0, foreignDocfrag, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [foreignDocfrag, 0, foreignDocfrag, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[removeAllRanges on [xmlDocfrag, 0, xmlDocfrag, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
||||
[empty on [xmlDocfrag, 0, xmlDocfrag, 0\] backwards]
|
||||
expected: FAIL
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,8 +13,13 @@ testRanges.unshift("[]");
|
|||
var range = rangeFromEndpoints([paras[0].firstChild, 0, paras[0].firstChild, 1]);
|
||||
|
||||
function testRange(rangeDesc, method) {
|
||||
var endpoints = eval(testRanges[i]);
|
||||
if (endpoints.length && (!isSelectableNode(endpoints[0]) ||
|
||||
!isSelectableNode(endpoints[2]))) {
|
||||
return;
|
||||
}
|
||||
test(function() {
|
||||
setSelectionForwards(eval(rangeDesc));
|
||||
setSelectionForwards(endpoints);
|
||||
selection[method]();
|
||||
assert_equals(selection.rangeCount, 0,
|
||||
"After " + method + "(), rangeCount must be 0");
|
||||
|
@ -28,7 +33,7 @@ function testRange(rangeDesc, method) {
|
|||
|
||||
// Copy-pasted from above
|
||||
test(function() {
|
||||
setSelectionBackwards(eval(rangeDesc));
|
||||
setSelectionBackwards(endpoints);
|
||||
selection[method]();
|
||||
assert_equals(selection.rangeCount, 0,
|
||||
"After " + method + "(), rangeCount must be 0");
|
||||
|
|
|
@ -57,7 +57,6 @@ const PREF_E10S_BLOCKED_BY_ADDONS = "extensions.e10sBlockedByAddons";
|
|||
const PREF_E10S_MULTI_BLOCKED_BY_ADDONS = "extensions.e10sMultiBlockedByAddons";
|
||||
const PREF_E10S_HAS_NONEXEMPT_ADDON = "extensions.e10s.rollout.hasAddon";
|
||||
|
||||
const KEY_APP_PROFILE = "app-profile";
|
||||
const KEY_APP_SYSTEM_ADDONS = "app-system-addons";
|
||||
const KEY_APP_SYSTEM_DEFAULTS = "app-system-defaults";
|
||||
const KEY_APP_GLOBAL = "app-global";
|
||||
|
@ -1278,11 +1277,7 @@ this.XPIDatabaseReconcile = {
|
|||
logger.warn("Disabling foreign installed add-on " + aNewAddon.id + " in "
|
||||
+ aInstallLocation.name);
|
||||
aNewAddon.userDisabled = true;
|
||||
|
||||
// If we don't have an old app version then this is a new profile in
|
||||
// which case just mark any sideloaded add-ons as already seen.
|
||||
aNewAddon.seen = (aInstallLocation.name != KEY_APP_PROFILE &&
|
||||
!aOldAppVersion);
|
||||
aNewAddon.seen = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,14 +7,17 @@ const ID = "bootstrap1@tests.mozilla.org";
|
|||
let profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
startupManager();
|
||||
// By default disable add-ons from the profile and the system-wide scope
|
||||
const SCOPES = AddonManager.SCOPE_PROFILE | AddonManager.SCOPE_SYSTEM;
|
||||
Services.prefs.setIntPref("extensions.enabledScopes", SCOPES);
|
||||
Services.prefs.setIntPref("extensions.autoDisableScopes", SCOPES);
|
||||
|
||||
// By default disable add-ons from the profile
|
||||
Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_PROFILE);
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
// Installing an add-on through the API should mark it as seen
|
||||
add_task(async function() {
|
||||
await promiseStartupManager();
|
||||
|
||||
let install = await promiseInstallFile(do_get_addon("test_bootstrap1_1"));
|
||||
do_check_eq(install.state, AddonManager.STATE_INSTALLED);
|
||||
do_check_false(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
|
||||
|
@ -47,16 +50,58 @@ add_task(async function() {
|
|||
do_check_true(addon.seen);
|
||||
|
||||
addon.uninstall();
|
||||
|
||||
await promiseShutdownManager();
|
||||
});
|
||||
|
||||
// Sideloading an add-on should mark it as unseen
|
||||
// Sideloading an add-on in the systemwide location should mark it as unseen
|
||||
add_task(async function() {
|
||||
let savedStartupScanScopes = Services.prefs.getIntPref("extensions.startupScanScopes");
|
||||
Services.prefs.setIntPref("extensions.startupScanScopes", 0);
|
||||
|
||||
let systemParentDir = gTmpD.clone();
|
||||
systemParentDir.append("systemwide-extensions");
|
||||
registerDirectory("XRESysSExtPD", systemParentDir.clone());
|
||||
do_register_cleanup(() => {
|
||||
systemParentDir.remove(true);
|
||||
});
|
||||
|
||||
let systemDir = systemParentDir.clone();
|
||||
systemDir.append(Services.appinfo.ID);
|
||||
|
||||
let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), systemDir, ID);
|
||||
// Make sure the startup code will detect sideloaded updates
|
||||
setExtensionModifiedTime(path, Date.now() - 10000);
|
||||
|
||||
await promiseStartupManager();
|
||||
await AddonManagerPrivate.getNewSideloads();
|
||||
|
||||
let addon = await promiseAddonByID(ID);
|
||||
do_check_eq(addon.version, "1.0");
|
||||
do_check_true(addon.foreignInstall);
|
||||
do_check_false(addon.seen);
|
||||
|
||||
await promiseRestartManager();
|
||||
|
||||
addon = await promiseAddonByID(ID);
|
||||
do_check_true(addon.foreignInstall);
|
||||
do_check_false(addon.seen);
|
||||
|
||||
await promiseShutdownManager();
|
||||
Services.obs.notifyObservers(path, "flush-cache-entry");
|
||||
path.remove(true);
|
||||
|
||||
Services.prefs.setIntPref("extensions.startupScanScopes", savedStartupScanScopes);
|
||||
});
|
||||
|
||||
// Sideloading an add-on in the profile should mark it as unseen and it should
|
||||
// remain unseen after an update is sideloaded.
|
||||
add_task(async function() {
|
||||
let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
|
||||
// Make sure the startup code will detect sideloaded updates
|
||||
setExtensionModifiedTime(path, Date.now() - 10000);
|
||||
|
||||
startupManager();
|
||||
await promiseStartupManager();
|
||||
|
||||
let addon = await promiseAddonByID(ID);
|
||||
do_check_eq(addon.version, "1.0");
|
||||
|
@ -76,7 +121,7 @@ add_task(async function() {
|
|||
manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir, ID);
|
||||
setExtensionModifiedTime(path, Date.now());
|
||||
|
||||
startupManager();
|
||||
await promiseStartupManager();
|
||||
|
||||
addon = await promiseAddonByID(ID);
|
||||
do_check_eq(addon.version, "2.0");
|
||||
|
@ -87,13 +132,14 @@ add_task(async function() {
|
|||
await promiseShutdownManager();
|
||||
});
|
||||
|
||||
// Sideloading an add-on should mark it as unseen
|
||||
// Sideloading an add-on in the profile should mark it as unseen and it should
|
||||
// remain unseen after a regular update.
|
||||
add_task(async function() {
|
||||
let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
|
||||
// Make sure the startup code will detect sideloaded updates
|
||||
setExtensionModifiedTime(path, Date.now() - 10000);
|
||||
|
||||
startupManager();
|
||||
await promiseStartupManager();
|
||||
|
||||
let addon = await promiseAddonByID(ID);
|
||||
do_check_eq(addon.version, "1.0");
|
||||
|
@ -126,13 +172,14 @@ add_task(async function() {
|
|||
await promiseShutdownManager();
|
||||
});
|
||||
|
||||
// Sideloading an add-on should mark it as unseen
|
||||
// After a sideloaded addon has been seen, sideloading an update should
|
||||
// not reset it to unseen.
|
||||
add_task(async function() {
|
||||
let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
|
||||
// Make sure the startup code will detect sideloaded updates
|
||||
setExtensionModifiedTime(path, Date.now() - 10000);
|
||||
|
||||
startupManager();
|
||||
await promiseStartupManager();
|
||||
|
||||
let addon = await promiseAddonByID(ID);
|
||||
do_check_eq(addon.version, "1.0");
|
||||
|
@ -154,7 +201,7 @@ add_task(async function() {
|
|||
manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir, ID);
|
||||
setExtensionModifiedTime(path, Date.now());
|
||||
|
||||
startupManager();
|
||||
await promiseStartupManager();
|
||||
|
||||
addon = await promiseAddonByID(ID);
|
||||
do_check_eq(addon.version, "2.0");
|
||||
|
@ -165,13 +212,14 @@ add_task(async function() {
|
|||
await promiseShutdownManager();
|
||||
});
|
||||
|
||||
// Sideloading an add-on should mark it as unseen
|
||||
// After a sideloaded addon has been seen, manually applying an update should
|
||||
// not reset it to unseen.
|
||||
add_task(async function() {
|
||||
let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
|
||||
// Make sure the startup code will detect sideloaded updates
|
||||
setExtensionModifiedTime(path, Date.now() - 10000);
|
||||
|
||||
startupManager();
|
||||
await promiseStartupManager();
|
||||
|
||||
let addon = await promiseAddonByID(ID);
|
||||
do_check_eq(addon.version, "1.0");
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
const ID = "bootstrap1@tests.mozilla.org";
|
||||
|
||||
Services.prefs.setIntPref("extensions.enabledScopes",
|
||||
AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_SYSTEM);
|
||||
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
BootstrapMonitor.init();
|
||||
|
||||
const globalDir = gProfD.clone();
|
||||
globalDir.append("extensions2");
|
||||
globalDir.append(gAppInfo.ID);
|
||||
registerDirectory("XRESysSExtPD", globalDir.parent);
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
// By default disable add-ons from the system
|
||||
Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_SYSTEM);
|
||||
|
||||
// When new add-ons already exist in a system location when starting with a new
|
||||
// profile they should be marked as already seen.
|
||||
add_task(async function() {
|
||||
manuallyInstall(do_get_addon("test_bootstrap1_1"), globalDir, ID);
|
||||
|
||||
startupManager();
|
||||
|
||||
let addon = await promiseAddonByID(ID);
|
||||
do_check_true(addon.foreignInstall);
|
||||
do_check_true(addon.seen);
|
||||
do_check_true(addon.userDisabled);
|
||||
do_check_false(addon.isActive);
|
||||
|
||||
BootstrapMonitor.checkAddonInstalled(ID);
|
||||
BootstrapMonitor.checkAddonNotStarted(ID);
|
||||
|
||||
await promiseShutdownManager();
|
||||
});
|
|
@ -312,7 +312,6 @@ run-sequentially = Uses hardcoded ports in xpi files.
|
|||
[test_json_updatecheck.js]
|
||||
[test_migrate_state_prefs.js]
|
||||
[test_seen.js]
|
||||
[test_seen_newprofile.js]
|
||||
[test_updateid.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
|
|
|
@ -267,19 +267,7 @@ class FormatProvider(MachCommandBase):
|
|||
"--include", "glob:**.h",
|
||||
"--exclude", "listfile:.clang-format-ignore"], stdout=PIPE)
|
||||
else:
|
||||
git_process = Popen(["git", "diff", "--no-color", "-U0", "HEAD^"], stdout=PIPE)
|
||||
try:
|
||||
diff_process = Popen(["filterdiff", "--include=*.h",
|
||||
"--include=*.cpp", "--include=*.c",
|
||||
"--exclude-from-file=.clang-format-ignore"],
|
||||
stdin=git_process.stdout, stdout=PIPE)
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
print("Can't find filterdiff. Please install patchutils.")
|
||||
else:
|
||||
print("OSError {0}: {1}".format(e.code, e.reason))
|
||||
return 1
|
||||
|
||||
diff_process = Popen(["git", "diff", "--no-color", "-U0", "HEAD","--","*.c","*.cpp","*.h"], stdout=PIPE)
|
||||
args = [sys.executable, clang_format_diff, "-p1"]
|
||||
if not show:
|
||||
args.append("-i")
|
||||
|
|
|
@ -66,12 +66,10 @@ def attributeParamlist(a, getter):
|
|||
|
||||
|
||||
def attributeAsNative(a, getter, declType = 'NS_IMETHOD'):
|
||||
deprecated = a.deprecated and "NS_DEPRECATED " or ""
|
||||
params = {'deprecated': deprecated,
|
||||
'returntype': attributeReturnType(a, declType),
|
||||
params = {'returntype': attributeReturnType(a, declType),
|
||||
'binaryname': attributeNativeName(a, getter),
|
||||
'paramlist': attributeParamlist(a, getter)}
|
||||
return "%(deprecated)s%(returntype)s %(binaryname)s(%(paramlist)s)" % params
|
||||
return "%(returntype)s %(binaryname)s(%(paramlist)s)" % params
|
||||
|
||||
|
||||
def methodNativeName(m):
|
||||
|
@ -393,8 +391,6 @@ def write_interface(iface, fd):
|
|||
if not foundcdata:
|
||||
fd.write("NS_NO_VTABLE ")
|
||||
|
||||
if iface.attributes.deprecated:
|
||||
fd.write("MOZ_DEPRECATED ")
|
||||
fd.write(iface.name)
|
||||
if iface.base:
|
||||
fd.write(" : public %s" % iface.base)
|
||||
|
|
|
@ -33,7 +33,7 @@ class TestParser(unittest.TestCase):
|
|||
self.assertEqual("foo", i.productions[0].name)
|
||||
|
||||
def testAttributes(self):
|
||||
i = self.p.parse("[scriptable, builtinclass, function, deprecated, uuid(abc)] interface foo {};", filename='f')
|
||||
i = self.p.parse("[scriptable, builtinclass, function, uuid(abc)] interface foo {};", filename='f')
|
||||
self.assertTrue(isinstance(i, xpidl.IDL))
|
||||
self.assertTrue(isinstance(i.productions[0], xpidl.Interface))
|
||||
iface = i.productions[0]
|
||||
|
@ -41,7 +41,6 @@ class TestParser(unittest.TestCase):
|
|||
self.assertTrue(iface.attributes.scriptable)
|
||||
self.assertTrue(iface.attributes.builtinclass)
|
||||
self.assertTrue(iface.attributes.function)
|
||||
self.assertTrue(iface.attributes.deprecated)
|
||||
|
||||
i = self.p.parse("[noscript, uuid(abc)] interface foo {};", filename='f')
|
||||
self.assertTrue(isinstance(i, xpidl.IDL))
|
||||
|
|
|
@ -602,7 +602,6 @@ class InterfaceAttributes(object):
|
|||
scriptable = False
|
||||
builtinclass = False
|
||||
function = False
|
||||
deprecated = False
|
||||
noscript = False
|
||||
main_process_scriptable_only = False
|
||||
|
||||
|
@ -621,9 +620,6 @@ class InterfaceAttributes(object):
|
|||
def setbuiltinclass(self):
|
||||
self.builtinclass = True
|
||||
|
||||
def setdeprecated(self):
|
||||
self.deprecated = True
|
||||
|
||||
def setmain_process_scriptable_only(self):
|
||||
self.main_process_scriptable_only = True
|
||||
|
||||
|
@ -633,7 +629,6 @@ class InterfaceAttributes(object):
|
|||
'builtinclass': (False, setbuiltinclass),
|
||||
'function': (False, setfunction),
|
||||
'noscript': (False, setnoscript),
|
||||
'deprecated': (False, setdeprecated),
|
||||
'object': (False, lambda self: True),
|
||||
'main_process_scriptable_only': (False, setmain_process_scriptable_only),
|
||||
}
|
||||
|
@ -716,7 +711,6 @@ class Attribute(object):
|
|||
binaryname = None
|
||||
null = None
|
||||
undefined = None
|
||||
deprecated = False
|
||||
infallible = False
|
||||
|
||||
def __init__(self, type, name, attlist, readonly, location, doccomments):
|
||||
|
@ -764,8 +758,6 @@ class Attribute(object):
|
|||
self.noscript = True
|
||||
elif name == 'implicit_jscontext':
|
||||
self.implicit_jscontext = True
|
||||
elif name == 'deprecated':
|
||||
self.deprecated = True
|
||||
elif name == 'nostdcall':
|
||||
self.nostdcall = True
|
||||
elif name == 'must_use':
|
||||
|
@ -822,7 +814,6 @@ class Method(object):
|
|||
nostdcall = False
|
||||
must_use = False
|
||||
optional_argc = False
|
||||
deprecated = False
|
||||
|
||||
def __init__(self, type, name, attlist, paramlist, location, doccomments, raises):
|
||||
self.type = type
|
||||
|
@ -853,8 +844,6 @@ class Method(object):
|
|||
self.implicit_jscontext = True
|
||||
elif name == 'optional_argc':
|
||||
self.optional_argc = True
|
||||
elif name == 'deprecated':
|
||||
self.deprecated = True
|
||||
elif name == 'nostdcall':
|
||||
self.nostdcall = True
|
||||
elif name == 'must_use':
|
||||
|
|
Загрузка…
Ссылка в новой задаче