summaryrefslogtreecommitdiffstats
path: root/dom/svg/SVGSwitchElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/svg/SVGSwitchElement.cpp')
-rw-r--r--dom/svg/SVGSwitchElement.cpp56
1 files changed, 2 insertions, 54 deletions
diff --git a/dom/svg/SVGSwitchElement.cpp b/dom/svg/SVGSwitchElement.cpp
index e049d07496..a19dfd8631 100644
--- a/dom/svg/SVGSwitchElement.cpp
+++ b/dom/svg/SVGSwitchElement.cpp
@@ -7,7 +7,6 @@
#include "mozilla/dom/SVGSwitchElement.h"
#include "nsLayoutUtils.h"
-#include "mozilla/Preferences.h"
#include "mozilla/SVGUtils.h"
#include "mozilla/dom/SVGSwitchElementBinding.h"
@@ -46,14 +45,13 @@ void SVGSwitchElement::MaybeInvalidate() {
// InvalidateAndScheduleBoundsUpdate has been called, otherwise
// it will not correctly invalidate the old mActiveChild area.
- nsIContent* newActiveChild = FindActiveChild();
+ auto* newActiveChild = SVGTests::FindActiveSwitchChild(this);
if (newActiveChild == mActiveChild) {
return;
}
- nsIFrame* frame = GetPrimaryFrame();
- if (frame) {
+ if (auto* frame = GetPrimaryFrame()) {
nsLayoutUtils::PostRestyleEvent(this, RestyleHint{0},
nsChangeHint_InvalidateRenderingObservers);
SVGUtils::ScheduleReflowSVG(frame);
@@ -86,54 +84,4 @@ void SVGSwitchElement::RemoveChildNode(nsIContent* aKid, bool aNotify) {
MaybeInvalidate();
}
-//----------------------------------------------------------------------
-// Implementation Helpers:
-
-nsIContent* SVGSwitchElement::FindActiveChild() const {
- nsAutoString acceptLangs;
- Preferences::GetLocalizedString("intl.accept_languages", acceptLangs);
-
- int32_t bestLanguagePreferenceRank = -1;
- nsIContent* bestChild = nullptr;
- nsIContent* defaultChild = nullptr;
- for (nsIContent* child = nsINode::GetFirstChild(); child;
- child = child->GetNextSibling()) {
- if (!child->IsElement()) {
- continue;
- }
- nsCOMPtr<SVGTests> tests(do_QueryInterface(child));
- if (tests) {
- if (tests->PassesConditionalProcessingTestsIgnoringSystemLanguage()) {
- int32_t languagePreferenceRank =
- tests->GetBestLanguagePreferenceRank(acceptLangs);
- switch (languagePreferenceRank) {
- case 0:
- // best possible match
- return child;
- case -1:
- // no match
- break;
- case -2:
- // no systemLanguage attribute. If there's nothing better
- // we'll use the first such child.
- if (!defaultChild) {
- defaultChild = child;
- }
- break;
- default:
- if (bestLanguagePreferenceRank == -1 ||
- languagePreferenceRank < bestLanguagePreferenceRank) {
- bestLanguagePreferenceRank = languagePreferenceRank;
- bestChild = child;
- }
- break;
- }
- }
- } else if (!bestChild) {
- bestChild = child;
- }
- }
- return bestChild ? bestChild : defaultChild;
-}
-
} // namespace mozilla::dom