diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp index 563ac6fe001..e344599ecde 100644 --- a/accessible/generic/HyperTextAccessible.cpp +++ b/accessible/generic/HyperTextAccessible.cpp @@ -1466,7 +1466,7 @@ HyperTextAccessible::CaretLineNumber() break; // Add lines for the sibling frames before the caret - nsIFrame *sibling = parentFrame->GetFirstPrincipalChild(); + nsIFrame *sibling = parentFrame->PrincipalChildList().FirstChild(); while (sibling && sibling != caretFrame) { nsAutoLineIterator lineIterForSibling = sibling->GetLineIterator(); if (lineIterForSibling) { diff --git a/b2g/app/nsBrowserApp.cpp b/b2g/app/nsBrowserApp.cpp index ae115bd922d..e7fcc431a5e 100644 --- a/b2g/app/nsBrowserApp.cpp +++ b/b2g/app/nsBrowserApp.cpp @@ -281,7 +281,6 @@ int main(int argc, _CONST char* argv[]) int result; { ScopedLogging log; - mozilla::LogModule::Init(); char **_argv; /* diff --git a/b2g/config/aries-l/sources.xml b/b2g/config/aries-l/sources.xml index f1f4f5309d6..c8005201ca6 100644 --- a/b2g/config/aries-l/sources.xml +++ b/b2g/config/aries-l/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/b2g/config/aries/sources.xml b/b2g/config/aries/sources.xml index 9d6927bef66..eb1df795c7e 100644 --- a/b2g/config/aries/sources.xml +++ b/b2g/config/aries/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index 4cb3b474895..28e0174330d 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 3bf9286b9bc..5d75798b057 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index ff868d7e0b9..e24a032eb66 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index ebeb02198e9..367e3f91a5e 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/b2g/config/emulator-l/sources.xml b/b2g/config/emulator-l/sources.xml index 221b8bad201..e1340a00119 100644 --- a/b2g/config/emulator-l/sources.xml +++ b/b2g/config/emulator-l/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 3bf9286b9bc..5d75798b057 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index 9e1d0bde2c0..8158bd0c99b 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -21,10 +21,12 @@ - + + + @@ -135,7 +137,7 @@ - + diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 19e3a8dc036..e7ceb76a283 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,9 +1,9 @@ { "git": { - "git_revision": "77c0e08caa0dda8c6e50f6e7cbad9f79b320a3b0", + "git_revision": "4f0e2a1a42a2d049b6fe8f4f095cdcdf0fd5465c", "remote": "https://git.mozilla.org/releases/gaia.git", "branch": "" }, - "revision": "256902cd676226f40965b353e0ec12e9b0372290", + "revision": "07d30dcbe75d2c053a6e98697fd2e362fb786ca9", "repo_path": "integration/gaia-central" } diff --git a/b2g/config/nexus-4-kk/sources.xml b/b2g/config/nexus-4-kk/sources.xml index 9152e78d1b6..6aa653212b2 100644 --- a/b2g/config/nexus-4-kk/sources.xml +++ b/b2g/config/nexus-4-kk/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index d56ec7e8f77..9fa8d20e469 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/b2g/config/nexus-5-l/sources.xml b/b2g/config/nexus-5-l/sources.xml index 0cdc8e27acc..852d0aaf307 100644 --- a/b2g/config/nexus-5-l/sources.xml +++ b/b2g/config/nexus-5-l/sources.xml @@ -21,10 +21,12 @@ - + + + diff --git a/browser/config/mozconfigs/linux64/debug b/browser/config/mozconfigs/linux64/debug index f03930e7384..b74a64e9872 100644 --- a/browser/config/mozconfigs/linux64/debug +++ b/browser/config/mozconfigs/linux64/debug @@ -18,6 +18,6 @@ export MOZ_PACKAGE_JSSHELL=1 ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/unix/mozconfig.rust" +. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/linux64/nightly b/browser/config/mozconfigs/linux64/nightly index 89c710061e7..41f5c224959 100644 --- a/browser/config/mozconfigs/linux64/nightly +++ b/browser/config/mozconfigs/linux64/nightly @@ -10,6 +10,6 @@ STRIP_FLAGS="--strip-debug" ac_add_options --with-branding=browser/branding/nightly -. "$topsrcdir/build/unix/mozconfig.rust" +. "$topsrcdir/build/mozconfig.rust" . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/whitelist b/browser/config/mozconfigs/whitelist index 919bb1610a9..4d85bc90d9c 100644 --- a/browser/config/mozconfigs/whitelist +++ b/browser/config/mozconfigs/whitelist @@ -40,7 +40,7 @@ whitelist['nightly']['linux64'] += [ 'STRIP_FLAGS="--strip-debug"', 'ac_add_options --with-ccache=/usr/bin/ccache', '. "$topsrcdir/build/mozconfig.cache"', - '. "$topsrcdir/build/unix/mozconfig.rust"', + '. "$topsrcdir/build/mozconfig.rust"', ] whitelist['nightly']['macosx-universal'] += [ @@ -67,6 +67,7 @@ whitelist['nightly']['win32'] += [ whitelist['nightly']['win64'] += [ '. "$topsrcdir/browser/config/mozconfigs/win64/common-win64"', '. "$topsrcdir/build/mozconfig.cache"', + '. "$topsrcdir/build/mozconfig.rust"', ] for platform in all_platforms: diff --git a/browser/config/mozconfigs/win64/debug b/browser/config/mozconfigs/win64/debug index 80054ba132e..b361a4db204 100644 --- a/browser/config/mozconfigs/win64/debug +++ b/browser/config/mozconfigs/win64/debug @@ -30,5 +30,7 @@ ac_add_options --with-branding=browser/branding/nightly . $topsrcdir/build/win64/mozconfig.vs2013 +. "$topsrcdir/build/mozconfig.rust" + . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/mozconfigs/win64/nightly b/browser/config/mozconfigs/win64/nightly index 9c31c44644e..f710aabe3a0 100644 --- a/browser/config/mozconfigs/win64/nightly +++ b/browser/config/mozconfigs/win64/nightly @@ -7,5 +7,7 @@ ac_add_options --enable-verify-mar ac_add_options --with-branding=browser/branding/nightly +. "$topsrcdir/build/mozconfig.rust" + . "$topsrcdir/build/mozconfig.common.override" . "$topsrcdir/build/mozconfig.cache" diff --git a/browser/config/tooltool-manifests/win64/releng.manifest b/browser/config/tooltool-manifests/win64/releng.manifest index 6343fb6d816..b891a301572 100644 --- a/browser/config/tooltool-manifests/win64/releng.manifest +++ b/browser/config/tooltool-manifests/win64/releng.manifest @@ -6,6 +6,14 @@ "filename": "mozmake.exe" }, { +"size": 72442063, +"digest": "899da5af9b322ba63ec04de06f92b5bb82a2700f9fe03001e75fdc6f678a435cd66a474190fd93863327456270aef5649d3788aa50d852121059ced99a6004db", +"algorithm": "sha512", +"visibility": "public", +"filename": "rustc.tar.bz2", +"unpack": true +}, +{ "size": 167175, "digest": "0b71a936edf5bd70cf274aaa5d7abc8f77fe8e7b5593a208f805cc9436fac646b9c4f0b43c2b10de63ff3da671497d35536077ecbc72dba7f8159a38b580f831", "algorithm": "sha512", diff --git a/build/unix/mozconfig.rust b/build/mozconfig.rust similarity index 100% rename from build/unix/mozconfig.rust rename to build/mozconfig.rust diff --git a/configure.in b/configure.in index fd5e5499ecf..37f6f008545 100644 --- a/configure.in +++ b/configure.in @@ -3503,7 +3503,7 @@ MOZ_ARG_WITH_BOOL(system-nss, _USE_SYSTEM_NSS=1 ) if test -n "$_USE_SYSTEM_NSS"; then - AM_PATH_NSS(3.20.1, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])]) + AM_PATH_NSS(3.22, [MOZ_NATIVE_NSS=1], [AC_MSG_ERROR([you don't have NSS installed or your version is too old])]) fi if test -n "$MOZ_NATIVE_NSS"; then @@ -9200,6 +9200,7 @@ export MOZ_APP_NAME export MOZ_APP_REMOTINGNAME export DONT_POPULATE_VIRTUALENV=1 export PYTHON +export RUSTC export MOZILLA_CENTRAL_PATH=$_topsrcdir export STLPORT_CPPFLAGS export STLPORT_LIBS diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c9f33499f10..60edb8f31fd 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -266,9 +266,9 @@ static uint32_t gValidateOrigin = 0xffffffff; #define NS_EVENT_STARVATION_DELAY_HINT 2000 #ifdef DEBUG -static mozilla::LazyLogModule gDocShellLog("nsDocShell"); +static PRLogModuleInfo* gDocShellLog; #endif -static mozilla::LazyLogModule gDocShellLeakLog("nsDocShellLeak");; +static PRLogModuleInfo* gDocShellLeakLog; const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties"; const char kAppstringsBundleURL[] = "chrome://global/locale/appstrings.properties"; @@ -818,7 +818,17 @@ nsDocShell::nsDocShell() CallGetService(NS_URIFIXUP_CONTRACTID, &sURIFixup); } - MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this)); +#ifdef DEBUG + if (!gDocShellLog) { + gDocShellLog = PR_NewLogModule("nsDocShell"); + } +#endif + if (!gDocShellLeakLog) { + gDocShellLeakLog = PR_NewLogModule("nsDocShellLeak"); + } + if (gDocShellLeakLog) { + MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this)); + } #ifdef DEBUG // We're counting the number of |nsDocShells| to help find leaks diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp index 263231c1d70..6400fe64dbd 100644 --- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -59,9 +59,16 @@ int32_t nsSHistory::sHistoryMaxTotalViewers = -1; // entries were touched, so that we can evict older entries first. static uint32_t gTouchCounter = 0; -static LazyLogModule gSHistoryLog("nsSHistory"); - -#define LOG(format) MOZ_LOG(gSHistoryLog, mozilla::LogLevel::Debug, format) +static PRLogModuleInfo* +GetSHistoryLog() +{ + static PRLogModuleInfo* sLog; + if (!sLog) { + sLog = PR_NewLogModule("nsSHistory"); + } + return sLog; +} +#define LOG(format) MOZ_LOG(GetSHistoryLog(), mozilla::LogLevel::Debug, format) // This macro makes it easier to print a log message which includes a URI's // spec. Example use: @@ -71,7 +78,7 @@ static LazyLogModule gSHistoryLog("nsSHistory"); // #define LOG_SPEC(format, uri) \ PR_BEGIN_MACRO \ - if (MOZ_LOG_TEST(gSHistoryLog, LogLevel::Debug)) { \ + if (MOZ_LOG_TEST(GetSHistoryLog(), LogLevel::Debug)) { \ nsAutoCString _specStr(NS_LITERAL_CSTRING("(null)"));\ if (uri) { \ uri->GetSpec(_specStr); \ @@ -89,7 +96,7 @@ static LazyLogModule gSHistoryLog("nsSHistory"); // #define LOG_SHENTRY_SPEC(format, shentry) \ PR_BEGIN_MACRO \ - if (MOZ_LOG_TEST(gSHistoryLog, LogLevel::Debug)) { \ + if (MOZ_LOG_TEST(GetSHistoryLog(), LogLevel::Debug)) { \ nsCOMPtr uri; \ shentry->GetURI(getter_AddRefs(uri)); \ LOG_SPEC(format, uri); \ diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 8681aad2e73..3c13f6f0fec 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -11,7 +11,6 @@ #include #include -#include "prprf.h" #include "DecoderTraits.h" #include "harfbuzz/hb.h" #include "imgICache.h" @@ -3525,7 +3524,7 @@ nsContentUtils::ReportToConsoleNonLocalized(const nsAString& aErrorText, } void -nsContentUtils::LogMessageToConsole(const char* aMsg, ...) +nsContentUtils::LogMessageToConsole(const char* aMsg) { if (!sConsoleService) { // only need to bother null-checking here CallGetService(NS_CONSOLESERVICE_CONTRACTID, &sConsoleService); @@ -3533,17 +3532,7 @@ nsContentUtils::LogMessageToConsole(const char* aMsg, ...) return; } } - - va_list args; - va_start(args, aMsg); - char* formatted = PR_vsmprintf(aMsg, args); - va_end(args); - if (!formatted) { - return; - } - - sConsoleService->LogStringMessage(NS_ConvertUTF8toUTF16(formatted).get()); - PR_smprintf_free(formatted); + sConsoleService->LogStringMessage(NS_ConvertUTF8toUTF16(aMsg).get()); } bool @@ -6928,7 +6917,7 @@ nsContentUtils::GetAdjustedOffsetInTextControl(nsIFrame* aOffsetFrame, // has the text frames (containing the content) as its children. This will // be the case if we click to the right of any of the text frames, or at the // bottom of the text area. - nsIFrame* firstChild = aOffsetFrame->GetFirstPrincipalChild(); + nsIFrame* firstChild = aOffsetFrame->PrincipalChildList().FirstChild(); if (firstChild) { // In this case, the passed-in offset is incorrect, and we want the length // of the entire content in the text control frame. @@ -6941,7 +6930,7 @@ nsContentUtils::GetAdjustedOffsetInTextControl(nsIFrame* aOffsetFrame, // frame. Our offset should therefore be the length of the first child of // our parent. int32_t aOutOffset = - aOffsetFrame->GetParent()->GetFirstPrincipalChild()->GetContent()->Length(); + aOffsetFrame->GetParent()->PrincipalChildList().FirstChild()->GetContent()->Length(); return aOutOffset; } diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index c04edd485f3..a714367dad1 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -893,8 +893,8 @@ public: uint32_t aLineNumber = 0, uint32_t aColumnNumber = 0); - static void LogMessageToConsole(const char* aMsg, ...); - + static void LogMessageToConsole(const char* aMsg); + /** * Get the localized string named |aKey| in properties file |aFile|. */ diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 76da94771f3..05fcb4d61ab 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -106,7 +106,6 @@ #include "HTMLImageElement.h" #include "mozilla/css/ImageLoader.h" #include "mozilla/layers/APZCTreeManager.h" // for layers::ZoomToRectBehavior -#include "mozilla/dom/Promise.h" #ifdef XP_WIN #undef GetClassName @@ -2151,29 +2150,26 @@ nsDOMWindowUtils::GetLayerManagerRemote(bool* retval) } NS_IMETHODIMP -nsDOMWindowUtils::GetSupportsHardwareH264Decoding(JS::MutableHandle aPromise) +nsDOMWindowUtils::GetSupportsHardwareH264Decoding(nsAString& aRetval) { - nsCOMPtr window = do_QueryReferent(mWindow); - NS_ENSURE_STATE(window); - nsCOMPtr parentObject = do_QueryInterface(window); - NS_ENSURE_STATE(parentObject); #ifdef MOZ_FMP4 nsCOMPtr widget = GetWidget(); - NS_ENSURE_STATE(widget); + if (!widget) + return NS_ERROR_FAILURE; + LayerManager *mgr = widget->GetLayerManager(); - NS_ENSURE_STATE(mgr); - RefPtr promise = - MP4Decoder::IsVideoAccelerated(mgr->GetCompositorBackendType(), parentObject); - NS_ENSURE_STATE(promise); - aPromise.setObject(*promise->GetWrapper()); -#else - ErrorResult rv; - RefPtr promise = Promise::Create(parentObject, rv); - if (rv.Failed()) { - return rv.StealNSResult(); + if (!mgr) + return NS_ERROR_FAILURE; + + nsCString failureReason; + if (MP4Decoder::IsVideoAccelerated(mgr->GetCompositorBackendType(), failureReason)) { + aRetval.AssignLiteral("Yes"); + } else { + aRetval.AssignLiteral("No; "); + AppendUTF8toUTF16(failureReason, aRetval); } - promise.MaybeResolve(NS_LITERAL_STRING("No; Compiled without MP4 support.")); - aPromise.setObject(*promise->GetWrapper()); +#else + aRetval.AssignLiteral("No; Compiled without MP4 support."); #endif return NS_OK; } diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp index 2e45a3043cc..f100a808d65 100644 --- a/dom/base/nsDocumentEncoder.cpp +++ b/dom/base/nsDocumentEncoder.cpp @@ -331,12 +331,10 @@ LineHasNonEmptyContentWorker(nsIFrame* aFrame) // Look for non-empty frames, but ignore inline and br frames. // For inline frames, descend into the children, if any. if (aFrame->GetType() == nsGkAtoms::inlineFrame) { - nsIFrame* child = aFrame->GetFirstPrincipalChild(); - while (child) { + for (nsIFrame* child : aFrame->PrincipalChildList()) { if (LineHasNonEmptyContentWorker(child)) { return true; } - child = child->GetNextSibling(); } } else { if (aFrame->GetType() != nsGkAtoms::brFrame && diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index cad3985d5a3..97b5db16032 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -9885,13 +9885,11 @@ static nsCanvasFrame* FindCanvasFrame(nsIFrame* aFrame) return canvasFrame; } - nsIFrame* kid = aFrame->GetFirstPrincipalChild(); - while (kid) { + for (nsIFrame* kid : aFrame->PrincipalChildList()) { canvasFrame = FindCanvasFrame(kid); if (canvasFrame) { return canvasFrame; } - kid = kid->GetNextSibling(); } return nullptr; diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index 688f927a9cd..090895092db 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -3335,7 +3335,7 @@ IsLastNonemptyRowGroupOfTable(nsIFrame* aFrame) } for (nsIFrame* c = aFrame; c; c = c->GetNextContinuation()) { for (nsIFrame* next = c->GetNextSibling(); next; next = next->GetNextSibling()) { - if (next->GetFirstPrincipalChild()) { + if (next->PrincipalChildList().FirstChild()) { return false; } } diff --git a/dom/canvas/WebGLValidateStrings.cpp b/dom/canvas/WebGLValidateStrings.cpp index 4aa4ad582f9..9df3fef7092 100644 --- a/dom/canvas/WebGLValidateStrings.cpp +++ b/dom/canvas/WebGLValidateStrings.cpp @@ -141,7 +141,7 @@ ValidateGLSLVariableName(const nsAString& name, WebGLContext* webgl, const char* if (name.IsEmpty()) return false; - const uint32_t maxSize = 256; + const uint32_t maxSize = webgl->IsWebGL2() ? 1024 : 256; if (name.Length() > maxSize) { webgl->ErrorInvalidValue("%s: Identifier is %d characters long, exceeds the" " maximum allowed length of %d characters.", diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 0de79536e4d..259cc1e7058 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -2917,9 +2917,7 @@ HTMLInputElement::Focus(ErrorResult& aError) // tab to the next one. nsIFrame* frame = GetPrimaryFrame(); if (frame) { - for (nsIFrame* childFrame = frame->GetFirstPrincipalChild(); - childFrame; - childFrame = childFrame->GetNextSibling()) { + for (nsIFrame* childFrame : frame->PrincipalChildList()) { // See if the child is a button control. nsCOMPtr formCtrl = do_QueryInterface(childFrame->GetContent()); diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index b9bc0c2f623..df88883d8e4 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -3058,41 +3058,36 @@ class HTMLMediaElement::StreamSizeListener : public MediaStreamListener { public: explicit StreamSizeListener(HTMLMediaElement* aElement) : mElement(aElement), - mMutex("HTMLMediaElement::StreamSizeListener") + mInitialSizeFound(false) {} void Forget() { mElement = nullptr; } - void ReceivedSize() + void ReceivedSize(gfx::IntSize aSize) { if (!mElement) { return; } - gfx::IntSize size; - { - MutexAutoLock lock(mMutex); - size = mInitialSize; - } RefPtr deathGrip = mElement; - mElement->UpdateInitialMediaSize(size); + mElement->UpdateInitialMediaSize(aSize); } - virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID, - StreamTime aTrackOffset, - uint32_t aTrackEvents, - const MediaSegment& aQueuedMedia, - MediaStream* aInputStream, - TrackID aInputTrackID) override + + void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID, + StreamTime aTrackOffset, + uint32_t aTrackEvents, + const MediaSegment& aQueuedMedia, + MediaStream* aInputStream, + TrackID aInputTrackID) override { - MutexAutoLock lock(mMutex); - if (mInitialSize != gfx::IntSize(0,0) || - aQueuedMedia.GetType() != MediaSegment::VIDEO) { + if (mInitialSizeFound || aQueuedMedia.GetType() != MediaSegment::VIDEO) { return; } const VideoSegment& video = static_cast(aQueuedMedia); for (VideoSegment::ConstChunkIterator c(video); !c.IsEnded(); c.Next()) { if (c->mFrame.GetIntrinsicSize() != gfx::IntSize(0,0)) { - mInitialSize = c->mFrame.GetIntrinsicSize(); nsCOMPtr event = - NS_NewRunnableMethod(this, &StreamSizeListener::ReceivedSize); + NS_NewRunnableMethodWithArgs( + this, &StreamSizeListener::ReceivedSize, + c->mFrame.GetIntrinsicSize()); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } } @@ -3102,9 +3097,8 @@ private: // These fields may only be accessed on the main thread HTMLMediaElement* mElement; - // mMutex protects the fields below; they can be accessed on any thread - Mutex mMutex; - gfx::IntSize mInitialSize; + // These fields may only be accessed on the MSG thread + bool mInitialSizeFound; }; class HTMLMediaElement::MediaStreamTracksAvailableCallback: @@ -3174,9 +3168,7 @@ void HTMLMediaElement::UpdateSrcMediaStreamPlaying(uint32_t aFlags) mMediaStreamListener = new StreamListener(this, "HTMLMediaElement::mMediaStreamListener"); - mMediaStreamSizeListener = new StreamSizeListener(this); stream->AddListener(mMediaStreamListener); - stream->AddListener(mMediaStreamSizeListener); mWatchManager.Watch(*mMediaStreamListener, &HTMLMediaElement::UpdateReadyStateInternal); @@ -3193,7 +3185,6 @@ void HTMLMediaElement::UpdateSrcMediaStreamPlaying(uint32_t aFlags) mSrcStreamPausedCurrentTime = CurrentTime(); stream->RemoveListener(mMediaStreamListener); - stream->RemoveListener(mMediaStreamSizeListener); stream->RemoveAudioOutput(this); VideoFrameContainer* container = GetVideoFrameContainer(); @@ -3209,8 +3200,6 @@ void HTMLMediaElement::UpdateSrcMediaStreamPlaying(uint32_t aFlags) mMediaStreamListener->Forget(); mMediaStreamListener = nullptr; - mMediaStreamSizeListener->Forget(); - mMediaStreamSizeListener = nullptr; } } @@ -3229,6 +3218,9 @@ void HTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream) RefPtr stream = GetSrcMediaStream(); if (stream) { stream->SetAudioChannelType(mAudioChannel); + + mMediaStreamSizeListener = new StreamSizeListener(this); + stream->AddListener(mMediaStreamSizeListener); } UpdateSrcMediaStreamPlaying(); @@ -3255,6 +3247,15 @@ void HTMLMediaElement::EndSrcMediaStreamPlayback() UpdateSrcMediaStreamPlaying(REMOVING_SRC_STREAM); + if (mMediaStreamSizeListener) { + RefPtr stream = GetSrcMediaStream(); + if (stream) { + stream->RemoveListener(mMediaStreamSizeListener); + } + mMediaStreamSizeListener->Forget(); + mMediaStreamSizeListener = nullptr; + } + mSrcStream->UnregisterTrackListener(mMediaStreamTrackListener); mMediaStreamTrackListener = nullptr; @@ -3403,6 +3404,10 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo, if (IsVideo() && HasVideo()) { DispatchAsyncEvent(NS_LITERAL_STRING("resize")); } + NS_ASSERTION(!HasVideo() || + (mMediaInfo.mVideo.mDisplay.width > 0 && + mMediaInfo.mVideo.mDisplay.height > 0), + "Video resolution must be known on 'loadedmetadata'"); DispatchAsyncEvent(NS_LITERAL_STRING("loadedmetadata")); if (mDecoder && mDecoder->IsTransportSeekable() && mDecoder->IsMediaSeekable()) { ProcessMediaFragmentURI(); @@ -4160,6 +4165,16 @@ void HTMLMediaElement::UpdateInitialMediaSize(const nsIntSize& aSize) if (!mMediaInfo.HasVideo()) { UpdateMediaSize(aSize); } + + if (!mMediaStreamSizeListener) { + return; + } + RefPtr stream = GetSrcMediaStream(); + if (stream) { + stream->RemoveListener(mMediaStreamSizeListener); + } + mMediaStreamSizeListener->Forget(); + mMediaStreamSizeListener = nullptr; } void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendEvents) diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index f3ca091fb0c..dde6b89dc43 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -1111,7 +1111,7 @@ nsGenericHTMLElement::GetFormControlFrame(bool aFlushFrames) // If we have generated content, the primary frame will be a // wrapper frame.. out real frame will be in its child list. - for (frame = frame->GetFirstPrincipalChild(); + for (frame = frame->PrincipalChildList().FirstChild(); frame; frame = frame->GetNextSibling()) { form_frame = do_QueryFrame(frame); diff --git a/dom/html/nsTextEditorState.cpp b/dom/html/nsTextEditorState.cpp index 06c88fac56a..11077c5149c 100644 --- a/dom/html/nsTextEditorState.cpp +++ b/dom/html/nsTextEditorState.cpp @@ -2168,7 +2168,7 @@ nsTextEditorState::InitializeKeyboardEventListeners() TrustedEventsAtSystemGroupBubble()); } - mSelCon->SetScrollableFrame(do_QueryFrame(mBoundFrame->GetFirstPrincipalChild())); + mSelCon->SetScrollableFrame(do_QueryFrame(mBoundFrame->PrincipalChildList().FirstChild())); } void diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index e2cb2b88748..6fdf5aee6bb 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -49,7 +49,7 @@ interface nsIJSRAIIHelper; interface nsIContentPermissionRequest; interface nsIObserver; -[scriptable, uuid(46b44e33-13c2-4eb3-bf80-76a4e0857ccc)] +[scriptable, uuid(ca6a458c-82e7-4979-886e-6d214eac6f0b)] interface nsIDOMWindowUtils : nsISupports { /** @@ -1334,12 +1334,11 @@ interface nsIDOMWindowUtils : nsISupports { readonly attribute boolean layerManagerRemote; /** - * Returns a Promise that will be resolved with a string once the capabilities - * of the h264 decoder have been determined. - * Success does not mean that all h264 video decoding will be done + * True if we can initialize a hardware-backed h264 decoder for a simple + * test video, does not mean that all h264 video decoding will be done * in hardware. */ - readonly attribute jsval supportsHardwareH264Decoding; + readonly attribute AString supportsHardwareH264Decoding; /** * Record (and return) frame-intervals for frames which were presented diff --git a/dom/media/fmp4/MP4Decoder.cpp b/dom/media/fmp4/MP4Decoder.cpp index f9945f857c3..25ad3adb21b 100644 --- a/dom/media/fmp4/MP4Decoder.cpp +++ b/dom/media/fmp4/MP4Decoder.cpp @@ -182,46 +182,23 @@ MP4Decoder::IsEnabled() return Preferences::GetBool("media.mp4.enabled"); } -// sTestH264ExtraData represents the content of the avcC atom found in -// an AVC1 h264 video. It contains the H264 SPS and PPS NAL. -// the structure of the avcC atom is as follow: -// write(0x1); // version, always 1 -// write(sps[0].data[1]); // profile -// write(sps[0].data[2]); // compatibility -// write(sps[0].data[3]); // level -// write(0xFC | 3); // reserved (6 bits), NULA length size - 1 (2 bits) -// write(0xE0 | 1); // reserved (3 bits), num of SPS (5 bits) -// write_word(sps[0].size); // 2 bytes for length of SPS -// for(size_t i=0 ; i < sps[0].size ; ++i) -// write(sps[0].data[i]); // data of SPS -// write(&b, pps.size()); // num of PPS -// for(size_t i=0 ; i < pps.size() ; ++i) { -// write_word(pps[i].size); // 2 bytes for length of PPS -// for(size_t j=0 ; j < pps[i].size ; ++j) -// write(pps[i].data[j]); // data of PPS -// } -// } -// here we have a h264 Baseline, 640x360 -// We use a 640x360 extradata, as some video framework (Apple VT) will never -// attempt to use hardware decoding for small videos. static const uint8_t sTestH264ExtraData[] = { - 0x01, 0x42, 0xc0, 0x1e, 0xff, 0xe1, 0x00, 0x17, 0x67, 0x42, - 0xc0, 0x1e, 0xbb, 0x40, 0x50, 0x17, 0xfc, 0xb8, 0x08, 0x80, - 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, 0xb5, 0x07, 0x8b, 0x17, - 0x50, 0x01, 0x00, 0x04, 0x68, 0xce, 0x32, 0xc8 + 0x01, 0x64, 0x00, 0x0a, 0xff, 0xe1, 0x00, 0x17, 0x67, 0x64, + 0x00, 0x0a, 0xac, 0xd9, 0x44, 0x26, 0x84, 0x00, 0x00, 0x03, + 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xc8, 0x3c, 0x48, 0x96, + 0x58, 0x01, 0x00, 0x06, 0x68, 0xeb, 0xe3, 0xcb, 0x22, 0xc0 }; static already_AddRefed CreateTestH264Decoder(layers::LayersBackend aBackend, - VideoInfo& aConfig, - FlushableTaskQueue* aTaskQueue) + VideoInfo& aConfig) { aConfig.mMimeType = "video/avc"; aConfig.mId = 1; aConfig.mDuration = 40000; aConfig.mMediaTime = 0; - aConfig.mDisplay = nsIntSize(640, 360); - aConfig.mImage = nsIntRect(0, 0, 640, 360); + aConfig.mDisplay = nsIntSize(64, 64); + aConfig.mImage = nsIntRect(0, 0, 64, 64); aConfig.mExtraData = new MediaByteBuffer(); aConfig.mExtraData->AppendElements(sTestH264ExtraData, MOZ_ARRAY_LENGTH(sTestH264ExtraData)); @@ -230,60 +207,23 @@ CreateTestH264Decoder(layers::LayersBackend aBackend, RefPtr platform = new PDMFactory(); RefPtr decoder( - platform->CreateDecoder(aConfig, aTaskQueue, nullptr, aBackend, nullptr)); + platform->CreateDecoder(aConfig, nullptr, nullptr, aBackend, nullptr)); return decoder.forget(); } -/* static */ already_AddRefed -MP4Decoder::IsVideoAccelerated(layers::LayersBackend aBackend, nsIGlobalObject* aParent) +/* static */ bool +MP4Decoder::IsVideoAccelerated(layers::LayersBackend aBackend, nsACString& aFailureReason) { - MOZ_ASSERT(NS_IsMainThread()); - - ErrorResult rv; - RefPtr promise; - promise = dom::Promise::Create(aParent, rv); - if (rv.Failed()) { - rv.SuppressException(); - return nullptr; - } - RefPtr taskQueue = - new FlushableTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER)); VideoInfo config; - RefPtr decoder(CreateTestH264Decoder(aBackend, config, taskQueue)); + RefPtr decoder(CreateTestH264Decoder(aBackend, config)); if (!decoder) { - promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to create H264 decoder")); - return promise.forget(); + aFailureReason.AssignLiteral("Failed to create H264 decoder"); + return false; } - - decoder->Init() - ->Then(AbstractThread::MainThread(), __func__, - [promise, decoder, taskQueue] (TrackInfo::TrackType aTrack) { - nsCString failureReason; - bool ok = decoder->IsHardwareAccelerated(failureReason); - nsAutoString result; - if (ok) { - result.AssignLiteral("Yes"); - } else { - result.AssignLiteral("No"); - if (failureReason.Length()) { - result.AppendLiteral("; "); - AppendUTF8toUTF16(failureReason, result); - } - } - promise->MaybeResolve(result); - decoder->Shutdown(); - taskQueue->BeginShutdown(); - taskQueue->AwaitShutdownAndIdle(); - }, - [promise, decoder, taskQueue] (MediaDataDecoder::DecoderFailureReason aResult) { - promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to initialize H264 decoder")); - decoder->Shutdown(); - taskQueue->BeginShutdown(); - taskQueue->AwaitShutdownAndIdle(); - }); - - return promise.forget(); + bool result = decoder->IsHardwareAccelerated(aFailureReason); + decoder->Shutdown(); + return result; } void diff --git a/dom/media/fmp4/MP4Decoder.h b/dom/media/fmp4/MP4Decoder.h index d99eb8e9767..62578ed2348 100644 --- a/dom/media/fmp4/MP4Decoder.h +++ b/dom/media/fmp4/MP4Decoder.h @@ -8,7 +8,6 @@ #include "MediaDecoder.h" #include "MediaFormatReader.h" -#include "mozilla/dom/Promise.h" namespace mozilla { @@ -39,8 +38,7 @@ public: // Returns true if the MP4 backend is preffed on. static bool IsEnabled(); - static already_AddRefed - IsVideoAccelerated(layers::LayersBackend aBackend, nsIGlobalObject* aParent); + static bool IsVideoAccelerated(layers::LayersBackend aBackend, nsACString& aReason); void GetMozDebugReaderData(nsAString& aString) override; diff --git a/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp b/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp index 036dcfc22a5..2922838a36a 100644 --- a/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp +++ b/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp @@ -43,6 +43,7 @@ FFVPXRuntimeLinker::Init() } MOZ_ASSERT(NS_IsMainThread()); + sLinkStatus = LinkStatus_FAILED; // We retrieve the path of the XUL library as this is where mozavcodec and // mozavutil libs are located. @@ -85,8 +86,6 @@ FFVPXRuntimeLinker::Init() sLinkStatus = LinkStatus_SUCCEEDED; return true; } - sLinkStatus = LinkStatus_FAILED; - return false; } diff --git a/dom/media/tests/mochitest/mochitest.ini b/dom/media/tests/mochitest/mochitest.ini index d5a050d1b7b..4abdca22dc2 100644 --- a/dom/media/tests/mochitest/mochitest.ini +++ b/dom/media/tests/mochitest/mochitest.ini @@ -54,6 +54,7 @@ skip-if = (toolkit == 'gonk' || buildapp == 'mulet' && debug) # debug-only failu [test_getUserMedia_callbacks.html] skip-if = toolkit == 'gonk' || buildapp == 'mulet' # Bug 1063290, intermittent timeout # TC: Bug 1144079 - Re-enable Mulet mochitests and reftests taskcluster-specific disables. [test_getUserMedia_gumWithinGum.html] +[test_getUserMedia_loadedmetadata.html] [test_getUserMedia_mediaStreamConstructors.html] [test_getUserMedia_playAudioTwice.html] [test_getUserMedia_playVideoAudioTwice.html] diff --git a/dom/media/tests/mochitest/test_getUserMedia_loadedmetadata.html b/dom/media/tests/mochitest/test_getUserMedia_loadedmetadata.html new file mode 100644 index 00000000000..3af0ea5ba1b --- /dev/null +++ b/dom/media/tests/mochitest/test_getUserMedia_loadedmetadata.html @@ -0,0 +1,36 @@ + + + + + + +
+
+
+ + diff --git a/dom/system/gonk/GonkGPSGeolocationProvider.cpp b/dom/system/gonk/GonkGPSGeolocationProvider.cpp index fa62d30c1d4..5ad23c67d6e 100644 --- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp +++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp @@ -56,6 +56,13 @@ #define FLUSH_AIDE_DATA 0 +#undef LOG +#undef ERR +#undef DBG +#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GonkGPSGeolocationProvider", ## args) +#define ERR(args...) __android_log_print(ANDROID_LOG_ERROR, "GonkGPSGeolocationProvider", ## args) +#define DBG(args...) __android_log_print(ANDROID_LOG_DEBUG, "GonkGPSGeolocationProvider" , ## args) + using namespace mozilla; using namespace mozilla::dom; @@ -139,10 +146,10 @@ GonkGPSGeolocationProvider::LocationCallback(GpsLocation* location) // set in the DOM JS. if (gDebug_isLoggingEnabled) { - nsContentUtils::LogMessageToConsole("geo: GPS got a fix (%f, %f). accuracy: %f", - location->latitude, - location->longitude, - location->accuracy); + DBG("geo: GPS got a fix (%f, %f). accuracy: %f", + location->latitude, + location->longitude, + location->accuracy); } RefPtr event = new UpdateLocationEvent(somewhere); @@ -199,7 +206,7 @@ GonkGPSGeolocationProvider::StatusCallback(GpsStatus* status) break; } if (gDebug_isLoggingEnabled){ - nsContentUtils::LogMessageToConsole(msgStream); + DBG("%s", msgStream); } } @@ -240,7 +247,7 @@ GonkGPSGeolocationProvider::SvStatusCallback(GpsSvStatus* sv_info) svEphemerisCount != numEphemeris || svUsedCount != numUsedInFix) { - nsContentUtils::LogMessageToConsole( + LOG( "geo: Number of SVs have (visibility, almanac, ephemeris): (%d, %d, %d)." " %d of these SVs were used in fix.\n", sv_info->num_svs, svAlmanacCount, svEphemerisCount, svUsedCount); @@ -257,8 +264,7 @@ void GonkGPSGeolocationProvider::NmeaCallback(GpsUtcTime timestamp, const char* nmea, int length) { if (gDebug_isLoggingEnabled) { - nsContentUtils::LogMessageToConsole("geo: NMEA: timestamp:\t%lld, length: %d, %s", - timestamp, length, nmea); + DBG("NMEA: timestamp:\t%lld, length: %d, %s", timestamp, length, nmea); } } @@ -532,15 +538,13 @@ GonkGPSGeolocationProvider::RequestSettingValue(const char* aKey) nsCOMPtr lock; nsresult rv = ss->CreateLock(nullptr, getter_AddRefs(lock)); if (NS_FAILED(rv)) { - nsContentUtils::LogMessageToConsole( - "geo: error while createLock setting '%s': %d\n", aKey, rv); + ERR("error while createLock setting '%s': %d\n", aKey, rv); return; } rv = lock->Get(aKey, this); if (NS_FAILED(rv)) { - nsContentUtils::LogMessageToConsole( - "geo: error while get setting '%s': %d\n", aKey, rv); + ERR("error while get setting '%s': %d\n", aKey, rv); return; } } @@ -639,8 +643,8 @@ ConvertToGpsRefLocationType(const nsAString& aConnectionType) } if (gDebug_isLoggingEnabled) { - nsContentUtils::LogMessageToConsole("geo: Unsupported connection type %s\n", - NS_ConvertUTF16toUTF8(aConnectionType).get()); + DBG("geo: Unsupported connection type %s\n", + NS_ConvertUTF16toUTF8(aConnectionType).get()); } return AGPS_REF_LOCATION_TYPE_GSM_CELLID; } @@ -744,8 +748,7 @@ GonkGPSGeolocationProvider::InjectLocation(double latitude, float accuracy) { if (gDebug_isLoggingEnabled) { - nsContentUtils::LogMessageToConsole("geo: injecting location (%f, %f) accuracy: %f", - latitude, longitude, accuracy); + DBG("injecting location (%f, %f) accuracy: %f", latitude, longitude, accuracy); } MOZ_ASSERT(NS_IsMainThread()); @@ -947,14 +950,12 @@ GonkGPSGeolocationProvider::NetworkLocationUpdate::Update(nsIDOMGeoPosition *pos (isGPSTempInactive && delta > kMinMLSCoordChangeInMeters)) { if (gDebug_isLoggingEnabled) { - nsContentUtils::LogMessageToConsole("geo: Using MLS, GPS age:%fs, MLS Delta:%fm\n", - diff_ms / 1000.0, delta); + DBG("Using MLS, GPS age:%fs, MLS Delta:%fm\n", diff_ms / 1000.0, delta); } provider->mLocationCallback->Update(position); } else if (provider->mLastGPSPosition) { if (gDebug_isLoggingEnabled) { - nsContentUtils::LogMessageToConsole("geo: Using old GPS age:%fs\n", - diff_ms / 1000.0); + DBG("Using old GPS age:%fs\n", diff_ms / 1000.0); } // This is a fallback case so that the GPS provider responds with its last @@ -1185,16 +1186,15 @@ GonkGPSGeolocationProvider::Observe(nsISupports* aSubject, } if (setting.mKey.EqualsASCII(kSettingDebugGpsIgnored)) { - nsContentUtils::LogMessageToConsole("geo: received mozsettings-changed: ignoring\n"); + LOG("received mozsettings-changed: ignoring\n"); gDebug_isGPSLocationIgnored = setting.mValue.isBoolean() ? setting.mValue.toBoolean() : false; if (gDebug_isLoggingEnabled) { - nsContentUtils::LogMessageToConsole("geo: Debug: GPS ignored %d\n", - gDebug_isGPSLocationIgnored); + DBG("GPS ignored %d\n", gDebug_isGPSLocationIgnored); } return NS_OK; } else if (setting.mKey.EqualsASCII(kSettingDebugEnabled)) { - nsContentUtils::LogMessageToConsole("geo: received mozsettings-changed: logging\n"); + LOG("received mozsettings-changed: logging\n"); gDebug_isLoggingEnabled = setting.mValue.isBoolean() ? setting.mValue.toBoolean() : false; return NS_OK; diff --git a/dom/workers/ServiceWorkerRegistrar.cpp b/dom/workers/ServiceWorkerRegistrar.cpp index 36270d66b73..83348c217ab 100644 --- a/dom/workers/ServiceWorkerRegistrar.cpp +++ b/dom/workers/ServiceWorkerRegistrar.cpp @@ -310,8 +310,8 @@ ServiceWorkerRegistrar::ReadData() } if (!IsSupportedVersion(version)) { - nsContentUtils::LogMessageToConsole( - "Unsupported service worker registrar version: %s", version.get()); + nsContentUtils::LogMessageToConsole(nsPrintfCString( + "Unsupported service worker registrar version: %s", version.get()).get()); return NS_ERROR_FAILURE; } diff --git a/extensions/auth/nsAuth.h b/extensions/auth/nsAuth.h index a32072cdb7b..6abee650e2b 100644 --- a/extensions/auth/nsAuth.h +++ b/extensions/auth/nsAuth.h @@ -20,7 +20,7 @@ enum pType { // set NSPR_LOG_MODULES=negotiateauth:4 // set NSPR_LOG_FILE=negotiateauth.log // -extern mozilla::LazyLogModule gNegotiateLog; +extern PRLogModuleInfo* gNegotiateLog; #define LOG(args) MOZ_LOG(gNegotiateLog, mozilla::LogLevel::Debug, args) diff --git a/extensions/auth/nsAuthFactory.cpp b/extensions/auth/nsAuthFactory.cpp index d97d9ca8597..a6434251f4c 100644 --- a/extensions/auth/nsAuthFactory.cpp +++ b/extensions/auth/nsAuthFactory.cpp @@ -220,12 +220,13 @@ static const mozilla::Module::ContractIDEntry kAuthContracts[] = { }; //----------------------------------------------------------------------------- -mozilla::LazyLogModule gNegotiateLog("negotiateauth"); +PRLogModuleInfo *gNegotiateLog; // setup nspr logging ... static nsresult InitNegotiateAuth() { + gNegotiateLog = PR_NewLogModule("negotiateauth"); return NS_OK; } diff --git a/extensions/gio/nsGIOProtocolHandler.cpp b/extensions/gio/nsGIOProtocolHandler.cpp index 00d842fba59..71db2d5da3a 100644 --- a/extensions/gio/nsGIOProtocolHandler.cpp +++ b/extensions/gio/nsGIOProtocolHandler.cpp @@ -37,7 +37,7 @@ //----------------------------------------------------------------------------- // NSPR_LOG_MODULES=gio:5 -static mozilla::LazyLogModule sGIOLog("gio"); +static PRLogModuleInfo *sGIOLog; #define LOG(args) MOZ_LOG(sGIOLog, mozilla::LogLevel::Debug, args) @@ -911,6 +911,8 @@ NS_IMPL_ISUPPORTS(nsGIOProtocolHandler, nsIProtocolHandler, nsIObserver) nsresult nsGIOProtocolHandler::Init() { + sGIOLog = PR_NewLogModule("gio"); + nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); if (prefs) { diff --git a/extensions/pref/autoconfig/src/nsAutoConfig.cpp b/extensions/pref/autoconfig/src/nsAutoConfig.cpp index c8c9b3098d3..56688e6390a 100644 --- a/extensions/pref/autoconfig/src/nsAutoConfig.cpp +++ b/extensions/pref/autoconfig/src/nsAutoConfig.cpp @@ -26,7 +26,7 @@ using mozilla::LogLevel; -mozilla::LazyLogModule MCD("MCD"); +PRLogModuleInfo *MCD; extern nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length, const char *filename, diff --git a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp index c5aafffc3b1..4da1c1fa433 100644 --- a/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp +++ b/extensions/pref/autoconfig/src/nsJSConfigTriggers.cpp @@ -19,7 +19,7 @@ #include "nsIScriptError.h" #include "jswrapper.h" -extern mozilla::LazyLogModule MCD; +extern PRLogModuleInfo *MCD; using mozilla::AutoSafeJSContext; //***************************************************************************** diff --git a/extensions/pref/autoconfig/src/nsReadConfig.cpp b/extensions/pref/autoconfig/src/nsReadConfig.cpp index fe50f67cfb1..7ac886c7c90 100644 --- a/extensions/pref/autoconfig/src/nsReadConfig.cpp +++ b/extensions/pref/autoconfig/src/nsReadConfig.cpp @@ -26,7 +26,7 @@ #include "nsXULAppAPI.h" #include "nsContentUtils.h" -extern mozilla::LazyLogModule MCD; +extern PRLogModuleInfo *MCD; extern nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length, const char *filename, @@ -75,6 +75,8 @@ NS_IMPL_ISUPPORTS(nsReadConfig, nsIReadConfig, nsIObserver) nsReadConfig::nsReadConfig() : mRead(false) { + if (!MCD) + MCD = PR_NewLogModule("MCD"); } nsresult nsReadConfig::Init() diff --git a/hal/Hal.cpp b/hal/Hal.cpp index b982b0cfbbc..3117721b469 100644 --- a/hal/Hal.cpp +++ b/hal/Hal.cpp @@ -61,10 +61,13 @@ using namespace mozilla::dom; namespace mozilla { namespace hal { -mozilla::LogModule * +PRLogModuleInfo * GetHalLog() { - static mozilla::LazyLogModule sHalLog("hal"); + static PRLogModuleInfo *sHalLog; + if (!sHalLog) { + sHalLog = PR_NewLogModule("hal"); + } return sHalLog; } diff --git a/hal/HalLog.h b/hal/HalLog.h index 0d72e98d0fd..7cdc9d88794 100644 --- a/hal/HalLog.h +++ b/hal/HalLog.h @@ -20,7 +20,7 @@ namespace mozilla { namespace hal { -mozilla::LogModule *GetHalLog(); +extern PRLogModuleInfo *GetHalLog(); #define HAL_LOG(...) \ MOZ_LOG(mozilla::hal::GetHalLog(), LogLevel::Debug, (__VA_ARGS__)) #define HAL_ERR(...) \ diff --git a/ipc/chromium/src/base/logging.cc b/ipc/chromium/src/base/logging.cc index ed7facc96eb..8b0f9d843c3 100644 --- a/ipc/chromium/src/base/logging.cc +++ b/ipc/chromium/src/base/logging.cc @@ -42,7 +42,7 @@ Logger::~Logger() break; } - MOZ_LOG(gChromiumPRLog, prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "")); + MOZ_LOG(GetLog(), prlevel, ("%s:%i: %s", mFile, mLine, mMsg ? mMsg : "")); if (xpcomlevel != -1) NS_DebugBreak(xpcomlevel, mMsg, NULL, mFile, mLine); @@ -58,7 +58,15 @@ Logger::printf(const char* fmt, ...) va_end(args); } -LazyLogModule Logger::gChromiumPRLog("chromium"); +PRLogModuleInfo* Logger::gChromiumPRLog; + +PRLogModuleInfo* Logger::GetLog() +{ + if (!gChromiumPRLog) + gChromiumPRLog = PR_NewLogModule("chromium"); + return gChromiumPRLog; +} + } // namespace mozilla mozilla::Logger& diff --git a/ipc/chromium/src/base/logging.h b/ipc/chromium/src/base/logging.h index b8e3c64d9a0..5a9c16655ee 100644 --- a/ipc/chromium/src/base/logging.h +++ b/ipc/chromium/src/base/logging.h @@ -45,8 +45,8 @@ public: void printf(const char* fmt, ...); private: - static mozilla::LazyLogModule gChromiumPRLog; -// static PRLogModuleInfo* GetLog(); + static PRLogModuleInfo* gChromiumPRLog; + static PRLogModuleInfo* GetLog(); LogSeverity mSeverity; const char* mFile; diff --git a/js/src/asmjs/AsmJS.cpp b/js/src/asmjs/AsmJS.cpp index 88791f68ca1..2700af4c280 100644 --- a/js/src/asmjs/AsmJS.cpp +++ b/js/src/asmjs/AsmJS.cpp @@ -1674,11 +1674,6 @@ class MOZ_STACK_CLASS ModuleValidator return sigMap_.add(p, &mg_.sig(*sigIndex), *sigIndex); } - // ModuleGeneratorData limits: - static const unsigned MaxSigs = 4 * 1024; - static const unsigned MaxFuncs = 512 * 1024; - static const unsigned MaxImports = 4 * 1024; - public: ModuleValidator(ExclusiveContext* cx, AsmJSParser& parser, ParseNode* moduleFunctionNode) : cx_(cx), diff --git a/js/src/asmjs/Wasm.cpp b/js/src/asmjs/Wasm.cpp index 9a7e9833b86..ba25f5cc05d 100644 --- a/js/src/asmjs/Wasm.cpp +++ b/js/src/asmjs/Wasm.cpp @@ -322,11 +322,14 @@ DecodeSignatureSection(JSContext* cx, Decoder& d, ModuleGeneratorData* init) uint32_t sectionStart; if (!d.startSection(§ionStart)) - return Fail(cx, d, "expected decl section byte size"); + return Fail(cx, d, "expected signature section byte size"); uint32_t numSigs; if (!d.readVarU32(&numSigs)) - return Fail(cx, d, "expected number of declarations"); + return Fail(cx, d, "expected number of signatures"); + + if (numSigs > MaxSigs) + return Fail(cx, d, "too many signatures"); if (!init->sigs.resize(numSigs)) return false; @@ -336,6 +339,9 @@ DecodeSignatureSection(JSContext* cx, Decoder& d, ModuleGeneratorData* init) if (!d.readVarU32(&numArgs)) return Fail(cx, d, "bad number of signature args"); + if (numArgs > MaxArgsPerFunc) + return Fail(cx, d, "too many arguments in signature"); + ExprType result; if (!DecodeExprType(cx, d, &result)) return false; @@ -387,6 +393,9 @@ DecodeDeclarationSection(JSContext* cx, Decoder& d, ModuleGeneratorData* init) if (!d.readVarU32(&numDecls)) return Fail(cx, d, "expected number of declarations"); + if (numDecls > MaxFuncs) + return Fail(cx, d, "too many functions"); + if (!init->funcSigs.resize(numDecls)) return false; @@ -465,6 +474,9 @@ DecodeImportSection(JSContext* cx, Decoder& d, ModuleGeneratorData* init, Import if (!d.readVarU32(&numImports)) return Fail(cx, d, "expected number of imports"); + if (numImports > MaxImports) + return Fail(cx, d, "too many imports"); + for (uint32_t i = 0; i < numImports; i++) { if (!DecodeImport(cx, d, init, imports)) return false; @@ -526,6 +538,9 @@ DecodeExportsSection(JSContext* cx, Decoder& d, ModuleGenerator& mg, ExportMap* if (!d.readVarU32(&numExports)) return Fail(cx, d, "expected number of exports"); + if (numExports > MaxExports) + return Fail(cx, d, "too many exports"); + for (uint32_t i = 0; i < numExports; i++) { if (!DecodeExport(cx, d, mg, exportMap)) return false; diff --git a/js/src/asmjs/WasmBinary.h b/js/src/asmjs/WasmBinary.h index d9045476037..2c0aaae73cd 100644 --- a/js/src/asmjs/WasmBinary.h +++ b/js/src/asmjs/WasmBinary.h @@ -28,6 +28,13 @@ class PropertyName; namespace wasm { +// Module generator limits +static const unsigned MaxSigs = 4 * 1024; +static const unsigned MaxFuncs = 512 * 1024; +static const unsigned MaxImports = 4 * 1024; +static const unsigned MaxExports = 4 * 1024; +static const unsigned MaxArgsPerFunc = 4 * 1024; + // Module header constants static const uint32_t MagicNumber = 0x6d736100; // "\0asm" static const uint32_t EncodingVersion = -1; // experimental diff --git a/js/src/jit-test/tests/wasm/binary.js b/js/src/jit-test/tests/wasm/binary.js index 719b71d9d1f..1192b34ffbb 100644 --- a/js/src/jit-test/tests/wasm/binary.js +++ b/js/src/jit-test/tests/wasm/binary.js @@ -49,6 +49,8 @@ function varU32(u32) { return [u32]; } +const U32MAX_LEB = [255, 255, 255, 255, 15]; + function moduleHeaderThen(...rest) { return [magic0, magic1, magic2, magic3, ver0, ver1, ver2, ver3, ...rest]; } @@ -139,6 +141,12 @@ const trivialSigSection = sigSection([{args:[], ret:VoidCode}]); const trivialDeclSection = declSection([0]); const trivialCodeSection = codeSection([{locals:[], body:[0, 0]}]); +assertErrorMessage(() => wasmEval(toBuf(moduleWithSections([ {name: sigSectionStr, body: U32MAX_LEB, } ]))), Error, /too many signatures/); +assertErrorMessage(() => wasmEval(toBuf(moduleWithSections([ {name: sigSectionStr, body: [1, ...U32MAX_LEB], } ]))), Error, /too many arguments in signature/); +assertErrorMessage(() => wasmEval(toBuf(moduleWithSections([trivialSigSection, {name: declSectionStr, body: U32MAX_LEB, }]))), Error, /too many functions/); +assertErrorMessage(() => wasmEval(toBuf(moduleWithSections([trivialSigSection, {name: importSectionStr, body: U32MAX_LEB, }]))), Error, /too many imports/); +assertErrorMessage(() => wasmEval(toBuf(moduleWithSections([trivialSigSection, {name: exportSectionStr, body: U32MAX_LEB, }]))), Error, /too many exports/); + assertThrowsInstanceOf(() => wasmEval(toBuf(moduleWithSections([{name: sigSectionStr, body: [1]}]))), TypeError); assertThrowsInstanceOf(() => wasmEval(toBuf(moduleWithSections([{name: sigSectionStr, body: [1, 1, 0]}]))), TypeError); diff --git a/js/src/jit/arm/BaselineIC-arm.cpp b/js/src/jit/arm/BaselineIC-arm.cpp index 2f56a01b8ef..8534638882e 100644 --- a/js/src/jit/arm/BaselineIC-arm.cpp +++ b/js/src/jit/arm/BaselineIC-arm.cpp @@ -31,8 +31,8 @@ ICCompare_Int32::Compiler::generateStubCode(MacroAssembler& masm) // Compare payload regs of R0 and R1. Assembler::Condition cond = JSOpToCondition(op, /* signed = */true); masm.cmp32(R0.payloadReg(), R1.payloadReg()); - masm.ma_mov(Imm32(1), R0.payloadReg(), LeaveCC, cond); - masm.ma_mov(Imm32(0), R0.payloadReg(), LeaveCC, Assembler::InvertCondition(cond)); + masm.ma_mov(Imm32(1), R0.payloadReg(), cond); + masm.ma_mov(Imm32(0), R0.payloadReg(), Assembler::InvertCondition(cond)); // Result is implicitly boxed already. masm.tagValue(JSVAL_TYPE_BOOLEAN, R0.payloadReg(), R0); @@ -59,7 +59,7 @@ ICCompare_Double::Compiler::generateStubCode(MacroAssembler& masm) masm.compareDouble(FloatReg0, FloatReg1); masm.ma_mov(Imm32(0), dest); - masm.ma_mov(Imm32(1), dest, LeaveCC, cond); + masm.ma_mov(Imm32(1), dest, cond); masm.tagValue(JSVAL_TYPE_BOOLEAN, dest, R0); EmitReturnFromIC(masm); diff --git a/js/src/jit/arm/CodeGenerator-arm.cpp b/js/src/jit/arm/CodeGenerator-arm.cpp index 202dc5752b5..f35f9d89976 100644 --- a/js/src/jit/arm/CodeGenerator-arm.cpp +++ b/js/src/jit/arm/CodeGenerator-arm.cpp @@ -90,7 +90,7 @@ CodeGeneratorARM::visitCompare(LCompare* comp) else masm.ma_cmp(ToRegister(left), ToOperand(right)); masm.ma_mov(Imm32(0), ToRegister(def)); - masm.ma_mov(Imm32(1), ToRegister(def), LeaveCC, cond); + masm.ma_mov(Imm32(1), ToRegister(def), cond); } void @@ -1583,8 +1583,8 @@ CodeGeneratorARM::visitNotD(LNotD* ins) } else { masm.as_vmrs(pc); masm.ma_mov(Imm32(0), dest); - masm.ma_mov(Imm32(1), dest, LeaveCC, Assembler::Equal); - masm.ma_mov(Imm32(1), dest, LeaveCC, Assembler::Overflow); + masm.ma_mov(Imm32(1), dest, Assembler::Equal); + masm.ma_mov(Imm32(1), dest, Assembler::Overflow); } } @@ -1611,8 +1611,8 @@ CodeGeneratorARM::visitNotF(LNotF* ins) } else { masm.as_vmrs(pc); masm.ma_mov(Imm32(0), dest); - masm.ma_mov(Imm32(1), dest, LeaveCC, Assembler::Equal); - masm.ma_mov(Imm32(1), dest, LeaveCC, Assembler::Overflow); + masm.ma_mov(Imm32(1), dest, Assembler::Equal); + masm.ma_mov(Imm32(1), dest, Assembler::Overflow); } } @@ -2183,7 +2183,7 @@ CodeGeneratorARM::visitAsmJSLoadHeap(LAsmJSLoadHeap* ins) if (mir->isAtomicAccess()) masm.ma_b(masm.asmOnOutOfBoundsLabel(), Assembler::AboveOrEqual); else - masm.ma_mov(Imm32(0), d, LeaveCC, Assembler::AboveOrEqual); + masm.ma_mov(Imm32(0), d, Assembler::AboveOrEqual); masm.ma_dataTransferN(IsLoad, size, isSigned, HeapReg, ptrReg, d, Offset, Assembler::Below); } memoryBarrier(mir->barrierAfter()); diff --git a/js/src/jit/arm/MacroAssembler-arm.cpp b/js/src/jit/arm/MacroAssembler-arm.cpp index 13a497d2734..2a8e5f7211d 100644 --- a/js/src/jit/arm/MacroAssembler-arm.cpp +++ b/js/src/jit/arm/MacroAssembler-arm.cpp @@ -272,6 +272,10 @@ void MacroAssemblerARM::ma_alu(Register src1, Imm32 imm, Register dest, ALUOp op, SBit s, Condition c) { + // ma_mov should be used for moves. + MOZ_ASSERT(op != OpMov); + MOZ_ASSERT(op != OpMvn); + // As it turns out, if you ask for a compare-like instruction you *probably* // want it to set condition codes. if (dest == InvalidReg) @@ -301,71 +305,18 @@ MacroAssemblerARM::ma_alu(Register src1, Imm32 imm, Register dest, return; } - if (HasMOVWT()) { - // If the operation is a move-a-like then we can try to use movw to move - // the bits into the destination. Otherwise, we'll need to fall back on - // a multi-instruction format :( - // movw/movt does not set condition codes, so don't hold your breath. - if (s == LeaveCC && (op == OpMov || op == OpMvn)) { - // ARMv7 supports movw/movt. movw zero-extends its 16 bit argument, - // so we can set the register this way. movt leaves the bottom 16 - // bits in tact, so it is unsuitable to move a constant that - if (op == OpMov && ((imm.value & ~ 0xffff) == 0)) { - MOZ_ASSERT(src1 == InvalidReg); - as_movw(dest, Imm16((uint16_t)imm.value), c); - return; - } - - // If they asked for a mvn rfoo, imm, where ~imm fits into 16 bits - // then do it. - if (op == OpMvn && (((~imm.value) & ~ 0xffff) == 0)) { - MOZ_ASSERT(src1 == InvalidReg); - as_movw(dest, Imm16((uint16_t)~imm.value), c); - return; - } - - // TODO: constant dedup may enable us to add dest, r0, 23 *if* we - // are attempting to load a constant that looks similar to one that - // already exists. If it can't be done with a single movw then we - // *need* to use two instructions since this must be some sort of a - // move operation, we can just use a movw/movt pair and get the - // whole thing done in two moves. This does not work for ops like - // add, since we'd need to do: movw tmp; movt tmp; add dest, tmp, - // src1. - if (op == OpMvn) - imm.value = ~imm.value; - as_movw(dest, Imm16(imm.value & 0xffff), c); - as_movt(dest, Imm16((imm.value >> 16) & 0xffff), c); - return; - } - // If we weren't doing a movalike, a 16 bit immediate will require 2 - // instructions. With the same amount of space and (less)time, we can do - // two 8 bit operations, reusing the dest register. e.g. - // movw tmp, 0xffff; add dest, src, tmp ror 4 - // vs. - // add dest, src, 0xff0; add dest, dest, 0xf000000f - // - // It turns out that there are some immediates that we miss with the - // second approach. A sample value is: add dest, src, 0x1fffe this can - // be done by movw tmp, 0xffff; add dest, src, tmp lsl 1 since imm8m's - // only get even offsets, we cannot encode this. I'll try to encode as - // two imm8's first, since they are faster. Both operations should take - // 1 cycle, where as add dest, tmp ror 4 takes two cycles to execute. - } - - // Either a) this isn't ARMv7 b) this isn't a move start by attempting to - // generate a two instruction form. Some things cannot be made into two-inst - // forms correctly. Namely, adds dest, src, 0xffff. Since we want the - // condition codes (and don't know which ones will be checked), we need to - // assume that the overflow flag will be checked and add{,s} dest, src, - // 0xff00; add{,s} dest, dest, 0xff is not guaranteed to set the overflow - // flag the same as the (theoretical) one instruction variant. + // Start by attempting to generate a two instruction form. Some things + // cannot be made into two-inst forms correctly. Namely, adds dest, src, + // 0xffff. Since we want the condition codes (and don't know which ones + // will be checked), we need to assume that the overflow flag will be + // checked and add{,s} dest, src, 0xff00; add{,s} dest, dest, 0xff is not + // guaranteed to set the overflof flag the same as the (theoretical) one + // instruction variant. if (alu_dbl(src1, imm, dest, op, s, c)) return; // And try with its negative. - if (negOp != OpInvalid && - alu_dbl(src1, negImm, negDest, negOp, s, c)) + if (negOp != OpInvalid && alu_dbl(src1, negImm, negDest, negOp, s, c)) return; // Often this code is called with dest as the ScratchRegister. The register @@ -381,25 +332,7 @@ MacroAssemblerARM::ma_alu(Register src1, Imm32 imm, Register dest, } #endif - // Well, damn. We can use two 16 bit mov's, then do the op or we can do a - // single load from a pool then op. - if (HasMOVWT()) { - // Try to load the immediate into a scratch register then use that - as_movw(scratch, Imm16(imm.value & 0xffff), c); - if ((imm.value >> 16) != 0) - as_movt(scratch, Imm16((imm.value >> 16) & 0xffff), c); - } else { - // Going to have to use a load. If the operation is a move, then just - // move it into the destination register - if (op == OpMov) { - as_Imm32Pool(dest, imm.value, c); - return; - } else { - // If this isn't just going into a register, then stick it in a - // temp, and then proceed. - as_Imm32Pool(scratch, imm.value, c); - } - } + ma_mov(imm, scratch, c); as_alu(dest, src1, O2Reg(scratch), op, s, c); } @@ -479,17 +412,44 @@ MacroAssemblerARM::ma_mov(Register src, Register dest, SBit s, Assembler::Condit } void -MacroAssemblerARM::ma_mov(Imm32 imm, Register dest, - SBit s, Assembler::Condition c) +MacroAssemblerARM::ma_mov(Imm32 imm, Register dest, Assembler::Condition c) { - ma_alu(InvalidReg, imm, dest, OpMov, s, c); + // Try mov with Imm8 operand. + Imm8 imm8 = Imm8(imm.value); + if (!imm8.invalid) { + as_alu(dest, InvalidReg, imm8, OpMov, LeaveCC, c); + return; + } + + // Try mvn with Imm8 operand. + Imm32 negImm = imm; + Register negDest; + ALUOp negOp = ALUNeg(OpMov, dest, &negImm, &negDest); + Imm8 negImm8 = Imm8(negImm.value); + if (negOp != OpInvalid && !negImm8.invalid) { + as_alu(negDest, InvalidReg, negImm8, negOp, LeaveCC, c); + return; + } + + // Try movw/movt. + if (HasMOVWT()) { + // ARMv7 supports movw/movt. movw zero-extends its 16 bit argument, + // so we can set the register this way. movt leaves the bottom 16 + // bits in tact, so we always need a movw. + as_movw(dest, Imm16(imm.value & 0xffff), c); + if (uint32_t(imm.value) >> 16) + as_movt(dest, Imm16(uint32_t(imm.value) >> 16), c); + return; + } + + // If we don't have movw/movt, we need a load. + as_Imm32Pool(dest, imm.value, c); } void -MacroAssemblerARM::ma_mov(ImmWord imm, Register dest, - SBit s, Assembler::Condition c) +MacroAssemblerARM::ma_mov(ImmWord imm, Register dest, Assembler::Condition c) { - ma_alu(InvalidReg, Imm32(imm.value), dest, OpMov, s, c); + ma_mov(Imm32(imm.value), dest, c); } void @@ -566,12 +526,6 @@ MacroAssemblerARM::ma_rol(Register shift, Register src, Register dst) } // Move not (dest <- ~src) -void -MacroAssemblerARM::ma_mvn(Imm32 imm, Register dest, SBit s, Assembler::Condition c) -{ - ma_alu(InvalidReg, imm, dest, OpMvn, s, c); -} - void MacroAssemblerARM::ma_mvn(Register src1, Register dest, SBit s, Assembler::Condition c) { @@ -1015,7 +969,7 @@ MacroAssemblerARM::ma_mod_mask(Register src, Register dest, Register hold, Regis ma_mov(Imm32(0), dest); // Set the hold appropriately. ma_mov(Imm32(1), hold); - ma_mov(Imm32(-1), hold, LeaveCC, Signed); + ma_mov(Imm32(-1), hold, Signed); ma_rsb(Imm32(0), tmp, SetCC, Signed); // Begin the main loop. @@ -2410,10 +2364,10 @@ MacroAssembler::clampDoubleToUint8(FloatRegister input, Register output) // Copy the converted value out. as_vxfer(output, InvalidReg, scratchDouble, FloatToCore); as_vmrs(pc); - ma_mov(Imm32(0), output, LeaveCC, Overflow); // NaN => 0 + ma_mov(Imm32(0), output, Overflow); // NaN => 0 ma_b(&outOfRange, Overflow); // NaN ma_cmp(output, Imm32(0xff)); - ma_mov(Imm32(0xff), output, LeaveCC, Above); + ma_mov(Imm32(0xff), output, Above); ma_b(&outOfRange, Above); // Convert it back to see if we got the same value back. as_vcvt(scratchDouble, VFPRegister(scratchDouble).uintOverlay()); diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 6b486c637ff..7b6fb5e0f09 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -123,19 +123,12 @@ class MacroAssemblerARM : public Assembler static void ma_mov_patch(ImmPtr imm, Register dest, Assembler::Condition c, RelocStyle rs, Instruction* i); - // These should likely be wrapped up as a set of macros or something like - // that. I cannot think of a good reason to explicitly have all of this - // code. - // ALU based ops // mov - void ma_mov(Register src, Register dest, - SBit s = LeaveCC, Condition c = Always); + void ma_mov(Register src, Register dest, SBit s = LeaveCC, Condition c = Always); - void ma_mov(Imm32 imm, Register dest, - SBit s = LeaveCC, Condition c = Always); - void ma_mov(ImmWord imm, Register dest, - SBit s = LeaveCC, Condition c = Always); + void ma_mov(Imm32 imm, Register dest, Condition c = Always); + void ma_mov(ImmWord imm, Register dest, Condition c = Always); void ma_mov(ImmGCPtr ptr, Register dest); @@ -145,7 +138,7 @@ class MacroAssemblerARM : public Assembler void ma_asr(Imm32 shift, Register src, Register dst); void ma_ror(Imm32 shift, Register src, Register dst); void ma_rol(Imm32 shift, Register src, Register dst); - // Shifts (just a move with a shifting op2) + void ma_lsl(Register shift, Register src, Register dst); void ma_lsr(Register shift, Register src, Register dst); void ma_asr(Register shift, Register src, Register dst); @@ -153,12 +146,7 @@ class MacroAssemblerARM : public Assembler void ma_rol(Register shift, Register src, Register dst); // Move not (dest <- ~src) - void ma_mvn(Imm32 imm, Register dest, - SBit s = LeaveCC, Condition c = Always); - - - void ma_mvn(Register src1, Register dest, - SBit s = LeaveCC, Condition c = Always); + void ma_mvn(Register src1, Register dest, SBit s = LeaveCC, Condition c = Always); // Negate (dest <- -src) implemented as rsb dest, src, 0 void ma_neg(Register src, Register dest, @@ -177,8 +165,6 @@ class MacroAssemblerARM : public Assembler void ma_and(Imm32 imm, Register src1, Register dest, SBit s = LeaveCC, Condition c = Always); - - // Bit clear (dest <- dest & ~imm) or (dest <- src1 & ~src2) void ma_bic(Imm32 imm, Register dest, SBit s = LeaveCC, Condition c = Always); @@ -1595,8 +1581,8 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM // <0, then we want to clamp to 0, otherwise, we wish to clamp to 255 ScratchRegisterScope scratch(asMasm()); as_mov(scratch, asr(reg, 8), SetCC); - ma_mov(Imm32(0xff), reg, LeaveCC, NotEqual); - ma_mov(Imm32(0), reg, LeaveCC, Signed); + ma_mov(Imm32(0xff), reg, NotEqual); + ma_mov(Imm32(0), reg, Signed); } inline void incrementInt32Value(const Address& addr); @@ -1648,7 +1634,7 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM emitSet(Assembler::Condition cond, Register dest) { ma_mov(Imm32(0), dest); - ma_mov(Imm32(1), dest, LeaveCC, cond); + ma_mov(Imm32(1), dest, cond); } template diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 0e5c2b32fb0..1a095a922b1 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -71,7 +71,7 @@ static const char kJSCachePrefix[] = "jsloader"; #define XPC_DESERIALIZATION_BUFFER_SIZE (12 * 8192) // NSPR_LOG_MODULES=JSComponentLoader:5 -static LazyLogModule gJSCLLog("JSComponentLoader"); +static PRLogModuleInfo* gJSCLLog; #define LOG(args) MOZ_LOG(gJSCLLog, mozilla::LogLevel::Debug, args) @@ -198,6 +198,10 @@ mozJSComponentLoader::mozJSComponentLoader() { MOZ_ASSERT(!sSelf, "mozJSComponentLoader should be a singleton"); + if (!gJSCLLog) { + gJSCLLog = PR_NewLogModule("JSComponentLoader"); + } + sSelf = this; } diff --git a/js/xpconnect/src/XPCLog.cpp b/js/xpconnect/src/XPCLog.cpp index 515af2a4786..5624587c788 100644 --- a/js/xpconnect/src/XPCLog.cpp +++ b/js/xpconnect/src/XPCLog.cpp @@ -25,12 +25,13 @@ static char* g_Spaces; static int g_InitState = 0; static int g_Indent = 0; -static mozilla::LazyLogModule g_LogMod("xpclog"); +static PRLogModuleInfo* g_LogMod = nullptr; static bool Init() { + g_LogMod = PR_NewLogModule("xpclog"); g_Spaces = new char[SPACE_COUNT+1]; - if (!g_Spaces || !MOZ_LOG_TEST(g_LogMod,LogLevel::Error)) { + if (!g_LogMod || !g_Spaces || !MOZ_LOG_TEST(g_LogMod,LogLevel::Error)) { g_InitState = 1; XPC_Log_Finish(); return false; @@ -46,6 +47,8 @@ XPC_Log_Finish() { if (g_InitState == 1) { delete [] g_Spaces; + // we'd like to properly cleanup the LogModule, but nspr owns that + g_LogMod = nullptr; } g_InitState = -1; } diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index b3ac37a6dad..cf5c614b01c 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -202,7 +202,7 @@ xpc::ErrorReport::Init(JSErrorReport* aReport, const char* aFallbackMessage, mIsMuted = aReport->isMuted; } -static LazyLogModule gJSDiagnostics("JSDiagnostics"); +static PRLogModuleInfo* gJSDiagnostics; void xpc::ErrorReport::LogToConsole() @@ -232,10 +232,15 @@ xpc::ErrorReport::LogToConsoleWithStack(JS::HandleObject aStack) fflush(stderr); } - MOZ_LOG(gJSDiagnostics, - JSREPORT_IS_WARNING(mFlags) ? LogLevel::Warning : LogLevel::Error, - ("file %s, line %u\n%s", NS_LossyConvertUTF16toASCII(mFileName).get(), - mLineNumber, NS_LossyConvertUTF16toASCII(mErrorMsg).get())); + // Log to the PR Log Module. + if (!gJSDiagnostics) + gJSDiagnostics = PR_NewLogModule("JSDiagnostics"); + if (gJSDiagnostics) { + MOZ_LOG(gJSDiagnostics, + JSREPORT_IS_WARNING(mFlags) ? LogLevel::Warning : LogLevel::Error, + ("file %s, line %u\n%s", NS_LossyConvertUTF16toASCII(mFileName).get(), + mLineNumber, NS_LossyConvertUTF16toASCII(mErrorMsg).get())); + } // Log to the console. We do this last so that we can simply return if // there's no console service without affecting the other reporting diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index be559cd075a..947048132da 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -223,13 +223,13 @@ GetFrameForChildrenOnlyTransformHint(nsIFrame *aFrame) // This happens if the root- is fixed positioned, in which case we // can't use aFrame->GetContent() to find the primary frame, since // GetContent() returns nullptr for ViewportFrame. - aFrame = aFrame->GetFirstPrincipalChild(); + aFrame = aFrame->PrincipalChildList().FirstChild(); } // For an nsHTMLScrollFrame, this will get the SVG frame that has the // children-only transforms: aFrame = aFrame->GetContent()->GetPrimaryFrame(); if (aFrame->GetType() == nsGkAtoms::svgOuterSVGFrame) { - aFrame = aFrame->GetFirstPrincipalChild(); + aFrame = aFrame->PrincipalChildList().FirstChild(); MOZ_ASSERT(aFrame->GetType() == nsGkAtoms::svgOuterSVGAnonChildFrame, "Where is the nsSVGOuterSVGFrame's anon child??"); } @@ -327,7 +327,7 @@ DoApplyRenderingChangeToTree(nsIFrame* aFrame, if (aChange & nsChangeHint_ChildrenOnlyTransform) { needInvalidatingPaint = true; nsIFrame* childFrame = - GetFrameForChildrenOnlyTransformHint(aFrame)->GetFirstPrincipalChild(); + GetFrameForChildrenOnlyTransformHint(aFrame)->PrincipalChildList().FirstChild(); for ( ; childFrame; childFrame = childFrame->GetNextSibling()) { ActiveLayerTracker::NotifyRestyle(childFrame, eCSSProperty_transform); } @@ -902,7 +902,7 @@ RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList) if (hint & nsChangeHint_ChildrenOnlyTransform) { // The overflow areas of the child frames need to be updated: nsIFrame* hintFrame = GetFrameForChildrenOnlyTransformHint(frame); - nsIFrame* childFrame = hintFrame->GetFirstPrincipalChild(); + nsIFrame* childFrame = hintFrame->PrincipalChildList().FirstChild(); NS_ASSERTION(!nsLayoutUtils::GetNextContinuationOrIBSplitSibling(frame), "SVG frames should not have continuations " "or ib-split siblings"); diff --git a/layout/base/nsBidiPresUtils.cpp b/layout/base/nsBidiPresUtils.cpp index 789844db214..2d423aecbcb 100644 --- a/layout/base/nsBidiPresUtils.cpp +++ b/layout/base/nsBidiPresUtils.cpp @@ -464,7 +464,7 @@ IsBidiSplittable(nsIFrame* aFrame) static bool IsBidiLeaf(nsIFrame* aFrame) { - nsIFrame* kid = aFrame->GetFirstPrincipalChild(); + nsIFrame* kid = aFrame->PrincipalChildList().FirstChild(); return !kid || !aFrame->IsFrameOfType(nsIFrame::eBidiInlineContainer); } @@ -670,7 +670,7 @@ nsBidiPresUtils::Resolve(nsBlockFrame* aBlockFrame) block->RemoveStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION); nsBlockInFlowLineIterator lineIter(block, block->begin_lines()); bpd.ResetForNewBlock(); - TraverseFrames(aBlockFrame, &lineIter, block->GetFirstPrincipalChild(), &bpd); + TraverseFrames(aBlockFrame, &lineIter, block->PrincipalChildList().FirstChild(), &bpd); // XXX what about overflow lines? } @@ -1184,7 +1184,7 @@ nsBidiPresUtils::TraverseFrames(nsBlockFrame* aBlockFrame, } } else { // For a non-leaf frame, recurse into TraverseFrames - nsIFrame* kid = frame->GetFirstPrincipalChild(); + nsIFrame* kid = frame->PrincipalChildList().FirstChild(); MOZ_ASSERT(!frame->GetChildList(nsIFrame::kOverflowList).FirstChild(), "should have drained the overflow list above"); if (kid) { @@ -1263,7 +1263,7 @@ nsBidiPresUtils::ReorderFrames(nsIFrame* aFirstFrameOnLine, // as the container size. containerSize = aFirstFrameOnLine->GetSize(); - aFirstFrameOnLine = aFirstFrameOnLine->GetFirstPrincipalChild(); + aFirstFrameOnLine = aFirstFrameOnLine->PrincipalChildList().FirstChild(); if (!aFirstFrameOnLine) { return 0; } @@ -1281,7 +1281,7 @@ nsBidiPresUtils::GetFirstLeaf(nsIFrame* aFrame) { nsIFrame* firstLeaf = aFrame; while (!IsBidiLeaf(firstLeaf)) { - nsIFrame* firstChild = firstLeaf->GetFirstPrincipalChild(); + nsIFrame* firstChild = firstLeaf->PrincipalChildList().FirstChild(); nsIFrame* realFrame = nsPlaceholderFrame::GetRealFrameFor(firstChild); firstLeaf = (realFrame->GetType() == nsGkAtoms::letterFrame) ? realFrame : firstChild; @@ -1307,7 +1307,7 @@ nsBidiPresUtils::GetFrameBaseLevel(nsIFrame* aFrame) { nsIFrame* firstLeaf = aFrame; while (!IsBidiLeaf(firstLeaf)) { - firstLeaf = firstLeaf->GetFirstPrincipalChild(); + firstLeaf = firstLeaf->PrincipalChildList().FirstChild(); } return NS_GET_BASE_LEVEL(firstLeaf); } @@ -1650,10 +1650,7 @@ nsBidiPresUtils::InitContinuationStates(nsIFrame* aFrame, if (!IsBidiLeaf(aFrame) || RubyUtils::IsRubyBox(aFrame->GetType())) { // Continue for child frames - nsIFrame* frame; - for (frame = aFrame->GetFirstPrincipalChild(); - frame; - frame = frame->GetNextSibling()) { + for (nsIFrame* frame : aFrame->PrincipalChildList()) { InitContinuationStates(frame, aContinuationStates); } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index d678d6bda97..16bbba972dd 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -361,7 +361,7 @@ static inline nsContainerFrame* GetFieldSetBlockFrame(nsIFrame* aFieldsetFrame) { // Depends on the fieldset child frame order - see ConstructFieldSetFrame() below. - nsIFrame* firstChild = aFieldsetFrame->GetFirstPrincipalChild(); + nsIFrame* firstChild = aFieldsetFrame->PrincipalChildList().FirstChild(); nsIFrame* inner = firstChild && firstChild->GetNextSibling() ? firstChild->GetNextSibling() : firstChild; return inner ? inner->GetContentInsertionFrame() : nullptr; } @@ -492,7 +492,7 @@ GetLastIBSplitSibling(nsIFrame* aFrame, bool aReturnEmptyTrailingInline) for (nsIFrame *frame = aFrame, *next; ; frame = next) { next = GetIBSplitSibling(frame); if (!next || - (!aReturnEmptyTrailingInline && !next->GetFirstPrincipalChild() && + (!aReturnEmptyTrailingInline && !next->PrincipalChildList().FirstChild() && !GetIBSplitSibling(next))) { NS_ASSERTION(!next || !frame->IsInlineOutside(), "Should have a block here!"); @@ -1867,9 +1867,9 @@ IsTablePseudo(nsIFrame* aFrame) aFrame->GetParent()->StyleContext()->GetPseudo() == nsCSSAnonBoxes::tableCell) || (pseudoType == nsCSSAnonBoxes::tableOuter && - (aFrame->GetFirstPrincipalChild()->StyleContext()->GetPseudo() == + (aFrame->PrincipalChildList().FirstChild()->StyleContext()->GetPseudo() == nsCSSAnonBoxes::table || - aFrame->GetFirstPrincipalChild()->StyleContext()->GetPseudo() == + aFrame->PrincipalChildList().FirstChild()->StyleContext()->GetPseudo() == nsCSSAnonBoxes::inlineTable))); } @@ -2886,7 +2886,7 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, // containing block for fixed elements which are repeated on every page. nsIFrame* prevPageContentFrame = nullptr; if (aPrevPageFrame) { - prevPageContentFrame = aPrevPageFrame->GetFirstPrincipalChild(); + prevPageContentFrame = aPrevPageFrame->PrincipalChildList().FirstChild(); NS_ASSERTION(prevPageContentFrame, "missing page content frame"); } pageContentFrame->Init(nullptr, pageFrame, prevPageContentFrame); @@ -2903,7 +2903,7 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell, nsIFrame* prevCanvasFrame = nullptr; if (prevPageContentFrame) { - prevCanvasFrame = prevPageContentFrame->GetFirstPrincipalChild(); + prevCanvasFrame = prevPageContentFrame->PrincipalChildList().FirstChild(); NS_ASSERTION(prevCanvasFrame, "missing canvas frame"); } aCanvasFrame->Init(nullptr, pageContentFrame, prevCanvasFrame); @@ -6182,7 +6182,7 @@ FindAppendPrevSibling(nsIFrame* aParentFrame, nsIFrame* aAfterFrame) if (aAfterFrame) { NS_ASSERTION(aAfterFrame->GetParent() == aParentFrame, "Wrong parent"); NS_ASSERTION(aAfterFrame->GetPrevSibling() || - aParentFrame->GetFirstPrincipalChild() == aAfterFrame, + aParentFrame->PrincipalChildList().FirstChild() == aAfterFrame, ":after frame must be on the principal child list here"); return aAfterFrame->GetPrevSibling(); } @@ -6203,7 +6203,7 @@ GetInsertNextSibling(nsIFrame* aParentFrame, nsIFrame* aPrevSibling) return aPrevSibling->GetNextSibling(); } - return aParentFrame->GetFirstPrincipalChild(); + return aParentFrame->PrincipalChildList().FirstChild(); } /** @@ -6220,7 +6220,7 @@ nsCSSFrameConstructor::AppendFramesToParent(nsFrameConstructorState& aStat { NS_PRECONDITION(!IsFramePartOfIBSplit(aParentFrame) || !GetIBSplitSibling(aParentFrame) || - !GetIBSplitSibling(aParentFrame)->GetFirstPrincipalChild(), + !GetIBSplitSibling(aParentFrame)->PrincipalChildList().FirstChild(), "aParentFrame has a ib-split sibling with kids?"); NS_PRECONDITION(!aPrevSibling || aPrevSibling->GetParent() == aParentFrame, "Parent and prevsibling don't match"); @@ -6229,7 +6229,7 @@ nsCSSFrameConstructor::AppendFramesToParent(nsFrameConstructorState& aStat NS_ASSERTION(nextSibling || !aParentFrame->GetNextContinuation() || - !aParentFrame->GetNextContinuation()->GetFirstPrincipalChild() || + !aParentFrame->GetNextContinuation()->PrincipalChildList().FirstChild() || aIsRecursiveCall, "aParentFrame has later continuations with kids?"); NS_ASSERTION(nextSibling || @@ -7720,7 +7720,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer, if (!prevSibling) { // We're inserting the new frames as the first child. See if the // parent has a :before pseudo-element - nsIFrame* firstChild = insertion.mParentFrame->GetFirstPrincipalChild(); + nsIFrame* firstChild = insertion.mParentFrame->PrincipalChildList().FirstChild(); if (firstChild && nsLayoutUtils::IsGeneratedContentFor(container, firstChild, @@ -8064,7 +8064,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer, if (!aContainer) { nsIFrame* viewport = GetRootFrame(); if (viewport) { - nsIFrame* firstChild = viewport->GetFirstPrincipalChild(); + nsIFrame* firstChild = viewport->PrincipalChildList().FirstChild(); if (firstChild && firstChild->GetContent() == aChild) { isRoot = true; childFrame = firstChild; @@ -8146,7 +8146,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer, if (grandparentFrame && grandparentFrame->IsBoxFrame() && (grandparentFrame->GetStateBits() & NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK) && // check if this frame is the only one needing wrapping - aChild == AnyKidsNeedBlockParent(parentFrame->GetFirstPrincipalChild()) && + aChild == AnyKidsNeedBlockParent(parentFrame->PrincipalChildList().FirstChild()) && !AnyKidsNeedBlockParent(childFrame->GetNextSibling())) { *aDidReconstruct = true; LAYOUT_PHASE_TEMP_EXIT(); @@ -8538,7 +8538,7 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresSh // replicate the caption nsFrameItems newChildFrames; - nsIFrame* childFrame = aFrame->GetFirstPrincipalChild(); + nsIFrame* childFrame = aFrame->PrincipalChildList().FirstChild(); if (childFrame) { nsIFrame* continuingTableFrame = CreateContinuingFrame(aPresContext, childFrame, newFrame); @@ -8566,8 +8566,7 @@ nsCSSFrameConstructor::CreateContinuingTableFrame(nsIPresShell* aPresShell, // Replicate any header/footer frames nsFrameItems childFrames; - nsIFrame* childFrame = aFrame->GetFirstPrincipalChild(); - for ( ; childFrame; childFrame = childFrame->GetNextSibling()) { + for (nsIFrame* childFrame : aFrame->PrincipalChildList()) { // See if it's a header/footer, possibly wrapped in a scroll frame. nsTableRowGroupFrame* rowGroupFrame = static_cast(childFrame); @@ -8689,7 +8688,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext, // Create a continuing frame for each table cell frame nsFrameItems newChildList; - nsIFrame* cellFrame = aFrame->GetFirstPrincipalChild(); + nsIFrame* cellFrame = aFrame->PrincipalChildList().FirstChild(); while (cellFrame) { // See if it's a table cell frame if (IS_TABLE_CELL(cellFrame->GetType())) { @@ -8718,7 +8717,7 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext, } // Create a continuing area frame - nsIFrame* blockFrame = aFrame->GetFirstPrincipalChild(); + nsIFrame* blockFrame = aFrame->PrincipalChildList().FirstChild(); nsIFrame* continuingBlockFrame = CreateContinuingFrame(aPresContext, blockFrame, static_cast(cellFrame)); @@ -8831,8 +8830,8 @@ nsCSSFrameConstructor::ReplicateFixedFrames(nsPageContentFrame* aParentFrame) return NS_OK; } nsContainerFrame* canvasFrame = - do_QueryFrame(aParentFrame->GetFirstPrincipalChild()); - nsIFrame* prevCanvasFrame = prevPageContentFrame->GetFirstPrincipalChild(); + do_QueryFrame(aParentFrame->PrincipalChildList().FirstChild()); + nsIFrame* prevCanvasFrame = prevPageContentFrame->PrincipalChildList().FirstChild(); if (!canvasFrame || !prevCanvasFrame) { // document's root element frame missing return NS_ERROR_UNEXPECTED; @@ -8887,7 +8886,7 @@ nsCSSFrameConstructor::ReplicateFixedFrames(nsPageContentFrame* aParentFrame) // Add the placeholders to our primary child list. // XXXbz this is a little screwed up, since the fixed frames will have // broken auto-positioning. Oh, well. - NS_ASSERTION(!canvasFrame->GetFirstPrincipalChild(), + NS_ASSERTION(!canvasFrame->PrincipalChildList().FirstChild(), "leaking frames; doc root continuation must be empty"); canvasFrame->SetInitialChildList(kPrincipalList, fixedPlaceholders); return NS_OK; @@ -9034,7 +9033,7 @@ IsWhitespaceFrame(nsIFrame* aFrame) static nsIFrame* FindFirstNonWhitespaceChild(nsIFrame* aParentFrame) { - nsIFrame* f = aParentFrame->GetFirstPrincipalChild(); + nsIFrame* f = aParentFrame->PrincipalChildList().FirstChild(); while (f && IsWhitespaceFrame(f)) { f = f->GetNextSibling(); } @@ -9253,7 +9252,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame, // If inFlowFrame is not the only in-flow child of |parent|, then removing // it will change nothing about the {ib} split. - if (inFlowFrame != parent->GetFirstPrincipalChild() || + if (inFlowFrame != parent->PrincipalChildList().FirstChild() || inFlowFrame->LastContinuation()->GetNextSibling()) { return false; } @@ -10659,7 +10658,7 @@ nsCSSFrameConstructor::InsertFirstLineFrames( if (!aPrevSibling) { // Insertion will become the first frame. Two cases: we either // already have a first-line frame or we don't. - nsIFrame* firstBlockKid = aBlockFrame->GetFirstPrincipalChild(); + nsIFrame* firstBlockKid = aBlockFrame->PrincipalChildList().FirstChild(); if (firstBlockKid->GetType() == nsGkAtoms::lineFrame) { // We already have a first-line frame nsIFrame* lineFrame = firstBlockKid; @@ -10759,7 +10758,7 @@ nsCSSFrameConstructor::InsertFirstLineFrames( if (!nextLineFrame) { break; } - nsIFrame* kids = nextLineFrame->GetFirstPrincipalChild(); + nsIFrame* kids = nextLineFrame->PrincipalChildList().FirstChild(); } } else { @@ -11063,7 +11062,7 @@ nsCSSFrameConstructor::WrapFramesInFirstLetterFrame( } } else if (IsInlineFrame(frame) && frameType != nsGkAtoms::brFrame) { - nsIFrame* kids = frame->GetFirstPrincipalChild(); + nsIFrame* kids = frame->PrincipalChildList().FirstChild(); WrapFramesInFirstLetterFrame(aBlockFrame, aBlockContinuation, static_cast(frame), kids, aModifiedParent, aTextFrame, @@ -11118,7 +11117,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames( // Take the text frame away from the letter frame (so it isn't // destroyed when we destroy the letter frame). - nsIFrame* textFrame = floatFrame->GetFirstPrincipalChild(); + nsIFrame* textFrame = floatFrame->PrincipalChildList().FirstChild(); if (!textFrame) { return NS_OK; } @@ -11197,12 +11196,12 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsIPresShell* aPresShell, bool* aStopLooking) { nsIFrame* prevSibling = nullptr; - nsIFrame* kid = aFrame->GetFirstPrincipalChild(); + nsIFrame* kid = aFrame->PrincipalChildList().FirstChild(); while (kid) { if (nsGkAtoms::letterFrame == kid->GetType()) { // Bingo. Found it. First steal away the text frame. - nsIFrame* textFrame = kid->GetFirstPrincipalChild(); + nsIFrame* textFrame = kid->PrincipalChildList().FirstChild(); if (!textFrame) { break; } @@ -11309,7 +11308,7 @@ nsCSSFrameConstructor::RecoverLetterFrames(nsContainerFrame* aBlockFrame) // XXX shouldn't this bit be set already (bug 408493), assert instead? continuation->AddStateBits(NS_BLOCK_HAS_FIRST_LETTER_STYLE); WrapFramesInFirstLetterFrame(aBlockFrame, continuation, continuation, - continuation->GetFirstPrincipalChild(), + continuation->PrincipalChildList().FirstChild(), &parentFrame, &textFrame, &prevFrame, letterFrames, &stopLooking); if (stopLooking) { @@ -12025,7 +12024,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsFrameConstructorState& aState, // Try to find one after all nsIFrame* parentNextCont = aFrame->GetNextContinuation(); while (parentNextCont) { - nextSibling = parentNextCont->GetFirstPrincipalChild(); + nextSibling = parentNextCont->PrincipalChildList().FirstChild(); if (nextSibling) { break; } diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index eb6d1726a16..027c0175e9f 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -3115,7 +3115,7 @@ nsCSSRendering::ComputeImageLayerPositioningArea(nsPresContext* aPresContext, } if (MOZ_UNLIKELY(frameType == nsGkAtoms::canvasFrame)) { - geometryFrame = aForFrame->GetFirstPrincipalChild(); + geometryFrame = aForFrame->PrincipalChildList().FirstChild(); // geometryFrame might be null if this canvas is a page created // as an overflow container (e.g. the in-flow content has already // finished and this page only displays the continuations of diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index 38a0026b1dd..3810ffcb5bb 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -62,7 +62,7 @@ CheckForTrailingTextFrameRecursive(nsIFrame* aFrame, nsIFrame* aStopAtFrame) if (!aFrame->IsFrameOfType(nsIFrame::eLineParticipant)) return nullptr; - for (nsIFrame* f = aFrame->GetFirstPrincipalChild(); f; f = f->GetNextSibling()) + for (nsIFrame* f : aFrame->PrincipalChildList()) { nsIFrame* r = CheckForTrailingTextFrameRecursive(f, aStopAtFrame); if (r) diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 030f49b2676..f185fdb6e7d 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -3795,8 +3795,7 @@ nsDocumentViewer::PrintPreviewNavigate(int16_t aType, int32_t aPageNum) // Now, locate the current page we are on and // and the page of the page number - nsIFrame* pageFrame = seqFrame->GetFirstPrincipalChild(); - while (pageFrame != nullptr) { + for (nsIFrame* pageFrame : seqFrame->PrincipalChildList()) { nsRect pageRect = pageFrame->GetRect(); if (pageRect.Contains(pageRect.x, pt.y)) { currentPage = pageFrame; @@ -3806,7 +3805,6 @@ nsDocumentViewer::PrintPreviewNavigate(int16_t aType, int32_t aPageNum) break; } pageNum++; - pageFrame = pageFrame->GetNextSibling(); } if (aType == nsIWebBrowserPrint::PRINTPREVIEW_PREV_PAGE) { diff --git a/layout/base/nsFrameTraversal.cpp b/layout/base/nsFrameTraversal.cpp index 51a30fdadd5..6ab455395eb 100644 --- a/layout/base/nsFrameTraversal.cpp +++ b/layout/base/nsFrameTraversal.cpp @@ -466,7 +466,7 @@ nsFrameIterator::GetPrevSibling(nsIFrame* aFrame) nsIFrame* nsFrameIterator::GetFirstChildInner(nsIFrame* aFrame) { - return aFrame->GetFirstPrincipalChild(); + return aFrame->PrincipalChildList().FirstChild(); } nsIFrame* diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 1a1bbd5bc16..8bd5278839c 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1254,7 +1254,7 @@ nsLayoutUtils::LastContinuationWithChild(nsContainerFrame* aFrame) { NS_PRECONDITION(aFrame, "NULL frame pointer"); nsIFrame* f = aFrame->LastContinuation(); - while (!f->GetFirstPrincipalChild() && f->GetPrevContinuation()) { + while (!f->PrincipalChildList().FirstChild() && f->GetPrevContinuation()) { f = f->GetPrevContinuation(); } return static_cast(f); @@ -1382,7 +1382,7 @@ nsLayoutUtils::GetBeforeFrameForContent(nsIFrame* aFrame, // If the first child frame is a pseudo-frame, then try that. // Note that the frame we create for the generated content is also a // pseudo-frame and so don't drill down in that case. - nsIFrame* childFrame = genConParentFrame->GetFirstPrincipalChild(); + nsIFrame* childFrame = genConParentFrame->PrincipalChildList().FirstChild(); if (childFrame && childFrame->IsPseudoFrame(aContent) && !childFrame->IsGeneratedContentFrame()) { @@ -1466,7 +1466,7 @@ nsIFrame* nsLayoutUtils::GetStyleFrame(nsIFrame* aFrame) { if (aFrame->GetType() == nsGkAtoms::tableOuterFrame) { - nsIFrame* inner = aFrame->GetFirstPrincipalChild(); + nsIFrame* inner = aFrame->PrincipalChildList().FirstChild(); NS_ASSERTION(inner, "Outer table must have an inner"); return inner; } @@ -3597,7 +3597,7 @@ AddBoxesForFrame(nsIFrame* aFrame, nsIAtom* pseudoType = aFrame->StyleContext()->GetPseudo(); if (pseudoType == nsCSSAnonBoxes::tableOuter) { - AddBoxesForFrame(aFrame->GetFirstPrincipalChild(), aCallback); + AddBoxesForFrame(aFrame->PrincipalChildList().FirstChild(), aCallback); nsIFrame* kid = aFrame->GetChildList(nsIFrame::kCaptionList).FirstChild(); if (kid) { AddBoxesForFrame(kid, aCallback); @@ -3630,7 +3630,7 @@ nsLayoutUtils::GetFirstNonAnonymousFrame(nsIFrame* aFrame) nsIAtom* pseudoType = aFrame->StyleContext()->GetPseudo(); if (pseudoType == nsCSSAnonBoxes::tableOuter) { - nsIFrame* f = GetFirstNonAnonymousFrame(aFrame->GetFirstPrincipalChild()); + nsIFrame* f = GetFirstNonAnonymousFrame(aFrame->PrincipalChildList().FirstChild()); if (f) { return f; } @@ -5859,7 +5859,7 @@ nsLayoutUtils::GetFirstLinePosition(WritingMode aWM, if (fType == nsGkAtoms::fieldSetFrame) { LinePosition kidPosition; - nsIFrame* kid = aFrame->GetFirstPrincipalChild(); + nsIFrame* kid = aFrame->PrincipalChildList().FirstChild(); // kid might be a legend frame here, but that's ok. if (GetFirstLinePosition(aWM, kid, &kidPosition)) { *aResult = kidPosition + @@ -6758,7 +6758,7 @@ nsLayoutUtils::GetFrameTransparency(nsIFrame* aBackgroundFrame, // doing otherwise breaks window display effects on some platforms, // specifically Vista. (bug 450322) if (aBackgroundFrame->GetType() == nsGkAtoms::viewportFrame && - !aBackgroundFrame->GetFirstPrincipalChild()) { + !aBackgroundFrame->PrincipalChildList().FirstChild()) { return eTransparencyOpaque; } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index e46b096740b..dd4d225f4d9 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -2276,7 +2276,7 @@ nsIPresShell::GetRootScrollFrame() const // Ensure root frame is a viewport frame if (!rootFrame || nsGkAtoms::viewportFrame != rootFrame->GetType()) return nullptr; - nsIFrame* theFrame = rootFrame->GetFirstPrincipalChild(); + nsIFrame* theFrame = rootFrame->PrincipalChildList().FirstChild(); if (!theFrame || nsGkAtoms::scrollFrame != theFrame->GetType()) return nullptr; return theFrame; @@ -9591,13 +9591,11 @@ FindTopFrame(nsIFrame* aRoot) } // Try one of the children - nsIFrame* kid = aRoot->GetFirstPrincipalChild(); - while (nullptr != kid) { + for (nsIFrame* kid : aRoot->PrincipalChildList()) { nsIFrame* result = FindTopFrame(kid); if (nullptr != result) { return result; } - kid = kid->GetNextSibling(); } } return nullptr; @@ -10177,10 +10175,8 @@ static void RecurseIndiTotals(nsPresContext* aPresContext, free(name); } - nsIFrame* child = aParentFrame->GetFirstPrincipalChild(); - while (child) { + for (nsIFrame* child : aParentFrame->PrincipalChildList()) { RecurseIndiTotals(aPresContext, aHT, child, aLevel+1); - child = child->GetNextSibling(); } } diff --git a/layout/forms/nsHTMLButtonControlFrame.h b/layout/forms/nsHTMLButtonControlFrame.h index 61bbe5e02eb..e5784202e08 100644 --- a/layout/forms/nsHTMLButtonControlFrame.h +++ b/layout/forms/nsHTMLButtonControlFrame.h @@ -81,7 +81,7 @@ public: // Inserted child content gets its frames parented by our child block virtual nsContainerFrame* GetContentInsertionFrame() override { - return GetFirstPrincipalChild()->GetContentInsertionFrame(); + return PrincipalChildList().FirstChild()->GetContentInsertionFrame(); } virtual bool IsFrameOfType(uint32_t aFlags) const override diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index fafa31c535c..a18f1889326 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -265,8 +265,7 @@ static nscoord GetMaxOptionBSize(nsIFrame* aContainer, WritingMode aWM) { nscoord result = 0; - for (nsIFrame* option = aContainer->GetFirstPrincipalChild(); - option; option = option->GetNextSibling()) { + for (nsIFrame* option : aContainer->PrincipalChildList()) { nscoord optionBSize; if (nsCOMPtr (do_QueryInterface(option->GetContent()))) { diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index fdbf641bcd3..36e8e66e7a9 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -210,7 +210,7 @@ nsTextControlFrame::CalcIntrinsicSize(nsRenderingContext* aRenderingContext, // Add in the size of the scrollbars for textarea if (IsTextArea()) { - nsIFrame* first = GetFirstPrincipalChild(); + nsIFrame* first = PrincipalChildList().FirstChild(); nsIScrollableFrame *scrollableFrame = do_QueryFrame(first); NS_ASSERTION(scrollableFrame, "Child must be scrollable"); @@ -1231,7 +1231,7 @@ nsTextControlFrame::SetInitialChildList(ChildListID aListID, // Mark the scroll frame as being a reflow root. This will allow // incremental reflows to be initiated at the scroll frame, rather // than descending from the root frame of the frame hierarchy. - if (nsIFrame* first = GetFirstPrincipalChild()) { + if (nsIFrame* first = PrincipalChildList().FirstChild()) { first->AddStateBits(NS_FRAME_REFLOW_ROOT); nsCOMPtr txtCtrl = do_QueryInterface(GetContent()); diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index 044fe14d6f2..0157d3b4a78 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -40,7 +40,7 @@ public: virtual void DestroyFrom(nsIFrame* aDestructRoot) override; virtual nsIScrollableFrame* GetScrollTargetFrame() override { - return do_QueryFrame(GetFirstPrincipalChild()); + return do_QueryFrame(PrincipalChildList().FirstChild()); } virtual nscoord GetMinISize(nsRenderingContext* aRenderingContext) override; diff --git a/layout/generic/RubyUtils.cpp b/layout/generic/RubyUtils.cpp index 3a9cdbc1ad8..f340663bc21 100644 --- a/layout/generic/RubyUtils.cpp +++ b/layout/generic/RubyUtils.cpp @@ -78,7 +78,7 @@ RubyColumn::Iterator::SkipUntilExistingFrame() RubySegmentEnumerator::RubySegmentEnumerator(nsRubyFrame* aRubyFrame) { - nsIFrame* frame = aRubyFrame->GetFirstPrincipalChild(); + nsIFrame* frame = aRubyFrame->PrincipalChildList().FirstChild(); MOZ_ASSERT(!frame || frame->GetType() == nsGkAtoms::rubyBaseContainerFrame); mBaseContainer = static_cast(frame); @@ -103,7 +103,7 @@ RubyColumnEnumerator::RubyColumnEnumerator( const uint32_t rtcCount = aTextContainers.Length(); mFrames.SetCapacity(rtcCount + 1); - nsIFrame* rbFrame = aBaseContainer->GetFirstPrincipalChild(); + nsIFrame* rbFrame = aBaseContainer->PrincipalChildList().FirstChild(); MOZ_ASSERT(!rbFrame || rbFrame->GetType() == nsGkAtoms::rubyBaseFrame); mFrames.AppendElement(static_cast(rbFrame)); for (uint32_t i = 0; i < rtcCount; i++) { @@ -111,7 +111,7 @@ RubyColumnEnumerator::RubyColumnEnumerator( // If the container is for span, leave a nullptr here. // Spans do not take part in pairing. nsIFrame* rtFrame = !container->IsSpanContainer() ? - container->GetFirstPrincipalChild() : nullptr; + container->PrincipalChildList().FirstChild() : nullptr; MOZ_ASSERT(!rtFrame || rtFrame->GetType() == nsGkAtoms::rubyTextFrame); mFrames.AppendElement(static_cast(rtFrame)); } diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index afcfa915645..62e64a93456 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -380,13 +380,11 @@ TextOverflow::ExamineFrameSubtree(nsIFrame* aFrame, return; } - nsIFrame* child = aFrame->GetFirstPrincipalChild(); - while (child) { + for (nsIFrame* child : aFrame->PrincipalChildList()) { ExamineFrameSubtree(child, aContentArea, aInsideMarkersArea, aFramesToHide, aAlignmentEdges, aFoundVisibleTextOrAtomic, aClippedMarkerEdges); - child = child->GetNextSibling(); } } diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index bfb2a7fcbd0..02626e1d963 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -2368,7 +2368,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState) aState.mPresContext->HasPendingInterrupt()) { // Need to make sure to pull overflows from any prev-in-flows for (nsIFrame* inlineKid = line->mFirstChild; inlineKid; - inlineKid = inlineKid->GetFirstPrincipalChild()) { + inlineKid = inlineKid->PrincipalChildList().FirstChild()) { inlineKid->PullOverflowsFromPrevInFlow(); } } @@ -7200,7 +7200,7 @@ nsBlockFrame::DoCollectFloats(nsIFrame* aFrame, nsFrameList& aList, // XXXmats nsInlineFrame's lazy reparenting depends on NOT doing that. } - DoCollectFloats(aFrame->GetFirstPrincipalChild(), aList, true); + DoCollectFloats(aFrame->PrincipalChildList().FirstChild(), aList, true); DoCollectFloats(aFrame->GetChildList(kOverflowList).FirstChild(), aList, true); } if (!aCollectSiblings) diff --git a/layout/generic/nsBlockReflowContext.cpp b/layout/generic/nsBlockReflowContext.cpp index 44aa2f02d16..6a046f26873 100644 --- a/layout/generic/nsBlockReflowContext.cpp +++ b/layout/generic/nsBlockReflowContext.cpp @@ -41,7 +41,7 @@ static nsIFrame* DescendIntoBlockLevelFrame(nsIFrame* aFrame) nsIAtom* type = aFrame->GetType(); if (type == nsGkAtoms::columnSetFrame) { static_cast(aFrame)->DrainOverflowColumns(); - nsIFrame* child = aFrame->GetFirstPrincipalChild(); + nsIFrame* child = aFrame->PrincipalChildList().FirstChild(); if (child) { return DescendIntoBlockLevelFrame(child); } diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp index cba64823e16..bba5f77e735 100644 --- a/layout/generic/nsCanvasFrame.cpp +++ b/layout/generic/nsCanvasFrame.cpp @@ -434,8 +434,7 @@ nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, } } - nsIFrame* kid; - for (kid = GetFirstPrincipalChild(); kid; kid = kid->GetNextSibling()) { + for (nsIFrame* kid : PrincipalChildList()) { // Put our child into its own pseudo-stack. BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists); } diff --git a/layout/generic/nsColumnSetFrame.h b/layout/generic/nsColumnSetFrame.h index 49860624d54..fefb298de56 100644 --- a/layout/generic/nsColumnSetFrame.h +++ b/layout/generic/nsColumnSetFrame.h @@ -45,7 +45,7 @@ public: virtual nscoord GetAvailableContentBSize(const nsHTMLReflowState& aReflowState); virtual nsContainerFrame* GetContentInsertionFrame() override { - nsIFrame* frame = GetFirstPrincipalChild(); + nsIFrame* frame = PrincipalChildList().FirstChild(); // if no children return nullptr if (!frame) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index c956a895671..af5d5b9ee1f 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -917,7 +917,7 @@ GetFirstNonAnonBoxDescendant(nsIFrame* aFrame) } // USUAL CASE: Descend to the first child in principal list. - aFrame = aFrame->GetFirstPrincipalChild(); + aFrame = aFrame->PrincipalChildList().FirstChild(); } return aFrame; } @@ -2023,7 +2023,7 @@ nsFlexContainerFrame::SanityCheckAnonymousFlexItems() const "two anon flex items in a row (shouldn't happen, unless our " "children have been reordered with the 'order' property)"); - nsIFrame* firstWrappedChild = child->GetFirstPrincipalChild(); + nsIFrame* firstWrappedChild = child->PrincipalChildList().FirstChild(); MOZ_ASSERT(firstWrappedChild, "anonymous flex item is empty (shouldn't happen)"); prevChildWasAnonFlexItem = true; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index f64db90b82e..7f3bed7cf05 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -789,7 +789,7 @@ nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) if (IsSVGText()) { SVGTextFrame* svgTextFrame = static_cast( nsLayoutUtils::GetClosestFrameOfType(this, nsGkAtoms::svgTextFrame)); - nsIFrame* anonBlock = svgTextFrame->GetFirstPrincipalChild(); + nsIFrame* anonBlock = svgTextFrame->PrincipalChildList().FirstChild(); // Just as in SVGTextFrame::DidSetStyleContext, we need to ensure that // any non-display SVGTextFrames get reflowed when a child text frame // gets new style. @@ -3675,7 +3675,7 @@ static FrameTarget DrillDownToSelectionFrame(nsIFrame* aFrame, bool aEndFrame, uint32_t aFlags) { if (SelectionDescendToKids(aFrame)) { nsIFrame* result = nullptr; - nsIFrame *frame = aFrame->GetFirstPrincipalChild(); + nsIFrame *frame = aFrame->PrincipalChildList().FirstChild(); if (!aEndFrame) { while (frame && (!SelfIsSelectable(frame, aFlags) || frame->IsEmpty())) @@ -3858,7 +3858,7 @@ static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame, nsPoint aPoint, return target; } - nsIFrame *kid = aFrame->GetFirstPrincipalChild(); + nsIFrame *kid = aFrame->PrincipalChildList().FirstChild(); if (kid) { // Go through all the child frames to find the closest one @@ -6637,7 +6637,7 @@ FindBlockFrameOrBR(nsIFrame* aFrame, nsDirection aDirection) child = child->GetPrevSibling(); } } else { // eDirNext - nsIFrame* child = aFrame->GetFirstPrincipalChild(); + nsIFrame* child = aFrame->PrincipalChildList().FirstChild(); while(child && !result.mContent) { result = FindBlockFrameOrBR(child, aDirection); child = child->GetNextSibling(); @@ -6950,7 +6950,7 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct* aPos) if (aPos->mResultFrame->GetType() == nsGkAtoms::tableOuterFrame || aPos->mResultFrame->GetType() == nsGkAtoms::tableCellFrame) { - nsIFrame *frame = aPos->mResultFrame->GetFirstPrincipalChild(); + nsIFrame *frame = aPos->mResultFrame->PrincipalChildList().FirstChild(); //got the table frame now while(frame) //ok time to drill down to find iterator { @@ -6963,7 +6963,7 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct* aPos) break; //while(frame) } result = NS_ERROR_FAILURE; - frame = frame->GetFirstPrincipalChild(); + frame = frame->PrincipalChildList().FirstChild(); } } @@ -7627,7 +7627,7 @@ ComputeAndIncludeOutlineArea(nsIFrame* aFrame, nsOverflowAreas& aOverflowAreas, pseudoType != nsCSSAnonBoxes::mozAnonymousPositionedBlock) break; // If we're done, we really want it and all its later siblings. - frameForArea = frameForArea->GetFirstPrincipalChild(); + frameForArea = frameForArea->PrincipalChildList().FirstChild(); NS_ASSERTION(frameForArea, "anonymous block with no children?"); } while (frameForArea); @@ -8065,7 +8065,7 @@ GetCorrectedParent(const nsIFrame* aFrame) // For a table caption we want the _inner_ table frame (unless it's anonymous) // as the style parent. if (aFrame->IsTableCaption()) { - nsIFrame* innerTable = parent->GetFirstPrincipalChild(); + nsIFrame* innerTable = parent->PrincipalChildList().FirstChild(); if (!innerTable->StyleContext()->GetPseudo()) { return innerTable; } @@ -8076,7 +8076,7 @@ GetCorrectedParent(const nsIFrame* aFrame) // know its parent. So get the pseudo of the inner in that case. nsIAtom* pseudo = aFrame->StyleContext()->GetPseudo(); if (pseudo == nsCSSAnonBoxes::tableOuter) { - pseudo = aFrame->GetFirstPrincipalChild()->StyleContext()->GetPseudo(); + pseudo = aFrame->PrincipalChildList().FirstChild()->StyleContext()->GetPseudo(); } return nsFrame::CorrectStyleParentFrame(parent, pseudo); } @@ -8214,7 +8214,7 @@ nsFrame::GetLastLeaf(nsPresContext* aPresContext, nsIFrame **aFrame) nsIFrame *child = *aFrame; //if we are a block frame then go for the last line of 'this' while (1){ - child = child->GetFirstPrincipalChild(); + child = child->PrincipalChildList().FirstChild(); if (!child) return;//nothing to do nsIFrame* siblingFrame; @@ -8236,7 +8236,7 @@ nsFrame::GetFirstLeaf(nsPresContext* aPresContext, nsIFrame **aFrame) return; nsIFrame *child = *aFrame; while (1){ - child = child->GetFirstPrincipalChild(); + child = child->PrincipalChildList().FirstChild(); if (!child) return;//nothing to do *aFrame = child; diff --git a/layout/generic/nsFrameList.h b/layout/generic/nsFrameList.h index 5ede791f341..98dc009255c 100644 --- a/layout/generic/nsFrameList.h +++ b/layout/generic/nsFrameList.h @@ -245,6 +245,11 @@ public: bool ContainsFrame(const nsIFrame* aFrame) const; + /** + * Get the number of frames in this list. Note that currently the + * implementation has O(n) time complexity. Do not call it repeatedly in hot + * code. + */ int32_t GetLength() const; /** diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index e2f8a4e5a61..bca1a2b1cda 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -602,7 +602,7 @@ nsHTMLScrollFrame::GuessVScrollbarNeeded(const ScrollReflowState& aState) return false; if (mHelper.mIsRoot) { - nsIFrame *f = mHelper.mScrolledFrame->GetFirstPrincipalChild(); + nsIFrame *f = mHelper.mScrolledFrame->PrincipalChildList().FirstChild(); if (f && f->GetType() == nsGkAtoms::svgOuterSVGFrame && static_cast(f)->VerticalScrollbarNotNeeded()) { // Common SVG case - avoid a bad guess. @@ -3913,8 +3913,7 @@ ScrollFrameHelper::ReloadChildFrames() mScrollCornerBox = nullptr; mResizerBox = nullptr; - nsIFrame* frame = mOuter->GetFirstPrincipalChild(); - while (frame) { + for (nsIFrame* frame : mOuter->PrincipalChildList()) { nsIContent* content = frame->GetContent(); if (content == mOuter->GetContent()) { NS_ASSERTION(!mScrolledFrame, "Already found the scrolled frame"); @@ -3940,8 +3939,6 @@ ScrollFrameHelper::ReloadChildFrames() mScrollCornerBox = frame; } } - - frame = frame->GetNextSibling(); } } @@ -5337,7 +5334,7 @@ ScrollFrameHelper::GetScrolledRectInternal(const nsRect& aScrolledFrameOverflowA // direction set by the text content overrides the direction of the frame if (mScrolledFrame->StyleTextReset()->mUnicodeBidi & NS_STYLE_UNICODE_BIDI_PLAINTEXT) { - nsIFrame* childFrame = mScrolledFrame->GetFirstPrincipalChild(); + nsIFrame* childFrame = mScrolledFrame->PrincipalChildList().FirstChild(); if (childFrame) { frameDir = (nsBidiPresUtils::ParagraphDirection(childFrame) == NSBIDI_LTR) diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index b5308b6addf..1c9b3819a5e 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -3585,7 +3585,7 @@ nsGridContainerFrame::SanityCheckAnonymousGridItems() const "children have been reordered with the 'order' property)"); */ MOZ_ASSERT(!prevChildWasAnonGridItem, "two anon grid items in a row"); - nsIFrame* firstWrappedChild = child->GetFirstPrincipalChild(); + nsIFrame* firstWrappedChild = child->PrincipalChildList().FirstChild(); MOZ_ASSERT(firstWrappedChild, "anonymous grid item is empty (shouldn't happen)"); prevChildWasAnonGridItem = true; diff --git a/layout/generic/nsHTMLCanvasFrame.h b/layout/generic/nsHTMLCanvasFrame.h index e3bbf731c37..aada81e0410 100644 --- a/layout/generic/nsHTMLCanvasFrame.h +++ b/layout/generic/nsHTMLCanvasFrame.h @@ -95,7 +95,7 @@ public: // Inserted child content gets its frames parented by our child block virtual nsContainerFrame* GetContentInsertionFrame() override { - return GetFirstPrincipalChild()->GetContentInsertionFrame(); + return PrincipalChildList().FirstChild()->GetContentInsertionFrame(); } protected: diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 85c430d01bb..d297a41645d 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -570,7 +570,7 @@ nsHTMLReflowState::InitResizeFlags(nsPresContext* aPresContext, nsIAtom* aFrameT if (frame->GetType() == nsGkAtoms::svgForeignObjectFrame) { // Foreign object frames use dirty bits in a special way. frame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); - nsIFrame *kid = frame->GetFirstPrincipalChild(); + nsIFrame *kid = frame->PrincipalChildList().FirstChild(); if (kid) { kid->AddStateBits(NS_FRAME_IS_DIRTY); } diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index e53b41d6962..c4b5e5fbc1e 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -1079,7 +1079,7 @@ public: * frame type, an empty list will be returned. */ virtual const nsFrameList& GetChildList(ChildListID aListID) const = 0; - const nsFrameList& PrincipalChildList() { return GetChildList(kPrincipalList); } + const nsFrameList& PrincipalChildList() const { return GetChildList(kPrincipalList); } virtual void GetChildLists(nsTArray* aLists) const = 0; /** @@ -1088,10 +1088,6 @@ public: */ void GetCrossDocChildLists(nsTArray* aLists); - nsIFrame* GetFirstPrincipalChild() const { - return GetChildList(kPrincipalList).FirstChild(); - } - // The individual concrete child lists. static const ChildListID kPrincipalList = mozilla::layout::kPrincipalList; static const ChildListID kAbsoluteList = mozilla::layout::kAbsoluteList; diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index dbafb16a387..e5925bd3aa3 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -652,7 +652,7 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext, // so nsFirstLetterFrame::Reflow can destroy them safely (bug 401042). nsIFrame* realFrame = nsPlaceholderFrame::GetRealFrameFor(frame); if (realFrame->GetType() == nsGkAtoms::letterFrame) { - nsIFrame* child = realFrame->GetFirstPrincipalChild(); + nsIFrame* child = realFrame->PrincipalChildList().FirstChild(); if (child) { NS_ASSERTION(child->GetType() == nsGkAtoms::textFrame, "unexpected frame type"); diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index 1a8c5721d3c..cba5dd65562 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -465,7 +465,7 @@ GetNextPage(nsIFrame* aPageContentFrame) return nullptr; NS_ASSERTION(nextPageFrame->GetType() == nsGkAtoms::pageFrame, "pageFrame's sibling is not a page frame..."); - nsIFrame* f = nextPageFrame->GetFirstPrincipalChild(); + nsIFrame* f = nextPageFrame->PrincipalChildList().FirstChild(); NS_ASSERTION(f, "pageFrame has no page content frame!"); NS_ASSERTION(f->GetType() == nsGkAtoms::pageContentFrame, "pageFrame's child is not page content!"); diff --git a/layout/generic/nsPluginFrame.cpp b/layout/generic/nsPluginFrame.cpp index 89076f2e26d..3316df311bc 100644 --- a/layout/generic/nsPluginFrame.cpp +++ b/layout/generic/nsPluginFrame.cpp @@ -1771,9 +1771,7 @@ nsPluginFrame::SetIsDocumentActive(bool aIsActive) nsIObjectFrame * nsPluginFrame::GetNextObjectFrame(nsPresContext* aPresContext, nsIFrame* aRoot) { - nsIFrame* child = aRoot->GetFirstPrincipalChild(); - - while (child) { + for (nsIFrame* child : aRoot->PrincipalChildList()) { nsIObjectFrame* outFrame = do_QueryFrame(child); if (outFrame) { RefPtr pi; @@ -1785,7 +1783,6 @@ nsPluginFrame::GetNextObjectFrame(nsPresContext* aPresContext, nsIFrame* aRoot) outFrame = GetNextObjectFrame(aPresContext, child); if (outFrame) return outFrame; - child = child->GetNextSibling(); } return nullptr; diff --git a/layout/generic/nsRubyBaseContainerFrame.cpp b/layout/generic/nsRubyBaseContainerFrame.cpp index 047e0cd27ae..364324babed 100644 --- a/layout/generic/nsRubyBaseContainerFrame.cpp +++ b/layout/generic/nsRubyBaseContainerFrame.cpp @@ -68,7 +68,7 @@ LineBreakBefore(nsIFrame* aFrame, const nsLineList::iterator* aLine) { for (nsIFrame* child = aFrame; child; - child = child->GetFirstPrincipalChild()) { + child = child->PrincipalChildList().FirstChild()) { if (!child->CanContinueTextRun()) { // It is not an inline element. We can break before it. return gfxBreakPriority::eNormalBreak; @@ -241,7 +241,7 @@ nsRubyBaseContainerFrame::AddInlinePrefISize( } for (uint32_t i = 0, iend = textContainers.Length(); i < iend; i++) { if (textContainers[i]->IsSpanContainer()) { - nsIFrame* frame = textContainers[i]->GetFirstPrincipalChild(); + nsIFrame* frame = textContainers[i]->PrincipalChildList().FirstChild(); nsIFrame::InlinePrefISizeData data; frame->AddInlinePrefISize(aRenderingContext, &data); MOZ_ASSERT(data.prevLines == 0, "Shouldn't have prev lines"); @@ -818,7 +818,7 @@ nsRubyBaseContainerFrame::ReflowSpans(const ReflowState& aReflowState) continue; } - nsIFrame* rtFrame = container->GetFirstPrincipalChild(); + nsIFrame* rtFrame = container->PrincipalChildList().FirstChild(); nsReflowStatus reflowStatus; bool pushedFrame; nsLineLayout* lineLayout = aReflowState.mTextReflowStates[i]->mLineLayout; diff --git a/layout/generic/nsSimplePageSequenceFrame.cpp b/layout/generic/nsSimplePageSequenceFrame.cpp index 103f62de04f..6f3edd2fed1 100644 --- a/layout/generic/nsSimplePageSequenceFrame.cpp +++ b/layout/generic/nsSimplePageSequenceFrame.cpp @@ -520,7 +520,7 @@ GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArrayGetFirstPrincipalChild()) { + if (!child->PrincipalChildList().FirstChild()) { nsSubDocumentFrame* subdocumentFrame = do_QueryFrame(child); if (subdocumentFrame) { // Descend into the subdocument @@ -742,7 +742,7 @@ nsSimplePageSequenceFrame::PrintNextPage() height -= mMargin.top + mMargin.bottom; width -= mMargin.left + mMargin.right; nscoord selectionY = height; - nsIFrame* conFrame = currentPage->GetFirstPrincipalChild(); + nsIFrame* conFrame = currentPage->PrincipalChildList().FirstChild(); if (mSelectionHeight >= 0) { conFrame->SetPosition(conFrame->GetPosition() + nsPoint(0, -mYSelOffset)); nsContainerFrame::PositionChildViews(conFrame); @@ -837,7 +837,7 @@ nsSimplePageSequenceFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, DisplayListClipState::AutoSaveRestore clipState(aBuilder); clipState.Clear(); - nsIFrame* child = GetFirstPrincipalChild(); + nsIFrame* child = PrincipalChildList().FirstChild(); nsRect dirty = aDirtyRect; dirty.ScaleInverseRoundOut(PresContext()->GetPrintPreviewScale()); diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index fc6ddf26330..23d49ca59f3 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -1270,7 +1270,7 @@ nsSubDocumentFrame::ObtainIntrinsicSizeFrame() if (scrollable) { nsIFrame* scrolled = scrollable->GetScrolledFrame(); if (scrolled) { - subDocRoot = scrolled->GetFirstPrincipalChild(); + subDocRoot = scrolled->PrincipalChildList().FirstChild(); } } } diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index eda5181f2dc..8010ecac81c 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -1145,7 +1145,7 @@ CanTextCrossFrameBoundary(nsIFrame* aFrame, nsIAtom* aType) } } else { if (continuesTextRun) { - result.mFrameToScan = aFrame->GetFirstPrincipalChild(); + result.mFrameToScan = aFrame->PrincipalChildList().FirstChild(); result.mOverflowFrameToScan = aFrame->GetChildList(nsIFrame::kOverflowList).FirstChild(); NS_WARN_IF_FALSE(!result.mOverflowFrameToScan, diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp index 79741dbe9db..3582633fb13 100644 --- a/layout/mathml/nsMathMLChar.cpp +++ b/layout/mathml/nsMathMLChar.cpp @@ -942,9 +942,7 @@ ComputeSizeFromParts(nsPresContext* aPresContext, // Add the parts that cannot be left out. nscoord sum = 0; for (int32_t i = first; i <= last; i++) { - if (aGlyphs[i] != aGlyphs[glue]) { - sum += aSizes[i]; - } + sum += aSizes[i]; } // Determine how much is used in joins diff --git a/layout/mathml/nsMathMLContainerFrame.cpp b/layout/mathml/nsMathMLContainerFrame.cpp index a48312efd61..b380078145b 100644 --- a/layout/mathml/nsMathMLContainerFrame.cpp +++ b/layout/mathml/nsMathMLContainerFrame.cpp @@ -218,7 +218,7 @@ nsMathMLContainerFrame::GetPreferredStretchSize(DrawTarget* aDrawTarget bool firstTime = true; nsBoundingMetrics bm, bmChild; nsIFrame* childFrame = - stretchAll ? GetFirstPrincipalChild() : mPresentationData.baseFrame; + stretchAll ? PrincipalChildList().FirstChild() : mPresentationData.baseFrame; while (childFrame) { // initializations in case this child happens not to be a MathML frame nsIMathMLFrame* mathMLFrame = do_QueryFrame(childFrame); @@ -482,7 +482,7 @@ nsMathMLContainerFrame::FinalizeReflow(DrawTarget* aDrawTarget, // through Stretch() eventually. if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) { GatherAndStoreOverflow(&aDesiredSize); - DidReflowChildren(GetFirstPrincipalChild()); + DidReflowChildren(PrincipalChildList().FirstChild()); return rv; } @@ -531,8 +531,7 @@ nsMathMLContainerFrame::FinalizeReflow(DrawTarget* aDrawTarget, { // The Place() call above didn't request FinishReflowChild(), // so let's check that we eventually did through Stretch(). - nsIFrame* childFrame = GetFirstPrincipalChild(); - for ( ; childFrame; childFrame = childFrame->GetNextSibling()) { + for (nsIFrame* childFrame : PrincipalChildList()) { NS_ASSERTION(!(childFrame->GetStateBits() & NS_FRAME_IN_REFLOW), "DidReflow() was never called"); } @@ -587,11 +586,9 @@ nsMathMLContainerFrame::PropagatePresentationDataFor(nsIFrame* aFrame, } else { // propagate down the subtrees - nsIFrame* childFrame = aFrame->GetFirstPrincipalChild(); - while (childFrame) { + for (nsIFrame* childFrame : aFrame->PrincipalChildList()) { PropagatePresentationDataFor(childFrame, aFlagsValues, aFlagsToUpdate); - childFrame = childFrame->GetNextSibling(); } } } @@ -606,8 +603,7 @@ nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(nsIFrame* aPa if (!aParentFrame || !aFlagsToUpdate) return; int32_t index = 0; - nsIFrame* childFrame = aParentFrame->GetFirstPrincipalChild(); - while (childFrame) { + for (nsIFrame* childFrame : aParentFrame->PrincipalChildList()) { if ((index >= aFirstChildIndex) && ((aLastChildIndex <= 0) || ((aLastChildIndex > 0) && (index <= aLastChildIndex)))) { @@ -615,7 +611,6 @@ nsMathMLContainerFrame::PropagatePresentationDataFromChildAt(nsIFrame* aPa aFlagsValues, aFlagsToUpdate); } index++; - childFrame = childFrame->GetNextSibling(); } } @@ -666,14 +661,12 @@ nsMathMLContainerFrame::RebuildAutomaticDataForChildren(nsIFrame* aParentFrame) // the parent // 2. As we ascend the tree, transmit any specific change that we want // down the subtrees - nsIFrame* childFrame = aParentFrame->GetFirstPrincipalChild(); - while (childFrame) { + for (nsIFrame* childFrame : aParentFrame->PrincipalChildList()) { nsIMathMLFrame* childMathMLFrame = do_QueryFrame(childFrame); if (childMathMLFrame) { childMathMLFrame->InheritAutomaticData(aParentFrame); } RebuildAutomaticDataForChildren(childFrame); - childFrame = childFrame->GetNextSibling(); } nsIMathMLFrame* mathMLFrame = do_QueryFrame(aParentFrame); if (mathMLFrame) { @@ -1375,7 +1368,7 @@ GetInterFrameSpacingFor(int32_t aScriptLevel, nsIFrame* aParentFrame, nsIFrame* aChildFrame) { - nsIFrame* childFrame = aParentFrame->GetFirstPrincipalChild(); + nsIFrame* childFrame = aParentFrame->PrincipalChildList().FirstChild(); if (!childFrame || aChildFrame == childFrame) return 0; @@ -1463,7 +1456,7 @@ nsMathMLContainerFrame::DidReflowChildren(nsIFrame* aFirst, nsIFrame* aStop) NS_ASSERTION(frame, "aStop isn't a sibling"); if (frame->GetStateBits() & NS_FRAME_IN_REFLOW) { // finish off principal descendants, too - nsIFrame* grandchild = frame->GetFirstPrincipalChild(); + nsIFrame* grandchild = frame->PrincipalChildList().FirstChild(); if (grandchild) DidReflowChildren(grandchild, nullptr); @@ -1501,7 +1494,7 @@ nsMathMLContainerFrame::TransmitAutomaticDataForMrowLikeElement() bool embellishedOpFound = false; nsEmbellishData embellishData; - for (childFrame = GetFirstPrincipalChild(); + for (childFrame = PrincipalChildList().FirstChild(); childFrame; childFrame = childFrame->GetNextSibling()) { nsIMathMLFrame* mathMLFrame = do_QueryFrame(childFrame); @@ -1555,10 +1548,8 @@ nsMathMLContainerFrame::PropagateFrameFlagFor(nsIFrame* aFrame, return; aFrame->AddStateBits(aFlags); - nsIFrame* childFrame = aFrame->GetFirstPrincipalChild(); - while (childFrame) { + for (nsIFrame* childFrame : aFrame->PrincipalChildList()) { PropagateFrameFlagFor(childFrame, aFlags); - childFrame = childFrame->GetNextSibling(); } } diff --git a/layout/mathml/nsMathMLTokenFrame.cpp b/layout/mathml/nsMathMLTokenFrame.cpp index 73d58b28e9e..dc6b7933972 100644 --- a/layout/mathml/nsMathMLTokenFrame.cpp +++ b/layout/mathml/nsMathMLTokenFrame.cpp @@ -64,9 +64,9 @@ nsMathMLTokenFrame::MarkTextFramesAsTokenMathML() // - to force them to trim their leading and trailing whitespaces. // - Indicate which frames are suitable for mathvariant // - flag single character frames for special italic treatment - for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame; + for (nsIFrame* childFrame = PrincipalChildList().FirstChild(); childFrame; childFrame = childFrame->GetNextSibling()) { - for (nsIFrame* childFrame2 = childFrame->GetFirstPrincipalChild(); + for (nsIFrame* childFrame2 = childFrame->PrincipalChildList().FirstChild(); childFrame2; childFrame2 = childFrame2->GetNextSibling()) { if (childFrame2->GetType() == nsGkAtoms::textFrame) { childFrame2->AddStateBits(TEXT_IS_IN_TOKEN_MATHML); @@ -132,8 +132,7 @@ nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext, aDesiredSize.SetBlockStartAscent(0); aDesiredSize.mBoundingMetrics = nsBoundingMetrics(); - nsIFrame* childFrame = GetFirstPrincipalChild(); - while (childFrame) { + for (nsIFrame* childFrame : PrincipalChildList()) { // ask our children to compute their bounding metrics nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode(), aDesiredSize.mFlags @@ -148,8 +147,6 @@ nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext, //NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize, childDesiredSize.mBoundingMetrics); - - childFrame = childFrame->GetNextSibling(); } // place and size children @@ -168,8 +165,7 @@ nsMathMLTokenFrame::Place(DrawTarget* aDrawTarget, nsHTMLReflowMetrics& aDesiredSize) { mBoundingMetrics = nsBoundingMetrics(); - for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame; - childFrame = childFrame->GetNextSibling()) { + for (nsIFrame* childFrame :PrincipalChildList()) { nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode()); GetReflowAndBoundingMetricsFor(childFrame, childSize, childSize.mBoundingMetrics, nullptr); @@ -192,8 +188,7 @@ nsMathMLTokenFrame::Place(DrawTarget* aDrawTarget, if (aPlaceOrigin) { nscoord dy, dx = 0; - for (nsIFrame* childFrame = GetFirstPrincipalChild(); childFrame; - childFrame = childFrame->GetNextSibling()) { + for (nsIFrame* childFrame : PrincipalChildList()) { nsHTMLReflowMetrics childSize(aDesiredSize.GetWritingMode()); GetReflowAndBoundingMetricsFor(childFrame, childSize, childSize.mBoundingMetrics); diff --git a/layout/mathml/nsMathMLmencloseFrame.cpp b/layout/mathml/nsMathMLmencloseFrame.cpp index 149e9b5cfc7..9dc02df765f 100644 --- a/layout/mathml/nsMathMLmencloseFrame.cpp +++ b/layout/mathml/nsMathMLmencloseFrame.cpp @@ -327,7 +327,7 @@ nsMathMLmencloseFrame::PlaceInternal(DrawTarget* aDrawTarget, nsMathMLContainerFrame::Place(aDrawTarget, false, baseSize); if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) { - DidReflowChildren(GetFirstPrincipalChild()); + DidReflowChildren(PrincipalChildList().FirstChild()); return rv; } diff --git a/layout/mathml/nsMathMLmfencedFrame.cpp b/layout/mathml/nsMathMLmfencedFrame.cpp index 56d665f0a87..915e3a05a31 100644 --- a/layout/mathml/nsMathMLmfencedFrame.cpp +++ b/layout/mathml/nsMathMLmfencedFrame.cpp @@ -245,7 +245,7 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext, // refactored to use nsMathMLContainerFrame::Reflow() at some stage. nsReflowStatus childStatus; - nsIFrame* firstChild = GetFirstPrincipalChild(); + nsIFrame* firstChild = PrincipalChildList().FirstChild(); nsIFrame* childFrame = firstChild; nscoord ascent = 0, descent = 0; if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) { @@ -626,8 +626,7 @@ nsMathMLmfencedFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingCon } int32_t i = 0; - nsIFrame* childFrame = GetFirstPrincipalChild(); - while (childFrame) { + for (nsIFrame* childFrame : PrincipalChildList()) { // XXX This includes margin while Reflow currently doesn't consider // margin, so we may end up with too much space, but, with stretchy // characters, this is an approximation anyway. @@ -641,8 +640,6 @@ nsMathMLmfencedFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingCon NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel, em); } i++; - - childFrame = childFrame->GetNextSibling(); } if (mCloseChar) { diff --git a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp index c1d9957a3c9..126f54ca305 100644 --- a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp +++ b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp @@ -173,7 +173,7 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, // depend only on the current font //////////////////////////////////////// - nsIFrame* baseFrame = aFrame->GetFirstPrincipalChild(); + nsIFrame* baseFrame = aFrame->PrincipalChildList().FirstChild(); if (!baseFrame) { if (tag == nsGkAtoms::mmultiscripts_) @@ -330,7 +330,7 @@ nsMathMLmmultiscriptsFrame::PlaceMultiScript(nsPresContext* aPresContext, // Note that only msup starts with a superscript. bool isSubScript = (tag != nsGkAtoms::msup_); - nsIFrame* childFrame = aFrame->GetFirstPrincipalChild(); + nsIFrame* childFrame = aFrame->PrincipalChildList().FirstChild(); while (childFrame) { if (childFrame->GetContent()->IsMathMLElement(nsGkAtoms::mprescripts_)) { if (tag != nsGkAtoms::mmultiscripts_) { diff --git a/layout/mathml/nsMathMLmpaddedFrame.cpp b/layout/mathml/nsMathMLmpaddedFrame.cpp index aefdabd8e4a..b24f93e741b 100644 --- a/layout/mathml/nsMathMLmpaddedFrame.cpp +++ b/layout/mathml/nsMathMLmpaddedFrame.cpp @@ -326,7 +326,7 @@ nsMathMLmpaddedFrame::Place(DrawTarget* aDrawTarget, nsresult rv = nsMathMLContainerFrame::Place(aDrawTarget, false, aDesiredSize); if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) { - DidReflowChildren(GetFirstPrincipalChild()); + DidReflowChildren(PrincipalChildList().FirstChild()); return rv; } diff --git a/layout/mathml/nsMathMLmrowFrame.cpp b/layout/mathml/nsMathMLmrowFrame.cpp index 5bdcff1706a..65b9e0fd5f0 100644 --- a/layout/mathml/nsMathMLmrowFrame.cpp +++ b/layout/mathml/nsMathMLmrowFrame.cpp @@ -43,7 +43,7 @@ nsMathMLmrowFrame::AttributeChanged(int32_t aNameSpaceID, // notification to the real mtable if (mContent->IsMathMLElement(nsGkAtoms::mtable_)) { nsIFrame* frame = mFrames.FirstChild(); - for ( ; frame; frame = frame->GetFirstPrincipalChild()) { + for ( ; frame; frame = frame->PrincipalChildList().FirstChild()) { // drill down to the real mtable if (frame->GetType() == nsGkAtoms::tableOuterFrame) return frame->AttributeChanged(aNameSpaceID, aAttribute, aModType); diff --git a/layout/mathml/nsMathMLmtableFrame.cpp b/layout/mathml/nsMathMLmtableFrame.cpp index 1df2a7188f9..5f522c70605 100644 --- a/layout/mathml/nsMathMLmtableFrame.cpp +++ b/layout/mathml/nsMathMLmtableFrame.cpp @@ -577,12 +577,11 @@ MapAllAttributesIntoCSS(nsMathMLmtableFrame* aTableFrame) ParseSpacingAttributes(aTableFrame); // mtable is simple and only has one (pseudo) row-group - nsIFrame* rgFrame = aTableFrame->GetFirstPrincipalChild(); + nsIFrame* rgFrame = aTableFrame->PrincipalChildList().FirstChild(); if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame) return; - nsIFrame* rowFrame = rgFrame->GetFirstPrincipalChild(); - for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) { + for (nsIFrame* rowFrame : rgFrame->PrincipalChildList()) { DEBUG_VERIFY_THAT_FRAME_IS(rowFrame, TABLE_ROW); if (rowFrame->GetType() == nsGkAtoms::tableRowFrame) { // Map row rowalign. @@ -590,8 +589,7 @@ MapAllAttributesIntoCSS(nsMathMLmtableFrame* aTableFrame) // Map row columnalign. ParseFrameAttribute(rowFrame, nsGkAtoms::columnalign_, true); - nsIFrame* cellFrame = rowFrame->GetFirstPrincipalChild(); - for ( ; cellFrame; cellFrame = cellFrame->GetNextSibling()) { + for (nsIFrame* cellFrame : rowFrame->PrincipalChildList()) { DEBUG_VERIFY_THAT_FRAME_IS(cellFrame, TABLE_CELL); if (IS_TABLE_CELL(cellFrame->GetType())) { // Map cell rowalign. @@ -725,7 +723,7 @@ nsMathMLmtableOuterFrame::AttributeChanged(int32_t aNameSpaceID, nsIFrame* tableFrame = mFrames.FirstChild(); NS_ASSERTION(tableFrame && tableFrame->GetType() == nsGkAtoms::tableFrame, "should always have an inner table frame"); - nsIFrame* rgFrame = tableFrame->GetFirstPrincipalChild(); + nsIFrame* rgFrame = tableFrame->PrincipalChildList().FirstChild(); if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame) return NS_OK; @@ -798,7 +796,7 @@ nsMathMLmtableOuterFrame::GetRowFrameAt(int32_t aRowIndex) nsIFrame* tableFrame = mFrames.FirstChild(); NS_ASSERTION(tableFrame && tableFrame->GetType() == nsGkAtoms::tableFrame, "should always have an inner table frame"); - nsIFrame* rgFrame = tableFrame->GetFirstPrincipalChild(); + nsIFrame* rgFrame = tableFrame->PrincipalChildList().FirstChild(); if (!rgFrame || rgFrame->GetType() != nsGkAtoms::tableRowGroupFrame) return nullptr; for (nsIFrame* rowFrame : rgFrame->PrincipalChildList()) { diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index bd0d647e33f..22b49b93f95 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -2238,11 +2238,7 @@ nsPrintEngine::CalcNumPrintablePages(int32_t& aNumPages) nsIPageSequenceFrame* pageSequence = po->mPresShell->GetPageSequenceFrame(); nsIFrame * seqFrame = do_QueryFrame(pageSequence); if (seqFrame) { - nsIFrame* frame = seqFrame->GetFirstPrincipalChild(); - while (frame) { - aNumPages++; - frame = frame->GetNextSibling(); - } + aNumPages += seqFrame->PrincipalChildList().GetLength(); } } } @@ -2867,7 +2863,7 @@ nsPrintEngine::GetPageRangeForSelection(nsIPageSequenceFrame* aPageSeqFrame, // dump all the pages and their pointers { int32_t pageNum = 1; - nsIFrame* child = seqFrame->GetFirstPrincipalChild(); + nsIFrame* child = seqFrame->PrincipalChildList().FirstChild(); while (child != nullptr) { printf("Page: %d - %p\n", pageNum, child); pageNum++; @@ -2879,8 +2875,7 @@ nsPrintEngine::GetPageRangeForSelection(nsIPageSequenceFrame* aPageSeqFrame, // Now that we have the page frames // find out what the page numbers are for each frame int32_t pageNum = 1; - nsIFrame* page = seqFrame->GetFirstPrincipalChild(); - while (page != nullptr) { + for (nsIFrame* page : seqFrame->PrincipalChildList()) { if (page == startPageFrame) { aStartPageNum = pageNum; } @@ -2888,7 +2883,6 @@ nsPrintEngine::GetPageRangeForSelection(nsIPageSequenceFrame* aPageSeqFrame, aEndPageNum = pageNum; } pageNum++; - page = page->GetNextSibling(); } #ifdef DEBUG_rodsX @@ -3642,7 +3636,7 @@ static void DumpFrames(FILE* out, NS_ASSERTION(aRendContext, "Pointer is null!"); NS_ASSERTION(aFrame, "Pointer is null!"); - nsIFrame* child = aFrame->GetFirstPrincipalChild(); + nsIFrame* child = aFrame->PrincipalChildList().FirstChild(); while (child != nullptr) { for (int32_t i=0;i * aDocList) if (sqf) { break; } - rootFrame = rootFrame->GetFirstPrincipalChild(); + rootFrame = rootFrame->PrincipalChildList().FirstChild(); } } diff --git a/layout/reftests/mathml/mo-glyph-size-ref.html b/layout/reftests/mathml/mo-glyph-size-ref.html new file mode 100644 index 00000000000..e4dd43747e0 --- /dev/null +++ b/layout/reftests/mathml/mo-glyph-size-ref.html @@ -0,0 +1,14 @@ + + + + + + + + +
+ + diff --git a/layout/reftests/mathml/mo-glyph-size.html b/layout/reftests/mathml/mo-glyph-size.html new file mode 100644 index 00000000000..a7f1a1ab6c2 --- /dev/null +++ b/layout/reftests/mathml/mo-glyph-size.html @@ -0,0 +1,50 @@ + + + + + + + + + + + | + + f + + ( + x + ) + + - + + f + + ( + + x + 0 + + ) + + + + | + + +