Bug 1857841 - pt 3. Add a new page kind named "fresh" r=glandium
[gecko.git] / dom / xul / XULTextElement.cpp
blob04edfabc09a9f9cecb07768c87f251ed0759486d
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/Element.h"
8 #include "mozilla/dom/ToJSValue.h"
9 #include "nsCOMPtr.h"
10 #include "nsChangeHint.h"
11 #include "nsIContent.h"
12 #include "nsPresContext.h"
13 #include "nsIScrollableFrame.h"
14 #include "mozilla/dom/MutationEventBinding.h"
15 #include "mozilla/dom/XULTextElement.h"
16 #include "mozilla/dom/XULTextElementBinding.h"
18 namespace mozilla::dom {
20 nsChangeHint XULTextElement::GetAttributeChangeHint(const nsAtom* aAttribute,
21 int32_t aModType) const {
22 const bool reframe = [&] {
23 if (aAttribute == nsGkAtoms::value) {
24 // If we have an accesskey we need to recompute our -moz-label-content.
25 // Otherwise this is handled by either the attribute text node, or
26 // nsTextBoxFrame for crop="center".
27 return aModType == MutationEvent_Binding::ADDITION ||
28 aModType == MutationEvent_Binding::REMOVAL ||
29 HasAttr(nsGkAtoms::accesskey);
31 if (aAttribute == nsGkAtoms::crop || aAttribute == nsGkAtoms::accesskey) {
32 // value attr + crop="center" still uses nsTextBoxFrame. accesskey
33 // requires reframing as per the above comment.
34 return HasAttr(nsGkAtoms::value);
36 return false;
37 }();
38 if (reframe) {
39 return nsChangeHint_ReconstructFrame;
41 return nsXULElement::GetAttributeChangeHint(aAttribute, aModType);
44 JSObject* XULTextElement::WrapNode(JSContext* aCx,
45 JS::Handle<JSObject*> aGivenProto) {
46 return XULTextElement_Binding::Wrap(aCx, this, aGivenProto);
49 } // namespace mozilla::dom