2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#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"
|
|
|
|
|
2010-06-08 22:28:14 -07:00
|
|
|
#define COL_TYPE_BITS (NS_FRAME_STATE_BIT(28) | \
|
|
|
|
NS_FRAME_STATE_BIT(29) | \
|
|
|
|
NS_FRAME_STATE_BIT(30) | \
|
|
|
|
NS_FRAME_STATE_BIT(31))
|
2007-03-22 10:30:00 -07:00
|
|
|
#define COL_TYPE_OFFSET 28
|
|
|
|
|
2007-12-02 23:45:06 -08:00
|
|
|
nsTableColFrame::nsTableColFrame(nsStyleContext* aContext) :
|
|
|
|
nsSplittableFrame(aContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2007-12-02 23:45:06 -08:00
|
|
|
NS_ASSERTION(aType != eColAnonymousCol ||
|
|
|
|
(GetPrevContinuation() &&
|
|
|
|
GetPrevContinuation()->GetNextContinuation() == this &&
|
|
|
|
GetPrevContinuation()->GetNextSibling() == this),
|
|
|
|
"spanned content cols must be continuations");
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t type = aType - eColContent;
|
2014-02-04 17:59:39 -08:00
|
|
|
mState |= nsFrameState(type << COL_TYPE_OFFSET);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-10-26 03:11:34 -07:00
|
|
|
/* virtual */ void
|
|
|
|
nsTableColFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
|
|
|
{
|
2012-08-13 14:13:34 -07:00
|
|
|
nsSplittableFrame::DidSetStyleContext(aOldStyleContext);
|
|
|
|
|
2008-10-26 03:11:34 -07:00
|
|
|
if (!aOldStyleContext) //avoid this on init
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
2013-02-15 21:38:33 -08:00
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
|
2012-01-22 14:48:34 -08:00
|
|
|
nsIntRect damageArea(GetColIndex(), 0, 1, tableFrame->GetRowCount());
|
2011-10-27 06:58:44 -07:00
|
|
|
tableFrame->AddBCDamageArea(damageArea);
|
2008-10-26 03:11:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void nsTableColFrame::SetContinuousBCBorderWidth(uint8_t aForSide,
|
2007-03-22 10:30:00 -07:00
|
|
|
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);
|
2013-12-27 09:59:52 -08:00
|
|
|
aDesiredSize.Width() = 0;
|
|
|
|
aDesiredSize.Height() = 0;
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleVisibility* colVis = StyleVisibility();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (collapseCol) {
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2012-01-16 15:38:10 -08:00
|
|
|
tableFrame->SetNeedToCollapse(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t nsTableColFrame::GetSpan()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-16 13:51:02 -08:00
|
|
|
return StyleTable()->mSpan;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2012-08-22 08:56:38 -07:00
|
|
|
void nsTableColFrame::Dump(int32_t aIndent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
char* indent = new char[aIndent + 1];
|
|
|
|
if (!indent) return;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t i = 0; i < aIndent + 1; i++) {
|
2007-03-22 10:30:00 -07:00
|
|
|
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;
|
|
|
|
}
|
2008-01-17 20:18:21 -08:00
|
|
|
printf("\nm:%d c:%d(%c) p:%f sm:%d sc:%d sp:%f f:%d",
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t(mMinCoord), int32_t(mPrefCoord),
|
2012-01-22 14:48:34 -08:00
|
|
|
mHasSpecifiedCoord ? 's' : 'u', mPrefPercent,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t(mSpanMinCoord), int32_t(mSpanPrefCoord),
|
2007-03-22 10:30:00 -07:00
|
|
|
mSpanPrefPercent,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t(GetFinalWidth()));
|
2007-03-22 10:30:00 -07:00
|
|
|
printf("\n%s**END COL DUMP** ", indent);
|
|
|
|
delete [] indent;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
2007-11-18 10:56:49 -08:00
|
|
|
nsTableColFrame*
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_NewTableColFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsTableColFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableColFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableColFrame*
|
|
|
|
nsTableColFrame::GetNextCol() const
|
|
|
|
{
|
|
|
|
nsIFrame* childFrame = GetNextSibling();
|
|
|
|
while (childFrame) {
|
|
|
|
if (nsGkAtoms::tableColFrame == childFrame->GetType()) {
|
|
|
|
return (nsTableColFrame*)childFrame;
|
|
|
|
}
|
|
|
|
childFrame = childFrame->GetNextSibling();
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsTableColFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::tableColFrame;
|
|
|
|
}
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableColFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableCol"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
2007-12-02 23:45:06 -08:00
|
|
|
|
|
|
|
nsSplittableType
|
|
|
|
nsTableColFrame::GetSplittableType() const
|
|
|
|
{
|
|
|
|
return NS_FRAME_NOT_SPLITTABLE;
|
|
|
|
}
|
|
|
|
|
2012-08-28 22:39:31 -07:00
|
|
|
void
|
2012-08-28 22:48:45 -07:00
|
|
|
nsTableColFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
2012-08-28 22:39:31 -07:00
|
|
|
{
|
2012-08-28 22:48:45 -07:00
|
|
|
nsIFrame::InvalidateFrame(aDisplayItemKey);
|
|
|
|
GetParent()->InvalidateFrameWithRect(GetVisualOverflowRect() + GetPosition(), aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableColFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
nsIFrame::InvalidateFrameWithRect(aRect, aDisplayItemKey);
|
|
|
|
|
|
|
|
// If we have filters applied that would affects our bounds, then
|
|
|
|
// we get an inactive layer created and this is computed
|
|
|
|
// within FrameLayerBuilder
|
|
|
|
GetParent()->InvalidateFrameWithRect(aRect + GetPosition(), aDisplayItemKey);
|
2012-08-28 22:39:31 -07:00
|
|
|
}
|
|
|
|
|