2001-09-25 05:32:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2006-03-25 08:47:31 +03:00
|
|
|
/*
|
|
|
|
* structs that contain the data provided by nsStyleContext, the
|
|
|
|
* internal API for computed style data for an element
|
|
|
|
*/
|
|
|
|
|
2002-07-03 21:14:41 +04:00
|
|
|
#include "nsStyleStruct.h"
|
2008-07-17 10:30:25 +04:00
|
|
|
#include "nsStyleStructInlines.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2007-09-05 14:27:06 +04:00
|
|
|
#include "nsThemeConstants.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
#include "nsString.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2009-04-02 01:59:02 +04:00
|
|
|
#include "nsIWidget.h"
|
2011-06-21 09:03:59 +04:00
|
|
|
#include "nsCRTGlue.h"
|
2015-10-01 14:26:52 +03:00
|
|
|
#include "nsCSSParser.h"
|
2009-08-21 01:52:47 +04:00
|
|
|
#include "nsCSSProps.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
2002-02-19 23:41:32 +03:00
|
|
|
#include "nsBidiUtils.h"
|
2011-01-13 13:40:12 +03:00
|
|
|
#include "nsLayoutUtils.h"
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
#include "imgIRequest.h"
|
2009-08-22 00:39:25 +04:00
|
|
|
#include "imgIContainer.h"
|
2014-06-12 05:12:00 +04:00
|
|
|
#include "CounterStyleManager.h"
|
2007-10-09 01:58:22 +04:00
|
|
|
|
2012-10-26 17:32:10 +04:00
|
|
|
#include "mozilla/Likely.h"
|
2013-09-07 17:01:08 +04:00
|
|
|
#include "nsIURI.h"
|
2013-10-02 15:40:07 +04:00
|
|
|
#include "nsIDocument.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2012-10-26 17:32:10 +04:00
|
|
|
|
2015-03-31 06:05:33 +03:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2013-07-18 21:59:53 +04:00
|
|
|
static_assert((((1 << nsStyleStructID_Length) - 1) &
|
|
|
|
~(NS_STYLE_INHERIT_MASK)) == 0,
|
|
|
|
"Not enough bits in NS_STYLE_INHERIT_MASK");
|
2004-03-09 06:57:51 +03:00
|
|
|
|
2015-04-30 21:42:50 +03:00
|
|
|
// These are the limits that we choose to clamp grid line numbers to.
|
|
|
|
// http://dev.w3.org/csswg/css-grid/#overlarge-grids
|
|
|
|
const int32_t nsStyleGridLine::kMinLine = -10000;
|
|
|
|
const int32_t nsStyleGridLine::kMaxLine = 10000;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
inline bool IsFixedUnit(const nsStyleCoord& aCoord, bool aEnumOK)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2010-08-31 20:05:12 +04:00
|
|
|
return aCoord.ConvertsToLength() ||
|
|
|
|
(aEnumOK && aCoord.GetUnit() == eStyleUnit_Enumerated);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool EqualURIs(nsIURI *aURI1, nsIURI *aURI2)
|
2003-10-04 10:36:33 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool eq;
|
2003-10-04 10:36:33 +04:00
|
|
|
return aURI1 == aURI2 || // handle null==null, and optimize
|
|
|
|
(aURI1 && aURI2 &&
|
|
|
|
NS_SUCCEEDED(aURI1->Equals(aURI2, &eq)) && // not equal on fail
|
|
|
|
eq);
|
|
|
|
}
|
|
|
|
|
2012-08-24 21:50:49 +04:00
|
|
|
static bool EqualURIs(mozilla::css::URLValue *aURI1, mozilla::css::URLValue *aURI2)
|
2007-07-19 01:56:57 +04:00
|
|
|
{
|
|
|
|
return aURI1 == aURI2 || // handle null==null, and optimize
|
|
|
|
(aURI1 && aURI2 && aURI1->URIEquals(*aURI2));
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool EqualImages(imgIRequest *aImage1, imgIRequest* aImage2)
|
2004-03-09 06:57:51 +03:00
|
|
|
{
|
|
|
|
if (aImage1 == aImage2) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2004-03-09 06:57:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!aImage1 || !aImage2) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2004-03-09 06:57:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri1, uri2;
|
|
|
|
aImage1->GetURI(getter_AddRefs(uri1));
|
|
|
|
aImage2->GetURI(getter_AddRefs(uri2));
|
|
|
|
return EqualURIs(uri1, uri2);
|
|
|
|
}
|
|
|
|
|
2011-06-21 09:03:59 +04:00
|
|
|
// A nullsafe wrapper for strcmp. We depend on null-safety.
|
2014-01-04 19:02:17 +04:00
|
|
|
static int safe_strcmp(const char16_t* a, const char16_t* b)
|
2011-06-21 09:03:59 +04:00
|
|
|
{
|
|
|
|
if (!a || !b) {
|
|
|
|
return (int)(a - b);
|
|
|
|
}
|
|
|
|
return NS_strcmp(a, b);
|
|
|
|
}
|
|
|
|
|
2015-10-02 06:05:28 +03:00
|
|
|
static bool AreShadowArraysEqual(nsCSSShadowArray* lhs,
|
|
|
|
nsCSSShadowArray* rhs);
|
2008-07-08 04:56:52 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleFont
|
|
|
|
//
|
2008-01-09 12:38:28 +03:00
|
|
|
nsStyleFont::nsStyleFont(const nsFont& aFont, nsPresContext *aPresContext)
|
2012-08-21 06:23:32 +04:00
|
|
|
: mFont(aFont)
|
2015-10-08 02:19:29 +03:00
|
|
|
, mSize(nsStyleFont::ZoomText(aPresContext, mFont.size))
|
2012-08-21 06:23:32 +04:00
|
|
|
, mGenericID(kGenericFont_NONE)
|
2015-10-08 02:19:29 +03:00
|
|
|
, mScriptLevel(0)
|
|
|
|
, mMathVariant(NS_MATHML_MATHVARIANT_NONE)
|
|
|
|
, mMathDisplay(NS_MATHML_DISPLAYSTYLE_INLINE)
|
2015-10-08 02:19:29 +03:00
|
|
|
, mMinFontSizeRatio(100) // 100%
|
2012-08-21 06:23:32 +04:00
|
|
|
, mExplicitLanguage(false)
|
2015-10-08 02:19:29 +03:00
|
|
|
, mAllowZoom(true)
|
|
|
|
, mScriptUnconstrainedSize(mSize)
|
|
|
|
, mScriptMinSize(aPresContext->CSSTwipsToAppUnits(
|
|
|
|
NS_POINTS_TO_TWIPS(NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT)))
|
|
|
|
, mScriptSizeMultiplier(NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER)
|
|
|
|
, mLanguage(GetLanguage(aPresContext))
|
2001-09-27 22:33:58 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleFont);
|
2015-10-08 02:19:29 +03:00
|
|
|
mFont.size = mSize;
|
2001-09-27 22:33:58 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
nsStyleFont::nsStyleFont(const nsStyleFont& aSrc)
|
2008-01-09 12:38:28 +03:00
|
|
|
: mFont(aSrc.mFont)
|
|
|
|
, mSize(aSrc.mSize)
|
2008-10-10 18:56:18 +04:00
|
|
|
, mGenericID(aSrc.mGenericID)
|
2008-01-09 12:38:28 +03:00
|
|
|
, mScriptLevel(aSrc.mScriptLevel)
|
2013-12-02 20:49:00 +04:00
|
|
|
, mMathVariant(aSrc.mMathVariant)
|
2014-01-14 18:39:50 +04:00
|
|
|
, mMathDisplay(aSrc.mMathDisplay)
|
2015-10-08 02:19:29 +03:00
|
|
|
, mMinFontSizeRatio(aSrc.mMinFontSizeRatio)
|
2012-08-21 06:23:32 +04:00
|
|
|
, mExplicitLanguage(aSrc.mExplicitLanguage)
|
2013-06-29 07:28:50 +04:00
|
|
|
, mAllowZoom(aSrc.mAllowZoom)
|
2008-01-09 12:38:28 +03:00
|
|
|
, mScriptUnconstrainedSize(aSrc.mScriptUnconstrainedSize)
|
|
|
|
, mScriptMinSize(aSrc.mScriptMinSize)
|
2008-02-19 10:36:50 +03:00
|
|
|
, mScriptSizeMultiplier(aSrc.mScriptSizeMultiplier)
|
2012-01-24 17:09:55 +04:00
|
|
|
, mLanguage(aSrc.mLanguage)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleFont);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleFont::nsStyleFont(nsPresContext* aPresContext)
|
2015-10-08 02:19:29 +03:00
|
|
|
: nsStyleFont(*(aPresContext->GetDefaultFont(
|
|
|
|
kPresContext_DefaultVariableFont_ID, nullptr)), aPresContext)
|
2003-03-13 18:29:36 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleFont::Destroy(nsPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStyleFont();
|
2014-07-16 09:27:13 +04:00
|
|
|
aContext->PresShell()->
|
2015-09-17 05:08:19 +03:00
|
|
|
FreeByObjectID(eArenaObjectID_nsStyleFont, this);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2013-06-29 07:28:50 +04:00
|
|
|
void
|
|
|
|
nsStyleFont::EnableZoom(nsPresContext* aContext, bool aEnable)
|
|
|
|
{
|
|
|
|
if (mAllowZoom == aEnable) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mAllowZoom = aEnable;
|
|
|
|
if (mAllowZoom) {
|
|
|
|
mSize = nsStyleFont::ZoomText(aContext, mSize);
|
|
|
|
mFont.size = nsStyleFont::ZoomText(aContext, mFont.size);
|
|
|
|
mScriptUnconstrainedSize =
|
|
|
|
nsStyleFont::ZoomText(aContext, mScriptUnconstrainedSize);
|
|
|
|
} else {
|
|
|
|
mSize = nsStyleFont::UnZoomText(aContext, mSize);
|
|
|
|
mFont.size = nsStyleFont::UnZoomText(aContext, mFont.size);
|
|
|
|
mScriptUnconstrainedSize =
|
|
|
|
nsStyleFont::UnZoomText(aContext, mScriptUnconstrainedSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2013-06-29 07:28:50 +04:00
|
|
|
MOZ_ASSERT(mAllowZoom == aOther.mAllowZoom,
|
|
|
|
"expected mAllowZoom to be the same on both nsStyleFonts");
|
2012-01-24 17:09:55 +04:00
|
|
|
if (mSize != aOther.mSize ||
|
2012-08-21 06:23:32 +04:00
|
|
|
mLanguage != aOther.mLanguage ||
|
2013-12-02 20:49:00 +04:00
|
|
|
mExplicitLanguage != aOther.mExplicitLanguage ||
|
2014-01-14 18:39:50 +04:00
|
|
|
mMathVariant != aOther.mMathVariant ||
|
2015-10-08 02:19:29 +03:00
|
|
|
mMathDisplay != aOther.mMathDisplay ||
|
|
|
|
mMinFontSizeRatio != aOther.mMinFontSizeRatio) {
|
2012-01-24 17:09:55 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2001-09-27 22:33:58 +04:00
|
|
|
}
|
2014-09-05 07:48:43 +04:00
|
|
|
|
|
|
|
nsChangeHint hint = CalcFontDifference(mFont, aOther.mFont);
|
|
|
|
if (hint) {
|
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX Should any of these cause a non-nsChangeHint_NeutralChange change?
|
|
|
|
if (mGenericID != aOther.mGenericID ||
|
|
|
|
mScriptLevel != aOther.mScriptLevel ||
|
|
|
|
mScriptUnconstrainedSize != aOther.mScriptUnconstrainedSize ||
|
|
|
|
mScriptMinSize != aOther.mScriptMinSize ||
|
|
|
|
mScriptSizeMultiplier != aOther.mScriptSizeMultiplier) {
|
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-11-16 19:32:39 +03:00
|
|
|
// aSize can be negative (e.g.: calc(-1px)) so we can't assert that here.
|
|
|
|
// The caller is expected deal with that.
|
|
|
|
return NSCoordSaturatingMultiply(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
|
|
|
{
|
2015-11-16 19:32:39 +03:00
|
|
|
// aSize can be negative (e.g.: calc(-1px)) so we can't assert that here.
|
|
|
|
// The caller is expected deal with that.
|
|
|
|
return NSCoordSaturatingMultiply(aSize, 1.0 / aPresContext->TextZoom());
|
2003-03-13 18:29:36 +03:00
|
|
|
}
|
|
|
|
|
2015-10-08 02:19:29 +03:00
|
|
|
/* static */ already_AddRefed<nsIAtom>
|
|
|
|
nsStyleFont::GetLanguage(nsPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
nsAutoString language;
|
|
|
|
aPresContext->Document()->GetContentLanguage(language);
|
|
|
|
language.StripWhitespace();
|
|
|
|
|
|
|
|
// Content-Language may be a comma-separated list of language codes,
|
|
|
|
// in which case the HTML5 spec says to treat it as unknown
|
|
|
|
if (!language.IsEmpty() &&
|
|
|
|
!language.Contains(char16_t(','))) {
|
|
|
|
return do_GetAtom(language);
|
|
|
|
// NOTE: This does *not* count as an explicit language; in other
|
|
|
|
// words, it doesn't trigger language-specific hyphenation.
|
|
|
|
} else {
|
|
|
|
// we didn't find a (usable) Content-Language, so we fall back
|
|
|
|
// to whatever the presContext guessed from the charset
|
|
|
|
return do_AddRef(aPresContext->GetLanguageFromCharset());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.weight == aFont2.weight) &&
|
2009-01-29 23:39:18 +03:00
|
|
|
(aFont1.stretch == aFont2.stretch) &&
|
2013-07-30 00:00:41 +04:00
|
|
|
(aFont1.smoothing == aFont2.smoothing) &&
|
2014-06-06 10:09:23 +04:00
|
|
|
(aFont1.fontlist == aFont2.fontlist) &&
|
2013-05-20 06:59:20 +04:00
|
|
|
(aFont1.kerning == aFont2.kerning) &&
|
|
|
|
(aFont1.synthesis == aFont2.synthesis) &&
|
|
|
|
(aFont1.variantAlternates == aFont2.variantAlternates) &&
|
|
|
|
(aFont1.alternateValues == aFont2.alternateValues) &&
|
|
|
|
(aFont1.featureValueLookup == aFont2.featureValueLookup) &&
|
|
|
|
(aFont1.variantCaps == aFont2.variantCaps) &&
|
|
|
|
(aFont1.variantEastAsian == aFont2.variantEastAsian) &&
|
|
|
|
(aFont1.variantLigatures == aFont2.variantLigatures) &&
|
|
|
|
(aFont1.variantNumeric == aFont2.variantNumeric) &&
|
|
|
|
(aFont1.variantPosition == aFont2.variantPosition) &&
|
2012-04-26 10:24:26 +04:00
|
|
|
(aFont1.fontFeatureSettings == aFont2.fontFeatureSettings) &&
|
2013-11-06 05:23:38 +04:00
|
|
|
(aFont1.languageOverride == aFont2.languageOverride) &&
|
|
|
|
(aFont1.systemFont == aFont2.systemFont)) {
|
2001-06-01 02:19:43 +04:00
|
|
|
if ((aFont1.decorations == aFont2.decorations)) {
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool IsFixedData(const nsStyleSides& aSides, bool aEnumOK)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2004-04-13 01:54:45 +04:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2010-08-31 20:05:12 +04:00
|
|
|
if (!IsFixedUnit(aSides.Get(side), aEnumOK))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2004-04-13 01:54:45 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static nscoord CalcCoord(const nsStyleCoord& aCoord,
|
|
|
|
const nscoord* aEnumTable,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aNumEnums)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2010-08-31 20:05:12 +04:00
|
|
|
if (aCoord.GetUnit() == eStyleUnit_Enumerated) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aEnumTable, "must have enum table");
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t value = aCoord.GetIntValue();
|
2010-08-31 20:05:12 +04:00
|
|
|
if (0 <= value && value < aNumEnums) {
|
|
|
|
return aEnumTable[aCoord.GetIntValue()];
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("unexpected enum value");
|
|
|
|
return 0;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aCoord.ConvertsToLength(), "unexpected unit");
|
2010-08-31 20:05:12 +04:00
|
|
|
return nsRuleNode::ComputeCoordPercentCalc(aCoord, 0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2014-07-16 09:27:12 +04:00
|
|
|
nsStyleMargin::nsStyleMargin()
|
|
|
|
: mHasCachedMargin(false)
|
|
|
|
, mCachedMargin(0, 0, 0, 0)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleMargin);
|
2009-10-14 06:38:20 +04:00
|
|
|
nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
|
2007-05-11 09:58:34 +04:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mMargin.Set(side, zero);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2014-07-16 09:27:12 +04:00
|
|
|
nsStyleMargin::nsStyleMargin(const nsStyleMargin& aSrc)
|
|
|
|
: mMargin(aSrc.mMargin)
|
|
|
|
, mHasCachedMargin(false)
|
|
|
|
, mCachedMargin(0, 0, 0, 0)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleMargin);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleMargin::Destroy(nsPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStyleMargin();
|
2014-07-16 09:27:13 +04:00
|
|
|
aContext->PresShell()->
|
2015-09-17 05:08:19 +03:00
|
|
|
FreeByObjectID(eArenaObjectID_nsStyleMargin, this);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nsStyleMargin::RecalcData()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
if (IsFixedData(mMargin, false)) {
|
2004-04-13 01:54:45 +04:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mCachedMargin.Side(side) = CalcCoord(mMargin.Get(side), nullptr, 0);
|
2004-04-13 01:54:45 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasCachedMargin = true;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
else
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasCachedMargin = false;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2009-08-04 05:22:13 +04:00
|
|
|
// Margin differences can't affect descendant intrinsic sizes and
|
|
|
|
// don't need to force children to reflow.
|
2015-06-21 07:54:15 +03:00
|
|
|
return nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_ReflowChangesSizeOrPosition |
|
|
|
|
nsChangeHint_ClearAncestorIntrinsics;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2014-07-16 09:27:12 +04:00
|
|
|
nsStylePadding::nsStylePadding()
|
|
|
|
: mHasCachedPadding(false)
|
|
|
|
, mCachedPadding(0, 0, 0, 0)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStylePadding);
|
2009-10-14 06:38:20 +04:00
|
|
|
nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
|
2007-05-11 09:58:34 +04:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mPadding.Set(side, zero);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2014-07-16 09:27:12 +04:00
|
|
|
nsStylePadding::nsStylePadding(const nsStylePadding& aSrc)
|
|
|
|
: mPadding(aSrc.mPadding)
|
|
|
|
, mHasCachedPadding(false)
|
|
|
|
, mCachedPadding(0, 0, 0, 0)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStylePadding);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStylePadding::Destroy(nsPresContext* aContext) {
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStylePadding();
|
2014-07-16 09:27:13 +04:00
|
|
|
aContext->PresShell()->
|
2015-09-17 05:08:19 +03:00
|
|
|
FreeByObjectID(eArenaObjectID_nsStylePadding, this);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsStylePadding::RecalcData()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
if (IsFixedData(mPadding, false)) {
|
2004-04-13 01:54:45 +04:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2010-09-09 19:21:46 +04:00
|
|
|
// Clamp negative calc() to 0.
|
2011-04-19 07:07:22 +04:00
|
|
|
mCachedPadding.Side(side) =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::max(CalcCoord(mPadding.Get(side), nullptr, 0), 0);
|
2004-04-13 01:54:45 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasCachedPadding = true;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
else
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasCachedPadding = false;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2009-08-04 05:22:13 +04:00
|
|
|
// Padding differences can't affect descendant intrinsic sizes, but do need
|
|
|
|
// to force children to reflow so that we can reposition them, since their
|
|
|
|
// offsets are from our frame bounds but our content rect's position within
|
|
|
|
// those bounds is moving.
|
|
|
|
return NS_SubtractHint(NS_STYLE_HINT_REFLOW,
|
|
|
|
nsChangeHint_ClearDescendantIntrinsics);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleBorder::nsStyleBorder(nsPresContext* aPresContext)
|
2012-07-30 18:20:58 +04:00
|
|
|
: mBorderColors(nullptr),
|
|
|
|
mBoxShadow(nullptr),
|
2011-12-23 03:34:45 +04:00
|
|
|
mBorderImageFill(NS_STYLE_BORDER_IMAGE_SLICE_NOFILL),
|
|
|
|
mBorderImageRepeatH(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH),
|
|
|
|
mBorderImageRepeatV(NS_STYLE_BORDER_IMAGE_REPEAT_STRETCH),
|
|
|
|
mFloatEdge(NS_STYLE_FLOAT_EDGE_CONTENT),
|
2014-05-05 21:55:53 +04:00
|
|
|
mBoxDecorationBreak(NS_STYLE_BOX_DECORATION_BREAK_SLICE),
|
2011-12-23 03:34:45 +04:00
|
|
|
mComputedBorder(0, 0, 0, 0)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleBorder);
|
2011-12-23 03:34:45 +04:00
|
|
|
|
|
|
|
NS_FOR_CSS_HALF_CORNERS (corner) {
|
|
|
|
mBorderRadius.Set(corner, nsStyleCoord(0, nsStyleCoord::CoordConstructor));
|
|
|
|
}
|
|
|
|
|
2005-04-29 19:44:38 +04:00
|
|
|
nscoord medium =
|
|
|
|
(aPresContext->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM];
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2011-12-23 03:34:45 +04:00
|
|
|
mBorderImageSlice.Set(side, nsStyleCoord(1.0f, eStyleUnit_Percent));
|
|
|
|
mBorderImageWidth.Set(side, nsStyleCoord(1.0f, eStyleUnit_Factor));
|
|
|
|
mBorderImageOutset.Set(side, nsStyleCoord(0.0f, eStyleUnit_Factor));
|
|
|
|
|
2011-04-19 07:07:22 +04:00
|
|
|
mBorder.Side(side) = medium;
|
2005-04-29 19:44:38 +04:00
|
|
|
mBorderStyle[side] = NS_STYLE_BORDER_STYLE_NONE | BORDER_COLOR_FOREGROUND;
|
|
|
|
mBorderColor[side] = NS_RGB(0, 0, 0);
|
2008-10-01 09:50:52 +04:00
|
|
|
}
|
2006-12-27 17:21:43 +03:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
mTwipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2008-10-17 12:13:16 +04:00
|
|
|
nsBorderColors::~nsBorderColors()
|
|
|
|
{
|
|
|
|
NS_CSS_DELETE_LIST_MEMBER(nsBorderColors, this, mNext);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBorderColors*
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBorderColors::Clone(bool aDeep) const
|
2008-10-17 12:13:16 +04:00
|
|
|
{
|
|
|
|
nsBorderColors* result = new nsBorderColors(mColor);
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(!result))
|
2008-10-17 12:13:16 +04:00
|
|
|
return result;
|
|
|
|
if (aDeep)
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_CSS_CLONE_LIST_MEMBER(nsBorderColors, this, mNext, result, (false));
|
2008-10-17 12:13:16 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleBorder::nsStyleBorder(const nsStyleBorder& aSrc)
|
2012-07-30 18:20:58 +04:00
|
|
|
: mBorderColors(nullptr),
|
2008-07-17 10:30:25 +04:00
|
|
|
mBoxShadow(aSrc.mBoxShadow),
|
2011-12-23 03:34:45 +04:00
|
|
|
mBorderRadius(aSrc.mBorderRadius),
|
2014-01-31 07:36:41 +04:00
|
|
|
mBorderImageSource(aSrc.mBorderImageSource),
|
2011-12-23 03:34:45 +04:00
|
|
|
mBorderImageSlice(aSrc.mBorderImageSlice),
|
2008-07-17 10:30:25 +04:00
|
|
|
mBorderImageWidth(aSrc.mBorderImageWidth),
|
2011-12-23 03:34:45 +04:00
|
|
|
mBorderImageOutset(aSrc.mBorderImageOutset),
|
2012-04-17 23:22:49 +04:00
|
|
|
mBorderImageFill(aSrc.mBorderImageFill),
|
2011-12-23 03:34:45 +04:00
|
|
|
mBorderImageRepeatH(aSrc.mBorderImageRepeatH),
|
|
|
|
mBorderImageRepeatV(aSrc.mBorderImageRepeatV),
|
|
|
|
mFloatEdge(aSrc.mFloatEdge),
|
2014-05-05 21:55:53 +04:00
|
|
|
mBoxDecorationBreak(aSrc.mBoxDecorationBreak),
|
2008-07-17 10:30:25 +04:00
|
|
|
mComputedBorder(aSrc.mComputedBorder),
|
|
|
|
mBorder(aSrc.mBorder),
|
|
|
|
mTwipsPerPixel(aSrc.mTwipsPerPixel)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleBorder);
|
2001-12-05 11:35:05 +03:00
|
|
|
if (aSrc.mBorderColors) {
|
|
|
|
EnsureBorderColors();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = 0; i < 4; i++)
|
2001-12-05 11:35:05 +03:00
|
|
|
if (aSrc.mBorderColors[i])
|
2008-10-17 12:13:16 +04:00
|
|
|
mBorderColors[i] = aSrc.mBorderColors[i]->Clone();
|
2001-12-05 11:35:05 +03:00
|
|
|
else
|
2012-07-30 18:20:58 +04:00
|
|
|
mBorderColors[i] = nullptr;
|
2001-12-05 11:35:05 +03:00
|
|
|
}
|
2008-07-08 04:56:52 +04:00
|
|
|
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mBorderStyle[side] = aSrc.mBorderStyle[side];
|
|
|
|
mBorderColor[side] = aSrc.mBorderColor[side];
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2008-07-17 10:30:25 +04:00
|
|
|
nsStyleBorder::~nsStyleBorder()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleBorder);
|
2008-07-17 10:30:25 +04:00
|
|
|
if (mBorderColors) {
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = 0; i < 4; i++)
|
2008-07-17 10:30:25 +04:00
|
|
|
delete mBorderColors[i];
|
|
|
|
delete [] mBorderColors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-23 03:34:45 +04:00
|
|
|
nsMargin
|
|
|
|
nsStyleBorder::GetImageOutset() const
|
|
|
|
{
|
|
|
|
// We don't check whether there is a border-image (which is OK since
|
|
|
|
// the initial values yields 0 outset) so that we don't have to
|
|
|
|
// reflow to update overflow areas when an image loads.
|
|
|
|
nsMargin outset;
|
|
|
|
NS_FOR_CSS_SIDES(s) {
|
|
|
|
nsStyleCoord coord = mBorderImageOutset.Get(s);
|
|
|
|
nscoord value;
|
|
|
|
switch (coord.GetUnit()) {
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
value = coord.GetCoordValue();
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Factor:
|
|
|
|
value = coord.GetFactorValue() * mComputedBorder.Side(s);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unexpected CSS unit for image outset");
|
|
|
|
value = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
outset.Side(s) = value;
|
|
|
|
}
|
|
|
|
return outset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleBorder::Destroy(nsPresContext* aContext) {
|
2014-01-31 07:36:41 +04:00
|
|
|
UntrackImage(aContext);
|
2001-06-02 01:04:23 +04:00
|
|
|
this->~nsStyleBorder();
|
2014-07-16 09:27:13 +04:00
|
|
|
aContext->PresShell()->
|
2015-09-17 05:08:19 +03:00
|
|
|
FreeByObjectID(eArenaObjectID_nsStyleBorder, this);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleBorder::CalcDifference(const nsStyleBorder& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-04 05:22:13 +04:00
|
|
|
// XXXbz we should be able to return a more specific change hint for
|
2012-05-31 09:19:49 +04:00
|
|
|
// at least GetComputedBorder() differences...
|
2008-11-03 03:58:46 +03:00
|
|
|
if (mTwipsPerPixel != aOther.mTwipsPerPixel ||
|
2012-05-31 09:19:49 +04:00
|
|
|
GetComputedBorder() != aOther.GetComputedBorder() ||
|
2008-11-03 03:58:46 +03:00
|
|
|
mFloatEdge != aOther.mFloatEdge ||
|
2011-12-23 03:34:45 +04:00
|
|
|
mBorderImageOutset != aOther.mBorderImageOutset ||
|
2014-05-05 21:55:53 +04:00
|
|
|
mBoxDecorationBreak != aOther.mBoxDecorationBreak)
|
2008-11-03 03:58:46 +03:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2005-04-29 19:44:38 +04:00
|
|
|
|
2015-10-02 06:05:28 +03:00
|
|
|
nsChangeHint boxShadowHint = nsChangeHint(0);
|
|
|
|
if (!AreShadowArraysEqual(mBoxShadow, aOther.mBoxShadow)) {
|
|
|
|
// Update overflow regions & trigger DLBI to be sure it's noticed:
|
|
|
|
NS_UpdateHint(boxShadowHint, nsChangeHint_UpdateOverflow);
|
|
|
|
NS_UpdateHint(boxShadowHint, nsChangeHint_SchedulePaint);
|
|
|
|
// Also request a repaint, since it's possible that only the color
|
|
|
|
// of the shadow is changing (and UpdateOverflow/SchedulePaint won't
|
|
|
|
// repaint for that, since they won't know what needs invalidating.)
|
|
|
|
NS_UpdateHint(boxShadowHint, nsChangeHint_RepaintFrame);
|
|
|
|
// Don't return yet; we may also need nsChangeHint_BorderStyleNoneChange.
|
|
|
|
}
|
|
|
|
|
2012-09-07 21:13:36 +04:00
|
|
|
NS_FOR_CSS_SIDES(ix) {
|
|
|
|
// See the explanation in nsChangeHint.h of
|
|
|
|
// nsChangeHint_BorderStyleNoneChange .
|
|
|
|
// Furthermore, even though we know *this* side is 0 width, just
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
// assume a repaint hint for some other change rather than bother
|
2012-09-07 21:13:36 +04:00
|
|
|
// tracking this result through the rest of the function.
|
|
|
|
if (HasVisibleStyle(ix) != aOther.HasVisibleStyle(ix)) {
|
2015-10-02 06:05:28 +03:00
|
|
|
return NS_CombineHint(boxShadowHint,
|
|
|
|
nsChangeHint_RepaintFrame |
|
2012-09-07 21:13:36 +04:00
|
|
|
nsChangeHint_BorderStyleNoneChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-02 06:05:28 +03:00
|
|
|
if (boxShadowHint) {
|
|
|
|
// NOTE: This hint (UpdateOverflow + SchedulePaint + RepaintFrame) is
|
|
|
|
// expected to subsume all hints returned after this point. (Hence, we're
|
|
|
|
// OK to return early.)
|
|
|
|
return boxShadowHint;
|
|
|
|
}
|
|
|
|
|
2008-11-03 03:58:46 +03:00
|
|
|
// Note that mBorderStyle stores not only the border style but also
|
|
|
|
// color-related flags. Given that we've already done an mComputedBorder
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
// comparison, border-style differences can only lead to a repaint hint. So
|
2008-11-03 03:58:46 +03:00
|
|
|
// 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])
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2008-11-03 03:58:46 +03:00
|
|
|
}
|
2001-12-19 14:59:31 +03:00
|
|
|
|
2008-11-03 03:58:46 +03:00
|
|
|
if (mBorderRadius != aOther.mBorderRadius ||
|
|
|
|
!mBorderColors != !aOther.mBorderColors)
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2008-07-26 20:14:49 +04:00
|
|
|
|
2008-11-03 03:58:46 +03:00
|
|
|
if (IsBorderImageLoaded() || aOther.IsBorderImageLoaded()) {
|
2011-12-23 03:34:45 +04:00
|
|
|
if (mBorderImageSource != aOther.mBorderImageSource ||
|
|
|
|
mBorderImageRepeatH != aOther.mBorderImageRepeatH ||
|
|
|
|
mBorderImageRepeatV != aOther.mBorderImageRepeatV ||
|
|
|
|
mBorderImageSlice != aOther.mBorderImageSlice ||
|
|
|
|
mBorderImageFill != aOther.mBorderImageFill ||
|
|
|
|
mBorderImageWidth != aOther.mBorderImageWidth ||
|
|
|
|
mBorderImageOutset != aOther.mBorderImageOutset)
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2008-11-03 03:58:46 +03:00
|
|
|
}
|
2001-12-19 14:59:31 +03:00
|
|
|
|
2008-11-03 03:58:46 +03: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]))
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2008-11-03 03:58:46 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2008-11-03 03:58:46 +03:00
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
// mBorder is the specified border value. Changes to this don't
|
|
|
|
// need any change processing, since we operate on the computed
|
|
|
|
// border values instead.
|
|
|
|
if (mBorder != aOther.mBorder) {
|
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleOutline::nsStyleOutline(nsPresContext* aPresContext)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleOutline);
|
2001-06-01 02:19:43 +04:00
|
|
|
// spacing values not inherited
|
2009-10-14 06:38:20 +04:00
|
|
|
nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
|
2008-10-01 09:50:52 +04:00
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
mOutlineRadius.Set(corner, zero);
|
2005-09-19 19:47:26 +04:00
|
|
|
}
|
|
|
|
|
2008-09-13 07:45:37 +04:00
|
|
|
mOutlineOffset = 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);
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasCachedOutline = false;
|
2007-02-07 10:46:44 +03:00
|
|
|
mTwipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
|
2015-04-28 21:48:39 +03:00
|
|
|
|
|
|
|
SetOutlineInitialColor();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2014-06-19 07:17:10 +04:00
|
|
|
nsStyleOutline::nsStyleOutline(const nsStyleOutline& aSrc)
|
|
|
|
: mOutlineRadius(aSrc.mOutlineRadius)
|
|
|
|
, mOutlineWidth(aSrc.mOutlineWidth)
|
|
|
|
, mOutlineOffset(aSrc.mOutlineOffset)
|
|
|
|
, mCachedOutlineWidth(aSrc.mCachedOutlineWidth)
|
|
|
|
, mOutlineColor(aSrc.mOutlineColor)
|
|
|
|
, mHasCachedOutline(aSrc.mHasCachedOutline)
|
|
|
|
, mOutlineStyle(aSrc.mOutlineStyle)
|
|
|
|
, mTwipsPerPixel(aSrc.mTwipsPerPixel)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(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;
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasCachedOutline = true;
|
|
|
|
} else if (IsFixedUnit(mOutlineWidth, true)) {
|
2010-09-09 19:21:46 +04:00
|
|
|
// Clamp negative calc() to 0.
|
2006-12-27 17:21:43 +03:00
|
|
|
mCachedOutlineWidth =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::max(CalcCoord(mOutlineWidth, aContext->GetBorderWidthTable(), 3), 0);
|
2006-12-27 17:21:43 +03:00
|
|
|
mCachedOutlineWidth =
|
|
|
|
NS_ROUND_BORDER_TO_PIXELS(mCachedOutlineWidth, mTwipsPerPixel);
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasCachedOutline = true;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
else
|
2011-10-17 18:59:28 +04:00
|
|
|
mHasCachedOutline = false;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleOutline::CalcDifference(const nsStyleOutline& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool outlineWasVisible =
|
2004-07-16 20:56:21 +04:00
|
|
|
mCachedOutlineWidth > 0 && mOutlineStyle != NS_STYLE_BORDER_STYLE_NONE;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool outlineIsVisible =
|
2004-07-16 20:56:21 +04:00
|
|
|
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 ||
|
2006-12-27 17:21:43 +03:00
|
|
|
mOutlineWidth != aOther.mOutlineWidth ||
|
|
|
|
mTwipsPerPixel != aOther.mTwipsPerPixel))) {
|
2015-02-17 21:45:00 +03:00
|
|
|
return NS_CombineHint(nsChangeHint_UpdateOverflow,
|
|
|
|
nsChangeHint_SchedulePaint);
|
2004-07-16 20:56:21 +04:00
|
|
|
}
|
2014-09-05 07:48:43 +04:00
|
|
|
|
2004-07-16 20:56:21 +04:00
|
|
|
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
|
|
|
}
|
2014-09-05 07:48:43 +04:00
|
|
|
|
|
|
|
// XXX Not exactly sure if we need to check the cached outline values.
|
|
|
|
if (mOutlineWidth != aOther.mOutlineWidth ||
|
|
|
|
mOutlineOffset != aOther.mOutlineOffset ||
|
|
|
|
mTwipsPerPixel != aOther.mTwipsPerPixel ||
|
|
|
|
mHasCachedOutline != aOther.mHasCachedOutline ||
|
|
|
|
(mHasCachedOutline &&
|
|
|
|
(mCachedOutlineWidth != aOther.mCachedOutlineWidth))) {
|
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleList
|
|
|
|
//
|
2014-06-12 05:12:00 +04:00
|
|
|
nsStyleList::nsStyleList(nsPresContext* aPresContext)
|
|
|
|
: mListStylePosition(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE),
|
|
|
|
mListStyleType(NS_LITERAL_STRING("disc")),
|
|
|
|
mCounterStyle(aPresContext->CounterStyleManager()->
|
|
|
|
BuildCounterStyle(mListStyleType))
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleList);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::~nsStyleList()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleList);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleList::nsStyleList(const nsStyleList& aSource)
|
2014-06-12 05:12:00 +04:00
|
|
|
: mListStylePosition(aSource.mListStylePosition),
|
|
|
|
mListStyleType(aSource.mListStyleType),
|
|
|
|
mCounterStyle(aSource.mCounterStyle),
|
2004-01-15 05:24:17 +03:00
|
|
|
mImageRegion(aSource.mImageRegion)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2010-08-16 20:23:09 +04:00
|
|
|
SetListStyleImage(aSource.GetListStyleImage());
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleList);
|
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
|
|
|
{
|
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 08:38:33 +03:00
|
|
|
if (mListStylePosition != aOther.mListStylePosition)
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
if (EqualImages(mListStyleImage, aOther.mListStyleImage) &&
|
2014-09-20 05:43:00 +04:00
|
|
|
mCounterStyle == aOther.mCounterStyle) {
|
|
|
|
if (mImageRegion.IsEqualInterior(aOther.mImageRegion)) {
|
|
|
|
if (mListStyleType != aOther.mListStyleType)
|
|
|
|
return nsChangeHint_NeutralChange;
|
2002-11-06 10:31:27 +03:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2014-09-20 05:43:00 +04:00
|
|
|
}
|
2002-11-06 10:31:27 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleXUL
|
|
|
|
//
|
|
|
|
nsStyleXUL::nsStyleXUL()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(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;
|
2011-10-17 18:59:28 +04:00
|
|
|
mStretchStack = true;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleXUL::~nsStyleXUL()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleXUL);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleXUL::nsStyleXUL(const nsStyleXUL& aSource)
|
2014-06-19 07:17:10 +04:00
|
|
|
: mBoxFlex(aSource.mBoxFlex)
|
|
|
|
, mBoxOrdinal(aSource.mBoxOrdinal)
|
|
|
|
, mBoxAlign(aSource.mBoxAlign)
|
|
|
|
, mBoxDirection(aSource.mBoxDirection)
|
|
|
|
, mBoxOrient(aSource.mBoxOrient)
|
|
|
|
, mBoxPack(aSource.mBoxPack)
|
|
|
|
, mStretchStack(aSource.mStretchStack)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(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 &&
|
2013-11-18 08:15:38 +04:00
|
|
|
mBoxOrdinal == aOther.mBoxOrdinal &&
|
|
|
|
mStretchStack == aOther.mStretchStack)
|
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-06-17 15:57:37 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleColumn
|
|
|
|
//
|
2013-05-31 19:51:43 +04:00
|
|
|
/* static */ const uint32_t nsStyleColumn::kMaxColumnCount = 1000;
|
|
|
|
|
2008-07-19 14:38:25 +04:00
|
|
|
nsStyleColumn::nsStyleColumn(nsPresContext* aPresContext)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColumn);
|
2004-06-17 15:57:37 +04:00
|
|
|
mColumnCount = NS_STYLE_COLUMN_COUNT_AUTO;
|
|
|
|
mColumnWidth.SetAutoValue();
|
2007-01-17 06:25:38 +03:00
|
|
|
mColumnGap.SetNormalValue();
|
2012-07-31 20:21:19 +04:00
|
|
|
mColumnFill = NS_STYLE_COLUMN_FILL_BALANCE;
|
2008-07-19 14:38:25 +04:00
|
|
|
|
|
|
|
mColumnRuleWidth = (aPresContext->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM];
|
|
|
|
mColumnRuleStyle = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
mColumnRuleColor = NS_RGB(0, 0, 0);
|
2011-10-17 18:59:28 +04:00
|
|
|
mColumnRuleColorIsForeground = true;
|
2008-07-19 14:38:25 +04:00
|
|
|
|
|
|
|
mTwipsPerPixel = aPresContext->AppUnitsPerDevPixel();
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColumn::~nsStyleColumn()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleColumn);
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColumn::nsStyleColumn(const nsStyleColumn& aSource)
|
2014-06-19 07:17:10 +04:00
|
|
|
: mColumnCount(aSource.mColumnCount)
|
|
|
|
, mColumnWidth(aSource.mColumnWidth)
|
|
|
|
, mColumnGap(aSource.mColumnGap)
|
|
|
|
, mColumnRuleColor(aSource.mColumnRuleColor)
|
|
|
|
, mColumnRuleStyle(aSource.mColumnRuleStyle)
|
|
|
|
, mColumnFill(aSource.mColumnFill)
|
|
|
|
, mColumnRuleColorIsForeground(aSource.mColumnRuleColorIsForeground)
|
|
|
|
, mColumnRuleWidth(aSource.mColumnRuleWidth)
|
|
|
|
, mTwipsPerPixel(aSource.mTwipsPerPixel)
|
2004-06-17 15:57:37 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColumn);
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2008-07-19 14:38:25 +04:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2004-07-18 16:12:46 +04:00
|
|
|
|
2004-10-08 16:17:10 +04:00
|
|
|
if (mColumnWidth != aOther.mColumnWidth ||
|
2012-07-31 20:21:19 +04:00
|
|
|
mColumnGap != aOther.mColumnGap ||
|
|
|
|
mColumnFill != aOther.mColumnFill)
|
2008-07-19 14:38:25 +04: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 16:12:46 +04:00
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
// XXX Is it right that we never check mTwipsPerPixel to return a
|
|
|
|
// non-nsChangeHint_NeutralChange hint?
|
|
|
|
if (mColumnRuleWidth != aOther.mColumnRuleWidth ||
|
|
|
|
mTwipsPerPixel != aOther.mTwipsPerPixel) {
|
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2004-07-18 16:12:46 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
// --------------------
|
|
|
|
// 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
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVG);
|
2007-01-09 14:02:17 +03: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);
|
2012-07-30 18:20:58 +04:00
|
|
|
mStrokeDasharray = nullptr;
|
2005-01-25 06:55:03 +03:00
|
|
|
|
2007-07-21 18:20:25 +04:00
|
|
|
mStrokeDashoffset.SetCoordValue(0);
|
|
|
|
mStrokeWidth.SetCoordValue(nsPresContext::CSSPixelsToAppUnits(1));
|
2005-04-05 01:42:26 +04:00
|
|
|
|
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;
|
2007-01-30 16:19:55 +03:00
|
|
|
mColorInterpolation = NS_STYLE_COLOR_INTERPOLATION_SRGB;
|
|
|
|
mColorInterpolationFilters = NS_STYLE_COLOR_INTERPOLATION_LINEARRGB;
|
2005-01-25 06:55:03 +03:00
|
|
|
mFillRule = NS_STYLE_FILL_RULE_NONZERO;
|
2009-03-21 18:36:38 +03:00
|
|
|
mImageRendering = NS_STYLE_IMAGE_RENDERING_AUTO;
|
2013-01-13 03:27:53 +04:00
|
|
|
mPaintOrder = NS_STYLE_PAINT_ORDER_NORMAL;
|
2005-01-25 06:55:03 +03:00
|
|
|
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;
|
2012-09-06 08:58:46 +04:00
|
|
|
mFillOpacitySource = eStyleSVGOpacitySource_Normal;
|
|
|
|
mStrokeOpacitySource = eStyleSVGOpacitySource_Normal;
|
2012-09-06 08:58:47 +04:00
|
|
|
mStrokeDasharrayFromObject = false;
|
|
|
|
mStrokeDashoffsetFromObject = false;
|
|
|
|
mStrokeWidthFromObject = false;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::~nsStyleSVG()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleSVG);
|
2004-11-09 21:19:28 +03:00
|
|
|
delete [] mStrokeDasharray;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVG);
|
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;
|
2007-07-21 18:20:25 +04:00
|
|
|
mMarkerStart = 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];
|
2014-06-19 07:17:10 +04:00
|
|
|
if (mStrokeDasharray) {
|
|
|
|
for (size_t i = 0; i < mStrokeDasharrayLength; i++) {
|
|
|
|
mStrokeDasharray[i] = aSource.mStrokeDasharray[i];
|
|
|
|
}
|
|
|
|
} else {
|
2004-11-09 21:19:28 +03:00
|
|
|
mStrokeDasharrayLength = 0;
|
2014-06-19 07:17:10 +04:00
|
|
|
}
|
2004-11-09 21:19:28 +03:00
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
mStrokeDasharray = nullptr;
|
2004-11-09 21:19:28 +03:00
|
|
|
}
|
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;
|
2007-01-30 16:19:55 +03:00
|
|
|
mColorInterpolation = aSource.mColorInterpolation;
|
|
|
|
mColorInterpolationFilters = aSource.mColorInterpolationFilters;
|
2005-01-25 06:55:03 +03:00
|
|
|
mFillRule = aSource.mFillRule;
|
2009-03-21 18:36:38 +03:00
|
|
|
mImageRendering = aSource.mImageRendering;
|
2013-01-13 03:27:53 +04:00
|
|
|
mPaintOrder = aSource.mPaintOrder;
|
2005-01-25 06:55:03 +03:00
|
|
|
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;
|
2012-09-06 08:58:46 +04:00
|
|
|
mFillOpacitySource = aSource.mFillOpacitySource;
|
|
|
|
mStrokeOpacitySource = aSource.mStrokeOpacitySource;
|
2012-09-06 08:58:47 +04:00
|
|
|
mStrokeDasharrayFromObject = aSource.mStrokeDasharrayFromObject;
|
|
|
|
mStrokeDashoffsetFromObject = aSource.mStrokeDashoffsetFromObject;
|
|
|
|
mStrokeWidthFromObject = aSource.mStrokeWidthFromObject;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool PaintURIChanged(const nsStyleSVGPaint& aPaint1,
|
2008-10-01 04:51:05 +04:00
|
|
|
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 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleSVG::CalcDifference(const nsStyleSVG& aOther) const
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2008-10-01 04:51:05 +04:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2009-01-22 04:02:40 +03:00
|
|
|
if (!EqualURIs(mMarkerEnd, aOther.mMarkerEnd) ||
|
|
|
|
!EqualURIs(mMarkerMid, aOther.mMarkerMid) ||
|
|
|
|
!EqualURIs(mMarkerStart, aOther.mMarkerStart)) {
|
2013-05-24 21:31:33 +04:00
|
|
|
// Markers currently contribute to nsSVGPathGeometryFrame::mRect,
|
|
|
|
// so we need a reflow as well as a repaint. No intrinsic sizes need
|
|
|
|
// to change, so nsChangeHint_NeedReflow is sufficient.
|
2013-05-25 00:03:03 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateEffects);
|
2013-05-24 21:31:33 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedDirtyReflow); // XXX remove me: bug 876085
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2009-01-22 04:02:40 +03:00
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
2008-10-01 04:51:05 +04:00
|
|
|
if (mFill != aOther.mFill ||
|
2013-11-23 17:32:21 +04:00
|
|
|
mStroke != aOther.mStroke ||
|
|
|
|
mFillOpacity != aOther.mFillOpacity ||
|
|
|
|
mStrokeOpacity != aOther.mStrokeOpacity) {
|
2008-10-01 04:51:05 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2013-11-23 17:32:21 +04:00
|
|
|
if (HasStroke() != aOther.HasStroke() ||
|
|
|
|
(!HasStroke() && HasFill() != aOther.HasFill())) {
|
|
|
|
// Frame bounds and overflow rects depend on whether we "have" fill or
|
|
|
|
// stroke. Whether we have stroke or not just changed, or else we have no
|
|
|
|
// stroke (in which case whether we have fill or not is significant to frame
|
|
|
|
// bounds) and whether we have fill or not just changed. In either case we
|
|
|
|
// need to reflow so the frame rect is updated.
|
|
|
|
// XXXperf this is a waste on non nsSVGPathGeometryFrames.
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedDirtyReflow); // XXX remove me: bug 876085
|
|
|
|
}
|
2008-10-01 04:51:05 +04:00
|
|
|
if (PaintURIChanged(mFill, aOther.mFill) ||
|
|
|
|
PaintURIChanged(mStroke, aOther.mStroke)) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateEffects);
|
|
|
|
}
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stroke currently contributes to nsSVGPathGeometryFrame::mRect, so
|
|
|
|
// we need a reflow here. No intrinsic sizes need to change, so
|
|
|
|
// nsChangeHint_NeedReflow is sufficient.
|
|
|
|
// Note that stroke-dashoffset does not affect nsSVGPathGeometryFrame::mRect.
|
|
|
|
// text-anchor and text-rendering changes also require a reflow since they
|
|
|
|
// change frames' rects.
|
|
|
|
if (mStrokeWidth != aOther.mStrokeWidth ||
|
|
|
|
mStrokeMiterlimit != aOther.mStrokeMiterlimit ||
|
|
|
|
mStrokeLinecap != aOther.mStrokeLinecap ||
|
|
|
|
mStrokeLinejoin != aOther.mStrokeLinejoin ||
|
|
|
|
mTextAnchor != aOther.mTextAnchor ||
|
|
|
|
mTextRendering != aOther.mTextRendering) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedDirtyReflow); // XXX remove me: bug 876085
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2008-10-01 04:51:05 +04:00
|
|
|
return hint;
|
|
|
|
}
|
2007-01-08 19:48:56 +03:00
|
|
|
|
2013-05-24 21:31:33 +04:00
|
|
|
if (hint & nsChangeHint_RepaintFrame) {
|
|
|
|
return hint; // we don't add anything else below
|
|
|
|
}
|
2013-05-25 00:03:03 +04:00
|
|
|
|
2013-05-24 21:31:33 +04:00
|
|
|
if ( mStrokeDashoffset != aOther.mStrokeDashoffset ||
|
2005-01-25 06:55:03 +03:00
|
|
|
mClipRule != aOther.mClipRule ||
|
2007-01-30 16:19:55 +03:00
|
|
|
mColorInterpolation != aOther.mColorInterpolation ||
|
|
|
|
mColorInterpolationFilters != aOther.mColorInterpolationFilters ||
|
2005-01-25 06:55:03 +03:00
|
|
|
mFillRule != aOther.mFillRule ||
|
2009-03-21 18:36:38 +03:00
|
|
|
mImageRendering != aOther.mImageRendering ||
|
2013-01-13 03:27:53 +04:00
|
|
|
mPaintOrder != aOther.mPaintOrder ||
|
2005-01-25 06:55:03 +03:00
|
|
|
mShapeRendering != aOther.mShapeRendering ||
|
|
|
|
mStrokeDasharrayLength != aOther.mStrokeDasharrayLength ||
|
2012-09-06 08:58:46 +04:00
|
|
|
mFillOpacitySource != aOther.mFillOpacitySource ||
|
2012-09-06 08:58:47 +04:00
|
|
|
mStrokeOpacitySource != aOther.mStrokeOpacitySource ||
|
|
|
|
mStrokeDasharrayFromObject != aOther.mStrokeDasharrayFromObject ||
|
|
|
|
mStrokeDashoffsetFromObject != aOther.mStrokeDashoffsetFromObject ||
|
|
|
|
mStrokeWidthFromObject != aOther.mStrokeWidthFromObject) {
|
2008-10-01 04:51:05 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
return hint;
|
|
|
|
}
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2005-04-05 01:42:26 +04:00
|
|
|
// length of stroke dasharrays are the same (tested above) - check entries
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i=0; i<mStrokeDasharrayLength; i++)
|
2008-10-01 04:51:05 +04:00
|
|
|
if (mStrokeDasharray[i] != aOther.mStrokeDasharray[i]) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
return hint;
|
|
|
|
}
|
2004-11-09 21:19:28 +03:00
|
|
|
|
2008-10-01 04:51:05 +04:00
|
|
|
return hint;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2014-09-28 03:56:00 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleClipPath
|
|
|
|
//
|
|
|
|
nsStyleClipPath::nsStyleClipPath()
|
|
|
|
: mType(NS_STYLE_CLIP_PATH_NONE)
|
|
|
|
, mURL(nullptr)
|
|
|
|
, mSizingBox(NS_STYLE_CLIP_SHAPE_SIZING_NOBOX)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleClipPath::nsStyleClipPath(const nsStyleClipPath& aSource)
|
|
|
|
: mType(NS_STYLE_CLIP_PATH_NONE)
|
|
|
|
, mURL(nullptr)
|
|
|
|
, mSizingBox(NS_STYLE_CLIP_SHAPE_SIZING_NOBOX)
|
|
|
|
{
|
|
|
|
if (aSource.mType == NS_STYLE_CLIP_PATH_URL) {
|
|
|
|
SetURL(aSource.mURL);
|
|
|
|
} else if (aSource.mType == NS_STYLE_CLIP_PATH_SHAPE) {
|
|
|
|
SetBasicShape(aSource.mBasicShape, aSource.mSizingBox);
|
2015-09-28 00:17:39 +03:00
|
|
|
} else if (aSource.mType == NS_STYLE_CLIP_PATH_BOX) {
|
2014-09-28 03:56:00 +04:00
|
|
|
SetSizingBox(aSource.mSizingBox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleClipPath::~nsStyleClipPath()
|
|
|
|
{
|
|
|
|
ReleaseRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleClipPath&
|
|
|
|
nsStyleClipPath::operator=(const nsStyleClipPath& aOther)
|
|
|
|
{
|
|
|
|
if (this == &aOther) {
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aOther.mType == NS_STYLE_CLIP_PATH_URL) {
|
|
|
|
SetURL(aOther.mURL);
|
|
|
|
} else if (aOther.mType == NS_STYLE_CLIP_PATH_SHAPE) {
|
|
|
|
SetBasicShape(aOther.mBasicShape, aOther.mSizingBox);
|
|
|
|
} else if (aOther.mType == NS_STYLE_CLIP_PATH_BOX) {
|
|
|
|
SetSizingBox(aOther.mSizingBox);
|
|
|
|
} else {
|
2015-04-13 05:34:15 +03:00
|
|
|
ReleaseRef();
|
2014-09-28 03:56:00 +04:00
|
|
|
mSizingBox = NS_STYLE_CLIP_SHAPE_SIZING_NOBOX;
|
|
|
|
mType = NS_STYLE_CLIP_PATH_NONE;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsStyleClipPath::operator==(const nsStyleClipPath& aOther) const
|
|
|
|
{
|
|
|
|
if (mType != aOther.mType) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mType == NS_STYLE_CLIP_PATH_URL) {
|
|
|
|
return EqualURIs(mURL, aOther.mURL);
|
|
|
|
} else if (mType == NS_STYLE_CLIP_PATH_SHAPE) {
|
|
|
|
return *mBasicShape == *aOther.mBasicShape &&
|
|
|
|
mSizingBox == aOther.mSizingBox;
|
|
|
|
} else if (mType == NS_STYLE_CLIP_PATH_BOX) {
|
|
|
|
return mSizingBox == aOther.mSizingBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleClipPath::ReleaseRef()
|
|
|
|
{
|
|
|
|
if (mType == NS_STYLE_CLIP_PATH_SHAPE) {
|
|
|
|
NS_ASSERTION(mBasicShape, "expected pointer");
|
|
|
|
mBasicShape->Release();
|
|
|
|
} else if (mType == NS_STYLE_CLIP_PATH_URL) {
|
|
|
|
NS_ASSERTION(mURL, "expected pointer");
|
|
|
|
mURL->Release();
|
|
|
|
}
|
2015-08-11 12:38:37 +03:00
|
|
|
// mBasicShap, mURL, etc. are all pointers in a union of pointers. Nulling
|
|
|
|
// one of them nulls all of them:
|
2014-09-28 03:56:00 +04:00
|
|
|
mURL = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleClipPath::SetURL(nsIURI* aURL)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aURL, "expected pointer");
|
|
|
|
ReleaseRef();
|
|
|
|
mURL = aURL;
|
|
|
|
mURL->AddRef();
|
|
|
|
mType = NS_STYLE_CLIP_PATH_URL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleClipPath::SetBasicShape(nsStyleBasicShape* aBasicShape, uint8_t aSizingBox)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aBasicShape, "expected pointer");
|
|
|
|
ReleaseRef();
|
|
|
|
mBasicShape = aBasicShape;
|
|
|
|
mBasicShape->AddRef();
|
|
|
|
mSizingBox = aSizingBox;
|
|
|
|
mType = NS_STYLE_CLIP_PATH_SHAPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleClipPath::SetSizingBox(uint8_t aSizingBox)
|
|
|
|
{
|
|
|
|
ReleaseRef();
|
|
|
|
mSizingBox = aSizingBox;
|
|
|
|
mType = NS_STYLE_CLIP_PATH_BOX;
|
|
|
|
}
|
|
|
|
|
2013-07-23 02:08:33 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleFilter
|
|
|
|
//
|
|
|
|
nsStyleFilter::nsStyleFilter()
|
2013-08-06 11:53:30 +04:00
|
|
|
: mType(NS_STYLE_FILTER_NONE)
|
2013-08-05 11:02:27 +04:00
|
|
|
, mDropShadow(nullptr)
|
2013-07-23 02:08:33 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleFilter);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleFilter::nsStyleFilter(const nsStyleFilter& aSource)
|
2013-08-06 11:53:30 +04:00
|
|
|
: mType(NS_STYLE_FILTER_NONE)
|
2013-08-05 11:02:27 +04:00
|
|
|
, mDropShadow(nullptr)
|
2013-07-23 02:08:33 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleFilter);
|
2013-08-06 11:53:30 +04:00
|
|
|
if (aSource.mType == NS_STYLE_FILTER_URL) {
|
2013-08-05 11:02:27 +04:00
|
|
|
SetURL(aSource.mURL);
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (aSource.mType == NS_STYLE_FILTER_DROP_SHADOW) {
|
2013-08-05 11:02:27 +04:00
|
|
|
SetDropShadow(aSource.mDropShadow);
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (aSource.mType != NS_STYLE_FILTER_NONE) {
|
2013-08-05 11:02:27 +04:00
|
|
|
SetFilterParameter(aSource.mFilterParameter, aSource.mType);
|
2013-07-23 02:08:33 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleFilter::~nsStyleFilter()
|
|
|
|
{
|
2013-08-05 11:02:27 +04:00
|
|
|
ReleaseRef();
|
2013-07-23 02:08:33 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleFilter);
|
|
|
|
}
|
|
|
|
|
2013-08-05 11:02:27 +04:00
|
|
|
nsStyleFilter&
|
|
|
|
nsStyleFilter::operator=(const nsStyleFilter& aOther)
|
|
|
|
{
|
|
|
|
if (this == &aOther)
|
|
|
|
return *this;
|
|
|
|
|
2013-08-06 11:53:30 +04:00
|
|
|
if (aOther.mType == NS_STYLE_FILTER_URL) {
|
2013-08-05 11:02:27 +04:00
|
|
|
SetURL(aOther.mURL);
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (aOther.mType == NS_STYLE_FILTER_DROP_SHADOW) {
|
2013-08-05 11:02:27 +04:00
|
|
|
SetDropShadow(aOther.mDropShadow);
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (aOther.mType != NS_STYLE_FILTER_NONE) {
|
2013-08-05 11:02:27 +04:00
|
|
|
SetFilterParameter(aOther.mFilterParameter, aOther.mType);
|
2015-04-13 05:34:15 +03:00
|
|
|
} else {
|
|
|
|
ReleaseRef();
|
|
|
|
mType = NS_STYLE_FILTER_NONE;
|
2013-08-05 11:02:27 +04:00
|
|
|
}
|
2015-04-13 05:34:15 +03:00
|
|
|
|
2013-08-05 11:02:27 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-23 02:08:33 +04:00
|
|
|
bool
|
|
|
|
nsStyleFilter::operator==(const nsStyleFilter& aOther) const
|
|
|
|
{
|
|
|
|
if (mType != aOther.mType) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-06 11:53:30 +04:00
|
|
|
if (mType == NS_STYLE_FILTER_URL) {
|
2013-07-23 02:08:33 +04:00
|
|
|
return EqualURIs(mURL, aOther.mURL);
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (mType == NS_STYLE_FILTER_DROP_SHADOW) {
|
2013-08-05 11:02:27 +04:00
|
|
|
return *mDropShadow == *aOther.mDropShadow;
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (mType != NS_STYLE_FILTER_NONE) {
|
2013-07-26 10:02:33 +04:00
|
|
|
return mFilterParameter == aOther.mFilterParameter;
|
2013-07-23 02:08:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-05 11:02:27 +04:00
|
|
|
void
|
|
|
|
nsStyleFilter::ReleaseRef()
|
|
|
|
{
|
2013-08-06 11:53:30 +04:00
|
|
|
if (mType == NS_STYLE_FILTER_DROP_SHADOW) {
|
2013-08-05 11:02:27 +04:00
|
|
|
NS_ASSERTION(mDropShadow, "expected pointer");
|
|
|
|
mDropShadow->Release();
|
2013-08-06 11:53:30 +04:00
|
|
|
} else if (mType == NS_STYLE_FILTER_URL) {
|
2013-08-05 11:02:27 +04:00
|
|
|
NS_ASSERTION(mURL, "expected pointer");
|
|
|
|
mURL->Release();
|
|
|
|
}
|
2015-04-13 05:34:15 +03:00
|
|
|
mURL = nullptr;
|
2013-08-05 11:02:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleFilter::SetFilterParameter(const nsStyleCoord& aFilterParameter,
|
2013-08-06 11:53:30 +04:00
|
|
|
int32_t aType)
|
2013-08-05 11:02:27 +04:00
|
|
|
{
|
|
|
|
ReleaseRef();
|
|
|
|
mFilterParameter = aFilterParameter;
|
|
|
|
mType = aType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleFilter::SetURL(nsIURI* aURL)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aURL, "expected pointer");
|
|
|
|
ReleaseRef();
|
|
|
|
mURL = aURL;
|
|
|
|
mURL->AddRef();
|
2013-08-06 11:53:30 +04:00
|
|
|
mType = NS_STYLE_FILTER_URL;
|
2013-08-05 11:02:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleFilter::SetDropShadow(nsCSSShadowArray* aDropShadow)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aDropShadow, "expected pointer");
|
|
|
|
ReleaseRef();
|
|
|
|
mDropShadow = aDropShadow;
|
|
|
|
mDropShadow->AddRef();
|
2013-08-06 11:53:30 +04:00
|
|
|
mType = NS_STYLE_FILTER_DROP_SHADOW;
|
2013-08-05 11:02:27 +04:00
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVGReset);
|
2007-01-09 14:02:17 +03:00
|
|
|
mStopColor = NS_RGB(0,0,0);
|
2007-01-09 23:40:09 +03:00
|
|
|
mFloodColor = NS_RGB(0,0,0);
|
2007-07-26 10:57:42 +04:00
|
|
|
mLightingColor = NS_RGB(255,255,255);
|
2012-07-30 18:20:58 +04:00
|
|
|
mMask = nullptr;
|
2005-04-05 01:42:26 +04:00
|
|
|
mStopOpacity = 1.0f;
|
2007-01-09 23:40:09 +03:00
|
|
|
mFloodOpacity = 1.0f;
|
2005-04-05 01:42:26 +04:00
|
|
|
mDominantBaseline = NS_STYLE_DOMINANT_BASELINE_AUTO;
|
2012-05-18 12:33:40 +04:00
|
|
|
mVectorEffect = NS_STYLE_VECTOR_EFFECT_NONE;
|
2012-12-21 04:15:22 +04:00
|
|
|
mMaskType = NS_STYLE_MASK_TYPE_LUMINANCE;
|
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()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleSVGReset);
|
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(const nsStyleSVGReset& aSource)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVGReset);
|
2005-04-05 01:42:26 +04:00
|
|
|
mStopColor = aSource.mStopColor;
|
2007-01-09 23:40:09 +03:00
|
|
|
mFloodColor = aSource.mFloodColor;
|
2007-07-26 10:57:42 +04:00
|
|
|
mLightingColor = aSource.mLightingColor;
|
2005-01-25 06:55:03 +03:00
|
|
|
mClipPath = aSource.mClipPath;
|
2013-07-23 02:08:33 +04:00
|
|
|
mFilters = aSource.mFilters;
|
2006-01-20 20:00:43 +03:00
|
|
|
mMask = aSource.mMask;
|
2005-04-05 01:42:26 +04:00
|
|
|
mStopOpacity = aSource.mStopOpacity;
|
2007-01-09 23:40:09 +03:00
|
|
|
mFloodOpacity = aSource.mFloodOpacity;
|
2005-01-25 06:55:03 +03:00
|
|
|
mDominantBaseline = aSource.mDominantBaseline;
|
2012-05-18 12:33:40 +04:00
|
|
|
mVectorEffect = aSource.mVectorEffect;
|
2012-12-21 04:15:22 +04:00
|
|
|
mMaskType = aSource.mMaskType;
|
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
|
|
|
|
{
|
2008-08-06 04:55:07 +04:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2014-09-28 03:56:00 +04:00
|
|
|
if (mClipPath != aOther.mClipPath ||
|
2013-07-23 02:08:33 +04:00
|
|
|
!EqualURIs(mMask, aOther.mMask) ||
|
2014-07-16 09:27:12 +04:00
|
|
|
mFilters != aOther.mFilters) {
|
2008-08-06 04:55:07 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateEffects);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2014-07-16 09:27:12 +04:00
|
|
|
// We only actually need to update the overflow area for filter
|
|
|
|
// changes. However, mask and clip-path changes require that we
|
|
|
|
// update the PreEffectsBBoxProperty, which is done during overflow
|
|
|
|
// computation.
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateOverflow);
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mDominantBaseline != aOther.mDominantBaseline) {
|
|
|
|
// XXXjwatt: why NS_STYLE_HINT_REFLOW? Isn't that excessive?
|
2013-02-11 10:22:16 +04:00
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_REFLOW);
|
2013-05-24 21:31:33 +04:00
|
|
|
} else if (mVectorEffect != aOther.mVectorEffect) {
|
|
|
|
// Stroke currently affects nsSVGPathGeometryFrame::mRect, and
|
|
|
|
// vector-effect affect stroke. As a result we need to reflow if
|
|
|
|
// vector-effect changes in order to have nsSVGPathGeometryFrame::
|
|
|
|
// ReflowSVG called to update its mRect. No intrinsic sizes need
|
|
|
|
// to change so nsChangeHint_NeedReflow is sufficient.
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedDirtyReflow); // XXX remove me: bug 876085
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2012-08-02 15:38:48 +04:00
|
|
|
} else if (mStopColor != aOther.mStopColor ||
|
|
|
|
mFloodColor != aOther.mFloodColor ||
|
|
|
|
mLightingColor != aOther.mLightingColor ||
|
|
|
|
mStopOpacity != aOther.mStopOpacity ||
|
|
|
|
mFloodOpacity != aOther.mFloodOpacity ||
|
2013-05-24 21:31:33 +04:00
|
|
|
mMaskType != aOther.mMaskType) {
|
2008-08-06 04:55:07 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
2008-08-06 04:55:07 +04:00
|
|
|
|
|
|
|
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 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2004-10-15 03:02:53 +04:00
|
|
|
// nsStyleSVGPaint implementation
|
2007-10-19 19:36:15 +04:00
|
|
|
nsStyleSVGPaint::~nsStyleSVGPaint()
|
|
|
|
{
|
2004-10-15 03:02:53 +04:00
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
|
|
|
NS_IF_RELEASE(mPaint.mPaintServer);
|
2007-10-19 19:36:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleSVGPaint::SetType(nsStyleSVGPaintType aType)
|
|
|
|
{
|
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
|
|
|
this->~nsStyleSVGPaint();
|
|
|
|
new (this) nsStyleSVGPaint();
|
|
|
|
}
|
|
|
|
mType = aType;
|
2004-10-15 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGPaint& nsStyleSVGPaint::operator=(const nsStyleSVGPaint& aOther)
|
|
|
|
{
|
2007-10-19 19:36:15 +04:00
|
|
|
if (this == &aOther)
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
SetType(aOther.mType);
|
|
|
|
|
2007-01-09 14:02:17 +03:00
|
|
|
mFallbackColor = aOther.mFallbackColor;
|
2004-10-15 03:02:53 +04:00
|
|
|
if (mType == eStyleSVGPaintType_Server) {
|
|
|
|
mPaint.mPaintServer = aOther.mPaint.mPaintServer;
|
|
|
|
NS_IF_ADDREF(mPaint.mPaintServer);
|
|
|
|
} else {
|
|
|
|
mPaint.mColor = aOther.mPaint.mColor;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsStyleSVGPaint::operator==(const nsStyleSVGPaint& aOther) const
|
2004-10-15 03:02:53 +04:00
|
|
|
{
|
|
|
|
if (mType != aOther.mType)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2005-04-05 01:42:26 +04:00
|
|
|
if (mType == eStyleSVGPaintType_Server)
|
2007-01-09 14:02:17 +03:00
|
|
|
return EqualURIs(mPaint.mPaintServer, aOther.mPaint.mPaintServer) &&
|
|
|
|
mFallbackColor == aOther.mFallbackColor;
|
2012-09-06 08:58:46 +04:00
|
|
|
if (mType == eStyleSVGPaintType_Color)
|
|
|
|
return mPaint.mColor == aOther.mPaint.mColor;
|
|
|
|
return true;
|
2004-10-15 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStylePosition
|
|
|
|
//
|
2014-03-11 02:54:13 +04:00
|
|
|
nsStylePosition::nsStylePosition(void)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStylePosition);
|
2014-09-10 05:09:32 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// positioning values not inherited
|
2014-09-10 05:09:32 +04:00
|
|
|
|
|
|
|
mObjectPosition.SetInitialPercentValues(0.5f);
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleCoord autoCoord(eStyleUnit_Auto);
|
|
|
|
mOffset.SetLeft(autoCoord);
|
|
|
|
mOffset.SetTop(autoCoord);
|
|
|
|
mOffset.SetRight(autoCoord);
|
|
|
|
mOffset.SetBottom(autoCoord);
|
|
|
|
mWidth.SetAutoValue();
|
2014-07-22 19:24:34 +04:00
|
|
|
mMinWidth.SetAutoValue();
|
2007-05-11 10:01:31 +04:00
|
|
|
mMaxWidth.SetNoneValue();
|
2001-06-01 02:19:43 +04:00
|
|
|
mHeight.SetAutoValue();
|
2014-07-22 19:24:35 +04:00
|
|
|
mMinHeight.SetAutoValue();
|
2007-05-11 10:01:31 +04:00
|
|
|
mMaxHeight.SetNoneValue();
|
2014-11-25 22:28:15 +03:00
|
|
|
mFlexBasis.SetAutoValue();
|
2014-03-11 02:54:15 +04:00
|
|
|
|
|
|
|
// The initial value of grid-auto-columns and grid-auto-rows is 'auto',
|
2015-04-30 21:42:50 +03:00
|
|
|
// which computes to 'minmax(auto, auto)'.
|
|
|
|
mGridAutoColumnsMin.SetAutoValue();
|
|
|
|
mGridAutoColumnsMax.SetAutoValue();
|
|
|
|
mGridAutoRowsMin.SetAutoValue();
|
|
|
|
mGridAutoRowsMax.SetAutoValue();
|
2014-03-11 02:54:15 +04:00
|
|
|
|
2014-05-06 13:45:13 +04:00
|
|
|
mGridAutoFlow = NS_STYLE_GRID_AUTO_FLOW_ROW;
|
2001-06-01 02:19:43 +04:00
|
|
|
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
|
2015-11-03 17:18:06 +03:00
|
|
|
mAlignContent = NS_STYLE_ALIGN_AUTO;
|
2015-11-03 17:18:05 +03:00
|
|
|
mAlignItems = NS_STYLE_ALIGN_AUTO;
|
2015-11-03 17:18:06 +03:00
|
|
|
mAlignSelf = NS_STYLE_ALIGN_AUTO;
|
2015-11-03 17:18:05 +03:00
|
|
|
mJustifyContent = NS_STYLE_JUSTIFY_AUTO;
|
2015-11-03 17:18:05 +03:00
|
|
|
mJustifyItems = NS_STYLE_JUSTIFY_AUTO;
|
2015-11-03 17:18:05 +03:00
|
|
|
mJustifySelf = NS_STYLE_JUSTIFY_AUTO;
|
2012-07-07 04:06:20 +04:00
|
|
|
mFlexDirection = NS_STYLE_FLEX_DIRECTION_ROW;
|
2013-12-05 22:57:50 +04:00
|
|
|
mFlexWrap = NS_STYLE_FLEX_WRAP_NOWRAP;
|
2014-09-10 05:09:32 +04:00
|
|
|
mObjectFit = NS_STYLE_OBJECT_FIT_FILL;
|
2012-07-07 04:06:19 +04:00
|
|
|
mOrder = NS_STYLE_ORDER_INITIAL;
|
2012-07-07 04:06:22 +04:00
|
|
|
mFlexGrow = 0.0f;
|
|
|
|
mFlexShrink = 1.0f;
|
2001-06-01 02:19:43 +04:00
|
|
|
mZIndex.SetAutoValue();
|
2014-03-21 19:06:16 +04:00
|
|
|
// Other members get their default constructors
|
|
|
|
// which initialize them to representations of their respective initial value.
|
|
|
|
// mGridTemplateAreas: nullptr for 'none'
|
2014-03-27 19:54:40 +04:00
|
|
|
// mGridTemplate{Rows,Columns}: false and empty arrays for 'none'
|
2014-03-21 19:06:16 +04:00
|
|
|
// mGrid{Column,Row}{Start,End}: false/0/empty values for 'auto'
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2014-03-11 02:54:13 +04:00
|
|
|
nsStylePosition::~nsStylePosition(void)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStylePosition);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStylePosition::nsStylePosition(const nsStylePosition& aSource)
|
2014-09-10 05:09:32 +04:00
|
|
|
: mObjectPosition(aSource.mObjectPosition)
|
|
|
|
, mOffset(aSource.mOffset)
|
2014-06-19 07:17:10 +04:00
|
|
|
, mWidth(aSource.mWidth)
|
|
|
|
, mMinWidth(aSource.mMinWidth)
|
|
|
|
, mMaxWidth(aSource.mMaxWidth)
|
|
|
|
, mHeight(aSource.mHeight)
|
|
|
|
, mMinHeight(aSource.mMinHeight)
|
|
|
|
, mMaxHeight(aSource.mMaxHeight)
|
|
|
|
, mFlexBasis(aSource.mFlexBasis)
|
|
|
|
, mGridAutoColumnsMin(aSource.mGridAutoColumnsMin)
|
|
|
|
, mGridAutoColumnsMax(aSource.mGridAutoColumnsMax)
|
|
|
|
, mGridAutoRowsMin(aSource.mGridAutoRowsMin)
|
|
|
|
, mGridAutoRowsMax(aSource.mGridAutoRowsMax)
|
|
|
|
, mGridAutoFlow(aSource.mGridAutoFlow)
|
|
|
|
, mBoxSizing(aSource.mBoxSizing)
|
|
|
|
, mAlignContent(aSource.mAlignContent)
|
|
|
|
, mAlignItems(aSource.mAlignItems)
|
|
|
|
, mAlignSelf(aSource.mAlignSelf)
|
2015-11-03 17:18:05 +03:00
|
|
|
, mJustifyContent(aSource.mJustifyContent)
|
2015-11-03 17:18:05 +03:00
|
|
|
, mJustifyItems(aSource.mJustifyItems)
|
2015-11-03 17:18:05 +03:00
|
|
|
, mJustifySelf(aSource.mJustifySelf)
|
2014-06-19 07:17:10 +04:00
|
|
|
, mFlexDirection(aSource.mFlexDirection)
|
|
|
|
, mFlexWrap(aSource.mFlexWrap)
|
2014-09-10 05:09:32 +04:00
|
|
|
, mObjectFit(aSource.mObjectFit)
|
2014-06-19 07:17:10 +04:00
|
|
|
, mOrder(aSource.mOrder)
|
|
|
|
, mFlexGrow(aSource.mFlexGrow)
|
|
|
|
, mFlexShrink(aSource.mFlexShrink)
|
|
|
|
, mZIndex(aSource.mZIndex)
|
|
|
|
, mGridTemplateColumns(aSource.mGridTemplateColumns)
|
2014-03-11 02:54:13 +04:00
|
|
|
, mGridTemplateRows(aSource.mGridTemplateRows)
|
2014-03-11 02:54:14 +04:00
|
|
|
, mGridTemplateAreas(aSource.mGridTemplateAreas)
|
2014-03-11 02:54:17 +04:00
|
|
|
, mGridColumnStart(aSource.mGridColumnStart)
|
|
|
|
, mGridColumnEnd(aSource.mGridColumnEnd)
|
|
|
|
, mGridRowStart(aSource.mGridRowStart)
|
|
|
|
, mGridRowEnd(aSource.mGridRowEnd)
|
2015-11-18 21:52:27 +03:00
|
|
|
, mGridColumnGap(aSource.mGridColumnGap)
|
|
|
|
, mGridRowGap(aSource.mGridRowGap)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStylePosition);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2013-09-10 04:08:41 +04:00
|
|
|
static bool
|
|
|
|
IsAutonessEqual(const nsStyleSides& aSides1, const nsStyleSides& aSides2)
|
|
|
|
{
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
if ((aSides1.GetUnit(side) == eStyleUnit_Auto) !=
|
|
|
|
(aSides2.GetUnit(side) == eStyleUnit_Auto)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:22:02 +03:00
|
|
|
nsChangeHint
|
|
|
|
nsStylePosition::CalcDifference(const nsStylePosition& aOther,
|
2015-10-23 02:57:35 +03:00
|
|
|
const nsStyleVisibility* aOldStyleVisibility) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2014-09-10 05:09:32 +04:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2015-01-15 20:51:19 +03:00
|
|
|
// Changes to "z-index" require a repaint.
|
|
|
|
if (mZIndex != aOther.mZIndex) {
|
2015-01-15 11:32:18 +03:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2015-01-15 09:43:05 +03:00
|
|
|
}
|
|
|
|
|
2015-01-15 20:51:19 +03:00
|
|
|
// Changes to "object-fit" & "object-position" require a repaint. They
|
|
|
|
// may also require a reflow, if we have a nsSubDocumentFrame, so that we
|
|
|
|
// can adjust the size & position of the subdocument.
|
|
|
|
if (mObjectFit != aOther.mObjectFit ||
|
|
|
|
mObjectPosition != aOther.mObjectPosition) {
|
|
|
|
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_RepaintFrame,
|
|
|
|
nsChangeHint_NeedReflow));
|
|
|
|
}
|
|
|
|
|
2014-08-01 22:13:28 +04:00
|
|
|
if (mOrder != aOther.mOrder) {
|
|
|
|
// "order" impacts both layout order and stacking order, so we need both a
|
|
|
|
// reflow and a repaint when it changes. (Technically, we only need a
|
|
|
|
// reflow if we're in a multi-line flexbox (which we can't be sure about,
|
|
|
|
// since that's determined by styling on our parent) -- there, "order" can
|
|
|
|
// affect which flex line we end up on, & hence can affect our sizing by
|
|
|
|
// changing the group of flex items we're competing with for space.)
|
|
|
|
return NS_CombineHint(hint, NS_CombineHint(nsChangeHint_RepaintFrame,
|
|
|
|
nsChangeHint_AllReflowHints));
|
|
|
|
}
|
|
|
|
|
2009-10-30 04:47:43 +03:00
|
|
|
if (mBoxSizing != aOther.mBoxSizing) {
|
2009-10-30 06:43:52 +03:00
|
|
|
// Can affect both widths and heights; just a bad scene.
|
2012-09-08 02:57:06 +04:00
|
|
|
return NS_CombineHint(hint, nsChangeHint_AllReflowHints);
|
2009-10-30 04:47:43 +03:00
|
|
|
}
|
|
|
|
|
2012-07-07 04:06:19 +04:00
|
|
|
// Properties that apply to flex items:
|
2014-08-01 22:13:28 +04:00
|
|
|
// XXXdholbert These should probably be more targeted (bug 819536)
|
2012-07-07 04:06:21 +04:00
|
|
|
if (mAlignSelf != aOther.mAlignSelf ||
|
2012-07-07 04:06:23 +04:00
|
|
|
mFlexBasis != aOther.mFlexBasis ||
|
2012-07-07 04:06:22 +04:00
|
|
|
mFlexGrow != aOther.mFlexGrow ||
|
2014-08-01 22:13:28 +04:00
|
|
|
mFlexShrink != aOther.mFlexShrink) {
|
2012-09-08 02:57:06 +04:00
|
|
|
return NS_CombineHint(hint, nsChangeHint_AllReflowHints);
|
2012-07-07 04:06:19 +04:00
|
|
|
}
|
|
|
|
|
2013-12-05 22:57:50 +04:00
|
|
|
// Properties that apply to flex containers:
|
|
|
|
// - flex-direction can swap a flex container between vertical & horizontal.
|
|
|
|
// - align-items can change the sizing of a flex container & the positioning
|
|
|
|
// of its children.
|
|
|
|
// - flex-wrap changes whether a flex container's children are wrapped, which
|
|
|
|
// impacts their sizing/positioning and hence impacts the container's size.
|
2012-07-07 04:06:21 +04:00
|
|
|
if (mAlignItems != aOther.mAlignItems ||
|
2013-12-05 22:57:50 +04:00
|
|
|
mFlexDirection != aOther.mFlexDirection ||
|
|
|
|
mFlexWrap != aOther.mFlexWrap) {
|
2012-09-08 02:57:06 +04:00
|
|
|
return NS_CombineHint(hint, nsChangeHint_AllReflowHints);
|
2012-07-07 04:06:20 +04:00
|
|
|
}
|
|
|
|
|
2014-03-11 02:54:13 +04:00
|
|
|
// Properties that apply to grid containers:
|
2014-03-11 02:54:17 +04:00
|
|
|
// FIXME: only for grid containers
|
|
|
|
// (ie. 'display: grid' or 'display: inline-grid')
|
2014-03-11 02:54:13 +04:00
|
|
|
if (mGridTemplateColumns != aOther.mGridTemplateColumns ||
|
2014-03-11 02:54:14 +04:00
|
|
|
mGridTemplateRows != aOther.mGridTemplateRows ||
|
2014-03-11 02:54:15 +04:00
|
|
|
mGridTemplateAreas != aOther.mGridTemplateAreas ||
|
|
|
|
mGridAutoColumnsMin != aOther.mGridAutoColumnsMin ||
|
|
|
|
mGridAutoColumnsMax != aOther.mGridAutoColumnsMax ||
|
|
|
|
mGridAutoRowsMin != aOther.mGridAutoRowsMin ||
|
2014-03-11 02:54:16 +04:00
|
|
|
mGridAutoRowsMax != aOther.mGridAutoRowsMax ||
|
|
|
|
mGridAutoFlow != aOther.mGridAutoFlow) {
|
2014-03-11 02:54:13 +04:00
|
|
|
return NS_CombineHint(hint, nsChangeHint_AllReflowHints);
|
|
|
|
}
|
|
|
|
|
2014-03-11 02:54:17 +04:00
|
|
|
// Properties that apply to grid items:
|
|
|
|
// FIXME: only for grid items
|
|
|
|
// (ie. parent frame is 'display: grid' or 'display: inline-grid')
|
|
|
|
if (mGridColumnStart != aOther.mGridColumnStart ||
|
|
|
|
mGridColumnEnd != aOther.mGridColumnEnd ||
|
|
|
|
mGridRowStart != aOther.mGridRowStart ||
|
2015-11-18 21:52:27 +03:00
|
|
|
mGridRowEnd != aOther.mGridRowEnd ||
|
|
|
|
mGridColumnGap != aOther.mGridColumnGap ||
|
|
|
|
mGridRowGap != aOther.mGridRowGap) {
|
2014-03-11 02:54:17 +04:00
|
|
|
return NS_CombineHint(hint, nsChangeHint_AllReflowHints);
|
|
|
|
}
|
2014-03-11 02:54:13 +04:00
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
// Changing 'justify-content/items/self' might affect the positioning,
|
2015-11-03 17:18:05 +03:00
|
|
|
// but it won't affect any sizing.
|
|
|
|
if (mJustifyContent != aOther.mJustifyContent ||
|
2015-11-03 17:18:05 +03:00
|
|
|
mJustifyItems != aOther.mJustifyItems ||
|
|
|
|
mJustifySelf != aOther.mJustifySelf) {
|
2012-07-07 04:06:19 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
|
|
|
|
}
|
|
|
|
|
2015-09-10 22:07:26 +03:00
|
|
|
// 'align-content' doesn't apply to a single-line flexbox but we don't know
|
|
|
|
// if we're a flex container at this point so we can't optimize for that.
|
|
|
|
if (mAlignContent != aOther.mAlignContent) {
|
2013-12-05 22:57:50 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:22:02 +03:00
|
|
|
bool widthChanged = mWidth != aOther.mWidth ||
|
|
|
|
mMinWidth != aOther.mMinWidth ||
|
|
|
|
mMaxWidth != aOther.mMaxWidth;
|
|
|
|
bool heightChanged = mHeight != aOther.mHeight ||
|
|
|
|
mMinHeight != aOther.mMinHeight ||
|
|
|
|
mMaxHeight != aOther.mMaxHeight;
|
2015-10-23 02:57:35 +03:00
|
|
|
|
|
|
|
// If aOldStyleVisibility is null, we don't need to bother with any of
|
|
|
|
// these tests, since we know that the element never had its
|
|
|
|
// nsStyleVisibility accessed, which means it couldn't have done
|
|
|
|
// layout.
|
|
|
|
// Note that we pass an nsStyleVisibility here because we don't want
|
|
|
|
// to cause a new struct to be computed during
|
|
|
|
// nsStyleContext::CalcStyleDifference, which can lead to incorrect
|
|
|
|
// style data.
|
|
|
|
// It doesn't matter whether we're looking at the old or new
|
|
|
|
// visibility struct, since a change between vertical and horizontal
|
|
|
|
// writing-mode will cause a reframe, and it's easier to pass the old.
|
|
|
|
if (aOldStyleVisibility) {
|
|
|
|
bool isVertical = WritingMode(aOldStyleVisibility).IsVertical();
|
|
|
|
if (isVertical ? widthChanged : heightChanged) {
|
|
|
|
// Block-size changes can affect descendant intrinsic sizes due to
|
|
|
|
// replaced elements with percentage bsizes in descendants which
|
|
|
|
// also have percentage bsizes. This is handled via
|
|
|
|
// nsChangeHint_UpdateComputedBSize which clears intrinsic sizes
|
|
|
|
// for frames that have such replaced elements.
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_UpdateComputedBSize |
|
|
|
|
nsChangeHint_ReflowChangesSizeOrPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isVertical ? heightChanged : widthChanged) {
|
|
|
|
// None of our inline-size differences can affect descendant
|
|
|
|
// intrinsic sizes and none of them need to force children to
|
|
|
|
// reflow.
|
|
|
|
NS_UpdateHint(hint, NS_SubtractHint(nsChangeHint_AllReflowHints,
|
|
|
|
NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
|
|
|
|
nsChangeHint_NeedDirtyReflow)));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (widthChanged || heightChanged) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeutralChange);
|
|
|
|
}
|
2009-08-04 05:22:13 +04:00
|
|
|
}
|
|
|
|
|
2015-08-04 07:41:50 +03:00
|
|
|
// If any of the offsets have changed, then return the respective hints
|
|
|
|
// so that we would hopefully be able to avoid reflowing.
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-06 08:53:48 +04:00
|
|
|
// Note that it is possible that we'll need to reflow when processing
|
|
|
|
// restyles, but we don't have enough information to make a good decision
|
|
|
|
// right now.
|
2013-09-10 04:08:41 +04:00
|
|
|
// Don't try to handle changes between "auto" and non-auto efficiently;
|
|
|
|
// that's tricky to do and will hardly ever be able to avoid a reflow.
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-06 08:53:48 +04:00
|
|
|
if (mOffset != aOther.mOffset) {
|
2013-09-10 04:08:41 +04:00
|
|
|
if (IsAutonessEqual(mOffset, aOther.mOffset)) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint(nsChangeHint_RecomputePosition |
|
2015-02-16 06:34:29 +03:00
|
|
|
nsChangeHint_UpdateParentOverflow));
|
2013-09-10 04:08:41 +04:00
|
|
|
} else {
|
2015-08-04 07:41:50 +03:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_AllReflowHints);
|
2013-09-10 04:08:41 +04:00
|
|
|
}
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-06 08:53:48 +04:00
|
|
|
}
|
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
/* static */ bool
|
2010-08-11 23:32:53 +04:00
|
|
|
nsStylePosition::WidthCoordDependsOnContainer(const nsStyleCoord &aCoord)
|
|
|
|
{
|
2014-07-22 19:24:34 +04:00
|
|
|
return aCoord.HasPercent() ||
|
2010-08-11 23:32:53 +04:00
|
|
|
(aCoord.GetUnit() == eStyleUnit_Enumerated &&
|
|
|
|
(aCoord.GetIntValue() == NS_STYLE_WIDTH_FIT_CONTENT ||
|
|
|
|
aCoord.GetIntValue() == NS_STYLE_WIDTH_AVAILABLE));
|
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
uint8_t
|
|
|
|
nsStylePosition::MapLeftRightToStart(uint8_t aAlign, LogicalAxis aAxis,
|
|
|
|
const nsStyleDisplay* aDisplay) const
|
|
|
|
{
|
|
|
|
auto val = aAlign & ~NS_STYLE_ALIGN_FLAG_BITS;
|
|
|
|
if (val == NS_STYLE_ALIGN_LEFT || val == NS_STYLE_ALIGN_RIGHT) {
|
|
|
|
switch (aDisplay->mDisplay) {
|
|
|
|
case NS_STYLE_DISPLAY_FLEX:
|
|
|
|
case NS_STYLE_DISPLAY_INLINE_FLEX:
|
|
|
|
// XXX TODO
|
|
|
|
// NOTE: make sure to strip off 'legacy' bit when mapping to 'start'
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (aAxis == eLogicalAxisBlock) {
|
|
|
|
return NS_STYLE_ALIGN_START | (aAlign & NS_STYLE_ALIGN_FLAG_BITS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aAlign;
|
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:06 +03:00
|
|
|
uint16_t
|
|
|
|
nsStylePosition::ComputedAlignContent(const nsStyleDisplay* aDisplay) const
|
|
|
|
{
|
|
|
|
uint8_t val = mAlignContent & NS_STYLE_ALIGN_ALL_BITS;
|
|
|
|
val = MapLeftRightToStart(val, eLogicalAxisBlock, aDisplay);
|
|
|
|
uint8_t fallback = mAlignContent >> NS_STYLE_ALIGN_ALL_SHIFT;
|
|
|
|
fallback = MapLeftRightToStart(fallback, eLogicalAxisBlock, aDisplay);
|
|
|
|
return (uint16_t(fallback) << NS_STYLE_ALIGN_ALL_SHIFT) | uint16_t(val);
|
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
uint8_t
|
|
|
|
nsStylePosition::ComputedAlignItems(const nsStyleDisplay* aDisplay) const
|
|
|
|
{
|
|
|
|
if (mAlignItems != NS_STYLE_ALIGN_AUTO) {
|
|
|
|
return MapLeftRightToStart(mAlignItems, eLogicalAxisBlock, aDisplay);
|
|
|
|
}
|
|
|
|
return aDisplay->IsFlexOrGridDisplayType() ? NS_STYLE_ALIGN_STRETCH
|
|
|
|
: NS_STYLE_ALIGN_START;
|
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:06 +03:00
|
|
|
uint8_t
|
|
|
|
nsStylePosition::ComputedAlignSelf(const nsStyleDisplay* aDisplay,
|
|
|
|
nsStyleContext* aParent) const
|
|
|
|
{
|
|
|
|
if (mAlignSelf != NS_STYLE_ALIGN_AUTO) {
|
|
|
|
return MapLeftRightToStart(mAlignSelf, eLogicalAxisBlock, aDisplay);
|
|
|
|
}
|
|
|
|
if (MOZ_UNLIKELY(aDisplay->IsAbsolutelyPositionedStyle())) {
|
|
|
|
return NS_STYLE_ALIGN_AUTO;
|
|
|
|
}
|
|
|
|
if (MOZ_LIKELY(aParent)) {
|
|
|
|
auto parentAlignItems = aParent->StylePosition()->
|
|
|
|
ComputedAlignItems(aParent->StyleDisplay());
|
|
|
|
MOZ_ASSERT(!(parentAlignItems & NS_STYLE_ALIGN_LEGACY),
|
|
|
|
"align-items can't have 'legacy'");
|
|
|
|
return MapLeftRightToStart(parentAlignItems, eLogicalAxisBlock, aDisplay);
|
|
|
|
}
|
|
|
|
return NS_STYLE_ALIGN_START;
|
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
uint16_t
|
|
|
|
nsStylePosition::ComputedJustifyContent(const nsStyleDisplay* aDisplay) const
|
|
|
|
{
|
|
|
|
switch (aDisplay->mDisplay) {
|
|
|
|
case NS_STYLE_DISPLAY_FLEX:
|
|
|
|
case NS_STYLE_DISPLAY_INLINE_FLEX:
|
2015-11-12 01:42:21 +03:00
|
|
|
// For flex containers, css-align-3 says the justify-content value
|
|
|
|
// "'stretch' computes to 'flex-start'."
|
|
|
|
// https://drafts.csswg.org/css-align-3/#propdef-justify-content
|
2015-11-03 17:18:05 +03:00
|
|
|
// XXX maybe map 'auto' too? (ISSUE 8 in the spec)
|
|
|
|
// https://drafts.csswg.org/css-align-3/#content-distribution
|
2015-11-12 01:42:21 +03:00
|
|
|
if ((mJustifyContent & NS_STYLE_ALIGN_ALL_BITS) ==
|
|
|
|
NS_STYLE_JUSTIFY_STRETCH) {
|
2015-11-03 17:18:05 +03:00
|
|
|
return NS_STYLE_JUSTIFY_FLEX_START;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
uint8_t val = mJustifyContent & NS_STYLE_JUSTIFY_ALL_BITS;
|
|
|
|
val = MapLeftRightToStart(val, eLogicalAxisInline, aDisplay);
|
|
|
|
uint8_t fallback = mJustifyContent >> NS_STYLE_JUSTIFY_ALL_SHIFT;
|
|
|
|
fallback = MapLeftRightToStart(fallback, eLogicalAxisInline, aDisplay);
|
|
|
|
return (uint16_t(fallback) << NS_STYLE_JUSTIFY_ALL_SHIFT) | uint16_t(val);
|
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
uint8_t
|
|
|
|
nsStylePosition::ComputedJustifyItems(const nsStyleDisplay* aDisplay,
|
|
|
|
nsStyleContext* aParent) const
|
|
|
|
{
|
|
|
|
if (mJustifyItems != NS_STYLE_JUSTIFY_AUTO) {
|
2015-11-03 17:18:05 +03:00
|
|
|
return MapLeftRightToStart(mJustifyItems, eLogicalAxisInline, aDisplay);
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
if (MOZ_LIKELY(aParent)) {
|
|
|
|
auto inheritedJustifyItems =
|
|
|
|
aParent->StylePosition()->ComputedJustifyItems(aParent->StyleDisplay(),
|
|
|
|
aParent->GetParent());
|
|
|
|
if (inheritedJustifyItems & NS_STYLE_JUSTIFY_LEGACY) {
|
|
|
|
return inheritedJustifyItems;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aDisplay->IsFlexOrGridDisplayType() ? NS_STYLE_JUSTIFY_STRETCH
|
|
|
|
: NS_STYLE_JUSTIFY_START;
|
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
uint8_t
|
|
|
|
nsStylePosition::ComputedJustifySelf(const nsStyleDisplay* aDisplay,
|
|
|
|
nsStyleContext* aParent) const
|
|
|
|
{
|
|
|
|
if (mJustifySelf != NS_STYLE_JUSTIFY_AUTO) {
|
2015-11-03 17:18:05 +03:00
|
|
|
return MapLeftRightToStart(mJustifySelf, eLogicalAxisInline, aDisplay);
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
if (MOZ_UNLIKELY(aDisplay->IsAbsolutelyPositionedStyle())) {
|
|
|
|
return NS_STYLE_JUSTIFY_AUTO;
|
|
|
|
}
|
|
|
|
if (MOZ_LIKELY(aParent)) {
|
|
|
|
auto inheritedJustifyItems = aParent->StylePosition()->
|
|
|
|
ComputedJustifyItems(aParent->StyleDisplay(), aParent->GetParent());
|
|
|
|
inheritedJustifyItems &= ~NS_STYLE_JUSTIFY_LEGACY;
|
2015-11-03 17:18:05 +03:00
|
|
|
return MapLeftRightToStart(inheritedJustifyItems, eLogicalAxisInline,
|
|
|
|
aDisplay);
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
return NS_STYLE_JUSTIFY_START;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleTable
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleTable::nsStyleTable()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTable);
|
2001-06-01 02:19:43 +04:00
|
|
|
// values not inherited
|
|
|
|
mLayoutStrategy = NS_STYLE_TABLE_LAYOUT_AUTO;
|
|
|
|
mSpan = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTable::~nsStyleTable(void)
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleTable);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTable::nsStyleTable(const nsStyleTable& aSource)
|
2014-06-19 07:17:10 +04:00
|
|
|
: mLayoutStrategy(aSource.mLayoutStrategy)
|
|
|
|
, mSpan(aSource.mSpan)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(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
|
|
|
{
|
2014-08-03 06:37:49 +04:00
|
|
|
if (mSpan != aOther.mSpan ||
|
2008-02-08 22:56:03 +03:00
|
|
|
mLayoutStrategy != aOther.mLayoutStrategy)
|
2003-12-04 09:26:15 +03:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2008-02-08 22:56:03 +03:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------
|
|
|
|
// nsStyleTableBorder
|
|
|
|
|
2014-12-01 23:15:41 +03:00
|
|
|
nsStyleTableBorder::nsStyleTableBorder()
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTableBorder);
|
2001-06-01 02:19:43 +04:00
|
|
|
mBorderCollapse = NS_STYLE_BORDER_SEPARATE;
|
|
|
|
|
2014-12-01 23:15:41 +03:00
|
|
|
mEmptyCells = NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
|
2015-09-16 00:02:30 +03:00
|
|
|
mCaptionSide = NS_STYLE_CAPTION_SIDE_TOP;
|
2015-03-20 07:16:00 +03:00
|
|
|
mBorderSpacingCol = 0;
|
|
|
|
mBorderSpacingRow = 0;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTableBorder::~nsStyleTableBorder(void)
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleTableBorder);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleTableBorder::nsStyleTableBorder(const nsStyleTableBorder& aSource)
|
2015-03-20 07:16:00 +03:00
|
|
|
: mBorderSpacingCol(aSource.mBorderSpacingCol)
|
|
|
|
, mBorderSpacingRow(aSource.mBorderSpacingRow)
|
2014-06-19 07:17:10 +04:00
|
|
|
, mBorderCollapse(aSource.mBorderCollapse)
|
|
|
|
, mCaptionSide(aSource.mCaptionSide)
|
|
|
|
, mEmptyCells(aSource.mEmptyCells)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(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) &&
|
2015-03-20 07:16:00 +03:00
|
|
|
(mBorderSpacingCol == aOther.mBorderSpacingCol) &&
|
|
|
|
(mBorderSpacingRow == aOther.mBorderSpacingRow)) {
|
2001-06-01 02:19:43 +04:00
|
|
|
if (mEmptyCells == aOther.mEmptyCells)
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleColor
|
|
|
|
//
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsStyleColor::nsStyleColor(nsPresContext* aPresContext)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColor);
|
2004-02-01 01:41:40 +03:00
|
|
|
mColor = aPresContext->DefaultColor();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColor::nsStyleColor(const nsStyleColor& aSource)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColor);
|
2001-06-01 02:19:43 +04:00
|
|
|
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;
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2009-08-01 19:53:40 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleGradient
|
|
|
|
//
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-01 19:53:40 +04:00
|
|
|
nsStyleGradient::operator==(const nsStyleGradient& aOther) const
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mSize == NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER ||
|
|
|
|
mShape != NS_STYLE_GRADIENT_SHAPE_LINEAR,
|
|
|
|
"incorrect combination of shape and size");
|
|
|
|
MOZ_ASSERT(aOther.mSize == NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER ||
|
|
|
|
aOther.mShape != NS_STYLE_GRADIENT_SHAPE_LINEAR,
|
|
|
|
"incorrect combination of shape and size");
|
2009-11-02 22:36:43 +03:00
|
|
|
|
|
|
|
if (mShape != aOther.mShape ||
|
|
|
|
mSize != aOther.mSize ||
|
|
|
|
mRepeating != aOther.mRepeating ||
|
2015-07-15 17:37:22 +03:00
|
|
|
mLegacySyntax != aOther.mLegacySyntax ||
|
2009-11-02 22:36:43 +03:00
|
|
|
mBgPosX != aOther.mBgPosX ||
|
|
|
|
mBgPosY != aOther.mBgPosY ||
|
2012-07-07 18:27:08 +04:00
|
|
|
mAngle != aOther.mAngle ||
|
|
|
|
mRadiusX != aOther.mRadiusX ||
|
|
|
|
mRadiusY != aOther.mRadiusY)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-01 19:53:40 +04:00
|
|
|
|
|
|
|
if (mStops.Length() != aOther.mStops.Length())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-01 19:53:40 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mStops.Length(); i++) {
|
2014-10-22 16:24:00 +04:00
|
|
|
const auto& stop1 = mStops[i];
|
|
|
|
const auto& stop2 = aOther.mStops[i];
|
|
|
|
if (stop1.mLocation != stop2.mLocation ||
|
|
|
|
stop1.mIsInterpolationHint != stop2.mIsInterpolationHint ||
|
|
|
|
(!stop1.mIsInterpolationHint && stop1.mColor != stop2.mColor))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-01 19:53:40 +04:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-01 19:53:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleGradient::nsStyleGradient(void)
|
2009-11-02 22:36:43 +03:00
|
|
|
: mShape(NS_STYLE_GRADIENT_SHAPE_LINEAR)
|
|
|
|
, mSize(NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mRepeating(false)
|
2015-07-15 17:37:22 +03:00
|
|
|
, mLegacySyntax(false)
|
2009-08-01 19:53:40 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2011-01-03 04:48:09 +03:00
|
|
|
nsStyleGradient::IsOpaque()
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mStops.Length(); i++) {
|
2011-01-03 04:48:09 +03:00
|
|
|
if (NS_GET_A(mStops[i].mColor) < 255)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-01-03 04:48:09 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2011-01-03 04:48:09 +03:00
|
|
|
}
|
|
|
|
|
2012-08-27 08:09:46 +04:00
|
|
|
bool
|
|
|
|
nsStyleGradient::HasCalc()
|
|
|
|
{
|
2012-10-04 09:31:56 +04:00
|
|
|
for (uint32_t i = 0; i < mStops.Length(); i++) {
|
|
|
|
if (mStops[i].mLocation.IsCalcUnit())
|
|
|
|
return true;
|
|
|
|
}
|
2012-08-27 08:09:46 +04:00
|
|
|
return mBgPosX.IsCalcUnit() || mBgPosY.IsCalcUnit() || mAngle.IsCalcUnit() ||
|
2014-02-17 04:05:10 +04:00
|
|
|
mRadiusX.IsCalcUnit() || mRadiusY.IsCalcUnit();
|
2012-08-27 08:09:46 +04:00
|
|
|
}
|
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleImage
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleImage::nsStyleImage()
|
|
|
|
: mType(eStyleImageType_Null)
|
2012-07-30 18:20:58 +04:00
|
|
|
, mCropRect(nullptr)
|
2010-08-06 01:57:18 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
, mImageTracked(false)
|
|
|
|
#endif
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleImage::~nsStyleImage()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleImage);
|
|
|
|
if (mType != eStyleImageType_Null)
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleImage::nsStyleImage(const nsStyleImage& aOther)
|
|
|
|
: mType(eStyleImageType_Null)
|
2012-07-30 18:20:58 +04:00
|
|
|
, mCropRect(nullptr)
|
2010-08-06 01:57:18 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
, mImageTracked(false)
|
|
|
|
#endif
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
|
|
|
// We need our own copy constructor because we don't want
|
|
|
|
// to copy the reference count
|
|
|
|
MOZ_COUNT_CTOR(nsStyleImage);
|
|
|
|
DoCopy(aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleImage&
|
|
|
|
nsStyleImage::operator=(const nsStyleImage& aOther)
|
|
|
|
{
|
|
|
|
if (this != &aOther)
|
|
|
|
DoCopy(aOther);
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::DoCopy(const nsStyleImage& aOther)
|
|
|
|
{
|
|
|
|
SetNull();
|
|
|
|
|
|
|
|
if (aOther.mType == eStyleImageType_Image)
|
|
|
|
SetImageData(aOther.mImage);
|
|
|
|
else if (aOther.mType == eStyleImageType_Gradient)
|
|
|
|
SetGradientData(aOther.mGradient);
|
2010-08-13 17:33:37 +04:00
|
|
|
else if (aOther.mType == eStyleImageType_Element)
|
|
|
|
SetElementId(aOther.mElementId);
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
SetCropRect(aOther.mCropRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::SetNull()
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mImageTracked,
|
|
|
|
"Calling SetNull() with image tracked!");
|
2010-08-06 01:57:18 +04:00
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
if (mType == eStyleImageType_Gradient)
|
|
|
|
mGradient->Release();
|
|
|
|
else if (mType == eStyleImageType_Image)
|
|
|
|
NS_RELEASE(mImage);
|
2010-08-13 17:33:37 +04:00
|
|
|
else if (mType == eStyleImageType_Element)
|
2015-04-01 08:29:55 +03:00
|
|
|
free(mElementId);
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
mType = eStyleImageType_Null;
|
2012-07-30 18:20:58 +04:00
|
|
|
mCropRect = nullptr;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-07-29 18:56:39 +04:00
|
|
|
nsStyleImage::SetImageData(imgRequestProxy* aImage)
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mImageTracked,
|
|
|
|
"Setting a new image without untracking the old one!");
|
2010-08-06 01:57:18 +04:00
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
NS_IF_ADDREF(aImage);
|
|
|
|
|
|
|
|
if (mType != eStyleImageType_Null)
|
|
|
|
SetNull();
|
|
|
|
|
|
|
|
if (aImage) {
|
|
|
|
mImage = aImage;
|
|
|
|
mType = eStyleImageType_Image;
|
|
|
|
}
|
2014-01-31 07:36:41 +04:00
|
|
|
mSubImages.Clear();
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2010-08-06 01:57:18 +04:00
|
|
|
void
|
|
|
|
nsStyleImage::TrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mImageTracked, "Already tracking image!");
|
|
|
|
MOZ_ASSERT(mType == eStyleImageType_Image,
|
|
|
|
"Can't track image when there isn't one!");
|
2010-08-06 01:57:18 +04:00
|
|
|
|
|
|
|
// Register the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
|
|
|
if (doc)
|
|
|
|
doc->AddImage(mImage);
|
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::UntrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mImageTracked, "Image not tracked!");
|
|
|
|
MOZ_ASSERT(mType == eStyleImageType_Image,
|
|
|
|
"Can't untrack image when there isn't one!");
|
2010-08-06 01:57:18 +04:00
|
|
|
|
|
|
|
// Unregister the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
|
|
|
if (doc)
|
2012-10-01 21:53:57 +04:00
|
|
|
doc->RemoveImage(mImage, nsIDocument::REQUEST_DISCARD);
|
2010-08-06 01:57:18 +04:00
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
void
|
|
|
|
nsStyleImage::SetGradientData(nsStyleGradient* aGradient)
|
|
|
|
{
|
|
|
|
if (aGradient)
|
|
|
|
aGradient->AddRef();
|
|
|
|
|
|
|
|
if (mType != eStyleImageType_Null)
|
|
|
|
SetNull();
|
|
|
|
|
|
|
|
if (aGradient) {
|
|
|
|
mGradient = aGradient;
|
|
|
|
mType = eStyleImageType_Gradient;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-13 17:33:37 +04:00
|
|
|
void
|
2014-01-04 19:02:17 +04:00
|
|
|
nsStyleImage::SetElementId(const char16_t* aElementId)
|
2010-08-13 17:33:37 +04:00
|
|
|
{
|
|
|
|
if (mType != eStyleImageType_Null)
|
|
|
|
SetNull();
|
|
|
|
|
|
|
|
if (aElementId) {
|
2011-06-21 09:03:59 +04:00
|
|
|
mElementId = NS_strdup(aElementId);
|
2010-08-13 17:33:37 +04:00
|
|
|
mType = eStyleImageType_Element;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
void
|
|
|
|
nsStyleImage::SetCropRect(nsStyleSides* aCropRect)
|
|
|
|
{
|
|
|
|
if (aCropRect) {
|
|
|
|
mCropRect = new nsStyleSides(*aCropRect);
|
|
|
|
// There is really not much we can do if 'new' fails
|
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
mCropRect = nullptr;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t
|
|
|
|
ConvertToPixelCoord(const nsStyleCoord& aCoord, int32_t aPercentScale)
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
|
|
|
double pixelValue;
|
|
|
|
switch (aCoord.GetUnit()) {
|
|
|
|
case eStyleUnit_Percent:
|
|
|
|
pixelValue = aCoord.GetPercentValue() * aPercentScale;
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Factor:
|
|
|
|
pixelValue = aCoord.GetFactorValue();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unexpected unit for image crop rect");
|
|
|
|
return 0;
|
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(pixelValue >= 0, "we ensured non-negative while parsing");
|
2013-01-15 16:22:03 +04:00
|
|
|
pixelValue = std::min(pixelValue, double(INT32_MAX)); // avoid overflow
|
2009-08-22 00:39:25 +04:00
|
|
|
return NS_lround(pixelValue);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-22 00:39:25 +04:00
|
|
|
nsStyleImage::ComputeActualCropRect(nsIntRect& aActualCropRect,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aIsEntireImage) const
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
|
|
|
if (mType != eStyleImageType_Image)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
|
|
|
mImage->GetImage(getter_AddRefs(imageContainer));
|
|
|
|
if (!imageContainer)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
nsIntSize imageSize;
|
|
|
|
imageContainer->GetWidth(&imageSize.width);
|
|
|
|
imageContainer->GetHeight(&imageSize.height);
|
|
|
|
if (imageSize.width <= 0 || imageSize.height <= 0)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t left = ConvertToPixelCoord(mCropRect->GetLeft(), imageSize.width);
|
|
|
|
int32_t top = ConvertToPixelCoord(mCropRect->GetTop(), imageSize.height);
|
|
|
|
int32_t right = ConvertToPixelCoord(mCropRect->GetRight(), imageSize.width);
|
|
|
|
int32_t bottom = ConvertToPixelCoord(mCropRect->GetBottom(), imageSize.height);
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
// IntersectRect() returns an empty rect if we get negative width or height
|
|
|
|
nsIntRect cropRect(left, top, right - left, bottom - top);
|
|
|
|
nsIntRect imageRect(nsIntPoint(0, 0), imageSize);
|
|
|
|
aActualCropRect.IntersectRect(imageRect, cropRect);
|
|
|
|
|
|
|
|
if (aIsEntireImage)
|
2011-04-19 07:07:23 +04:00
|
|
|
*aIsEntireImage = aActualCropRect.IsEqualInterior(imageRect);
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2009-09-13 02:44:18 +04:00
|
|
|
nsresult
|
2012-10-13 00:04:03 +04:00
|
|
|
nsStyleImage::StartDecoding() const
|
2009-09-13 02:44:18 +04:00
|
|
|
{
|
|
|
|
if ((mType == eStyleImageType_Image) && mImage)
|
2012-10-05 00:02:15 +04:00
|
|
|
return mImage->StartDecoding();
|
2009-09-13 02:44:18 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-22 00:39:25 +04:00
|
|
|
nsStyleImage::IsOpaque() const
|
|
|
|
{
|
|
|
|
if (!IsComplete())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2011-01-03 04:48:09 +03:00
|
|
|
if (mType == eStyleImageType_Gradient)
|
|
|
|
return mGradient->IsOpaque();
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2010-08-13 17:33:37 +04:00
|
|
|
if (mType == eStyleImageType_Element)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-08-13 17:33:37 +04:00
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mType == eStyleImageType_Image, "unexpected image type");
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
|
|
|
mImage->GetImage(getter_AddRefs(imageContainer));
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(imageContainer, "IsComplete() said image container is ready");
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2014-11-25 10:42:43 +03:00
|
|
|
// Check if the crop region of the image is opaque.
|
|
|
|
if (imageContainer->IsOpaque()) {
|
2009-08-22 00:39:25 +04:00
|
|
|
if (!mCropRect)
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
// Must make sure if mCropRect contains at least a pixel.
|
2011-10-17 18:59:28 +04:00
|
|
|
// XXX Is this optimization worth it? Maybe I should just return false.
|
2009-08-22 00:39:25 +04:00
|
|
|
nsIntRect actualCropRect;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool rv = ComputeActualCropRect(actualCropRect);
|
2009-08-22 00:39:25 +04:00
|
|
|
NS_ASSERTION(rv, "ComputeActualCropRect() can not fail here");
|
|
|
|
return rv && !actualCropRect.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-22 00:39:25 +04:00
|
|
|
nsStyleImage::IsComplete() const
|
|
|
|
{
|
|
|
|
switch (mType) {
|
|
|
|
case eStyleImageType_Null:
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
case eStyleImageType_Gradient:
|
2010-08-13 17:33:37 +04:00
|
|
|
case eStyleImageType_Element:
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-22 00:39:25 +04:00
|
|
|
case eStyleImageType_Image:
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t status = imgIRequest::STATUS_ERROR;
|
2009-08-22 00:39:25 +04:00
|
|
|
return NS_SUCCEEDED(mImage->GetImageStatus(&status)) &&
|
|
|
|
(status & imgIRequest::STATUS_SIZE_AVAILABLE) &&
|
|
|
|
(status & imgIRequest::STATUS_FRAME_COMPLETE);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unexpected image type");
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-19 12:40:02 +04:00
|
|
|
bool
|
|
|
|
nsStyleImage::IsLoaded() const
|
|
|
|
{
|
|
|
|
switch (mType) {
|
|
|
|
case eStyleImageType_Null:
|
|
|
|
return false;
|
|
|
|
case eStyleImageType_Gradient:
|
|
|
|
case eStyleImageType_Element:
|
|
|
|
return true;
|
|
|
|
case eStyleImageType_Image:
|
|
|
|
{
|
|
|
|
uint32_t status = imgIRequest::STATUS_ERROR;
|
|
|
|
return NS_SUCCEEDED(mImage->GetImageStatus(&status)) &&
|
|
|
|
!(status & imgIRequest::STATUS_ERROR) &&
|
|
|
|
(status & imgIRequest::STATUS_LOAD_COMPLETE);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unexpected image type");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static inline bool
|
2009-08-22 00:39:25 +04:00
|
|
|
EqualRects(const nsStyleSides* aRect1, const nsStyleSides* aRect2)
|
|
|
|
{
|
|
|
|
return aRect1 == aRect2 || /* handles null== null, and optimize */
|
|
|
|
(aRect1 && aRect2 && *aRect1 == *aRect2);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-22 00:39:25 +04:00
|
|
|
nsStyleImage::operator==(const nsStyleImage& aOther) const
|
|
|
|
{
|
|
|
|
if (mType != aOther.mType)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
if (!EqualRects(mCropRect, aOther.mCropRect))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
if (mType == eStyleImageType_Image)
|
|
|
|
return EqualImages(mImage, aOther.mImage);
|
|
|
|
|
|
|
|
if (mType == eStyleImageType_Gradient)
|
|
|
|
return *mGradient == *aOther.mGradient;
|
|
|
|
|
2010-08-13 17:33:37 +04:00
|
|
|
if (mType == eStyleImageType_Element)
|
2011-06-21 09:03:59 +04:00
|
|
|
return NS_strcmp(mElementId, aOther.mElementId) == 0;
|
2010-08-13 17:33:37 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleBackground
|
|
|
|
//
|
|
|
|
|
2008-09-12 19:35:53 +04:00
|
|
|
nsStyleBackground::nsStyleBackground()
|
2009-02-20 08:29:21 +03:00
|
|
|
: mAttachmentCount(1)
|
|
|
|
, mClipCount(1)
|
|
|
|
, mOriginCount(1)
|
|
|
|
, mRepeatCount(1)
|
|
|
|
, mPositionCount(1)
|
|
|
|
, mImageCount(1)
|
2009-05-28 22:09:05 +04:00
|
|
|
, mSizeCount(1)
|
2013-11-08 19:07:36 +04:00
|
|
|
, mBlendModeCount(1)
|
2009-02-20 08:29:21 +03:00
|
|
|
, mBackgroundColor(NS_RGBA(0, 0, 0, 0))
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleBackground);
|
2009-02-20 08:29:21 +03:00
|
|
|
Layer *onlyLayer = mLayers.AppendElement();
|
|
|
|
NS_ASSERTION(onlyLayer, "auto array must have room for 1 element");
|
|
|
|
onlyLayer->SetInitialValues();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
|
2009-02-20 08:29:21 +03:00
|
|
|
: mAttachmentCount(aSource.mAttachmentCount)
|
|
|
|
, mClipCount(aSource.mClipCount)
|
|
|
|
, mOriginCount(aSource.mOriginCount)
|
|
|
|
, mRepeatCount(aSource.mRepeatCount)
|
|
|
|
, mPositionCount(aSource.mPositionCount)
|
|
|
|
, mImageCount(aSource.mImageCount)
|
2009-05-28 22:09:05 +04:00
|
|
|
, mSizeCount(aSource.mSizeCount)
|
2013-11-08 19:07:36 +04:00
|
|
|
, mBlendModeCount(aSource.mBlendModeCount)
|
2009-02-20 08:29:21 +03:00
|
|
|
, mLayers(aSource.mLayers) // deep copy
|
|
|
|
, mBackgroundColor(aSource.mBackgroundColor)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleBackground);
|
2009-02-20 08:29:21 +03:00
|
|
|
// If the deep copy of mLayers failed, truncate the counts.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t count = mLayers.Length();
|
2009-02-20 08:29:21 +03:00
|
|
|
if (count != aSource.mLayers.Length()) {
|
|
|
|
NS_WARNING("truncating counts due to out-of-memory");
|
2013-01-15 16:22:03 +04:00
|
|
|
mAttachmentCount = std::max(mAttachmentCount, count);
|
|
|
|
mClipCount = std::max(mClipCount, count);
|
|
|
|
mOriginCount = std::max(mOriginCount, count);
|
|
|
|
mRepeatCount = std::max(mRepeatCount, count);
|
|
|
|
mPositionCount = std::max(mPositionCount, count);
|
|
|
|
mImageCount = std::max(mImageCount, count);
|
|
|
|
mSizeCount = std::max(mSizeCount, count);
|
2013-11-08 19:07:36 +04:00
|
|
|
mBlendModeCount = std::max(mSizeCount, count);
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
nsStyleBackground::~nsStyleBackground()
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleBackground);
|
2004-03-09 06:57:51 +03:00
|
|
|
}
|
|
|
|
|
2010-08-06 01:57:18 +04:00
|
|
|
void
|
|
|
|
nsStyleBackground::Destroy(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Untrack all the images stored in our layers
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mImageCount; ++i)
|
2010-08-06 01:57:18 +04:00
|
|
|
mLayers[i].UntrackImages(aContext);
|
|
|
|
|
|
|
|
this->~nsStyleBackground();
|
2014-07-16 09:27:13 +04:00
|
|
|
aContext->PresShell()->
|
2015-09-17 05:08:19 +03:00
|
|
|
FreeByObjectID(eArenaObjectID_nsStyleBackground, this);
|
2010-08-06 01:57:18 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleBackground::CalcDifference(const nsStyleBackground& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2010-08-13 17:33:37 +04:00
|
|
|
const nsStyleBackground* moreLayers =
|
|
|
|
mImageCount > aOther.mImageCount ? this : &aOther;
|
|
|
|
const nsStyleBackground* lessLayers =
|
|
|
|
mImageCount > aOther.mImageCount ? &aOther : this;
|
2009-02-20 08:29:21 +03:00
|
|
|
|
2015-11-02 19:36:35 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2010-08-13 17:33:37 +04:00
|
|
|
|
|
|
|
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, moreLayers) {
|
|
|
|
if (i < lessLayers->mImageCount) {
|
2015-11-02 19:36:35 +03:00
|
|
|
nsChangeHint layerDifference = moreLayers->mLayers[i].CalcDifference(lessLayers->mLayers[i]);
|
|
|
|
hint |= layerDifference;
|
|
|
|
if (layerDifference &&
|
|
|
|
((moreLayers->mLayers[i].mImage.GetType() == eStyleImageType_Element) ||
|
|
|
|
(lessLayers->mLayers[i].mImage.GetType() == eStyleImageType_Element))) {
|
|
|
|
hint |= nsChangeHint_UpdateEffects | nsChangeHint_RepaintFrame;
|
2010-08-13 17:33:37 +04:00
|
|
|
}
|
|
|
|
} else {
|
2015-11-02 19:36:35 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
if (moreLayers->mLayers[i].mImage.GetType() == eStyleImageType_Element) {
|
|
|
|
hint |= nsChangeHint_UpdateEffects | nsChangeHint_RepaintFrame;
|
|
|
|
}
|
2010-08-13 17:33:37 +04:00
|
|
|
}
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
|
|
|
|
2015-11-02 19:36:35 +03:00
|
|
|
if (mBackgroundColor != aOther.mBackgroundColor) {
|
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hint) {
|
|
|
|
return hint;
|
|
|
|
}
|
2010-08-13 17:33:37 +04:00
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
if (mAttachmentCount != aOther.mAttachmentCount ||
|
|
|
|
mClipCount != aOther.mClipCount ||
|
|
|
|
mOriginCount != aOther.mOriginCount ||
|
|
|
|
mRepeatCount != aOther.mRepeatCount ||
|
|
|
|
mPositionCount != aOther.mPositionCount ||
|
|
|
|
mSizeCount != aOther.mSizeCount) {
|
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2009-02-20 08:29:21 +03:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsStyleBackground::HasFixedBackground() const
|
2004-09-14 00:40:46 +04:00
|
|
|
{
|
2009-02-20 08:29:21 +03:00
|
|
|
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, this) {
|
|
|
|
const Layer &layer = mLayers[i];
|
2009-08-01 19:53:40 +04:00
|
|
|
if (layer.mAttachment == NS_STYLE_BG_ATTACHMENT_FIXED &&
|
2009-08-22 00:39:25 +04:00
|
|
|
!layer.mImage.IsEmpty()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsStyleBackground::IsTransparent() const
|
2009-02-20 08:29:21 +03:00
|
|
|
{
|
2009-08-22 00:39:25 +04:00
|
|
|
return BottomLayer().mImage.IsEmpty() &&
|
2009-08-01 19:53:40 +04:00
|
|
|
mImageCount == 1 &&
|
2009-02-20 08:29:21 +03:00
|
|
|
NS_GET_A(mBackgroundColor) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-09 22:40:18 +04:00
|
|
|
nsStyleBackground::Position::SetInitialPercentValues(float aPercentVal)
|
2009-02-20 08:29:21 +03:00
|
|
|
{
|
2014-09-09 22:40:18 +04:00
|
|
|
mXPosition.mPercent = aPercentVal;
|
2010-09-15 19:11:26 +04:00
|
|
|
mXPosition.mLength = 0;
|
2011-10-17 18:59:28 +04:00
|
|
|
mXPosition.mHasPercent = true;
|
2014-09-09 22:40:18 +04:00
|
|
|
mYPosition.mPercent = aPercentVal;
|
2010-09-15 19:11:26 +04:00
|
|
|
mYPosition.mLength = 0;
|
2011-10-17 18:59:28 +04:00
|
|
|
mYPosition.mHasPercent = true;
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
|
|
|
|
2014-02-04 05:54:22 +04:00
|
|
|
void
|
|
|
|
nsStyleBackground::Position::SetInitialZeroValues()
|
|
|
|
{
|
|
|
|
mXPosition.mPercent = 0;
|
|
|
|
mXPosition.mLength = 0;
|
|
|
|
mXPosition.mHasPercent = false;
|
|
|
|
mYPosition.mPercent = 0;
|
|
|
|
mYPosition.mLength = 0;
|
|
|
|
mYPosition.mHasPercent = false;
|
|
|
|
}
|
|
|
|
|
2011-01-13 13:40:12 +03:00
|
|
|
bool
|
2012-11-08 19:05:32 +04:00
|
|
|
nsStyleBackground::Size::DependsOnPositioningAreaSize(const nsStyleImage& aImage) const
|
2011-01-13 13:40:12 +03:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aImage.GetType() != eStyleImageType_Null,
|
|
|
|
"caller should have handled this");
|
2011-01-13 13:40:12 +03:00
|
|
|
|
|
|
|
// If either dimension contains a non-zero percentage, rendering for that
|
|
|
|
// dimension straightforwardly depends on frame size.
|
|
|
|
if ((mWidthType == eLengthPercentage && mWidth.mPercent != 0.0f) ||
|
|
|
|
(mHeightType == eLengthPercentage && mHeight.mPercent != 0.0f)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// So too for contain and cover.
|
|
|
|
if (mWidthType == eContain || mWidthType == eCover) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If both dimensions are fixed lengths, there's no dependency.
|
|
|
|
if (mWidthType == eLengthPercentage && mHeightType == eLengthPercentage) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT((mWidthType == eLengthPercentage && mHeightType == eAuto) ||
|
|
|
|
(mWidthType == eAuto && mHeightType == eLengthPercentage) ||
|
|
|
|
(mWidthType == eAuto && mHeightType == eAuto),
|
|
|
|
"logic error");
|
2011-01-13 13:40:12 +03:00
|
|
|
|
|
|
|
nsStyleImageType type = aImage.GetType();
|
|
|
|
|
|
|
|
// Gradient rendering depends on frame size when auto is involved because
|
|
|
|
// gradients have no intrinsic ratio or dimensions, and therefore the relevant
|
|
|
|
// dimension is "treat[ed] as 100%".
|
|
|
|
if (type == eStyleImageType_Gradient) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX Element rendering for auto or fixed length doesn't depend on frame size
|
|
|
|
// according to the spec. However, we don't implement the spec yet, so
|
|
|
|
// for now we bail and say element() plus auto affects ultimate size.
|
|
|
|
if (type == eStyleImageType_Element) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == eStyleImageType_Image) {
|
|
|
|
nsCOMPtr<imgIContainer> imgContainer;
|
|
|
|
aImage.GetImageData()->GetImage(getter_AddRefs(imgContainer));
|
|
|
|
if (imgContainer) {
|
2015-03-30 18:35:47 +03:00
|
|
|
CSSIntSize imageSize;
|
2011-01-13 13:40:12 +03:00
|
|
|
nsSize imageRatio;
|
|
|
|
bool hasWidth, hasHeight;
|
|
|
|
nsLayoutUtils::ComputeSizeForDrawing(imgContainer, imageSize, imageRatio,
|
|
|
|
hasWidth, hasHeight);
|
|
|
|
|
|
|
|
// If the image has a fixed width and height, rendering never depends on
|
|
|
|
// the frame size.
|
|
|
|
if (hasWidth && hasHeight) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the image has an intrinsic ratio, rendering will depend on frame
|
|
|
|
// size when background-size is all auto.
|
|
|
|
if (imageRatio != nsSize(0, 0)) {
|
|
|
|
return mWidthType == mHeightType;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, rendering depends on frame size when the image dimensions
|
|
|
|
// and background-size don't complement each other.
|
|
|
|
return !(hasWidth && mHeightType == eLengthPercentage) &&
|
|
|
|
!(hasHeight && mWidthType == eLengthPercentage);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
NS_NOTREACHED("missed an enum value");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Passed the gauntlet: no dependency.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-05-28 22:09:05 +04:00
|
|
|
void
|
|
|
|
nsStyleBackground::Size::SetInitialValues()
|
|
|
|
{
|
|
|
|
mWidthType = mHeightType = eAuto;
|
|
|
|
}
|
|
|
|
|
2010-09-15 19:11:26 +04:00
|
|
|
bool
|
2009-05-28 22:09:05 +04:00
|
|
|
nsStyleBackground::Size::operator==(const Size& aOther) const
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mWidthType < eDimensionType_COUNT,
|
|
|
|
"bad mWidthType for this");
|
|
|
|
MOZ_ASSERT(mHeightType < eDimensionType_COUNT,
|
|
|
|
"bad mHeightType for this");
|
|
|
|
MOZ_ASSERT(aOther.mWidthType < eDimensionType_COUNT,
|
|
|
|
"bad mWidthType for aOther");
|
|
|
|
MOZ_ASSERT(aOther.mHeightType < eDimensionType_COUNT,
|
|
|
|
"bad mHeightType for aOther");
|
2009-05-28 22:09:05 +04:00
|
|
|
|
2010-09-15 19:11:26 +04:00
|
|
|
return mWidthType == aOther.mWidthType &&
|
|
|
|
mHeightType == aOther.mHeightType &&
|
|
|
|
(mWidthType != eLengthPercentage || mWidth == aOther.mWidth) &&
|
|
|
|
(mHeightType != eLengthPercentage || mHeight == aOther.mHeight);
|
2009-05-28 22:09:05 +04:00
|
|
|
}
|
|
|
|
|
2012-02-25 09:23:14 +04:00
|
|
|
void
|
|
|
|
nsStyleBackground::Repeat::SetInitialValues()
|
|
|
|
{
|
|
|
|
mXRepeat = NS_STYLE_BG_REPEAT_REPEAT;
|
|
|
|
mYRepeat = NS_STYLE_BG_REPEAT_REPEAT;
|
|
|
|
}
|
|
|
|
|
2009-02-20 08:29:21 +03:00
|
|
|
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;
|
2012-02-25 09:23:14 +04:00
|
|
|
mRepeat.SetInitialValues();
|
2013-11-08 19:07:36 +04:00
|
|
|
mBlendMode = NS_STYLE_BLEND_NORMAL;
|
2014-09-09 22:40:18 +04:00
|
|
|
mPosition.SetInitialPercentValues(0.0f); // Initial value is "0% 0%"
|
2009-05-28 22:09:05 +04:00
|
|
|
mSize.SetInitialValues();
|
2009-08-01 19:53:40 +04:00
|
|
|
mImage.SetNull();
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-11-08 19:05:32 +04:00
|
|
|
nsStyleBackground::Layer::RenderingMightDependOnPositioningAreaSizeChange() const
|
2010-10-07 02:18:52 +04:00
|
|
|
{
|
2010-10-07 02:18:52 +04:00
|
|
|
// Do we even have an image?
|
|
|
|
if (mImage.IsEmpty()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-10-07 02:18:52 +04:00
|
|
|
}
|
|
|
|
|
2012-11-08 19:05:32 +04:00
|
|
|
return mPosition.DependsOnPositioningAreaSize() ||
|
|
|
|
mSize.DependsOnPositioningAreaSize(mImage);
|
2010-10-07 02:18:52 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-10-07 02:18:52 +04:00
|
|
|
nsStyleBackground::Layer::operator==(const Layer& aOther) const
|
2009-02-20 08:29:21 +03:00
|
|
|
{
|
|
|
|
return mAttachment == aOther.mAttachment &&
|
|
|
|
mClip == aOther.mClip &&
|
|
|
|
mOrigin == aOther.mOrigin &&
|
|
|
|
mRepeat == aOther.mRepeat &&
|
2013-11-08 19:07:36 +04:00
|
|
|
mBlendMode == aOther.mBlendMode &&
|
2009-02-20 08:29:21 +03:00
|
|
|
mPosition == aOther.mPosition &&
|
2009-05-28 22:09:05 +04:00
|
|
|
mSize == aOther.mSize &&
|
2009-08-01 19:53:40 +04:00
|
|
|
mImage == aOther.mImage;
|
|
|
|
}
|
|
|
|
|
2015-11-02 19:36:35 +03:00
|
|
|
nsChangeHint
|
|
|
|
nsStyleBackground::Layer::CalcDifference(const Layer& aOther) const
|
|
|
|
{
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
if (mAttachment != aOther.mAttachment ||
|
|
|
|
mClip != aOther.mClip ||
|
|
|
|
mOrigin != aOther.mOrigin ||
|
|
|
|
mRepeat != aOther.mRepeat ||
|
|
|
|
mBlendMode != aOther.mBlendMode ||
|
|
|
|
mSize != aOther.mSize ||
|
|
|
|
mImage != aOther.mImage) {
|
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
if (mPosition != aOther.mPosition) {
|
|
|
|
hint |= nsChangeHint_SchedulePaint;
|
|
|
|
}
|
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleDisplay
|
|
|
|
//
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsTimingFunction::AssignFromKeyword(int32_t aTimingFunctionType)
|
2009-08-21 01:52:47 +04:00
|
|
|
{
|
2011-04-12 10:18:42 +04:00
|
|
|
switch (aTimingFunctionType) {
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_STEP_START:
|
2015-09-29 05:20:13 +03:00
|
|
|
mType = Type::StepStart;
|
|
|
|
mStepSyntax = StepSyntax::Keyword;
|
2011-04-12 10:18:42 +04:00
|
|
|
mSteps = 1;
|
|
|
|
return;
|
2015-09-29 05:20:13 +03:00
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("aTimingFunctionType must be a keyword value");
|
|
|
|
// fall through
|
2011-04-12 10:18:42 +04:00
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_STEP_END:
|
2015-09-29 05:20:13 +03:00
|
|
|
mType = Type::StepEnd;
|
|
|
|
mStepSyntax = StepSyntax::Keyword;
|
2011-04-12 10:18:42 +04:00
|
|
|
mSteps = 1;
|
|
|
|
return;
|
2015-09-29 05:20:13 +03:00
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE:
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR:
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN:
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_OUT:
|
|
|
|
case NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN_OUT:
|
|
|
|
mType = static_cast<Type>(aTimingFunctionType);
|
2011-04-12 10:18:42 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-07-18 21:59:53 +04:00
|
|
|
static_assert(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE == 0 &&
|
|
|
|
NS_STYLE_TRANSITION_TIMING_FUNCTION_LINEAR == 1 &&
|
|
|
|
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN == 2 &&
|
|
|
|
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_OUT == 3 &&
|
|
|
|
NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE_IN_OUT == 4,
|
|
|
|
"transition timing function constants not as expected");
|
2009-08-21 01:52:47 +04:00
|
|
|
|
|
|
|
static const float timingFunctionValues[5][4] = {
|
2013-04-28 14:02:35 +04:00
|
|
|
{ 0.25f, 0.10f, 0.25f, 1.00f }, // ease
|
|
|
|
{ 0.00f, 0.00f, 1.00f, 1.00f }, // linear
|
|
|
|
{ 0.42f, 0.00f, 1.00f, 1.00f }, // ease-in
|
|
|
|
{ 0.00f, 0.00f, 0.58f, 1.00f }, // ease-out
|
|
|
|
{ 0.42f, 0.00f, 0.58f, 1.00f } // ease-in-out
|
2009-08-21 01:52:47 +04:00
|
|
|
};
|
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(0 <= aTimingFunctionType && aTimingFunctionType < 5,
|
|
|
|
"keyword out of range");
|
2011-04-12 10:18:42 +04:00
|
|
|
mFunc.mX1 = timingFunctionValues[aTimingFunctionType][0];
|
|
|
|
mFunc.mY1 = timingFunctionValues[aTimingFunctionType][1];
|
|
|
|
mFunc.mX2 = timingFunctionValues[aTimingFunctionType][2];
|
|
|
|
mFunc.mY2 = timingFunctionValues[aTimingFunctionType][3];
|
2009-08-21 01:52:47 +04:00
|
|
|
}
|
|
|
|
|
2014-06-27 03:57:12 +04:00
|
|
|
mozilla::StyleTransition::StyleTransition(const StyleTransition& aCopy)
|
2009-08-21 01:52:47 +04:00
|
|
|
: mTimingFunction(aCopy.mTimingFunction)
|
|
|
|
, mDuration(aCopy.mDuration)
|
|
|
|
, mDelay(aCopy.mDelay)
|
|
|
|
, mProperty(aCopy.mProperty)
|
2010-10-21 04:24:16 +04:00
|
|
|
, mUnknownProperty(aCopy.mUnknownProperty)
|
2009-08-21 01:52:47 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-06-27 03:57:12 +04:00
|
|
|
void
|
|
|
|
mozilla::StyleTransition::SetInitialValues()
|
2009-08-21 01:52:47 +04:00
|
|
|
{
|
|
|
|
mTimingFunction = nsTimingFunction(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE);
|
|
|
|
mDuration = 0.0;
|
|
|
|
mDelay = 0.0;
|
|
|
|
mProperty = eCSSPropertyExtra_all_properties;
|
|
|
|
}
|
|
|
|
|
2014-06-27 03:57:12 +04:00
|
|
|
void
|
|
|
|
mozilla::StyleTransition::SetUnknownProperty(const nsAString& aUnknownProperty)
|
2009-08-21 01:52:47 +04:00
|
|
|
{
|
2012-07-14 03:59:05 +04:00
|
|
|
NS_ASSERTION(nsCSSProps::LookupProperty(aUnknownProperty,
|
2014-03-07 21:14:23 +04:00
|
|
|
nsCSSProps::eEnabledForAllContent) ==
|
2009-08-21 01:52:47 +04:00
|
|
|
eCSSProperty_UNKNOWN,
|
|
|
|
"should be unknown property");
|
|
|
|
mProperty = eCSSProperty_UNKNOWN;
|
|
|
|
mUnknownProperty = do_GetAtom(aUnknownProperty);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
bool
|
|
|
|
mozilla::StyleTransition::operator==(const mozilla::StyleTransition& aOther) const
|
|
|
|
{
|
|
|
|
return mTimingFunction == aOther.mTimingFunction &&
|
|
|
|
mDuration == aOther.mDuration &&
|
|
|
|
mDelay == aOther.mDelay &&
|
|
|
|
mProperty == aOther.mProperty &&
|
|
|
|
(mProperty != eCSSProperty_UNKNOWN ||
|
|
|
|
mUnknownProperty == aOther.mUnknownProperty);
|
|
|
|
}
|
|
|
|
|
2014-06-27 03:57:11 +04:00
|
|
|
mozilla::StyleAnimation::StyleAnimation(const mozilla::StyleAnimation& aCopy)
|
2011-04-12 10:18:42 +04:00
|
|
|
: mTimingFunction(aCopy.mTimingFunction)
|
|
|
|
, mDuration(aCopy.mDuration)
|
|
|
|
, mDelay(aCopy.mDelay)
|
|
|
|
, mName(aCopy.mName)
|
|
|
|
, mDirection(aCopy.mDirection)
|
|
|
|
, mFillMode(aCopy.mFillMode)
|
|
|
|
, mPlayState(aCopy.mPlayState)
|
|
|
|
, mIterationCount(aCopy.mIterationCount)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-06-27 03:57:11 +04:00
|
|
|
mozilla::StyleAnimation::SetInitialValues()
|
2011-04-12 10:18:42 +04:00
|
|
|
{
|
|
|
|
mTimingFunction = nsTimingFunction(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE);
|
|
|
|
mDuration = 0.0;
|
|
|
|
mDelay = 0.0;
|
|
|
|
mName = EmptyString();
|
|
|
|
mDirection = NS_STYLE_ANIMATION_DIRECTION_NORMAL;
|
|
|
|
mFillMode = NS_STYLE_ANIMATION_FILL_MODE_NONE;
|
|
|
|
mPlayState = NS_STYLE_ANIMATION_PLAY_STATE_RUNNING;
|
|
|
|
mIterationCount = 1.0f;
|
|
|
|
}
|
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
bool
|
|
|
|
mozilla::StyleAnimation::operator==(const mozilla::StyleAnimation& aOther) const
|
|
|
|
{
|
|
|
|
return mTimingFunction == aOther.mTimingFunction &&
|
|
|
|
mDuration == aOther.mDuration &&
|
|
|
|
mDelay == aOther.mDelay &&
|
|
|
|
mName == aOther.mName &&
|
|
|
|
mDirection == aOther.mDirection &&
|
|
|
|
mFillMode == aOther.mFillMode &&
|
|
|
|
mPlayState == aOther.mPlayState &&
|
|
|
|
mIterationCount == aOther.mIterationCount;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleDisplay::nsStyleDisplay()
|
2015-03-20 07:12:17 +03:00
|
|
|
: mWillChangeBitField(0)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleDisplay);
|
2007-09-05 14:27:06 +04:00
|
|
|
mAppearance = NS_THEME_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
mDisplay = NS_STYLE_DISPLAY_INLINE;
|
2011-10-29 11:04:20 +04:00
|
|
|
mOriginalDisplay = mDisplay;
|
2015-06-04 17:38:00 +03:00
|
|
|
mContain = NS_STYLE_CONTAIN_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;
|
2011-10-29 11:04:20 +04:00
|
|
|
mOriginalFloats = mFloats;
|
2001-06-01 02:19:43 +04:00
|
|
|
mBreakType = NS_STYLE_CLEAR_NONE;
|
2012-11-08 20:09:37 +04:00
|
|
|
mBreakInside = NS_STYLE_PAGE_BREAK_AUTO;
|
2011-10-17 18:59:28 +04:00
|
|
|
mBreakBefore = false;
|
|
|
|
mBreakAfter = false;
|
2004-09-05 04:04:04 +04:00
|
|
|
mOverflowX = NS_STYLE_OVERFLOW_VISIBLE;
|
|
|
|
mOverflowY = NS_STYLE_OVERFLOW_VISIBLE;
|
2014-02-22 05:18:23 +04:00
|
|
|
mOverflowClipBox = NS_STYLE_OVERFLOW_CLIP_BOX_PADDING_BOX;
|
2010-03-19 14:49:33 +03:00
|
|
|
mResize = NS_STYLE_RESIZE_NONE;
|
2015-03-20 07:12:17 +03:00
|
|
|
mClipFlags = NS_STYLE_CLIP_AUTO;
|
|
|
|
mClip.SetRect(0,0,0,0);
|
2003-11-02 01:34:59 +03:00
|
|
|
mOpacity = 1.0f;
|
2015-03-20 07:12:17 +03:00
|
|
|
mSpecifiedTransform = nullptr;
|
|
|
|
mTransformOrigin[0].SetPercentValue(0.5f); // Transform is centered on origin
|
|
|
|
mTransformOrigin[1].SetPercentValue(0.5f);
|
|
|
|
mTransformOrigin[2].SetCoordValue(0);
|
|
|
|
mPerspectiveOrigin[0].SetPercentValue(0.5f);
|
|
|
|
mPerspectiveOrigin[1].SetPercentValue(0.5f);
|
|
|
|
mChildPerspective.SetNoneValue();
|
|
|
|
mBackfaceVisibility = NS_STYLE_BACKFACE_VISIBILITY_VISIBLE;
|
|
|
|
mTransformStyle = NS_STYLE_TRANSFORM_STYLE_FLAT;
|
2015-05-16 00:43:25 +03:00
|
|
|
mTransformBox = NS_STYLE_TRANSFORM_BOX_BORDER_BOX;
|
2014-06-27 14:22:32 +04:00
|
|
|
mOrient = NS_STYLE_ORIENT_INLINE;
|
2013-08-07 11:59:10 +04:00
|
|
|
mMixBlendMode = NS_STYLE_BLEND_NORMAL;
|
2014-10-15 16:13:00 +04:00
|
|
|
mIsolation = NS_STYLE_ISOLATION_AUTO;
|
2014-01-15 19:03:15 +04:00
|
|
|
mTouchAction = NS_STYLE_TOUCH_ACTION_AUTO;
|
2015-10-07 06:04:32 +03:00
|
|
|
mTopLayer = NS_STYLE_TOP_LAYER_NONE;
|
2014-09-15 23:29:58 +04:00
|
|
|
mScrollBehavior = NS_STYLE_SCROLL_BEHAVIOR_AUTO;
|
2014-02-04 05:54:22 +04:00
|
|
|
mScrollSnapTypeX = NS_STYLE_SCROLL_SNAP_TYPE_NONE;
|
|
|
|
mScrollSnapTypeY = NS_STYLE_SCROLL_SNAP_TYPE_NONE;
|
|
|
|
mScrollSnapPointsX.SetNoneValue();
|
|
|
|
mScrollSnapPointsY.SetNoneValue();
|
|
|
|
// Initial value for mScrollSnapDestination is "0px 0px"
|
|
|
|
mScrollSnapDestination.SetInitialZeroValues();
|
2011-04-12 10:18:42 +04:00
|
|
|
|
2009-08-21 01:52:47 +04:00
|
|
|
mTransitions.AppendElement();
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mTransitions.Length() == 1,
|
|
|
|
"appending within auto buffer should never fail");
|
2009-08-21 01:52:47 +04:00
|
|
|
mTransitions[0].SetInitialValues();
|
|
|
|
mTransitionTimingFunctionCount = 1;
|
|
|
|
mTransitionDurationCount = 1;
|
|
|
|
mTransitionDelayCount = 1;
|
|
|
|
mTransitionPropertyCount = 1;
|
2011-04-12 10:18:42 +04:00
|
|
|
|
|
|
|
mAnimations.AppendElement();
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mAnimations.Length() == 1,
|
|
|
|
"appending within auto buffer should never fail");
|
2011-04-12 10:18:42 +04:00
|
|
|
mAnimations[0].SetInitialValues();
|
|
|
|
mAnimationTimingFunctionCount = 1;
|
|
|
|
mAnimationDurationCount = 1;
|
|
|
|
mAnimationDelayCount = 1;
|
|
|
|
mAnimationNameCount = 1;
|
|
|
|
mAnimationDirectionCount = 1;
|
|
|
|
mAnimationFillModeCount = 1;
|
|
|
|
mAnimationPlayStateCount = 1;
|
|
|
|
mAnimationIterationCountCount = 1;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
2012-07-07 03:31:54 +04:00
|
|
|
: mBinding(aSource.mBinding)
|
2015-03-20 07:12:17 +03:00
|
|
|
, mClip(aSource.mClip)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mOpacity(aSource.mOpacity)
|
|
|
|
, mDisplay(aSource.mDisplay)
|
|
|
|
, mOriginalDisplay(aSource.mOriginalDisplay)
|
2015-06-04 17:38:00 +03:00
|
|
|
, mContain(aSource.mContain)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mAppearance(aSource.mAppearance)
|
|
|
|
, mPosition(aSource.mPosition)
|
|
|
|
, mFloats(aSource.mFloats)
|
|
|
|
, mOriginalFloats(aSource.mOriginalFloats)
|
|
|
|
, mBreakType(aSource.mBreakType)
|
2012-11-08 20:09:37 +04:00
|
|
|
, mBreakInside(aSource.mBreakInside)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mBreakBefore(aSource.mBreakBefore)
|
|
|
|
, mBreakAfter(aSource.mBreakAfter)
|
|
|
|
, mOverflowX(aSource.mOverflowX)
|
|
|
|
, mOverflowY(aSource.mOverflowY)
|
2014-02-22 05:18:23 +04:00
|
|
|
, mOverflowClipBox(aSource.mOverflowClipBox)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mResize(aSource.mResize)
|
2015-03-20 07:12:17 +03:00
|
|
|
, mClipFlags(aSource.mClipFlags)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mOrient(aSource.mOrient)
|
2013-08-07 11:59:10 +04:00
|
|
|
, mMixBlendMode(aSource.mMixBlendMode)
|
2014-10-15 16:13:00 +04:00
|
|
|
, mIsolation(aSource.mIsolation)
|
2015-10-07 06:04:32 +03:00
|
|
|
, mTopLayer(aSource.mTopLayer)
|
2015-03-20 07:12:17 +03:00
|
|
|
, mWillChangeBitField(aSource.mWillChangeBitField)
|
|
|
|
, mWillChange(aSource.mWillChange)
|
2014-01-15 19:03:15 +04:00
|
|
|
, mTouchAction(aSource.mTouchAction)
|
2014-09-15 23:29:58 +04:00
|
|
|
, mScrollBehavior(aSource.mScrollBehavior)
|
2014-02-04 05:54:22 +04:00
|
|
|
, mScrollSnapTypeX(aSource.mScrollSnapTypeX)
|
|
|
|
, mScrollSnapTypeY(aSource.mScrollSnapTypeY)
|
|
|
|
, mScrollSnapPointsX(aSource.mScrollSnapPointsX)
|
|
|
|
, mScrollSnapPointsY(aSource.mScrollSnapPointsY)
|
|
|
|
, mScrollSnapDestination(aSource.mScrollSnapDestination)
|
|
|
|
, mScrollSnapCoordinate(aSource.mScrollSnapCoordinate)
|
2015-03-20 07:12:17 +03:00
|
|
|
, mBackfaceVisibility(aSource.mBackfaceVisibility)
|
|
|
|
, mTransformStyle(aSource.mTransformStyle)
|
2015-05-16 00:43:25 +03:00
|
|
|
, mTransformBox(aSource.mTransformBox)
|
2015-03-20 07:12:17 +03:00
|
|
|
, mSpecifiedTransform(aSource.mSpecifiedTransform)
|
|
|
|
, mChildPerspective(aSource.mChildPerspective)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mTransitions(aSource.mTransitions)
|
2009-08-21 01:52:47 +04:00
|
|
|
, mTransitionTimingFunctionCount(aSource.mTransitionTimingFunctionCount)
|
|
|
|
, mTransitionDurationCount(aSource.mTransitionDurationCount)
|
|
|
|
, mTransitionDelayCount(aSource.mTransitionDelayCount)
|
|
|
|
, mTransitionPropertyCount(aSource.mTransitionPropertyCount)
|
2011-04-12 10:18:42 +04:00
|
|
|
, mAnimations(aSource.mAnimations)
|
|
|
|
, mAnimationTimingFunctionCount(aSource.mAnimationTimingFunctionCount)
|
|
|
|
, mAnimationDurationCount(aSource.mAnimationDurationCount)
|
|
|
|
, mAnimationDelayCount(aSource.mAnimationDelayCount)
|
|
|
|
, mAnimationNameCount(aSource.mAnimationNameCount)
|
|
|
|
, mAnimationDirectionCount(aSource.mAnimationDirectionCount)
|
|
|
|
, mAnimationFillModeCount(aSource.mAnimationFillModeCount)
|
|
|
|
, mAnimationPlayStateCount(aSource.mAnimationPlayStateCount)
|
|
|
|
, mAnimationIterationCountCount(aSource.mAnimationIterationCountCount)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleDisplay);
|
2015-03-20 07:12:17 +03:00
|
|
|
|
|
|
|
/* Copy over transform origin. */
|
|
|
|
mTransformOrigin[0] = aSource.mTransformOrigin[0];
|
|
|
|
mTransformOrigin[1] = aSource.mTransformOrigin[1];
|
|
|
|
mTransformOrigin[2] = aSource.mTransformOrigin[2];
|
|
|
|
mPerspectiveOrigin[0] = aSource.mPerspectiveOrigin[0];
|
|
|
|
mPerspectiveOrigin[1] = aSource.mPerspectiveOrigin[1];
|
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)
|
2013-07-18 12:09:16 +04:00
|
|
|
|| mPosition != aOther.mPosition
|
2002-09-30 15:56:37 +04:00
|
|
|
|| mDisplay != aOther.mDisplay
|
2015-06-04 17:38:00 +03:00
|
|
|
|| mContain != aOther.mContain
|
2003-11-15 01:55:46 +03:00
|
|
|
|| (mFloats == NS_STYLE_FLOAT_NONE) != (aOther.mFloats == NS_STYLE_FLOAT_NONE)
|
2011-09-13 23:09:51 +04:00
|
|
|
|| mOverflowX != aOther.mOverflowX
|
|
|
|
|| mOverflowY != aOther.mOverflowY
|
2014-10-28 23:41:00 +03:00
|
|
|
|| mScrollBehavior != aOther.mScrollBehavior
|
2014-02-04 05:54:22 +04:00
|
|
|
|| mScrollSnapTypeX != aOther.mScrollSnapTypeX
|
|
|
|
|| mScrollSnapTypeY != aOther.mScrollSnapTypeY
|
|
|
|
|| mScrollSnapPointsX != aOther.mScrollSnapPointsX
|
|
|
|
|| mScrollSnapPointsY != aOther.mScrollSnapPointsY
|
|
|
|
|| mScrollSnapDestination != aOther.mScrollSnapDestination
|
2015-10-07 06:04:32 +03:00
|
|
|
|| mTopLayer != aOther.mTopLayer
|
2013-07-18 12:09:16 +04:00
|
|
|
|| mResize != aOther.mResize)
|
2002-09-30 15:56:37 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
|
|
|
|
|
2014-02-04 05:54:22 +04:00
|
|
|
/* Note: When mScrollBehavior, mScrollSnapTypeX, mScrollSnapTypeY,
|
|
|
|
* mScrollSnapPointsX, mScrollSnapPointsY, or mScrollSnapDestination are
|
|
|
|
* changed, nsChangeHint_NeutralChange is not sufficient to enter
|
|
|
|
* nsCSSFrameConstructor::PropagateScrollToViewport. By using the same hint
|
|
|
|
* as used when the overflow css property changes,
|
2014-10-28 23:41:00 +03:00
|
|
|
* nsChangeHint_ReconstructFrame, PropagateScrollToViewport will be called.
|
|
|
|
*
|
|
|
|
* The scroll-behavior css property is not expected to change often (the
|
|
|
|
* CSSOM-View DOM methods are likely to be used in those cases); however,
|
|
|
|
* if this does become common perhaps a faster-path might be worth while.
|
|
|
|
*/
|
|
|
|
|
2013-12-09 03:26:07 +04:00
|
|
|
if ((mAppearance == NS_THEME_TEXTFIELD &&
|
|
|
|
aOther.mAppearance != NS_THEME_TEXTFIELD) ||
|
|
|
|
(mAppearance != NS_THEME_TEXTFIELD &&
|
|
|
|
aOther.mAppearance == NS_THEME_TEXTFIELD)) {
|
|
|
|
// This is for <input type=number> where we allow authors to specify a
|
|
|
|
// |-moz-appearance:textfield| to get a control without a spinner. (The
|
|
|
|
// spinner is present for |-moz-appearance:number-input| but also other
|
|
|
|
// values such as 'none'.) We need to reframe since we want to use
|
|
|
|
// nsTextControlFrame instead of nsNumberControlFrame if the author
|
|
|
|
// specifies 'textfield'.
|
|
|
|
return nsChangeHint_ReconstructFrame;
|
|
|
|
}
|
|
|
|
|
2009-08-04 05:22:13 +04:00
|
|
|
if (mFloats != aOther.mFloats) {
|
|
|
|
// Changing which side we float on doesn't affect descendants directly
|
|
|
|
NS_UpdateHint(hint,
|
2012-09-08 02:57:06 +04:00
|
|
|
NS_SubtractHint(nsChangeHint_AllReflowHints,
|
2009-08-04 05:22:13 +04:00
|
|
|
NS_CombineHint(nsChangeHint_ClearDescendantIntrinsics,
|
|
|
|
nsChangeHint_NeedDirtyReflow)));
|
|
|
|
}
|
2003-11-15 01:55:46 +03:00
|
|
|
|
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
|
2012-11-08 20:09:37 +04:00
|
|
|
|| mBreakInside != aOther.mBreakInside
|
2002-09-30 15:56:37 +04:00
|
|
|
|| mBreakBefore != aOther.mBreakBefore
|
|
|
|
|| mBreakAfter != aOther.mBreakAfter
|
2010-09-02 22:07:37 +04:00
|
|
|
|| mAppearance != aOther.mAppearance
|
2011-05-10 17:47:46 +04:00
|
|
|
|| mOrient != aOther.mOrient
|
2015-03-20 07:12:17 +03:00
|
|
|
|| mOverflowClipBox != aOther.mOverflowClipBox
|
|
|
|
|| mClipFlags != aOther.mClipFlags)
|
2012-09-08 02:57:06 +04:00
|
|
|
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_AllReflowHints,
|
|
|
|
nsChangeHint_RepaintFrame));
|
2002-09-30 15:56:37 +04:00
|
|
|
|
2015-03-20 07:12:17 +03:00
|
|
|
if (!mClip.IsEqualInterior(aOther.mClip)) {
|
|
|
|
// If the clip has changed, we just need to update overflow areas. DLBI
|
|
|
|
// will handle the invalidation.
|
|
|
|
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_UpdateOverflow,
|
|
|
|
nsChangeHint_SchedulePaint));
|
|
|
|
}
|
|
|
|
|
2010-07-16 01:07:53 +04:00
|
|
|
if (mOpacity != aOther.mOpacity) {
|
2014-03-14 03:14:35 +04:00
|
|
|
// If we're going from the optimized >=0.99 opacity value to 1.0 or back, then
|
|
|
|
// repaint the frame because DLBI will not catch the invalidation. Otherwise,
|
|
|
|
// just update the opacity layer.
|
|
|
|
if ((mOpacity >= 0.99f && mOpacity < 1.0f && aOther.mOpacity == 1.0f) ||
|
|
|
|
(aOther.mOpacity >= 0.99f && aOther.mOpacity < 1.0f && mOpacity == 1.0f)) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
} else {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateOpacityLayer);
|
|
|
|
}
|
2010-07-16 01:07:53 +04:00
|
|
|
}
|
2002-09-30 15:56:37 +04:00
|
|
|
|
2014-10-15 16:13:00 +04:00
|
|
|
if (mMixBlendMode != aOther.mMixBlendMode
|
|
|
|
|| mIsolation != aOther.mIsolation) {
|
2014-09-24 17:48:00 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
}
|
|
|
|
|
2015-03-20 07:12:17 +03: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 (HasTransformStyle() != aOther.HasTransformStyle()) {
|
|
|
|
// We do not need to apply nsChangeHint_UpdateTransformLayer since
|
|
|
|
// nsChangeHint_RepaintFrame will forcibly invalidate the frame area and
|
|
|
|
// ensure layers are rebuilt (or removed).
|
2015-08-04 06:18:00 +03:00
|
|
|
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_UpdateContainingBlock,
|
2015-03-20 07:12:17 +03:00
|
|
|
NS_CombineHint(nsChangeHint_UpdateOverflow,
|
|
|
|
nsChangeHint_RepaintFrame)));
|
|
|
|
} else {
|
|
|
|
/* 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 recompute its overflow rect (which probably changed
|
|
|
|
* if the transform changed) and to redraw within the bounds of that new
|
|
|
|
* overflow rect.
|
|
|
|
*
|
|
|
|
* If the property isn't present in either style struct, we still do the
|
|
|
|
* comparisons but turn all the resulting change hints into
|
|
|
|
* nsChangeHint_NeutralChange.
|
|
|
|
*/
|
|
|
|
nsChangeHint transformHint = nsChangeHint(0);
|
|
|
|
|
|
|
|
if (!mSpecifiedTransform != !aOther.mSpecifiedTransform ||
|
|
|
|
(mSpecifiedTransform &&
|
|
|
|
*mSpecifiedTransform != *aOther.mSpecifiedTransform)) {
|
|
|
|
NS_UpdateHint(transformHint, nsChangeHint_UpdateTransformLayer);
|
|
|
|
|
|
|
|
if (mSpecifiedTransform &&
|
|
|
|
aOther.mSpecifiedTransform) {
|
|
|
|
NS_UpdateHint(transformHint, nsChangeHint_UpdatePostTransformOverflow);
|
|
|
|
} else {
|
|
|
|
NS_UpdateHint(transformHint, nsChangeHint_UpdateOverflow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsChangeHint kUpdateOverflowAndRepaintHint =
|
|
|
|
NS_CombineHint(nsChangeHint_UpdateOverflow, nsChangeHint_RepaintFrame);
|
|
|
|
for (uint8_t index = 0; index < 3; ++index)
|
|
|
|
if (mTransformOrigin[index] != aOther.mTransformOrigin[index]) {
|
2015-07-02 20:47:05 +03:00
|
|
|
NS_UpdateHint(transformHint, NS_CombineHint(nsChangeHint_UpdateTransformLayer,
|
|
|
|
nsChangeHint_UpdatePostTransformOverflow));
|
2015-03-20 07:12:17 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint8_t index = 0; index < 2; ++index)
|
|
|
|
if (mPerspectiveOrigin[index] != aOther.mPerspectiveOrigin[index]) {
|
|
|
|
NS_UpdateHint(transformHint, kUpdateOverflowAndRepaintHint);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-08-05 00:29:16 +03:00
|
|
|
if (HasPerspectiveStyle() != aOther.HasPerspectiveStyle()) {
|
|
|
|
// A change from/to being a containing block for position:fixed.
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateContainingBlock);
|
|
|
|
}
|
|
|
|
|
2015-03-20 07:12:17 +03:00
|
|
|
if (mChildPerspective != aOther.mChildPerspective ||
|
2015-05-16 00:43:25 +03:00
|
|
|
mTransformStyle != aOther.mTransformStyle ||
|
|
|
|
mTransformBox != aOther.mTransformBox)
|
2015-03-20 07:12:17 +03:00
|
|
|
NS_UpdateHint(transformHint, kUpdateOverflowAndRepaintHint);
|
|
|
|
|
|
|
|
if (mBackfaceVisibility != aOther.mBackfaceVisibility)
|
|
|
|
NS_UpdateHint(transformHint, nsChangeHint_RepaintFrame);
|
|
|
|
|
|
|
|
if (transformHint) {
|
|
|
|
if (HasTransformStyle()) {
|
|
|
|
NS_UpdateHint(hint, transformHint);
|
|
|
|
} else {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeutralChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note that the HasTransformStyle() != aOther.HasTransformStyle()
|
|
|
|
// test above handles relevant changes in the
|
|
|
|
// NS_STYLE_WILL_CHANGE_TRANSFORM bit, which in turn handles frame
|
|
|
|
// reconstruction for changes in the containing block of
|
|
|
|
// fixed-positioned elements. Other than that, all changes to
|
|
|
|
// 'will-change' can be handled by a repaint.
|
|
|
|
uint8_t willChangeBitsChanged =
|
|
|
|
mWillChangeBitField ^ aOther.mWillChangeBitField;
|
|
|
|
if (willChangeBitsChanged) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
|
|
|
}
|
|
|
|
|
2009-12-11 19:13:19 +03:00
|
|
|
// Note: Our current behavior for handling changes to the
|
|
|
|
// transition-duration, transition-delay, and transition-timing-function
|
2009-10-08 07:22:42 +04:00
|
|
|
// properties is to do nothing. In other words, the transition
|
|
|
|
// property that matters is what it is when the transition begins, and
|
|
|
|
// we don't stop a transition later because the transition property
|
|
|
|
// changed.
|
2009-12-11 19:13:19 +03:00
|
|
|
// We do handle changes to transition-property, but we don't need to
|
|
|
|
// bother with anything here, since the transition manager is notified
|
|
|
|
// of any style context change anyway.
|
2011-04-12 10:18:42 +04:00
|
|
|
|
|
|
|
// Note: Likewise, for animation-*, the animation manager gets
|
|
|
|
// notified about every new style context constructed, and it uses
|
|
|
|
// that opportunity to handle dynamic changes appropriately.
|
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
// But we still need to return nsChangeHint_NeutralChange for these
|
|
|
|
// properties, since some data did change in the style struct.
|
|
|
|
|
|
|
|
if (!hint &&
|
2015-03-20 07:12:17 +03:00
|
|
|
(!mClip.IsEqualEdges(aOther.mClip) ||
|
|
|
|
mOriginalDisplay != aOther.mOriginalDisplay ||
|
2014-09-05 07:48:43 +04:00
|
|
|
mOriginalFloats != aOther.mOriginalFloats ||
|
|
|
|
mTransitions != aOther.mTransitions ||
|
|
|
|
mTransitionTimingFunctionCount !=
|
|
|
|
aOther.mTransitionTimingFunctionCount ||
|
|
|
|
mTransitionDurationCount != aOther.mTransitionDurationCount ||
|
|
|
|
mTransitionDelayCount != aOther.mTransitionDelayCount ||
|
|
|
|
mTransitionPropertyCount != aOther.mTransitionPropertyCount ||
|
|
|
|
mAnimations != aOther.mAnimations ||
|
|
|
|
mAnimationTimingFunctionCount != aOther.mAnimationTimingFunctionCount ||
|
|
|
|
mAnimationDurationCount != aOther.mAnimationDurationCount ||
|
|
|
|
mAnimationDelayCount != aOther.mAnimationDelayCount ||
|
|
|
|
mAnimationNameCount != aOther.mAnimationNameCount ||
|
|
|
|
mAnimationDirectionCount != aOther.mAnimationDirectionCount ||
|
|
|
|
mAnimationFillModeCount != aOther.mAnimationFillModeCount ||
|
|
|
|
mAnimationPlayStateCount != aOther.mAnimationPlayStateCount ||
|
2014-02-04 05:54:22 +04:00
|
|
|
mAnimationIterationCountCount != aOther.mAnimationIterationCountCount ||
|
|
|
|
mScrollSnapCoordinate != aOther.mScrollSnapCoordinate)) {
|
2014-09-05 07:48:43 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeutralChange);
|
|
|
|
}
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
return hint;
|
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
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleVisibility);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t 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;
|
|
|
|
|
|
|
|
mVisible = NS_STYLE_VISIBILITY_VISIBLE;
|
2009-08-27 07:53:35 +04:00
|
|
|
mPointerEvents = NS_STYLE_POINTER_EVENTS_AUTO;
|
2013-05-28 20:00:49 +04:00
|
|
|
mWritingMode = NS_STYLE_WRITING_MODE_HORIZONTAL_TB;
|
2014-12-11 21:56:19 +03:00
|
|
|
mTextOrientation = NS_STYLE_TEXT_ORIENTATION_MIXED;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleVisibility);
|
2013-08-29 02:39:06 +04:00
|
|
|
mImageOrientation = aSource.mImageOrientation;
|
2001-06-01 02:19:43 +04:00
|
|
|
mDirection = aSource.mDirection;
|
|
|
|
mVisible = aSource.mVisible;
|
2009-08-27 07:53:35 +04:00
|
|
|
mPointerEvents = aSource.mPointerEvents;
|
2013-05-28 20:00:49 +04:00
|
|
|
mWritingMode = aSource.mWritingMode;
|
2014-12-11 21:56:19 +03:00
|
|
|
mTextOrientation = aSource.mTextOrientation;
|
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
|
|
|
{
|
2010-12-11 03:25:25 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2013-05-28 20:00:49 +04:00
|
|
|
if (mDirection != aOther.mDirection || mWritingMode != aOther.mWritingMode) {
|
2015-08-12 13:02:02 +03:00
|
|
|
// It's important that a change in mWritingMode results in frame
|
|
|
|
// reconstruction, because it may affect intrinsic size (see
|
|
|
|
// nsSubDocumentFrame::GetIntrinsicISize/BSize).
|
2010-12-11 03:25:25 +03:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_ReconstructFrame);
|
2013-05-24 21:31:33 +04:00
|
|
|
} else {
|
2013-08-29 02:39:06 +04:00
|
|
|
if ((mImageOrientation != aOther.mImageOrientation)) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_AllReflowHints);
|
2014-06-28 07:50:26 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
|
2013-08-29 02:39:06 +04:00
|
|
|
}
|
2013-05-24 21:31:33 +04:00
|
|
|
if (mVisible != aOther.mVisible) {
|
|
|
|
if ((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||
|
|
|
|
(NS_STYLE_VISIBILITY_COLLAPSE == aOther.mVisible)) {
|
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_REFLOW);
|
|
|
|
} else {
|
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_VISUAL);
|
|
|
|
}
|
|
|
|
}
|
2014-12-11 21:56:19 +03:00
|
|
|
if (mTextOrientation != aOther.mTextOrientation) {
|
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_REFLOW);
|
|
|
|
}
|
2013-05-24 21:31:33 +04:00
|
|
|
if (mPointerEvents != aOther.mPointerEvents) {
|
|
|
|
// nsSVGPathGeometryFrame's mRect depends on stroke _and_ on the value
|
|
|
|
// of pointer-events. See nsSVGPathGeometryFrame::ReflowSVG's use of
|
|
|
|
// GetHitTestFlags. (Only a reflow, no visual change.)
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedReflow);
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeedDirtyReflow); // XXX remove me: bug 876085
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
2010-12-11 03:25:25 +03:00
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2004-07-15 02:19:22 +04:00
|
|
|
nsStyleContentData::~nsStyleContentData()
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mImageTracked,
|
|
|
|
"nsStyleContentData being destroyed while still tracking image!");
|
2004-07-15 02:19:22 +04:00
|
|
|
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) {
|
2015-04-01 08:29:55 +03:00
|
|
|
free(mContent.mString);
|
2004-07-15 02:19:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContentData& nsStyleContentData::operator=(const nsStyleContentData& aOther)
|
|
|
|
{
|
2005-04-02 03:07:00 +04:00
|
|
|
if (this == &aOther)
|
|
|
|
return *this;
|
|
|
|
this->~nsStyleContentData();
|
2007-10-19 19:36:15 +04:00
|
|
|
new (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) {
|
2006-11-17 04:49:06 +03:00
|
|
|
mContent.mString = NS_strdup(aOther.mContent.mString);
|
2004-07-15 02:19:22 +04:00
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
mContent.mString = nullptr;
|
2004-07-15 02:19:22 +04:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsStyleContentData::operator==(const nsStyleContentData& aOther) const
|
2004-07-15 02:19:22 +04:00
|
|
|
{
|
|
|
|
if (mType != aOther.mType)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2004-07-15 02:19:22 +04:00
|
|
|
if (mType == eStyleContentType_Image) {
|
2005-09-20 06:02:21 +04:00
|
|
|
if (!mContent.mImage || !aOther.mContent.mImage)
|
|
|
|
return mContent.mImage == aOther.mContent.mImage;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool eq;
|
2004-07-15 02:19:22 +04:00
|
|
|
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;
|
2011-06-21 09:03:59 +04:00
|
|
|
return safe_strcmp(mContent.mString, aOther.mContent.mString) == 0;
|
2004-07-15 02:19:22 +04:00
|
|
|
}
|
|
|
|
|
2010-08-06 21:27:01 +04:00
|
|
|
void
|
|
|
|
nsStyleContentData::TrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!mImageTracked, "Already tracking image!");
|
|
|
|
MOZ_ASSERT(mType == eStyleContentType_Image,
|
|
|
|
"Trying to do image tracking on non-image!");
|
|
|
|
MOZ_ASSERT(mContent.mImage,
|
|
|
|
"Can't track image when there isn't one!");
|
2010-08-06 21:27:01 +04:00
|
|
|
|
|
|
|
// Register the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
|
|
|
if (doc)
|
|
|
|
doc->AddImage(mContent.mImage);
|
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleContentData::UntrackImage(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Sanity
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mImageTracked, "Image not tracked!");
|
|
|
|
MOZ_ASSERT(mType == eStyleContentType_Image,
|
|
|
|
"Trying to do image tracking on non-image!");
|
|
|
|
MOZ_ASSERT(mContent.mImage,
|
|
|
|
"Can't untrack image when there isn't one!");
|
2010-08-06 21:27:01 +04:00
|
|
|
|
|
|
|
// Unregister the image with the document
|
|
|
|
nsIDocument* doc = aContext->Document();
|
|
|
|
if (doc)
|
2012-10-01 21:53:57 +04:00
|
|
|
doc->RemoveImage(mContent.mImage, nsIDocument::REQUEST_DISCARD);
|
2010-08-06 21:27:01 +04:00
|
|
|
|
|
|
|
// Mark state
|
|
|
|
#ifdef DEBUG
|
|
|
|
mImageTracked = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleContent
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleContent::nsStyleContent(void)
|
|
|
|
: mMarkerOffset(),
|
2012-07-30 18:20:58 +04:00
|
|
|
mContents(nullptr),
|
|
|
|
mIncrements(nullptr),
|
|
|
|
mResets(nullptr),
|
2009-05-13 12:26:48 +04:00
|
|
|
mContentCount(0),
|
|
|
|
mIncrementCount(0),
|
|
|
|
mResetCount(0)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleContent);
|
2007-05-11 09:58:34 +04:00
|
|
|
mMarkerOffset.SetAutoValue();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContent::~nsStyleContent(void)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleContent);
|
2001-06-01 02:19:43 +04:00
|
|
|
DELETE_ARRAY_IF(mContents);
|
|
|
|
DELETE_ARRAY_IF(mIncrements);
|
|
|
|
DELETE_ARRAY_IF(mResets);
|
|
|
|
}
|
|
|
|
|
2010-08-06 21:27:01 +04:00
|
|
|
void
|
|
|
|
nsStyleContent::Destroy(nsPresContext* aContext)
|
|
|
|
{
|
|
|
|
// Unregister any images we might have with the document.
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mContentCount; ++i) {
|
2010-08-06 21:27:01 +04:00
|
|
|
if ((mContents[i].mType == eStyleContentType_Image) &&
|
|
|
|
mContents[i].mContent.mImage) {
|
|
|
|
mContents[i].UntrackImage(aContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this->~nsStyleContent();
|
2014-07-16 09:27:13 +04:00
|
|
|
aContext->PresShell()->
|
2015-09-17 05:08:19 +03:00
|
|
|
FreeByObjectID(eArenaObjectID_nsStyleContent, this);
|
2010-08-06 21:27:01 +04:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleContent::nsStyleContent(const nsStyleContent& aSource)
|
|
|
|
:mMarkerOffset(),
|
2012-07-30 18:20:58 +04:00
|
|
|
mContents(nullptr),
|
|
|
|
mIncrements(nullptr),
|
|
|
|
mResets(nullptr),
|
2009-05-13 12:26:48 +04:00
|
|
|
mContentCount(0),
|
|
|
|
mIncrementCount(0),
|
|
|
|
mResetCount(0)
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleContent);
|
2001-06-01 02:19:43 +04:00
|
|
|
mMarkerOffset = aSource.mMarkerOffset;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t index;
|
2001-06-01 02:19:43 +04:00
|
|
|
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
|
|
|
{
|
2010-06-18 20:23:05 +04:00
|
|
|
// In ReResolveStyleContext we assume that if there's no existing
|
|
|
|
// ::before or ::after and we don't have to restyle children of the
|
|
|
|
// node then we can't end up with a ::before or ::after due to the
|
|
|
|
// restyle of the node itself. That's not quite true, but the only
|
|
|
|
// exception to the above is when the 'content' property of the node
|
|
|
|
// changes and the pseudo-element inherits the changed value. Since
|
|
|
|
// the code here triggers a frame change on the node in that case,
|
|
|
|
// the optimization in ReResolveStyleContext is ok. But if we ever
|
|
|
|
// change this code to not reconstruct frames on changes to the
|
|
|
|
// 'content' property, then we will need to revisit the optimization
|
|
|
|
// in ReResolveStyleContext.
|
|
|
|
|
2005-04-02 03:07:00 +04:00
|
|
|
if (mContentCount != aOther.mContentCount ||
|
|
|
|
mIncrementCount != aOther.mIncrementCount ||
|
|
|
|
mResetCount != aOther.mResetCount) {
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t ix = mContentCount;
|
2005-04-02 03:07:00 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult nsStyleContent::AllocateContents(uint32_t aCount)
|
2004-07-15 03:51:25 +04:00
|
|
|
{
|
2007-09-27 20:27:48 +04: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-15 03:51:25 +04:00
|
|
|
}
|
|
|
|
}
|
2007-09-27 20:27:48 +04:00
|
|
|
mContentCount = aCount;
|
2004-07-15 03:51:25 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// ---------------------
|
|
|
|
// nsStyleQuotes
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleQuotes::nsStyleQuotes(void)
|
|
|
|
: mQuotesCount(0),
|
2012-07-30 18:20:58 +04:00
|
|
|
mQuotes(nullptr)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleQuotes);
|
2008-08-19 18:18:58 +04:00
|
|
|
SetInitial();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleQuotes::~nsStyleQuotes(void)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleQuotes);
|
2001-06-01 02:19:43 +04:00
|
|
|
DELETE_ARRAY_IF(mQuotes);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleQuotes::nsStyleQuotes(const nsStyleQuotes& aSource)
|
2002-10-13 22:55:12 +04:00
|
|
|
: mQuotesCount(0),
|
2012-07-30 18:20:58 +04:00
|
|
|
mQuotes(nullptr)
|
2008-08-19 18:18:58 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleQuotes);
|
2008-08-19 18:18:58 +04: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.
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t initialQuotes[8] = {
|
2008-08-19 18:18:58 +04:00
|
|
|
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-06-01 02:19:43 +04:00
|
|
|
{
|
|
|
|
if (NS_SUCCEEDED(AllocateQuotes(aSource.QuotesCount()))) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t count = (mQuotesCount * 2);
|
|
|
|
for (uint32_t index = 0; index < count; index += 2) {
|
2001-06-01 02:19:43 +04:00
|
|
|
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) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t ix = (mQuotesCount * 2);
|
2001-06-01 02:19:43 +04:00
|
|
|
while (0 < ix--) {
|
|
|
|
if (mQuotes[ix] != aOther.mQuotes[ix]) {
|
2002-08-14 16:34:39 +04:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_STYLE_HINT_NONE;
|
|
|
|
}
|
2002-08-14 16:34:39 +04:00
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleTextReset
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleTextReset::nsStyleTextReset(void)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTextReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
mVerticalAlign.SetIntValue(NS_STYLE_VERTICAL_ALIGN_BASELINE, eStyleUnit_Enumerated);
|
2011-04-23 09:16:41 +04:00
|
|
|
mTextDecorationLine = NS_STYLE_TEXT_DECORATION_LINE_NONE;
|
2011-03-31 16:26:35 +04:00
|
|
|
mTextDecorationColor = NS_RGB(0,0,0);
|
|
|
|
mTextDecorationStyle =
|
|
|
|
NS_STYLE_TEXT_DECORATION_STYLE_SOLID | BORDER_COLOR_FOREGROUND;
|
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)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTextReset);
|
2011-06-22 22:11:47 +04:00
|
|
|
*this = aSource;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2009-08-07 18:38:44 +04:00
|
|
|
nsStyleTextReset::~nsStyleTextReset(void)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleTextReset);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2008-03-30 00:25:15 +03:00
|
|
|
if (mVerticalAlign == aOther.mVerticalAlign
|
|
|
|
&& mUnicodeBidi == aOther.mUnicodeBidi) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t lineStyle = GetDecorationStyle();
|
|
|
|
uint8_t otherLineStyle = aOther.GetDecorationStyle();
|
2011-04-23 09:16:41 +04:00
|
|
|
if (mTextDecorationLine != aOther.mTextDecorationLine ||
|
2011-03-31 16:26:35 +04:00
|
|
|
lineStyle != otherLineStyle) {
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
// Changes to our text-decoration line can impact our overflow area &
|
|
|
|
// also our descendants' overflow areas (particularly for text-frame
|
|
|
|
// descendants). So, we update those areas & trigger a repaint.
|
|
|
|
nsChangeHint hint = nsChangeHint_RepaintFrame;
|
2014-06-17 18:32:00 +04:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_UpdateSubtreeOverflow);
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
NS_UpdateHint(hint, nsChangeHint_SchedulePaint);
|
2014-06-17 18:32:00 +04:00
|
|
|
return hint;
|
2011-03-31 16:26:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Repaint for decoration color changes
|
|
|
|
nscolor decColor, otherDecColor;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isFG, otherIsFG;
|
2011-03-31 16:26:35 +04:00
|
|
|
GetDecorationColor(decColor, isFG);
|
|
|
|
aOther.GetDecorationColor(otherDecColor, otherIsFG);
|
|
|
|
if (isFG != otherIsFG || (!isFG && decColor != otherDecColor)) {
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2008-03-30 00:25:15 +03:00
|
|
|
}
|
|
|
|
|
2011-06-22 22:11:47 +04:00
|
|
|
if (mTextOverflow != aOther.mTextOverflow) {
|
Bug 1198894: Use nsChangeHint_RepaintFrame instead of NS_STYLE_HINT_VISUAL to trigger simple repaints in nsStyleStruct.cpp CalcDifference methods. r=heycam
Specifically, this makes us use nsChangeHint_RepaintFrame for changes to font decorations, border-{color,style,radius,image}, color, background-{image,color}, text-decoration-{line,color}, text-overflow
2015-09-22 02:11:51 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2011-06-22 22:11:47 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_NONE;
|
2008-03-30 00:25:15 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2015-10-02 06:05:28 +03:00
|
|
|
// Returns true if the given shadow-arrays are equal.
|
|
|
|
static bool
|
|
|
|
AreShadowArraysEqual(nsCSSShadowArray* lhs,
|
2008-07-08 04:56:52 +04:00
|
|
|
nsCSSShadowArray* rhs)
|
|
|
|
{
|
|
|
|
if (lhs == rhs)
|
2015-10-02 06:05:28 +03:00
|
|
|
return true;
|
2008-07-08 04:56:52 +04:00
|
|
|
|
|
|
|
if (!lhs || !rhs || lhs->Length() != rhs->Length())
|
2015-10-02 06:05:28 +03:00
|
|
|
return false;
|
2008-07-08 04:56:52 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < lhs->Length(); ++i) {
|
2008-07-08 04:56:52 +04:00
|
|
|
if (*lhs->ShadowAt(i) != *rhs->ShadowAt(i))
|
2015-10-02 06:05:28 +03:00
|
|
|
return false;
|
2008-07-08 04:56:52 +04:00
|
|
|
}
|
2015-10-02 06:05:28 +03:00
|
|
|
return true;
|
2008-07-08 04:56:52 +04:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleText
|
|
|
|
//
|
|
|
|
|
2008-06-06 03:06:34 +04:00
|
|
|
nsStyleText::nsStyleText(void)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleText);
|
2001-06-01 02:19:43 +04:00
|
|
|
mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT;
|
2012-01-12 21:52:21 +04:00
|
|
|
mTextAlignLast = NS_STYLE_TEXT_ALIGN_AUTO;
|
2013-10-28 00:56:32 +04:00
|
|
|
mTextAlignTrue = false;
|
|
|
|
mTextAlignLastTrue = false;
|
2001-06-01 02:19:43 +04:00
|
|
|
mTextTransform = NS_STYLE_TEXT_TRANSFORM_NONE;
|
|
|
|
mWhiteSpace = NS_STYLE_WHITESPACE_NORMAL;
|
2012-05-07 23:18:23 +04:00
|
|
|
mWordBreak = NS_STYLE_WORDBREAK_NORMAL;
|
2008-07-24 11:16:18 +04:00
|
|
|
mWordWrap = NS_STYLE_WORDWRAP_NORMAL;
|
2011-05-04 15:14:50 +04:00
|
|
|
mHyphens = NS_STYLE_HYPHENS_MANUAL;
|
2015-02-17 08:01:49 +03:00
|
|
|
mRubyAlign = NS_STYLE_RUBY_ALIGN_SPACE_AROUND;
|
2015-01-22 06:04:55 +03:00
|
|
|
mRubyPosition = NS_STYLE_RUBY_POSITION_OVER;
|
2011-11-24 06:48:23 +04:00
|
|
|
mTextSizeAdjust = NS_STYLE_TEXT_SIZE_ADJUST_AUTO;
|
2014-04-17 04:15:18 +04:00
|
|
|
mTextCombineUpright = NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE;
|
2015-10-01 14:26:52 +03:00
|
|
|
mControlCharacterVisibility = nsCSSParser::ControlCharVisibilityDefault();
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2015-10-22 08:13:11 +03:00
|
|
|
mWordSpacing.SetCoordValue(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
mLetterSpacing.SetNormalValue();
|
|
|
|
mLineHeight.SetNormalValue();
|
|
|
|
mTextIndent.SetCoordValue(0);
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mTextShadow = nullptr;
|
2009-09-27 00:23:47 +04:00
|
|
|
mTabSize = NS_STYLE_TABSIZE_INITIAL;
|
2008-06-04 03:42:13 +04:00
|
|
|
}
|
2008-06-04 02:25:31 +04:00
|
|
|
|
2008-06-06 03:06:34 +04:00
|
|
|
nsStyleText::nsStyleText(const nsStyleText& aSource)
|
|
|
|
: mTextAlign(aSource.mTextAlign),
|
2012-01-12 21:52:21 +04:00
|
|
|
mTextAlignLast(aSource.mTextAlignLast),
|
2013-10-28 00:56:32 +04:00
|
|
|
mTextAlignTrue(false),
|
|
|
|
mTextAlignLastTrue(false),
|
2008-06-06 03:06:34 +04:00
|
|
|
mTextTransform(aSource.mTextTransform),
|
|
|
|
mWhiteSpace(aSource.mWhiteSpace),
|
2012-05-07 23:18:23 +04:00
|
|
|
mWordBreak(aSource.mWordBreak),
|
2008-07-24 11:16:18 +04:00
|
|
|
mWordWrap(aSource.mWordWrap),
|
2011-05-04 15:14:50 +04:00
|
|
|
mHyphens(aSource.mHyphens),
|
2015-02-17 08:01:49 +03:00
|
|
|
mRubyAlign(aSource.mRubyAlign),
|
2014-12-09 09:47:18 +03:00
|
|
|
mRubyPosition(aSource.mRubyPosition),
|
2011-11-24 06:48:23 +04:00
|
|
|
mTextSizeAdjust(aSource.mTextSizeAdjust),
|
2014-04-17 04:15:18 +04:00
|
|
|
mTextCombineUpright(aSource.mTextCombineUpright),
|
2014-02-05 14:08:48 +04:00
|
|
|
mControlCharacterVisibility(aSource.mControlCharacterVisibility),
|
2009-10-15 06:42:03 +04:00
|
|
|
mTabSize(aSource.mTabSize),
|
2012-04-17 23:22:49 +04:00
|
|
|
mWordSpacing(aSource.mWordSpacing),
|
2008-06-06 03:06:34 +04:00
|
|
|
mLetterSpacing(aSource.mLetterSpacing),
|
|
|
|
mLineHeight(aSource.mLineHeight),
|
|
|
|
mTextIndent(aSource.mTextIndent),
|
2009-10-15 06:42:03 +04:00
|
|
|
mTextShadow(aSource.mTextShadow)
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleText);
|
|
|
|
}
|
2008-06-06 03:06:34 +04:00
|
|
|
|
2009-08-07 18:38:44 +04:00
|
|
|
nsStyleText::~nsStyleText(void)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleText);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleText::CalcDifference(const nsStyleText& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2012-09-07 09:42:19 +04:00
|
|
|
if (WhiteSpaceOrNewlineIsSignificant() !=
|
|
|
|
aOther.WhiteSpaceOrNewlineIsSignificant()) {
|
2009-06-13 13:16:34 +04:00
|
|
|
// This may require construction of suppressed text frames
|
|
|
|
return NS_STYLE_HINT_FRAMECHANGE;
|
|
|
|
}
|
|
|
|
|
2014-04-17 04:15:18 +04:00
|
|
|
if (mTextCombineUpright != aOther.mTextCombineUpright ||
|
2014-02-05 14:08:48 +04:00
|
|
|
mControlCharacterVisibility != aOther.mControlCharacterVisibility) {
|
2013-08-19 14:26:44 +04:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
|
|
|
}
|
|
|
|
|
2008-06-06 03:06:34 +04:00
|
|
|
if ((mTextAlign != aOther.mTextAlign) ||
|
2012-01-12 21:52:21 +04:00
|
|
|
(mTextAlignLast != aOther.mTextAlignLast) ||
|
2013-10-28 00:56:32 +04:00
|
|
|
(mTextAlignTrue != aOther.mTextAlignTrue) ||
|
|
|
|
(mTextAlignLastTrue != aOther.mTextAlignLastTrue) ||
|
2008-06-06 03:06:34 +04:00
|
|
|
(mTextTransform != aOther.mTextTransform) ||
|
2009-07-30 07:02:22 +04:00
|
|
|
(mWhiteSpace != aOther.mWhiteSpace) ||
|
2012-05-07 23:18:23 +04:00
|
|
|
(mWordBreak != aOther.mWordBreak) ||
|
2008-07-24 11:16:18 +04:00
|
|
|
(mWordWrap != aOther.mWordWrap) ||
|
2011-05-04 15:14:50 +04:00
|
|
|
(mHyphens != aOther.mHyphens) ||
|
2015-02-17 08:01:49 +03:00
|
|
|
(mRubyAlign != aOther.mRubyAlign) ||
|
2014-12-09 09:47:18 +03:00
|
|
|
(mRubyPosition != aOther.mRubyPosition) ||
|
2011-11-24 06:48:23 +04:00
|
|
|
(mTextSizeAdjust != aOther.mTextSizeAdjust) ||
|
2008-06-06 03:06:34 +04:00
|
|
|
(mLetterSpacing != aOther.mLetterSpacing) ||
|
|
|
|
(mLineHeight != aOther.mLineHeight) ||
|
|
|
|
(mTextIndent != aOther.mTextIndent) ||
|
2009-09-27 00:23:47 +04:00
|
|
|
(mWordSpacing != aOther.mWordSpacing) ||
|
|
|
|
(mTabSize != aOther.mTabSize))
|
2008-06-06 03:06:34 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
|
2015-10-02 06:05:28 +03:00
|
|
|
if (!AreShadowArraysEqual(mTextShadow, aOther.mTextShadow)) {
|
|
|
|
return nsChangeHint_UpdateSubtreeOverflow |
|
|
|
|
nsChangeHint_SchedulePaint |
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// nsStyleUserInterface
|
|
|
|
//
|
|
|
|
|
2005-07-01 08:29:42 +04:00
|
|
|
nsCursorImage::nsCursorImage()
|
2011-10-17 18:59:28 +04:00
|
|
|
: mHaveHotspot(false)
|
2005-07-01 08:29:42 +04:00
|
|
|
, mHotspotX(0.0f)
|
|
|
|
, mHotspotY(0.0f)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-16 20:19:26 +04:00
|
|
|
nsCursorImage::nsCursorImage(const nsCursorImage& aOther)
|
|
|
|
: mHaveHotspot(aOther.mHaveHotspot)
|
|
|
|
, mHotspotX(aOther.mHotspotX)
|
|
|
|
, mHotspotY(aOther.mHotspotY)
|
|
|
|
{
|
|
|
|
SetImage(aOther.GetImage());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCursorImage::~nsCursorImage()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
SetImage(nullptr);
|
2010-08-16 20:19:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCursorImage&
|
|
|
|
nsCursorImage::operator=(const nsCursorImage& aOther)
|
|
|
|
{
|
|
|
|
if (this != &aOther) {
|
|
|
|
mHaveHotspot = aOther.mHaveHotspot;
|
|
|
|
mHotspotX = aOther.mHotspotX;
|
|
|
|
mHotspotY = aOther.mHotspotY;
|
|
|
|
SetImage(aOther.GetImage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleUserInterface::nsStyleUserInterface(void)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUserInterface);
|
2001-06-01 02:19:43 +04:00
|
|
|
mUserInput = NS_STYLE_USER_INPUT_AUTO;
|
|
|
|
mUserModify = NS_STYLE_USER_MODIFY_READ_ONLY;
|
|
|
|
mUserFocus = NS_STYLE_USER_FOCUS_NONE;
|
2014-09-18 12:52:25 +04:00
|
|
|
mWindowDragging = NS_STYLE_WINDOW_DRAGGING_NO_DRAG;
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
mCursor = NS_STYLE_CURSOR_AUTO; // fix for bugzilla bug 51113
|
2005-07-01 08:29:42 +04:00
|
|
|
|
|
|
|
mCursorArrayLength = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
mCursorArray = nullptr;
|
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),
|
2014-09-18 12:52:25 +04:00
|
|
|
mWindowDragging(aSource.mWindowDragging),
|
2005-07-01 08:29:42 +04:00
|
|
|
mCursor(aSource.mCursor)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUserInterface);
|
2005-07-01 08:29:42 +04:00
|
|
|
CopyCursorArrayFrom(aSource);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUserInterface::~nsStyleUserInterface(void)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleUserInterface);
|
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
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
if (mUserInput != aOther.mUserInput) {
|
|
|
|
if (NS_STYLE_USER_INPUT_NONE == mUserInput ||
|
|
|
|
NS_STYLE_USER_INPUT_NONE == aOther.mUserInput) {
|
|
|
|
NS_UpdateHint(hint, NS_STYLE_HINT_FRAMECHANGE);
|
|
|
|
} else {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeutralChange);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
if (mUserFocus != aOther.mUserFocus) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_NeutralChange);
|
|
|
|
}
|
2004-12-28 16:48:25 +03:00
|
|
|
|
2014-09-18 12:52:25 +04:00
|
|
|
if (mWindowDragging != aOther.mWindowDragging) {
|
|
|
|
NS_UpdateHint(hint, nsChangeHint_SchedulePaint);
|
|
|
|
}
|
|
|
|
|
2004-12-28 16:48:25 +03:00
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2005-07-01 08:29:42 +04:00
|
|
|
void
|
|
|
|
nsStyleUserInterface::CopyCursorArrayFrom(const nsStyleUserInterface& aSource)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mCursorArray = nullptr;
|
2005-07-01 08:29:42 +04:00
|
|
|
mCursorArrayLength = 0;
|
|
|
|
if (aSource.mCursorArrayLength) {
|
|
|
|
mCursorArray = new nsCursorImage[aSource.mCursorArrayLength];
|
|
|
|
if (mCursorArray) {
|
|
|
|
mCursorArrayLength = aSource.mCursorArrayLength;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mCursorArrayLength; ++i)
|
2005-07-01 08:29:42 +04:00
|
|
|
mCursorArray[i] = aSource.mCursorArray[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleUIReset
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleUIReset::nsStyleUIReset(void)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUIReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
mUserSelect = NS_STYLE_USER_SELECT_AUTO;
|
2002-03-26 23:14:05 +03:00
|
|
|
mForceBrokenImageIcon = 0;
|
2007-05-16 19:51:37 +04:00
|
|
|
mIMEMode = NS_STYLE_IME_MODE_AUTO;
|
2008-10-14 18:44:25 +04:00
|
|
|
mWindowShadow = NS_STYLE_WINDOW_SHADOW_DEFAULT;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUIReset::nsStyleUIReset(const nsStyleUIReset& aSource)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUIReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
mUserSelect = aSource.mUserSelect;
|
2002-03-26 23:14:05 +03:00
|
|
|
mForceBrokenImageIcon = aSource.mForceBrokenImageIcon;
|
2007-05-16 19:51:37 +04:00
|
|
|
mIMEMode = aSource.mIMEMode;
|
2008-10-14 18:44:25 +04:00
|
|
|
mWindowShadow = aSource.mWindowShadow;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleUIReset::~nsStyleUIReset(void)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleUIReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
nsChangeHint nsStyleUIReset::CalcDifference(const nsStyleUIReset& aOther) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2007-05-16 19:51:37 +04:00
|
|
|
// ignore mIMEMode
|
2008-10-14 18:44:25 +04: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-06-01 02:19:43 +04:00
|
|
|
}
|
2008-10-14 18:44:25 +04:00
|
|
|
if (mUserSelect != aOther.mUserSelect)
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
return NS_STYLE_HINT_NONE;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2013-12-12 06:09:40 +04:00
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// nsStyleVariables
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleVariables::nsStyleVariables()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleVariables);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleVariables::nsStyleVariables(const nsStyleVariables& aSource)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleVariables);
|
2015-05-05 12:57:34 +03:00
|
|
|
mVariables = aSource.mVariables;
|
2013-12-12 06:09:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleVariables::~nsStyleVariables(void)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleVariables);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint
|
|
|
|
nsStyleVariables::CalcDifference(const nsStyleVariables& aOther) const
|
|
|
|
{
|
|
|
|
return nsChangeHint(0);
|
|
|
|
}
|