layout/generic/nsFrameState.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/generic/nsFrameState.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/* constants for frame state bits and a type to store them in a uint64_t */
    1.10 +
    1.11 +#include "nsFrameState.h"
    1.12 +
    1.13 +#include "nsBlockFrame.h"
    1.14 +#include "nsBoxFrame.h"
    1.15 +#include "nsBulletFrame.h"
    1.16 +#include "nsFlexContainerFrame.h"
    1.17 +#include "nsGfxScrollFrame.h"
    1.18 +#include "nsIFrame.h"
    1.19 +#include "nsISVGChildFrame.h"
    1.20 +#include "nsImageFrame.h"
    1.21 +#include "nsInlineFrame.h"
    1.22 +#include "nsPlaceholderFrame.h"
    1.23 +#include "nsSVGContainerFrame.h"
    1.24 +#include "nsTableCellFrame.h"
    1.25 +#include "nsTableRowFrame.h"
    1.26 +#include "nsTableRowGroupFrame.h"
    1.27 +#include "nsTextFrame.h"
    1.28 +
    1.29 +namespace mozilla {
    1.30 +
    1.31 +#ifdef DEBUG
    1.32 +nsCString
    1.33 +GetFrameState(nsIFrame* aFrame)
    1.34 +{
    1.35 +  nsCString result;
    1.36 +  nsAutoTArray<const char*,3> groups;
    1.37 +
    1.38 +  nsFrameState state = aFrame->GetStateBits();
    1.39 +
    1.40 +  if (state == nsFrameState(0)) {
    1.41 +    result.AssignLiteral("0");
    1.42 +    return result;
    1.43 +  }
    1.44 +
    1.45 +#define FRAME_STATE_GROUP(name_, class_)                                      \
    1.46 +  {                                                                           \
    1.47 +    class_* frame = do_QueryFrame(aFrame);                                    \
    1.48 +    if (frame && (groups.IsEmpty() || strcmp(groups.LastElement(), #name_))) {\
    1.49 +      groups.AppendElement(#name_);                                           \
    1.50 +    }                                                                         \
    1.51 +  }
    1.52 +#define FRAME_STATE_BIT(group_, value_, name_)                                \
    1.53 +  if ((state & NS_FRAME_STATE_BIT(value_)) && groups.Contains(#group_)) {     \
    1.54 +    if (!result.IsEmpty()) {                                                  \
    1.55 +      result.Insert(" | ", 0);                                                \
    1.56 +    }                                                                         \
    1.57 +    result.Insert(#name_, 0);                                                 \
    1.58 +    state = state & ~NS_FRAME_STATE_BIT(value_);                              \
    1.59 +  }
    1.60 +#include "nsFrameStateBits.h"
    1.61 +#undef FRAME_STATE_GROUP
    1.62 +#undef FRAME_STATE_BIT
    1.63 +
    1.64 +  if (state) {
    1.65 +    result.AppendPrintf(" | 0x%0llx", state);
    1.66 +  }
    1.67 +
    1.68 +  return result;
    1.69 +}
    1.70 +
    1.71 +void
    1.72 +PrintFrameState(nsIFrame* aFrame)
    1.73 +{
    1.74 +  printf("%s\n", GetFrameState(aFrame).get());
    1.75 +}
    1.76 +#endif
    1.77 +
    1.78 +} // namespace mozilla

mercurial