/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- * vim: sw=2 ts=8 et :
*/ /* 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/. */
// A cached copy of the data extracted by ExtractData. // // Storing this lets us avoid doing most of the work of ExtractData each // time we create a new content process. // // Only used in the parent process. static StaticAutoPtr<FullLookAndFeel> sCachedLookAndFeelData;
RemoteLookAndFeel::RemoteLookAndFeel(FullLookAndFeel&& aData)
: mTables(std::move(aData.tables())) {
MOZ_ASSERT(XRE_IsContentProcess(), "Only content processes should be using a RemoteLookAndFeel");
}
void RemoteLookAndFeel::SetDataImpl(FullLookAndFeel&& aData) {
MOZ_ASSERT(XRE_IsContentProcess(), "Only content processes should be using a RemoteLookAndFeel");
MOZ_ASSERT(NS_IsMainThread());
mTables = std::move(aData.tables());
}
namespace {
// Some lnf values are somewhat expensive to get, and are not needed in child // processes, so we can avoid querying them. bool IsNeededInChildProcess(LookAndFeel::IntID aId) { switch (aId) { case LookAndFeel::IntID::AlertNotificationOrigin: returnfalse; // see bug 1703205 default: returntrue;
}
}
// Check if there is an existing value in aItems that we can point to. // // The arrays should be small enough and contain few enough unique // values that sequential search here is reasonable. for (size_t i = 0; i < newIndex; ++i) { if (aItems[i] == aNewItem.ref()) {
aMap[mapIndex] = static_cast<UInt>(i); return;
}
}
nsresult RemoteLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
MOZ_DIAGNOSTIC_ASSERT(
IsNeededInChildProcess(aID), "Querying value that we didn't bother getting from the parent process!");
// This assignment to sCachedLookAndFeelData must be done after the // WithThemeConfiguredForContent call, since it can end up calling RefreshImpl // on the LookAndFeel, which will clear out sCachedTables.
sCachedLookAndFeelData = lf; return sCachedLookAndFeelData;
}
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.