зеркало из https://github.com/mozilla/gecko-dev.git
Backout changesets 20bd44c62c89, 7fbc0a154eaa, and b8cfaab9ac09 (bug 1346256)
For touching servo/. (This is Autoland's fault for landing it.) --HG-- extra : amend_source : a31555ab2a959af8e57f78f4f8b1d5e9700c0fb7 extra : histedit_source : 73e44d941d04553b9766ca75d3ad33618fe4f3f5%2C8f568b83aec10dc07a1e9c6cf2b32797cb9236e3
This commit is contained in:
Родитель
0048196e85
Коммит
4d56c2a609
|
@ -52,9 +52,6 @@
|
|||
#include "mozilla/StyleSetHandleInlines.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/ServoCSSRuleList.h"
|
||||
#include "mozilla/ServoStyleRule.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::css;
|
||||
|
@ -246,12 +243,7 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
|
|||
}
|
||||
|
||||
NonOwningStyleContextSource source = styleContext->StyleSource();
|
||||
if (source.IsNull()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMutableArray> rules = nsArray::Create();
|
||||
if (source.IsGeckoRuleNodeOrNull()) {
|
||||
if (!source.IsNull() && source.IsGeckoRuleNodeOrNull()) {
|
||||
nsRuleNode* ruleNode = source.AsGeckoRuleNode();
|
||||
|
||||
AutoTArray<nsRuleNode*, 16> ruleNodes;
|
||||
|
@ -260,6 +252,7 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
|
|||
ruleNode = ruleNode->GetParent();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMutableArray> rules = nsArray::Create();
|
||||
for (nsRuleNode* ruleNode : Reversed(ruleNodes)) {
|
||||
RefPtr<Declaration> decl = do_QueryObject(ruleNode->GetRule());
|
||||
if (decl) {
|
||||
|
@ -269,46 +262,10 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// It's a Servo source, so use some servo methods on the element to get
|
||||
// the rule list.
|
||||
nsTArray<const RawServoStyleRule*> rawRuleList;
|
||||
Servo_Element_GetStyleRuleList(element, &rawRuleList);
|
||||
size_t rawRuleCount = rawRuleList.Length();
|
||||
|
||||
// We have RawServoStyleRules, and now we'll map them to ServoStyleRules
|
||||
// by looking them up in the ServoStyleSheets owned by this document.
|
||||
ServoCSSRuleList::StyleRuleHashtable rawRulesToRules;
|
||||
|
||||
nsIDocument* document = element->GetOwnerDocument();
|
||||
int32_t sheetCount = document->GetNumberOfStyleSheets();
|
||||
|
||||
for (int32_t i = 0; i < sheetCount; i++) {
|
||||
StyleSheet* sheet = document->GetStyleSheetAt(i);
|
||||
MOZ_ASSERT(sheet->IsServo());
|
||||
|
||||
ErrorResult ignored;
|
||||
ServoCSSRuleList* ruleList = static_cast<ServoCSSRuleList*>(
|
||||
sheet->GetCssRules(*nsContentUtils::SubjectPrincipal(), ignored));
|
||||
if (ruleList) {
|
||||
// Generate the map from raw rules to rules.
|
||||
ruleList->FillStyleRuleHashtable(rawRulesToRules);
|
||||
}
|
||||
}
|
||||
|
||||
// Find matching rules in the table.
|
||||
for (size_t j = 0; j < rawRuleCount; j++) {
|
||||
const RawServoStyleRule* rawRule = rawRuleList.ElementAt(j);
|
||||
ServoStyleRule* rule;
|
||||
rawRulesToRules.Get(rawRule, &rule);
|
||||
MOZ_ASSERT(rule, "We should always be able to map a raw rule to a rule.");
|
||||
RefPtr<css::Rule> ruleObj(rule);
|
||||
rules->AppendElement(ruleObj, false);
|
||||
}
|
||||
rules.forget(_retval);
|
||||
}
|
||||
|
||||
rules.forget(_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -296,12 +296,6 @@ SERVO_BINDING_FUNC(Servo_Shutdown, void)
|
|||
SERVO_BINDING_FUNC(Servo_Element_GetSnapshot, ServoElementSnapshot*,
|
||||
RawGeckoElementBorrowed element)
|
||||
|
||||
// Gets the source style rules for the element. This returns the result via
|
||||
// rules, which would include a list of unowned pointers to RawServoStyleRule.
|
||||
SERVO_BINDING_FUNC(Servo_Element_GetStyleRuleList, void,
|
||||
RawGeckoElementBorrowed element,
|
||||
RawGeckoServoStyleRuleListBorrowedMut rules)
|
||||
|
||||
// Restyle and change hints.
|
||||
SERVO_BINDING_FUNC(Servo_NoteExplicitHints, void, RawGeckoElementBorrowed element,
|
||||
nsRestyleHint restyle_hint, nsChangeHint change_hint)
|
||||
|
|
|
@ -56,7 +56,6 @@ typedef nsStyleAutoArray<mozilla::StyleAnimation> RawGeckoStyleAnimationList;
|
|||
typedef nsTArray<nsFontFaceRuleContainer> RawGeckoFontFaceRuleList;
|
||||
typedef mozilla::AnimationPropertySegment RawGeckoAnimationPropertySegment;
|
||||
typedef mozilla::ComputedTiming RawGeckoComputedTiming;
|
||||
typedef nsTArray<const RawServoStyleRule*> RawGeckoServoStyleRuleList;
|
||||
|
||||
// We have these helper types so that we can directly generate
|
||||
// things like &T or Borrowed<T> on the Rust side in the function, providing
|
||||
|
@ -136,7 +135,6 @@ DECL_BORROWED_REF_TYPE_FOR(nsTimingFunction)
|
|||
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoFontFaceRuleList)
|
||||
DECL_BORROWED_REF_TYPE_FOR(RawGeckoAnimationPropertySegment)
|
||||
DECL_BORROWED_REF_TYPE_FOR(RawGeckoComputedTiming)
|
||||
DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoServoStyleRuleList)
|
||||
|
||||
#undef DECL_ARC_REF_TYPE_FOR
|
||||
#undef DECL_OWNED_REF_TYPE_FOR
|
||||
|
|
|
@ -202,26 +202,6 @@ ServoCSSRuleList::GetRuleType(uint32_t aIndex) const
|
|||
return CastToPtr(rule)->Type();
|
||||
}
|
||||
|
||||
void
|
||||
ServoCSSRuleList::FillStyleRuleHashtable(StyleRuleHashtable& aTable)
|
||||
{
|
||||
for (uint32_t i = 0; i < mRules.Length(); i++) {
|
||||
uint16_t type = GetRuleType(i);
|
||||
if (type == nsIDOMCSSRule::STYLE_RULE) {
|
||||
ServoStyleRule* castedRule = static_cast<ServoStyleRule*>(GetRule(i));
|
||||
RawServoStyleRule* rawRule = castedRule->Raw();
|
||||
aTable.Put(rawRule, castedRule);
|
||||
} else if (type == nsIDOMCSSRule::MEDIA_RULE) {
|
||||
ServoMediaRule* castedRule = static_cast<ServoMediaRule*>(GetRule(i));
|
||||
|
||||
// Call this method recursively on the ServoCSSRuleList in the rule.
|
||||
ServoCSSRuleList* castedRuleList = static_cast<ServoCSSRuleList*>(
|
||||
castedRule->CssRules());
|
||||
castedRuleList->FillStyleRuleHashtable(aTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ServoCSSRuleList::~ServoCSSRuleList()
|
||||
{
|
||||
DropAllRules();
|
||||
|
|
|
@ -11,11 +11,9 @@
|
|||
|
||||
#include "mozilla/ServoBindingTypes.h"
|
||||
#include "mozilla/dom/CSSRuleList.h"
|
||||
#include "nsDataHashtable.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ServoStyleRule;
|
||||
class ServoStyleSheet;
|
||||
namespace css {
|
||||
class GroupRule;
|
||||
|
@ -46,10 +44,6 @@ public:
|
|||
|
||||
uint16_t GetRuleType(uint32_t aIndex) const;
|
||||
|
||||
typedef nsDataHashtable<nsPtrHashKey<const RawServoStyleRule>,
|
||||
ServoStyleRule*> StyleRuleHashtable;
|
||||
void FillStyleRuleHashtable(StyleRuleHashtable& aTable);
|
||||
|
||||
private:
|
||||
virtual ~ServoCSSRuleList();
|
||||
|
||||
|
|
|
@ -610,11 +610,9 @@ mod bindings {
|
|||
"RawServoAnimationValue",
|
||||
"RawServoAnimationValueMap",
|
||||
"RawServoDeclarationBlock",
|
||||
"RawServoStyleRule",
|
||||
"RawGeckoPresContext",
|
||||
"RawGeckoPresContextOwned",
|
||||
"RawGeckoStyleAnimationList",
|
||||
"RawGeckoServoStyleRuleList",
|
||||
"RawGeckoURLExtraData",
|
||||
"RefPtr",
|
||||
"CSSPseudoClassType",
|
||||
|
@ -726,7 +724,6 @@ mod bindings {
|
|||
"RawGeckoKeyframeList",
|
||||
"RawGeckoComputedKeyframeValuesList",
|
||||
"RawGeckoFontFaceRuleList",
|
||||
"RawGeckoServoStyleRuleList",
|
||||
];
|
||||
for &ty in structs_types.iter() {
|
||||
builder = builder.hide_type(ty)
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
#![allow(non_snake_case, missing_docs)]
|
||||
|
||||
use gecko_bindings::bindings::{RawServoMediaList, RawServoMediaRule, RawServoNamespaceRule};
|
||||
use gecko_bindings::bindings::{RawServoStyleSheet, RawServoImportRule};
|
||||
use gecko_bindings::bindings::{RawServoStyleSheet, RawServoStyleRule, RawServoImportRule};
|
||||
use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules};
|
||||
use gecko_bindings::structs::{RawServoAnimationValue, RawServoAnimationValueMap};
|
||||
use gecko_bindings::structs::{RawServoDeclarationBlock, RawServoStyleRule};
|
||||
use gecko_bindings::structs::{RawServoAnimationValue, RawServoAnimationValueMap, RawServoDeclarationBlock};
|
||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI};
|
||||
use media_queries::MediaList;
|
||||
use parking_lot::RwLock;
|
||||
|
|
|
@ -32,6 +32,7 @@ use style::gecko_bindings::bindings::{RawServoDeclarationBlockBorrowed, RawServo
|
|||
use style::gecko_bindings::bindings::{RawServoMediaListBorrowed, RawServoMediaListStrong};
|
||||
use style::gecko_bindings::bindings::{RawServoMediaRule, RawServoMediaRuleBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoNamespaceRule, RawServoNamespaceRuleBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleRule, RawServoStyleRuleBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleSetBorrowed, RawServoStyleSetOwned};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleSheetBorrowed, ServoComputedValuesBorrowed};
|
||||
use style::gecko_bindings::bindings::{RawServoStyleSheetStrong, ServoComputedValuesStrong};
|
||||
|
@ -43,12 +44,10 @@ use style::gecko_bindings::bindings::RawGeckoComputedKeyframeValuesListBorrowedM
|
|||
use style::gecko_bindings::bindings::RawGeckoComputedTimingBorrowed;
|
||||
use style::gecko_bindings::bindings::RawGeckoElementBorrowed;
|
||||
use style::gecko_bindings::bindings::RawGeckoFontFaceRuleListBorrowedMut;
|
||||
use style::gecko_bindings::bindings::RawGeckoServoStyleRuleListBorrowedMut;
|
||||
use style::gecko_bindings::bindings::RawServoAnimationValueBorrowed;
|
||||
use style::gecko_bindings::bindings::RawServoAnimationValueMapBorrowed;
|
||||
use style::gecko_bindings::bindings::RawServoAnimationValueStrong;
|
||||
use style::gecko_bindings::bindings::RawServoImportRuleBorrowed;
|
||||
use style::gecko_bindings::bindings::RawServoStyleRuleBorrowed;
|
||||
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
|
||||
use style::gecko_bindings::bindings::nsTimingFunctionBorrowed;
|
||||
|
@ -58,7 +57,7 @@ use style::gecko_bindings::structs::{SheetParsingMode, nsIAtom, nsCSSPropertyID}
|
|||
use style::gecko_bindings::structs::{nsRestyleHint, nsChangeHint, nsCSSFontFaceRule};
|
||||
use style::gecko_bindings::structs::Loader;
|
||||
use style::gecko_bindings::structs::RawGeckoPresContextOwned;
|
||||
use style::gecko_bindings::structs::{RawServoStyleRule, ServoStyleSheet};
|
||||
use style::gecko_bindings::structs::ServoStyleSheet;
|
||||
use style::gecko_bindings::structs::URLExtraData;
|
||||
use style::gecko_bindings::structs::nsCSSValueSharedList;
|
||||
use style::gecko_bindings::structs::nsresult;
|
||||
|
@ -76,7 +75,6 @@ use style::properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
|||
use style::properties::animated_properties::{AnimationValue, Interpolate, TransitionProperty};
|
||||
use style::properties::parse_one_declaration;
|
||||
use style::restyle_hints::{self, RestyleHint};
|
||||
use style::rule_tree::StyleSource;
|
||||
use style::selector_parser::PseudoElementCascadeType;
|
||||
use style::sequential;
|
||||
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards, ToCssWithGuard, Locked};
|
||||
|
@ -1529,30 +1527,6 @@ pub extern "C" fn Servo_Element_GetSnapshot(element: RawGeckoElementBorrowed) ->
|
|||
snapshot
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_Element_GetStyleRuleList(element: RawGeckoElementBorrowed,
|
||||
rules: RawGeckoServoStyleRuleListBorrowedMut) {
|
||||
let element = GeckoElement(element);
|
||||
let data = match element.borrow_data() {
|
||||
Some(element_data) => element_data,
|
||||
None => return,
|
||||
};
|
||||
let computed = match data.get_styles() {
|
||||
Some(styles) => &styles.primary,
|
||||
None => return,
|
||||
};
|
||||
let mut result = vec![];
|
||||
for rule_node in computed.rules.self_and_ancestors() {
|
||||
if let Some(&StyleSource::Style(ref rule)) = rule_node.style_source() {
|
||||
result.push(Locked::<StyleRule>::arc_as_borrowed(&rule));
|
||||
}
|
||||
}
|
||||
unsafe { rules.set_len(result.len() as u32) };
|
||||
for (&src, dest) in result.into_iter().zip(rules.iter_mut()) {
|
||||
*dest = src;
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_NoteExplicitHints(element: RawGeckoElementBorrowed,
|
||||
restyle_hint: nsRestyleHint,
|
||||
|
|
Загрузка…
Ссылка в новой задаче