/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */
nsIContent* content = aFrame->GetContent(); if (!content || !content->IsElement()) returnfalse;
if (content->IsHTMLElement()) return content->AsElement()->HasAttr(aAtom);
// For XML/XUL elements, an attribute must be equal to the literal // string "true" to be counted as true. An empty string should _not_ // be counted as true. return content->AsElement()->AttrValueIs(kNameSpaceID_None, aAtom, u"true"_ns,
eCaseMatters);
}
bool nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext,
nsIFrame* aFrame,
StyleAppearance aAppearance) { // Check for specific widgets to see if HTML has overridden the style. if (!aFrame) { returnfalse;
}
/** * Progress bar appearance should be the same for the bar and the container * frame. nsProgressFrame owns the logic and will tell us what we should do.
*/ if (aAppearance == StyleAppearance::Progresschunk ||
aAppearance == StyleAppearance::ProgressBar) {
nsProgressFrame* progressFrame = do_QueryFrame(
aAppearance == StyleAppearance::Progresschunk ? aFrame->GetParent()
: aFrame); if (progressFrame) { return !progressFrame->ShouldUseNativeStyle();
}
}
/** * Meter bar appearance should be the same for the bar and the container * frame. nsMeterFrame owns the logic and will tell us what we should do.
*/ if (aAppearance == StyleAppearance::Meterchunk ||
aAppearance == StyleAppearance::Meter) {
nsMeterFrame* meterFrame = do_QueryFrame(
aAppearance == StyleAppearance::Meterchunk ? aFrame->GetParent()
: aFrame); if (meterFrame) { return !meterFrame->ShouldUseNativeStyle();
}
}
/** * An nsRangeFrame and its children are treated atomically when it * comes to native theming (either all parts, or no parts, are themed). * nsRangeFrame owns the logic and will tell us what we should do.
*/ if (aAppearance == StyleAppearance::Range ||
aAppearance == StyleAppearance::RangeThumb) {
nsRangeFrame* rangeFrame = do_QueryFrame(
aAppearance == StyleAppearance::RangeThumb ? aFrame->GetParent()
: aFrame); if (rangeFrame) { return !rangeFrame->ShouldUseNativeStyle();
}
}
nsIContent* content = aFrame->GetContent(); if (content->IsElement()) { switch (content->AsElement()->FindAttrValueIn(
kNameSpaceID_None, nsGkAtoms::sortDirection, strings, eCaseMatters)) { case 0: return eTreeSortDirection_Descending; case 1: return eTreeSortDirection_Ascending;
}
}
return eTreeSortDirection_Natural;
}
bool nsNativeTheme::IsLastTreeHeaderCell(nsIFrame* aFrame) { if (!aFrame) { returnfalse;
}
// A tree column picker button is always the last header cell. if (aFrame->GetContent()->IsXULElement(nsGkAtoms::button)) { returntrue;
}
// Find the parent tree.
nsIContent* parent = aFrame->GetContent()->GetParent(); while (parent && !parent->IsXULElement(nsGkAtoms::tree)) {
parent = parent->GetParent();
}
// If the column picker is visible, this can't be the last column. if (parent && !parent->AsElement()->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::hidecolumnpicker,
u"true"_ns, eCaseMatters)) returnfalse;
while ((aFrame = aFrame->GetNextSibling())) { if (aFrame->GetRect().Width() > 0) returnfalse;
} returntrue;
}
// tab: bool nsNativeTheme::IsBottomTab(nsIFrame* aFrame) { if (!aFrame) returnfalse;
nsAutoString classStr; if (aFrame->GetContent()->IsElement()) {
aFrame->GetContent()->AsElement()->GetAttr(nsGkAtoms::_class, classStr);
} // FIXME: This looks bogus, shouldn't this be looking at GetClasses()? return !classStr.IsEmpty() && classStr.Find(u"tab-bottom") != kNotFound;
}
bool nsNativeTheme::IsFirstTab(nsIFrame* aFrame) { if (!aFrame) returnfalse;
for (nsIFrame* first : aFrame->GetParent()->PrincipalChildList()) { if (first->GetRect().Width() > 0 &&
first->GetContent()->IsXULElement(nsGkAtoms::tab)) return (first == aFrame);
} returnfalse;
}
bool nsNativeTheme::IsHorizontal(nsIFrame* aFrame) { if (!aFrame) returnfalse;
if (!aFrame->GetContent()->IsElement()) returntrue;
bool nsNativeTheme::IsVerticalMeter(nsIFrame* aFrame) {
MOZ_ASSERT(aFrame, "You have to pass a non-null aFrame"); switch (aFrame->StyleDisplay()->mOrient) { case StyleOrient::Horizontal: returnfalse; case StyleOrient::Vertical: returntrue; case StyleOrient::Inline: return aFrame->GetWritingMode().IsVertical(); case StyleOrient::Block: return !aFrame->GetWritingMode().IsVertical();
}
MOZ_ASSERT_UNREACHABLE("unexpected -moz-orient value"); returnfalse;
}
bool nsNativeTheme::QueueAnimatedContentForRefresh(nsIContent* aContent,
uint32_t aMinimumFrameRate) {
NS_ASSERTION(aContent, "Null pointer!");
NS_ASSERTION(aMinimumFrameRate, "aMinimumFrameRate must be non-zero!");
NS_ASSERTION(aMinimumFrameRate <= 1000, "aMinimumFrameRate must be less than 1000!");
// Find the next visible sibling.
nsIFrame* sibling = aFrame; do {
sibling =
aNextSibling ? sibling->GetNextSibling() : sibling->GetPrevSibling();
} while (sibling && sibling->GetRect().Width() == 0);
// Check same appearance and adjacency. if (!sibling ||
sibling->StyleDisplay()->EffectiveAppearance() !=
aFrame->StyleDisplay()->EffectiveAppearance() ||
(sibling->GetRect().XMost() != aFrame->GetRect().X() &&
aFrame->GetRect().XMost() != sibling->GetRect().X())) return nullptr; return sibling;
}
bool nsNativeTheme::IsRangeHorizontal(nsIFrame* aFrame) {
nsIFrame* rangeFrame = aFrame; if (!rangeFrame->IsRangeFrame()) { // If the thumb's frame is passed in, get its range parent:
rangeFrame = aFrame->GetParent();
} if (rangeFrame->IsRangeFrame()) { returnstatic_cast<nsRangeFrame*>(rangeFrame)->IsHorizontal();
} // Not actually a range frame - just use the ratio of the frame's size to // decide: return aFrame->GetSize().width >= aFrame->GetSize().height;
}
/* static */ bool nsNativeTheme::IsDarkBackgroundForScrollbar(nsIFrame* aFrame) { // Try to find the scrolled frame. Note that for stuff like xul <tree> there // might be none.
{
nsIFrame* frame = aFrame;
ScrollContainerFrame* scrollContainerFrame = nullptr; while (!scrollContainerFrame && frame) {
scrollContainerFrame = frame->GetScrollTargetFrame();
frame = frame->GetParent();
} if (scrollContainerFrame) {
aFrame = scrollContainerFrame->GetScrolledFrame();
} else { // Leave aFrame untouched.
}
}
/*static*/ bool nsNativeTheme::IsWidgetScrollbarPart(StyleAppearance aAppearance) { switch (aAppearance) { case StyleAppearance::ScrollbarVertical: case StyleAppearance::ScrollbarHorizontal: case StyleAppearance::ScrollbarbuttonUp: case StyleAppearance::ScrollbarbuttonDown: case StyleAppearance::ScrollbarbuttonLeft: case StyleAppearance::ScrollbarbuttonRight: case StyleAppearance::ScrollbarthumbVertical: case StyleAppearance::ScrollbarthumbHorizontal: case StyleAppearance::Scrollcorner: returntrue; default: returnfalse;
}
}
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.