Bug 1686037 - Part 1: Move nsGenericHTMLElement::GetPresContext to Element; r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D102321
This commit is contained in:
Edgar Chen 2021-01-21 14:19:57 +00:00
parent 56848ca9c1
commit f43f83b1a9
5 changed files with 20 additions and 21 deletions

View File

@ -4147,6 +4147,17 @@ already_AddRefed<nsIAutoCompletePopup> Element::AsAutoCompletePopup() {
return value.forget();
}
nsPresContext* Element::GetPresContext(PresContextFor aFor) {
// Get the document
Document* doc =
(aFor == eForComposedDoc) ? GetComposedDoc() : GetUncomposedDoc();
if (doc) {
return doc->GetPresContext();
}
return nullptr;
}
MOZ_DEFINE_MALLOC_SIZE_OF(ServoElementMallocSizeOf)
MOZ_DEFINE_MALLOC_ENCLOSING_SIZE_OF(ServoElementMallocEnclosingSizeOf)

View File

@ -1640,6 +1640,13 @@ class Element : public FragmentOrElement {
already_AddRefed<nsIBrowser> AsBrowser();
already_AddRefed<nsIAutoCompletePopup> AsAutoCompletePopup();
/**
* Get the presentation context for this content node.
* @return the presentation context
*/
enum PresContextFor { eForComposedDoc, eForUncomposedDoc };
nsPresContext* GetPresContext(PresContextFor aFor);
protected:
/*
* Named-bools for use with SetAttrAndNotify to make call sites easier to

View File

@ -5667,10 +5667,8 @@ void EventStateManager::ContentRemoved(Document* aDocument,
if (aContent->IsAnyOfHTMLElements(nsGkAtoms::a, nsGkAtoms::area) &&
(aContent->AsElement()->State().HasAtLeastOneOfStates(
NS_EVENT_STATE_FOCUS | NS_EVENT_STATE_HOVER))) {
nsGenericHTMLElement* element =
static_cast<nsGenericHTMLElement*>(aContent);
element->LeaveLink(
element->GetPresContext(nsGenericHTMLElement::eForComposedDoc));
Element* element = aContent->AsElement();
element->LeaveLink(element->GetPresContext(Element::eForComposedDoc));
}
IMEStateManager::OnRemoveContent(mPresContext, aContent);

View File

@ -971,17 +971,6 @@ nsIFormControlFrame* nsGenericHTMLElement::GetFormControlFrame(
return nullptr;
}
nsPresContext* nsGenericHTMLElement::GetPresContext(PresContextFor aFor) {
// Get the document
Document* doc =
(aFor == eForComposedDoc) ? GetComposedDoc() : GetUncomposedDoc();
if (doc) {
return doc->GetPresContext();
}
return nullptr;
}
static const nsAttrValue::EnumTable kDivAlignTable[] = {
{"left", StyleTextAlign::MozLeft},
{"right", StyleTextAlign::MozRight},

View File

@ -575,12 +575,6 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase {
*/
static void MapScrollingAttributeInto(const nsMappedAttributes* aAttributes,
mozilla::MappedDeclarations&);
/**
* Get the presentation context for this content node.
* @return the presentation context
*/
enum PresContextFor { eForComposedDoc, eForUncomposedDoc };
nsPresContext* GetPresContext(PresContextFor aFor);
// Form Helper Routines
/**