本文整理汇总了C++中Document::LocalizationLinkRemoved方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::LocalizationLinkRemoved方法的具体用法?C++ Document::LocalizationLinkRemoved怎么用?C++ Document::LocalizationLinkRemoved使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document
的用法示例。
在下文中一共展示了Document::LocalizationLinkRemoved方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnbindFromTree
void HTMLLinkElement::UnbindFromTree(bool aDeep, bool aNullParent) {
// Cancel any DNS prefetches
// Note: Must come before ResetLinkState. If called after, it will recreate
// mCachedURI based on data that is invalid - due to a call to GetHostname.
CancelDNSPrefetch(HTML_LINK_DNS_PREFETCH_DEFERRED,
HTML_LINK_DNS_PREFETCH_REQUESTED);
CancelPrefetchOrPreload();
// Without removing the link state we risk a dangling pointer
// in the mStyledLinks hashtable
Link::ResetLinkState(false, Link::ElementHasHref());
// If this is reinserted back into the document it will not be
// from the parser.
Document* oldDoc = GetUncomposedDoc();
ShadowRoot* oldShadowRoot = GetContainingShadow();
// We want to update the localization but only if the
// link is removed from a DOM change, and not
// because the document is going away.
bool ignore;
if (oldDoc && oldDoc->GetScriptHandlingObject(ignore) &&
this->AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel,
nsGkAtoms::localization, eIgnoreCase)) {
oldDoc->LocalizationLinkRemoved(this);
}
CreateAndDispatchEvent(oldDoc, NS_LITERAL_STRING("DOMLinkRemoved"));
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
Unused << UpdateStyleSheetInternal(oldDoc, oldShadowRoot);
}
示例2: AfterSetAttr
nsresult HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue,
nsIPrincipal* aSubjectPrincipal,
bool aNotify) {
// It's safe to call ResetLinkState here because our new attr value has
// already been set or unset. ResetLinkState needs the updated attribute
// value because notifying the document that content states have changed will
// call IntrinsicState, which will try to get updated information about the
// visitedness from Link.
if (aName == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
bool hasHref = aValue;
Link::ResetLinkState(!!aNotify, hasHref);
if (IsInUncomposedDoc()) {
CreateAndDispatchEvent(OwnerDoc(), NS_LITERAL_STRING("DOMLinkChanged"));
}
}
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::href) {
mTriggeringPrincipal = nsContentUtils::GetAttrTriggeringPrincipal(
this, aValue ? aValue->GetStringValue() : EmptyString(),
aSubjectPrincipal);
}
// If a link's `rel` attribute was changed from or to `localization`,
// update the list of localization links.
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::rel) {
Document* doc = GetComposedDoc();
if (doc) {
if ((aValue && aValue->Equals(nsGkAtoms::localization, eIgnoreCase)) &&
(!aOldValue ||
!aOldValue->Equals(nsGkAtoms::localization, eIgnoreCase))) {
doc->LocalizationLinkAdded(this);
} else if ((aOldValue &&
aOldValue->Equals(nsGkAtoms::localization, eIgnoreCase)) &&
(!aValue ||
!aValue->Equals(nsGkAtoms::localization, eIgnoreCase))) {
doc->LocalizationLinkRemoved(this);
}
}
}
// If the link has `rel=localization` and its `href` attribute is changed,
// update the list of localization links.
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::href &&
AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel, nsGkAtoms::localization,
eIgnoreCase)) {
Document* doc = GetComposedDoc();
if (doc) {
if (aOldValue) {
doc->LocalizationLinkRemoved(this);
}
if (aValue) {
doc->LocalizationLinkAdded(this);
}
}
}
if (aValue) {
if (aNameSpaceID == kNameSpaceID_None &&
(aName == nsGkAtoms::href || aName == nsGkAtoms::rel ||
aName == nsGkAtoms::title || aName == nsGkAtoms::media ||
aName == nsGkAtoms::type || aName == nsGkAtoms::as ||
aName == nsGkAtoms::crossorigin)) {
bool dropSheet = false;
if (aName == nsGkAtoms::rel) {
nsAutoString value;
aValue->ToString(value);
uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(value);
if (GetSheet()) {
dropSheet = !(linkTypes & nsStyleLinkElement::eSTYLESHEET);
}
}
if ((aName == nsGkAtoms::rel || aName == nsGkAtoms::href) &&
IsInComposedDoc()) {
TryDNSPrefetchOrPreconnectOrPrefetchOrPreloadOrPrerender();
}
if ((aName == nsGkAtoms::as || aName == nsGkAtoms::type ||
aName == nsGkAtoms::crossorigin || aName == nsGkAtoms::media) &&
IsInComposedDoc()) {
UpdatePreload(aName, aValue, aOldValue);
}
const bool forceUpdate = dropSheet || aName == nsGkAtoms::title ||
aName == nsGkAtoms::media ||
aName == nsGkAtoms::type;
Unused << UpdateStyleSheetInternal(
nullptr, nullptr, forceUpdate ? ForceUpdate::Yes : ForceUpdate::No);
}
} else {
// Since removing href or rel makes us no longer link to a
// stylesheet, force updates for those too.
if (aNameSpaceID == kNameSpaceID_None) {
if (aName == nsGkAtoms::href || aName == nsGkAtoms::rel ||
aName == nsGkAtoms::title || aName == nsGkAtoms::media ||
aName == nsGkAtoms::type) {
Unused << UpdateStyleSheetInternal(nullptr, nullptr, ForceUpdate::Yes);
//.........这里部分代码省略.........