gecko/layout/tables/nsTableColFrame.cpp
Ehsan Akhgari 0fd9123eac Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00

193 lines
5.3 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsCOMPtr.h"
#include "nsTableColFrame.h"
#include "nsTableFrame.h"
#include "nsContainerFrame.h"
#include "nsStyleContext.h"
#include "nsStyleConsts.h"
#include "nsPresContext.h"
#include "nsGkAtoms.h"
#include "nsCSSRendering.h"
#include "nsIContent.h"
#include "nsIDOMHTMLTableColElement.h"
#define COL_TYPE_BITS (NS_FRAME_STATE_BIT(28) | \
NS_FRAME_STATE_BIT(29) | \
NS_FRAME_STATE_BIT(30) | \
NS_FRAME_STATE_BIT(31))
#define COL_TYPE_OFFSET 28
nsTableColFrame::nsTableColFrame(nsStyleContext* aContext) :
nsSplittableFrame(aContext)
{
SetColType(eColContent);
ResetIntrinsics();
ResetSpanIntrinsics();
ResetFinalWidth();
}
nsTableColFrame::~nsTableColFrame()
{
}
nsTableColType
nsTableColFrame::GetColType() const
{
return (nsTableColType)((mState & COL_TYPE_BITS) >> COL_TYPE_OFFSET);
}
void
nsTableColFrame::SetColType(nsTableColType aType)
{
NS_ASSERTION(aType != eColAnonymousCol ||
(GetPrevContinuation() &&
GetPrevContinuation()->GetNextContinuation() == this &&
GetPrevContinuation()->GetNextSibling() == this),
"spanned content cols must be continuations");
uint32_t type = aType - eColContent;
mState |= (type << COL_TYPE_OFFSET);
}
/* virtual */ void
nsTableColFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
{
nsSplittableFrame::DidSetStyleContext(aOldStyleContext);
if (!aOldStyleContext) //avoid this on init
return;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
if (tableFrame->IsBorderCollapse() &&
tableFrame->BCRecalcNeeded(aOldStyleContext, GetStyleContext())) {
nsIntRect damageArea(GetColIndex(), 0, 1, tableFrame->GetRowCount());
tableFrame->AddBCDamageArea(damageArea);
}
}
void nsTableColFrame::SetContinuousBCBorderWidth(uint8_t aForSide,
BCPixelSize aPixelValue)
{
switch (aForSide) {
case NS_SIDE_TOP:
mTopContBorderWidth = aPixelValue;
return;
case NS_SIDE_RIGHT:
mRightContBorderWidth = aPixelValue;
return;
case NS_SIDE_BOTTOM:
mBottomContBorderWidth = aPixelValue;
return;
default:
NS_ERROR("invalid side arg");
}
}
NS_METHOD nsTableColFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsTableColFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
aDesiredSize.width=0;
aDesiredSize.height=0;
const nsStyleVisibility* colVis = GetStyleVisibility();
bool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
if (collapseCol) {
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
tableFrame->SetNeedToCollapse(true);
}
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return NS_OK;
}
int32_t nsTableColFrame::GetSpan()
{
return GetStyleTable()->mSpan;
}
#ifdef DEBUG
void nsTableColFrame::Dump(int32_t aIndent)
{
char* indent = new char[aIndent + 1];
if (!indent) return;
for (int32_t i = 0; i < aIndent + 1; i++) {
indent[i] = ' ';
}
indent[aIndent] = 0;
printf("%s**START COL DUMP**\n%s colIndex=%d coltype=",
indent, indent, mColIndex);
nsTableColType colType = GetColType();
switch (colType) {
case eColContent:
printf(" content ");
break;
case eColAnonymousCol:
printf(" anonymous-column ");
break;
case eColAnonymousColGroup:
printf(" anonymous-colgroup ");
break;
case eColAnonymousCell:
printf(" anonymous-cell ");
break;
}
printf("\nm:%d c:%d(%c) p:%f sm:%d sc:%d sp:%f f:%d",
int32_t(mMinCoord), int32_t(mPrefCoord),
mHasSpecifiedCoord ? 's' : 'u', mPrefPercent,
int32_t(mSpanMinCoord), int32_t(mSpanPrefCoord),
mSpanPrefPercent,
int32_t(GetFinalWidth()));
printf("\n%s**END COL DUMP** ", indent);
delete [] indent;
}
#endif
/* ----- global methods ----- */
nsTableColFrame*
NS_NewTableColFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
return new (aPresShell) nsTableColFrame(aContext);
}
NS_IMPL_FRAMEARENA_HELPERS(nsTableColFrame)
nsTableColFrame*
nsTableColFrame::GetNextCol() const
{
nsIFrame* childFrame = GetNextSibling();
while (childFrame) {
if (nsGkAtoms::tableColFrame == childFrame->GetType()) {
return (nsTableColFrame*)childFrame;
}
childFrame = childFrame->GetNextSibling();
}
return nullptr;
}
nsIAtom*
nsTableColFrame::GetType() const
{
return nsGkAtoms::tableColFrame;
}
#ifdef DEBUG
NS_IMETHODIMP
nsTableColFrame::GetFrameName(nsAString& aResult) const
{
return MakeFrameName(NS_LITERAL_STRING("TableCol"), aResult);
}
#endif
nsSplittableType
nsTableColFrame::GetSplittableType() const
{
return NS_FRAME_NOT_SPLITTABLE;
}