本文整理汇总了C++中ShadowRoot::RemoveSheet方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadowRoot::RemoveSheet方法的具体用法?C++ ShadowRoot::RemoveSheet怎么用?C++ ShadowRoot::RemoveSheet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadowRoot
的用法示例。
在下文中一共展示了ShadowRoot::RemoveSheet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CallQueryInterface
void
nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
{
if (!mStyleSheet) {
return;
}
if (mStyleSheet->IsServo()) {
// XXXheycam ServoStyleSheets don't support <style scoped>.
NS_ERROR("stylo: ServoStyleSheets don't support <style scoped>");
return;
}
CSSStyleSheet* sheet = mStyleSheet->AsGecko();
nsCOMPtr<nsIContent> thisContent;
CallQueryInterface(this, getter_AddRefs(thisContent));
Element* oldScopeElement = sheet->GetScopeElement();
Element* newScopeElement = aIsNowScoped ?
thisContent->GetParentElement() :
nullptr;
if (oldScopeElement == newScopeElement) {
return;
}
nsIDocument* document = thisContent->GetOwnerDocument();
if (thisContent->IsInShadowTree()) {
ShadowRoot* containingShadow = thisContent->GetContainingShadow();
containingShadow->RemoveSheet(mStyleSheet);
sheet->SetScopeElement(newScopeElement);
containingShadow->InsertSheet(mStyleSheet, thisContent);
} else {
document->BeginUpdate(UPDATE_STYLE);
document->RemoveStyleSheet(mStyleSheet);
sheet->SetScopeElement(newScopeElement);
document->AddStyleSheet(mStyleSheet);
document->EndUpdate(UPDATE_STYLE);
}
if (oldScopeElement) {
UpdateIsElementInStyleScopeFlagOnSubtree(oldScopeElement);
}
if (newScopeElement) {
newScopeElement->SetIsElementInStyleScopeFlagOnSubtree(true);
}
}
示例2: CallQueryInterface
void
nsStyleLinkElement::UpdateStyleSheetScopedness(bool aIsNowScoped)
{
if (!mStyleSheet) {
return;
}
nsCOMPtr<nsIContent> thisContent;
CallQueryInterface(this, getter_AddRefs(thisContent));
Element* oldScopeElement = mStyleSheet->GetScopeElement();
Element* newScopeElement = aIsNowScoped ?
thisContent->GetParentElement() :
nullptr;
if (oldScopeElement == newScopeElement) {
return;
}
nsIDocument* document = thisContent->GetOwnerDocument();
if (thisContent->HasFlag(NODE_IS_IN_SHADOW_TREE)) {
ShadowRoot* containingShadow = thisContent->GetContainingShadow();
containingShadow->RemoveSheet(mStyleSheet);
mStyleSheet->SetScopeElement(newScopeElement);
containingShadow->InsertSheet(mStyleSheet, thisContent);
} else {
document->BeginUpdate(UPDATE_STYLE);
document->RemoveStyleSheet(mStyleSheet);
mStyleSheet->SetScopeElement(newScopeElement);
document->AddStyleSheet(mStyleSheet);
document->EndUpdate(UPDATE_STYLE);
}
if (oldScopeElement) {
UpdateIsElementInStyleScopeFlagOnSubtree(oldScopeElement);
}
if (newScopeElement) {
SetIsElementInStyleScopeFlagOnSubtree(newScopeElement);
}
}
示例3: CallQueryInterface
nsresult
nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
ShadowRoot* aOldShadowRoot,
nsICSSLoaderObserver* aObserver,
bool* aWillNotify,
bool* aIsAlternate,
bool aForceUpdate)
{
*aWillNotify = false;
nsCOMPtr<nsIContent> thisContent;
CallQueryInterface(this, getter_AddRefs(thisContent));
// All instances of nsStyleLinkElement should implement nsIContent.
NS_ENSURE_TRUE(thisContent, NS_ERROR_FAILURE);
if (thisContent->IsInAnonymousSubtree() &&
thisContent->IsAnonymousContentInSVGUseSubtree()) {
// Stylesheets in <use>-cloned subtrees are disabled until we figure out
// how they should behave.
return NS_OK;
}
// Check for a ShadowRoot because link elements are inert in a
// ShadowRoot.
ShadowRoot* containingShadow = thisContent->GetContainingShadow();
if (thisContent->IsHTMLElement(nsGkAtoms::link) &&
(aOldShadowRoot || containingShadow)) {
return NS_OK;
}
Element* oldScopeElement = GetScopeElement(mStyleSheet);
if (mStyleSheet && (aOldDocument || aOldShadowRoot)) {
MOZ_ASSERT(!(aOldDocument && aOldShadowRoot),
"ShadowRoot content is never in document, thus "
"there should not be a old document and old "
"ShadowRoot simultaneously.");
// We're removing the link element from the document or shadow tree,
// unload the stylesheet. We want to do this even if updates are
// disabled, since otherwise a sheet with a stale linking element pointer
// will be hanging around -- not good!
if (aOldShadowRoot) {
aOldShadowRoot->RemoveSheet(mStyleSheet);
} else {
aOldDocument->BeginUpdate(UPDATE_STYLE);
aOldDocument->RemoveStyleSheet(mStyleSheet);
aOldDocument->EndUpdate(UPDATE_STYLE);
}
nsStyleLinkElement::SetStyleSheet(nullptr);
if (oldScopeElement) {
UpdateIsElementInStyleScopeFlagOnSubtree(oldScopeElement);
}
}
// When static documents are created, stylesheets are cloned manually.
if (mDontLoadStyle || !mUpdatesEnabled ||
thisContent->OwnerDoc()->IsStaticDocument()) {
return NS_OK;
}
nsCOMPtr<nsIDocument> doc = thisContent->IsInShadowTree() ?
thisContent->OwnerDoc() : thisContent->GetUncomposedDoc();
if (!doc || !doc->CSSLoader()->GetEnabled()) {
return NS_OK;
}
bool isInline;
nsCOMPtr<nsIURI> uri = GetStyleSheetURL(&isInline);
if (!aForceUpdate && mStyleSheet && !isInline && uri) {
nsIURI* oldURI = mStyleSheet->GetSheetURI();
if (oldURI) {
bool equal;
nsresult rv = oldURI->Equals(uri, &equal);
if (NS_SUCCEEDED(rv) && equal) {
return NS_OK; // We already loaded this stylesheet
}
}
}
if (mStyleSheet) {
if (thisContent->IsInShadowTree()) {
ShadowRoot* containingShadow = thisContent->GetContainingShadow();
containingShadow->RemoveSheet(mStyleSheet);
} else {
doc->BeginUpdate(UPDATE_STYLE);
doc->RemoveStyleSheet(mStyleSheet);
doc->EndUpdate(UPDATE_STYLE);
}
nsStyleLinkElement::SetStyleSheet(nullptr);
}
if (!uri && !isInline) {
return NS_OK; // If href is empty and this is not inline style then just bail
}
//.........这里部分代码省略.........