mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-07 20:17:37 +00:00
126 lines
3.9 KiB
C++
126 lines
3.9 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
*
|
|
* The contents of this file are subject to the Netscape Public License
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
* http://www.mozilla.org/NPL/
|
|
*
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
* for the specific language governing rights and limitations under the
|
|
* NPL.
|
|
*
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
* Communications Corporation. Portions created by Netscape are
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
* Reserved.
|
|
*/
|
|
#if 0
|
|
#include "nsCSSLayout.h"
|
|
#include "nsIStyleContext.h"
|
|
#include "nsStyleConsts.h"
|
|
#include "nsIContent.h"
|
|
#include "nsIFrame.h"
|
|
#include "nsIHTMLReflow.h"
|
|
#include "nsIFontMetrics.h"
|
|
#include "nsIPresContext.h"
|
|
#include "nsRect.h"
|
|
#include "nsIPtr.h"
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
NS_DEF_PTR(nsIStyleContext);
|
|
NS_DEF_PTR(nsIContent);
|
|
|
|
/**
|
|
* Horizontally place the children in the container frame.
|
|
*/
|
|
void
|
|
nsCSSLayout::HorizontallyPlaceChildren(nsIPresContext* aCX,
|
|
nsIFrame* aContainer,
|
|
PRInt32 aTextAlign,
|
|
PRInt32 aDirection,
|
|
nsIFrame* aFirstChild,
|
|
PRInt32 aChildCount,
|
|
nscoord aLineWidth,
|
|
nscoord aMaxWidth)
|
|
{
|
|
if (aLineWidth < aMaxWidth) {
|
|
nscoord dx = 0;
|
|
switch (aTextAlign) {
|
|
case NS_STYLE_TEXT_ALIGN_DEFAULT:
|
|
if (NS_STYLE_DIRECTION_LTR == aDirection) {
|
|
// default alignment for left-to-right is left so do nothing
|
|
return;
|
|
}
|
|
// Fall through to align right case for default alignment
|
|
// used when the direction is right-to-left.
|
|
|
|
case NS_STYLE_TEXT_ALIGN_RIGHT:
|
|
dx = aMaxWidth - aLineWidth;
|
|
break;
|
|
|
|
case NS_STYLE_TEXT_ALIGN_LEFT:
|
|
case NS_STYLE_TEXT_ALIGN_JUSTIFY:
|
|
// Default layout has everything aligned left
|
|
return;
|
|
|
|
case NS_STYLE_TEXT_ALIGN_CENTER:
|
|
dx = (aMaxWidth - aLineWidth) / 2;
|
|
break;
|
|
}
|
|
|
|
// Position children
|
|
nsPoint origin;
|
|
nsIFrame* kid = aFirstChild;
|
|
while (--aChildCount >= 0) {
|
|
kid->GetOrigin(origin);
|
|
kid->MoveTo(origin.x + dx, origin.y);
|
|
kid->GetNextSibling(kid);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Apply css relative positioning to any child that requires it.
|
|
*/
|
|
void
|
|
nsCSSLayout::RelativePositionChildren(nsIPresContext* aCX,
|
|
nsIFrame* aContainer,
|
|
nsIFrame* aFirstChild,
|
|
PRInt32 aChildCount)
|
|
{
|
|
nsPoint origin;
|
|
nsIFrame* kid = aFirstChild;
|
|
while (--aChildCount >= 0) {
|
|
const nsStylePosition* kidPosition;
|
|
kid->GetStyleData(eStyleStruct_Position,
|
|
(const nsStyleStruct*&)kidPosition);
|
|
if (NS_STYLE_POSITION_RELATIVE == kidPosition->mPosition) {
|
|
kid->GetOrigin(origin);
|
|
nscoord dx = 0;
|
|
switch (kidPosition->mLeftOffset.GetUnit()) {
|
|
case eStyleUnit_Percent:
|
|
printf("XXX: not yet implemented: % relative position\n");
|
|
case eStyleUnit_Auto:
|
|
break;
|
|
case eStyleUnit_Coord:
|
|
dx = kidPosition->mLeftOffset.GetCoordValue();
|
|
break;
|
|
}
|
|
nscoord dy = 0;
|
|
switch (kidPosition->mTopOffset.GetUnit()) {
|
|
case eStyleUnit_Percent:
|
|
printf("XXX: not yet implemented: % relative position\n");
|
|
case eStyleUnit_Auto:
|
|
break;
|
|
case eStyleUnit_Coord:
|
|
dy = kidPosition->mTopOffset.GetCoordValue();
|
|
break;
|
|
}
|
|
kid->MoveTo(origin.x + dx, origin.y + dy);
|
|
}
|
|
kid->GetNextSibling(kid);
|
|
}
|
|
}
|
|
#endif
|