本文整理汇总了C++中HasAttr函数的典型用法代码示例。如果您正苦于以下问题:C++ HasAttr函数的具体用法?C++ HasAttr怎么用?C++ HasAttr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HasAttr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShouldShowValidityUI
EventStates
HTMLTextAreaElement::IntrinsicState() const
{
EventStates state = nsGenericHTMLFormElementWithState::IntrinsicState();
if (HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
state |= NS_EVENT_STATE_REQUIRED;
} else {
state |= NS_EVENT_STATE_OPTIONAL;
}
if (IsCandidateForConstraintValidation()) {
if (IsValid()) {
state |= NS_EVENT_STATE_VALID;
} else {
state |= NS_EVENT_STATE_INVALID;
// :-moz-ui-invalid always apply if the element suffers from a custom
// error and never applies if novalidate is set on the form owner.
if ((!mForm || !mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) &&
(GetValidityState(VALIDITY_STATE_CUSTOM_ERROR) ||
(mCanShowInvalidUI && ShouldShowValidityUI()))) {
state |= NS_EVENT_STATE_MOZ_UI_INVALID;
}
}
// :-moz-ui-valid applies if all the following are true:
// 1. The element is not focused, or had either :-moz-ui-valid or
// :-moz-ui-invalid applying before it was focused ;
// 2. The element is either valid or isn't allowed to have
// :-moz-ui-invalid applying ;
// 3. The element has no form owner or its form owner doesn't have the
// novalidate attribute set ;
// 4. The element has already been modified or the user tried to submit the
// form owner while invalid.
if ((!mForm || !mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) &&
(mCanShowValidUI && ShouldShowValidityUI() &&
(IsValid() || (state.HasState(NS_EVENT_STATE_MOZ_UI_INVALID) &&
!mCanShowInvalidUI)))) {
state |= NS_EVENT_STATE_MOZ_UI_VALID;
}
}
if (HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder) &&
IsValueEmpty()) {
state |= NS_EVENT_STATE_PLACEHOLDERSHOWN;
}
return state;
}
示例2: NS_ENSURE_SUCCESS
nsresult
HTMLImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent,
aCompileEventHandlers);
if (aParent) {
UpdateFormOwner();
}
bool haveSrcset = IsSrcsetEnabled() &&
HasAttr(kNameSpaceID_None, nsGkAtoms::srcset);
if (haveSrcset || HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
// FIXME: Bug 660963 it would be nice if we could just have
// ClearBrokenState update our state and do it fast...
ClearBrokenState();
RemoveStatesSilently(NS_EVENT_STATE_BROKEN);
// We don't handle responsive changes when not bound to a tree, update them
// now if necessary
if (haveSrcset) {
nsAutoString srcset;
GetAttr(kNameSpaceID_None, nsGkAtoms::srcset, srcset);
UpdateSourceSet(srcset);
if (mResponsiveSelector) {
nsAutoString src;
GetAttr(kNameSpaceID_None, nsGkAtoms::src, src);
mResponsiveSelector->SetDefaultSource(src);
}
}
// If loading is temporarily disabled, don't even launch MaybeLoadImage.
// Otherwise MaybeLoadImage may run later when someone has reenabled
// loading.
if (LoadingEnabled()) {
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage));
}
}
return rv;
}
示例3: NS_ENSURE_SUCCESS
nsresult
SVGIFrameElement::BindToTree(nsIDocument* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = nsSVGElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"Missing a script blocker!");
PROFILER_LABEL("SVGIFrameElement", "BindToTree",
js::ProfileEntry::Category::OTHER);
// We're in a document now. Kick off the frame load.
LoadSrc();
if (HasAttr(kNameSpaceID_None, nsGkAtoms::sandbox)) {
if (mFrameLoader) {
mFrameLoader->ApplySandboxFlags(GetSandboxFlags());
}
}
}
// We're now in document and scripts may move us, so clear
// the mNetworkCreated flag.
mNetworkCreated = false;
return rv;
}
示例4: SetBarredFromConstraintValidation
void
HTMLTextAreaElement::UpdateBarredFromConstraintValidation()
{
SetBarredFromConstraintValidation(HasAttr(kNameSpaceID_None,
nsGkAtoms::readonly) ||
IsDisabled());
}
示例5: GetSrc
void
HTMLScriptElement::FreezeUriAsyncDefer()
{
if (mFrozen) {
return;
}
// variation of this code in nsSVGScriptElement - check if changes
// need to be transfered when modifying
if (HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
nsAutoString src;
GetSrc(src);
NS_NewURI(getter_AddRefs(mUri), src);
// At this point mUri will be null for invalid URLs.
mExternal = true;
bool defer, async;
GetAsync(&async);
GetDefer(&defer);
mDefer = !async && defer;
mAsync = async;
}
mFrozen = true;
}
示例6: RebuildPathAndVertices
// Helper to regenerate our path representation & its list of vertices
void
SVGMotionSMILAnimationFunction::
RebuildPathAndVertices(const nsIContent* aTargetElement)
{
NS_ABORT_IF_FALSE(mIsPathStale, "rebuilding path when it isn't stale");
// Clear stale data
mPath = nullptr;
mPathVertices.Clear();
mPathSourceType = ePathSourceType_None;
// Do we have a mpath child? if so, it trumps everything. Otherwise, we look
// through our list of path-defining attributes, in order of priority.
SVGMPathElement* firstMpathChild = GetFirstMPathChild(mAnimationElement);
if (firstMpathChild) {
RebuildPathAndVerticesFromMpathElem(firstMpathChild);
mValueNeedsReparsingEverySample = false;
} else if (HasAttr(nsGkAtoms::path)) {
RebuildPathAndVerticesFromPathAttr();
mValueNeedsReparsingEverySample = false;
} else {
// Get path & vertices from basic SMIL attrs: from/by/to/values
RebuildPathAndVerticesFromBasicAttrs(aTargetElement);
mValueNeedsReparsingEverySample = true;
}
mIsPathStale = false;
}
示例7: CreateStaticImageClone
nsresult
HTMLImageElement::CopyInnerTo(Element* aDest)
{
bool destIsStatic = aDest->OwnerDoc()->IsStaticDocument();
auto dest = static_cast<HTMLImageElement*>(aDest);
if (destIsStatic) {
CreateStaticImageClone(dest);
}
nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest);
if (NS_FAILED(rv)) {
return rv;
}
if (!destIsStatic) {
// In SetAttr (called from nsGenericHTMLElement::CopyInnerTo), dest skipped
// doing the image load because we passed in false for aNotify. But we
// really do want it to do the load, so set it up to happen once the cloning
// reaches a stable state.
if (!dest->InResponsiveMode() &&
dest->HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(dest, &HTMLImageElement::MaybeLoadImage));
}
}
return NS_OK;
}
示例8: GetParent
EventStates
HTMLOptionElement::IntrinsicState() const
{
EventStates state = nsGenericHTMLElement::IntrinsicState();
if (Selected()) {
state |= NS_EVENT_STATE_CHECKED;
}
if (DefaultSelected()) {
state |= NS_EVENT_STATE_DEFAULT;
}
// An <option> is disabled if it has @disabled set or if it's <optgroup> has
// @disabled set.
if (HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
state |= NS_EVENT_STATE_DISABLED;
state &= ~NS_EVENT_STATE_ENABLED;
} else {
nsIContent* parent = GetParent();
if (parent && parent->IsHTMLElement(nsGkAtoms::optgroup) &&
parent->HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
state |= NS_EVENT_STATE_DISABLED;
state &= ~NS_EVENT_STATE_ENABLED;
} else {
state &= ~NS_EVENT_STATE_DISABLED;
state |= NS_EVENT_STATE_ENABLED;
}
}
return state;
}
示例9: NS_ENSURE_SUCCESS
nsresult
HTMLImageElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent,
aCompileEventHandlers);
if (HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
// FIXME: Bug 660963 it would be nice if we could just have
// ClearBrokenState update our state and do it fast...
ClearBrokenState();
RemoveStatesSilently(NS_EVENT_STATE_BROKEN);
// If loading is temporarily disabled, don't even launch MaybeLoadImage.
// Otherwise MaybeLoadImage may run later when someone has reenabled
// loading.
if (LoadingEnabled()) {
nsContentUtils::AddScriptRunner(
NS_NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage));
}
}
return rv;
}
示例10: UnlinkHrefTarget
nsresult
SVGMPathElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue,
nsIPrincipal* aMaybeScriptedPrincipal,
bool aNotify)
{
if (!aValue && aName == nsGkAtoms::href) {
// href attr being removed.
if (aNamespaceID == kNameSpaceID_None) {
UnlinkHrefTarget(true);
// After unsetting href, we may still have xlink:href, so we should
// try to add it back.
const nsAttrValue* xlinkHref =
mAttrsAndChildren.GetAttr(nsGkAtoms::href, kNameSpaceID_XLink);
if (xlinkHref) {
UpdateHrefTarget(GetParent(), xlinkHref->GetStringValue());
}
} else if (aNamespaceID == kNameSpaceID_XLink &&
!HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
UnlinkHrefTarget(true);
} // else: we unset some random-namespace href attribute, or unset xlink:href
// but still have href attribute, so keep the target linking to href.
}
return SVGMPathElementBase::AfterSetAttr(aNamespaceID, aName,
aValue, aOldValue,
aMaybeScriptedPrincipal, aNotify);
}
示例11: GetAttr
void
SVGStyleElement::GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
bool* aIsScoped,
bool* aIsAlternate)
{
*aIsAlternate = false;
nsAutoString title;
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
title.CompressWhitespace();
aTitle.Assign(title);
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
// The SVG spec is formulated in terms of the CSS2 spec,
// which specifies that media queries are case insensitive.
nsContentUtils::ASCIIToLower(aMedia);
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
if (aType.IsEmpty()) {
aType.AssignLiteral("text/css");
}
*aIsScoped = HasAttr(kNameSpaceID_None, nsGkAtoms::scoped);
return;
}
示例12: SetKeyPointsErrorFlag
void
SVGMotionSMILAnimationFunction::CheckKeyPoints()
{
if (!HasAttr(nsGkAtoms::keyPoints))
return;
// attribute is ignored for calcMode="paced" (even if it's got errors)
if (GetCalcMode() == CALC_PACED) {
SetKeyPointsErrorFlag(false);
}
if (mKeyPoints.IsEmpty()) {
// keyPoints attr is set, but array is empty => it failed preliminary checks
SetKeyPointsErrorFlag(true);
return;
}
// Nothing else to check -- we can catch all keyPoints errors elsewhere.
// - Formatting & range issues will be caught in SetKeyPoints, and will
// result in an empty mKeyPoints array, which will drop us into the error
// case above.
// - Number-of-entries issues will be caught in CheckKeyTimes (and flagged
// as a problem with |keyTimes|), since we use our keyPoints entries to
// populate the "values" list, and that list's count gets passed to
// CheckKeyTimes.
}
示例13: double
/*
* Scale the simple progress, taking into account any keyTimes.
*/
void
nsSMILAnimationFunction::ScaleSimpleProgress(double& aProgress)
{
if (!HasAttr(nsGkAtoms::keyTimes))
return;
PRUint32 numTimes = mKeyTimes.Length();
if (numTimes < 2)
return;
PRUint32 i = 0;
for (; i < numTimes - 2 && aProgress >= mKeyTimes[i+1]; ++i);
double& intervalStart = mKeyTimes[i];
double& intervalEnd = mKeyTimes[i+1];
double intervalLength = intervalEnd - intervalStart;
if (intervalLength <= 0.0) {
aProgress = intervalStart;
return;
}
aProgress = (i + (aProgress - intervalStart) / intervalLength) *
1.0 / double(numTimes - 1);
}
示例14: IsToAnimation
bool SVGMotionSMILAnimationFunction::IsToAnimation() const {
// Rely on inherited method, but not if we have an <mpath> child or a |path|
// attribute, because they'll override any 'to' attr we might have.
// NOTE: We can't rely on mPathSourceType, because it might not have been
// set to a useful value yet (or it might be stale).
return !GetFirstMPathChild(mAnimationElement) && !HasAttr(nsGkAtoms::path) &&
SMILAnimationFunction::IsToAnimation();
}
示例15:
SVGPathElement*
SVGMPathElement::GetReferencedPath()
{
if (!HasAttr(kNameSpaceID_XLink, nsGkAtoms::href) &&
!HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
MOZ_ASSERT(!mPathTracker.get(),
"We shouldn't have a href target "
"if we don't have an xlink:href or href attribute");
return nullptr;
}
nsIContent* genericTarget = mPathTracker.get();
if (genericTarget && genericTarget->IsSVGElement(nsGkAtoms::path)) {
return static_cast<SVGPathElement*>(genericTarget);
}
return nullptr;
}