Save 8 bytes per table cell frame by eliminating mCollapseOffset and
using a frame property instead.
This commit is contained in:
troy%netscape.com 1999-10-22 02:06:22 +00:00
Родитель 2234776b85
Коммит 5d86678e7b
13 изменённых файлов: 184 добавлений и 47 удалений

Просмотреть файл

@ -100,8 +100,9 @@ LAYOUT_ATOM(textFrame, "TextFrame")
LAYOUT_ATOM(viewportFrame, "ViewportFrame")
// Alphabetical list of frame property names
LAYOUT_ATOM(overflowProperty, "OverflowProperty")
LAYOUT_ATOM(collapseOffsetProperty, "CollapseOffsetProperty")
LAYOUT_ATOM(maxElementSizeProperty, "MaxElementSizeProperty")
LAYOUT_ATOM(overflowProperty, "OverflowProperty")
#ifdef DEBUG
// Alphabetical list of atoms used by debugging code

Просмотреть файл

@ -100,8 +100,9 @@ LAYOUT_ATOM(textFrame, "TextFrame")
LAYOUT_ATOM(viewportFrame, "ViewportFrame")
// Alphabetical list of frame property names
LAYOUT_ATOM(overflowProperty, "OverflowProperty")
LAYOUT_ATOM(collapseOffsetProperty, "CollapseOffsetProperty")
LAYOUT_ATOM(maxElementSizeProperty, "MaxElementSizeProperty")
LAYOUT_ATOM(overflowProperty, "OverflowProperty")
#ifdef DEBUG
// Alphabetical list of atoms used by debugging code

Просмотреть файл

@ -100,8 +100,9 @@ LAYOUT_ATOM(textFrame, "TextFrame")
LAYOUT_ATOM(viewportFrame, "ViewportFrame")
// Alphabetical list of frame property names
LAYOUT_ATOM(overflowProperty, "OverflowProperty")
LAYOUT_ATOM(collapseOffsetProperty, "CollapseOffsetProperty")
LAYOUT_ATOM(maxElementSizeProperty, "MaxElementSizeProperty")
LAYOUT_ATOM(overflowProperty, "OverflowProperty")
#ifdef DEBUG
// Alphabetical list of atoms used by debugging code

Просмотреть файл

