mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 11:57:32 +09:00
Issue #2111 - Implement CSSStyleRule.selectorText setter
Unlike the original patch, this copies Chrome behavior: ignores invalid values of selectorText without any console log. Partially based on https://bugzilla.mozilla.org/show_bug.cgi?id=37468
This commit is contained in:
parent
87eaaee953
commit
6d3500bb48
4 changed files with 45 additions and 3 deletions
|
|
@ -1618,6 +1618,12 @@ CSSStyleSheet::DidDirty()
|
||||||
ClearRuleCascades();
|
ClearRuleCascades();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CSSStyleSheet::AssertHasUniqueInner()
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(mInner->mSheets.Length() == 1, "expected unique inner");
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
CSSStyleSheet::RegisterNamespaceRule(css::Rule* aRule)
|
CSSStyleSheet::RegisterNamespaceRule(css::Rule* aRule)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,7 @@ public:
|
||||||
|
|
||||||
void WillDirty();
|
void WillDirty();
|
||||||
void DidDirty();
|
void DidDirty();
|
||||||
|
void AssertHasUniqueInner();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSSStyleSheet(const CSSStyleSheet& aCopy,
|
CSSStyleSheet(const CSSStyleSheet& aCopy,
|
||||||
|
|
|
||||||
|
|
@ -1571,9 +1571,43 @@ StyleRule::GetSelectorText(nsAString& aSelectorText)
|
||||||
void
|
void
|
||||||
StyleRule::SetSelectorText(const nsAString& aSelectorText)
|
StyleRule::SetSelectorText(const nsAString& aSelectorText)
|
||||||
{
|
{
|
||||||
// XXX TBI - get a parser and re-parse the selectors,
|
CSSStyleSheet* sheet = GetStyleSheet();
|
||||||
// XXX then need to re-compute the cascade
|
|
||||||
// XXX and dirty sheet
|
nsIDocument* doc = GetDocument();
|
||||||
|
RefPtr<css::Loader> loader;
|
||||||
|
|
||||||
|
if (doc) {
|
||||||
|
loader = doc->CSSLoader();
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Passing a null loader means that the parser is always in
|
||||||
|
// standards mode and never in quirks mode.
|
||||||
|
nsCSSParser css(loader, sheet);
|
||||||
|
|
||||||
|
// StyleRule lives inside of the Inner, it is unsafe to call WillDirty
|
||||||
|
// if sheet does not already have a unique Inner.
|
||||||
|
sheet->AssertHasUniqueInner();
|
||||||
|
sheet->WillDirty();
|
||||||
|
|
||||||
|
nsCSSSelectorList* selectorList = nullptr;
|
||||||
|
|
||||||
|
nsresult result = css.ParseSelectorString(
|
||||||
|
aSelectorText, sheet->GetSheetURI(), 0, &selectorList);
|
||||||
|
if (NS_FAILED(result)) {
|
||||||
|
// Ignore parsing errors and continue to use the previous value.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace selector.
|
||||||
|
delete mSelector;
|
||||||
|
mSelector = selectorList;
|
||||||
|
|
||||||
|
sheet->DidDirty();
|
||||||
|
|
||||||
|
if (doc) {
|
||||||
|
mozAutoDocUpdate updateBatch(doc, UPDATE_STYLE, true);
|
||||||
|
doc->StyleRuleChanged(sheet, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* virtual */ size_t
|
/* virtual */ size_t
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,7 @@ public:
|
||||||
// WillDirty and then make no change and skip the DidDirty call.
|
// WillDirty and then make no change and skip the DidDirty call.
|
||||||
inline void WillDirty();
|
inline void WillDirty();
|
||||||
inline void DidDirty();
|
inline void DidDirty();
|
||||||
|
inline void AssertHasUniqueInner();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Get a handle to the various stylesheet bits which live on the 'inner' for
|
// Get a handle to the various stylesheet bits which live on the 'inner' for
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue