layout/generic/nsFrameState.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 /* constants for frame state bits and a type to store them in a uint64_t */
     8 #include "nsFrameState.h"
    10 #include "nsBlockFrame.h"
    11 #include "nsBoxFrame.h"
    12 #include "nsBulletFrame.h"
    13 #include "nsFlexContainerFrame.h"
    14 #include "nsGfxScrollFrame.h"
    15 #include "nsIFrame.h"
    16 #include "nsISVGChildFrame.h"
    17 #include "nsImageFrame.h"
    18 #include "nsInlineFrame.h"
    19 #include "nsPlaceholderFrame.h"
    20 #include "nsSVGContainerFrame.h"
    21 #include "nsTableCellFrame.h"
    22 #include "nsTableRowFrame.h"
    23 #include "nsTableRowGroupFrame.h"
    24 #include "nsTextFrame.h"
    26 namespace mozilla {
    28 #ifdef DEBUG
    29 nsCString
    30 GetFrameState(nsIFrame* aFrame)
    31 {
    32   nsCString result;
    33   nsAutoTArray<const char*,3> groups;
    35   nsFrameState state = aFrame->GetStateBits();
    37   if (state == nsFrameState(0)) {
    38     result.AssignLiteral("0");
    39     return result;
    40   }
    42 #define FRAME_STATE_GROUP(name_, class_)                                      \
    43   {                                                                           \
    44     class_* frame = do_QueryFrame(aFrame);                                    \
    45     if (frame && (groups.IsEmpty() || strcmp(groups.LastElement(), #name_))) {\
    46       groups.AppendElement(#name_);                                           \
    47     }                                                                         \
    48   }
    49 #define FRAME_STATE_BIT(group_, value_, name_)                                \
    50   if ((state & NS_FRAME_STATE_BIT(value_)) && groups.Contains(#group_)) {     \
    51     if (!result.IsEmpty()) {                                                  \
    52       result.Insert(" | ", 0);                                                \
    53     }                                                                         \
    54     result.Insert(#name_, 0);                                                 \
    55     state = state & ~NS_FRAME_STATE_BIT(value_);                              \
    56   }
    57 #include "nsFrameStateBits.h"
    58 #undef FRAME_STATE_GROUP
    59 #undef FRAME_STATE_BIT
    61   if (state) {
    62     result.AppendPrintf(" | 0x%0llx", state);
    63   }
    65   return result;
    66 }
    68 void
    69 PrintFrameState(nsIFrame* aFrame)
    70 {
    71   printf("%s\n", GetFrameState(aFrame).get());
    72 }
    73 #endif
    75 } // namespace mozilla

mercurial