@ -462,10 +462,10 @@ nsContainerFrame::GetOverflowFrames(nsIPresContext* aPresContext,
PRBool aRemoveProperty)
{
nsCOMPtr<nsIPresShell> presShell;
nsCOMPtr<nsIFrameManager> frameManager;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
if (frameManager) {
@ -503,11 +503,11 @@ nsContainerFrame::SetOverflowFrames(nsIPresContext* aPresContext,
nsIFrame* aOverflowFrames)
{
nsCOMPtr<nsIPresShell> presShell;
nsCOMPtr<nsIFrameManager> frameManager;
nsresult rv = NS_ERROR_FAILURE;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
if (frameManager) {

Просмотреть файл

@ -462,10 +462,10 @@ nsContainerFrame::GetOverflowFrames(nsIPresContext* aPresContext,
PRBool aRemoveProperty)
{
nsCOMPtr<nsIPresShell> presShell;
nsCOMPtr<nsIFrameManager> frameManager;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
if (frameManager) {
@ -503,11 +503,11 @@ nsContainerFrame::SetOverflowFrames(nsIPresContext* aPresContext,
nsIFrame* aOverflowFrames)
{
nsCOMPtr<nsIPresShell> presShell;
nsCOMPtr<nsIFrameManager> frameManager;
nsresult rv = NS_ERROR_FAILURE;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
if (frameManager) {

Просмотреть файл

@ -36,6 +36,8 @@
#include "nsIView.h"
#include "nsStyleUtil.h"
#include "nsLayoutAtoms.h"
#include "nsIFrameManager.h"
#include "nsIPresShell.h"
#include "nsCOMPtr.h"
#include "nsIHTMLTableCellElement.h"
#include "nsIDOMHTMLTableCellElement.h"
@ -162,7 +164,6 @@ void nsTableCellFrame::InitCellFrame(PRInt32 aColIndex)
mBorderEdges->mEdges[NS_SIDE_BOTTOM].AppendElement(borderToAdd);
}
}
mCollapseOffset = nsPoint(0,0);
}
}
@ -280,7 +281,8 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext,
// the rendering context.
PRBool clipState;
aRenderingContext.PushState();
nsPoint offset = mCollapseOffset;
nsPoint offset;
GetCollapseOffset(&aPresContext, offset);
if ((0 != offset.x) || (0 != offset.y)) {
aRenderingContext.Translate(offset.x, offset.y);
}
@ -1119,19 +1121,84 @@ nsTableCellFrame::GetFrameName(nsString& aResult) const
return MakeFrameName("TableCell", aResult);
}
void nsTableCellFrame::SetCollapseOffsetX(nscoord aXOffset)
// Destructor function for the collapse offset frame property
static void
DestroyPointFunc(nsIPresContext* aPresContext,
nsIFrame* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
{
mCollapseOffset.x = aXOffset;
delete (nsPoint*)aPropertyValue;
}
void nsTableCellFrame::SetCollapseOffsetY(nscoord aYOffset)
static nsPoint*
GetCollapseOffsetProperty(nsIPresContext* aPresContext,
nsIFrame* aFrame,
PRBool aCreateIfNecessary = PR_FALSE)
{
mCollapseOffset.y = aYOffset;
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
if (frameManager) {
void* value;
frameManager->GetFrameProperty(aFrame, nsLayoutAtoms::collapseOffsetProperty,
0, &value);
if (value) {
return (nsPoint*)value; // the property already exists
} else if (aCreateIfNecessary) {
// The property isn't set yet, so allocate a new point, set the property,
// and return the newly allocated point
nsPoint* offset = new nsPoint(0, 0);
frameManager->SetFrameProperty(aFrame, nsLayoutAtoms::collapseOffsetProperty,
offset, DestroyPointFunc);
return offset;
}
}
}
return nsnull;
}
nsPoint nsTableCellFrame::GetCollapseOffset()
void nsTableCellFrame::SetCollapseOffsetX(nsIPresContext* aPresContext,
nscoord aXOffset)
{
return mCollapseOffset;
// Get the frame property (creating a point struct if necessary)
nsPoint* offset = ::GetCollapseOffsetProperty(aPresContext, this, PR_TRUE);
if (offset) {
offset->x = aXOffset;
}
}
void nsTableCellFrame::SetCollapseOffsetY(nsIPresContext* aPresContext,
nscoord aYOffset)
{
// Get the property (creating a point struct if necessary)
nsPoint* offset = ::GetCollapseOffsetProperty(aPresContext, this, PR_TRUE);
if (offset) {
offset->y = aYOffset;
}
}
void nsTableCellFrame::GetCollapseOffset(nsIPresContext* aPresContext,
nsPoint& aOffset)
{
// See if the property is set
nsPoint* offset = ::GetCollapseOffsetProperty(aPresContext, this);
if (offset) {
aOffset = *offset;
} else {
aOffset.MoveTo(0, 0);
}
}
#ifdef DEBUG

Просмотреть файл

@ -193,9 +193,9 @@ public:
void SetContentEmpty(PRBool aContentEmpty);
// The collapse offset is (0,0) except for cells originating in a row/col which is collapsed
void SetCollapseOffsetX(nscoord aXOffset);
void SetCollapseOffsetY(nscoord aYOffset);
nsPoint GetCollapseOffset();
void SetCollapseOffsetX(nsIPresContext* aPresContext, nscoord aXOffset);
void SetCollapseOffsetY(nsIPresContext* aPresContext, nscoord aYOffset);
void GetCollapseOffset(nsIPresContext* aPresContext, nsPoint& aOffset);
protected:
/** implement abstract method on nsHTMLContainerFrame */
@ -246,8 +246,6 @@ protected:
nsSize mPass1DesiredSize;
nsSize mPass1MaxElementSize;
nsPoint mCollapseOffset;
public:
nsBorderEdges *mBorderEdges; // one list of border segments for each side of the table frame
// used only for the collapsing border model

Просмотреть файл

@ -2655,7 +2655,8 @@ NS_METHOD nsTableFrame::AdjustForCollapsingRowGroup(nsIFrame* aRowGroupFrame,
return NS_OK;
}
NS_METHOD nsTableFrame::CollapseRowGroup(nsIFrame* aRowGroupFrame,
NS_METHOD nsTableFrame::CollapseRowGroup(nsIPresContext* aPresContext,
nsIFrame* aRowGroupFrame,
const nscoord& aYTotalOffset,
nscoord& aYGroupOffset, PRInt32& aRowX)
{
@ -2670,7 +2671,7 @@ NS_METHOD nsTableFrame::CollapseRowGroup(nsIFrame* aRowGroupFrame,
const nsStyleDisplay* rowDisplay;
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
CollapseRowGroup(rowFrame, aYTotalOffset, aYGroupOffset, aRowX);
CollapseRowGroup(aPresContext, rowFrame, aYTotalOffset, aYGroupOffset, aRowX);
}
else if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
nsRect rowRect;
@ -2689,7 +2690,7 @@ NS_METHOD nsTableFrame::CollapseRowGroup(nsIFrame* aRowGroupFrame,
nsRect cRect;
cFrame->GetRect(cRect);
cRect.height -= rowRect.height;
cFrame->SetCollapseOffsetY(-aYGroupOffset);
cFrame->SetCollapseOffsetY(aPresContext, -aYGroupOffset);
cFrame->SetRect(cRect);
}
cellFrame->GetNextSibling(&cellFrame);
@ -2763,7 +2764,7 @@ NS_METHOD nsTableFrame::AdjustForCollapsingRows(nsIPresContext& aPresContext,
const nsStyleDisplay* groupDisplay;
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
if (IsRowGroup(groupDisplay->mDisplay)) {
CollapseRowGroup(groupFrame, yTotalOffset, yGroupOffset, rowX);
CollapseRowGroup(&aPresContext, groupFrame, yTotalOffset, yGroupOffset, rowX);
}
yTotalOffset += yGroupOffset;
yGroupOffset = 0;
@ -2844,7 +2845,7 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext& aPresContext,
if (collapseGroup || collapseCol) {
if (lastCell != cellFrame) { // do it only once if there is a row span
cellRect.width -= colWidth;
cellFrame->SetCollapseOffsetX(-xOffset);
cellFrame->SetCollapseOffsetX(&aPresContext, -xOffset);
}
} else { // the cell is not in a collapsed col but needs to move
cellRect.x -= xOffset;

Просмотреть файл

@ -565,7 +565,8 @@ protected:
NS_METHOD AdjustForCollapsingRowGroup(nsIFrame* aRowGroupFrame,
PRInt32& aRowX);
NS_METHOD CollapseRowGroup(nsIFrame* aRowGroupFrame,
NS_METHOD CollapseRowGroup(nsIPresContext* aPresContext,
nsIFrame* aRowGroupFrame,
const nscoord& aYTotalOffset,
nscoord& aYGroupOffset, PRInt32& aRowX);

Просмотреть файл

@ -36,6 +36,8 @@
#include "nsIView.h"
#include "nsStyleUtil.h"
#include "nsLayoutAtoms.h"
#include "nsIFrameManager.h"
#include "nsIPresShell.h"
#include "nsCOMPtr.h"
#include "nsIHTMLTableCellElement.h"
#include "nsIDOMHTMLTableCellElement.h"
@ -162,7 +164,6 @@ void nsTableCellFrame::InitCellFrame(PRInt32 aColIndex)
mBorderEdges->mEdges[NS_SIDE_BOTTOM].AppendElement(borderToAdd);
}
}
mCollapseOffset = nsPoint(0,0);
}
}
@ -280,7 +281,8 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext,
// the rendering context.
PRBool clipState;
aRenderingContext.PushState();
nsPoint offset = mCollapseOffset;
nsPoint offset;
GetCollapseOffset(&aPresContext, offset);
if ((0 != offset.x) || (0 != offset.y)) {
aRenderingContext.Translate(offset.x, offset.y);
}
@ -1119,19 +1121,84 @@ nsTableCellFrame::GetFrameName(nsString& aResult) const
return MakeFrameName("TableCell", aResult);
}
void nsTableCellFrame::SetCollapseOffsetX(nscoord aXOffset)
// Destructor function for the collapse offset frame property
static void
DestroyPointFunc(nsIPresContext* aPresContext,
nsIFrame* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
{
mCollapseOffset.x = aXOffset;
delete (nsPoint*)aPropertyValue;
}
void nsTableCellFrame::SetCollapseOffsetY(nscoord aYOffset)
static nsPoint*
GetCollapseOffsetProperty(nsIPresContext* aPresContext,
nsIFrame* aFrame,
PRBool aCreateIfNecessary = PR_FALSE)
{
mCollapseOffset.y = aYOffset;
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
if (frameManager) {
void* value;
frameManager->GetFrameProperty(aFrame, nsLayoutAtoms::collapseOffsetProperty,
0, &value);
if (value) {
return (nsPoint*)value; // the property already exists
} else if (aCreateIfNecessary) {
// The property isn't set yet, so allocate a new point, set the property,
// and return the newly allocated point
nsPoint* offset = new nsPoint(0, 0);
frameManager->SetFrameProperty(aFrame, nsLayoutAtoms::collapseOffsetProperty,
offset, DestroyPointFunc);
return offset;
}
}
}
return nsnull;
}
nsPoint nsTableCellFrame::GetCollapseOffset()
void nsTableCellFrame::SetCollapseOffsetX(nsIPresContext* aPresContext,
nscoord aXOffset)
{
return mCollapseOffset;
// Get the frame property (creating a point struct if necessary)
nsPoint* offset = ::GetCollapseOffsetProperty(aPresContext, this, PR_TRUE);
if (offset) {
offset->x = aXOffset;
}
}
void nsTableCellFrame::SetCollapseOffsetY(nsIPresContext* aPresContext,
nscoord aYOffset)
{
// Get the property (creating a point struct if necessary)
nsPoint* offset = ::GetCollapseOffsetProperty(aPresContext, this, PR_TRUE);
if (offset) {
offset->y = aYOffset;
}
}
void nsTableCellFrame::GetCollapseOffset(nsIPresContext* aPresContext,
nsPoint& aOffset)
{
// See if the property is set
nsPoint* offset = ::GetCollapseOffsetProperty(aPresContext, this);
if (offset) {
aOffset = *offset;
} else {
aOffset.MoveTo(0, 0);
}
}
#ifdef DEBUG

Просмотреть файл

@ -193,9 +193,9 @@ public:
void SetContentEmpty(PRBool aContentEmpty);
// The collapse offset is (0,0) except for cells originating in a row/col which is collapsed
void SetCollapseOffsetX(nscoord aXOffset);
void SetCollapseOffsetY(nscoord aYOffset);
nsPoint GetCollapseOffset();
void SetCollapseOffsetX(nsIPresContext* aPresContext, nscoord aXOffset);
void SetCollapseOffsetY(nsIPresContext* aPresContext, nscoord aYOffset);
void GetCollapseOffset(nsIPresContext* aPresContext, nsPoint& aOffset);
protected:
/** implement abstract method on nsHTMLContainerFrame */
@ -246,8 +246,6 @@ protected:
nsSize mPass1DesiredSize;
nsSize mPass1MaxElementSize;
nsPoint mCollapseOffset;
public:
nsBorderEdges *mBorderEdges; // one list of border segments for each side of the table frame
// used only for the collapsing border model

Просмотреть файл

@ -2655,7 +2655,8 @@ NS_METHOD nsTableFrame::AdjustForCollapsingRowGroup(nsIFrame* aRowGroupFrame,
return NS_OK;
}
NS_METHOD nsTableFrame::CollapseRowGroup(nsIFrame* aRowGroupFrame,
NS_METHOD nsTableFrame::CollapseRowGroup(nsIPresContext* aPresContext,
nsIFrame* aRowGroupFrame,
const nscoord& aYTotalOffset,
nscoord& aYGroupOffset, PRInt32& aRowX)
{
@ -2670,7 +2671,7 @@ NS_METHOD nsTableFrame::CollapseRowGroup(nsIFrame* aRowGroupFrame,
const nsStyleDisplay* rowDisplay;
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
CollapseRowGroup(rowFrame, aYTotalOffset, aYGroupOffset, aRowX);
CollapseRowGroup(aPresContext, rowFrame, aYTotalOffset, aYGroupOffset, aRowX);
}
else if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
nsRect rowRect;
@ -2689,7 +2690,7 @@ NS_METHOD nsTableFrame::CollapseRowGroup(nsIFrame* aRowGroupFrame,
nsRect cRect;
cFrame->GetRect(cRect);
cRect.height -= rowRect.height;
cFrame->SetCollapseOffsetY(-aYGroupOffset);
cFrame->SetCollapseOffsetY(aPresContext, -aYGroupOffset);
cFrame->SetRect(cRect);
}
cellFrame->GetNextSibling(&cellFrame);
@ -2763,7 +2764,7 @@ NS_METHOD nsTableFrame::AdjustForCollapsingRows(nsIPresContext& aPresContext,
const nsStyleDisplay* groupDisplay;
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
if (IsRowGroup(groupDisplay->mDisplay)) {
CollapseRowGroup(groupFrame, yTotalOffset, yGroupOffset, rowX);
CollapseRowGroup(&aPresContext, groupFrame, yTotalOffset, yGroupOffset, rowX);
}
yTotalOffset += yGroupOffset;
yGroupOffset = 0;
@ -2844,7 +2845,7 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext& aPresContext,
if (collapseGroup || collapseCol) {
if (lastCell != cellFrame) { // do it only once if there is a row span
cellRect.width -= colWidth;
cellFrame->SetCollapseOffsetX(-xOffset);
cellFrame->SetCollapseOffsetX(&aPresContext, -xOffset);
}
} else { // the cell is not in a collapsed col but needs to move
cellRect.x -= xOffset;

Просмотреть файл

@ -565,7 +565,8 @@ protected:
NS_METHOD AdjustForCollapsingRowGroup(nsIFrame* aRowGroupFrame,
PRInt32& aRowX);
NS_METHOD CollapseRowGroup(nsIFrame* aRowGroupFrame,
NS_METHOD CollapseRowGroup(nsIPresContext* aPresContext,
nsIFrame* aRowGroupFrame,
const nscoord& aYTotalOffset,
nscoord& aYGroupOffset, PRInt32& aRowX);