/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
void nsMeterFrame::Destroy(DestroyContext& aContext) {
NS_ASSERTION(!GetPrevContinuation(), "nsMeterFrame should not have continuations; if it does we " "need to call RegUnregAccessKey only for the first.");
aContext.AddAnonymousContent(mBarDiv.forget());
nsContainerFrame::Destroy(aContext);
}
nsresult nsMeterFrame::CreateAnonymousContent(
nsTArray<ContentInfo>& aElements) { // Get the NodeInfoManager and tag necessary to create the meter bar div.
nsCOMPtr<Document> doc = mContent->GetComposedDoc();
// Create the div.
mBarDiv = doc->CreateHTMLElement(nsGkAtoms::div);
// Associate the right pseudo-element to the anonymous child. if (StaticPrefs::layout_css_modern_range_pseudos_enabled()) { // TODO(emilio): Create also a slider-track pseudo-element.
mBarDiv->SetPseudoElementType(PseudoStyleType::sliderFill);
} else {
mBarDiv->SetPseudoElementType(PseudoStyleType::mozMeterBar);
}
NS_ASSERTION(mBarDiv, "Meter bar div must exist!");
NS_ASSERTION(!GetPrevContinuation(), "nsMeterFrame should not have continuations; if it does we " "need to call RegUnregAccessKey only for the first.");
nsIFrame* barFrame = mBarDiv->GetPrimaryFrame();
NS_ASSERTION(barFrame, "The meter frame should have a child with a frame!");
// The bar position is *always* constrained. if (vertical) { // We want the bar to begin at the bottom.
yoffset += parentPhysicalSize.Height() - size;
size -= reflowInput.ComputedPhysicalMargin().TopBottom() +
reflowInput.ComputedPhysicalBorderPadding().TopBottom();
size = std::max(size, 0);
reflowInput.SetComputedHeight(size);
} else {
size -= reflowInput.ComputedPhysicalMargin().LeftRight() +
reflowInput.ComputedPhysicalBorderPadding().LeftRight();
size = std::max(size, 0);
reflowInput.SetComputedWidth(size);
}
nsresult nsMeterFrame::AttributeChanged(int32_t aNameSpaceID,
nsAtom* aAttribute, int32_t aModType) {
NS_ASSERTION(mBarDiv, "Meter bar div must exist!");
if (aNameSpaceID == kNameSpaceID_None &&
(aAttribute == nsGkAtoms::value || aAttribute == nsGkAtoms::max ||
aAttribute == nsGkAtoms::min)) {
nsIFrame* barFrame = mBarDiv->GetPrimaryFrame();
NS_ASSERTION(barFrame, "The meter frame should have a child with a frame!");
PresShell()->FrameNeedsReflow(barFrame, IntrinsicDirty::None,
NS_FRAME_IS_DIRTY);
InvalidateFrame();
}
// Use the native style if these conditions are satisfied: // - both frames use the native appearance; // - neither frame has author specified rules setting the border or the // background. return StyleDisplay()->EffectiveAppearance() == StyleAppearance::Meter &&
!Style()->HasAuthorSpecifiedBorderOrBackground() && barFrame &&
barFrame->StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::Meterchunk &&
!barFrame->Style()->HasAuthorSpecifiedBorderOrBackground();
}
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.