2001-09-25 01:32:19 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-05-31 22:19:43 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00: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-05-31 22:19:43 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00: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-05-31 22:19:43 +00:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 01:32:19 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-05-31 22:19:43 +00:00
|
|
|
*
|
2001-09-25 01:32:19 +00:00
|
|
|
* Contributor(s):
|
2004-04-12 21:54:45 +00:00
|
|
|
* David Hyatt (hyatt@netscape.com)
|
2005-03-27 11:36:08 +00:00
|
|
|
* Mats Palmgren <mats.palmgren@bredband.net>
|
2008-06-05 23:06:34 +00:00
|
|
|
* Michael Ventnor <m.ventnor@gmail.com>
|
2001-09-25 01:32:19 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00: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 01:32:19 +00: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-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 01:32:19 +00: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-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 01:32:19 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2006-03-25 05:47:31 +00:00
|
|
|
/*
|
|
|
|
* structs that contain the data provided by nsStyleContext, the
|
|
|
|
* internal API for computed style data for an element
|
|
|
|
*/
|
|
|
|
|
2002-07-03 17:14:41 +00:00
|
|
|
#include "nsStyleStruct.h"
|
2008-07-17 06:30:25 +00:00
|
|
|
#include "nsStyleStructInlines.h"
|
2001-05-31 22:19:43 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2007-09-05 10:27:06 +00:00
|
|
|
#include "nsThemeConstants.h"
|
2001-05-31 22:19:43 +00:00
|
|
|
#include "nsString.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2003-03-13 15:29:36 +00:00
|
|
|
#include "nsIDeviceContext.h"
|
2009-04-01 21:59:02 +00:00
|
|
|
#include "nsIWidget.h"
|
2001-05-31 22:19:43 +00:00
|
|
|
#include "nsIStyleRule.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIPresShell.h"
|
2001-10-24 00:01:09 +00:00
|
|
|
#include "nsIFrame.h"
|
2004-11-25 02:43:28 +00:00
|
|
|
#include "nsHTMLReflowState.h"
|
2001-05-31 22:19:43 +00:00
|
|
|
#include "prenv.h"
|
|
|
|
|
2002-02-19 20:41:32 +00:00
|
|
|
#include "nsBidiUtils.h"
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2004-03-09 03:57:51 +00:00
|
|
|
#include "imgIRequest.h"
|
2007-10-08 21:58:22 +00:00
|
|
|
#include "prlog.h"
|
|
|
|
|
|
|
|
// Make sure we have enough bits in NS_STYLE_INHERIT_MASK.
|
|
|
|
PR_STATIC_ASSERT((((1 << nsStyleStructID_Length) - 1) &
|
|
|
|
~(NS_STYLE_INHERIT_MASK)) == 0);
|
2004-03-09 03:57:51 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
inline PRBool IsFixedUnit(nsStyleUnit aUnit, PRBool aEnumOK)
|
|
|
|
{
|
2007-05-11 06:02:31 +00:00
|
|
|
return PRBool((aUnit == eStyleUnit_Coord) ||
|
2001-05-31 22:19:43 +00:00
|
|
|
(aEnumOK && (aUnit == eStyleUnit_Enumerated)));
|
|
|
|
}
|
|
|
|
|
2003-10-04 06:36:33 +00: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);
|
|
|
|
}
|
|
|
|
|
2007-07-18 21:56:57 +00:00
|
|
|
static PRBool EqualURIs(nsCSSValue::URL *aURI1, nsCSSValue::URL *aURI2)
|
|
|
|
{
|
|
|
|
return aURI1 == aURI2 || // handle null==null, and optimize
|
|
|
|
(aURI1 && aURI2 && aURI1->URIEquals(*aURI2));
|
|
|
|
}
|
|
|
|
|
2004-03-09 03:57:51 +00: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);
|
|
|
|
}
|
|
|
|
|
2008-07-08 00:56:52 +00:00
|
|
|
static nsChangeHint CalcShadowDifference(nsCSSShadowArray* lhs,
|
|
|
|
nsCSSShadowArray* rhs);
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleFont
|
|
|
|
//
|
2008-01-09 09:38:28 +00:00
|
|
|
nsStyleFont::nsStyleFont(const nsFont& aFont, nsPresContext *aPresContext)
|
|
|
|
: mFont(aFont),
|
2008-10-10 14:56:18 +00:00
|
|
|
mGenericID(kGenericFont_NONE)
|
2001-09-27 18:33:58 +00:00
|
|
|
{
|
2008-01-09 09:38:28 +00:00
|
|
|
mSize = mFont.size = nsStyleFont::ZoomText(aPresContext, mFont.size);
|
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
mScriptUnconstrainedSize = mSize;
|
|
|
|
mScriptMinSize = aPresContext->TwipsToAppUnits(
|
|
|
|
NS_POINTS_TO_TWIPS(NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT));
|
|
|
|
mScriptLevel = 0;
|
|
|
|
mScriptSizeMultiplier = NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER;
|
|
|
|
#endif
|
2001-09-27 18:33:58 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
|
|
|
|
nsStyleFont::nsStyleFont(const nsStyleFont& aSrc)
|
2008-01-09 09:38:28 +00:00
|
|
|
: mFont(aSrc.mFont)
|
|
|
|
, mSize(aSrc.mSize)
|
2008-10-10 14:56:18 +00:00
|
|
|
, mGenericID(aSrc.mGenericID)
|
2008-01-09 09:38:28 +00:00
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
, mScriptLevel(aSrc.mScriptLevel)
|
|
|
|
, mScriptUnconstrainedSize(aSrc.mScriptUnconstrainedSize)
|
|
|
|
, mScriptMinSize(aSrc.mScriptMinSize)
|
2008-02-19 07:36:50 +00:00
|
|
|
, mScriptSizeMultiplier(aSrc.mScriptSizeMultiplier)
|
2008-01-09 09:38:28 +00:00
|
|
|
#endif
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleFont::nsStyleFont(nsPresContext* aPresContext)
|
2008-01-09 09:38:28 +00:00
|
|
|
: mFont(*(aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID))),
|
2008-10-10 14:56:18 +00:00
|
|
|
mGenericID(kGenericFont_NONE)
|
2003-03-13 15:29:36 +00:00
|
|
|
{
|
|
|
|
mSize = mFont.size = nsStyleFont::ZoomText(aPresContext, mFont.size);
|
2008-01-09 09:38:28 +00:00
|
|
|
#ifdef MOZ_MATHML
|
|
|
|
mScriptUnconstrainedSize = mSize;
|
|
|
|
mScriptMinSize = aPresContext->TwipsToAppUnits(
|
|
|
|
NS_POINTS_TO_TWIPS(NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT));
|
|
|
|
mScriptLevel = 0;
|
|
|
|
mScriptSizeMultiplier = NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER;
|
|
|
|
#endif
|
2003-03-13 15:29:36 +00:00
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
void*
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleFont::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 00:28:44 +00:00
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
2001-05-31 22:19:43 +00:00
|
|
|
if (result)
|
2004-04-13 00:28:44 +00:00
|
|
|
memset(result, 0, sz);
|
2001-05-31 22:19:43 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleFont::Destroy(nsPresContext* aContext) {
|
2001-06-01 21:04:23 +00:00
|
|
|
this->~nsStyleFont();
|
2001-05-31 22:19:43 +00:00
|
|
|
aContext->FreeToShell(sizeof(nsStyleFont), this);
|
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2001-09-27 18:33:58 +00:00
|
|
|
if (mSize == aOther.mSize) {
|
|
|
|
return CalcFontDifference(mFont, aOther.mFont);
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleFont::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-03-13 15:29:36 +00:00
|
|
|
/* static */ nscoord
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleFont::ZoomText(nsPresContext *aPresContext, nscoord aSize)
|
2003-03-13 15:29:36 +00:00
|
|
|
{
|
2005-08-13 11:54:22 +00:00
|
|
|
return nscoord(float(aSize) * aPresContext->TextZoom());
|
2003-03-13 15:29:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nscoord
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleFont::UnZoomText(nsPresContext *aPresContext, nscoord aSize)
|
2003-03-13 15:29:36 +00:00
|
|
|
{
|
2005-08-13 11:54:22 +00:00
|
|
|
return nscoord(float(aSize) / aPresContext->TextZoom());
|
2003-03-13 15:29:36 +00:00
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleFont::CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
if ((aFont1.size == aFont2.size) &&
|
2001-09-27 18:33:58 +00:00
|
|
|
(aFont1.sizeAdjust == aFont2.sizeAdjust) &&
|
2001-05-31 22:19:43 +00:00
|
|
|
(aFont1.style == aFont2.style) &&
|
|
|
|
(aFont1.variant == aFont2.variant) &&
|
2002-11-12 15:17:07 +00:00
|
|
|
(aFont1.familyNameQuirks == aFont2.familyNameQuirks) &&
|
2001-05-31 22:19:43 +00:00
|
|
|
(aFont1.weight == aFont2.weight) &&
|
2009-01-29 20:39:18 +00:00
|
|
|
(aFont1.stretch == aFont2.stretch) &&
|
2001-09-24 15:26:39 +00:00
|
|
|
(aFont1.name == aFont2.name)) {
|
2001-05-31 22:19:43 +00: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-12 21:54:45 +00:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
if (!IsFixedUnit(aSides.GetUnit(side), aEnumOK))
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nscoord CalcCoord(const nsStyleCoord& aCoord,
|
|
|
|
const nscoord* aEnumTable,
|
|
|
|
PRInt32 aNumEnums)
|
|
|
|
{
|
|
|
|
switch (aCoord.GetUnit()) {
|
|
|
|
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() {
|
2007-05-11 05:58:34 +00:00
|
|
|
nsStyleCoord zero(0);
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mMargin.Set(side, zero);
|
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
mHasCachedMargin = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleMargin::nsStyleMargin(const nsStyleMargin& aSrc) {
|
|
|
|
mMargin = aSrc.mMargin;
|
|
|
|
mHasCachedMargin = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleMargin::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 00:28:44 +00:00
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
2001-05-31 22:19:43 +00:00
|
|
|
if (result)
|
2004-04-13 00:28:44 +00:00
|
|
|
memset(result, 0, sz);
|
2001-05-31 22:19:43 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleMargin::Destroy(nsPresContext* aContext) {
|
2001-06-01 21:04:23 +00:00
|
|
|
this->~nsStyleMargin();
|
2001-05-31 22:19:43 +00:00
|
|
|
aContext->FreeToShell(sizeof(nsStyleMargin), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nsStyleMargin::RecalcData()
|
|
|
|
{
|
|
|
|
if (IsFixedData(mMargin, PR_FALSE)) {
|
2004-04-12 21:54:45 +00:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2008-03-06 00:05:26 +00:00
|
|
|
mCachedMargin.side(side) = CalcCoord(mMargin.Get(side), nsnull, 0);
|
2004-04-12 21:54:45 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
mHasCachedMargin = PR_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mHasCachedMargin = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleMargin::CalcDifference(const nsStyleMargin& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
if (mMargin == aOther.mMargin) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleMargin::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStylePadding::nsStylePadding() {
|
2007-05-11 05:58:34 +00:00
|
|
|
nsStyleCoord zero(0);
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mPadding.Set(side, zero);
|
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
mHasCachedPadding = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePadding::nsStylePadding(const nsStylePadding& aSrc) {
|
|
|
|
mPadding = aSrc.mPadding;
|
|
|
|
mHasCachedPadding = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void*
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStylePadding::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 00:28:44 +00:00
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
2001-05-31 22:19:43 +00:00
|
|
|
if (result)
|
2004-04-13 00:28:44 +00:00
|
|
|
memset(result, 0, sz);
|
2001-05-31 22:19:43 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStylePadding::Destroy(nsPresContext* aContext) {
|
2001-06-01 21:04:23 +00:00
|
|
|
this->~nsStylePadding();
|
2001-05-31 22:19:43 +00:00
|
|
|
aContext->FreeToShell(sizeof(nsStylePadding), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsStylePadding::RecalcData()
|
|
|
|
{
|
|
|
|
if (IsFixedData(mPadding, PR_FALSE)) {
|
2004-04-12 21:54:45 +00:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2008-03-06 00:05:26 +00:00
|
|
|
mCachedPadding.side(side) = CalcCoord(mPadding.Get(side), nsnull, 0);
|
2004-04-12 21:54:45 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
mHasCachedPadding = PR_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mHasCachedPadding = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStylePadding::CalcDifference(const nsStylePadding& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
if (mPadding == aOther.mPadding) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStylePadding::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext)
|
2008-07-17 06:30:25 +00:00
|
|
|
: mHaveBorderImageWidth(PR_FALSE),
|
|
|
|
mComputedBorder(0, 0, 0, 0),
|
|
|
|
mBorderImage(nsnull)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2005-04-29 15:44:38 +00: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);
|
2008-10-01 05:50:52 +00:00
|
|
|
}
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
mBorderRadius.Set(corner, nsStyleCoord(0));
|
2005-04-29 15:44:38 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2001-12-05 08:35:05 +00:00
|
|
|
mBorderColors = nsnull;
|
2008-07-08 00:56:52 +00:00
|
|
|
mBoxShadow = nsnull;
|
2001-12-05 08:35:05 +00:00
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
mFloatEdge = NS_STYLE_FLOAT_EDGE_CONTENT;
|
2006-12-27 14:21:43 +00:00
|
|
|
|
2007-02-07 07:46:44 +00:00
|
|
|
mTwipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2008-10-17 08:13:16 +00:00
|
|
|
nsBorderColors::~nsBorderColors()
|
|
|
|
{
|
|
|
|
NS_CSS_DELETE_LIST_MEMBER(nsBorderColors, this, mNext);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBorderColors*
|
|
|
|
nsBorderColors::Clone(PRBool aDeep) const
|
|
|
|
{
|
|
|
|
nsBorderColors* result = new nsBorderColors(mColor);
|
|
|
|
if (NS_UNLIKELY(!result))
|
|
|
|
return result;
|
|
|
|
if (aDeep)
|
|
|
|
NS_CSS_CLONE_LIST_MEMBER(nsBorderColors, this, mNext, result, (PR_FALSE));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleBorder::nsStyleBorder(const nsStyleBorder& aSrc)
|
2008-07-17 06:30:25 +00:00
|
|
|
: mBorderRadius(aSrc.mBorderRadius),
|
|
|
|
mBorderImageSplit(aSrc.mBorderImageSplit),
|
2008-07-17 05:59:14 +00:00
|
|
|
mFloatEdge(aSrc.mFloatEdge),
|
2008-07-17 06:30:25 +00:00
|
|
|
mBorderImageHFill(aSrc.mBorderImageHFill),
|
|
|
|
mBorderImageVFill(aSrc.mBorderImageVFill),
|
2008-10-17 08:13:16 +00:00
|
|
|
mBorderColors(nsnull),
|
2008-07-17 06:30:25 +00:00
|
|
|
mBoxShadow(aSrc.mBoxShadow),
|
|
|
|
mHaveBorderImageWidth(aSrc.mHaveBorderImageWidth),
|
|
|
|
mBorderImageWidth(aSrc.mBorderImageWidth),
|
|
|
|
mComputedBorder(aSrc.mComputedBorder),
|
|
|
|
mBorder(aSrc.mBorder),
|
|
|
|
mBorderImage(aSrc.mBorderImage),
|
|
|
|
mTwipsPerPixel(aSrc.mTwipsPerPixel)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2001-12-05 08:35:05 +00:00
|
|
|
if (aSrc.mBorderColors) {
|
|
|
|
EnsureBorderColors();
|
|
|
|
for (PRInt32 i = 0; i < 4; i++)
|
|
|
|
if (aSrc.mBorderColors[i])
|
2008-10-17 08:13:16 +00:00
|
|
|
mBorderColors[i] = aSrc.mBorderColors[i]->Clone();
|
2001-12-05 08:35:05 +00:00
|
|
|
else
|
|
|
|
mBorderColors[i] = nsnull;
|
|
|
|
}
|
2008-07-08 00:56:52 +00:00
|
|
|
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mBorderStyle[side] = aSrc.mBorderStyle[side];
|
|
|
|
mBorderColor[side] = aSrc.mBorderColor[side];
|
|
|
|
}
|
2008-10-01 05:50:52 +00:00
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
mBorderRadius.Set(corner, aSrc.mBorderRadius.Get(corner));
|
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2008-07-17 06:30:25 +00:00
|
|
|
nsStyleBorder::~nsStyleBorder()
|
|
|
|
{
|
|
|
|
if (mBorderColors) {
|
|
|
|
for (PRInt32 i = 0; i < 4; i++)
|
|
|
|
delete mBorderColors[i];
|
|
|
|
delete [] mBorderColors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
void*
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleBorder::operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
|
2004-04-13 00:28:44 +00:00
|
|
|
void* result = aContext->AllocateFromShell(sz);
|
2001-05-31 22:19:43 +00:00
|
|
|
if (result)
|
2004-04-13 00:28:44 +00:00
|
|
|
memset(result, 0, sz);
|
2001-05-31 22:19:43 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleBorder::Destroy(nsPresContext* aContext) {
|
2001-06-01 21:04:23 +00:00
|
|
|
this->~nsStyleBorder();
|
2001-05-31 22:19:43 +00:00
|
|
|
aContext->FreeToShell(sizeof(nsStyleBorder), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2008-11-03 00:58:46 +00:00
|
|
|
nsChangeHint shadowDifference =
|
|
|
|
CalcShadowDifference(mBoxShadow, aOther.mBoxShadow);
|
|
|
|
|
2005-04-29 15:44:38 +00:00
|
|
|
// Note that differences in mBorder don't affect rendering (which should only
|
|
|
|
// use mComputedBorder), so don't need to be tested for here.
|
2008-11-03 00:58:46 +00:00
|
|
|
if (mTwipsPerPixel != aOther.mTwipsPerPixel ||
|
|
|
|
GetActualBorder() != aOther.GetActualBorder() ||
|
|
|
|
mFloatEdge != aOther.mFloatEdge ||
|
|
|
|
(shadowDifference & nsChangeHint_ReflowFrame))
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2005-04-29 15:44:38 +00:00
|
|
|
|
2008-11-03 00:58:46 +00:00
|
|
|
// Note that mBorderStyle stores not only the border style but also
|
|
|
|
// 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.
|
|
|
|
NS_FOR_CSS_SIDES(ix) {
|
|
|
|
if (mBorderStyle[ix] != aOther.mBorderStyle[ix] ||
|
|
|
|
mBorderColor[ix] != aOther.mBorderColor[ix])
|
2001-12-19 11:59:31 +00:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2008-11-03 00:58:46 +00:00
|
|
|
}
|
2001-12-19 11:59:31 +00:00
|
|
|
|
2008-11-03 00:58:46 +00:00
|
|
|
if (mBorderRadius != aOther.mBorderRadius ||
|
|
|
|
!mBorderColors != !aOther.mBorderColors)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2008-07-26 16:14:49 +00:00
|
|
|
|
2008-11-03 00:58:46 +00:00
|
|
|
if (IsBorderImageLoaded() || aOther.IsBorderImageLoaded()) {
|
|
|
|
if (mBorderImage != aOther.mBorderImage ||
|
|
|
|
mBorderImageHFill != aOther.mBorderImageHFill ||
|
|
|
|
mBorderImageVFill != aOther.mBorderImageVFill ||
|
|
|
|
mBorderImageSplit != aOther.mBorderImageSplit)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
// The call to GetActualBorder above already considered
|
|
|
|
// mBorderImageWidth and mHaveBorderImageWidth.
|
|
|
|
}
|
2001-12-19 11:59:31 +00:00
|
|
|
|
2008-11-03 00:58:46 +00:00
|
|
|
// Note that at this point if mBorderColors is non-null so is
|
|
|
|
// aOther.mBorderColors
|
|
|
|
if (mBorderColors) {
|
|
|
|
NS_FOR_CSS_SIDES(ix) {
|
|
|
|
if (!nsBorderColors::Equal(mBorderColors[ix],
|
|
|
|
aOther.mBorderColors[ix]))
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
2008-11-03 00:58:46 +00:00
|
|
|
|
|
|
|
return shadowDifference;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleBorder::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-07-17 06:30:25 +00:00
|
|
|
PRBool
|
|
|
|
nsStyleBorder::ImageBorderDiffers() const
|
|
|
|
{
|
|
|
|
return mComputedBorder !=
|
|
|
|
(mHaveBorderImageWidth ? mBorderImageWidth : mBorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsMargin&
|
|
|
|
nsStyleBorder::GetActualBorder() const
|
|
|
|
{
|
|
|
|
if (IsBorderImageLoaded())
|
|
|
|
if (mHaveBorderImageWidth)
|
|
|
|
return mBorderImageWidth;
|
|
|
|
else
|
|
|
|
return mBorder;
|
|
|
|
else
|
|
|
|
return mComputedBorder;
|
|
|
|
}
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleOutline::nsStyleOutline(nsPresContext* aPresContext)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
// spacing values not inherited
|
2005-09-19 15:47:26 +00:00
|
|
|
nsStyleCoord zero(0);
|
2008-10-01 05:50:52 +00:00
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
mOutlineRadius.Set(corner, zero);
|
2005-09-19 15:47:26 +00:00
|
|
|
}
|
|
|
|
|
2008-09-13 03:45:37 +00:00
|
|
|
mOutlineOffset = 0;
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2005-03-27 11:36:08 +00:00
|
|
|
mOutlineWidth = nsStyleCoord(NS_STYLE_BORDER_WIDTH_MEDIUM, eStyleUnit_Enumerated);
|
2001-05-31 22:19:43 +00:00
|
|
|
mOutlineStyle = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
mOutlineColor = NS_RGB(0, 0, 0);
|
|
|
|
|
|
|
|
mHasCachedOutline = PR_FALSE;
|
2007-02-07 07:46:44 +00:00
|
|
|
mTwipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleOutline::nsStyleOutline(const nsStyleOutline& aSrc) {
|
2002-01-12 03:18:55 +00:00
|
|
|
memcpy((nsStyleOutline*)this, &aSrc, sizeof(nsStyleOutline));
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-11-26 18:40:58 +00:00
|
|
|
nsStyleOutline::RecalcData(nsPresContext* aContext)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2005-03-27 11:36:08 +00:00
|
|
|
if (NS_STYLE_BORDER_STYLE_NONE == GetOutlineStyle()) {
|
|
|
|
mCachedOutlineWidth = 0;
|
|
|
|
mHasCachedOutline = PR_TRUE;
|
|
|
|
} else if (IsFixedUnit(mOutlineWidth.GetUnit(), PR_TRUE)) {
|
2006-12-27 14:21:43 +00:00
|
|
|
mCachedOutlineWidth =
|
|
|
|
CalcCoord(mOutlineWidth, aContext->GetBorderWidthTable(), 3);
|
|
|
|
mCachedOutlineWidth =
|
|
|
|
NS_ROUND_BORDER_TO_PIXELS(mCachedOutlineWidth, mTwipsPerPixel);
|
2001-05-31 22:19:43 +00:00
|
|
|
mHasCachedOutline = PR_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mHasCachedOutline = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleOutline::CalcDifference(const nsStyleOutline& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2004-07-16 16:56:21 +00: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 12:57:15 +00:00
|
|
|
if (outlineWasVisible != outlineIsVisible ||
|
|
|
|
(outlineIsVisible && (mOutlineOffset != aOther.mOutlineOffset ||
|
2006-12-27 14:21:43 +00:00
|
|
|
mOutlineWidth != aOther.mOutlineWidth ||
|
|
|
|
mTwipsPerPixel != aOther.mTwipsPerPixel))) {
|
2004-07-16 16:56:21 +00:00
|
|
|
return NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame);
|
|
|
|
}
|
|
|
|
if ((mOutlineStyle != aOther.mOutlineStyle) ||
|
2001-05-31 22:19:43 +00:00
|
|
|
(mOutlineColor != aOther.mOutlineColor) ||
|
|
|
|
(mOutlineRadius != aOther.mOutlineRadius)) {
|
2004-07-16 16:56:21 +00:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleOutline::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleList
|
|
|
|
//
|
|
|
|
nsStyleList::nsStyleList()
|
2004-01-15 22:06:39 +00:00
|
|
|
: mListStyleType(NS_STYLE_LIST_STYLE_DISC),
|
|
|
|
mListStylePosition(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::~nsStyleList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::nsStyleList(const nsStyleList& aSource)
|
2003-10-01 22:53:56 +00:00
|
|
|
: mListStyleType(aSource.mListStyleType),
|
|
|
|
mListStylePosition(aSource.mListStylePosition),
|
2004-01-15 02:24:17 +00:00
|
|
|
mListStyleImage(aSource.mListStyleImage),
|
|
|
|
mImageRegion(aSource.mImageRegion)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (mListStylePosition != aOther.mListStylePosition)
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
if (EqualImages(mListStyleImage, aOther.mListStyleImage) &&
|
2002-11-06 07:31:27 +00: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-05-31 22:19:43 +00:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleList::MaxDifference()
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2004-10-01 03:33:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleXUL
|
|
|
|
//
|
|
|
|
nsStyleXUL::nsStyleXUL()
|
|
|
|
{
|
2001-08-02 00:09:27 +00:00
|
|
|
mBoxAlign = NS_STYLE_BOX_ALIGN_STRETCH;
|
|
|
|
mBoxDirection = NS_STYLE_BOX_DIRECTION_NORMAL;
|
|
|
|
mBoxFlex = 0.0f;
|
2001-05-31 22:19:43 +00:00
|
|
|
mBoxOrient = NS_STYLE_BOX_ORIENT_HORIZONTAL;
|
2001-08-02 00:09:27 +00:00
|
|
|
mBoxPack = NS_STYLE_BOX_PACK_START;
|
2001-09-25 22:17:00 +00:00
|
|
|
mBoxOrdinal = 1;
|
2008-06-05 06:46:24 +00:00
|
|
|
mStretchStack = PR_TRUE;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleXUL::~nsStyleXUL()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleXUL::nsStyleXUL(const nsStyleXUL& aSource)
|
|
|
|
{
|
2002-01-12 03:18:55 +00:00
|
|
|
memcpy((nsStyleXUL*)this, &aSource, sizeof(nsStyleXUL));
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleXUL::CalcDifference(const nsStyleXUL& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2001-08-02 00:09:27 +00:00
|
|
|
if (mBoxAlign == aOther.mBoxAlign &&
|
|
|
|
mBoxDirection == aOther.mBoxDirection &&
|
|
|
|
mBoxFlex == aOther.mBoxFlex &&
|
|
|
|
mBoxOrient == aOther.mBoxOrient &&
|
2001-09-25 22:17:00 +00:00
|
|
|
mBoxPack == aOther.mBoxPack &&
|
|
|
|
mBoxOrdinal == aOther.mBoxOrdinal)
|
2001-05-31 22:19:43 +00:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-09-25 22:17:00 +00:00
|
|
|
if (mBoxOrdinal != aOther.mBoxOrdinal)
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-05-31 22:19:43 +00:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleXUL::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-06-17 11:57:37 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleColumn
|
|
|
|
//
|
2008-07-19 10:38:25 +00:00
|
|
|
nsStyleColumn::nsStyleColumn(nsPresContext* aPresContext)
|
|
|
|
{
|
2004-06-17 11:57:37 +00:00
|
|
|
mColumnCount = NS_STYLE_COLUMN_COUNT_AUTO;
|
|
|
|
mColumnWidth.SetAutoValue();
|
2007-01-17 03:25:38 +00:00
|
|
|
mColumnGap.SetNormalValue();
|
2008-07-19 10:38:25 +00:00
|
|
|
|
|
|
|
mColumnRuleWidth = (aPresContext->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM];
|
|
|
|
mColumnRuleStyle = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
mColumnRuleColor = NS_RGB(0, 0, 0);
|
|
|
|
mColumnRuleColorIsForeground = PR_TRUE;
|
|
|
|
|
|
|
|
mTwipsPerPixel = aPresContext->AppUnitsPerDevPixel();
|
2004-06-17 11:57:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColumn::~nsStyleColumn()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColumn::nsStyleColumn(const nsStyleColumn& aSource)
|
|
|
|
{
|
|
|
|
memcpy((nsStyleColumn*)this, &aSource, sizeof(nsStyleColumn));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleColumn::CalcDifference(const nsStyleColumn& aOther) const
|
|
|
|
{
|
2004-07-18 12:12:46 +00:00
|
|
|
if ((mColumnWidth.GetUnit() == eStyleUnit_Auto)
|
|
|
|
!= (aOther.mColumnWidth.GetUnit() == eStyleUnit_Auto) ||
|
2004-10-08 12:17:10 +00: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
|
2008-07-19 10:38:25 +00:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2004-07-18 12:12:46 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
if (mColumnWidth != aOther.mColumnWidth ||
|
2004-07-18 12:12:46 +00:00
|
|
|
mColumnGap != aOther.mColumnGap)
|
2008-07-19 10:38:25 +00:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
|
|
|
|
if (GetComputedColumnRuleWidth() != aOther.GetComputedColumnRuleWidth() ||
|
|
|
|
mColumnRuleStyle != aOther.mColumnRuleStyle ||
|
|
|
|
mColumnRuleColor != aOther.mColumnRuleColor ||
|
|
|
|
mColumnRuleColorIsForeground != aOther.mColumnRuleColorIsForeground)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2004-07-18 12:12:46 +00:00
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2004-06-17 11:57:37 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleColumn::MaxDifference()
|
|
|
|
{
|
2008-07-19 10:38:25 +00:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2004-10-01 03:33:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-12-12 07:59:31 +00: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 12:39:26 +00:00
|
|
|
{
|
2007-01-09 11:02:17 +00:00
|
|
|
mFill.mType = eStyleSVGPaintType_Color;
|
|
|
|
mFill.mPaint.mColor = NS_RGB(0,0,0);
|
|
|
|
mFill.mFallbackColor = NS_RGB(0,0,0);
|
|
|
|
mStroke.mType = eStyleSVGPaintType_None;
|
|
|
|
mStroke.mPaint.mColor = NS_RGB(0,0,0);
|
|
|
|
mStroke.mFallbackColor = NS_RGB(0,0,0);
|
|
|
|
mStrokeDasharray = nsnull;
|
2005-01-25 03:55:03 +00:00
|
|
|
|
2007-07-21 14:20:25 +00:00
|
|
|
mStrokeDashoffset.SetCoordValue(0);
|
|
|
|
mStrokeWidth.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(1));
|
2005-04-04 21:42:26 +00:00
|
|
|
|
2005-01-25 03:55:03 +00:00
|
|
|
mFillOpacity = 1.0f;
|
2004-10-14 23:02:53 +00:00
|
|
|
mStrokeMiterlimit = 4.0f;
|
|
|
|
mStrokeOpacity = 1.0f;
|
2005-01-25 03:55:03 +00:00
|
|
|
|
|
|
|
mStrokeDasharrayLength = 0;
|
|
|
|
mClipRule = NS_STYLE_FILL_RULE_NONZERO;
|
2007-01-30 13:19:55 +00:00
|
|
|
mColorInterpolation = NS_STYLE_COLOR_INTERPOLATION_SRGB;
|
|
|
|
mColorInterpolationFilters = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB;
|
2005-01-25 03:55:03 +00:00
|
|
|
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
|
2009-03-21 15:36:38 +00:00
|
|
|
mImageRendering = NS_STYLE_IMAGE_RENDERING_AUTO;
|
2005-01-25 03:55:03 +00:00
|
|
|
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-14 23:02:53 +00:00
|
|
|
mTextAnchor = NS_STYLE_TEXT_ANCHOR_START;
|
|
|
|
mTextRendering = NS_STYLE_TEXT_RENDERING_AUTO;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::~nsStyleSVG()
|
|
|
|
{
|
2004-11-09 18:19:28 +00:00
|
|
|
delete [] mStrokeDasharray;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
|
|
|
{
|
2002-01-12 03:18:55 +00:00
|
|
|
//memcpy((nsStyleSVG*)this, &aSource, sizeof(nsStyleSVG));
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2004-10-14 23:02:53 +00:00
|
|
|
mFill = aSource.mFill;
|
2005-01-25 03:55:03 +00:00
|
|
|
mStroke = aSource.mStroke;
|
|
|
|
|
2004-12-09 03:16:15 +00:00
|
|
|
mMarkerEnd = aSource.mMarkerEnd;
|
|
|
|
mMarkerMid = aSource.mMarkerMid;
|
2007-07-21 14:20:25 +00:00
|
|
|
mMarkerStart = aSource.mMarkerStart;
|
2005-01-25 03:55:03 +00:00
|
|
|
|
2004-11-09 18:19:28 +00:00
|
|
|
mStrokeDasharrayLength = aSource.mStrokeDasharrayLength;
|
|
|
|
if (aSource.mStrokeDasharray) {
|
2005-04-04 21:42:26 +00:00
|
|
|
mStrokeDasharray = new nsStyleCoord[mStrokeDasharrayLength];
|
2004-11-09 18:19:28 +00:00
|
|
|
if (mStrokeDasharray)
|
|
|
|
memcpy(mStrokeDasharray,
|
|
|
|
aSource.mStrokeDasharray,
|
2005-04-04 21:42:26 +00:00
|
|
|
mStrokeDasharrayLength * sizeof(nsStyleCoord));
|
2004-11-09 18:19:28 +00:00
|
|
|
else
|
|
|
|
mStrokeDasharrayLength = 0;
|
|
|
|
} else {
|
|
|
|
mStrokeDasharray = nsnull;
|
|
|
|
}
|
2005-01-25 03:55:03 +00:00
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
mStrokeDashoffset = aSource.mStrokeDashoffset;
|
2005-04-04 21:42:26 +00:00
|
|
|
mStrokeWidth = aSource.mStrokeWidth;
|
|
|
|
|
|
|
|
mFillOpacity = aSource.mFillOpacity;
|
2001-12-12 07:59:31 +00:00
|
|
|
mStrokeMiterlimit = aSource.mStrokeMiterlimit;
|
|
|
|
mStrokeOpacity = aSource.mStrokeOpacity;
|
2005-01-25 03:55:03 +00:00
|
|
|
|
|
|
|
mClipRule = aSource.mClipRule;
|
2007-01-30 13:19:55 +00:00
|
|
|
mColorInterpolation = aSource.mColorInterpolation;
|
|
|
|
mColorInterpolationFilters = aSource.mColorInterpolationFilters;
|
2005-01-25 03:55:03 +00:00
|
|
|
mFillRule = aSource.mFillRule;
|
2009-03-21 15:36:38 +00:00
|
|
|
mImageRendering = aSource.mImageRendering;
|
2005-01-25 03:55:03 +00:00
|
|
|
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 12:39:26 +00:00
|
|
|
mTextAnchor = aSource.mTextAnchor;
|
|
|
|
mTextRendering = aSource.mTextRendering;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
static PRBool PaintURIChanged(const nsStyleSVGPaint& aPaint1,
|
|
|
|
const nsStyleSVGPaint& aPaint2)
|
|
|
|
{
|
|
|
|
if (aPaint1.mType != aPaint2.mType) {
|
|
|
|
return aPaint1.mType == eStyleSVGPaintType_Server ||
|
|
|
|
aPaint2.mType == eStyleSVGPaintType_Server;
|
|
|
|
}
|
|
|
|
return aPaint1.mType == eStyleSVGPaintType_Server &&
|
|
|
|
!EqualURIs(aPaint1.mPaint.mPaintServer, aPaint2.mPaint.mPaintServer);
|
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
|
2001-12-12 07:59:31 +00:00
|
|
|
{
|
2008-10-01 00:51:05 +00:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
|
|
|
if (mTextRendering != aOther.mTextRendering) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
// May be needed for non-svg frames
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReflowFrame);
|
|
|
|
}
|
|
|
|
|
2009-01-22 01:02:40 +00:00
|
|
|
if (!EqualURIs(mMarkerEnd, aOther.mMarkerEnd) ||
|
|
|
|
!EqualURIs(mMarkerMid, aOther.mMarkerMid) ||
|
|
|
|
!EqualURIs(mMarkerStart, aOther.mMarkerStart)) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateEffects);
|
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
if (mFill != aOther.mFill ||
|
|
|
|
mStroke != aOther.mStroke) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
if (PaintURIChanged(mFill, aOther.mFill) ||
|
|
|
|
PaintURIChanged(mStroke, aOther.mStroke)) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateEffects);
|
|
|
|
}
|
|
|
|
// Nothing more to do, below we can only set "repaint"
|
|
|
|
return hint;
|
|
|
|
}
|
2007-01-08 16:48:56 +00:00
|
|
|
|
2009-01-22 01:02:40 +00:00
|
|
|
if ( mStrokeDashoffset != aOther.mStrokeDashoffset ||
|
2005-04-04 21:42:26 +00:00
|
|
|
mStrokeWidth != aOther.mStrokeWidth ||
|
|
|
|
|
|
|
|
mFillOpacity != aOther.mFillOpacity ||
|
2004-11-09 18:19:28 +00:00
|
|
|
mStrokeMiterlimit != aOther.mStrokeMiterlimit ||
|
|
|
|
mStrokeOpacity != aOther.mStrokeOpacity ||
|
2005-01-25 03:55:03 +00:00
|
|
|
|
|
|
|
mClipRule != aOther.mClipRule ||
|
2007-01-30 13:19:55 +00:00
|
|
|
mColorInterpolation != aOther.mColorInterpolation ||
|
|
|
|
mColorInterpolationFilters != aOther.mColorInterpolationFilters ||
|
2005-01-25 03:55:03 +00:00
|
|
|
mFillRule != aOther.mFillRule ||
|
2009-03-21 15:36:38 +00:00
|
|
|
mImageRendering != aOther.mImageRendering ||
|
2005-01-25 03:55:03 +00:00
|
|
|
mShapeRendering != aOther.mShapeRendering ||
|
|
|
|
mStrokeDasharrayLength != aOther.mStrokeDasharrayLength ||
|
|
|
|
mStrokeLinecap != aOther.mStrokeLinecap ||
|
|
|
|
mStrokeLinejoin != aOther.mStrokeLinejoin ||
|
2008-10-01 00:51:05 +00:00
|
|
|
mTextAnchor != aOther.mTextAnchor) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
return hint;
|
|
|
|
}
|
2001-12-12 07:59:31 +00:00
|
|
|
|
2005-04-04 21:42:26 +00:00
|
|
|
// length of stroke dasharrays are the same (tested above) - check entries
|
2004-11-09 18:19:28 +00:00
|
|
|
for (PRUint32 i=0; i<mStrokeDasharrayLength; i++)
|
2008-10-01 00:51:05 +00:00
|
|
|
if (mStrokeDasharray[i] != aOther.mStrokeDasharray[i]) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
return hint;
|
|
|
|
}
|
2004-11-09 18:19:28 +00:00
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
return hint;
|
2001-12-12 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleSVG::MaxDifference()
|
|
|
|
{
|
2008-10-01 00:51:05 +00:00
|
|
|
return NS_CombineHint(NS_CombineHint(nsChangeHint_UpdateEffects,
|
|
|
|
nsChangeHint_ReflowFrame),
|
|
|
|
nsChangeHint_RepaintFrame);
|
2004-10-01 03:33:05 +00:00
|
|
|
}
|
|
|
|
#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 12:39:26 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleSVGReset
|
|
|
|
//
|
|
|
|
nsStyleSVGReset::nsStyleSVGReset()
|
|
|
|
{
|
2007-01-09 11:02:17 +00:00
|
|
|
mStopColor = NS_RGB(0,0,0);
|
2007-01-09 20:40:09 +00:00
|
|
|
mFloodColor = NS_RGB(0,0,0);
|
2007-07-26 06:57:42 +00:00
|
|
|
mLightingColor = NS_RGB(255,255,255);
|
2005-04-04 21:42:26 +00:00
|
|
|
mClipPath = nsnull;
|
2005-09-06 22:30:40 +00:00
|
|
|
mFilter = nsnull;
|
2006-01-20 17:00:43 +00:00
|
|
|
mMask = nsnull;
|
2005-04-04 21:42:26 +00:00
|
|
|
mStopOpacity = 1.0f;
|
2007-01-09 20:40:09 +00:00
|
|
|
mFloodOpacity = 1.0f;
|
2005-04-04 21:42:26 +00:00
|
|
|
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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGReset::~nsStyleSVGReset()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGReset::nsStyleSVGReset(const nsStyleSVGReset& aSource)
|
|
|
|
{
|
2005-04-04 21:42:26 +00:00
|
|
|
mStopColor = aSource.mStopColor;
|
2007-01-09 20:40:09 +00:00
|
|
|
mFloodColor = aSource.mFloodColor;
|
2007-07-26 06:57:42 +00:00
|
|
|
mLightingColor = aSource.mLightingColor;
|
2005-01-25 03:55:03 +00:00
|
|
|
mClipPath = aSource.mClipPath;
|
2005-09-06 22:30:40 +00:00
|
|
|
mFilter = aSource.mFilter;
|
2006-01-20 17:00:43 +00:00
|
|
|
mMask = aSource.mMask;
|
2005-04-04 21:42:26 +00:00
|
|
|
mStopOpacity = aSource.mStopOpacity;
|
2007-01-09 20:40:09 +00:00
|
|
|
mFloodOpacity = aSource.mFloodOpacity;
|
2005-01-25 03:55:03 +00: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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aOther) const
|
|
|
|
{
|
2008-08-06 00:55:07 +00:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
|
|
|
if (!EqualURIs(mClipPath, aOther.mClipPath) ||
|
|
|
|
!EqualURIs(mFilter, aOther.mFilter) ||
|
|
|
|
!EqualURIs(mMask, aOther.mMask)) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateEffects);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReflowFrame);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2008-10-01 00:51:05 +00:00
|
|
|
} else if (mStopColor != aOther.mStopColor ||
|
|
|
|
mFloodColor != aOther.mFloodColor ||
|
|
|
|
mLightingColor != aOther.mLightingColor ||
|
|
|
|
mStopOpacity != aOther.mStopOpacity ||
|
|
|
|
mFloodOpacity != aOther.mFloodOpacity ||
|
|
|
|
mDominantBaseline != aOther.mDominantBaseline)
|
2008-08-06 00:55:07 +00:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
|
|
|
|
return hint;
|
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 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleSVGReset::MaxDifference()
|
|
|
|
{
|
2008-08-06 00:55:07 +00:00
|
|
|
return NS_CombineHint(NS_CombineHint(nsChangeHint_UpdateEffects,
|
|
|
|
nsChangeHint_ReflowFrame),
|
|
|
|
nsChangeHint_RepaintFrame);
|
2004-10-01 03:33:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-10-14 23:02:53 +00:00
|
|
|
// nsStyleSVGPaint implementation
|
2007-10-19 15:36:15 +00:00
|
|
|
nsStyleSVGPaint::~nsStyleSVGPaint()
|
|
|
|
{
|
2004-10-14 23:02:53 +00:00
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
|
|
|
NS_IF_RELEASE(mPaint.mPaintServer);
|
2007-10-19 15:36:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleSVGPaint::SetType(nsStyleSVGPaintType aType)
|
|
|
|
{
|
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
|
|
|
this->~nsStyleSVGPaint();
|
|
|
|
new (this) nsStyleSVGPaint();
|
|
|
|
}
|
|
|
|
mType = aType;
|
2004-10-14 23:02:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGPaint& nsStyleSVGPaint::operator=(const nsStyleSVGPaint& aOther)
|
|
|
|
{
|
2007-10-19 15:36:15 +00:00
|
|
|
if (this == &aOther)
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
SetType(aOther.mType);
|
|
|
|
|
2007-01-09 11:02:17 +00:00
|
|
|
mFallbackColor = aOther.mFallbackColor;
|
2004-10-14 23:02:53 +00:00
|
|
|
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-04 21:42:26 +00:00
|
|
|
if (mType == eStyleSVGPaintType_Server)
|
2007-01-09 11:02:17 +00:00
|
|
|
return EqualURIs(mPaint.mPaintServer, aOther.mPaint.mPaintServer) &&
|
|
|
|
mFallbackColor == aOther.mFallbackColor;
|
2005-04-04 21:42:26 +00:00
|
|
|
if (mType == eStyleSVGPaintType_None)
|
|
|
|
return PR_TRUE;
|
2004-10-14 23:02:53 +00:00
|
|
|
return mPaint.mColor == aOther.mPaint.mColor;
|
|
|
|
}
|
|
|
|
|
2001-12-12 07:59:31 +00:00
|
|
|
#endif // MOZ_SVG
|
|
|
|
|
|
|
|
|
2001-05-31 22:19:43 +00: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);
|
2007-05-11 06:01:31 +00:00
|
|
|
mMaxWidth.SetNoneValue();
|
2001-05-31 22:19:43 +00:00
|
|
|
mHeight.SetAutoValue();
|
|
|
|
mMinHeight.SetCoordValue(0);
|
2007-05-11 06:01:31 +00:00
|
|
|
mMaxHeight.SetNoneValue();
|
2001-05-31 22:19:43 +00:00
|
|
|
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
|
|
|
|
mZIndex.SetAutoValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePosition::~nsStylePosition(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePosition::nsStylePosition(const nsStylePosition& aSource)
|
|
|
|
{
|
2002-01-12 03:18:55 +00:00
|
|
|
memcpy((nsStylePosition*)this, &aSource, sizeof(nsStylePosition));
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStylePosition::CalcDifference(const nsStylePosition& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2004-05-22 05:50:12 +00:00
|
|
|
if (mZIndex != aOther.mZIndex) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00: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 05:50:12 +00:00
|
|
|
(mBoxSizing == aOther.mBoxSizing))
|
2001-05-31 22:19:43 +00:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2004-05-22 05:50:12 +00:00
|
|
|
|
|
|
|
return nsChangeHint_ReflowFrame;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStylePosition::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00: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 15:48:28 +00:00
|
|
|
mRules = NS_STYLE_TABLE_RULES_NONE;
|
2001-05-31 22:19:43 +00:00
|
|
|
mSpan = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTable::~nsStyleTable(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTable::nsStyleTable(const nsStyleTable& aSource)
|
|
|
|
{
|
2002-01-12 03:18:55 +00:00
|
|
|
memcpy((nsStyleTable*)this, &aSource, sizeof(nsStyleTable));
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleTable::CalcDifference(const nsStyleTable& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2003-12-04 06:26:15 +00:00
|
|
|
// Changes in mRules may require reframing (if border-collapse stuff changes, for example).
|
2008-02-08 19:56:03 +00:00
|
|
|
if (mRules != aOther.mRules || mSpan != aOther.mSpan ||
|
|
|
|
mLayoutStrategy != aOther.mLayoutStrategy)
|
2003-12-04 06:26:15 +00:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2008-02-08 19:56:03 +00:00
|
|
|
if (mFrame != aOther.mFrame || mCols != aOther.mCols)
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleTable::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// -----------------------
|
|
|
|
// nsStyleTableBorder
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleTableBorder::nsStyleTableBorder(nsPresContext* aPresContext)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
mBorderCollapse = NS_STYLE_BORDER_SEPARATE;
|
|
|
|
|
2002-06-25 21:16:17 +00:00
|
|
|
nsCompatibility compatMode = eCompatibility_FullStandards;
|
2001-05-31 22:19:43 +00:00
|
|
|
if (aPresContext)
|
2003-12-24 21:51:50 +00:00
|
|
|
compatMode = aPresContext->CompatibilityMode();
|
2002-06-25 21:16:17 +00:00
|
|
|
mEmptyCells = (compatMode == eCompatibility_NavQuirks)
|
2001-11-06 22:52:59 +00:00
|
|
|
? NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND
|
2002-06-25 21:16:17 +00:00
|
|
|
: NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
|
2008-02-27 02:02:20 +00:00
|
|
|
mCaptionSide = NS_STYLE_CAPTION_SIDE_TOP;
|
2008-09-13 03:45:37 +00:00
|
|
|
mBorderSpacingX = 0;
|
|
|
|
mBorderSpacingY = 0;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTableBorder::~nsStyleTableBorder(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTableBorder::nsStyleTableBorder(const nsStyleTableBorder& aSource)
|
|
|
|
{
|
2002-01-12 03:18:55 +00:00
|
|
|
memcpy((nsStyleTableBorder*)this, &aSource, sizeof(nsStyleTableBorder));
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleTableBorder::CalcDifference(const nsStyleTableBorder& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2003-02-13 19:06:18 +00: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-05-31 22:19:43 +00: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 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleTableBorder::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleColor
|
|
|
|
//
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleColor::nsStyleColor(nsPresContext* aPresContext)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2004-01-31 22:41:40 +00:00
|
|
|
mColor = aPresContext->DefaultColor();
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColor::nsStyleColor(const nsStyleColor& aSource)
|
|
|
|
{
|
|
|
|
mColor = aSource.mColor;
|
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleColor::CalcDifference(const nsStyleColor& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
if (mColor == aOther.mColor)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleColor::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleBackground
|
|
|
|
//
|
|
|
|
|
2008-09-12 15:35:53 +00:00
|
|
|
nsStyleBackground::nsStyleBackground()
|
2009-02-20 05:29:21 +00:00
|
|
|
: mAttachmentCount(1)
|
|
|
|
, mClipCount(1)
|
|
|
|
, mOriginCount(1)
|
|
|
|
, mRepeatCount(1)
|
|
|
|
, mPositionCount(1)
|
|
|
|
, mImageCount(1)
|
|
|
|
, mBackgroundColor(NS_RGBA(0, 0, 0, 0))
|
|
|
|
, mFallbackBackgroundColor(NS_RGBA(0, 0, 0, 0))
|
|
|
|
, mBackgroundInlinePolicy(NS_STYLE_BG_INLINE_POLICY_CONTINUOUS)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2009-02-20 05:29:21 +00:00
|
|
|
Layer *onlyLayer = mLayers.AppendElement();
|
|
|
|
NS_ASSERTION(onlyLayer, "auto array must have room for 1 element");
|
|
|
|
onlyLayer->SetInitialValues();
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
|
2009-02-20 05:29:21 +00:00
|
|
|
: mAttachmentCount(aSource.mAttachmentCount)
|
|
|
|
, mClipCount(aSource.mClipCount)
|
|
|
|
, mOriginCount(aSource.mOriginCount)
|
|
|
|
, mRepeatCount(aSource.mRepeatCount)
|
|
|
|
, mPositionCount(aSource.mPositionCount)
|
|
|
|
, mImageCount(aSource.mImageCount)
|
|
|
|
, mLayers(aSource.mLayers) // deep copy
|
|
|
|
, mBackgroundColor(aSource.mBackgroundColor)
|
|
|
|
, mFallbackBackgroundColor(aSource.mFallbackBackgroundColor)
|
|
|
|
, mBackgroundInlinePolicy(aSource.mBackgroundInlinePolicy)
|
|
|
|
{
|
|
|
|
// If the deep copy of mLayers failed, truncate the counts.
|
|
|
|
PRUint32 count = mLayers.Length();
|
|
|
|
if (count != aSource.mLayers.Length()) {
|
|
|
|
NS_WARNING("truncating counts due to out-of-memory");
|
|
|
|
mAttachmentCount = PR_MAX(mAttachmentCount, count);
|
|
|
|
mClipCount = PR_MAX(mClipCount, count);
|
|
|
|
mOriginCount = PR_MAX(mOriginCount, count);
|
|
|
|
mRepeatCount = PR_MAX(mRepeatCount, count);
|
|
|
|
mPositionCount = PR_MAX(mPositionCount, count);
|
|
|
|
mImageCount = PR_MAX(mImageCount, count);
|
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-03-09 03:57:51 +00:00
|
|
|
nsStyleBackground::~nsStyleBackground()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleBackground::CalcDifference(const nsStyleBackground& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2009-02-20 05:29:21 +00:00
|
|
|
if (mBackgroundColor != aOther.mBackgroundColor ||
|
|
|
|
mFallbackBackgroundColor != aOther.mFallbackBackgroundColor ||
|
|
|
|
mBackgroundInlinePolicy != aOther.mBackgroundInlinePolicy ||
|
|
|
|
mImageCount != aOther.mImageCount)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
|
|
|
|
// We checked the image count above.
|
|
|
|
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, this) {
|
|
|
|
if (mLayers[i] != aOther.mLayers[i])
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleBackground::MaxDifference()
|
|
|
|
{
|
2007-02-27 22:03:26 +00:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2004-10-01 03:33:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-09-13 20:40:46 +00:00
|
|
|
PRBool nsStyleBackground::HasFixedBackground() const
|
|
|
|
{
|
2009-02-20 05:29:21 +00:00
|
|
|
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, this) {
|
|
|
|
const Layer &layer = mLayers[i];
|
|
|
|
if (layer.mAttachment == NS_STYLE_BG_ATTACHMENT_FIXED &&
|
|
|
|
layer.mImage.mRequest) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsStyleBackground::IsTransparent() const
|
|
|
|
{
|
|
|
|
return !BottomLayer().mImage.mRequest && mImageCount == 1 &&
|
|
|
|
NS_GET_A(mBackgroundColor) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleBackground::Position::SetInitialValues()
|
|
|
|
{
|
|
|
|
mXPosition.mFloat = 0.0f;
|
|
|
|
mYPosition.mFloat = 0.0f;
|
|
|
|
mXIsPercent = PR_TRUE;
|
|
|
|
mYIsPercent = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize to initial values
|
|
|
|
nsStyleBackground::Image::Image()
|
|
|
|
{
|
|
|
|
SetInitialValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::Image::~Image()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsStyleBackground::Image::SetInitialValues()
|
|
|
|
{
|
|
|
|
mRequest = nsnull;
|
|
|
|
mSpecified = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsStyleBackground::Image::operator==(const Image& aOther) const
|
|
|
|
{
|
|
|
|
return mSpecified == aOther.mSpecified &&
|
|
|
|
EqualImages(mRequest, aOther.mRequest);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::Layer::Layer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::Layer::~Layer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleBackground::Layer::SetInitialValues()
|
|
|
|
{
|
|
|
|
mAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL;
|
|
|
|
mClip = NS_STYLE_BG_CLIP_BORDER;
|
|
|
|
mOrigin = NS_STYLE_BG_ORIGIN_PADDING;
|
|
|
|
mRepeat = NS_STYLE_BG_REPEAT_XY;
|
|
|
|
mPosition.SetInitialValues();
|
|
|
|
mImage.SetInitialValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsStyleBackground::Layer::operator==(const Layer& aOther) const
|
|
|
|
{
|
|
|
|
return mAttachment == aOther.mAttachment &&
|
|
|
|
mClip == aOther.mClip &&
|
|
|
|
mOrigin == aOther.mOrigin &&
|
|
|
|
mRepeat == aOther.mRepeat &&
|
|
|
|
mPosition == aOther.mPosition &&
|
|
|
|
mImage == aOther.mImage;
|
2004-09-13 20:40:46 +00:00
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleDisplay
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleDisplay::nsStyleDisplay()
|
|
|
|
{
|
2007-09-05 10:27:06 +00:00
|
|
|
mAppearance = NS_THEME_NONE;
|
2001-05-31 22:19:43 +00:00
|
|
|
mDisplay = NS_STYLE_DISPLAY_INLINE;
|
2002-08-15 23:00:23 +00:00
|
|
|
mOriginalDisplay = NS_STYLE_DISPLAY_NONE;
|
2002-09-30 14:46:56 +00:00
|
|
|
mPosition = NS_STYLE_POSITION_STATIC;
|
2001-05-31 22:19:43 +00:00
|
|
|
mFloats = NS_STYLE_FLOAT_NONE;
|
|
|
|
mBreakType = NS_STYLE_CLEAR_NONE;
|
|
|
|
mBreakBefore = PR_FALSE;
|
|
|
|
mBreakAfter = PR_FALSE;
|
2004-09-05 00:04:04 +00:00
|
|
|
mOverflowX = NS_STYLE_OVERFLOW_VISIBLE;
|
|
|
|
mOverflowY = NS_STYLE_OVERFLOW_VISIBLE;
|
2001-05-31 22:19:43 +00:00
|
|
|
mClipFlags = NS_STYLE_CLIP_AUTO;
|
|
|
|
mClip.SetRect(0,0,0,0);
|
2003-11-01 22:34:59 +00:00
|
|
|
mOpacity = 1.0f;
|
2008-09-13 09:42:11 +00:00
|
|
|
mTransformPresent = PR_FALSE; // No transform
|
|
|
|
mTransformOrigin[0].SetPercentValue(0.5f); // Transform is centered on origin
|
|
|
|
mTransformOrigin[1].SetPercentValue(0.5f);
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
|
|
|
{
|
2001-12-17 22:51:39 +00:00
|
|
|
mAppearance = aSource.mAppearance;
|
2001-05-31 22:19:43 +00:00
|
|
|
mDisplay = aSource.mDisplay;
|
2002-08-15 23:00:23 +00:00
|
|
|
mOriginalDisplay = aSource.mOriginalDisplay;
|
2001-05-31 22:19:43 +00:00
|
|
|
mBinding = aSource.mBinding;
|
|
|
|
mPosition = aSource.mPosition;
|
|
|
|
mFloats = aSource.mFloats;
|
|
|
|
mBreakType = aSource.mBreakType;
|
|
|
|
mBreakBefore = aSource.mBreakBefore;
|
|
|
|
mBreakAfter = aSource.mBreakAfter;
|
2004-09-05 00:04:04 +00:00
|
|
|
mOverflowX = aSource.mOverflowX;
|
|
|
|
mOverflowY = aSource.mOverflowY;
|
2001-05-31 22:19:43 +00:00
|
|
|
mClipFlags = aSource.mClipFlags;
|
|
|
|
mClip = aSource.mClip;
|
2003-11-01 22:34:59 +00:00
|
|
|
mOpacity = aSource.mOpacity;
|
2008-09-13 09:42:11 +00:00
|
|
|
|
|
|
|
/* Copy over the transformation information. */
|
|
|
|
mTransformPresent = aSource.mTransformPresent;
|
|
|
|
if (mTransformPresent)
|
|
|
|
mTransform = aSource.mTransform;
|
|
|
|
|
|
|
|
/* Copy over transform origin. */
|
|
|
|
mTransformOrigin[0] = aSource.mTransformOrigin[0];
|
|
|
|
mTransformOrigin[1] = aSource.mTransformOrigin[1];
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2003-07-11 21:16:12 +00:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2002-09-30 11:56:37 +00:00
|
|
|
|
2003-10-04 06:36:33 +00:00
|
|
|
if (!EqualURIs(mBinding, aOther.mBinding)
|
2002-09-30 11:56:37 +00:00
|
|
|
|| mPosition != aOther.mPosition
|
|
|
|
|| mDisplay != aOther.mDisplay
|
2003-11-14 22:55:46 +00:00
|
|
|
|| (mFloats == NS_STYLE_FLOAT_NONE) != (aOther.mFloats == NS_STYLE_FLOAT_NONE)
|
2004-09-05 00:04:04 +00:00
|
|
|
|| mOverflowX != aOther.mOverflowX
|
2007-02-24 00:23:42 +00:00
|
|
|
|| mOverflowY != aOther.mOverflowY)
|
2002-09-30 11:56:37 +00:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
|
|
|
|
|
2003-11-14 22:55:46 +00:00
|
|
|
if (mFloats != aOther.mFloats)
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReflowFrame);
|
|
|
|
|
2007-03-27 03:58:17 +00:00
|
|
|
if (mClipFlags != aOther.mClipFlags || mClip != aOther.mClip) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReflowFrame);
|
|
|
|
}
|
2002-09-30 11:56:37 +00: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));
|
|
|
|
|
2007-03-27 03:58:17 +00:00
|
|
|
if (mOpacity != aOther.mOpacity)
|
2007-02-24 00:23:42 +00:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2002-09-30 11:56:37 +00:00
|
|
|
|
2008-09-13 09:42:11 +00:00
|
|
|
/* If we've added or removed the transform property, we need to reconstruct the frame to add
|
|
|
|
* or remove the view object, and also to handle abs-pos and fixed-pos containers.
|
|
|
|
*/
|
|
|
|
if (mTransformPresent != aOther.mTransformPresent) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
|
|
|
|
}
|
|
|
|
else if (mTransformPresent) {
|
|
|
|
/* Otherwise, if we've kept the property lying around and we already had a
|
|
|
|
* transform, we need to see whether or not we've changed the transform.
|
|
|
|
* If so, we need to do a reflow and a repaint. The reflow is to recompute
|
|
|
|
* the overflow rect (which probably changed if the transform changed)
|
|
|
|
* and to redraw within the bounds of that new overflow rect.
|
|
|
|
*/
|
|
|
|
if (mTransform != aOther.mTransform)
|
|
|
|
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_ReflowFrame,
|
|
|
|
nsChangeHint_RepaintFrame));
|
|
|
|
|
|
|
|
for (PRUint8 index = 0; index < 2; ++index)
|
|
|
|
if (mTransformOrigin[index] != aOther.mTransformOrigin[index]) {
|
|
|
|
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_ReflowFrame,
|
|
|
|
nsChangeHint_RepaintFrame));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
return hint;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleDisplay::MaxDifference()
|
|
|
|
{
|
|
|
|
// All the parts of FRAMECHANGE are present above in CalcDifference.
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleVisibility
|
|
|
|
//
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
nsStyleVisibility::nsStyleVisibility(nsPresContext* aPresContext)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2004-07-29 19:41:39 +00:00
|
|
|
PRUint32 bidiOptions = aPresContext->GetBidi();
|
2001-05-31 22:19:43 +00:00
|
|
|
if (GET_BIDI_OPTION_DIRECTION(bidiOptions) == IBMBIDI_TEXTDIRECTION_RTL)
|
|
|
|
mDirection = NS_STYLE_DIRECTION_RTL;
|
|
|
|
else
|
|
|
|
mDirection = NS_STYLE_DIRECTION_LTR;
|
|
|
|
|
2004-06-08 23:53:59 +00:00
|
|
|
mLangGroup = aPresContext->GetLangGroup();
|
2001-05-31 22:19:43 +00:00
|
|
|
mVisible = NS_STYLE_VISIBILITY_VISIBLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
|
|
|
|
{
|
|
|
|
mDirection = aSource.mDirection;
|
|
|
|
mVisible = aSource.mVisible;
|
2004-06-08 23:53:59 +00:00
|
|
|
mLangGroup = aSource.mLangGroup;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
if ((mDirection == aOther.mDirection) &&
|
2004-06-08 23:53:59 +00:00
|
|
|
(mLangGroup == aOther.mLangGroup)) {
|
2001-05-31 22:19:43 +00:00
|
|
|
if ((mVisible == aOther.mVisible)) {
|
2003-11-01 22:34:59 +00:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
2005-05-03 03:46:51 +00:00
|
|
|
if ((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||
|
|
|
|
(NS_STYLE_VISIBILITY_COLLAPSE == aOther.mVisible)) {
|
2005-06-10 13:57:27 +00:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
2005-06-10 13:57:27 +00:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
2005-06-10 13:57:27 +00:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleVisibility::MaxDifference()
|
|
|
|
{
|
2005-06-10 13:57:27 +00:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2004-10-01 03:33:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-07-14 22:19:22 +00:00
|
|
|
nsStyleContentData::~nsStyleContentData()
|
|
|
|
{
|
|
|
|
if (mType == eStyleContentType_Image) {
|
|
|
|
NS_IF_RELEASE(mContent.mImage);
|
2005-04-01 23:07:00 +00:00
|
|
|
} else if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters) {
|
|
|
|
mContent.mCounters->Release();
|
2004-07-14 22:19:22 +00:00
|
|
|
} else if (mContent.mString) {
|
2006-11-17 01:49:06 +00:00
|
|
|
NS_Free(mContent.mString);
|
2004-07-14 22:19:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContentData& nsStyleContentData::operator=(const nsStyleContentData& aOther)
|
|
|
|
{
|
2005-04-01 23:07:00 +00:00
|
|
|
if (this == &aOther)
|
|
|
|
return *this;
|
|
|
|
this->~nsStyleContentData();
|
2007-10-19 15:36:15 +00:00
|
|
|
new (this) nsStyleContentData();
|
|
|
|
|
2004-07-14 22:19:22 +00:00
|
|
|
mType = aOther.mType;
|
|
|
|
if (mType == eStyleContentType_Image) {
|
|
|
|
mContent.mImage = aOther.mContent.mImage;
|
|
|
|
NS_IF_ADDREF(mContent.mImage);
|
2005-04-01 23:07:00 +00:00
|
|
|
} else if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters) {
|
|
|
|
mContent.mCounters = aOther.mContent.mCounters;
|
|
|
|
mContent.mCounters->AddRef();
|
2004-07-14 22:19:22 +00:00
|
|
|
} else if (aOther.mContent.mString) {
|
2006-11-17 01:49:06 +00:00
|
|
|
mContent.mString = NS_strdup(aOther.mContent.mString);
|
2004-07-14 22:19:22 +00:00
|
|
|
} else {
|
|
|
|
mContent.mString = nsnull;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2007-01-31 13:59:26 +00:00
|
|
|
PRBool nsStyleContentData::operator==(const nsStyleContentData& aOther) const
|
2004-07-14 22:19:22 +00:00
|
|
|
{
|
|
|
|
if (mType != aOther.mType)
|
|
|
|
return PR_FALSE;
|
|
|
|
if (mType == eStyleContentType_Image) {
|
2005-09-20 02:02:21 +00:00
|
|
|
if (!mContent.mImage || !aOther.mContent.mImage)
|
|
|
|
return mContent.mImage == aOther.mContent.mImage;
|
2004-07-14 22:19:22 +00: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-01 23:07:00 +00:00
|
|
|
if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters)
|
|
|
|
return *mContent.mCounters == *aOther.mContent.mCounters;
|
2004-07-14 22:19:22 +00:00
|
|
|
return nsCRT::strcmp(mContent.mString, aOther.mContent.mString) == 0;
|
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleContent
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleContent::nsStyleContent(void)
|
|
|
|
: mMarkerOffset(),
|
|
|
|
mContents(nsnull),
|
|
|
|
mIncrements(nsnull),
|
2009-05-13 08:26:48 +00:00
|
|
|
mResets(nsnull),
|
|
|
|
mContentCount(0),
|
|
|
|
mIncrementCount(0),
|
|
|
|
mResetCount(0)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2007-05-11 05:58:34 +00:00
|
|
|
mMarkerOffset.SetAutoValue();
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContent::~nsStyleContent(void)
|
|
|
|
{
|
|
|
|
DELETE_ARRAY_IF(mContents);
|
|
|
|
DELETE_ARRAY_IF(mIncrements);
|
|
|
|
DELETE_ARRAY_IF(mResets);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContent::nsStyleContent(const nsStyleContent& aSource)
|
|
|
|
:mMarkerOffset(),
|
|
|
|
mContents(nsnull),
|
|
|
|
mIncrements(nsnull),
|
2009-05-13 08:26:48 +00:00
|
|
|
mResets(nsnull),
|
|
|
|
mContentCount(0),
|
|
|
|
mIncrementCount(0),
|
|
|
|
mResetCount(0)
|
2001-05-31 22:19:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
mMarkerOffset = aSource.mMarkerOffset;
|
|
|
|
|
|
|
|
PRUint32 index;
|
|
|
|
if (NS_SUCCEEDED(AllocateContents(aSource.ContentCount()))) {
|
|
|
|
for (index = 0; index < mContentCount; index++) {
|
2003-10-01 22:53:56 +00:00
|
|
|
ContentAt(index) = aSource.ContentAt(index);
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(AllocateCounterIncrements(aSource.CounterIncrementCount()))) {
|
|
|
|
for (index = 0; index < mIncrementCount; index++) {
|
2005-04-01 23:07:00 +00:00
|
|
|
const nsStyleCounterData *data = aSource.GetCounterIncrementAt(index);
|
|
|
|
mIncrements[index].mCounter = data->mCounter;
|
|
|
|
mIncrements[index].mValue = data->mValue;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(AllocateCounterResets(aSource.CounterResetCount()))) {
|
|
|
|
for (index = 0; index < mResetCount; index++) {
|
2005-04-01 23:07:00 +00:00
|
|
|
const nsStyleCounterData *data = aSource.GetCounterResetAt(index);
|
|
|
|
mResets[index].mCounter = data->mCounter;
|
|
|
|
mResets[index].mValue = data->mValue;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleContent::CalcDifference(const nsStyleContent& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2005-04-01 23:07:00 +00: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-05-31 22:19:43 +00:00
|
|
|
}
|
2005-04-01 23:07:00 +00:00
|
|
|
}
|
|
|
|
if (mMarkerOffset != aOther.mMarkerOffset) {
|
2001-05-31 22:19:43 +00:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
2005-04-01 23:07:00 +00:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleContent::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-07-14 23:51:25 +00:00
|
|
|
nsresult nsStyleContent::AllocateContents(PRUint32 aCount)
|
|
|
|
{
|
2007-09-27 16:27:48 +00:00
|
|
|
// We need to run the destructors of the elements of mContents, so we
|
|
|
|
// delete and reallocate even if aCount == mContentCount. (If
|
|
|
|
// nsStyleContentData had its members private and managed their
|
|
|
|
// ownership on setting, we wouldn't need this, but that seems
|
|
|
|
// unnecessary at this point.)
|
|
|
|
DELETE_ARRAY_IF(mContents);
|
|
|
|
if (aCount) {
|
|
|
|
mContents = new nsStyleContentData[aCount];
|
|
|
|
if (! mContents) {
|
|
|
|
mContentCount = 0;
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2004-07-14 23:51:25 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-27 16:27:48 +00:00
|
|
|
mContentCount = aCount;
|
2004-07-14 23:51:25 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// ---------------------
|
|
|
|
// nsStyleQuotes
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleQuotes::nsStyleQuotes(void)
|
|
|
|
: mQuotesCount(0),
|
|
|
|
mQuotes(nsnull)
|
|
|
|
{
|
2008-08-19 14:18:58 +00:00
|
|
|
SetInitial();
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleQuotes::~nsStyleQuotes(void)
|
|
|
|
{
|
|
|
|
DELETE_ARRAY_IF(mQuotes);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleQuotes::nsStyleQuotes(const nsStyleQuotes& aSource)
|
2002-10-13 18:55:12 +00:00
|
|
|
: mQuotesCount(0),
|
|
|
|
mQuotes(nsnull)
|
2008-08-19 14:18:58 +00:00
|
|
|
{
|
|
|
|
CopyFrom(aSource);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleQuotes::SetInitial()
|
|
|
|
{
|
|
|
|
// The initial value for quotes is the en-US typographic convention:
|
|
|
|
// outermost are LEFT and RIGHT DOUBLE QUOTATION MARK, alternating
|
|
|
|
// with LEFT and RIGHT SINGLE QUOTATION MARK.
|
|
|
|
static const PRUnichar initialQuotes[8] = {
|
|
|
|
0x201C, 0, 0x201D, 0, 0x2018, 0, 0x2019, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(AllocateQuotes(2))) {
|
|
|
|
SetQuotesAt(0,
|
|
|
|
nsDependentString(&initialQuotes[0], 1),
|
|
|
|
nsDependentString(&initialQuotes[2], 1));
|
|
|
|
SetQuotesAt(1,
|
|
|
|
nsDependentString(&initialQuotes[4], 1),
|
|
|
|
nsDependentString(&initialQuotes[6], 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleQuotes::CopyFrom(const nsStyleQuotes& aSource)
|
2001-05-31 22:19:43 +00: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 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleQuotes::CalcDifference(const nsStyleQuotes& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2002-08-14 12:34:39 +00: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-05-31 22:19:43 +00:00
|
|
|
if (mQuotesCount == aOther.mQuotesCount) {
|
|
|
|
PRUint32 ix = (mQuotesCount * 2);
|
|
|
|
while (0 < ix--) {
|
|
|
|
if (mQuotes[ix] != aOther.mQuotes[ix]) {
|
2002-08-14 12:34:39 +00:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
2002-08-14 12:34:39 +00:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleQuotes::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleTextReset
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleTextReset::nsStyleTextReset(void)
|
|
|
|
{
|
|
|
|
mVerticalAlign.SetIntValue(NS_STYLE_VERTICAL_ALIGN_BASELINE, eStyleUnit_Enumerated);
|
|
|
|
mTextDecoration = NS_STYLE_TEXT_DECORATION_NONE;
|
2001-06-29 03:15:58 +00:00
|
|
|
mUnicodeBidi = NS_STYLE_UNICODE_BIDI_NORMAL;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTextReset::nsStyleTextReset(const nsStyleTextReset& aSource)
|
|
|
|
{
|
2002-01-12 03:18:55 +00:00
|
|
|
memcpy((nsStyleTextReset*)this, &aSource, sizeof(nsStyleTextReset));
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTextReset::~nsStyleTextReset(void) { }
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2008-03-29 21:25:15 +00:00
|
|
|
if (mVerticalAlign == aOther.mVerticalAlign
|
|
|
|
&& mUnicodeBidi == aOther.mUnicodeBidi) {
|
|
|
|
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-05-31 22:19:43 +00:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2008-03-29 21:25:15 +00:00
|
|
|
}
|
2001-05-31 22:19:43 +00:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleTextReset::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-06-05 23:06:34 +00:00
|
|
|
// --------------------
|
2008-07-08 00:56:52 +00:00
|
|
|
// nsCSSShadowArray
|
|
|
|
// nsCSSShadowItem
|
2008-06-05 23:06:34 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
nsrefcnt
|
2008-07-08 00:56:52 +00:00
|
|
|
nsCSSShadowArray::Release()
|
2008-06-05 23:06:34 +00:00
|
|
|
{
|
2008-12-28 01:58:14 +00:00
|
|
|
if (mRefCnt == PR_UINT32_MAX) {
|
|
|
|
NS_WARNING("refcount overflow, leaking object");
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
2008-06-05 23:06:34 +00:00
|
|
|
mRefCnt--;
|
|
|
|
if (mRefCnt == 0) {
|
|
|
|
delete this;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
|
|
|
|
2008-11-03 00:58:46 +00:00
|
|
|
// Allowed to return one of NS_STYLE_HINT_NONE, NS_STYLE_HINT_REFLOW
|
|
|
|
// or NS_STYLE_HINT_VISUAL. Currently we just return NONE or REFLOW, though.
|
2008-07-08 00:56:52 +00:00
|
|
|
static nsChangeHint
|
|
|
|
CalcShadowDifference(nsCSSShadowArray* lhs,
|
|
|
|
nsCSSShadowArray* rhs)
|
|
|
|
{
|
|
|
|
if (lhs == rhs)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
|
|
|
|
if (!lhs || !rhs || lhs->Length() != rhs->Length())
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
|
|
|
|
for (PRUint32 i = 0; i < lhs->Length(); ++i) {
|
|
|
|
if (*lhs->ShadowAt(i) != *rhs->ShadowAt(i))
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
// --------------------
|
|
|
|
// nsStyleText
|
|
|
|
//
|
|
|
|
|
2008-06-05 23:06:34 +00:00
|
|
|
nsStyleText::nsStyleText(void)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
|
|
|
mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT;
|
|
|
|
mTextTransform = NS_STYLE_TEXT_TRANSFORM_NONE;
|
|
|
|
mWhiteSpace = NS_STYLE_WHITESPACE_NORMAL;
|
2008-07-24 07:16:18 +00:00
|
|
|
mWordWrap = NS_STYLE_WORDWRAP_NORMAL;
|
2001-05-31 22:19:43 +00:00
|
|
|
|
|
|
|
mLetterSpacing.SetNormalValue();
|
|
|
|
mLineHeight.SetNormalValue();
|
|
|
|
mTextIndent.SetCoordValue(0);
|
2008-12-28 01:58:14 +00:00
|
|
|
mWordSpacing = 0;
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2008-07-08 00:56:52 +00:00
|
|
|
mTextShadow = nsnull;
|
2008-06-03 23:42:13 +00:00
|
|
|
}
|
2008-06-03 22:25:31 +00:00
|
|
|
|
2008-06-05 23:06:34 +00:00
|
|
|
nsStyleText::nsStyleText(const nsStyleText& aSource)
|
|
|
|
: mTextAlign(aSource.mTextAlign),
|
|
|
|
mTextTransform(aSource.mTextTransform),
|
|
|
|
mWhiteSpace(aSource.mWhiteSpace),
|
2008-07-24 07:16:18 +00:00
|
|
|
mWordWrap(aSource.mWordWrap),
|
2008-06-05 23:06:34 +00:00
|
|
|
mLetterSpacing(aSource.mLetterSpacing),
|
|
|
|
mLineHeight(aSource.mLineHeight),
|
|
|
|
mTextIndent(aSource.mTextIndent),
|
|
|
|
mWordSpacing(aSource.mWordSpacing),
|
2008-07-08 00:56:52 +00:00
|
|
|
mTextShadow(aSource.mTextShadow)
|
2008-06-05 23:06:34 +00:00
|
|
|
{ }
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
nsStyleText::~nsStyleText(void) { }
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2008-06-05 23:06:34 +00:00
|
|
|
if ((mTextAlign != aOther.mTextAlign) ||
|
|
|
|
(mTextTransform != aOther.mTextTransform) ||
|
|
|
|
(mWhiteSpace != aOther.mWhiteSpace) ||
|
2008-07-24 07:16:18 +00:00
|
|
|
(mWordWrap != aOther.mWordWrap) ||
|
2008-06-05 23:06:34 +00:00
|
|
|
(mLetterSpacing != aOther.mLetterSpacing) ||
|
|
|
|
(mLineHeight != aOther.mLineHeight) ||
|
|
|
|
(mTextIndent != aOther.mTextIndent) ||
|
|
|
|
(mWordSpacing != aOther.mWordSpacing))
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
|
2008-07-08 00:56:52 +00:00
|
|
|
return CalcShadowDifference(mTextShadow, aOther.mTextShadow);
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleText::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 22:19:43 +00:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleUserInterface
|
|
|
|
//
|
|
|
|
|
2005-07-01 04:29:42 +00:00
|
|
|
nsCursorImage::nsCursorImage()
|
|
|
|
: mHaveHotspot(PR_FALSE)
|
|
|
|
, mHotspotX(0.0f)
|
|
|
|
, mHotspotY(0.0f)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-05-31 22:19:43 +00: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 04:29:42 +00:00
|
|
|
|
|
|
|
mCursorArrayLength = 0;
|
|
|
|
mCursorArray = nsnull;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-12-28 13:48:25 +00:00
|
|
|
nsStyleUserInterface::nsStyleUserInterface(const nsStyleUserInterface& aSource) :
|
|
|
|
mUserInput(aSource.mUserInput),
|
|
|
|
mUserModify(aSource.mUserModify),
|
|
|
|
mUserFocus(aSource.mUserFocus),
|
2005-07-01 04:29:42 +00:00
|
|
|
mCursor(aSource.mCursor)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2005-07-01 04:29:42 +00:00
|
|
|
CopyCursorArrayFrom(aSource);
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUserInterface::~nsStyleUserInterface(void)
|
|
|
|
{
|
2005-07-01 04:29:42 +00:00
|
|
|
delete [] mCursorArray;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2004-12-28 13:48:25 +00:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2004-01-18 01:12:58 +00:00
|
|
|
if (mCursor != aOther.mCursor)
|
2004-12-28 13:48:25 +00:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateCursor);
|
2001-05-31 22:19:43 +00:00
|
|
|
|
2004-12-30 21:56:11 +00:00
|
|
|
// We could do better. But it wouldn't be worth it, URL-specified cursors are
|
|
|
|
// rare.
|
2005-07-01 04:29:42 +00:00
|
|
|
if (mCursorArrayLength > 0 || aOther.mCursorArrayLength > 0)
|
2004-12-30 21:56:11 +00:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateCursor);
|
|
|
|
|
2004-12-28 13:48:25 +00:00
|
|
|
if (mUserModify != aOther.mUserModify)
|
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_VISUAL);
|
2001-05-31 22:19:43 +00:00
|
|
|
|
|
|
|
if ((mUserInput != aOther.mUserInput) &&
|
|
|
|
((NS_STYLE_USER_INPUT_NONE == mUserInput) ||
|
|
|
|
(NS_STYLE_USER_INPUT_NONE == aOther.mUserInput))) {
|
2004-12-28 13:48:25 +00:00
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_FRAMECHANGE);
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-12-28 13:48:25 +00:00
|
|
|
// ignore mUserFocus
|
|
|
|
|
|
|
|
return hint;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 03:33:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleUserInterface::MaxDifference()
|
|
|
|
{
|
2004-12-28 13:48:25 +00:00
|
|
|
return nsChangeHint(nsChangeHint_UpdateCursor | NS_STYLE_HINT_FRAMECHANGE);
|
2004-10-01 03:33:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-07-01 04:29:42 +00: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-05-31 22:19:43 +00:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleUIReset
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleUIReset::nsStyleUIReset(void)
|
|
|
|
{
|
|
|
|
mUserSelect = NS_STYLE_USER_SELECT_AUTO;
|
2002-03-26 20:14:05 +00:00
|
|
|
mForceBrokenImageIcon = 0;
|
2007-05-16 15:51:37 +00:00
|
|
|
mIMEMode = NS_STYLE_IME_MODE_AUTO;
|
2008-10-14 14:44:25 +00:00
|
|
|
mWindowShadow = NS_STYLE_WINDOW_SHADOW_DEFAULT;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUIReset::nsStyleUIReset(const nsStyleUIReset& aSource)
|
|
|
|
{
|
|
|
|
mUserSelect = aSource.mUserSelect;
|
2002-03-26 20:14:05 +00:00
|
|
|
mForceBrokenImageIcon = aSource.mForceBrokenImageIcon;
|
2007-05-16 15:51:37 +00:00
|
|
|
mIMEMode = aSource.mIMEMode;
|
2008-10-14 14:44:25 +00:00
|
|
|
mWindowShadow = aSource.mWindowShadow;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUIReset::~nsStyleUIReset(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
nsChangeHint nsStyleUIReset::CalcDifference(const nsStyleUIReset& aOther) const
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2007-05-16 15:51:37 +00:00
|
|
|
// ignore mIMEMode
|
2008-10-14 14:44:25 +00:00
|
|
|
if (mForceBrokenImageIcon != aOther.mForceBrokenImageIcon)
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
if (mWindowShadow != aOther.mWindowShadow) {
|
|
|
|
// We really need just an nsChangeHint_SyncFrameView, except
|
|
|
|
// on an ancestor of the frame, so we get that by doing a
|
|
|
|
// reflow.
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
2008-10-14 14:44:25 +00:00
|
|
|
if (mUserSelect != aOther.mUserSelect)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
2004-10-01 03:33:05 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */
|
|
|
|
nsChangeHint nsStyleUIReset::MaxDifference()
|
|
|
|
{
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|