Commit 136ccf14 authored by Olli Pettay's avatar Olli Pettay
Browse files

Bug 1521603 - Add a helper method to check if the top level content document...

Bug 1521603 - Add a helper method to check if the top level content document hasn't yet got first contentful paint and there is high prio event pending, r=jesup

--HG--
extra : rebase_source : 23ae3ef0cbb43db81d333135a0d6c52d64fb5fcf
parent 322fd9de
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@
#include "mozilla/Encoding.h"
#include "nsXULElement.h"
#include "mozilla/RecordReplay.h"

#include "nsThreadManager.h"
#include "nsIBidiKeyboard.h"

#if defined(XP_WIN)
@@ -10435,6 +10435,20 @@ static bool JSONCreator(const char16_t* aBuf, uint32_t aLen, void* aData) {
  return true;
}

/* static */
bool nsContentUtils::HighPriorityEventPendingForTopLevelDocumentBeforeContentfulPaint(
    Document* aDocument) {
  if (!aDocument) {
    return false;
  }

  Document* topLevel = aDocument->GetTopLevelContentDocument();
  return topLevel && topLevel->GetShell() &&
         topLevel->GetShell()->GetPresContext() &&
         !topLevel->GetShell()->GetPresContext()->HadContentfulPaint() &&
         nsThreadManager::MainThreadHasPendingHighPriorityEvents();
}

/* static */ bool nsContentUtils::IsURIInPrefList(nsIURI* aURI,
                                                  const char* aPrefName) {
  MOZ_ASSERT(aPrefName);
+8 −0
Original line number Diff line number Diff line
@@ -3304,6 +3304,14 @@ class nsContentUtils {
  static bool StringifyJSON(JSContext* aCx, JS::MutableHandle<JS::Value> vp,
                            nsAString& aOutStr);

  /**
   * Returns true if the top level ancestor content document of aDocument hasn't
   * yet had the first contentful paint and there is a high priority event
   * pending in the main thread.
   */
  static bool HighPriorityEventPendingForTopLevelDocumentBeforeContentfulPaint(
      Document* aDocument);

 private:
  static bool InitializeEventTable();