本文整理汇总了C++中ShadowRoot::InsertSheet方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadowRoot::InsertSheet方法的具体用法?C++ ShadowRoot::InsertSheet怎么用?C++ ShadowRoot::InsertSheet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadowRoot
的用法示例。
在下文中一共展示了ShadowRoot::InsertSheet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}