2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2001-06-01 02:19:43 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
2001-06-01 02:19:43 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2001-06-01 02:19:43 +04:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-06-01 02:19:43 +04:00
|
|
|
*
|
2001-09-25 05:32:19 +04:00
|
|
|
* Contributor(s):
|
2001-06-01 02:19:43 +04:00
|
|
|
* David Hyatt (hyatt@netscape.com
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2002-07-03 21:14:41 +04:00
|
|
|
#include "nsStyleStruct.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsUnitConversion.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIStyleRule.h"
|
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIStyleSet.h"
|
|
|
|
#include "nsIPresShell.h"
|
2001-10-24 04:01:09 +04:00
|
|
|
#include "nsIFrame.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
#include "nsLayoutAtoms.h"
|
|
|
|
#include "prenv.h"
|
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
2002-02-19 23:41:32 +03:00
|
|
|
#include "nsBidiUtils.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
inline PRBool IsFixedUnit(nsStyleUnit aUnit, PRBool aEnumOK)
|
|
|
|
{
|
|
|
|
return PRBool((aUnit == eStyleUnit_Null) ||
|
|
|
|
(aUnit == eStyleUnit_Coord) ||
|
|
|
|
(aEnumOK && (aUnit == eStyleUnit_Enumerated)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX this is here to support deprecated calc spacing methods only
|
|
|
|
inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
|
|
|
|
PRUint8 aSpacing, PRUint8 aSide,
|
|
|
|
const nscoord* aEnumTable, PRInt32 aNumEnums)
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
|
|
|
|
switch (aCoord.GetUnit()) {
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
// Auto margins are handled by layout
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Inherit:
|
|
|
|
nsIFrame* parentFrame;
|
|
|
|
aFrame->GetParent(&parentFrame); // XXX may not be direct parent...
|
|
|
|
if (nsnull != parentFrame) {
|
|
|
|
nsIStyleContext* parentContext;
|
|
|
|
parentFrame->GetStyleContext(&parentContext);
|
|
|
|
if (nsnull != parentContext) {
|
|
|
|
nsMargin parentSpacing;
|
|
|
|
switch (aSpacing) {
|
|
|
|
case NS_SPACING_MARGIN:
|
|
|
|
{
|
|
|
|
const nsStyleMargin* parentMargin = (const nsStyleMargin*)parentContext->GetStyleData(eStyleStruct_Margin);
|
|
|
|
parentMargin->CalcMarginFor(parentFrame, parentSpacing);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NS_SPACING_PADDING:
|
|
|
|
{
|
|
|
|
const nsStylePadding* parentPadding = (const nsStylePadding*)parentContext->GetStyleData(eStyleStruct_Padding);
|
|
|
|
parentPadding->CalcPaddingFor(parentFrame, parentSpacing);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NS_SPACING_BORDER:
|
|
|
|
{
|
|
|
|
const nsStyleBorder* parentBorder = (const nsStyleBorder*)parentContext->GetStyleData(eStyleStruct_Border);
|
|
|
|
parentBorder->CalcBorderFor(parentFrame, parentSpacing);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (aSide) {
|
|
|
|
case NS_SIDE_LEFT: result = parentSpacing.left; break;
|
|
|
|
case NS_SIDE_TOP: result = parentSpacing.top; break;
|
|
|
|
case NS_SIDE_RIGHT: result = parentSpacing.right; break;
|
|
|
|
case NS_SIDE_BOTTOM: result = parentSpacing.bottom; break;
|
|
|
|
}
|
|
|
|
NS_RELEASE(parentContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Percent:
|
|
|
|
{
|
|
|
|
nscoord baseWidth = 0;
|
|
|
|
PRBool isBase = PR_FALSE;
|
|
|
|
nsIFrame* frame;
|
|
|
|
aFrame->GetParent(&frame);
|
|
|
|
while (nsnull != frame) {
|
|
|
|
frame->IsPercentageBase(isBase);
|
|
|
|
if (isBase) {
|
|
|
|
nsSize size;
|
|
|
|
frame->GetSize(size);
|
2001-11-10 20:29:04 +03:00
|
|
|
baseWidth = size.width;
|
|
|
|
// subtract border of containing block
|
|
|
|
const nsStyleBorder* borderData = nsnull;
|
|
|
|
frame->GetStyleData(eStyleStruct_Border,
|
|
|
|
(const nsStyleStruct*&)borderData);
|
|
|
|
if (borderData) {
|
|
|
|
nsMargin border;
|
2001-11-11 06:56:49 +03:00
|
|
|
borderData->CalcBorderFor(frame, border);
|
|
|
|
baseWidth -= (border.left + border.right);
|
2001-11-10 20:29:04 +03:00
|
|
|
}
|
|
|
|
// if aFrame is not absolutely positioned, subtract
|
|
|
|
// padding of containing block
|
|
|
|
const nsStyleDisplay* displayData = nsnull;
|
|
|
|
aFrame->GetStyleData(eStyleStruct_Display,
|
|
|
|
(const nsStyleStruct*&)displayData);
|
|
|
|
if (displayData &&
|
|
|
|
displayData->mPosition != NS_STYLE_POSITION_ABSOLUTE &&
|
|
|
|
displayData->mPosition != NS_STYLE_POSITION_FIXED) {
|
|
|
|
const nsStylePadding* paddingData = nsnull;
|
|
|
|
frame->GetStyleData(eStyleStruct_Padding,
|
|
|
|
(const nsStyleStruct*&)paddingData);
|
|
|
|
if (paddingData) {
|
|
|
|
nsMargin padding;
|
|
|
|
paddingData->CalcPaddingFor(frame, padding);
|
|
|
|
baseWidth -= (padding.left + padding.right);
|
|
|
|
}
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
frame->GetParent(&frame);
|
|
|
|
}
|
|
|
|
result = (nscoord)((float)baseWidth * aCoord.GetPercentValue());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
result = aCoord.GetCoordValue();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Enumerated:
|
|
|
|
if (nsnull != aEnumTable) {
|
|
|
|
PRInt32 value = aCoord.GetIntValue();
|
|
|
|
if ((0 <= value) && (value < aNumEnums)) {
|
|
|
|
return aEnumTable[aCoord.GetIntValue()];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Null:
|
|
|
|
case eStyleUnit_Normal:
|
|
|
|
case eStyleUnit_Integer:
|
|
|
|
case eStyleUnit_Proportional:
|
|
|
|
default:
|
|
|
|
result = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((NS_SPACING_PADDING == aSpacing) || (NS_SPACING_BORDER == aSpacing)) {
|
|
|
|
if (result < 0) {
|
|
|
|
result = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void CalcSidesFor(const nsIFrame* aFrame, const nsStyleSides& aSides,
|
|
|
|
PRUint8 aSpacing,
|
|
|
|
const nscoord* aEnumTable, PRInt32 aNumEnums,
|
|
|
|
nsMargin& aResult)
|
|
|
|
{
|
|
|
|
nsStyleCoord coord;
|
|
|
|
|
|
|
|
aResult.left = CalcSideFor(aFrame, aSides.GetLeft(coord), aSpacing, NS_SIDE_LEFT,
|
|
|
|
aEnumTable, aNumEnums);
|
|
|
|
aResult.top = CalcSideFor(aFrame, aSides.GetTop(coord), aSpacing, NS_SIDE_TOP,
|
|
|
|
aEnumTable, aNumEnums);
|
|
|
|
aResult.right = CalcSideFor(aFrame, aSides.GetRight(coord), aSpacing, NS_SIDE_RIGHT,
|
|
|
|
aEnumTable, aNumEnums);
|
|
|
|
aResult.bottom = CalcSideFor(aFrame, aSides.GetBottom(coord), aSpacing, NS_SIDE_BOTTOM,
|
|
|
|
aEnumTable, aNumEnums);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleFont
|
|
|
|
//
|
|
|
|
nsStyleFont::nsStyleFont()
|
2001-09-27 22:33:58 +04:00
|
|
|
: mFlags(NS_STYLE_FONT_DEFAULT),
|
|
|
|
mFont(nsnull, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
|
|
|
NS_FONT_WEIGHT_NORMAL, NS_FONT_DECORATION_NONE, 0),
|
|
|
|
mSize(0)
|
2001-06-01 02:19:43 +04:00
|
|
|
{ }
|
|
|
|
|
2001-09-27 22:33:58 +04:00
|
|
|
nsStyleFont::nsStyleFont(const nsFont& aFont)
|
|
|
|
: mFlags(NS_STYLE_FONT_DEFAULT),
|
2002-02-16 19:24:25 +03:00
|
|
|
mFont(aFont),
|
|
|
|
mSize(aFont.size)
|
2001-09-27 22:33:58 +04:00
|
|
|
{
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
nsStyleFont::nsStyleFont(const nsStyleFont& aSrc)
|
2002-02-16 19:24:25 +03:00
|
|
|
: mFlags(aSrc.mFlags),
|
|
|
|
mFont(aSrc.mFont),
|
|
|
|
mSize(aSrc.mSize)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2002-07-03 00:25:30 +04:00
|
|
|
nsStyleFont::operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW {
|
2001-06-01 02:19:43 +04:00
|
|
|
void* result = nsnull;
|
|
|
|
aContext->AllocateFromShell(sz, &result);
|
|
|
|
if (result)
|
2002-01-30 05:55:57 +03:00
|
|
|
memset(result, 0, sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleFont::Destroy(nsIPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStyleFont();
|
2001-06-01 02:19:43 +04:00
|
|
|
aContext->FreeToShell(sizeof(nsStyleFont), this);
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2001-09-27 22:33:58 +04:00
|
|
|
if (mSize == aOther.mSize) {
|
|
|
|
return CalcFontDifference(mFont, aOther.mFont);
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleFont::CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if ((aFont1.size == aFont2.size) &&
|
2001-09-27 22:33:58 +04:00
|
|
|
(aFont1.sizeAdjust == aFont2.sizeAdjust) &&
|
2001-06-01 02:19:43 +04:00
|
|
|
(aFont1.style == aFont2.style) &&
|
|
|
|
(aFont1.variant == aFont2.variant) &&
|
2002-11-12 18:17:07 +03:00
|
|
|
(aFont1.familyNameQuirks == aFont2.familyNameQuirks) &&
|
2001-06-01 02:19:43 +04:00
|
|
|
(aFont1.weight == aFont2.weight) &&
|
2001-09-24 19:26:39 +04:00
|
|
|
(aFont1.name == aFont2.name)) {
|
2001-06-01 02:19:43 +04:00
|
|
|
if ((aFont1.decorations == aFont2.decorations)) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PRBool IsFixedData(const nsStyleSides& aSides, PRBool aEnumOK)
|
|
|
|
{
|
|
|
|
return PRBool(IsFixedUnit(aSides.GetLeftUnit(), aEnumOK) &&
|
|
|
|
IsFixedUnit(aSides.GetTopUnit(), aEnumOK) &&
|
|
|
|
IsFixedUnit(aSides.GetRightUnit(), aEnumOK) &&
|
|
|
|
IsFixedUnit(aSides.GetBottomUnit(), aEnumOK));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nscoord CalcCoord(const nsStyleCoord& aCoord,
|
|
|
|
const nscoord* aEnumTable,
|
|
|
|
PRInt32 aNumEnums)
|
|
|
|
{
|
|
|
|
switch (aCoord.GetUnit()) {
|
|
|
|
case eStyleUnit_Null:
|
|
|
|
return 0;
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
return aCoord.GetCoordValue();
|
|
|
|
case eStyleUnit_Enumerated:
|
|
|
|
if (nsnull != aEnumTable) {
|
|
|
|
PRInt32 value = aCoord.GetIntValue();
|
|
|
|
if ((0 <= value) && (value < aNumEnums)) {
|
|
|
|
return aEnumTable[aCoord.GetIntValue()];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_ERROR("bad unit type");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleMargin::nsStyleMargin() {
|
|
|
|
mMargin.Reset();
|
|
|
|
mHasCachedMargin = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleMargin::nsStyleMargin(const nsStyleMargin& aSrc) {
|
|
|
|
mMargin = aSrc.mMargin;
|
|
|
|
mHasCachedMargin = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2002-07-03 00:25:30 +04:00
|
|
|
nsStyleMargin::operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW {
|
2001-06-01 02:19:43 +04:00
|
|
|
void* result = nsnull;
|
|
|
|
aContext->AllocateFromShell(sz, &result);
|
|
|
|
if (result)
|
2002-01-30 05:55:57 +03:00
|
|
|
memset(result, 0, sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleMargin::Destroy(nsIPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStyleMargin();
|
2001-06-01 02:19:43 +04:00
|
|
|
aContext->FreeToShell(sizeof(nsStyleMargin), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nsStyleMargin::RecalcData()
|
|
|
|
{
|
|
|
|
if (IsFixedData(mMargin, PR_FALSE)) {
|
|
|
|
nsStyleCoord coord;
|
|
|
|
mCachedMargin.left = CalcCoord(mMargin.GetLeft(coord), nsnull, 0);
|
|
|
|
mCachedMargin.top = CalcCoord(mMargin.GetTop(coord), nsnull, 0);
|
|
|
|
mCachedMargin.right = CalcCoord(mMargin.GetRight(coord), nsnull, 0);
|
|
|
|
mCachedMargin.bottom = CalcCoord(mMargin.GetBottom(coord), nsnull, 0);
|
|
|
|
|
|
|
|
mHasCachedMargin = PR_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mHasCachedMargin = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleMargin::CalcDifference(const nsStyleMargin& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if (mMargin == aOther.mMargin) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleMargin::CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const
|
|
|
|
{
|
|
|
|
if (mHasCachedMargin) {
|
|
|
|
aMargin = mCachedMargin;
|
|
|
|
} else {
|
|
|
|
CalcSidesFor(aFrame, mMargin, NS_SPACING_MARGIN, nsnull, 0, aMargin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePadding::nsStylePadding() {
|
|
|
|
mPadding.Reset();
|
|
|
|
mHasCachedPadding = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePadding::nsStylePadding(const nsStylePadding& aSrc) {
|
|
|
|
mPadding = aSrc.mPadding;
|
|
|
|
mHasCachedPadding = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2002-07-03 00:25:30 +04:00
|
|
|
nsStylePadding::operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW {
|
2001-06-01 02:19:43 +04:00
|
|
|
void* result = nsnull;
|
|
|
|
aContext->AllocateFromShell(sz, &result);
|
|
|
|
if (result)
|
2002-01-30 05:55:57 +03:00
|
|
|
memset(result, 0, sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStylePadding::Destroy(nsIPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStylePadding();
|
2001-06-01 02:19:43 +04:00
|
|
|
aContext->FreeToShell(sizeof(nsStylePadding), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsStylePadding::RecalcData()
|
|
|
|
{
|
|
|
|
if (IsFixedData(mPadding, PR_FALSE)) {
|
|
|
|
nsStyleCoord coord;
|
|
|
|
mCachedPadding.left = CalcCoord(mPadding.GetLeft(coord), nsnull, 0);
|
|
|
|
mCachedPadding.top = CalcCoord(mPadding.GetTop(coord), nsnull, 0);
|
|
|
|
mCachedPadding.right = CalcCoord(mPadding.GetRight(coord), nsnull, 0);
|
|
|
|
mCachedPadding.bottom = CalcCoord(mPadding.GetBottom(coord), nsnull, 0);
|
|
|
|
|
|
|
|
mHasCachedPadding = PR_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mHasCachedPadding = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStylePadding::CalcDifference(const nsStylePadding& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if (mPadding == aOther.mPadding) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStylePadding::CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const
|
|
|
|
{
|
|
|
|
if (mHasCachedPadding) {
|
|
|
|
aPadding = mCachedPadding;
|
|
|
|
} else {
|
|
|
|
CalcSidesFor(aFrame, mPadding, NS_SPACING_PADDING, nsnull, 0, aPadding);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBorder::nsStyleBorder(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
// XXX support mBorderWidths until deprecated methods are removed
|
|
|
|
float pixelsToTwips = 20.0f;
|
|
|
|
if (aPresContext) {
|
|
|
|
aPresContext->GetPixelsToTwips(&pixelsToTwips);
|
|
|
|
}
|
|
|
|
mBorderWidths[NS_STYLE_BORDER_WIDTH_THIN] = NSIntPixelsToTwips(1, pixelsToTwips);
|
|
|
|
mBorderWidths[NS_STYLE_BORDER_WIDTH_MEDIUM] = NSIntPixelsToTwips(3, pixelsToTwips);
|
|
|
|
mBorderWidths[NS_STYLE_BORDER_WIDTH_THICK] = NSIntPixelsToTwips(5, pixelsToTwips);
|
|
|
|
|
|
|
|
// spacing values not inherited
|
|
|
|
nsStyleCoord medium(NS_STYLE_BORDER_WIDTH_MEDIUM, eStyleUnit_Enumerated);
|
|
|
|
mBorder.SetLeft(medium);
|
|
|
|
mBorder.SetTop(medium);
|
|
|
|
mBorder.SetRight(medium);
|
|
|
|
mBorder.SetBottom(medium);
|
|
|
|
|
|
|
|
mBorderStyle[0] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
mBorderStyle[1] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
mBorderStyle[2] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
mBorderStyle[3] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
|
|
|
|
mBorderColor[0] = NS_RGB(0, 0, 0);
|
|
|
|
mBorderColor[1] = NS_RGB(0, 0, 0);
|
|
|
|
mBorderColor[2] = NS_RGB(0, 0, 0);
|
|
|
|
mBorderColor[3] = NS_RGB(0, 0, 0);
|
|
|
|
|
2001-12-05 11:35:05 +03:00
|
|
|
mBorderColors = nsnull;
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
mBorderRadius.Reset();
|
|
|
|
|
|
|
|
mFloatEdge = NS_STYLE_FLOAT_EDGE_CONTENT;
|
|
|
|
|
|
|
|
mHasCachedBorder = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBorder::nsStyleBorder(const nsStyleBorder& aSrc)
|
|
|
|
{
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy((nsStyleBorder*)this, &aSrc, sizeof(nsStyleBorder));
|
2001-12-05 22:46:43 +03:00
|
|
|
mBorderColors = nsnull;
|
2001-12-05 11:35:05 +03:00
|
|
|
if (aSrc.mBorderColors) {
|
|
|
|
EnsureBorderColors();
|
|
|
|
for (PRInt32 i = 0; i < 4; i++)
|
|
|
|
if (aSrc.mBorderColors[i])
|
|
|
|
mBorderColors[i] = aSrc.mBorderColors[i]->CopyColors();
|
|
|
|
else
|
|
|
|
mBorderColors[i] = nsnull;
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
mHasCachedBorder = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2002-07-03 00:25:30 +04:00
|
|
|
nsStyleBorder::operator new(size_t sz, nsIPresContext* aContext) CPP_THROW_NEW {
|
2001-06-01 02:19:43 +04:00
|
|
|
void* result = nsnull;
|
|
|
|
aContext->AllocateFromShell(sz, &result);
|
|
|
|
if (result)
|
2002-01-30 05:55:57 +03:00
|
|
|
memset(result, 0, sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleBorder::Destroy(nsIPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStyleBorder();
|
2001-06-01 02:19:43 +04:00
|
|
|
aContext->FreeToShell(sizeof(nsStyleBorder), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRBool nsStyleBorder::IsBorderSideVisible(PRUint8 aSide) const
|
|
|
|
{
|
|
|
|
PRUint8 borderStyle = GetBorderStyle(aSide);
|
|
|
|
return ((borderStyle != NS_STYLE_BORDER_STYLE_NONE)
|
|
|
|
&& (borderStyle != NS_STYLE_BORDER_STYLE_HIDDEN));
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsStyleBorder::RecalcData()
|
|
|
|
{
|
|
|
|
if (((!IsBorderSideVisible(NS_SIDE_LEFT))||
|
|
|
|
IsFixedUnit(mBorder.GetLeftUnit(), PR_TRUE)) &&
|
|
|
|
((!IsBorderSideVisible(NS_SIDE_TOP)) ||
|
|
|
|
IsFixedUnit(mBorder.GetTopUnit(), PR_TRUE)) &&
|
|
|
|
((!IsBorderSideVisible(NS_SIDE_RIGHT)) ||
|
|
|
|
IsFixedUnit(mBorder.GetRightUnit(), PR_TRUE)) &&
|
|
|
|
((!IsBorderSideVisible(NS_SIDE_BOTTOM)) ||
|
|
|
|
IsFixedUnit(mBorder.GetBottomUnit(), PR_TRUE))) {
|
|
|
|
nsStyleCoord coord;
|
|
|
|
if (!IsBorderSideVisible(NS_SIDE_LEFT)) {
|
|
|
|
mCachedBorder.left = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mCachedBorder.left = CalcCoord(mBorder.GetLeft(coord), mBorderWidths, 3);
|
|
|
|
}
|
|
|
|
if (!IsBorderSideVisible(NS_SIDE_TOP)) {
|
|
|
|
mCachedBorder.top = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mCachedBorder.top = CalcCoord(mBorder.GetTop(coord), mBorderWidths, 3);
|
|
|
|
}
|
|
|
|
if (!IsBorderSideVisible(NS_SIDE_RIGHT)) {
|
|
|
|
mCachedBorder.right = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mCachedBorder.right = CalcCoord(mBorder.GetRight(coord), mBorderWidths, 3);
|
|
|
|
}
|
|
|
|
if (!IsBorderSideVisible(NS_SIDE_BOTTOM)) {
|
|
|
|
mCachedBorder.bottom = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mCachedBorder.bottom = CalcCoord(mBorder.GetBottom(coord), mBorderWidths, 3);
|
|
|
|
}
|
|
|
|
mHasCachedBorder = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mHasCachedBorder = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((mBorderStyle[NS_SIDE_TOP] & BORDER_COLOR_DEFINED) == 0) {
|
|
|
|
mBorderStyle[NS_SIDE_TOP] = BORDER_COLOR_DEFINED | BORDER_COLOR_FOREGROUND;
|
|
|
|
}
|
|
|
|
if ((mBorderStyle[NS_SIDE_BOTTOM] & BORDER_COLOR_DEFINED) == 0) {
|
|
|
|
mBorderStyle[NS_SIDE_BOTTOM] = BORDER_COLOR_DEFINED | BORDER_COLOR_FOREGROUND;
|
|
|
|
}
|
|
|
|
if ((mBorderStyle[NS_SIDE_LEFT]& BORDER_COLOR_DEFINED) == 0) {
|
|
|
|
mBorderStyle[NS_SIDE_LEFT] = BORDER_COLOR_DEFINED | BORDER_COLOR_FOREGROUND;
|
|
|
|
}
|
|
|
|
if ((mBorderStyle[NS_SIDE_RIGHT] & BORDER_COLOR_DEFINED) == 0) {
|
|
|
|
mBorderStyle[NS_SIDE_RIGHT] = BORDER_COLOR_DEFINED | BORDER_COLOR_FOREGROUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if ((mBorder == aOther.mBorder) &&
|
|
|
|
(mFloatEdge == aOther.mFloatEdge)) {
|
|
|
|
PRInt32 ix;
|
|
|
|
for (ix = 0; ix < 4; ix++) {
|
|
|
|
if ((mBorderStyle[ix] != aOther.mBorderStyle[ix]) ||
|
|
|
|
(mBorderColor[ix] != aOther.mBorderColor[ix])) {
|
|
|
|
if ((mBorderStyle[ix] != aOther.mBorderStyle[ix]) &&
|
|
|
|
((NS_STYLE_BORDER_STYLE_NONE == mBorderStyle[ix]) ||
|
|
|
|
(NS_STYLE_BORDER_STYLE_NONE == aOther.mBorderStyle[ix]) ||
|
|
|
|
(NS_STYLE_BORDER_STYLE_HIDDEN == mBorderStyle[ix]) || // bug 45754
|
|
|
|
(NS_STYLE_BORDER_STYLE_HIDDEN == aOther.mBorderStyle[ix]))) {
|
|
|
|
return NS_STYLE_HINT_REFLOW; // border on or off
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mBorderRadius != aOther.mBorderRadius) {
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
2001-12-19 14:59:31 +03:00
|
|
|
if (mBorderColors && !aOther.mBorderColors ||
|
|
|
|
!mBorderColors && aOther.mBorderColors) {
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mBorderColors && aOther.mBorderColors) {
|
|
|
|
for (ix = 0; ix < 4; ix++) {
|
|
|
|
if (mBorderColors[ix] && !aOther.mBorderColors[ix] ||
|
|
|
|
!mBorderColors[ix] && aOther.mBorderColors[ix]) {
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
} else if (mBorderColors[ix] && aOther.mBorderColors[ix]) {
|
|
|
|
if (!mBorderColors[ix]->Equals(aOther.mBorderColors[ix]))
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleBorder::CalcBorderFor(const nsIFrame* aFrame, nsMargin& aBorder) const
|
|
|
|
{
|
|
|
|
if (mHasCachedBorder) {
|
|
|
|
aBorder = mCachedBorder;
|
|
|
|
} else {
|
|
|
|
CalcSidesFor(aFrame, mBorder, NS_SPACING_BORDER, mBorderWidths, 3, aBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
void
|
|
|
|
nsStyleBorder::CalcBorderFor(const nsIFrame* aFrame, PRUint8 aSide, nscoord& aWidth) const
|
|
|
|
{
|
|
|
|
aWidth = 0;
|
|
|
|
// using mCachedBorder as above, doesn't work properly
|
|
|
|
nsStyleCoord coord;
|
|
|
|
switch(aSide) {
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
coord = mBorder.GetTop(coord);
|
|
|
|
break;
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
coord = mBorder.GetRight(coord);
|
|
|
|
break;
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
coord = mBorder.GetBottom(coord);
|
|
|
|
break;
|
|
|
|
default: // NS_SIDE_LEFT
|
|
|
|
coord = mBorder.GetLeft(coord);
|
|
|
|
}
|
|
|
|
aWidth = CalcSideFor(aFrame, coord, NS_SPACING_BORDER, aSide, mBorderWidths, 3);
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleOutline::nsStyleOutline(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
// XXX support mBorderWidths until deprecated methods are removed
|
|
|
|
float pixelsToTwips = 20.0f;
|
|
|
|
if (aPresContext)
|
|
|
|
aPresContext->GetPixelsToTwips(&pixelsToTwips);
|
|
|
|
mBorderWidths[NS_STYLE_BORDER_WIDTH_THIN] = NSIntPixelsToTwips(1, pixelsToTwips);
|
|
|
|
mBorderWidths[NS_STYLE_BORDER_WIDTH_MEDIUM] = NSIntPixelsToTwips(3, pixelsToTwips);
|
|
|
|
mBorderWidths[NS_STYLE_BORDER_WIDTH_THICK] = NSIntPixelsToTwips(5, pixelsToTwips);
|
|
|
|
|
|
|
|
// spacing values not inherited
|
|
|
|
mOutlineRadius.Reset();
|
|
|
|
|
|
|
|
nsStyleCoord medium(NS_STYLE_BORDER_WIDTH_MEDIUM, eStyleUnit_Enumerated);
|
|
|
|
mOutlineWidth = medium;
|
|
|
|
mOutlineStyle = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
mOutlineColor = NS_RGB(0, 0, 0);
|
|
|
|
|
|
|
|
mHasCachedOutline = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleOutline::nsStyleOutline(const nsStyleOutline& aSrc) {
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy((nsStyleOutline*)this, &aSrc, sizeof(nsStyleOutline));
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleOutline::RecalcData(void)
|
|
|
|
{
|
|
|
|
if ((NS_STYLE_BORDER_STYLE_NONE == GetOutlineStyle()) ||
|
|
|
|
IsFixedUnit(mOutlineWidth.GetUnit(), PR_TRUE)) {
|
|
|
|
if (NS_STYLE_BORDER_STYLE_NONE == GetOutlineStyle())
|
|
|
|
mCachedOutlineWidth = 0;
|
|
|
|
else
|
|
|
|
mCachedOutlineWidth = CalcCoord(mOutlineWidth, mBorderWidths, 3);
|
|
|
|
mHasCachedOutline = PR_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mHasCachedOutline = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleOutline::CalcDifference(const nsStyleOutline& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if ((mOutlineWidth != aOther.mOutlineWidth) ||
|
|
|
|
(mOutlineStyle != aOther.mOutlineStyle) ||
|
|
|
|
(mOutlineColor != aOther.mOutlineColor) ||
|
|
|
|
(mOutlineRadius != aOther.mOutlineRadius)) {
|
|
|
|
return NS_STYLE_HINT_VISUAL; // XXX: should be VISUAL: see bugs 9809 and 9816
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleList
|
|
|
|
//
|
|
|
|
nsStyleList::nsStyleList()
|
|
|
|
{
|
|
|
|
mListStyleType = NS_STYLE_LIST_STYLE_BASIC;
|
|
|
|
mListStylePosition = NS_STYLE_LIST_STYLE_POSITION_OUTSIDE;
|
|
|
|
mListStyleImage.Truncate();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::~nsStyleList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::nsStyleList(const nsStyleList& aSource)
|
|
|
|
{
|
|
|
|
mListStyleType = aSource.mListStyleType;
|
|
|
|
mListStylePosition = aSource.mListStylePosition;
|
|
|
|
mListStyleImage = aSource.mListStyleImage;
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2002-11-06 10:31:27 +03:00
|
|
|
if (mListStylePosition == aOther.mListStylePosition &&
|
|
|
|
mListStyleImage == aOther.mListStyleImage &&
|
|
|
|
mListStyleType == aOther.mListStyleType) {
|
|
|
|
if (mImageRegion == aOther.mImageRegion)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
if (mImageRegion.width == aOther.mImageRegion.width &&
|
|
|
|
mImageRegion.height == aOther.mImageRegion.height)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef INCLUDE_XUL
|
|
|
|
// --------------------
|
|
|
|
// nsStyleXUL
|
|
|
|
//
|
|
|
|
nsStyleXUL::nsStyleXUL()
|
|
|
|
{
|
2001-08-02 04:09:27 +04:00
|
|
|
mBoxAlign = NS_STYLE_BOX_ALIGN_STRETCH;
|
|
|
|
mBoxDirection = NS_STYLE_BOX_DIRECTION_NORMAL;
|
|
|
|
mBoxFlex = 0.0f;
|
2001-06-01 02:19:43 +04:00
|
|
|
mBoxOrient = NS_STYLE_BOX_ORIENT_HORIZONTAL;
|
2001-08-02 04:09:27 +04:00
|
|
|
mBoxPack = NS_STYLE_BOX_PACK_START;
|
2001-09-26 02:17:00 +04:00
|
|
|
mBoxOrdinal = 1;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleXUL::~nsStyleXUL()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleXUL::nsStyleXUL(const nsStyleXUL& aSource)
|
|
|
|
{
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy((nsStyleXUL*)this, &aSource, sizeof(nsStyleXUL));
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleXUL::CalcDifference(const nsStyleXUL& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2001-08-02 04:09:27 +04:00
|
|
|
if (mBoxAlign == aOther.mBoxAlign &&
|
|
|
|
mBoxDirection == aOther.mBoxDirection &&
|
|
|
|
mBoxFlex == aOther.mBoxFlex &&
|
|
|
|
mBoxOrient == aOther.mBoxOrient &&
|
2001-09-26 02:17:00 +04:00
|
|
|
mBoxPack == aOther.mBoxPack &&
|
|
|
|
mBoxOrdinal == aOther.mBoxOrdinal)
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-09-26 02:17:00 +04:00
|
|
|
if (mBoxOrdinal != aOther.mBoxOrdinal)
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // INCLUDE_XUL
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
// --------------------
|
|
|
|
// nsStyleSVG
|
|
|
|
//
|
|
|
|
nsStyleSVG::nsStyleSVG()
|
|
|
|
{
|
|
|
|
mFill.mType = eStyleSVGPaintType_None;
|
|
|
|
mFill.mColor = NS_RGB(0,0,0);
|
|
|
|
mFillOpacity = 1.0f;
|
|
|
|
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
|
|
|
|
mStroke.mType = eStyleSVGPaintType_None;
|
|
|
|
mStroke.mColor = NS_RGB(0,0,0);
|
|
|
|
mStrokeDasharray.Truncate();
|
|
|
|
mStrokeDashoffset = 0.0f;
|
|
|
|
mStrokeLinecap = NS_STYLE_STROKE_LINECAP_BUTT;
|
|
|
|
mStrokeLinejoin = NS_STYLE_STROKE_LINEJOIN_MITER;
|
|
|
|
mStrokeMiterlimit = 4.0f;
|
|
|
|
mStrokeOpacity = 1.0f;
|
|
|
|
mStrokeWidth = 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::~nsStyleSVG()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
|
|
|
{
|
2002-01-12 06:18:55 +03:00
|
|
|
//memcpy((nsStyleSVG*)this, &aSource, sizeof(nsStyleSVG));
|
2001-12-12 10:59:31 +03:00
|
|
|
|
|
|
|
mFill.mType = aSource.mFill.mType;
|
|
|
|
if (mFill.mType == eStyleSVGPaintType_Color)
|
|
|
|
mFill.mColor = aSource.mFill.mColor;
|
|
|
|
mFillOpacity = aSource.mFillOpacity;
|
|
|
|
mFillRule = aSource.mFillRule;
|
|
|
|
mStroke.mType = aSource.mStroke.mType;
|
|
|
|
if (mStroke.mType == eStyleSVGPaintType_Color)
|
|
|
|
mStroke.mColor = aSource.mStroke.mColor;
|
|
|
|
mStrokeDasharray = aSource.mStrokeDasharray;
|
|
|
|
mStrokeDashoffset = aSource.mStrokeDashoffset;
|
|
|
|
mStrokeLinecap = aSource.mStrokeLinecap;
|
|
|
|
mStrokeLinejoin = aSource.mStrokeLinejoin;
|
|
|
|
mStrokeMiterlimit = aSource.mStrokeMiterlimit;
|
|
|
|
mStrokeOpacity = aSource.mStrokeOpacity;
|
|
|
|
mStrokeWidth = aSource.mStrokeWidth;
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
|
|
|
if ( mFill.mType != aOther.mFill.mType ||
|
|
|
|
mFillOpacity != aOther.mFillOpacity ||
|
|
|
|
mFillRule != aOther.mFillRule ||
|
|
|
|
mStroke.mType != aOther.mStroke.mType ||
|
|
|
|
mStrokeDasharray != aOther.mStrokeDasharray ||
|
|
|
|
mStrokeDashoffset != aOther.mStrokeDashoffset ||
|
|
|
|
mStrokeLinecap != aOther.mStrokeLinecap ||
|
|
|
|
mStrokeLinejoin != aOther.mStrokeLinejoin ||
|
|
|
|
mStrokeMiterlimit != aOther.mStrokeMiterlimit ||
|
|
|
|
mStrokeOpacity != aOther.mStrokeOpacity ||
|
|
|
|
mStrokeWidth != aOther.mStrokeWidth )
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
|
|
|
|
if ( (mStroke.mType == eStyleSVGPaintType_Color && mStroke.mColor != aOther.mStroke.mColor) ||
|
|
|
|
(mFill.mType == eStyleSVGPaintType_Color && mFill.mColor != aOther.mFill.mColor) )
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MOZ_SVG
|
|
|
|
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStylePosition
|
|
|
|
//
|
|
|
|
nsStylePosition::nsStylePosition(void)
|
|
|
|
{
|
|
|
|
// positioning values not inherited
|
|
|
|
nsStyleCoord autoCoord(eStyleUnit_Auto);
|
|
|
|
mOffset.SetLeft(autoCoord);
|
|
|
|
mOffset.SetTop(autoCoord);
|
|
|
|
mOffset.SetRight(autoCoord);
|
|
|
|
mOffset.SetBottom(autoCoord);
|
|
|
|
mWidth.SetAutoValue();
|
|
|
|
mMinWidth.SetCoordValue(0);
|
|
|
|
mMaxWidth.Reset();
|
|
|
|
mHeight.SetAutoValue();
|
|
|
|
mMinHeight.SetCoordValue(0);
|
|
|
|
mMaxHeight.Reset();
|
|
|
|
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
|
|
|
|
mZIndex.SetAutoValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePosition::~nsStylePosition(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePosition::nsStylePosition(const nsStylePosition& aSource)
|
|
|
|
{
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy((nsStylePosition*)this, &aSource, sizeof(nsStylePosition));
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStylePosition::CalcDifference(const nsStylePosition& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if ((mOffset == aOther.mOffset) &&
|
|
|
|
(mWidth == aOther.mWidth) &&
|
|
|
|
(mMinWidth == aOther.mMinWidth) &&
|
|
|
|
(mMaxWidth == aOther.mMaxWidth) &&
|
|
|
|
(mHeight == aOther.mHeight) &&
|
|
|
|
(mMinHeight == aOther.mMinHeight) &&
|
|
|
|
(mMaxHeight == aOther.mMaxHeight) &&
|
|
|
|
(mBoxSizing == aOther.mBoxSizing) &&
|
2001-12-05 11:35:05 +03:00
|
|
|
(mZIndex == aOther.mZIndex))
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleTable
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleTable::nsStyleTable()
|
|
|
|
{
|
|
|
|
// values not inherited
|
|
|
|
mLayoutStrategy = NS_STYLE_TABLE_LAYOUT_AUTO;
|
|
|
|
mCols = NS_STYLE_TABLE_COLS_NONE;
|
|
|
|
mFrame = NS_STYLE_TABLE_FRAME_NONE;
|
2002-02-19 18:48:28 +03:00
|
|
|
mRules = NS_STYLE_TABLE_RULES_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
mSpan = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTable::~nsStyleTable(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTable::nsStyleTable(const nsStyleTable& aSource)
|
|
|
|
{
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy((nsStyleTable*)this, &aSource, sizeof(nsStyleTable));
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleTable::CalcDifference(const nsStyleTable& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if ((mLayoutStrategy == aOther.mLayoutStrategy) &&
|
|
|
|
(mFrame == aOther.mFrame) &&
|
|
|
|
(mRules == aOther.mRules) &&
|
|
|
|
(mCols == aOther.mCols) &&
|
|
|
|
(mSpan == aOther.mSpan))
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------
|
|
|
|
// nsStyleTableBorder
|
|
|
|
|
|
|
|
nsStyleTableBorder::nsStyleTableBorder(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
mBorderCollapse = NS_STYLE_BORDER_SEPARATE;
|
|
|
|
|
2002-06-26 01:16:17 +04:00
|
|
|
nsCompatibility compatMode = eCompatibility_FullStandards;
|
2001-06-01 02:19:43 +04:00
|
|
|
if (aPresContext)
|
2002-06-26 01:16:17 +04:00
|
|
|
aPresContext->GetCompatibilityMode(&compatMode);
|
|
|
|
mEmptyCells = (compatMode == eCompatibility_NavQuirks)
|
2001-11-07 01:52:59 +03:00
|
|
|
? NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND
|
2002-06-26 01:16:17 +04:00
|
|
|
: NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
|
2001-06-01 02:19:43 +04:00
|
|
|
mCaptionSide = NS_SIDE_TOP;
|
|
|
|
mBorderSpacingX.Reset();
|
|
|
|
mBorderSpacingY.Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTableBorder::~nsStyleTableBorder(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTableBorder::nsStyleTableBorder(const nsStyleTableBorder& aSource)
|
|
|
|
{
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy((nsStyleTableBorder*)this, &aSource, sizeof(nsStyleTableBorder));
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleTableBorder::CalcDifference(const nsStyleTableBorder& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if ((mBorderCollapse == aOther.mBorderCollapse) &&
|
|
|
|
(mCaptionSide == aOther.mCaptionSide) &&
|
|
|
|
(mBorderSpacingX == aOther.mBorderSpacingX) &&
|
|
|
|
(mBorderSpacingY == aOther.mBorderSpacingY)) {
|
|
|
|
if (mEmptyCells == aOther.mEmptyCells)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleColor
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleColor::nsStyleColor(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
aPresContext->GetDefaultColor(&mColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColor::nsStyleColor(const nsStyleColor& aSource)
|
|
|
|
{
|
|
|
|
mColor = aSource.mColor;
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleColor::CalcDifference(const nsStyleColor& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if (mColor == aOther.mColor)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleBackground
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleBackground::nsStyleBackground(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
mBackgroundFlags = NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE;
|
|
|
|
aPresContext->GetDefaultBackgroundColor(&mBackgroundColor);
|
2002-08-07 11:39:34 +04:00
|
|
|
mBackgroundAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL;
|
2002-10-08 14:24:53 +04:00
|
|
|
mBackgroundClip = NS_STYLE_BG_CLIP_BORDER;
|
|
|
|
mBackgroundOrigin = NS_STYLE_BG_ORIGIN_PADDING;
|
2002-08-07 11:39:34 +04:00
|
|
|
mBackgroundRepeat = NS_STYLE_BG_REPEAT_XY;
|
|
|
|
mBackgroundXPosition = mBackgroundYPosition = 0;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
|
|
|
|
{
|
|
|
|
mBackgroundAttachment = aSource.mBackgroundAttachment;
|
|
|
|
mBackgroundFlags = aSource.mBackgroundFlags;
|
|
|
|
mBackgroundRepeat = aSource.mBackgroundRepeat;
|
2002-10-08 14:24:53 +04:00
|
|
|
mBackgroundClip = aSource.mBackgroundClip;
|
|
|
|
mBackgroundOrigin = aSource.mBackgroundOrigin;
|
2001-06-01 02:19:43 +04:00
|
|
|
mBackgroundColor = aSource.mBackgroundColor;
|
|
|
|
mBackgroundXPosition = aSource.mBackgroundXPosition;
|
|
|
|
mBackgroundYPosition = aSource.mBackgroundYPosition;
|
|
|
|
mBackgroundImage = aSource.mBackgroundImage;
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleBackground::CalcDifference(const nsStyleBackground& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2002-01-27 10:53:27 +03:00
|
|
|
if (mBackgroundAttachment != aOther.mBackgroundAttachment
|
2002-08-24 18:41:28 +04:00
|
|
|
&& ((NS_STYLE_BG_ATTACHMENT_FIXED == mBackgroundAttachment) ||
|
|
|
|
(NS_STYLE_BG_ATTACHMENT_FIXED == aOther.mBackgroundAttachment)))
|
2002-01-27 10:53:27 +03:00
|
|
|
// this might require creation of a view
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if ((mBackgroundAttachment == aOther.mBackgroundAttachment) &&
|
|
|
|
(mBackgroundFlags == aOther.mBackgroundFlags) &&
|
|
|
|
(mBackgroundRepeat == aOther.mBackgroundRepeat) &&
|
|
|
|
(mBackgroundColor == aOther.mBackgroundColor) &&
|
|
|
|
(mBackgroundXPosition == aOther.mBackgroundXPosition) &&
|
|
|
|
(mBackgroundYPosition == aOther.mBackgroundYPosition) &&
|
2002-10-08 14:24:53 +04:00
|
|
|
(mBackgroundClip == aOther.mBackgroundClip) &&
|
|
|
|
(mBackgroundOrigin == aOther.mBackgroundOrigin) &&
|
2001-06-01 02:19:43 +04:00
|
|
|
(mBackgroundImage == aOther.mBackgroundImage))
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleDisplay
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleDisplay::nsStyleDisplay()
|
|
|
|
{
|
2001-12-18 01:51:39 +03:00
|
|
|
mAppearance = 0;
|
2001-06-01 02:19:43 +04:00
|
|
|
mDisplay = NS_STYLE_DISPLAY_INLINE;
|
2002-08-16 03:00:23 +04:00
|
|
|
mOriginalDisplay = NS_STYLE_DISPLAY_NONE;
|
2002-09-30 18:46:56 +04:00
|
|
|
mPosition = NS_STYLE_POSITION_STATIC;
|
2001-06-01 02:19:43 +04:00
|
|
|
mFloats = NS_STYLE_FLOAT_NONE;
|
|
|
|
mBreakType = NS_STYLE_CLEAR_NONE;
|
|
|
|
mBreakBefore = PR_FALSE;
|
|
|
|
mBreakAfter = PR_FALSE;
|
|
|
|
mOverflow = NS_STYLE_OVERFLOW_VISIBLE;
|
|
|
|
mClipFlags = NS_STYLE_CLIP_AUTO;
|
|
|
|
mClip.SetRect(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
|
|
|
{
|
2001-12-18 01:51:39 +03:00
|
|
|
mAppearance = aSource.mAppearance;
|
2001-06-01 02:19:43 +04:00
|
|
|
mDisplay = aSource.mDisplay;
|
2002-08-16 03:00:23 +04:00
|
|
|
mOriginalDisplay = aSource.mOriginalDisplay;
|
2001-06-01 02:19:43 +04:00
|
|
|
mBinding = aSource.mBinding;
|
|
|
|
mPosition = aSource.mPosition;
|
|
|
|
mFloats = aSource.mFloats;
|
|
|
|
mBreakType = aSource.mBreakType;
|
|
|
|
mBreakBefore = aSource.mBreakBefore;
|
|
|
|
mBreakAfter = aSource.mBreakAfter;
|
|
|
|
mOverflow = aSource.mOverflow;
|
|
|
|
mClipFlags = aSource.mClipFlags;
|
|
|
|
mClip = aSource.mClip;
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2002-09-30 15:56:37 +04:00
|
|
|
nsChangeHint hint = nsChangeHint_None;
|
|
|
|
|
|
|
|
if (mBinding != aOther.mBinding
|
|
|
|
|| mPosition != aOther.mPosition
|
|
|
|
|| mDisplay != aOther.mDisplay
|
|
|
|
|| mFloats != aOther.mFloats
|
|
|
|
|| mOverflow != aOther.mOverflow)
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
|
|
|
|
|
|
|
|
// XXX the following is conservative, for now: changing float breaking shouldn't
|
|
|
|
// necessarily require a repaint, reflow should suffice.
|
|
|
|
if (mBreakType != aOther.mBreakType
|
|
|
|
|| mBreakBefore != aOther.mBreakBefore
|
|
|
|
|| mBreakAfter != aOther.mBreakAfter
|
|
|
|
|| mAppearance != aOther.mAppearance)
|
|
|
|
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame));
|
|
|
|
|
|
|
|
if (mClipFlags != aOther.mClipFlags
|
|
|
|
|| mClip != aOther.mClip)
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_SyncFrameView);
|
|
|
|
|
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleVisibility
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleVisibility::nsStyleVisibility(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
PRUint32 bidiOptions;
|
|
|
|
aPresContext->GetBidi(&bidiOptions);
|
|
|
|
if (GET_BIDI_OPTION_DIRECTION(bidiOptions) == IBMBIDI_TEXTDIRECTION_RTL)
|
|
|
|
mDirection = NS_STYLE_DIRECTION_RTL;
|
|
|
|
else
|
|
|
|
mDirection = NS_STYLE_DIRECTION_LTR;
|
|
|
|
#else
|
|
|
|
mDirection = NS_STYLE_DIRECTION_LTR;
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
|
|
|
aPresContext->GetLanguage(getter_AddRefs(mLanguage));
|
|
|
|
mVisible = NS_STYLE_VISIBILITY_VISIBLE;
|
|
|
|
mOpacity = 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
|
|
|
|
{
|
|
|
|
mDirection = aSource.mDirection;
|
|
|
|
mVisible = aSource.mVisible;
|
|
|
|
mLanguage = aSource.mLanguage;
|
|
|
|
mOpacity = aSource.mOpacity;
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2002-01-27 10:53:27 +03:00
|
|
|
if (mOpacity != aOther.mOpacity
|
|
|
|
&& ((mOpacity < 1.0) != (aOther.mOpacity < 1.0)))
|
|
|
|
// might need to create a view to handle change from 1.0 to partial opacity
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
if ((mDirection == aOther.mDirection) &&
|
|
|
|
(mLanguage == aOther.mLanguage)) {
|
|
|
|
if ((mVisible == aOther.mVisible)) {
|
2002-01-27 10:53:27 +03:00
|
|
|
if (mOpacity == aOther.mOpacity)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
else
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
if ((mVisible != aOther.mVisible) &&
|
|
|
|
((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||
|
|
|
|
(NS_STYLE_VISIBILITY_COLLAPSE == aOther.mVisible))) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// nsStyleContent
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleContent::nsStyleContent(void)
|
|
|
|
: mMarkerOffset(),
|
|
|
|
mContentCount(0),
|
|
|
|
mContents(nsnull),
|
|
|
|
mIncrementCount(0),
|
|
|
|
mIncrements(nsnull),
|
|
|
|
mResetCount(0),
|
|
|
|
mResets(nsnull)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContent::~nsStyleContent(void)
|
|
|
|
{
|
|
|
|
DELETE_ARRAY_IF(mContents);
|
|
|
|
DELETE_ARRAY_IF(mIncrements);
|
|
|
|
DELETE_ARRAY_IF(mResets);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContent::nsStyleContent(const nsStyleContent& aSource)
|
|
|
|
:mMarkerOffset(),
|
|
|
|
mContentCount(0),
|
|
|
|
mContents(nsnull),
|
|
|
|
mIncrementCount(0),
|
|
|
|
mIncrements(nsnull),
|
|
|
|
mResetCount(0),
|
|
|
|
mResets(nsnull)
|
|
|
|
|
|
|
|
{
|
|
|
|
mMarkerOffset = aSource.mMarkerOffset;
|
|
|
|
|
|
|
|
PRUint32 index;
|
|
|
|
if (NS_SUCCEEDED(AllocateContents(aSource.ContentCount()))) {
|
|
|
|
for (index = 0; index < mContentCount; index++) {
|
|
|
|
aSource.GetContentAt(index, mContents[index].mType, mContents[index].mContent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(AllocateCounterIncrements(aSource.CounterIncrementCount()))) {
|
|
|
|
for (index = 0; index < mIncrementCount; index++) {
|
|
|
|
aSource.GetCounterIncrementAt(index, mIncrements[index].mCounter,
|
|
|
|
mIncrements[index].mValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(AllocateCounterResets(aSource.CounterResetCount()))) {
|
|
|
|
for (index = 0; index < mResetCount; index++) {
|
|
|
|
aSource.GetCounterResetAt(index, mResets[index].mCounter,
|
|
|
|
mResets[index].mValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleContent::CalcDifference(const nsStyleContent& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if (mContentCount == aOther.mContentCount) {
|
|
|
|
if ((mMarkerOffset == aOther.mMarkerOffset) &&
|
|
|
|
(mIncrementCount == aOther.mIncrementCount) &&
|
|
|
|
(mResetCount == aOther.mResetCount)) {
|
|
|
|
PRUint32 ix = mContentCount;
|
|
|
|
while (0 < ix--) {
|
|
|
|
if ((mContents[ix].mType != aOther.mContents[ix].mType) ||
|
|
|
|
(mContents[ix].mContent != aOther.mContents[ix].mContent)) {
|
2002-06-22 02:31:19 +04:00
|
|
|
// Unfortunately we need to reframe here; a simple reflow
|
|
|
|
// will not pick up different text or different image URLs,
|
|
|
|
// since we set all that up in the CSSFrameConstructor
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ix = mIncrementCount;
|
|
|
|
while (0 < ix--) {
|
|
|
|
if ((mIncrements[ix].mValue != aOther.mIncrements[ix].mValue) ||
|
|
|
|
(mIncrements[ix].mCounter != aOther.mIncrements[ix].mCounter)) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ix = mResetCount;
|
|
|
|
while (0 < ix--) {
|
|
|
|
if ((mResets[ix].mValue != aOther.mResets[ix].mValue) ||
|
|
|
|
(mResets[ix].mCounter != aOther.mResets[ix].mCounter)) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------
|
|
|
|
// nsStyleQuotes
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleQuotes::nsStyleQuotes(void)
|
|
|
|
: mQuotesCount(0),
|
|
|
|
mQuotes(nsnull)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleQuotes::~nsStyleQuotes(void)
|
|
|
|
{
|
|
|
|
DELETE_ARRAY_IF(mQuotes);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleQuotes::nsStyleQuotes(const nsStyleQuotes& aSource)
|
2002-10-13 22:55:12 +04:00
|
|
|
: mQuotesCount(0),
|
|
|
|
mQuotes(nsnull)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if (NS_SUCCEEDED(AllocateQuotes(aSource.QuotesCount()))) {
|
|
|
|
PRUint32 count = (mQuotesCount * 2);
|
|
|
|
for (PRUint32 index = 0; index < count; index += 2) {
|
|
|
|
aSource.GetQuotesAt(index, mQuotes[index], mQuotes[index + 1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleQuotes::CalcDifference(const nsStyleQuotes& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2002-08-14 16:34:39 +04:00
|
|
|
// If the quotes implementation is ever going to change we might not need
|
|
|
|
// a framechange here and a reflow should be sufficient. See bug 35768.
|
2001-06-01 02:19:43 +04:00
|
|
|
if (mQuotesCount == aOther.mQuotesCount) {
|
|
|
|
PRUint32 ix = (mQuotesCount * 2);
|
|
|
|
while (0 < ix--) {
|
|
|
|
if (mQuotes[ix] != aOther.mQuotes[ix]) {
|
2002-08-14 16:34:39 +04:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
2002-08-14 16:34:39 +04:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleTextReset
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleTextReset::nsStyleTextReset(void)
|
|
|
|
{
|
|
|
|
mVerticalAlign.SetIntValue(NS_STYLE_VERTICAL_ALIGN_BASELINE, eStyleUnit_Enumerated);
|
|
|
|
mTextDecoration = NS_STYLE_TEXT_DECORATION_NONE;
|
2001-06-29 07:15:58 +04:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
mUnicodeBidi = NS_STYLE_UNICODE_BIDI_NORMAL;
|
|
|
|
#endif // IBMBIDI
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTextReset::nsStyleTextReset(const nsStyleTextReset& aSource)
|
|
|
|
{
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy((nsStyleTextReset*)this, &aSource, sizeof(nsStyleTextReset));
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTextReset::~nsStyleTextReset(void) { }
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2001-06-29 07:15:58 +04:00
|
|
|
if (mVerticalAlign == aOther.mVerticalAlign
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
&& mUnicodeBidi == aOther.mUnicodeBidi
|
|
|
|
#endif // IBMBIDI
|
|
|
|
) {
|
2001-06-01 02:19:43 +04:00
|
|
|
if (mTextDecoration != aOther.mTextDecoration)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleText
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleText::nsStyleText(void)
|
|
|
|
{
|
|
|
|
mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT;
|
|
|
|
mTextTransform = NS_STYLE_TEXT_TRANSFORM_NONE;
|
|
|
|
mWhiteSpace = NS_STYLE_WHITESPACE_NORMAL;
|
|
|
|
|
|
|
|
mLetterSpacing.SetNormalValue();
|
|
|
|
mLineHeight.SetNormalValue();
|
|
|
|
mTextIndent.SetCoordValue(0);
|
|
|
|
mWordSpacing.SetNormalValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleText::nsStyleText(const nsStyleText& aSource)
|
|
|
|
{
|
2002-01-12 06:18:55 +03:00
|
|
|
memcpy((nsStyleText*)this, &aSource, sizeof(nsStyleText));
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleText::~nsStyleText(void) { }
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if ((mTextAlign == aOther.mTextAlign) &&
|
|
|
|
(mTextTransform == aOther.mTextTransform) &&
|
|
|
|
(mWhiteSpace == aOther.mWhiteSpace) &&
|
|
|
|
(mLetterSpacing == aOther.mLetterSpacing) &&
|
|
|
|
(mLineHeight == aOther.mLineHeight) &&
|
|
|
|
(mTextIndent == aOther.mTextIndent) &&
|
|
|
|
(mWordSpacing == aOther.mWordSpacing))
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// nsStyleUserInterface
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleUserInterface::nsStyleUserInterface(void)
|
|
|
|
{
|
|
|
|
mUserInput = NS_STYLE_USER_INPUT_AUTO;
|
|
|
|
mUserModify = NS_STYLE_USER_MODIFY_READ_ONLY;
|
|
|
|
mUserFocus = NS_STYLE_USER_FOCUS_NONE;
|
|
|
|
|
|
|
|
mCursor = NS_STYLE_CURSOR_AUTO; // fix for bugzilla bug 51113
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUserInterface::nsStyleUserInterface(const nsStyleUserInterface& aSource)
|
|
|
|
{
|
|
|
|
mUserInput = aSource.mUserInput;
|
|
|
|
mUserModify = aSource.mUserModify;
|
|
|
|
mUserFocus = aSource.mUserFocus;
|
|
|
|
|
|
|
|
mCursor = aSource.mCursor;
|
|
|
|
mCursorImage = aSource.mCursorImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUserInterface::~nsStyleUserInterface(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if ((mCursor != aOther.mCursor) ||
|
|
|
|
(mCursorImage != aOther.mCursorImage))
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
|
|
|
|
if (mUserInput == aOther.mUserInput) {
|
|
|
|
if (mUserModify == aOther.mUserModify) {
|
|
|
|
if (mUserFocus == aOther.mUserFocus) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_CONTENT;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((mUserInput != aOther.mUserInput) &&
|
|
|
|
((NS_STYLE_USER_INPUT_NONE == mUserInput) ||
|
|
|
|
(NS_STYLE_USER_INPUT_NONE == aOther.mUserInput))) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// nsStyleUIReset
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleUIReset::nsStyleUIReset(void)
|
|
|
|
{
|
|
|
|
mUserSelect = NS_STYLE_USER_SELECT_AUTO;
|
|
|
|
mKeyEquivalent = PRUnichar(0); // XXX what type should this be?
|
|
|
|
mResizer = NS_STYLE_RESIZER_AUTO;
|
2002-03-26 23:14:05 +03:00
|
|
|
mForceBrokenImageIcon = 0;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUIReset::nsStyleUIReset(const nsStyleUIReset& aSource)
|
|
|
|
{
|
|
|
|
mUserSelect = aSource.mUserSelect;
|
|
|
|
mKeyEquivalent = aSource.mKeyEquivalent;
|
|
|
|
mResizer = aSource.mResizer;
|
2002-03-26 23:14:05 +03:00
|
|
|
mForceBrokenImageIcon = aSource.mForceBrokenImageIcon;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUIReset::~nsStyleUIReset(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleUIReset::CalcDifference(const nsStyleUIReset& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2002-03-26 23:14:05 +03:00
|
|
|
if (mForceBrokenImageIcon == aOther.mForceBrokenImageIcon) {
|
|
|
|
if (mResizer == aOther.mResizer &&
|
|
|
|
mUserSelect == aOther.mUserSelect) {
|
2001-06-01 02:19:43 +04:00
|
|
|
if (mKeyEquivalent == aOther.mKeyEquivalent) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_CONTENT;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
2002-03-26 23:14:05 +03:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|