tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

FlushType.h (2535B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_FlushType_h
      8 #define mozilla_FlushType_h
      9 
     10 #include <stdint.h>
     11 
     12 #include "X11UndefineNone.h"
     13 #include "mozilla/EnumeratedArray.h"
     14 
     15 namespace mozilla {
     16 
     17 /**
     18 * This is the enum used by Document::FlushPendingNotifications to
     19 * decide what to flush.
     20 *
     21 * Please note that if you change these values, you should sync it with the
     22 * kFlushTypeNames array below.
     23 */
     24 enum class FlushType : uint8_t {
     25  None,             /* Actually don't flush anything */
     26  Event,            /* Flush pending events before notify other observers */
     27  Content,          /* flush the content model construction */
     28  ContentAndNotify, /* As above, plus flush the frame model
     29                       construction and other nsIMutationObserver
     30                       notifications. */
     31  Style,            /* As above, plus flush style reresolution */
     32  Frames,           /* As above, plus flush frame construction */
     33  EnsurePresShellInitAndFrames, /* As above, plus ensure the pres shell is alive
     34                                 */
     35  InterruptibleLayout, /* As above, plus flush reflow, but allow it to be
     36                          interrupted (so an incomplete layout may result) */
     37  Layout,              /* As above, but layout must run to completion */
     38  Display,             /* As above, plus flush painting */
     39  Count
     40 };
     41 
     42 // Flush type strings that will be displayed in the profiler
     43 // clang-format off
     44 const EnumeratedArray<FlushType, const char*, size_t(FlushType::Count)>
     45    kFlushTypeNames = {
     46  "",
     47  "Event",
     48  "Content",
     49  "ContentAndNotify",
     50  "Style",
     51  // As far as the profiler is concerned, EnsurePresShellInitAndFrames and
     52  // Frames are the same
     53  "Style",
     54  "Style",
     55  "InterruptibleLayout",
     56  "Layout",
     57  "Display"
     58 };
     59 // clang-format on
     60 
     61 struct ChangesToFlush {
     62  ChangesToFlush(FlushType aFlushType, bool aFlushAnimations,
     63                 bool aUpdateRelevancy)
     64      : mFlushType(aFlushType),
     65        mFlushAnimations(aFlushAnimations),
     66        mUpdateRelevancy(aUpdateRelevancy) {
     67    MOZ_ASSERT_IF(mUpdateRelevancy, mFlushType >= FlushType::Layout);
     68  }
     69 
     70  FlushType mFlushType;
     71  bool mFlushAnimations;
     72  bool mUpdateRelevancy;
     73 };
     74 
     75 }  // namespace mozilla
     76 
     77 #endif  // mozilla_FlushType_h