Bug 1417824 part 1 - Query theme for attribute change on element with appearance. r?heycam
The change is mostly copied from GeckoRestyleManager::AttributeChanged.
It is not clear to me whether it's worth moving it to the superclass so
that we don't duplicate the code. If we are removing the Gecko code in
short term, it probably doesn't matter.
It is also not clear whether we should port other code from that method
to ServoRestyleManager.
MozReview-Commit-ID: Fd1nbwgLGa1
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -1443,33 +1443,48 @@ AttributeChangeRequiresSubtreeRestyle(co
void
ServoRestyleManager::AttributeChanged(Element* aElement, int32_t aNameSpaceID,
nsAtom* aAttribute, int32_t aModType,
const nsAttrValue* aOldValue)
{
MOZ_ASSERT(!mInStyleRefresh);
- if (nsIFrame* primaryFrame = aElement->GetPrimaryFrame()) {
- primaryFrame->AttributeChanged(aNameSpaceID, aAttribute, aModType);
- }
-
auto changeHint = nsChangeHint(0);
auto restyleHint = nsRestyleHint(0);
changeHint |= aElement->GetAttributeChangeHint(aAttribute, aModType);
if (aAttribute == nsGkAtoms::style) {
restyleHint |= eRestyle_StyleAttribute;
} else if (AttributeChangeRequiresSubtreeRestyle(*aElement, aAttribute)) {
restyleHint |= eRestyle_Subtree;
} else if (aElement->IsAttributeMapped(aAttribute)) {
restyleHint |= eRestyle_Self;
}
+ if (nsIFrame* primaryFrame = aElement->GetPrimaryFrame()) {
+ // See if we have appearance information for a theme.
+ const nsStyleDisplay* disp = primaryFrame->StyleDisplay();
+ if (disp->mAppearance) {
+ nsITheme* theme = PresContext()->GetTheme();
+ if (theme && theme->ThemeSupportsWidget(PresContext(), primaryFrame,
+ disp->mAppearance)) {
+ bool repaint = false;
+ theme->WidgetStateChanged(primaryFrame, disp->mAppearance,
+ aAttribute, &repaint, aOldValue);
+ if (repaint) {
+ changeHint |= nsChangeHint_RepaintFrame;
+ }
+ }
+ }
+
+ primaryFrame->AttributeChanged(aNameSpaceID, aAttribute, aModType);
+ }
+
if (restyleHint || changeHint) {
Servo_NoteExplicitHints(aElement, restyleHint, changeHint);
}
if (restyleHint) {
// Assuming we need to invalidate cached style in getComputedStyle for
// undisplayed elements, since we don't know if it is needed.
IncrementUndisplayedRestyleGeneration();