mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
Issue #2112 - Part 5: Remove Servo from forwarding code used by magic pointer classes
This commit is contained in:
parent
b1c9206051
commit
a93a7bed47
52 changed files with 274 additions and 1116 deletions
|
|
@ -33,53 +33,21 @@ struct NonOwningStyleContextSource
|
|||
: mBits(reinterpret_cast<uintptr_t>(aComputedValues) | 1) {}
|
||||
|
||||
bool operator==(const NonOwningStyleContextSource& aOther) const {
|
||||
MOZ_ASSERT(IsServoComputedValues() == aOther.IsServoComputedValues(),
|
||||
"Comparing Servo to Gecko - probably a bug");
|
||||
// TODO: remove this servo-specific function.
|
||||
return mBits == aOther.mBits;
|
||||
}
|
||||
bool operator!=(const NonOwningStyleContextSource& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
|
||||
// We intentionally avoid exposing IsGeckoRuleNode() here, because that would
|
||||
// encourage callers to do:
|
||||
//
|
||||
// if (source.IsGeckoRuleNode()) {
|
||||
// // Code that we would run unconditionally if it weren't for Servo.
|
||||
// }
|
||||
//
|
||||
// We want these branches to compile away when MOZ_STYLO is disabled, but that
|
||||
// won't happen if there's an implicit null-check.
|
||||
bool IsNull() const { return !mBits; }
|
||||
bool IsGeckoRuleNodeOrNull() const { return !IsServoComputedValues(); }
|
||||
bool IsServoComputedValues() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsRuleNode* AsGeckoRuleNode() const {
|
||||
MOZ_ASSERT(IsGeckoRuleNodeOrNull() && !IsNull());
|
||||
return reinterpret_cast<nsRuleNode*>(mBits);
|
||||
}
|
||||
|
||||
const ServoComputedValues* AsServoComputedValues() const {
|
||||
MOZ_ASSERT(IsServoComputedValues());
|
||||
return reinterpret_cast<ServoComputedValues*>(mBits & ~1);
|
||||
}
|
||||
|
||||
bool MatchesNoRules() const {
|
||||
if (IsGeckoRuleNodeOrNull()) {
|
||||
return AsGeckoRuleNode()->IsRoot();
|
||||
}
|
||||
|
||||
// Just assume a Servo-backed StyleContextSource always matches some rules.
|
||||
//
|
||||
// MatchesNoRules is used to ensure style contexts that match no rules
|
||||
// go into a separate mEmptyChild list on their parent. This is only used
|
||||
// as an optimization so that calling FindChildWithRules for style context
|
||||
// sharing is faster for text nodes (which match no rules, and are common).
|
||||
// Since Servo will handle sharing for us, there's no need to split children
|
||||
// into two lists.
|
||||
return false;
|
||||
return AsGeckoRuleNode()->IsRoot();
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -118,12 +86,8 @@ struct OwningStyleContextSource
|
|||
MOZ_COUNT_DTOR(OwningStyleContextSource);
|
||||
if (mRaw.IsNull()) {
|
||||
// We must have invoked the move constructor.
|
||||
} else if (IsGeckoRuleNode()) {
|
||||
RefPtr<nsRuleNode> releaseme = dont_AddRef(AsGeckoRuleNode());
|
||||
} else {
|
||||
MOZ_ASSERT(IsServoComputedValues());
|
||||
RefPtr<ServoComputedValues> releaseme =
|
||||
dont_AddRef(AsServoComputedValues());
|
||||
RefPtr<nsRuleNode> releaseme = dont_AddRef(AsGeckoRuleNode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,17 +98,9 @@ struct OwningStyleContextSource
|
|||
return !(*this == aOther);
|
||||
}
|
||||
bool IsNull() const { return mRaw.IsNull(); }
|
||||
bool IsGeckoRuleNode() const {
|
||||
MOZ_ASSERT(!mRaw.IsNull());
|
||||
return mRaw.IsGeckoRuleNodeOrNull();
|
||||
}
|
||||
bool IsServoComputedValues() const { return mRaw.IsServoComputedValues(); }
|
||||
|
||||
NonOwningStyleContextSource AsRaw() const { return mRaw; }
|
||||
nsRuleNode* AsGeckoRuleNode() const { return mRaw.AsGeckoRuleNode(); }
|
||||
ServoComputedValues* AsServoComputedValues() const {
|
||||
return const_cast<ServoComputedValues*>(mRaw.AsServoComputedValues());
|
||||
}
|
||||
|
||||
bool MatchesNoRules() const { return mRaw.MatchesNoRules(); }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue