2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 01:52:36 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-06-01 02:19:43 +04:00
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
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.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 05:32:19 +04:00
|
|
|
* 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):
|
2004-04-13 01:54:45 +04:00
|
|
|
* David Hyatt (hyatt@netscape.com)
|
2005-03-27 15:36:08 +04:00
|
|
|
* Mats Palmgren <mats.palmgren@bredband.net>
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 01:52:36 +04:00
|
|
|
* either of 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"),
|
2001-09-25 05:32:19 +04:00
|
|
|
* 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
|
2004-04-18 01:52:36 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 05:32:19 +04:00
|
|
|
* 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
|
2004-04-18 01:52:36 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 05:32:19 +04:00
|
|
|
*
|
|
|
|
* ***** 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"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-03-13 18:29:36 +03:00
|
|
|
#include "nsIDeviceContext.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
#include "nsIStyleRule.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
|
|
|
|
#include "nsCOMPtr.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"
|
2004-11-25 05:43:28 +03:00
|
|
|
#include "nsHTMLReflowState.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
#include "prenv.h"
|
|
|
|
|
2002-02-19 23:41:32 +03:00
|
|
|
#include "nsBidiUtils.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
#include "imgIRequest.h"
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
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
|
2004-01-18 04:12:58 +03:00
|
|
|
// XXXldb Probably shouldn't be inline.
|
2001-06-01 02:19:43 +04:00
|
|
|
inline nscoord CalcSideFor(const nsIFrame* aFrame, const nsStyleCoord& aCoord,
|
2005-04-30 09:16:21 +04:00
|
|
|
PRUint8 aSpacing, PRUint8 aSide)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
|
|
|
|
switch (aCoord.GetUnit()) {
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
// Auto margins are handled by layout
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Percent:
|
|
|
|
{
|
|
|
|
nscoord baseWidth = 0;
|
2004-11-25 05:43:28 +03:00
|
|
|
nsIFrame* frame =
|
|
|
|
nsHTMLReflowState::GetContainingBlockFor(aFrame);
|
|
|
|
if (frame) {
|
|
|
|
baseWidth = frame->GetSize().width;
|
|
|
|
// subtract border of containing block
|
|
|
|
nsMargin border;
|
|
|
|
frame->GetStyleBorder()->CalcBorderFor(frame, border);
|
|
|
|
baseWidth -= (border.left + border.right);
|
|
|
|
// if aFrame is not absolutely positioned, subtract
|
|
|
|
// padding of containing block
|
|
|
|
const nsStyleDisplay* displayData = aFrame->GetStyleDisplay();
|
|
|
|
if (displayData->mPosition != NS_STYLE_POSITION_ABSOLUTE &&
|
|
|
|
displayData->mPosition != NS_STYLE_POSITION_FIXED) {
|
|
|
|
nsMargin padding;
|
|
|
|
frame->GetStylePadding()->CalcPaddingFor(frame, padding);
|
|
|
|
baseWidth -= (padding.left + padding.right);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
result = (nscoord)((float)baseWidth * aCoord.GetPercentValue());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
result = aCoord.GetCoordValue();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Enumerated:
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-01-18 04:12:58 +03:00
|
|
|
// XXXldb Probably shouldn't be inline.
|
2001-06-01 02:19:43 +04:00
|
|
|
inline void CalcSidesFor(const nsIFrame* aFrame, const nsStyleSides& aSides,
|
2005-04-30 09:16:21 +04:00
|
|
|
PRUint8 aSpacing, nsMargin& aResult)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
nsStyleCoord coord;
|
|
|
|
|
2005-04-30 09:16:21 +04:00
|
|
|
aResult.left = CalcSideFor(aFrame, aSides.GetLeft(coord), aSpacing,
|
|
|
|
NS_SIDE_LEFT);
|
|
|
|
aResult.top = CalcSideFor(aFrame, aSides.GetTop(coord), aSpacing,
|
|
|
|
NS_SIDE_TOP);
|
|
|
|
aResult.right = CalcSideFor(aFrame, aSides.GetRight(coord), aSpacing,
|
|
|
|
NS_SIDE_RIGHT);
|
|
|
|
aResult.bottom = CalcSideFor(aFrame, aSides.GetBottom(coord), aSpacing,
|
|
|
|
NS_SIDE_BOTTOM);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2003-10-04 10:36:33 +04:00
|
|
|
static PRBool EqualURIs(nsIURI *aURI1, nsIURI *aURI2)
|
|
|
|
{
|
|
|
|
PRBool eq;
|
|
|
|
return aURI1 == aURI2 || // handle null==null, and optimize
|
|
|
|
(aURI1 && aURI2 &&
|
|
|
|
NS_SUCCEEDED(aURI1->Equals(aURI2, &eq)) && // not equal on fail
|
|
|
|
eq);
|
|
|
|
}
|
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
static PRBool EqualImages(imgIRequest *aImage1, imgIRequest* aImage2)
|
|
|
|
{
|
|
|
|
if (aImage1 == aImage2) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aImage1 || !aImage2) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri1, uri2;
|
|
|
|
aImage1->GetURI(getter_AddRefs(uri1));
|
|
|
|
aImage2->GetURI(getter_AddRefs(uri2));
|
|
|
|
return EqualURIs(uri1, uri2);
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// 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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-03-13 18:29:36 +03:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleFont::nsStyleFont(nsPresContext* aPresContext)
|
2004-02-26 02:15:11 +03:00
|
|
|
: mFlags(NS_STYLE_FONT_DEFAULT),
|
|
|
|
mFont(*(aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID)))
|
2003-03-13 18:29:36 +03:00
|
|
|
{
|
|
|
|
mSize = mFont.size = nsStyleFont::ZoomText(aPresContext, mFont.size);
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
void*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleFont::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 04:28:44 +04:00
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (result)
|
2004-04-13 04:28:44 +04:00
|
|
|
memset(result, 0, sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleFont::Destroy(nsPresContext* 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
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleFont::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-03-13 18:29:36 +03:00
|
|
|
/* static */ nscoord
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleFont::ZoomText(nsPresContext *aPresContext, nscoord aSize)
|
2003-03-13 18:29:36 +03:00
|
|
|
{
|
2005-08-13 15:54:22 +04:00
|
|
|
return nscoord(float(aSize) * aPresContext->TextZoom());
|
2003-03-13 18:29:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nscoord
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleFont::UnZoomText(nsPresContext *aPresContext, nscoord aSize)
|
2003-03-13 18:29:36 +03:00
|
|
|
{
|
2005-08-13 15:54:22 +04:00
|
|
|
return nscoord(float(aSize) / aPresContext->TextZoom());
|
2003-03-13 18:29:36 +03: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)
|
|
|
|
{
|
2004-04-13 01:54:45 +04:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
if (!IsFixedUnit(aSides.GetUnit(side), aEnumOK))
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2005-03-27 15:36:08 +04:00
|
|
|
case eStyleUnit_Chars:
|
|
|
|
// XXX we need a frame and a rendering context to calculate this, bug 281972, bug 282126.
|
|
|
|
NS_NOTYETIMPLEMENTED("CalcCoord: eStyleUnit_Chars");
|
|
|
|
return 0;
|
2001-06-01 02:19:43 +04:00
|
|
|
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*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleMargin::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 04:28:44 +04:00
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (result)
|
2004-04-13 04:28:44 +04:00
|
|
|
memset(result, 0, sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleMargin::Destroy(nsPresContext* 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)) {
|
2004-04-13 01:54:45 +04:00
|
|
|
nsStyleCoord coord;
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2005-04-29 19:44:38 +04:00
|
|
|
mCachedMargin.side(side) =
|
2004-04-13 01:54:45 +04:00
|
|
|
CalcCoord(mMargin.Get(side, coord), nsnull, 0);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleMargin::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
void
|
|
|
|
nsStyleMargin::CalcMarginFor(const nsIFrame* aFrame, nsMargin& aMargin) const
|
|
|
|
{
|
|
|
|
if (mHasCachedMargin) {
|
|
|
|
aMargin = mCachedMargin;
|
|
|
|
} else {
|
2005-04-30 09:16:21 +04:00
|
|
|
CalcSidesFor(aFrame, mMargin, NS_SPACING_MARGIN, aMargin);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePadding::nsStylePadding() {
|
|
|
|
mPadding.Reset();
|
|
|
|
mHasCachedPadding = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePadding::nsStylePadding(const nsStylePadding& aSrc) {
|
|
|
|
mPadding = aSrc.mPadding;
|
|
|
|
mHasCachedPadding = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStylePadding::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 04:28:44 +04:00
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (result)
|
2004-04-13 04:28:44 +04:00
|
|
|
memset(result, 0, sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStylePadding::Destroy(nsPresContext* 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)) {
|
2004-04-13 01:54:45 +04:00
|
|
|
nsStyleCoord coord;
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2005-04-29 19:44:38 +04:00
|
|
|
mCachedPadding.side(side) =
|
2004-04-13 01:54:45 +04:00
|
|
|
CalcCoord(mPadding.Get(side, coord), nsnull, 0);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStylePadding::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
void
|
|
|
|
nsStylePadding::CalcPaddingFor(const nsIFrame* aFrame, nsMargin& aPadding) const
|
|
|
|
{
|
|
|
|
if (mHasCachedPadding) {
|
|
|
|
aPadding = mCachedPadding;
|
|
|
|
} else {
|
2005-04-30 09:16:21 +04:00
|
|
|
CalcSidesFor(aFrame, mPadding, NS_SPACING_PADDING, aPadding);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext)
|
2005-04-29 19:44:38 +04:00
|
|
|
: mComputedBorder(0, 0, 0, 0)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2005-04-29 19:44:38 +04:00
|
|
|
nscoord medium =
|
|
|
|
(aPresContext->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM];
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mBorder.side(side) = medium;
|
|
|
|
mBorderStyle[side] = NS_STYLE_BORDER_STYLE_NONE | BORDER_COLOR_FOREGROUND;
|
|
|
|
mBorderColor[side] = NS_RGB(0, 0, 0);
|
2005-09-19 19:47:26 +04:00
|
|
|
mBorderRadius.Set(side, nsStyleCoord(0));
|
2005-04-29 19:44:38 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2001-12-05 11:35:05 +03:00
|
|
|
mBorderColors = nsnull;
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
mFloatEdge = NS_STYLE_FLOAT_EDGE_CONTENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleBorder::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 04:28:44 +04:00
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
if (result)
|
2004-04-13 04:28:44 +04:00
|
|
|
memset(result, 0, sz);
|
2001-06-01 02:19:43 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleBorder::Destroy(nsPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStyleBorder();
|
2001-06-01 02:19:43 +04:00
|
|
|
aContext->FreeToShell(sizeof(nsStyleBorder), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2005-04-29 19:44:38 +04:00
|
|
|
// Note that differences in mBorder don't affect rendering (which should only
|
|
|
|
// use mComputedBorder), so don't need to be tested for here.
|
|
|
|
if (mComputedBorder == aOther.mComputedBorder &&
|
|
|
|
mFloatEdge == aOther.mFloatEdge) {
|
2005-04-15 20:56:05 +04:00
|
|
|
// Note that mBorderStyle stores not only the border style but also
|
2005-04-29 19:44:38 +04:00
|
|
|
// color-related flags. Given that we've already done an mComputedBorder
|
|
|
|
// comparison, border-style differences can only lead to a VISUAL hint. So
|
|
|
|
// it's OK to just compare the values directly -- if either the actual
|
|
|
|
// style or the color flags differ we want to repaint.
|
2004-04-13 01:54:45 +04:00
|
|
|
NS_FOR_CSS_SIDES(ix) {
|
2005-04-29 19:44:38 +04:00
|
|
|
if (mBorderStyle[ix] != aOther.mBorderStyle[ix] ||
|
|
|
|
mBorderColor[ix] != aOther.mBorderColor[ix]) {
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
2005-04-29 19:44:38 +04:00
|
|
|
|
|
|
|
if (mBorderRadius != aOther.mBorderRadius ||
|
2005-04-15 20:56:05 +04:00
|
|
|
!mBorderColors != !aOther.mBorderColors) {
|
2001-12-19 14:59:31 +03:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
2005-04-15 20:56:05 +04:00
|
|
|
// Note that at this point if mBorderColors is non-null so is
|
|
|
|
// aOther.mBorderColors
|
|
|
|
if (mBorderColors) {
|
2004-04-13 01:54:45 +04:00
|
|
|
NS_FOR_CSS_SIDES(ix) {
|
2005-04-29 19:44:38 +04:00
|
|
|
if (!mBorderColors[ix] != !aOther.mBorderColors[ix]) {
|
2001-12-19 14:59:31 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleBorder::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleOutline::nsStyleOutline(nsPresContext* aPresContext)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
// spacing values not inherited
|
2005-09-19 19:47:26 +04:00
|
|
|
nsStyleCoord zero(0);
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mOutlineRadius.Set(side, zero);
|
|
|
|
}
|
|
|
|
|
2005-03-27 15:36:08 +04:00
|
|
|
mOutlineOffset.SetCoordValue(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2005-03-27 15:36:08 +04:00
|
|
|
mOutlineWidth = nsStyleCoord(NS_STYLE_BORDER_WIDTH_MEDIUM, eStyleUnit_Enumerated);
|
2001-06-01 02:19:43 +04:00
|
|
|
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
|
2004-11-26 21:40:58 +03:00
|
|
|
nsStyleOutline::RecalcData(nsPresContext* aContext)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2005-03-27 15:36:08 +04:00
|
|
|
if (NS_STYLE_BORDER_STYLE_NONE == GetOutlineStyle()) {
|
|
|
|
mCachedOutlineWidth = 0;
|
|
|
|
mHasCachedOutline = PR_TRUE;
|
|
|
|
} else if (IsFixedUnit(mOutlineWidth.GetUnit(), PR_TRUE)) {
|
|
|
|
mCachedOutlineWidth = CalcCoord(mOutlineWidth, aContext->GetBorderWidthTable(), 3);
|
2001-06-01 02:19:43 +04:00
|
|
|
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
|
|
|
{
|
2004-07-16 20:56:21 +04:00
|
|
|
PRBool outlineWasVisible =
|
|
|
|
mCachedOutlineWidth > 0 && mOutlineStyle != NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
PRBool outlineIsVisible =
|
|
|
|
aOther.mCachedOutlineWidth > 0 && aOther.mOutlineStyle != NS_STYLE_BORDER_STYLE_NONE;
|
2004-10-26 16:57:15 +04:00
|
|
|
if (outlineWasVisible != outlineIsVisible ||
|
|
|
|
(outlineIsVisible && (mOutlineOffset != aOther.mOutlineOffset ||
|
|
|
|
mOutlineWidth != aOther.mOutlineWidth))) {
|
2004-07-16 20:56:21 +04:00
|
|
|
return NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame);
|
|
|
|
}
|
|
|
|
if ((mOutlineStyle != aOther.mOutlineStyle) ||
|
2001-06-01 02:19:43 +04:00
|
|
|
(mOutlineColor != aOther.mOutlineColor) ||
|
|
|
|
(mOutlineRadius != aOther.mOutlineRadius)) {
|
2004-07-16 20:56:21 +04:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleOutline::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleList
|
|
|
|
//
|
|
|
|
nsStyleList::nsStyleList()
|
2004-01-16 01:06:39 +03:00
|
|
|
: mListStyleType(NS_STYLE_LIST_STYLE_DISC),
|
|
|
|
mListStylePosition(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::~nsStyleList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::nsStyleList(const nsStyleList& aSource)
|
2003-10-02 02:53:56 +04:00
|
|
|
: mListStyleType(aSource.mListStyleType),
|
|
|
|
mListStylePosition(aSource.mListStylePosition),
|
2004-01-15 05:24:17 +03:00
|
|
|
mListStyleImage(aSource.mListStyleImage),
|
|
|
|
mImageRegion(aSource.mImageRegion)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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 &&
|
2004-08-04 07:23:37 +04:00
|
|
|
EqualImages(mListStyleImage, aOther.mListStyleImage) &&
|
2002-11-06 10:31:27 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleList::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleXUL::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-06-17 15:57:37 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleColumn
|
|
|
|
//
|
|
|
|
nsStyleColumn::nsStyleColumn()
|
|
|
|
{
|
|
|
|
mColumnCount = NS_STYLE_COLUMN_COUNT_AUTO;
|
|
|
|
mColumnWidth.SetAutoValue();
|
2004-07-18 16:12:46 +04:00
|
|
|
mColumnGap.SetCoordValue(0);
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColumn::~nsStyleColumn()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColumn::nsStyleColumn(const nsStyleColumn& aSource)
|
|
|
|
{
|
|
|
|
memcpy((nsStyleColumn*)this, &aSource, sizeof(nsStyleColumn));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const
|
|
|
|
{
|
2004-07-18 16:12:46 +04:00
|
|
|
if ((mColumnWidth.GetUnit() == eStyleUnit_Auto)
|
|
|
|
!= (aOther.mColumnWidth.GetUnit() == eStyleUnit_Auto) ||
|
2004-10-08 16:17:10 +04:00
|
|
|
mColumnCount != aOther.mColumnCount)
|
|
|
|
// We force column count changes to do a reframe, because it's tricky to handle
|
|
|
|
// some edge cases where the column count gets smaller and content overflows.
|
|
|
|
// XXX not ideal
|
2004-07-18 16:12:46 +04:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
|
|
|
|
2004-10-08 16:17:10 +04:00
|
|
|
if (mColumnWidth != aOther.mColumnWidth ||
|
2004-07-18 16:12:46 +04:00
|
|
|
mColumnGap != aOther.mColumnGap)
|
|
|
|
return nsChangeHint_ReflowFrame;
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleColumn::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_CombineHint(nsChangeHint_ReconstructFrame,
|
|
|
|
nsChangeHint_ReflowFrame);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
// --------------------
|
|
|
|
// nsStyleSVG
|
|
|
|
//
|
|
|
|
nsStyleSVG::nsStyleSVG()
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2004-10-15 03:02:53 +04:00
|
|
|
mFill.mType = eStyleSVGPaintType_Color;
|
|
|
|
mFill.mPaint.mColor = NS_RGB(0,0,0);
|
|
|
|
mStroke.mType = eStyleSVGPaintType_None;
|
|
|
|
mStroke.mPaint.mColor = NS_RGB(0,0,0);
|
2004-11-09 21:19:28 +03:00
|
|
|
mStrokeDasharray = nsnull;
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2005-04-05 01:42:26 +04:00
|
|
|
mStrokeDashoffset.SetFactorValue(0.0f);
|
|
|
|
mStrokeWidth.SetFactorValue(1.0f);
|
|
|
|
|
2005-01-25 06:55:03 +03:00
|
|
|
mFillOpacity = 1.0f;
|
2004-10-15 03:02:53 +04:00
|
|
|
mStrokeMiterlimit = 4.0f;
|
|
|
|
mStrokeOpacity = 1.0f;
|
2005-01-25 06:55:03 +03:00
|
|
|
|
|
|
|
mStrokeDasharrayLength = 0;
|
|
|
|
mClipRule = NS_STYLE_FILL_RULE_NONZERO;
|
|
|
|
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
|
|
|
|
mPointerEvents = NS_STYLE_POINTER_EVENTS_VISIBLEPAINTED;
|
|
|
|
mShapeRendering = NS_STYLE_SHAPE_RENDERING_AUTO;
|
|
|
|
mStrokeLinecap = NS_STYLE_STROKE_LINECAP_BUTT;
|
|
|
|
mStrokeLinejoin = NS_STYLE_STROKE_LINEJOIN_MITER;
|
2004-10-15 03:02:53 +04:00
|
|
|
mTextAnchor = NS_STYLE_TEXT_ANCHOR_START;
|
|
|
|
mTextRendering = NS_STYLE_TEXT_RENDERING_AUTO;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::~nsStyleSVG()
|
|
|
|
{
|
2004-11-09 21:19:28 +03:00
|
|
|
delete [] mStrokeDasharray;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2004-10-15 03:02:53 +04:00
|
|
|
mFill = aSource.mFill;
|
2005-01-25 06:55:03 +03:00
|
|
|
mStroke = aSource.mStroke;
|
|
|
|
|
2004-12-09 06:16:15 +03:00
|
|
|
mMarkerEnd = aSource.mMarkerEnd;
|
|
|
|
mMarkerMid = aSource.mMarkerMid;
|
|
|
|
mMarkerEnd = aSource.mMarkerStart;
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2004-11-09 21:19:28 +03:00
|
|
|
mStrokeDasharrayLength = aSource.mStrokeDasharrayLength;
|
|
|
|
if (aSource.mStrokeDasharray) {
|
2005-04-05 01:42:26 +04:00
|
|
|
mStrokeDasharray = new nsStyleCoord[mStrokeDasharrayLength];
|
2004-11-09 21:19:28 +03:00
|
|
|
if (mStrokeDasharray)
|
|
|
|
memcpy(mStrokeDasharray,
|
|
|
|
aSource.mStrokeDasharray,
|
2005-04-05 01:42:26 +04:00
|
|
|
mStrokeDasharrayLength * sizeof(nsStyleCoord));
|
2004-11-09 21:19:28 +03:00
|
|
|
else
|
|
|
|
mStrokeDasharrayLength = 0;
|
|
|
|
} else {
|
|
|
|
mStrokeDasharray = nsnull;
|
|
|
|
}
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
mStrokeDashoffset = aSource.mStrokeDashoffset;
|
2005-04-05 01:42:26 +04:00
|
|
|
mStrokeWidth = aSource.mStrokeWidth;
|
|
|
|
|
|
|
|
mFillOpacity = aSource.mFillOpacity;
|
2001-12-12 10:59:31 +03:00
|
|
|
mStrokeMiterlimit = aSource.mStrokeMiterlimit;
|
|
|
|
mStrokeOpacity = aSource.mStrokeOpacity;
|
2005-01-25 06:55:03 +03:00
|
|
|
|
|
|
|
mClipRule = aSource.mClipRule;
|
|
|
|
mFillRule = aSource.mFillRule;
|
|
|
|
mPointerEvents = aSource.mPointerEvents;
|
|
|
|
mShapeRendering = aSource.mShapeRendering;
|
|
|
|
mStrokeLinecap = aSource.mStrokeLinecap;
|
|
|
|
mStrokeLinejoin = aSource.mStrokeLinejoin;
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
mTextAnchor = aSource.mTextAnchor;
|
|
|
|
mTextRendering = aSource.mTextRendering;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2004-11-09 21:19:28 +03:00
|
|
|
if ( mFill != aOther.mFill ||
|
2005-04-05 01:42:26 +04:00
|
|
|
|
2005-01-25 06:55:03 +03:00
|
|
|
mStroke != aOther.mStroke ||
|
2004-12-09 06:16:15 +03:00
|
|
|
!EqualURIs(mMarkerEnd, aOther.mMarkerEnd) ||
|
|
|
|
!EqualURIs(mMarkerMid, aOther.mMarkerMid) ||
|
|
|
|
!EqualURIs(mMarkerStart, aOther.mMarkerStart) ||
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2004-11-09 21:19:28 +03:00
|
|
|
mStrokeDashoffset != aOther.mStrokeDashoffset ||
|
2005-04-05 01:42:26 +04:00
|
|
|
mStrokeWidth != aOther.mStrokeWidth ||
|
|
|
|
|
|
|
|
mFillOpacity != aOther.mFillOpacity ||
|
2004-11-09 21:19:28 +03:00
|
|
|
mStrokeMiterlimit != aOther.mStrokeMiterlimit ||
|
|
|
|
mStrokeOpacity != aOther.mStrokeOpacity ||
|
2005-01-25 06:55:03 +03:00
|
|
|
|
|
|
|
mClipRule != aOther.mClipRule ||
|
|
|
|
mFillRule != aOther.mFillRule ||
|
|
|
|
mPointerEvents != aOther.mPointerEvents ||
|
|
|
|
mShapeRendering != aOther.mShapeRendering ||
|
|
|
|
mStrokeDasharrayLength != aOther.mStrokeDasharrayLength ||
|
|
|
|
mStrokeLinecap != aOther.mStrokeLinecap ||
|
|
|
|
mStrokeLinejoin != aOther.mStrokeLinejoin ||
|
2004-11-09 21:19:28 +03:00
|
|
|
mTextAnchor != aOther.mTextAnchor ||
|
|
|
|
mTextRendering != aOther.mTextRendering)
|
2001-12-12 10:59:31 +03:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
|
2005-04-05 01:42:26 +04:00
|
|
|
// length of stroke dasharrays are the same (tested above) - check entries
|
2004-11-09 21:19:28 +03:00
|
|
|
for (PRUint32 i=0; i<mStrokeDasharrayLength; i++)
|
|
|
|
if (mStrokeDasharray[i] != aOther.mStrokeDasharray[i])
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleSVG::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
// --------------------
|
|
|
|
// nsStyleSVGReset
|
|
|
|
//
|
|
|
|
nsStyleSVGReset::nsStyleSVGReset()
|
|
|
|
{
|
2005-04-05 01:42:26 +04:00
|
|
|
mStopColor.mType = eStyleSVGPaintType_Color;
|
|
|
|
mStopColor.mPaint.mColor = NS_RGB(0,0,0);
|
|
|
|
mClipPath = nsnull;
|
2005-09-07 02:30:40 +04:00
|
|
|
mFilter = nsnull;
|
2005-04-05 01:42:26 +04:00
|
|
|
mStopOpacity = 1.0f;
|
|
|
|
mDominantBaseline = NS_STYLE_DOMINANT_BASELINE_AUTO;
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGReset::~nsStyleSVGReset()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGReset::nsStyleSVGReset(const nsStyleSVGReset& aSource)
|
|
|
|
{
|
2005-04-05 01:42:26 +04:00
|
|
|
mStopColor = aSource.mStopColor;
|
2005-01-25 06:55:03 +03:00
|
|
|
mClipPath = aSource.mClipPath;
|
2005-09-07 02:30:40 +04:00
|
|
|
mFilter = aSource.mFilter;
|
2005-04-05 01:42:26 +04:00
|
|
|
mStopOpacity = aSource.mStopOpacity;
|
2005-01-25 06:55:03 +03:00
|
|
|
mDominantBaseline = aSource.mDominantBaseline;
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aOther) const
|
|
|
|
{
|
2005-04-05 01:42:26 +04:00
|
|
|
if (mStopColor != aOther.mStopColor ||
|
|
|
|
!EqualURIs(mClipPath, aOther.mClipPath) ||
|
2005-09-07 02:30:40 +04:00
|
|
|
!EqualURIs(mFilter, aOther.mFilter) ||
|
2005-04-05 01:42:26 +04:00
|
|
|
mStopOpacity != aOther.mStopOpacity ||
|
2005-01-25 06:55:03 +03:00
|
|
|
mDominantBaseline != aOther.mDominantBaseline)
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleSVGReset::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-10-15 03:02:53 +04:00
|
|
|
// nsStyleSVGPaint implementation
|
|
|
|
nsStyleSVGPaint::~nsStyleSVGPaint() {
|
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
|
|
|
NS_IF_RELEASE(mPaint.mPaintServer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGPaint& nsStyleSVGPaint::operator=(const nsStyleSVGPaint& aOther)
|
|
|
|
{
|
|
|
|
mType = aOther.mType;
|
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
|
|
|
mPaint.mPaintServer = aOther.mPaint.mPaintServer;
|
|
|
|
NS_IF_ADDREF(mPaint.mPaintServer);
|
|
|
|
} else {
|
|
|
|
mPaint.mColor = aOther.mPaint.mColor;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsStyleSVGPaint::operator==(const nsStyleSVGPaint& aOther) const
|
|
|
|
{
|
|
|
|
if (mType != aOther.mType)
|
|
|
|
return PR_FALSE;
|
2005-04-05 01:42:26 +04:00
|
|
|
if (mType == eStyleSVGPaintType_Server)
|
2004-10-15 03:02:53 +04:00
|
|
|
return EqualURIs(mPaint.mPaintServer, aOther.mPaint.mPaintServer);
|
2005-04-05 01:42:26 +04:00
|
|
|
if (mType == eStyleSVGPaintType_None)
|
|
|
|
return PR_TRUE;
|
2004-10-15 03:02:53 +04:00
|
|
|
return mPaint.mColor == aOther.mPaint.mColor;
|
|
|
|
}
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
#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
|
|
|
{
|
2004-05-22 09:50:12 +04:00
|
|
|
if (mZIndex != aOther.mZIndex) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
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) &&
|
2004-05-22 09:50:12 +04:00
|
|
|
(mBoxSizing == aOther.mBoxSizing))
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2004-05-22 09:50:12 +04:00
|
|
|
|
|
|
|
return nsChangeHint_ReflowFrame;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStylePosition::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// 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
|
|
|
{
|
2003-12-04 09:26:15 +03:00
|
|
|
// Changes in mRules may require reframing (if border-collapse stuff changes, for example).
|
|
|
|
if (mRules != aOther.mRules)
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if ((mLayoutStrategy == aOther.mLayoutStrategy) &&
|
|
|
|
(mFrame == aOther.mFrame) &&
|
|
|
|
(mCols == aOther.mCols) &&
|
|
|
|
(mSpan == aOther.mSpan))
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleTable::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// -----------------------
|
|
|
|
// nsStyleTableBorder
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleTableBorder::nsStyleTableBorder(nsPresContext* aPresContext)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
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)
|
2003-12-25 00:51:50 +03:00
|
|
|
compatMode = aPresContext->CompatibilityMode();
|
2002-06-26 01:16:17 +04:00
|
|
|
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;
|
2004-11-30 21:30:58 +03:00
|
|
|
mBorderSpacingX.SetCoordValue(0);
|
|
|
|
mBorderSpacingY.SetCoordValue(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2003-02-13 22:06:18 +03:00
|
|
|
// Border-collapse changes need a reframe, because we use a different frame
|
|
|
|
// class for table cells in the collapsed border model. This is used to
|
|
|
|
// conserve memory when using the separated border model (collapsed borders
|
|
|
|
// require extra state to be stored).
|
|
|
|
if (mBorderCollapse != aOther.mBorderCollapse) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((mCaptionSide == aOther.mCaptionSide) &&
|
2001-06-01 02:19:43 +04:00
|
|
|
(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;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleTableBorder::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleColor
|
|
|
|
//
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleColor::nsStyleColor(nsPresContext* aPresContext)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2004-02-01 01:41:40 +03:00
|
|
|
mColor = aPresContext->DefaultColor();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleColor::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleBackground
|
|
|
|
//
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleBackground::nsStyleBackground(nsPresContext* aPresContext)
|
2003-01-17 12:33:52 +03:00
|
|
|
: mBackgroundFlags(NS_STYLE_BG_COLOR_TRANSPARENT | NS_STYLE_BG_IMAGE_NONE),
|
|
|
|
mBackgroundAttachment(NS_STYLE_BG_ATTACHMENT_SCROLL),
|
|
|
|
mBackgroundClip(NS_STYLE_BG_CLIP_BORDER),
|
|
|
|
mBackgroundInlinePolicy(NS_STYLE_BG_INLINE_POLICY_CONTINUOUS),
|
|
|
|
mBackgroundOrigin(NS_STYLE_BG_ORIGIN_PADDING),
|
2003-01-19 05:36:04 +03:00
|
|
|
mBackgroundRepeat(NS_STYLE_BG_REPEAT_XY)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2004-02-01 01:41:40 +03:00
|
|
|
mBackgroundColor = aPresContext->DefaultBackgroundColor();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
|
2003-01-17 12:33:52 +03:00
|
|
|
: mBackgroundFlags(aSource.mBackgroundFlags),
|
|
|
|
mBackgroundAttachment(aSource.mBackgroundAttachment),
|
|
|
|
mBackgroundClip(aSource.mBackgroundClip),
|
|
|
|
mBackgroundInlinePolicy(aSource.mBackgroundInlinePolicy),
|
|
|
|
mBackgroundOrigin(aSource.mBackgroundOrigin),
|
|
|
|
mBackgroundRepeat(aSource.mBackgroundRepeat),
|
|
|
|
mBackgroundXPosition(aSource.mBackgroundXPosition),
|
|
|
|
mBackgroundYPosition(aSource.mBackgroundYPosition),
|
2003-01-19 05:36:04 +03:00
|
|
|
mBackgroundColor(aSource.mBackgroundColor),
|
2003-01-17 12:33:52 +03:00
|
|
|
mBackgroundImage(aSource.mBackgroundImage)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
nsStyleBackground::~nsStyleBackground()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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
|
2003-03-13 18:29:36 +03:00
|
|
|
// XXX This probably doesn't call ApplyRenderingChangeToTree, which
|
|
|
|
// means we might not invalidate the canvas if this is the body.
|
2002-01-27 10:53:27 +03:00
|
|
|
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) &&
|
2002-10-08 14:24:53 +04:00
|
|
|
(mBackgroundClip == aOther.mBackgroundClip) &&
|
2003-01-17 12:33:52 +03:00
|
|
|
(mBackgroundInlinePolicy == aOther.mBackgroundInlinePolicy) &&
|
2002-10-08 14:24:53 +04:00
|
|
|
(mBackgroundOrigin == aOther.mBackgroundOrigin) &&
|
2004-03-09 06:57:51 +03:00
|
|
|
EqualImages(mBackgroundImage, aOther.mBackgroundImage) &&
|
2003-01-19 05:36:04 +03:00
|
|
|
((!(mBackgroundFlags & NS_STYLE_BG_X_POSITION_PERCENT) ||
|
|
|
|
(mBackgroundXPosition.mFloat == aOther.mBackgroundXPosition.mFloat)) &&
|
|
|
|
(!(mBackgroundFlags & NS_STYLE_BG_X_POSITION_LENGTH) ||
|
|
|
|
(mBackgroundXPosition.mCoord == aOther.mBackgroundXPosition.mCoord))) &&
|
|
|
|
((!(mBackgroundFlags & NS_STYLE_BG_Y_POSITION_PERCENT) ||
|
|
|
|
(mBackgroundYPosition.mFloat == aOther.mBackgroundYPosition.mFloat)) &&
|
|
|
|
(!(mBackgroundFlags & NS_STYLE_BG_Y_POSITION_LENGTH) ||
|
|
|
|
(mBackgroundYPosition.mCoord == aOther.mBackgroundYPosition.mCoord))))
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleBackground::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-09-14 00:40:46 +04:00
|
|
|
PRBool nsStyleBackground::HasFixedBackground() const
|
|
|
|
{
|
|
|
|
return mBackgroundAttachment == NS_STYLE_BG_ATTACHMENT_FIXED &&
|
|
|
|
mBackgroundImage;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// 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;
|
2004-09-05 04:04:04 +04:00
|
|
|
mOverflowX = NS_STYLE_OVERFLOW_VISIBLE;
|
|
|
|
mOverflowY = NS_STYLE_OVERFLOW_VISIBLE;
|
2001-06-01 02:19:43 +04:00
|
|
|
mClipFlags = NS_STYLE_CLIP_AUTO;
|
|
|
|
mClip.SetRect(0,0,0,0);
|
2003-11-02 01:34:59 +03:00
|
|
|
mOpacity = 1.0f;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2004-09-05 04:04:04 +04:00
|
|
|
mOverflowX = aSource.mOverflowX;
|
|
|
|
mOverflowY = aSource.mOverflowY;
|
2001-06-01 02:19:43 +04:00
|
|
|
mClipFlags = aSource.mClipFlags;
|
|
|
|
mClip = aSource.mClip;
|
2003-11-02 01:34:59 +03:00
|
|
|
mOpacity = aSource.mOpacity;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2003-07-12 01:16:12 +04:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2002-09-30 15:56:37 +04:00
|
|
|
|
2003-10-04 10:36:33 +04:00
|
|
|
if (!EqualURIs(mBinding, aOther.mBinding)
|
2002-09-30 15:56:37 +04:00
|
|
|
|| mPosition != aOther.mPosition
|
|
|
|
|| mDisplay != aOther.mDisplay
|
2003-11-15 01:55:46 +03:00
|
|
|
|| (mFloats == NS_STYLE_FLOAT_NONE) != (aOther.mFloats == NS_STYLE_FLOAT_NONE)
|
2004-09-05 04:04:04 +04:00
|
|
|
|| mOverflowX != aOther.mOverflowX
|
|
|
|
|| mOverflowY != aOther.mOverflowY
|
2003-11-02 01:34:59 +03:00
|
|
|
// might need to create a view to handle change from 1.0 to partial opacity
|
|
|
|
|| (mOpacity != aOther.mOpacity
|
|
|
|
&& ((mOpacity < 1.0) != (aOther.mOpacity < 1.0))))
|
2002-09-30 15:56:37 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
|
|
|
|
|
2003-11-15 01:55:46 +03:00
|
|
|
if (mFloats != aOther.mFloats)
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReflowFrame);
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
// 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
|
2003-11-02 01:34:59 +03:00
|
|
|
|| mClip != aOther.mClip
|
|
|
|
|| mOpacity != aOther.mOpacity)
|
2002-09-30 15:56:37 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_SyncFrameView);
|
|
|
|
|
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleDisplay::MaxDifference()
|
|
|
|
{
|
|
|
|
// All the parts of FRAMECHANGE are present above in CalcDifference.
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleVisibility
|
|
|
|
//
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleVisibility::nsStyleVisibility(nsPresContext* aPresContext)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2004-07-29 23:41:39 +04:00
|
|
|
PRUint32 bidiOptions = aPresContext->GetBidi();
|
2001-06-01 02:19:43 +04:00
|
|
|
if (GET_BIDI_OPTION_DIRECTION(bidiOptions) == IBMBIDI_TEXTDIRECTION_RTL)
|
|
|
|
mDirection = NS_STYLE_DIRECTION_RTL;
|
|
|
|
else
|
|
|
|
mDirection = NS_STYLE_DIRECTION_LTR;
|
|
|
|
|
2004-06-09 03:53:59 +04:00
|
|
|
mLangGroup = aPresContext->GetLangGroup();
|
2001-06-01 02:19:43 +04:00
|
|
|
mVisible = NS_STYLE_VISIBILITY_VISIBLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
|
|
|
|
{
|
|
|
|
mDirection = aSource.mDirection;
|
|
|
|
mVisible = aSource.mVisible;
|
2004-06-09 03:53:59 +04:00
|
|
|
mLangGroup = aSource.mLangGroup;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if ((mDirection == aOther.mDirection) &&
|
2004-06-09 03:53:59 +04:00
|
|
|
(mLangGroup == aOther.mLangGroup)) {
|
2001-06-01 02:19:43 +04:00
|
|
|
if ((mVisible == aOther.mVisible)) {
|
2003-11-02 01:34:59 +03:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2005-05-03 07:46:51 +04:00
|
|
|
if ((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||
|
|
|
|
(NS_STYLE_VISIBILITY_COLLAPSE == aOther.mVisible)) {
|
2005-06-10 17:57:27 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2005-06-10 17:57:27 +04:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2005-06-10 17:57:27 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleVisibility::MaxDifference()
|
|
|
|
{
|
2005-06-10 17:57:27 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2004-10-01 07:33:05 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-07-15 02:19:22 +04:00
|
|
|
nsStyleContentData::~nsStyleContentData()
|
|
|
|
{
|
|
|
|
if (mType == eStyleContentType_Image) {
|
|
|
|
NS_IF_RELEASE(mContent.mImage);
|
2005-04-02 03:07:00 +04:00
|
|
|
} else if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters) {
|
|
|
|
mContent.mCounters->Release();
|
2004-07-15 02:19:22 +04:00
|
|
|
} else if (mContent.mString) {
|
|
|
|
nsCRT::free(mContent.mString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContentData& nsStyleContentData::operator=(const nsStyleContentData& aOther)
|
|
|
|
{
|
2005-04-02 03:07:00 +04:00
|
|
|
if (this == &aOther)
|
|
|
|
return *this;
|
|
|
|
this->~nsStyleContentData();
|
2004-07-15 02:19:22 +04:00
|
|
|
mType = aOther.mType;
|
|
|
|
if (mType == eStyleContentType_Image) {
|
|
|
|
mContent.mImage = aOther.mContent.mImage;
|
|
|
|
NS_IF_ADDREF(mContent.mImage);
|
2005-04-02 03:07:00 +04:00
|
|
|
} else if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters) {
|
|
|
|
mContent.mCounters = aOther.mContent.mCounters;
|
|
|
|
mContent.mCounters->AddRef();
|
2004-07-15 02:19:22 +04:00
|
|
|
} else if (aOther.mContent.mString) {
|
|
|
|
mContent.mString = nsCRT::strdup(aOther.mContent.mString);
|
|
|
|
} else {
|
|
|
|
mContent.mString = nsnull;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsStyleContentData::operator==(const nsStyleContentData& aOther)
|
|
|
|
{
|
|
|
|
if (mType != aOther.mType)
|
|
|
|
return PR_FALSE;
|
|
|
|
if (mType == eStyleContentType_Image) {
|
2005-09-20 06:02:21 +04:00
|
|
|
if (!mContent.mImage || !aOther.mContent.mImage)
|
|
|
|
return mContent.mImage == aOther.mContent.mImage;
|
2004-07-15 02:19:22 +04:00
|
|
|
PRBool eq;
|
|
|
|
nsCOMPtr<nsIURI> thisURI, otherURI;
|
|
|
|
mContent.mImage->GetURI(getter_AddRefs(thisURI));
|
|
|
|
aOther.mContent.mImage->GetURI(getter_AddRefs(otherURI));
|
|
|
|
return thisURI == otherURI || // handles null==null
|
|
|
|
(thisURI && otherURI &&
|
|
|
|
NS_SUCCEEDED(thisURI->Equals(otherURI, &eq)) &&
|
|
|
|
eq);
|
|
|
|
}
|
2005-04-02 03:07:00 +04:00
|
|
|
if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters)
|
|
|
|
return *mContent.mCounters == *aOther.mContent.mCounters;
|
2004-07-15 02:19:22 +04:00
|
|
|
return nsCRT::strcmp(mContent.mString, aOther.mContent.mString) == 0;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
//-----------------------
|
|
|
|
// 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++) {
|
2003-10-02 02:53:56 +04:00
|
|
|
ContentAt(index) = aSource.ContentAt(index);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(AllocateCounterIncrements(aSource.CounterIncrementCount()))) {
|
|
|
|
for (index = 0; index < mIncrementCount; index++) {
|
2005-04-02 03:07:00 +04:00
|
|
|
const nsStyleCounterData *data = aSource.GetCounterIncrementAt(index);
|
|
|
|
mIncrements[index].mCounter = data->mCounter;
|
|
|
|
mIncrements[index].mValue = data->mValue;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(AllocateCounterResets(aSource.CounterResetCount()))) {
|
|
|
|
for (index = 0; index < mResetCount; index++) {
|
2005-04-02 03:07:00 +04:00
|
|
|
const nsStyleCounterData *data = aSource.GetCounterResetAt(index);
|
|
|
|
mResets[index].mCounter = data->mCounter;
|
|
|
|
mResets[index].mValue = data->mValue;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleContent::CalcDifference(const nsStyleContent& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2005-04-02 03:07:00 +04:00
|
|
|
if (mContentCount != aOther.mContentCount ||
|
|
|
|
mIncrementCount != aOther.mIncrementCount ||
|
|
|
|
mResetCount != aOther.mResetCount) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 ix = mContentCount;
|
|
|
|
while (0 < ix--) {
|
|
|
|
if (mContents[ix] != aOther.mContents[ix]) {
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ix = mIncrementCount;
|
|
|
|
while (0 < ix--) {
|
|
|
|
if ((mIncrements[ix].mValue != aOther.mIncrements[ix].mValue) ||
|
|
|
|
(mIncrements[ix].mCounter != aOther.mIncrements[ix].mCounter)) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ix = mResetCount;
|
|
|
|
while (0 < ix--) {
|
|
|
|
if ((mResets[ix].mValue != aOther.mResets[ix].mValue) ||
|
|
|
|
(mResets[ix].mCounter != aOther.mResets[ix].mCounter)) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2005-04-02 03:07:00 +04:00
|
|
|
}
|
|
|
|
if (mMarkerOffset != aOther.mMarkerOffset) {
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
2005-04-02 03:07:00 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleContent::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-07-15 03:51:25 +04:00
|
|
|
nsresult nsStyleContent::AllocateContents(PRUint32 aCount)
|
|
|
|
{
|
|
|
|
if (aCount != mContentCount) {
|
|
|
|
DELETE_ARRAY_IF(mContents);
|
|
|
|
if (aCount) {
|
|
|
|
mContents = new nsStyleContentData[aCount];
|
|
|
|
if (! mContents) {
|
|
|
|
mContentCount = 0;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mContentCount = aCount;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// ---------------------
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleQuotes::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
mUnicodeBidi = NS_STYLE_UNICODE_BIDI_NORMAL;
|
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
|
2003-01-17 15:09:23 +03:00
|
|
|
&& mUnicodeBidi == aOther.mUnicodeBidi) {
|
2004-05-02 08:51:08 +04:00
|
|
|
if (mTextDecoration != aOther.mTextDecoration) {
|
|
|
|
// Reflow for blink changes, repaint for others
|
|
|
|
return
|
|
|
|
(mTextDecoration & NS_STYLE_TEXT_DECORATION_BLINK) ==
|
|
|
|
(aOther.mTextDecoration & NS_STYLE_TEXT_DECORATION_BLINK) ?
|
|
|
|
NS_STYLE_HINT_VISUAL : NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleTextReset::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleText::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleUserInterface
|
|
|
|
//
|
|
|
|
|
2005-07-01 08:29:42 +04:00
|
|
|
nsCursorImage::nsCursorImage()
|
|
|
|
: mHaveHotspot(PR_FALSE)
|
|
|
|
, mHotspotX(0.0f)
|
|
|
|
, mHotspotY(0.0f)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
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
|
2005-07-01 08:29:42 +04:00
|
|
|
|
|
|
|
mCursorArrayLength = 0;
|
|
|
|
mCursorArray = nsnull;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-12-28 16:48:25 +03:00
|
|
|
nsStyleUserInterface::nsStyleUserInterface(const nsStyleUserInterface& aSource) :
|
|
|
|
mUserInput(aSource.mUserInput),
|
|
|
|
mUserModify(aSource.mUserModify),
|
|
|
|
mUserFocus(aSource.mUserFocus),
|
2005-07-01 08:29:42 +04:00
|
|
|
mCursor(aSource.mCursor)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2005-07-01 08:29:42 +04:00
|
|
|
CopyCursorArrayFrom(aSource);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUserInterface::~nsStyleUserInterface(void)
|
|
|
|
{
|
2005-07-01 08:29:42 +04:00
|
|
|
delete [] mCursorArray;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2004-12-28 16:48:25 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2004-01-18 04:12:58 +03:00
|
|
|
if (mCursor != aOther.mCursor)
|
2004-12-28 16:48:25 +03:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateCursor);
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2004-12-31 00:56:11 +03:00
|
|
|
// We could do better. But it wouldn't be worth it, URL-specified cursors are
|
|
|
|
// rare.
|
2005-07-01 08:29:42 +04:00
|
|
|
if (mCursorArrayLength > 0 || aOther.mCursorArrayLength > 0)
|
2004-12-31 00:56:11 +03:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateCursor);
|
|
|
|
|
2004-12-28 16:48:25 +03:00
|
|
|
if (mUserModify != aOther.mUserModify)
|
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_VISUAL);
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
if ((mUserInput != aOther.mUserInput) &&
|
|
|
|
((NS_STYLE_USER_INPUT_NONE == mUserInput) ||
|
|
|
|
(NS_STYLE_USER_INPUT_NONE == aOther.mUserInput))) {
|
2004-12-28 16:48:25 +03:00
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_FRAMECHANGE);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-12-28 16:48:25 +03:00
|
|
|
// ignore mUserFocus
|
|
|
|
|
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-10-01 07:33:05 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleUserInterface::MaxDifference()
|
|
|
|
{
|
2004-12-28 16:48:25 +03:00
|
|
|
return nsChangeHint(nsChangeHint_UpdateCursor | NS_STYLE_HINT_FRAMECHANGE);
|
2004-10-01 07:33:05 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-07-01 08:29:42 +04:00
|
|
|
void
|
|
|
|
nsStyleUserInterface::CopyCursorArrayFrom(const nsStyleUserInterface& aSource)
|
|
|
|
{
|
|
|
|
mCursorArray = nsnull;
|
|
|
|
mCursorArrayLength = 0;
|
|
|
|
if (aSource.mCursorArrayLength) {
|
|
|
|
mCursorArray = new nsCursorImage[aSource.mCursorArrayLength];
|
|
|
|
if (mCursorArray) {
|
|
|
|
mCursorArrayLength = aSource.mCursorArrayLength;
|
|
|
|
for (PRUint32 i = 0; i < mCursorArrayLength; ++i)
|
|
|
|
mCursorArray[i] = aSource.mCursorArray[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleUIReset
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleUIReset::nsStyleUIReset(void)
|
|
|
|
{
|
|
|
|
mUserSelect = NS_STYLE_USER_SELECT_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;
|
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) {
|
2004-05-06 01:37:32 +04:00
|
|
|
if (mUserSelect == aOther.mUserSelect) {
|
2003-07-12 01:16:12 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2004-10-01 07:33:05 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleUIReset::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|