2016-01-11 02:28:35 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
/*
|
2018-03-22 21:20:41 +03:00
|
|
|
* structs that contain the data provided by ComputedStyle, the
|
2006-03-25 08:47:31 +03:00
|
|
|
* 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"
|
2016-03-31 02:30:39 +03:00
|
|
|
#include "nsIAppShellService.h"
|
2009-04-02 01:59:02 +04:00
|
|
|
#include "nsIWidget.h"
|
2011-06-21 09:03:59 +04:00
|
|
|
#include "nsCRTGlue.h"
|
2009-08-21 01:52:47 +04:00
|
|
|
#include "nsCSSProps.h"
|
2016-07-29 00:51:12 +03:00
|
|
|
#include "nsDeviceContext.h"
|
|
|
|
#include "nsStyleUtil.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
|
|
|
|
2018-05-07 05:15:16 +03:00
|
|
|
#include "mozilla/dom/AnimationEffectBinding.h" // for PlaybackDirection
|
2017-03-14 16:29:55 +03:00
|
|
|
#include "mozilla/dom/DocGroup.h"
|
2016-10-13 10:04:15 +03:00
|
|
|
#include "mozilla/dom/ImageTracker.h"
|
2018-02-01 00:08:01 +03:00
|
|
|
#include "mozilla/CORSMode.h"
|
2017-08-09 04:30:25 +03:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
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>
|
2017-05-02 11:20:01 +03:00
|
|
|
#include "ImageLoader.h"
|
2012-10-26 17:32:10 +04:00
|
|
|
|
2015-03-31 06:05:33 +03:00
|
|
|
using namespace mozilla;
|
2016-12-01 21:37:44 +03:00
|
|
|
using namespace mozilla::dom;
|
2015-03-31 06:05:33 +03:00
|
|
|
|
2016-10-25 09:25:10 +03:00
|
|
|
/* static */ const int32_t nsStyleGridLine::kMinLine;
|
|
|
|
/* static */ const int32_t nsStyleGridLine::kMaxLine;
|
2015-04-30 21:42:50 +03:00
|
|
|
|
2017-08-09 04:47:02 +03:00
|
|
|
// We set the size limit of style structs to 504 bytes so that when they
|
|
|
|
// are allocated by Servo side with Arc, the total size doesn't exceed
|
|
|
|
// 512 bytes, which minimizes allocator slop.
|
|
|
|
static constexpr size_t kStyleStructSizeLimit = 504;
|
2018-03-26 12:09:17 +03:00
|
|
|
#define STYLE_STRUCT(name_) \
|
2017-08-09 04:47:02 +03:00
|
|
|
static_assert(sizeof(nsStyle##name_) <= kStyleStructSizeLimit, \
|
|
|
|
"nsStyle" #name_ " became larger than the size limit");
|
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
#undef STYLE_STRUCT
|
|
|
|
|
2016-10-11 09:56:11 +03:00
|
|
|
static bool
|
2016-10-11 09:56:12 +03:00
|
|
|
DefinitelyEqualURIs(css::URLValueData* aURI1,
|
|
|
|
css::URLValueData* aURI2)
|
2016-10-11 09:56:11 +03:00
|
|
|
{
|
|
|
|
return aURI1 == aURI2 ||
|
|
|
|
(aURI1 && aURI2 && aURI1->DefinitelyEqualURIs(*aURI2));
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
static bool
|
2016-10-11 09:56:12 +03:00
|
|
|
DefinitelyEqualURIsAndPrincipal(css::URLValueData* aURI1,
|
|
|
|
css::URLValueData* aURI2)
|
2007-07-19 01:56:57 +04:00
|
|
|
{
|
2016-09-02 17:22:48 +03:00
|
|
|
return aURI1 == aURI2 ||
|
|
|
|
(aURI1 && aURI2 && aURI1->DefinitelyEqualURIsAndPrincipal(*aURI2));
|
2007-07-19 01:56:57 +04:00
|
|
|
}
|
|
|
|
|
2016-11-02 11:58:31 +03:00
|
|
|
static bool
|
|
|
|
DefinitelyEqualImages(nsStyleImageRequest* aRequest1,
|
|
|
|
nsStyleImageRequest* aRequest2)
|
|
|
|
{
|
|
|
|
if (aRequest1 == aRequest2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aRequest1 || !aRequest2) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRequest1->DefinitelyEquals(*aRequest2);
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +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
|
|
|
|
//
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleFont::nsStyleFont(const nsFont& aFont, const nsPresContext* aContext)
|
2012-08-21 06:23:32 +04:00
|
|
|
: mFont(aFont)
|
2016-03-31 02:30:39 +03:00
|
|
|
, mSize(nsStyleFont::ZoomText(aContext, mFont.size))
|
2017-09-12 23:53:39 +03:00
|
|
|
, mFontSizeFactor(1.0)
|
|
|
|
, mFontSizeOffset(0)
|
|
|
|
, mFontSizeKeyword(NS_STYLE_FONT_SIZE_MEDIUM)
|
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)
|
2016-03-31 22:47:20 +03:00
|
|
|
, mScriptMinSize(nsPresContext::CSSTwipsToAppUnits(
|
2015-10-08 02:19:29 +03:00
|
|
|
NS_POINTS_TO_TWIPS(NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT)))
|
|
|
|
, mScriptSizeMultiplier(NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER)
|
2016-03-31 02:30:39 +03:00
|
|
|
, mLanguage(GetLanguage(aContext))
|
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)
|
2017-09-12 23:53:39 +03:00
|
|
|
, mFontSizeFactor(aSrc.mFontSizeFactor)
|
|
|
|
, mFontSizeOffset(aSrc.mFontSizeOffset)
|
|
|
|
, mFontSizeKeyword(aSrc.mFontSizeKeyword)
|
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
|
|
|
}
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleFont::nsStyleFont(const nsPresContext* aContext)
|
|
|
|
: nsStyleFont(*aContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID,
|
|
|
|
nullptr),
|
2016-03-31 02:30:39 +03:00
|
|
|
aContext)
|
2003-03-13 18:29:36 +03:00
|
|
|
{
|
2017-08-23 13:14:03 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
nscoord minimumFontSize = aContext->MinFontSize(mLanguage);
|
|
|
|
if (minimumFontSize > 0 && !aContext->IsChrome()) {
|
|
|
|
mFont.size = std::max(mSize, minimumFontSize);
|
|
|
|
} else {
|
|
|
|
mFont.size = mSize;
|
|
|
|
}
|
2003-03-13 18:29:36 +03: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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleFont::CalcDifference(const nsStyleFont& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-06-21 04:47:54 +03:00
|
|
|
MOZ_ASSERT(mAllowZoom == aNewData.mAllowZoom,
|
2013-06-29 07:28:50 +04:00
|
|
|
"expected mAllowZoom to be the same on both nsStyleFonts");
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mSize != aNewData.mSize ||
|
|
|
|
mLanguage != aNewData.mLanguage ||
|
|
|
|
mExplicitLanguage != aNewData.mExplicitLanguage ||
|
|
|
|
mMathVariant != aNewData.mMathVariant ||
|
|
|
|
mMathDisplay != aNewData.mMathDisplay ||
|
|
|
|
mMinFontSizeRatio != aNewData.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
|
|
|
|
2017-11-08 07:01:29 +03:00
|
|
|
switch (mFont.CalcDifference(aNewData.mFont)) {
|
|
|
|
case nsFont::MaxDifference::eLayoutAffecting:
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
|
|
|
|
case nsFont::MaxDifference::eVisual:
|
|
|
|
return NS_STYLE_HINT_VISUAL;
|
|
|
|
|
|
|
|
case nsFont::MaxDifference::eNone:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
// XXX Should any of these cause a non-nsChangeHint_NeutralChange change?
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mGenericID != aNewData.mGenericID ||
|
|
|
|
mScriptLevel != aNewData.mScriptLevel ||
|
|
|
|
mScriptUnconstrainedSize != aNewData.mScriptUnconstrainedSize ||
|
|
|
|
mScriptMinSize != aNewData.mScriptMinSize ||
|
|
|
|
mScriptSizeMultiplier != aNewData.mScriptSizeMultiplier) {
|
2014-09-05 07:48:43 +04:00
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2003-03-13 18:29:36 +03:00
|
|
|
/* static */ nscoord
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleFont::ZoomText(const 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.
|
2017-02-25 15:22:52 +03:00
|
|
|
return NSToCoordTruncClamped(float(aSize) * aPresContext->EffectiveTextZoom());
|
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.
|
2017-02-25 15:22:52 +03:00
|
|
|
return NSToCoordTruncClamped(float(aSize) / aPresContext->EffectiveTextZoom());
|
2003-03-13 18:29:36 +03:00
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
/* static */ already_AddRefed<nsAtom>
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleFont::GetLanguage(const nsPresContext* aPresContext)
|
2015-10-08 02:19:29 +03:00
|
|
|
{
|
2017-10-03 01:05:19 +03:00
|
|
|
RefPtr<nsAtom> language = aPresContext->GetContentLanguage();
|
2015-11-28 03:56:33 +03:00
|
|
|
if (!language) {
|
2015-10-08 02:19:29 +03:00
|
|
|
// we didn't find a (usable) Content-Language, so we fall back
|
|
|
|
// to whatever the presContext guessed from the charset
|
2015-11-28 03:56:33 +03:00
|
|
|
// NOTE this should not be used elsewhere, because we want websites
|
|
|
|
// to use UTF-8 with proper language tag, instead of relying on
|
|
|
|
// deriving language from charset. See bug 1040668 comment 67.
|
2017-01-04 22:52:27 +03:00
|
|
|
language = aPresContext->GetLanguageFromCharset();
|
2015-10-08 02:19:29 +03:00
|
|
|
}
|
2015-11-28 03:56:33 +03:00
|
|
|
return language.forget();
|
2015-10-08 02:19:29 +03:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleMargin::nsStyleMargin(const nsPresContext* aContext)
|
2014-07-16 09:27:12 +04:00
|
|
|
{
|
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)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleMargin);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleMargin::CalcDifference(const nsStyleMargin& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mMargin == aNewData.mMargin) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStylePadding::nsStylePadding(const nsPresContext* aContext)
|
2014-07-16 09:27:12 +04:00
|
|
|
{
|
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)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStylePadding);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStylePadding::CalcDifference(const nsStylePadding& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mPadding == aNewData.mPadding) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
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.
|
2016-10-13 21:41:52 +03:00
|
|
|
// FIXME: It would be good to return a weaker hint here that doesn't
|
|
|
|
// force reflow of all descendants, but the hint would need to force
|
|
|
|
// reflow of the frame's children (see how
|
|
|
|
// ReflowInput::InitResizeFlags initializes the inline-resize flag).
|
2016-05-23 06:26:03 +03:00
|
|
|
return NS_STYLE_HINT_REFLOW & ~nsChangeHint_ClearDescendantIntrinsics;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleBorder::nsStyleBorder(const nsPresContext* aContext)
|
2017-09-18 06:38:39 +03:00
|
|
|
: mBorderImageFill(NS_STYLE_BORDER_IMAGE_SLICE_NOFILL)
|
2017-12-21 08:16:40 +03:00
|
|
|
, mBorderImageRepeatH(StyleBorderImageRepeat::Stretch)
|
|
|
|
, mBorderImageRepeatV(StyleBorderImageRepeat::Stretch)
|
2016-07-25 09:26:05 +03:00
|
|
|
, mFloatEdge(StyleFloatEdge::ContentBox)
|
2016-08-26 10:14:32 +03:00
|
|
|
, mBoxDecorationBreak(StyleBoxDecorationBreak::Slice)
|
2018-06-05 04:24:12 +03:00
|
|
|
, mBorderTopColor(StyleComplexColor::CurrentColor())
|
|
|
|
, mBorderRightColor(StyleComplexColor::CurrentColor())
|
|
|
|
, mBorderBottomColor(StyleComplexColor::CurrentColor())
|
|
|
|
, mBorderLeftColor(StyleComplexColor::CurrentColor())
|
2016-06-03 18:56:54 +03: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 =
|
2016-03-31 22:47:20 +03:00
|
|
|
(StaticPresData::Get()->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM];
|
2005-04-29 19:44:38 +04:00
|
|
|
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;
|
2016-09-27 13:16:35 +03:00
|
|
|
mBorderStyle[side] = NS_STYLE_BORDER_STYLE_NONE;
|
2008-10-01 09:50:52 +04:00
|
|
|
}
|
2006-12-27 17:21:43 +03:00
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
mTwipsPerPixel = aContext->DevPixelsToAppUnits(1);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBorder::nsStyleBorder(const nsStyleBorder& aSrc)
|
2017-09-18 06:38:39 +03:00
|
|
|
: mBorderRadius(aSrc.mBorderRadius)
|
2016-06-03 18:56:54 +03:00
|
|
|
, mBorderImageSource(aSrc.mBorderImageSource)
|
|
|
|
, mBorderImageSlice(aSrc.mBorderImageSlice)
|
|
|
|
, mBorderImageWidth(aSrc.mBorderImageWidth)
|
|
|
|
, mBorderImageOutset(aSrc.mBorderImageOutset)
|
|
|
|
, mBorderImageFill(aSrc.mBorderImageFill)
|
|
|
|
, mBorderImageRepeatH(aSrc.mBorderImageRepeatH)
|
|
|
|
, mBorderImageRepeatV(aSrc.mBorderImageRepeatV)
|
|
|
|
, mFloatEdge(aSrc.mFloatEdge)
|
|
|
|
, mBoxDecorationBreak(aSrc.mBoxDecorationBreak)
|
2018-06-05 04:24:12 +03:00
|
|
|
, mBorderTopColor(aSrc.mBorderTopColor)
|
|
|
|
, mBorderRightColor(aSrc.mBorderRightColor)
|
|
|
|
, mBorderBottomColor(aSrc.mBorderBottomColor)
|
|
|
|
, mBorderLeftColor(aSrc.mBorderLeftColor)
|
2016-06-03 18:56:54 +03: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);
|
2008-07-08 04:56:52 +04:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mBorderStyle[side] = aSrc.mBorderStyle[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
|
|
|
}
|
|
|
|
|
2016-11-02 11:58:32 +03:00
|
|
|
void
|
2018-02-22 21:44:44 +03:00
|
|
|
nsStyleBorder::FinishStyle(nsPresContext* aPresContext, const nsStyleBorder* aOldStyle)
|
2016-11-02 11:58:32 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2018-02-22 21:44:44 +03:00
|
|
|
mBorderImageSource.ResolveImage(
|
|
|
|
aPresContext, aOldStyle ? &aOldStyle->mBorderImageSource : nullptr);
|
2016-11-02 11:58:32 +03:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleBorder::CalcDifference(const nsStyleBorder& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-10-13 21:41:52 +03:00
|
|
|
// FIXME: XXXbz: As in nsStylePadding::CalcDifference, many of these
|
|
|
|
// differences should not need to clear descendant intrinsics.
|
|
|
|
// FIXME: It would be good to return a weaker hint for the
|
|
|
|
// GetComputedBorder() differences (and perhaps others) that doesn't
|
|
|
|
// force reflow of all descendants, but the hint would need to force
|
|
|
|
// reflow of the frame's children (see how
|
|
|
|
// ReflowInput::InitResizeFlags initializes the inline-resize flag).
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTwipsPerPixel != aNewData.mTwipsPerPixel ||
|
|
|
|
GetComputedBorder() != aNewData.GetComputedBorder() ||
|
|
|
|
mFloatEdge != aNewData.mFloatEdge ||
|
|
|
|
mBorderImageOutset != aNewData.mBorderImageOutset ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mBoxDecorationBreak != aNewData.mBoxDecorationBreak) {
|
2008-11-03 03:58:46 +03:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2005-04-29 19:44:38 +04:00
|
|
|
|
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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasVisibleStyle(ix) != aNewData.HasVisibleStyle(ix)) {
|
2016-04-12 08:52:42 +03:00
|
|
|
return nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_BorderStyleNoneChange;
|
2012-09-07 21:13:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBorderStyle[ix] != aNewData.mBorderStyle[ix] ||
|
2018-06-05 04:24:12 +03:00
|
|
|
BorderColorFor(ix) != aNewData.BorderColorFor(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;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-11-03 03:58:46 +03:00
|
|
|
}
|
2001-12-19 14:59:31 +03:00
|
|
|
|
2018-01-15 05:36:00 +03:00
|
|
|
if (mBorderRadius != aNewData.mBorderRadius) {
|
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;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-07-26 20:14:49 +04:00
|
|
|
|
2017-04-18 10:04:35 +03:00
|
|
|
// Loading status of the border image can be accessed in main thread only
|
|
|
|
// while CalcDifference might be executed on a background thread. As a
|
|
|
|
// result, we have to check mBorderImage* fields even before border image was
|
|
|
|
// actually loaded.
|
|
|
|
if (!mBorderImageSource.IsEmpty() || !aNewData.mBorderImageSource.IsEmpty()) {
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBorderImageSource != aNewData.mBorderImageSource ||
|
|
|
|
mBorderImageRepeatH != aNewData.mBorderImageRepeatH ||
|
|
|
|
mBorderImageRepeatV != aNewData.mBorderImageRepeatV ||
|
|
|
|
mBorderImageSlice != aNewData.mBorderImageSlice ||
|
|
|
|
mBorderImageFill != aNewData.mBorderImageFill ||
|
2017-01-19 11:13:02 +03:00
|
|
|
mBorderImageWidth != aNewData.mBorderImageWidth) {
|
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;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-11-03 03:58:46 +03:00
|
|
|
}
|
2001-12-19 14:59:31 +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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBorder != aNewData.mBorder) {
|
2014-09-05 07:48:43 +04:00
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2017-04-18 10:04:35 +03:00
|
|
|
// mBorderImage* fields are checked only when border-image is not 'none'.
|
2017-01-19 11:13:02 +03:00
|
|
|
if (mBorderImageSource != aNewData.mBorderImageSource ||
|
|
|
|
mBorderImageRepeatH != aNewData.mBorderImageRepeatH ||
|
|
|
|
mBorderImageRepeatV != aNewData.mBorderImageRepeatV ||
|
|
|
|
mBorderImageSlice != aNewData.mBorderImageSlice ||
|
|
|
|
mBorderImageFill != aNewData.mBorderImageFill ||
|
|
|
|
mBorderImageWidth != aNewData.mBorderImageWidth) {
|
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleOutline::nsStyleOutline(const nsPresContext* aContext)
|
2016-11-29 15:08:08 +03:00
|
|
|
: mOutlineWidth((StaticPresData::Get()
|
|
|
|
->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM])
|
2016-05-02 06:11:45 +03:00
|
|
|
, mOutlineOffset(0)
|
2016-09-27 13:44:19 +03:00
|
|
|
, mOutlineColor(StyleComplexColor::CurrentColor())
|
2016-05-02 06:11:45 +03:00
|
|
|
, mOutlineStyle(NS_STYLE_BORDER_STYLE_NONE)
|
2016-09-27 13:44:19 +03:00
|
|
|
, mActualOutlineWidth(0)
|
2017-01-04 22:52:27 +03:00
|
|
|
, mTwipsPerPixel(aContext->DevPixelsToAppUnits(1))
|
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
|
|
|
}
|
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)
|
|
|
|
, mOutlineColor(aSrc.mOutlineColor)
|
|
|
|
, mOutlineStyle(aSrc.mOutlineStyle)
|
2016-09-27 13:44:19 +03:00
|
|
|
, mActualOutlineWidth(aSrc.mActualOutlineWidth)
|
2014-06-19 07:17:10 +04:00
|
|
|
, mTwipsPerPixel(aSrc.mTwipsPerPixel)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleOutline);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-07-27 04:13:04 +03:00
|
|
|
void
|
2016-05-08 21:22:00 +03:00
|
|
|
nsStyleOutline::RecalcData()
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-09-27 13:44:19 +03:00
|
|
|
if (NS_STYLE_BORDER_STYLE_NONE == mOutlineStyle) {
|
2016-05-11 07:03:34 +03:00
|
|
|
mActualOutlineWidth = 0;
|
2016-04-21 01:05:30 +03:00
|
|
|
} else {
|
2016-05-11 07:03:34 +03:00
|
|
|
mActualOutlineWidth =
|
2016-11-29 15:08:08 +03:00
|
|
|
NS_ROUND_BORDER_TO_PIXELS(mOutlineWidth, mTwipsPerPixel);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleOutline::CalcDifference(const nsStyleOutline& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mActualOutlineWidth != aNewData.mActualOutlineWidth ||
|
2016-05-11 07:03:34 +03:00
|
|
|
(mActualOutlineWidth > 0 &&
|
2016-06-21 04:47:54 +03:00
|
|
|
mOutlineOffset != aNewData.mOutlineOffset)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return nsChangeHint_UpdateOverflow |
|
Bug 1364338: Force a repaint when CSS 'outline-width' or 'outline-offset' change. r=heycam
Previously, when these properties changed, we'd only send change hints to
recompute overflow areas & trigger DLBI. If the outline was always outside of
the element's border box, this old strategy was generally OK, because the
outline tweak would cause a change to the overflow areas' size, and that would
invalidate the changed area via DLBI & trigger a repaint.
However, for outlines that are *inside* of the element (via negative
'outline-offset'), these change hints were not sufficient, because tweaks to
the outline width & offset will NOT affect the size of the element's overflow
areas and will not trigger any DLBI invalidation.
So in order to correctly handle these changes, we really need to request a
repaint of the affected element, since some piece of the element may need to be
repainted even if it's not changing in size.
MozReview-Commit-ID: J4KGUHrJ09U
--HG--
extra : rebase_source : 677950d5aebdf7e90120b8fe7bb937344da42d7d
2017-05-13 04:42:10 +03:00
|
|
|
nsChangeHint_SchedulePaint |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2004-07-16 20:56:21 +04:00
|
|
|
}
|
2014-09-05 07:48:43 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mOutlineStyle != aNewData.mOutlineStyle ||
|
|
|
|
mOutlineColor != aNewData.mOutlineColor ||
|
|
|
|
mOutlineRadius != aNewData.mOutlineRadius) {
|
2016-05-11 07:03:34 +03:00
|
|
|
if (mActualOutlineWidth > 0) {
|
|
|
|
return nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
return nsChangeHint_NeutralChange;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2014-09-05 07:48:43 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mOutlineWidth != aNewData.mOutlineWidth ||
|
|
|
|
mOutlineOffset != aNewData.mOutlineOffset ||
|
|
|
|
mTwipsPerPixel != aNewData.mTwipsPerPixel) {
|
2014-09-05 07:48:43 +04:00
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleList
|
|
|
|
//
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleList::nsStyleList(const nsPresContext* aContext)
|
2016-06-03 18:56:54 +03:00
|
|
|
: mListStylePosition(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleList);
|
2017-06-13 09:00:37 +03:00
|
|
|
mCounterStyle = CounterStyleManager::GetDiscStyle();
|
2016-04-12 08:52:40 +03:00
|
|
|
SetQuotesInitial();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-07-27 04:13:04 +03:00
|
|
|
nsStyleList::~nsStyleList()
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
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)
|
2016-06-03 18:56:54 +03:00
|
|
|
: mListStylePosition(aSource.mListStylePosition)
|
2016-11-03 04:40:53 +03:00
|
|
|
, mListStyleImage(aSource.mListStyleImage)
|
2016-06-03 18:56:54 +03:00
|
|
|
, mCounterStyle(aSource.mCounterStyle)
|
|
|
|
, mQuotes(aSource.mQuotes)
|
|
|
|
, mImageRegion(aSource.mImageRegion)
|
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
|
|
|
}
|
|
|
|
|
2016-11-03 04:40:53 +03:00
|
|
|
void
|
2018-02-22 21:44:44 +03:00
|
|
|
nsStyleList::FinishStyle(nsPresContext* aPresContext, const nsStyleList* aOldStyle)
|
2016-11-03 04:40:53 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
if (mListStyleImage && !mListStyleImage->IsResolved()) {
|
2018-02-22 21:44:44 +03:00
|
|
|
mListStyleImage->Resolve(
|
|
|
|
aPresContext, aOldStyle ? aOldStyle->mListStyleImage.get() : nullptr);
|
2016-11-03 04:40:53 +03:00
|
|
|
}
|
2017-05-27 16:33:25 +03:00
|
|
|
mCounterStyle.Resolve(aPresContext->CounterStyleManager());
|
2016-11-03 04:40:53 +03:00
|
|
|
}
|
|
|
|
|
2016-04-12 08:52:40 +03:00
|
|
|
void
|
|
|
|
nsStyleList::SetQuotesInherit(const nsStyleList* aOther)
|
|
|
|
{
|
|
|
|
mQuotes = aOther->mQuotes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleList::SetQuotesInitial()
|
|
|
|
{
|
|
|
|
if (!sInitialQuotes) {
|
|
|
|
// The initial value for quotes is the en-US typographic convention:
|
|
|
|
// outermost are LEFT and RIGHT DOUBLE QUOTATION MARK, alternating
|
|
|
|
// with LEFT and RIGHT SINGLE QUOTATION MARK.
|
|
|
|
static const char16_t initialQuotes[8] = {
|
|
|
|
0x201C, 0, 0x201D, 0, 0x2018, 0, 0x2019, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
sInitialQuotes = new nsStyleQuoteValues;
|
|
|
|
sInitialQuotes->mQuotePairs.AppendElement(
|
|
|
|
std::make_pair(nsDependentString(&initialQuotes[0], 1),
|
|
|
|
nsDependentString(&initialQuotes[2], 1)));
|
|
|
|
sInitialQuotes->mQuotePairs.AppendElement(
|
|
|
|
std::make_pair(nsDependentString(&initialQuotes[4], 1),
|
|
|
|
nsDependentString(&initialQuotes[6], 1)));
|
|
|
|
}
|
|
|
|
|
|
|
|
mQuotes = sInitialQuotes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleList::SetQuotesNone()
|
|
|
|
{
|
|
|
|
if (!sNoneQuotes) {
|
|
|
|
sNoneQuotes = new nsStyleQuoteValues;
|
|
|
|
}
|
|
|
|
mQuotes = sNoneQuotes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleList::SetQuotes(nsStyleQuoteValues::QuotePairArray&& aValues)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-04-12 08:52:40 +03:00
|
|
|
mQuotes = new nsStyleQuoteValues;
|
2018-05-30 22:15:35 +03:00
|
|
|
mQuotes->mQuotePairs = std::move(aValues);
|
2016-04-12 08:52:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const nsStyleQuoteValues::QuotePairArray&
|
|
|
|
nsStyleList::GetQuotePairs() const
|
|
|
|
{
|
|
|
|
return mQuotes->mQuotePairs;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint
|
2017-06-13 13:49:33 +03:00
|
|
|
nsStyleList::CalcDifference(const nsStyleList& aNewData,
|
|
|
|
const nsStyleDisplay* aOldDisplay) const
|
2016-04-12 08:52:40 +03: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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mQuotes != aNewData.mQuotes &&
|
|
|
|
(mQuotes || aNewData.mQuotes) &&
|
|
|
|
GetQuotePairs() != aNewData.GetQuotePairs()) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-04-12 08:52:40 +03:00
|
|
|
}
|
2017-06-13 13:49:33 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
// Only elements whose display value is list-item can be affected by
|
|
|
|
// list-style-position and list-style-type. If the old display struct
|
|
|
|
// doesn't exist, assume it isn't affected by display value at all,
|
|
|
|
// and thus these properties should not affect it either. This also
|
|
|
|
// relies on that when the display value changes from something else
|
|
|
|
// to list-item, that change itself would cause ReconstructFrame.
|
|
|
|
if (aOldDisplay && aOldDisplay->mDisplay == StyleDisplay::ListItem) {
|
|
|
|
if (mListStylePosition != aNewData.mListStylePosition) {
|
|
|
|
return nsChangeHint_ReconstructFrame;
|
|
|
|
}
|
|
|
|
if (mCounterStyle != aNewData.mCounterStyle) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2014-09-20 05:43:00 +04:00
|
|
|
}
|
2017-06-13 13:49:33 +03:00
|
|
|
} else if (mListStylePosition != aNewData.mListStylePosition ||
|
|
|
|
mCounterStyle != aNewData.mCounterStyle) {
|
|
|
|
hint = nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
// list-style-image and -moz-image-region may affect some XUL elements
|
|
|
|
// regardless of display value, so we still need to check them.
|
|
|
|
if (!DefinitelyEqualImages(mListStyleImage, aNewData.mListStyleImage)) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
if (!mImageRegion.IsEqualInterior(aNewData.mImageRegion)) {
|
|
|
|
if (mImageRegion.width != aNewData.mImageRegion.width ||
|
|
|
|
mImageRegion.height != aNewData.mImageRegion.height) {
|
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2017-06-13 13:49:33 +03:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2002-11-06 10:31:27 +03:00
|
|
|
}
|
2017-06-13 13:49:33 +03:00
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2017-03-09 08:03:32 +03:00
|
|
|
already_AddRefed<nsIURI>
|
|
|
|
nsStyleList::GetListStyleImageURI() const
|
|
|
|
{
|
|
|
|
if (!mListStyleImage) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri = mListStyleImage->GetImageURI();
|
|
|
|
return uri.forget();
|
|
|
|
}
|
|
|
|
|
2016-04-12 08:52:40 +03:00
|
|
|
StaticRefPtr<nsStyleQuoteValues>
|
|
|
|
nsStyleList::sInitialQuotes;
|
|
|
|
|
|
|
|
StaticRefPtr<nsStyleQuoteValues>
|
|
|
|
nsStyleList::sNoneQuotes;
|
|
|
|
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleXUL
|
|
|
|
//
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleXUL::nsStyleXUL(const nsPresContext* aContext)
|
2016-05-02 06:11:45 +03:00
|
|
|
: mBoxFlex(0.0f)
|
|
|
|
, mBoxOrdinal(1)
|
2016-08-26 10:09:19 +03:00
|
|
|
, mBoxAlign(StyleBoxAlign::Stretch)
|
2016-08-26 10:17:09 +03:00
|
|
|
, mBoxDirection(StyleBoxDirection::Normal)
|
2016-08-26 10:18:41 +03:00
|
|
|
, mBoxOrient(StyleBoxOrient::Horizontal)
|
2016-08-26 10:11:54 +03:00
|
|
|
, mBoxPack(StyleBoxPack::Start)
|
2017-05-15 14:33:46 +03:00
|
|
|
, mStackSizing(StyleStackSizing::StretchToFit)
|
2016-05-02 06:11:45 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleXUL);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-02 06:11:45 +03:00
|
|
|
nsStyleXUL::~nsStyleXUL()
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
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)
|
2017-05-15 14:33:46 +03:00
|
|
|
, mStackSizing(aSource.mStackSizing)
|
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
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleXUL::CalcDifference(const nsStyleXUL& aNewData) const
|
|
|
|
{
|
|
|
|
if (mBoxAlign == aNewData.mBoxAlign &&
|
|
|
|
mBoxDirection == aNewData.mBoxDirection &&
|
|
|
|
mBoxFlex == aNewData.mBoxFlex &&
|
|
|
|
mBoxOrient == aNewData.mBoxOrient &&
|
|
|
|
mBoxPack == aNewData.mBoxPack &&
|
|
|
|
mBoxOrdinal == aNewData.mBoxOrdinal &&
|
2017-05-15 14:33:46 +03:00
|
|
|
mStackSizing == aNewData.mStackSizing) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
|
|
|
if (mBoxOrdinal != aNewData.mBoxOrdinal) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
|
|
|
|
2004-06-17 15:57:37 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleColumn
|
|
|
|
//
|
2016-10-25 09:25:10 +03:00
|
|
|
/* static */ const uint32_t nsStyleColumn::kMaxColumnCount;
|
2013-05-31 19:51:43 +04:00
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleColumn::nsStyleColumn(const nsPresContext* aContext)
|
2016-05-02 06:11:45 +03:00
|
|
|
: mColumnCount(NS_STYLE_COLUMN_COUNT_AUTO)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mColumnWidth(eStyleUnit_Auto)
|
2016-09-27 13:12:08 +03:00
|
|
|
, mColumnRuleColor(StyleComplexColor::CurrentColor())
|
2016-05-02 06:11:45 +03:00
|
|
|
, mColumnRuleStyle(NS_STYLE_BORDER_STYLE_NONE)
|
|
|
|
, mColumnFill(NS_STYLE_COLUMN_FILL_BALANCE)
|
2017-02-14 03:57:33 +03:00
|
|
|
, mColumnSpan(NS_STYLE_COLUMN_SPAN_NONE)
|
2016-05-02 06:11:45 +03:00
|
|
|
, mColumnRuleWidth((StaticPresData::Get()
|
|
|
|
->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM])
|
2017-01-04 22:52:27 +03:00
|
|
|
, mTwipsPerPixel(aContext->AppUnitsPerDevPixel())
|
2008-07-19 14:38:25 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColumn);
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
2016-05-02 06:11:45 +03:00
|
|
|
nsStyleColumn::~nsStyleColumn()
|
2004-06-17 15:57:37 +04:00
|
|
|
{
|
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)
|
|
|
|
, mColumnRuleColor(aSource.mColumnRuleColor)
|
|
|
|
, mColumnRuleStyle(aSource.mColumnRuleStyle)
|
|
|
|
, mColumnFill(aSource.mColumnFill)
|
2017-02-14 03:57:33 +03:00
|
|
|
, mColumnSpan(aSource.mColumnSpan)
|
2014-06-19 07:17:10 +04:00
|
|
|
, 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
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleColumn::CalcDifference(const nsStyleColumn& aNewData) const
|
2004-06-17 15:57:37 +04:00
|
|
|
{
|
2004-07-18 16:12:46 +04:00
|
|
|
if ((mColumnWidth.GetUnit() == eStyleUnit_Auto)
|
2016-06-21 04:47:54 +03:00
|
|
|
!= (aNewData.mColumnWidth.GetUnit() == eStyleUnit_Auto) ||
|
2017-02-14 03:57:33 +03:00
|
|
|
mColumnCount != aNewData.mColumnCount ||
|
|
|
|
mColumnSpan != aNewData.mColumnSpan) {
|
2004-10-08 16:17:10 +04:00
|
|
|
// 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
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2004-07-18 16:12:46 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mColumnWidth != aNewData.mColumnWidth ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mColumnFill != aNewData.mColumnFill) {
|
2008-07-19 14:38:25 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-07-19 14:38:25 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (GetComputedColumnRuleWidth() != aNewData.GetComputedColumnRuleWidth() ||
|
|
|
|
mColumnRuleStyle != aNewData.mColumnRuleStyle ||
|
2016-09-27 13:12:08 +03:00
|
|
|
mColumnRuleColor != aNewData.mColumnRuleColor) {
|
2008-07-19 14:38:25 +04:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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?
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mColumnRuleWidth != aNewData.mColumnRuleWidth ||
|
|
|
|
mTwipsPerPixel != aNewData.mTwipsPerPixel) {
|
2014-09-05 07:48:43 +04:00
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2004-06-17 15:57:37 +04:00
|
|
|
}
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
// --------------------
|
|
|
|
// nsStyleSVG
|
|
|
|
//
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleSVG::nsStyleSVG(const nsPresContext* aContext)
|
2016-05-03 12:26:28 +03:00
|
|
|
: mFill(eStyleSVGPaintType_Color) // Will be initialized to NS_RGB(0, 0, 0)
|
|
|
|
, mStroke(eStyleSVGPaintType_None)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mStrokeDashoffset(0, nsStyleCoord::CoordConstructor)
|
2016-06-03 18:56:54 +03:00
|
|
|
, mStrokeWidth(nsPresContext::CSSPixelsToAppUnits(1), nsStyleCoord::CoordConstructor)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mFillOpacity(1.0f)
|
|
|
|
, mStrokeMiterlimit(4.0f)
|
|
|
|
, mStrokeOpacity(1.0f)
|
2016-08-17 09:43:26 +03:00
|
|
|
, mClipRule(StyleFillRule::Nonzero)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mColorInterpolation(NS_STYLE_COLOR_INTERPOLATION_SRGB)
|
|
|
|
, mColorInterpolationFilters(NS_STYLE_COLOR_INTERPOLATION_LINEARRGB)
|
2016-08-17 09:43:26 +03:00
|
|
|
, mFillRule(StyleFillRule::Nonzero)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mPaintOrder(NS_STYLE_PAINT_ORDER_NORMAL)
|
|
|
|
, mShapeRendering(NS_STYLE_SHAPE_RENDERING_AUTO)
|
|
|
|
, mStrokeLinecap(NS_STYLE_STROKE_LINECAP_BUTT)
|
|
|
|
, mStrokeLinejoin(NS_STYLE_STROKE_LINEJOIN_MITER)
|
|
|
|
, mTextAnchor(NS_STYLE_TEXT_ANCHOR_START)
|
2017-04-11 23:38:10 +03:00
|
|
|
, mContextPropsBits(0)
|
2016-06-03 10:16:39 +03:00
|
|
|
, mContextFlags((eStyleSVGOpacitySource_Normal << FILL_OPACITY_SOURCE_SHIFT) |
|
|
|
|
(eStyleSVGOpacitySource_Normal << STROKE_OPACITY_SOURCE_SHIFT))
|
2016-01-11 02:28:35 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleSVG);
|
2016-05-03 12:26:28 +03:00
|
|
|
}
|
2016-01-11 02:28:35 +03:00
|
|
|
|
|
|
|
nsStyleSVG::~nsStyleSVG()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleSVG);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVG::nsStyleSVG(const nsStyleSVG& aSource)
|
2016-05-03 12:26:28 +03:00
|
|
|
: mFill(aSource.mFill)
|
|
|
|
, mStroke(aSource.mStroke)
|
|
|
|
, mMarkerEnd(aSource.mMarkerEnd)
|
|
|
|
, mMarkerMid(aSource.mMarkerMid)
|
|
|
|
, mMarkerStart(aSource.mMarkerStart)
|
2016-05-26 09:01:58 +03:00
|
|
|
, mStrokeDasharray(aSource.mStrokeDasharray)
|
2017-04-11 23:38:10 +03:00
|
|
|
, mContextProps(aSource.mContextProps)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mStrokeDashoffset(aSource.mStrokeDashoffset)
|
|
|
|
, mStrokeWidth(aSource.mStrokeWidth)
|
|
|
|
, mFillOpacity(aSource.mFillOpacity)
|
|
|
|
, mStrokeMiterlimit(aSource.mStrokeMiterlimit)
|
|
|
|
, mStrokeOpacity(aSource.mStrokeOpacity)
|
|
|
|
, mClipRule(aSource.mClipRule)
|
|
|
|
, mColorInterpolation(aSource.mColorInterpolation)
|
|
|
|
, mColorInterpolationFilters(aSource.mColorInterpolationFilters)
|
|
|
|
, mFillRule(aSource.mFillRule)
|
|
|
|
, mPaintOrder(aSource.mPaintOrder)
|
|
|
|
, mShapeRendering(aSource.mShapeRendering)
|
|
|
|
, mStrokeLinecap(aSource.mStrokeLinecap)
|
|
|
|
, mStrokeLinejoin(aSource.mStrokeLinejoin)
|
|
|
|
, mTextAnchor(aSource.mTextAnchor)
|
2017-04-11 23:38:10 +03:00
|
|
|
, mContextPropsBits(aSource.mContextPropsBits)
|
2016-06-03 10:16:39 +03:00
|
|
|
, mContextFlags(aSource.mContextFlags)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVG);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
static bool
|
|
|
|
PaintURIChanged(const nsStyleSVGPaint& aPaint1, const nsStyleSVGPaint& aPaint2)
|
2008-10-01 04:51:05 +04:00
|
|
|
{
|
2016-10-11 09:56:11 +03:00
|
|
|
if (aPaint1.Type() != aPaint2.Type()) {
|
|
|
|
return aPaint1.Type() == eStyleSVGPaintType_Server ||
|
|
|
|
aPaint2.Type() == eStyleSVGPaintType_Server;
|
2008-10-01 04:51:05 +04:00
|
|
|
}
|
2016-10-11 09:56:11 +03:00
|
|
|
return aPaint1.Type() == eStyleSVGPaintType_Server &&
|
|
|
|
!DefinitelyEqualURIs(aPaint1.GetPaintServer(),
|
|
|
|
aPaint2.GetPaintServer());
|
2008-10-01 04:51:05 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleSVG::CalcDifference(const nsStyleSVG& aNewData) const
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2008-10-01 04:51:05 +04:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2016-10-11 09:56:11 +03:00
|
|
|
if (!DefinitelyEqualURIs(mMarkerEnd, aNewData.mMarkerEnd) ||
|
|
|
|
!DefinitelyEqualURIs(mMarkerMid, aNewData.mMarkerMid) ||
|
|
|
|
!DefinitelyEqualURIs(mMarkerStart, aNewData.mMarkerStart)) {
|
2016-12-18 14:11:47 +03:00
|
|
|
// Markers currently contribute to SVGGeometryFrame::mRect,
|
2013-05-24 21:31:33 +04:00
|
|
|
// so we need a reflow as well as a repaint. No intrinsic sizes need
|
|
|
|
// to change, so nsChangeHint_NeedReflow is sufficient.
|
2016-05-23 06:26:03 +03:00
|
|
|
return nsChangeHint_UpdateEffects |
|
|
|
|
nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow | // XXX remove me: bug 876085
|
|
|
|
nsChangeHint_RepaintFrame;
|
2009-01-22 04:02:40 +03:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mFill != aNewData.mFill ||
|
|
|
|
mStroke != aNewData.mStroke ||
|
|
|
|
mFillOpacity != aNewData.mFillOpacity ||
|
|
|
|
mStrokeOpacity != aNewData.mStrokeOpacity) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasStroke() != aNewData.HasStroke() ||
|
|
|
|
(!HasStroke() && HasFill() != aNewData.HasFill())) {
|
2013-11-23 17:32:21 +04:00
|
|
|
// 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.
|
2016-12-18 14:11:47 +03:00
|
|
|
// XXXperf this is a waste on non SVGGeometryFrames.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow; // XXX remove me: bug 876085
|
2013-11-23 17:32:21 +04:00
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (PaintURIChanged(mFill, aNewData.mFill) ||
|
|
|
|
PaintURIChanged(mStroke, aNewData.mStroke)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateEffects;
|
2008-10-01 04:51:05 +04:00
|
|
|
}
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
|
|
|
|
2016-12-18 14:11:47 +03:00
|
|
|
// Stroke currently contributes to SVGGeometryFrame::mRect, so
|
2013-05-24 21:31:33 +04:00
|
|
|
// we need a reflow here. No intrinsic sizes need to change, so
|
|
|
|
// nsChangeHint_NeedReflow is sufficient.
|
2016-12-18 14:11:47 +03:00
|
|
|
// Note that stroke-dashoffset does not affect SVGGeometryFrame::mRect.
|
2016-04-12 08:52:41 +03:00
|
|
|
// text-anchor changes also require a reflow since it changes frames' rects.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mStrokeWidth != aNewData.mStrokeWidth ||
|
|
|
|
mStrokeMiterlimit != aNewData.mStrokeMiterlimit ||
|
|
|
|
mStrokeLinecap != aNewData.mStrokeLinecap ||
|
|
|
|
mStrokeLinejoin != aNewData.mStrokeLinejoin ||
|
|
|
|
mTextAnchor != aNewData.mTextAnchor) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow | // XXX remove me: bug 876085
|
|
|
|
nsChangeHint_RepaintFrame;
|
2008-10-01 04:51:05 +04:00
|
|
|
}
|
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
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if ( mStrokeDashoffset != aNewData.mStrokeDashoffset ||
|
|
|
|
mClipRule != aNewData.mClipRule ||
|
|
|
|
mColorInterpolation != aNewData.mColorInterpolation ||
|
|
|
|
mColorInterpolationFilters != aNewData.mColorInterpolationFilters ||
|
|
|
|
mFillRule != aNewData.mFillRule ||
|
|
|
|
mPaintOrder != aNewData.mPaintOrder ||
|
|
|
|
mShapeRendering != aNewData.mShapeRendering ||
|
|
|
|
mStrokeDasharray != aNewData.mStrokeDasharray ||
|
2017-04-11 23:38:10 +03:00
|
|
|
mContextFlags != aNewData.mContextFlags ||
|
|
|
|
mContextPropsBits != aNewData.mContextPropsBits) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint | nsChangeHint_RepaintFrame;
|
2008-10-01 04:51:05 +04:00
|
|
|
}
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2017-04-11 23:38:10 +03:00
|
|
|
if (!hint) {
|
|
|
|
if (mContextProps != aNewData.mContextProps) {
|
|
|
|
hint = nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-01 04:51:05 +04:00
|
|
|
return hint;
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2016-02-17 03:19:27 +03:00
|
|
|
// --------------------
|
2016-07-27 13:14:36 +03:00
|
|
|
// StyleBasicShape
|
2016-02-17 03:19:27 +03:00
|
|
|
|
|
|
|
nsCSSKeyword
|
2016-07-27 13:14:36 +03:00
|
|
|
StyleBasicShape::GetShapeTypeName() const
|
2016-02-17 03:19:27 +03:00
|
|
|
{
|
|
|
|
switch (mType) {
|
2016-07-27 12:59:33 +03:00
|
|
|
case StyleBasicShapeType::Polygon:
|
2016-02-17 03:19:27 +03:00
|
|
|
return eCSSKeyword_polygon;
|
2016-07-27 12:59:33 +03:00
|
|
|
case StyleBasicShapeType::Circle:
|
2016-02-17 03:19:27 +03:00
|
|
|
return eCSSKeyword_circle;
|
2016-07-27 12:59:33 +03:00
|
|
|
case StyleBasicShapeType::Ellipse:
|
2016-02-17 03:19:27 +03:00
|
|
|
return eCSSKeyword_ellipse;
|
2016-07-27 12:59:33 +03:00
|
|
|
case StyleBasicShapeType::Inset:
|
2016-02-17 03:19:27 +03:00
|
|
|
return eCSSKeyword_inset;
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("unexpected type");
|
|
|
|
return eCSSKeyword_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
2017-09-27 06:32:38 +03:00
|
|
|
// --------------------
|
|
|
|
// StyleShapeSource
|
|
|
|
|
|
|
|
StyleShapeSource::StyleShapeSource(const StyleShapeSource& aSource)
|
|
|
|
{
|
2017-09-29 11:24:23 +03:00
|
|
|
DoCopy(aSource);
|
2017-09-27 06:32:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
StyleShapeSource&
|
|
|
|
StyleShapeSource::operator=(const StyleShapeSource& aOther)
|
|
|
|
{
|
2017-09-29 11:24:23 +03:00
|
|
|
if (this != &aOther) {
|
|
|
|
DoCopy(aOther);
|
2017-09-27 06:32:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2017-09-29 09:36:35 +03:00
|
|
|
bool
|
|
|
|
StyleShapeSource::operator==(const StyleShapeSource& aOther) const
|
|
|
|
{
|
|
|
|
if (mType != aOther.mType) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-17 11:34:37 +03:00
|
|
|
switch (mType) {
|
|
|
|
case StyleShapeSourceType::None:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case StyleShapeSourceType::URL:
|
|
|
|
case StyleShapeSourceType::Image:
|
|
|
|
return *mShapeImage == *aOther.mShapeImage;
|
|
|
|
|
|
|
|
case StyleShapeSourceType::Shape:
|
|
|
|
return *mBasicShape == *aOther.mBasicShape &&
|
|
|
|
mReferenceBox == aOther.mReferenceBox;
|
|
|
|
|
|
|
|
case StyleShapeSourceType::Box:
|
|
|
|
return mReferenceBox == aOther.mReferenceBox;
|
2017-09-29 09:36:35 +03:00
|
|
|
}
|
|
|
|
|
2017-11-17 11:34:37 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("Unexpected shape source type!");
|
2017-09-29 09:36:35 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-10-02 12:51:20 +03:00
|
|
|
void
|
2017-09-27 06:32:38 +03:00
|
|
|
StyleShapeSource::SetURL(css::URLValue* aValue)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aValue);
|
2017-09-29 11:24:23 +03:00
|
|
|
if (!mShapeImage) {
|
|
|
|
mShapeImage = MakeUnique<nsStyleImage>();
|
|
|
|
}
|
|
|
|
mShapeImage->SetURLValue(do_AddRef(aValue));
|
2017-09-27 06:32:38 +03:00
|
|
|
mType = StyleShapeSourceType::URL;
|
2017-11-17 11:34:37 +03:00
|
|
|
}
|
|
|
|
|
2017-11-17 11:34:37 +03:00
|
|
|
void
|
|
|
|
StyleShapeSource::SetShapeImage(UniquePtr<nsStyleImage> aShapeImage)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aShapeImage);
|
2018-05-30 22:15:35 +03:00
|
|
|
mShapeImage = std::move(aShapeImage);
|
2017-11-17 11:34:37 +03:00
|
|
|
mType = StyleShapeSourceType::Image;
|
|
|
|
}
|
|
|
|
|
2018-01-25 09:56:43 +03:00
|
|
|
imgIRequest*
|
|
|
|
StyleShapeSource::GetShapeImageData() const
|
|
|
|
{
|
|
|
|
if (mType != StyleShapeSourceType::Image) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (mShapeImage->GetType() != eStyleImageType_Image) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return mShapeImage->GetImageData();
|
|
|
|
}
|
|
|
|
|
2017-09-27 06:32:38 +03:00
|
|
|
void
|
2017-09-25 13:50:24 +03:00
|
|
|
StyleShapeSource::SetBasicShape(UniquePtr<StyleBasicShape> aBasicShape,
|
2017-09-27 06:32:38 +03:00
|
|
|
StyleGeometryBox aReferenceBox)
|
|
|
|
{
|
2017-11-17 11:34:37 +03:00
|
|
|
MOZ_ASSERT(aBasicShape);
|
2018-05-30 22:15:35 +03:00
|
|
|
mBasicShape = std::move(aBasicShape);
|
2017-09-27 06:32:38 +03:00
|
|
|
mReferenceBox = aReferenceBox;
|
|
|
|
mType = StyleShapeSourceType::Shape;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StyleShapeSource::SetReferenceBox(StyleGeometryBox aReferenceBox)
|
|
|
|
{
|
|
|
|
mReferenceBox = aReferenceBox;
|
|
|
|
mType = StyleShapeSourceType::Box;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-09-29 11:24:23 +03:00
|
|
|
StyleShapeSource::DoCopy(const StyleShapeSource& aOther)
|
2017-09-27 06:32:38 +03:00
|
|
|
{
|
2017-09-29 11:24:23 +03:00
|
|
|
switch (aOther.mType) {
|
|
|
|
case StyleShapeSourceType::None:
|
|
|
|
mReferenceBox = StyleGeometryBox::NoBox;
|
|
|
|
mType = StyleShapeSourceType::None;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case StyleShapeSourceType::URL:
|
|
|
|
SetURL(aOther.GetURL());
|
|
|
|
break;
|
|
|
|
|
2017-11-17 11:34:37 +03:00
|
|
|
case StyleShapeSourceType::Image:
|
|
|
|
SetShapeImage(MakeUnique<nsStyleImage>(*aOther.GetShapeImage()));
|
|
|
|
break;
|
|
|
|
|
2017-09-29 11:24:23 +03:00
|
|
|
case StyleShapeSourceType::Shape:
|
|
|
|
SetBasicShape(MakeUnique<StyleBasicShape>(*aOther.GetBasicShape()),
|
|
|
|
aOther.GetReferenceBox());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case StyleShapeSourceType::Box:
|
|
|
|
SetReferenceBox(aOther.GetReferenceBox());
|
|
|
|
break;
|
|
|
|
}
|
2017-09-27 06:32:38 +03:00
|
|
|
}
|
|
|
|
|
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) {
|
2016-10-11 09:56:12 +03: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)
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (this == &aOther) {
|
2013-08-05 11:02:27 +04:00
|
|
|
return *this;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2013-08-05 11:02:27 +04:00
|
|
|
|
2013-08-06 11:53:30 +04:00
|
|
|
if (aOther.mType == NS_STYLE_FILTER_URL) {
|
2016-10-11 09:56:12 +03: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) {
|
2016-10-11 09:56:12 +03:00
|
|
|
return DefinitelyEqualURIs(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");
|
2016-10-11 09:56:12 +03:00
|
|
|
mURL->Release();
|
2013-08-05 11:02:27 +04:00
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2016-07-23 11:16:59 +03:00
|
|
|
bool
|
2016-10-11 09:56:12 +03:00
|
|
|
nsStyleFilter::SetURL(css::URLValue* aURL)
|
2013-08-05 11:02:27 +04:00
|
|
|
{
|
|
|
|
ReleaseRef();
|
2016-10-11 09:56:12 +03:00
|
|
|
mURL = aURL;
|
|
|
|
mURL->AddRef();
|
2013-08-06 11:53:30 +04:00
|
|
|
mType = NS_STYLE_FILTER_URL;
|
2016-07-23 11:16:59 +03:00
|
|
|
return true;
|
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
|
|
|
|
//
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleSVGReset::nsStyleSVGReset(const nsPresContext* aContext)
|
2016-06-03 18:56:54 +03:00
|
|
|
: mMask(nsStyleImageLayers::LayerType::Mask)
|
2018-04-27 05:07:20 +03:00
|
|
|
, mStopColor(StyleComplexColor::FromColor(NS_RGB(0, 0, 0)))
|
|
|
|
, mFloodColor(StyleComplexColor::FromColor(NS_RGB(0, 0, 0)))
|
|
|
|
, mLightingColor(StyleComplexColor::FromColor(NS_RGB(255, 255, 255)))
|
2016-05-03 12:26:28 +03:00
|
|
|
, mStopOpacity(1.0f)
|
|
|
|
, mFloodOpacity(1.0f)
|
|
|
|
, mDominantBaseline(NS_STYLE_DOMINANT_BASELINE_AUTO)
|
|
|
|
, mVectorEffect(NS_STYLE_VECTOR_EFFECT_NONE)
|
|
|
|
, 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
|
|
|
{
|
2016-01-11 02:28:35 +03:00
|
|
|
MOZ_COUNT_CTOR(nsStyleSVGReset);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGReset::~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
|
|
|
{
|
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)
|
2016-01-28 08:39:00 +03:00
|
|
|
: mMask(aSource.mMask)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mClipPath(aSource.mClipPath)
|
|
|
|
, mStopColor(aSource.mStopColor)
|
|
|
|
, mFloodColor(aSource.mFloodColor)
|
|
|
|
, mLightingColor(aSource.mLightingColor)
|
|
|
|
, mStopOpacity(aSource.mStopOpacity)
|
|
|
|
, mFloodOpacity(aSource.mFloodOpacity)
|
|
|
|
, mDominantBaseline(aSource.mDominantBaseline)
|
|
|
|
, mVectorEffect(aSource.mVectorEffect)
|
|
|
|
, 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
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(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
|
|
|
}
|
|
|
|
|
2016-11-02 11:58:32 +03:00
|
|
|
void
|
2018-02-22 21:44:44 +03:00
|
|
|
nsStyleSVGReset::FinishStyle(nsPresContext* aPresContext, const nsStyleSVGReset* aOldStyle)
|
2016-11-02 11:58:32 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2017-07-26 06:21:30 +03:00
|
|
|
NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, mMask) {
|
|
|
|
nsStyleImage& image = mMask.mLayers[i].mImage;
|
|
|
|
if (image.GetType() == eStyleImageType_Image) {
|
|
|
|
// If the url of mask resource contains a reference('#'), it should be a
|
|
|
|
// <mask-source>, mostly. For a <mask-source>, there is no need to
|
|
|
|
// resolve this style image, since we do not depend on it to get the
|
|
|
|
// SVG mask resource.
|
|
|
|
if (!image.GetURLValue()->HasRef()) {
|
2018-02-22 21:44:44 +03:00
|
|
|
const nsStyleImage* oldImage =
|
|
|
|
(aOldStyle && aOldStyle->mMask.mLayers.Length() > i)
|
|
|
|
? &aOldStyle->mMask.mLayers[i].mImage
|
|
|
|
: nullptr;
|
|
|
|
|
|
|
|
image.ResolveImage(aPresContext, oldImage);
|
2017-07-26 06:21:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-02 11:58:32 +03:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleSVGReset::CalcDifference(const nsStyleSVGReset& aNewData) const
|
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
|
|
|
{
|
2008-08-06 04:55:07 +04:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2017-09-29 09:36:35 +03:00
|
|
|
if (mClipPath != aNewData.mClipPath) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateEffects |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2016-04-12 08:52:43 +03:00
|
|
|
// clip-path changes require that we update the PreEffectsBBoxProperty,
|
|
|
|
// which is done during overflow computation.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateOverflow;
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mDominantBaseline != aNewData.mDominantBaseline) {
|
2013-05-24 21:31:33 +04:00
|
|
|
// XXXjwatt: why NS_STYLE_HINT_REFLOW? Isn't that excessive?
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_REFLOW;
|
2016-06-21 04:47:54 +03:00
|
|
|
} else if (mVectorEffect != aNewData.mVectorEffect) {
|
2016-12-18 14:11:47 +03:00
|
|
|
// Stroke currently affects SVGGeometryFrame::mRect, and
|
2013-05-24 21:31:33 +04:00
|
|
|
// vector-effect affect stroke. As a result we need to reflow if
|
2016-12-18 14:11:47 +03:00
|
|
|
// vector-effect changes in order to have SVGGeometryFrame::
|
2013-05-24 21:31:33 +04:00
|
|
|
// ReflowSVG called to update its mRect. No intrinsic sizes need
|
|
|
|
// to change so nsChangeHint_NeedReflow is sufficient.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow | // XXX remove me: bug 876085
|
|
|
|
nsChangeHint_RepaintFrame;
|
2016-06-21 04:47:54 +03:00
|
|
|
} else if (mStopColor != aNewData.mStopColor ||
|
|
|
|
mFloodColor != aNewData.mFloodColor ||
|
|
|
|
mLightingColor != aNewData.mLightingColor ||
|
|
|
|
mStopOpacity != aNewData.mStopOpacity ||
|
|
|
|
mFloodOpacity != aNewData.mFloodOpacity ||
|
|
|
|
mMaskType != aNewData.mMaskType) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
2008-08-06 04:55:07 +04:00
|
|
|
|
2016-09-22 13:24:52 +03:00
|
|
|
hint |= mMask.CalcDifference(aNewData.mMask,
|
|
|
|
nsStyleImageLayers::LayerType::Mask);
|
2016-01-28 08:28:00 +03: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
|
|
|
}
|
|
|
|
|
2017-03-07 08:43:21 +03:00
|
|
|
bool
|
|
|
|
nsStyleSVGReset::HasMask() const
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < mMask.mImageCount; i++) {
|
2017-03-30 20:50:21 +03:00
|
|
|
if (!mMask.mLayers[i].mImage.IsEmpty()) {
|
2017-03-07 08:43:21 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-10-15 03:02:53 +04:00
|
|
|
// nsStyleSVGPaint implementation
|
2016-05-03 12:26:27 +03:00
|
|
|
nsStyleSVGPaint::nsStyleSVGPaint(nsStyleSVGPaintType aType)
|
2016-10-11 09:56:11 +03:00
|
|
|
: mType(aType)
|
2017-04-29 16:03:20 +03:00
|
|
|
, mFallbackType(eStyleSVGFallbackType_NotSet)
|
2016-05-03 12:26:27 +03:00
|
|
|
, mFallbackColor(NS_RGB(0, 0, 0))
|
2007-10-19 19:36:15 +04:00
|
|
|
{
|
2016-10-11 09:56:11 +03:00
|
|
|
MOZ_ASSERT(aType == nsStyleSVGPaintType(0) ||
|
|
|
|
aType == eStyleSVGPaintType_None ||
|
|
|
|
aType == eStyleSVGPaintType_Color);
|
|
|
|
mPaint.mColor = NS_RGB(0, 0, 0);
|
2016-05-03 12:26:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSVGPaint::nsStyleSVGPaint(const nsStyleSVGPaint& aSource)
|
2016-10-11 09:56:11 +03:00
|
|
|
: nsStyleSVGPaint(nsStyleSVGPaintType(0))
|
2016-05-03 12:26:27 +03:00
|
|
|
{
|
2016-10-11 09:56:11 +03:00
|
|
|
Assign(aSource);
|
2007-10-19 19:36:15 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:27 +03:00
|
|
|
nsStyleSVGPaint::~nsStyleSVGPaint()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleSVGPaint::Reset()
|
|
|
|
{
|
2016-10-11 09:56:11 +03:00
|
|
|
switch (mType) {
|
|
|
|
case eStyleSVGPaintType_None:
|
|
|
|
break;
|
|
|
|
case eStyleSVGPaintType_Color:
|
|
|
|
mPaint.mColor = NS_RGB(0, 0, 0);
|
|
|
|
break;
|
|
|
|
case eStyleSVGPaintType_Server:
|
|
|
|
mPaint.mPaintServer->Release();
|
|
|
|
mPaint.mPaintServer = nullptr;
|
|
|
|
MOZ_FALLTHROUGH;
|
|
|
|
case eStyleSVGPaintType_ContextFill:
|
|
|
|
case eStyleSVGPaintType_ContextStroke:
|
2017-04-29 16:03:20 +03:00
|
|
|
mFallbackType = eStyleSVGFallbackType_NotSet;
|
2016-10-11 09:56:11 +03:00
|
|
|
mFallbackColor = NS_RGB(0, 0, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mType = nsStyleSVGPaintType(0);
|
2016-05-03 12:26:27 +03:00
|
|
|
}
|
|
|
|
|
2016-10-11 09:56:11 +03:00
|
|
|
nsStyleSVGPaint&
|
|
|
|
nsStyleSVGPaint::operator=(const nsStyleSVGPaint& aOther)
|
2007-10-19 19:36:15 +04:00
|
|
|
{
|
2016-10-11 09:56:11 +03:00
|
|
|
if (this != &aOther) {
|
|
|
|
Assign(aOther);
|
2007-10-19 19:36:15 +04:00
|
|
|
}
|
2016-10-11 09:56:11 +03:00
|
|
|
return *this;
|
2004-10-15 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
2016-10-11 09:56:11 +03:00
|
|
|
void
|
|
|
|
nsStyleSVGPaint::Assign(const nsStyleSVGPaint& aOther)
|
2004-10-15 03:02:53 +04:00
|
|
|
{
|
2016-10-11 09:56:11 +03:00
|
|
|
MOZ_ASSERT(aOther.mType != nsStyleSVGPaintType(0),
|
|
|
|
"shouldn't copy uninitialized nsStyleSVGPaint");
|
|
|
|
|
|
|
|
switch (aOther.mType) {
|
|
|
|
case eStyleSVGPaintType_None:
|
|
|
|
SetNone();
|
|
|
|
break;
|
|
|
|
case eStyleSVGPaintType_Color:
|
|
|
|
SetColor(aOther.mPaint.mColor);
|
|
|
|
break;
|
|
|
|
case eStyleSVGPaintType_Server:
|
|
|
|
SetPaintServer(aOther.mPaint.mPaintServer,
|
2017-05-03 00:12:59 +03:00
|
|
|
aOther.mFallbackType,
|
2016-10-11 09:56:11 +03:00
|
|
|
aOther.mFallbackColor);
|
|
|
|
break;
|
|
|
|
case eStyleSVGPaintType_ContextFill:
|
|
|
|
case eStyleSVGPaintType_ContextStroke:
|
2017-05-03 00:12:59 +03:00
|
|
|
SetContextValue(aOther.mType,
|
|
|
|
aOther.mFallbackType,
|
|
|
|
aOther.mFallbackColor);
|
2016-10-11 09:56:11 +03:00
|
|
|
break;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2016-10-11 09:56:11 +03:00
|
|
|
}
|
2007-10-19 19:36:15 +04:00
|
|
|
|
2016-10-11 09:56:11 +03:00
|
|
|
void
|
|
|
|
nsStyleSVGPaint::SetNone()
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
mType = eStyleSVGPaintType_None;
|
|
|
|
}
|
2007-10-19 19:36:15 +04:00
|
|
|
|
2016-10-11 09:56:11 +03:00
|
|
|
void
|
|
|
|
nsStyleSVGPaint::SetContextValue(nsStyleSVGPaintType aType,
|
2017-05-03 00:12:59 +03:00
|
|
|
nsStyleSVGFallbackType aFallbackType,
|
2016-10-11 09:56:11 +03:00
|
|
|
nscolor aFallbackColor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aType == eStyleSVGPaintType_ContextFill ||
|
|
|
|
aType == eStyleSVGPaintType_ContextStroke);
|
|
|
|
Reset();
|
|
|
|
mType = aType;
|
2017-05-03 00:12:59 +03:00
|
|
|
mFallbackType = aFallbackType;
|
2016-10-11 09:56:11 +03:00
|
|
|
mFallbackColor = aFallbackColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleSVGPaint::SetColor(nscolor aColor)
|
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
mType = eStyleSVGPaintType_Color;
|
|
|
|
mPaint.mColor = aColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleSVGPaint::SetPaintServer(css::URLValue* aPaintServer,
|
2017-05-03 00:12:59 +03:00
|
|
|
nsStyleSVGFallbackType aFallbackType,
|
2016-10-11 09:56:11 +03:00
|
|
|
nscolor aFallbackColor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aPaintServer);
|
|
|
|
Reset();
|
|
|
|
mType = eStyleSVGPaintType_Server;
|
|
|
|
mPaint.mPaintServer = aPaintServer;
|
|
|
|
mPaint.mPaintServer->AddRef();
|
2017-05-03 00:12:59 +03:00
|
|
|
mFallbackType = aFallbackType;
|
2016-10-11 09:56:11 +03:00
|
|
|
mFallbackColor = aFallbackColor;
|
2004-10-15 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsStyleSVGPaint::operator==(const nsStyleSVGPaint& aOther) const
|
2004-10-15 03:02:53 +04:00
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != aOther.mType) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2016-10-11 09:56:11 +03:00
|
|
|
switch (mType) {
|
|
|
|
case eStyleSVGPaintType_Color:
|
|
|
|
return mPaint.mColor == aOther.mPaint.mColor;
|
|
|
|
case eStyleSVGPaintType_Server:
|
|
|
|
return DefinitelyEqualURIs(mPaint.mPaintServer,
|
|
|
|
aOther.mPaint.mPaintServer) &&
|
2017-05-03 00:12:59 +03:00
|
|
|
mFallbackType == aOther.mFallbackType &&
|
2016-10-11 09:56:11 +03:00
|
|
|
mFallbackColor == aOther.mFallbackColor;
|
|
|
|
case eStyleSVGPaintType_ContextFill:
|
|
|
|
case eStyleSVGPaintType_ContextStroke:
|
2017-05-03 00:12:59 +03:00
|
|
|
return mFallbackType == aOther.mFallbackType &&
|
|
|
|
mFallbackColor == aOther.mFallbackColor;
|
2016-10-11 09:56:11 +03:00
|
|
|
default:
|
|
|
|
MOZ_ASSERT(mType == eStyleSVGPaintType_None,
|
|
|
|
"Unexpected SVG paint type");
|
|
|
|
return true;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2004-10-15 03:02:53 +04:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStylePosition
|
|
|
|
//
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStylePosition::nsStylePosition(const nsPresContext* aContext)
|
2016-05-03 12:26:30 +03:00
|
|
|
: mWidth(eStyleUnit_Auto)
|
|
|
|
, mMinWidth(eStyleUnit_Auto)
|
|
|
|
, mMaxWidth(eStyleUnit_None)
|
|
|
|
, mHeight(eStyleUnit_Auto)
|
|
|
|
, mMinHeight(eStyleUnit_Auto)
|
|
|
|
, mMaxHeight(eStyleUnit_None)
|
|
|
|
, mFlexBasis(eStyleUnit_Auto)
|
|
|
|
, mGridAutoColumnsMin(eStyleUnit_Auto)
|
|
|
|
, mGridAutoColumnsMax(eStyleUnit_Auto)
|
|
|
|
, mGridAutoRowsMin(eStyleUnit_Auto)
|
|
|
|
, mGridAutoRowsMax(eStyleUnit_Auto)
|
|
|
|
, mGridAutoFlow(NS_STYLE_GRID_AUTO_FLOW_ROW)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mBoxSizing(StyleBoxSizing::Content)
|
|
|
|
, mAlignContent(NS_STYLE_ALIGN_NORMAL)
|
|
|
|
, mAlignItems(NS_STYLE_ALIGN_NORMAL)
|
|
|
|
, mAlignSelf(NS_STYLE_ALIGN_AUTO)
|
|
|
|
, mJustifyContent(NS_STYLE_JUSTIFY_NORMAL)
|
2018-04-19 18:50:32 +03:00
|
|
|
, mSpecifiedJustifyItems(NS_STYLE_JUSTIFY_LEGACY)
|
2017-07-26 16:26:19 +03:00
|
|
|
, mJustifyItems(NS_STYLE_JUSTIFY_NORMAL)
|
2016-05-03 12:26:28 +03:00
|
|
|
, mJustifySelf(NS_STYLE_JUSTIFY_AUTO)
|
|
|
|
, mFlexDirection(NS_STYLE_FLEX_DIRECTION_ROW)
|
|
|
|
, mFlexWrap(NS_STYLE_FLEX_WRAP_NOWRAP)
|
|
|
|
, mObjectFit(NS_STYLE_OBJECT_FIT_FILL)
|
|
|
|
, mOrder(NS_STYLE_ORDER_INITIAL)
|
|
|
|
, mFlexGrow(0.0f)
|
|
|
|
, mFlexShrink(1.0f)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mZIndex(eStyleUnit_Auto)
|
2018-04-24 02:52:51 +03:00
|
|
|
, mColumnGap(eStyleUnit_Normal)
|
|
|
|
, mRowGap(eStyleUnit_Normal)
|
2014-03-11 02:54:13 +04:00
|
|
|
{
|
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);
|
2016-05-03 12:26:30 +03:00
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
mOffset.Set(side, autoCoord);
|
|
|
|
}
|
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)'.
|
2014-03-11 02:54:15 +04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStylePosition::~nsStylePosition()
|
2014-03-11 02:54:13 +04:00
|
|
|
{
|
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)
|
2017-07-26 16:26:19 +03:00
|
|
|
, mSpecifiedJustifyItems(aSource.mSpecifiedJustifyItems)
|
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)
|
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)
|
2018-04-24 02:52:51 +03:00
|
|
|
, mColumnGap(aSource.mColumnGap)
|
|
|
|
, mRowGap(aSource.mRowGap)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStylePosition);
|
2017-08-09 04:30:25 +03:00
|
|
|
|
|
|
|
if (aSource.mGridTemplateColumns) {
|
|
|
|
mGridTemplateColumns =
|
|
|
|
MakeUnique<nsStyleGridTemplate>(*aSource.mGridTemplateColumns);
|
|
|
|
}
|
|
|
|
if (aSource.mGridTemplateRows) {
|
|
|
|
mGridTemplateRows =
|
|
|
|
MakeUnique<nsStyleGridTemplate>(*aSource.mGridTemplateRows);
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2017-08-09 04:30:25 +03:00
|
|
|
static bool
|
|
|
|
IsGridTemplateEqual(const UniquePtr<nsStyleGridTemplate>& aOldData,
|
|
|
|
const UniquePtr<nsStyleGridTemplate>& aNewData)
|
|
|
|
{
|
|
|
|
if (aOldData == aNewData) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!aOldData || !aNewData) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return *aOldData == *aNewData;
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:22:02 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStylePosition::CalcDifference(const nsStylePosition& aNewData,
|
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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mZIndex != aNewData.mZIndex) {
|
2016-05-23 06:26:03 +03:00
|
|
|
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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mObjectFit != aNewData.mObjectFit ||
|
|
|
|
mObjectPosition != aNewData.mObjectPosition) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_NeedReflow;
|
2015-01-15 20:51:19 +03:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mOrder != aNewData.mOrder) {
|
2014-08-01 22:13:28 +04:00
|
|
|
// "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.)
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_AllReflowHints;
|
2014-08-01 22:13:28 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBoxSizing != aNewData.mBoxSizing) {
|
2009-10-30 06:43:52 +03:00
|
|
|
// Can affect both widths and heights; just a bad scene.
|
2016-05-23 06:26:03 +03:00
|
|
|
return 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)
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mAlignSelf != aNewData.mAlignSelf ||
|
|
|
|
mFlexBasis != aNewData.mFlexBasis ||
|
|
|
|
mFlexGrow != aNewData.mFlexGrow ||
|
|
|
|
mFlexShrink != aNewData.mFlexShrink) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return 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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mAlignItems != aNewData.mAlignItems ||
|
|
|
|
mFlexDirection != aNewData.mFlexDirection ||
|
|
|
|
mFlexWrap != aNewData.mFlexWrap) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return 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')
|
2017-08-09 04:30:25 +03:00
|
|
|
if (!IsGridTemplateEqual(mGridTemplateColumns,
|
|
|
|
aNewData.mGridTemplateColumns) ||
|
|
|
|
!IsGridTemplateEqual(mGridTemplateRows,
|
|
|
|
aNewData.mGridTemplateRows) ||
|
2016-06-21 04:47:54 +03:00
|
|
|
mGridTemplateAreas != aNewData.mGridTemplateAreas ||
|
|
|
|
mGridAutoColumnsMin != aNewData.mGridAutoColumnsMin ||
|
|
|
|
mGridAutoColumnsMax != aNewData.mGridAutoColumnsMax ||
|
|
|
|
mGridAutoRowsMin != aNewData.mGridAutoRowsMin ||
|
|
|
|
mGridAutoRowsMax != aNewData.mGridAutoRowsMax ||
|
|
|
|
mGridAutoFlow != aNewData.mGridAutoFlow) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_AllReflowHints;
|
2014-03-11 02:54:13 +04:00
|
|
|
}
|
|
|
|
|
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')
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mGridColumnStart != aNewData.mGridColumnStart ||
|
|
|
|
mGridColumnEnd != aNewData.mGridColumnEnd ||
|
|
|
|
mGridRowStart != aNewData.mGridRowStart ||
|
|
|
|
mGridRowEnd != aNewData.mGridRowEnd ||
|
2018-04-24 02:52:51 +03:00
|
|
|
mColumnGap != aNewData.mColumnGap ||
|
|
|
|
mRowGap != aNewData.mRowGap) {
|
2016-05-23 06:26:03 +03:00
|
|
|
return hint |
|
|
|
|
nsChangeHint_AllReflowHints;
|
2014-03-11 02:54:17 +04:00
|
|
|
}
|
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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mJustifyContent != aNewData.mJustifyContent ||
|
|
|
|
mJustifyItems != aNewData.mJustifyItems ||
|
|
|
|
mJustifySelf != aNewData.mJustifySelf) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow;
|
2012-07-07 04:06:19 +04:00
|
|
|
}
|
|
|
|
|
2017-07-26 16:26:19 +03:00
|
|
|
// No need to do anything if mSpecifiedJustifyItems changes, as long as
|
|
|
|
// mJustifyItems (tested above) is unchanged.
|
|
|
|
if (mSpecifiedJustifyItems != aNewData.mSpecifiedJustifyItems) {
|
|
|
|
hint |= nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mAlignContent != aNewData.mAlignContent) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow;
|
2013-12-05 22:57:50 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
bool widthChanged = mWidth != aNewData.mWidth ||
|
|
|
|
mMinWidth != aNewData.mMinWidth ||
|
|
|
|
mMaxWidth != aNewData.mMaxWidth;
|
|
|
|
bool heightChanged = mHeight != aNewData.mHeight ||
|
|
|
|
mMinHeight != aNewData.mMinHeight ||
|
|
|
|
mMaxHeight != aNewData.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
|
2018-03-22 21:20:41 +03:00
|
|
|
// ComputedStyle::CalcStyleDifference, which can lead to incorrect
|
2015-10-23 02:57:35 +03:00
|
|
|
// 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) {
|
2017-05-26 00:46:03 +03:00
|
|
|
hint |= nsChangeHint_ReflowHintsForBSizeChange;
|
2015-10-23 02:57:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isVertical ? heightChanged : widthChanged) {
|
2017-05-26 00:46:03 +03:00
|
|
|
hint |= nsChangeHint_ReflowHintsForISizeChange;
|
2015-10-23 02:57:35 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (widthChanged || heightChanged) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2015-10-23 02:57:35 +03:00
|
|
|
}
|
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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mOffset != aNewData.mOffset) {
|
|
|
|
if (IsAutonessEqual(mOffset, aNewData.mOffset)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RecomputePosition |
|
|
|
|
nsChangeHint_UpdateParentOverflow;
|
2013-09-10 04:08:41 +04:00
|
|
|
} else {
|
2016-05-23 06:26:03 +03:00
|
|
|
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
|
2018-03-22 21:20:41 +03:00
|
|
|
nsStylePosition::UsedAlignSelf(ComputedStyle* aParent) const
|
2015-11-03 17:18:06 +03:00
|
|
|
{
|
|
|
|
if (mAlignSelf != NS_STYLE_ALIGN_AUTO) {
|
2015-11-28 23:37:44 +03:00
|
|
|
return mAlignSelf;
|
2015-11-03 17:18:06 +03:00
|
|
|
}
|
|
|
|
if (MOZ_LIKELY(aParent)) {
|
2016-10-03 23:05:35 +03:00
|
|
|
auto parentAlignItems = aParent->StylePosition()->mAlignItems;
|
2015-11-03 17:18:06 +03:00
|
|
|
MOZ_ASSERT(!(parentAlignItems & NS_STYLE_ALIGN_LEGACY),
|
|
|
|
"align-items can't have 'legacy'");
|
2015-11-28 23:37:44 +03:00
|
|
|
return parentAlignItems;
|
2015-11-03 17:18:06 +03:00
|
|
|
}
|
2016-01-05 23:27:13 +03:00
|
|
|
return NS_STYLE_ALIGN_NORMAL;
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
|
2015-11-03 17:18:05 +03:00
|
|
|
uint8_t
|
2018-03-22 21:20:41 +03:00
|
|
|
nsStylePosition::UsedJustifySelf(ComputedStyle* aParent) const
|
2015-11-03 17:18:05 +03:00
|
|
|
{
|
|
|
|
if (mJustifySelf != NS_STYLE_JUSTIFY_AUTO) {
|
2015-11-28 23:37:44 +03:00
|
|
|
return mJustifySelf;
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
if (MOZ_LIKELY(aParent)) {
|
2017-07-26 16:26:19 +03:00
|
|
|
auto inheritedJustifyItems = aParent->StylePosition()->mJustifyItems;
|
2015-11-28 23:37:44 +03:00
|
|
|
return inheritedJustifyItems & ~NS_STYLE_JUSTIFY_LEGACY;
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
2016-01-05 23:27:13 +03:00
|
|
|
return NS_STYLE_JUSTIFY_NORMAL;
|
2015-11-03 17:18:05 +03:00
|
|
|
}
|
|
|
|
|
2017-08-09 04:30:25 +03:00
|
|
|
static StaticAutoPtr<nsStyleGridTemplate> sDefaultGridTemplate;
|
|
|
|
|
|
|
|
static const nsStyleGridTemplate&
|
|
|
|
DefaultGridTemplate()
|
|
|
|
{
|
|
|
|
if (!sDefaultGridTemplate) {
|
|
|
|
sDefaultGridTemplate = new nsStyleGridTemplate;
|
|
|
|
ClearOnShutdown(&sDefaultGridTemplate);
|
|
|
|
}
|
|
|
|
return *sDefaultGridTemplate;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsStyleGridTemplate&
|
|
|
|
nsStylePosition::GridTemplateColumns() const
|
|
|
|
{
|
|
|
|
return mGridTemplateColumns ? *mGridTemplateColumns : DefaultGridTemplate();
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsStyleGridTemplate&
|
|
|
|
nsStylePosition::GridTemplateRows() const
|
|
|
|
{
|
|
|
|
return mGridTemplateRows ? *mGridTemplateRows : DefaultGridTemplate();
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleTable
|
|
|
|
//
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleTable::nsStyleTable(const nsPresContext* aContext)
|
2016-05-03 12:26:28 +03:00
|
|
|
: mLayoutStrategy(NS_STYLE_TABLE_LAYOUT_AUTO)
|
|
|
|
, mSpan(1)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTable);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleTable::~nsStyleTable()
|
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
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
nsChangeHint
|
|
|
|
nsStyleTable::CalcDifference(const nsStyleTable& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mSpan != aNewData.mSpan ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mLayoutStrategy != aNewData.mLayoutStrategy) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------
|
|
|
|
// nsStyleTableBorder
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleTableBorder::nsStyleTableBorder(const nsPresContext* aContext)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mBorderSpacingCol(0)
|
|
|
|
, mBorderSpacingRow(0)
|
|
|
|
, mBorderCollapse(NS_STYLE_BORDER_SEPARATE)
|
|
|
|
, mCaptionSide(NS_STYLE_CAPTION_SIDE_TOP)
|
|
|
|
, mEmptyCells(NS_STYLE_TABLE_EMPTY_CELLS_SHOW)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTableBorder);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleTableBorder::~nsStyleTableBorder()
|
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
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleTableBorder::CalcDifference(const nsStyleTableBorder& aNewData) 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).
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBorderCollapse != aNewData.mBorderCollapse) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2003-02-13 22:06:18 +03:00
|
|
|
}
|
2016-05-03 12:26:29 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if ((mCaptionSide == aNewData.mCaptionSide) &&
|
|
|
|
(mBorderSpacingCol == aNewData.mBorderSpacingCol) &&
|
|
|
|
(mBorderSpacingRow == aNewData.mBorderSpacingRow)) {
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mEmptyCells == aNewData.mEmptyCells) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
return NS_STYLE_HINT_VISUAL;
|
2016-07-06 08:06:13 +03:00
|
|
|
} else {
|
2016-07-06 06:40:49 +03:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleColor
|
|
|
|
//
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleColor::nsStyleColor(const nsPresContext* aContext)
|
|
|
|
: mColor(aContext->DefaultColor())
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColor);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleColor::nsStyleColor(const nsStyleColor& aSource)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mColor(aSource.mColor)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleColor);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleColor::CalcDifference(const nsStyleColor& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mColor == aNewData.mColor) {
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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 ||
|
2017-04-25 21:48:39 +03:00
|
|
|
mMozLegacySyntax != aOther.mMozLegacySyntax ||
|
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 ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mRadiusY != aOther.mRadiusY) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-01 19:53:40 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mStops.Length() != aOther.mStops.Length()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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 ||
|
2016-07-06 08:06:13 +03:00
|
|
|
(!stop1.mIsInterpolationHint && stop1.mColor != stop2.mColor)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleGradient::nsStyleGradient()
|
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)
|
2017-04-25 21:48:39 +03:00
|
|
|
, mMozLegacySyntax(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++) {
|
2018-06-07 08:55:26 +03:00
|
|
|
if (mStops[i].mColor.MaybeTransparent()) {
|
|
|
|
// We don't know the foreground color here, so if it's being used
|
|
|
|
// we must assume it might be transparent.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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++) {
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mStops[i].mLocation.IsCalcUnit()) {
|
2012-10-04 09:31:56 +04:00
|
|
|
return true;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2012-10-04 09:31:56 +04:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2016-11-02 11:58:31 +03:00
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// nsStyleImageRequest
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Runnable to release the nsStyleImageRequest's mRequestProxy,
|
2017-03-14 16:29:55 +03:00
|
|
|
* mImageValue and mImageTracker on the main thread, and to perform
|
2016-11-02 11:58:31 +03:00
|
|
|
* any necessary unlocking and untracking of the image.
|
|
|
|
*/
|
|
|
|
class StyleImageRequestCleanupTask : public mozilla::Runnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef nsStyleImageRequest::Mode Mode;
|
|
|
|
|
|
|
|
StyleImageRequestCleanupTask(Mode aModeFlags,
|
|
|
|
already_AddRefed<imgRequestProxy> aRequestProxy,
|
|
|
|
already_AddRefed<css::ImageValue> aImageValue,
|
|
|
|
already_AddRefed<ImageTracker> aImageTracker)
|
2017-06-12 22:34:10 +03:00
|
|
|
: mozilla::Runnable("StyleImageRequestCleanupTask")
|
|
|
|
, mModeFlags(aModeFlags)
|
2016-11-02 11:58:31 +03:00
|
|
|
, mRequestProxy(aRequestProxy)
|
|
|
|
, mImageValue(aImageValue)
|
|
|
|
, mImageTracker(aImageTracker)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-02-06 09:46:57 +03:00
|
|
|
NS_IMETHOD Run() final
|
2016-11-02 11:58:31 +03:00
|
|
|
{
|
2017-03-14 16:29:55 +03:00
|
|
|
MOZ_ASSERT(!mRequestProxy || NS_IsMainThread(),
|
|
|
|
"If mRequestProxy is non-null, we need to run on main thread!");
|
2016-11-02 11:58:31 +03:00
|
|
|
|
|
|
|
if (!mRequestProxy) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-11-02 11:58:32 +03:00
|
|
|
if (mModeFlags & Mode::Track) {
|
|
|
|
MOZ_ASSERT(mImageTracker);
|
|
|
|
mImageTracker->Remove(mRequestProxy);
|
|
|
|
} else {
|
2016-11-02 11:58:31 +03:00
|
|
|
mRequestProxy->UnlockImage();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mModeFlags & Mode::Discard) {
|
|
|
|
mRequestProxy->RequestDiscard();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2017-03-14 16:29:55 +03:00
|
|
|
virtual ~StyleImageRequestCleanupTask()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mImageValue->mRequests.Count() == 0 || NS_IsMainThread(),
|
|
|
|
"If mImageValue has any mRequests, we need to run on main "
|
|
|
|
"thread to release ImageValues!");
|
|
|
|
MOZ_ASSERT((!mRequestProxy && !mImageTracker) || NS_IsMainThread(),
|
|
|
|
"mRequestProxy and mImageTracker's destructor need to run "
|
|
|
|
"on the main thread!");
|
|
|
|
}
|
2016-11-02 11:58:31 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
Mode mModeFlags;
|
|
|
|
// Since we always dispatch this runnable to the main thread, these will be
|
|
|
|
// released on the main thread when the runnable itself is released.
|
|
|
|
RefPtr<imgRequestProxy> mRequestProxy;
|
|
|
|
RefPtr<css::ImageValue> mImageValue;
|
|
|
|
RefPtr<ImageTracker> mImageTracker;
|
|
|
|
};
|
|
|
|
|
|
|
|
nsStyleImageRequest::nsStyleImageRequest(Mode aModeFlags,
|
2018-05-22 14:02:55 +03:00
|
|
|
css::ImageValue* aImageValue)
|
2017-05-02 11:20:01 +03:00
|
|
|
: mImageValue(aImageValue)
|
|
|
|
, mModeFlags(aModeFlags)
|
|
|
|
, mResolved(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-11-02 11:58:31 +03:00
|
|
|
nsStyleImageRequest::~nsStyleImageRequest()
|
|
|
|
{
|
|
|
|
// We may or may not be being destroyed on the main thread. To clean
|
|
|
|
// up, we must untrack and unlock the image (depending on mModeFlags),
|
|
|
|
// and release mRequestProxy and mImageValue, all on the main thread.
|
|
|
|
{
|
|
|
|
RefPtr<StyleImageRequestCleanupTask> task =
|
|
|
|
new StyleImageRequestCleanupTask(mModeFlags,
|
|
|
|
mRequestProxy.forget(),
|
|
|
|
mImageValue.forget(),
|
|
|
|
mImageTracker.forget());
|
2017-05-08 10:08:46 +03:00
|
|
|
if (NS_IsMainThread()) {
|
2016-11-02 11:58:31 +03:00
|
|
|
task->Run();
|
|
|
|
} else {
|
2017-05-08 10:08:46 +03:00
|
|
|
if (mDocGroup) {
|
2017-07-26 11:13:35 +03:00
|
|
|
mDocGroup->Dispatch(TaskCategory::Other, task.forget());
|
2017-05-08 10:08:46 +03:00
|
|
|
} else {
|
|
|
|
// if Resolve was not called at some point, mDocGroup is not set.
|
2017-08-23 03:52:22 +03:00
|
|
|
SystemGroup::Dispatch(TaskCategory::Other, task.forget());
|
2017-05-08 10:08:46 +03:00
|
|
|
}
|
2016-11-02 11:58:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(!mRequestProxy);
|
|
|
|
MOZ_ASSERT(!mImageValue);
|
|
|
|
MOZ_ASSERT(!mImageTracker);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2018-02-22 21:44:44 +03:00
|
|
|
nsStyleImageRequest::Resolve(
|
2018-02-22 22:03:43 +03:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
const nsStyleImageRequest* aOldImageRequest)
|
2016-11-02 11:58:31 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(!IsResolved(), "already resolved");
|
2017-03-14 16:29:55 +03:00
|
|
|
MOZ_ASSERT(aPresContext);
|
2016-11-02 11:58:31 +03:00
|
|
|
|
|
|
|
mResolved = true;
|
2017-04-11 17:56:41 +03:00
|
|
|
|
|
|
|
nsIDocument* doc = aPresContext->Document();
|
|
|
|
nsIURI* docURI = doc->GetDocumentURI();
|
|
|
|
if (GetImageValue()->HasRef()) {
|
|
|
|
bool isEqualExceptRef = false;
|
|
|
|
RefPtr<nsIURI> imageURI = GetImageURI();
|
2018-04-14 18:24:45 +03:00
|
|
|
if (!imageURI) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(imageURI->EqualsExceptRef(docURI, &isEqualExceptRef)) &&
|
|
|
|
isEqualExceptRef) {
|
2017-04-11 17:56:41 +03:00
|
|
|
// Prevent loading an internal resource.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 22:03:43 +03:00
|
|
|
// TODO(emilio, bug 1440442): This is a hackaround to avoid flickering due the
|
|
|
|
// lack of non-http image caching in imagelib (bug 1406134), which causes
|
|
|
|
// stuff like bug 1439285. Cleanest fix if that doesn't get fixed is bug
|
|
|
|
// 1440305, but that seems too risky, and a lot of work to do before 60.
|
|
|
|
//
|
|
|
|
// Once that's fixed, the "old style" argument to FinishStyle can go away.
|
|
|
|
if (aPresContext->IsChrome() && aOldImageRequest &&
|
|
|
|
aOldImageRequest->IsResolved() && DefinitelyEquals(*aOldImageRequest)) {
|
|
|
|
MOZ_ASSERT(aOldImageRequest->mDocGroup == doc->GetDocGroup());
|
|
|
|
MOZ_ASSERT(mModeFlags == aOldImageRequest->mModeFlags);
|
|
|
|
|
|
|
|
mDocGroup = aOldImageRequest->mDocGroup;
|
|
|
|
mImageValue = aOldImageRequest->mImageValue;
|
|
|
|
mRequestProxy = aOldImageRequest->mRequestProxy;
|
|
|
|
} else {
|
|
|
|
mDocGroup = doc->GetDocGroup();
|
|
|
|
mImageValue->Initialize(doc);
|
2018-05-22 14:34:17 +03:00
|
|
|
imgRequestProxy* request = mImageValue->mRequests.GetWeak(doc);
|
|
|
|
if (aPresContext->IsDynamic()) {
|
|
|
|
mRequestProxy = request;
|
|
|
|
} else if (request) {
|
|
|
|
request->GetStaticRequest(doc, getter_AddRefs(mRequestProxy));
|
|
|
|
}
|
2018-02-22 22:03:43 +03:00
|
|
|
}
|
2016-11-02 11:58:31 +03:00
|
|
|
|
|
|
|
if (!mRequestProxy) {
|
|
|
|
// The URL resolution or image load failed.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-02 11:58:32 +03:00
|
|
|
if (mModeFlags & Mode::Track) {
|
2018-02-22 22:03:43 +03:00
|
|
|
mImageTracker = doc->ImageTracker();
|
2016-11-02 11:58:32 +03:00
|
|
|
}
|
|
|
|
|
2016-11-02 11:58:31 +03:00
|
|
|
MaybeTrackAndLock();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImageRequest::MaybeTrackAndLock()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ASSERT(IsResolved());
|
|
|
|
MOZ_ASSERT(mRequestProxy);
|
|
|
|
|
|
|
|
if (mModeFlags & Mode::Track) {
|
2016-11-02 11:58:32 +03:00
|
|
|
MOZ_ASSERT(mImageTracker);
|
2016-11-02 11:58:31 +03:00
|
|
|
mImageTracker->Add(mRequestProxy);
|
2016-11-02 11:58:32 +03:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(!mImageTracker);
|
2016-11-02 11:58:31 +03:00
|
|
|
mRequestProxy->LockImage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsStyleImageRequest::DefinitelyEquals(const nsStyleImageRequest& aOther) const
|
|
|
|
{
|
|
|
|
return DefinitelyEqualURIs(mImageValue, aOther.mImageValue);
|
|
|
|
}
|
|
|
|
|
2016-08-01 03:23:00 +03:00
|
|
|
// --------------------
|
|
|
|
// CachedBorderImageData
|
|
|
|
//
|
2016-08-01 03:24:00 +03:00
|
|
|
void
|
|
|
|
CachedBorderImageData::SetCachedSVGViewportSize(
|
|
|
|
const mozilla::Maybe<nsSize>& aSVGViewportSize)
|
|
|
|
{
|
|
|
|
mCachedSVGViewportSize = aSVGViewportSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
const mozilla::Maybe<nsSize>&
|
|
|
|
CachedBorderImageData::GetCachedSVGViewportSize()
|
|
|
|
{
|
|
|
|
return mCachedSVGViewportSize;
|
|
|
|
}
|
|
|
|
|
2017-02-20 15:39:05 +03:00
|
|
|
struct PurgeCachedImagesTask : mozilla::Runnable
|
|
|
|
{
|
2017-06-12 22:34:10 +03:00
|
|
|
PurgeCachedImagesTask() : mozilla::Runnable("PurgeCachedImagesTask") {}
|
2018-02-06 09:46:57 +03:00
|
|
|
NS_IMETHOD Run() final
|
2017-02-20 15:39:05 +03:00
|
|
|
{
|
|
|
|
mSubImages.Clear();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMArray<imgIContainer> mSubImages;
|
|
|
|
};
|
|
|
|
|
2016-08-01 03:23:00 +03:00
|
|
|
void
|
|
|
|
CachedBorderImageData::PurgeCachedImages()
|
|
|
|
{
|
2017-02-20 15:39:05 +03:00
|
|
|
if (ServoStyleSet::IsInServoTraversal()) {
|
|
|
|
RefPtr<PurgeCachedImagesTask> task = new PurgeCachedImagesTask();
|
|
|
|
task->mSubImages.SwapElements(mSubImages);
|
|
|
|
// This will run the task immediately if we're already on the main thread,
|
|
|
|
// but that is fine.
|
|
|
|
NS_DispatchToMainThread(task.forget());
|
|
|
|
} else {
|
|
|
|
mSubImages.Clear();
|
|
|
|
}
|
2016-08-01 03:23:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CachedBorderImageData::SetSubImage(uint8_t aIndex, imgIContainer* aSubImage)
|
|
|
|
{
|
|
|
|
mSubImages.ReplaceObjectAt(aSubImage, aIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
imgIContainer*
|
|
|
|
CachedBorderImageData::GetSubImage(uint8_t aIndex)
|
|
|
|
{
|
|
|
|
imgIContainer* subImage = nullptr;
|
|
|
|
if (aIndex < mSubImages.Count())
|
|
|
|
subImage = mSubImages[aIndex];
|
|
|
|
return subImage;
|
|
|
|
}
|
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleImage
|
|
|
|
//
|
|
|
|
|
|
|
|
nsStyleImage::nsStyleImage()
|
|
|
|
: mType(eStyleImageType_Null)
|
2018-06-14 12:54:03 +03:00
|
|
|
, mImage(nullptr)
|
2012-07-30 18:20:58 +04:00
|
|
|
, mCropRect(nullptr)
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleImage::~nsStyleImage()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != eStyleImageType_Null) {
|
2009-08-22 00:39:25 +04:00
|
|
|
SetNull();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleImage::nsStyleImage(const nsStyleImage& aOther)
|
|
|
|
: mType(eStyleImageType_Null)
|
2012-07-30 18:20:58 +04:00
|
|
|
, mCropRect(nullptr)
|
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)
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (this != &aOther) {
|
2009-08-22 00:39:25 +04:00
|
|
|
DoCopy(aOther);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::DoCopy(const nsStyleImage& aOther)
|
|
|
|
{
|
|
|
|
SetNull();
|
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (aOther.mType == eStyleImageType_Image) {
|
2016-11-02 11:58:32 +03:00
|
|
|
SetImageRequest(do_AddRef(aOther.mImage));
|
2016-07-06 08:06:13 +03:00
|
|
|
} else if (aOther.mType == eStyleImageType_Gradient) {
|
2009-08-22 00:39:25 +04:00
|
|
|
SetGradientData(aOther.mGradient);
|
2016-07-06 08:06:13 +03:00
|
|
|
} else if (aOther.mType == eStyleImageType_Element) {
|
2017-04-09 16:44:36 +03:00
|
|
|
SetElementId(do_AddRef(aOther.mElementId));
|
2017-03-30 18:16:46 +03:00
|
|
|
} else if (aOther.mType == eStyleImageType_URL) {
|
|
|
|
SetURLValue(do_AddRef(aOther.mURLValue));
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-29 01:06:02 +03:00
|
|
|
UniquePtr<nsStyleSides> cropRectCopy;
|
|
|
|
if (aOther.mCropRect) {
|
|
|
|
cropRectCopy = MakeUnique<nsStyleSides>(*aOther.mCropRect.get());
|
|
|
|
}
|
2018-05-30 22:15:35 +03:00
|
|
|
SetCropRect(std::move(cropRectCopy));
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::SetNull()
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Gradient) {
|
2009-08-22 00:39:25 +04:00
|
|
|
mGradient->Release();
|
2016-07-06 08:06:13 +03:00
|
|
|
} else if (mType == eStyleImageType_Image) {
|
2009-08-22 00:39:25 +04:00
|
|
|
NS_RELEASE(mImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
} else if (mType == eStyleImageType_Element) {
|
2017-04-09 16:44:36 +03:00
|
|
|
NS_RELEASE(mElementId);
|
2017-03-30 18:16:46 +03:00
|
|
|
} else if (mType == eStyleImageType_URL) {
|
|
|
|
NS_RELEASE(mURLValue);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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
|
2016-11-02 11:58:32 +03:00
|
|
|
nsStyleImage::SetImageRequest(already_AddRefed<nsStyleImageRequest> aImage)
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
2016-11-02 11:58:32 +03:00
|
|
|
RefPtr<nsStyleImageRequest> image = aImage;
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != eStyleImageType_Null) {
|
2009-08-22 00:39:25 +04:00
|
|
|
SetNull();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-11-02 11:58:32 +03:00
|
|
|
if (image) {
|
|
|
|
mImage = image.forget().take();
|
2009-08-22 00:39:25 +04:00
|
|
|
mType = eStyleImageType_Image;
|
|
|
|
}
|
2016-08-01 03:23:00 +03:00
|
|
|
if (mCachedBIData) {
|
|
|
|
mCachedBIData->PurgeCachedImages();
|
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImage::SetGradientData(nsStyleGradient* aGradient)
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (aGradient) {
|
2009-08-22 00:39:25 +04:00
|
|
|
aGradient->AddRef();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != eStyleImageType_Null) {
|
2009-08-22 00:39:25 +04:00
|
|
|
SetNull();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
if (aGradient) {
|
|
|
|
mGradient = aGradient;
|
|
|
|
mType = eStyleImageType_Gradient;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-13 17:33:37 +04:00
|
|
|
void
|
2017-10-03 01:05:19 +03:00
|
|
|
nsStyleImage::SetElementId(already_AddRefed<nsAtom> aElementId)
|
2010-08-13 17:33:37 +04:00
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != eStyleImageType_Null) {
|
2010-08-13 17:33:37 +04:00
|
|
|
SetNull();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2010-08-13 17:33:37 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
if (RefPtr<nsAtom> atom = aElementId) {
|
2017-04-09 16:44:36 +03:00
|
|
|
mElementId = atom.forget().take();
|
2010-08-13 17:33:37 +04:00
|
|
|
mType = eStyleImageType_Element;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
void
|
2016-07-29 01:06:02 +03:00
|
|
|
nsStyleImage::SetCropRect(UniquePtr<nsStyleSides> aCropRect)
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
2018-05-30 22:15:35 +03:00
|
|
|
mCropRect = std::move(aCropRect);
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2017-03-30 18:16:46 +03:00
|
|
|
void
|
|
|
|
nsStyleImage::SetURLValue(already_AddRefed<URLValue> aValue)
|
|
|
|
{
|
|
|
|
RefPtr<URLValue> value = aValue;
|
|
|
|
|
|
|
|
if (mType != eStyleImageType_Null) {
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
mURLValue = value.forget().take();
|
|
|
|
mType = eStyleImageType_URL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-03-09 08:03:32 +03:00
|
|
|
already_AddRefed<nsIURI>
|
|
|
|
nsStyleImageRequest::GetImageURI() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
|
|
|
|
if (mRequestProxy) {
|
|
|
|
mRequestProxy->GetURI(getter_AddRefs(uri));
|
|
|
|
if (uri) {
|
|
|
|
return uri.forget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we had some problem resolving the mRequestProxy, use the URL stored
|
|
|
|
// in the mImageValue.
|
|
|
|
if (!mImageValue) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
uri = mImageValue->GetURI();
|
|
|
|
return uri.forget();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2017-04-21 22:28:20 +03:00
|
|
|
MOZ_ASSERT(mType == eStyleImageType_Image,
|
|
|
|
"This function is designed to be used only when mType"
|
|
|
|
"is eStyleImageType_Image.");
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-11-02 11:58:32 +03:00
|
|
|
imgRequestProxy* req = GetImageData();
|
|
|
|
if (!req) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-22 00:39:25 +04:00
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
2016-11-02 11:58:32 +03:00
|
|
|
req->GetImage(getter_AddRefs(imageContainer));
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!imageContainer) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
nsIntSize imageSize;
|
|
|
|
imageContainer->GetWidth(&imageSize.width);
|
|
|
|
imageContainer->GetHeight(&imageSize.height);
|
2016-07-06 08:06:13 +03:00
|
|
|
if (imageSize.width <= 0 || imageSize.height <= 0) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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);
|
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (aIsEntireImage) {
|
2011-04-19 07:07:23 +04:00
|
|
|
*aIsEntireImage = aActualCropRect.IsEqualInterior(imageRect);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2016-12-23 10:07:45 +03:00
|
|
|
bool
|
2012-10-13 00:04:03 +04:00
|
|
|
nsStyleImage::StartDecoding() const
|
2009-09-13 02:44:18 +04:00
|
|
|
{
|
2016-08-15 04:57:13 +03:00
|
|
|
if (mType == eStyleImageType_Image) {
|
2016-11-02 11:58:32 +03:00
|
|
|
imgRequestProxy* req = GetImageData();
|
|
|
|
if (!req) {
|
2016-12-23 10:07:45 +03:00
|
|
|
return false;
|
2016-11-02 11:58:32 +03:00
|
|
|
}
|
2016-12-25 09:18:08 +03:00
|
|
|
return req->StartDecodingWithResult(imgIContainer::FLAG_ASYNC_NOTIFY);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2016-12-23 10:07:45 +03:00
|
|
|
// null image types always return false from IsComplete, so we do the same here.
|
|
|
|
return mType != eStyleImageType_Null ? true : false;
|
2009-09-13 02:44:18 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-08-22 00:39:25 +04:00
|
|
|
nsStyleImage::IsOpaque() const
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!IsComplete()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Gradient) {
|
2011-01-03 04:48:09 +03:00
|
|
|
return mGradient->IsOpaque();
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2017-04-11 17:56:41 +03:00
|
|
|
if (mType == eStyleImageType_Element || mType == eStyleImageType_URL) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2010-08-13 17:33:37 +04:00
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mType == eStyleImageType_Image, "unexpected image type");
|
2016-11-02 11:58:32 +03:00
|
|
|
MOZ_ASSERT(GetImageData(), "should've returned earlier above");
|
2009-08-22 00:39:25 +04:00
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
2016-11-02 11:58:32 +03:00
|
|
|
GetImageData()->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.
|
2016-08-23 05:15:38 +03:00
|
|
|
if (imageContainer->WillDrawOpaqueNow()) {
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!mCropRect) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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;
|
2017-04-21 22:28:20 +03:00
|
|
|
return ComputeActualCropRect(actualCropRect) && !actualCropRect.IsEmpty();
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
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:
|
2017-03-30 18:16:46 +03:00
|
|
|
case eStyleImageType_URL:
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-11-02 11:58:32 +03:00
|
|
|
case eStyleImageType_Image: {
|
2017-07-26 06:21:30 +03:00
|
|
|
if (!IsResolved()) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-11-02 11:58:32 +03:00
|
|
|
imgRequestProxy* req = GetImageData();
|
|
|
|
if (!req) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t status = imgIRequest::STATUS_ERROR;
|
2016-11-02 11:58:32 +03:00
|
|
|
return NS_SUCCEEDED(req->GetImageStatus(&status)) &&
|
2009-08-22 00:39:25 +04:00
|
|
|
(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:
|
2017-03-30 18:16:46 +03:00
|
|
|
case eStyleImageType_URL:
|
2013-07-19 12:40:02 +04:00
|
|
|
return true;
|
2016-11-02 11:58:32 +03:00
|
|
|
case eStyleImageType_Image: {
|
|
|
|
imgRequestProxy* req = GetImageData();
|
|
|
|
if (!req) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-07-19 12:40:02 +04:00
|
|
|
uint32_t status = imgIRequest::STATUS_ERROR;
|
2016-11-02 11:58:32 +03:00
|
|
|
return NS_SUCCEEDED(req->GetImageStatus(&status)) &&
|
2013-07-19 12:40:02 +04:00
|
|
|
!(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
|
2016-07-29 01:06:02 +03:00
|
|
|
EqualRects(const UniquePtr<nsStyleSides>& aRect1, const UniquePtr<nsStyleSides>& aRect2)
|
2009-08-22 00:39:25 +04:00
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != aOther.mType) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!EqualRects(mCropRect, aOther.mCropRect)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Image) {
|
2016-11-02 11:58:32 +03:00
|
|
|
return DefinitelyEqualImages(mImage, aOther.mImage);
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Gradient) {
|
2009-08-22 00:39:25 +04:00
|
|
|
return *mGradient == *aOther.mGradient;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2009-08-22 00:39:25 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType == eStyleImageType_Element) {
|
2017-04-09 16:44:36 +03:00
|
|
|
return mElementId == aOther.mElementId;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2010-08-13 17:33:37 +04:00
|
|
|
|
2017-03-30 18:16:46 +03:00
|
|
|
if (mType == eStyleImageType_URL) {
|
|
|
|
return DefinitelyEqualURIs(mURLValue, aOther.mURLValue);
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-08-22 00:39:25 +04:00
|
|
|
}
|
|
|
|
|
2016-08-01 03:24:00 +03:00
|
|
|
void
|
|
|
|
nsStyleImage::PurgeCacheForViewportChange(
|
|
|
|
const mozilla::Maybe<nsSize>& aSVGViewportSize,
|
|
|
|
const bool aHasIntrinsicRatio) const
|
|
|
|
{
|
|
|
|
EnsureCachedBIData();
|
|
|
|
|
|
|
|
// If we're redrawing with a different viewport-size than we used for our
|
|
|
|
// cached subimages, then we can't trust that our subimages are valid;
|
|
|
|
// any percent sizes/positions in our SVG doc may be different now. Purge!
|
|
|
|
// (We don't have to purge if the SVG document has an intrinsic ratio,
|
|
|
|
// though, because the actual size of elements in SVG documant's coordinate
|
|
|
|
// axis are fixed in this case.)
|
|
|
|
if (aSVGViewportSize != mCachedBIData->GetCachedSVGViewportSize() &&
|
|
|
|
!aHasIntrinsicRatio) {
|
|
|
|
mCachedBIData->PurgeCachedImages();
|
|
|
|
mCachedBIData->SetCachedSVGViewportSize(aSVGViewportSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-09 08:03:32 +03:00
|
|
|
already_AddRefed<nsIURI>
|
|
|
|
nsStyleImage::GetImageURI() const
|
|
|
|
{
|
|
|
|
if (mType != eStyleImageType_Image) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri = mImage->GetImageURI();
|
|
|
|
return uri.forget();
|
|
|
|
}
|
|
|
|
|
2017-03-30 18:16:46 +03:00
|
|
|
css::URLValueData*
|
|
|
|
nsStyleImage::GetURLValue() const
|
|
|
|
{
|
|
|
|
if (mType == eStyleImageType_Image) {
|
|
|
|
return mImage->GetImageValue();
|
|
|
|
} else if (mType == eStyleImageType_URL) {
|
|
|
|
return mURLValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
2016-01-28 08:24:00 +03:00
|
|
|
// nsStyleImageLayers
|
2001-06-01 02:19:43 +04:00
|
|
|
//
|
|
|
|
|
2016-08-17 04:37:48 +03:00
|
|
|
const nsCSSPropertyID nsStyleImageLayers::kBackgroundLayerTable[] = {
|
2016-01-28 08:28:00 +03:00
|
|
|
eCSSProperty_background, // shorthand
|
|
|
|
eCSSProperty_background_color, // color
|
|
|
|
eCSSProperty_background_image, // image
|
|
|
|
eCSSProperty_background_repeat, // repeat
|
2016-04-29 21:12:10 +03:00
|
|
|
eCSSProperty_background_position_x, // positionX
|
|
|
|
eCSSProperty_background_position_y, // positionY
|
2016-01-28 08:28:00 +03:00
|
|
|
eCSSProperty_background_clip, // clip
|
|
|
|
eCSSProperty_background_origin, // origin
|
|
|
|
eCSSProperty_background_size, // size
|
|
|
|
eCSSProperty_background_attachment, // attachment
|
|
|
|
eCSSProperty_UNKNOWN, // maskMode
|
|
|
|
eCSSProperty_UNKNOWN // composite
|
|
|
|
};
|
|
|
|
|
2016-08-17 04:37:48 +03:00
|
|
|
const nsCSSPropertyID nsStyleImageLayers::kMaskLayerTable[] = {
|
2016-01-28 08:28:00 +03:00
|
|
|
eCSSProperty_mask, // shorthand
|
|
|
|
eCSSProperty_UNKNOWN, // color
|
|
|
|
eCSSProperty_mask_image, // image
|
|
|
|
eCSSProperty_mask_repeat, // repeat
|
2016-04-29 21:12:10 +03:00
|
|
|
eCSSProperty_mask_position_x, // positionX
|
|
|
|
eCSSProperty_mask_position_y, // positionY
|
2016-01-28 08:28:00 +03:00
|
|
|
eCSSProperty_mask_clip, // clip
|
|
|
|
eCSSProperty_mask_origin, // origin
|
|
|
|
eCSSProperty_mask_size, // size
|
|
|
|
eCSSProperty_UNKNOWN, // attachment
|
|
|
|
eCSSProperty_mask_mode, // maskMode
|
|
|
|
eCSSProperty_mask_composite // composite
|
|
|
|
};
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsStyleImageLayers::nsStyleImageLayers(nsStyleImageLayers::LayerType aType)
|
2009-02-20 08:29:21 +03:00
|
|
|
: mAttachmentCount(1)
|
|
|
|
, mClipCount(1)
|
|
|
|
, mOriginCount(1)
|
|
|
|
, mRepeatCount(1)
|
2016-04-29 21:12:10 +03:00
|
|
|
, mPositionXCount(1)
|
|
|
|
, mPositionYCount(1)
|
2009-02-20 08:29:21 +03:00
|
|
|
, mImageCount(1)
|
2009-05-28 22:09:05 +04:00
|
|
|
, mSizeCount(1)
|
2016-01-28 08:28:00 +03:00
|
|
|
, mMaskModeCount(1)
|
2013-11-08 19:07:36 +04:00
|
|
|
, mBlendModeCount(1)
|
2016-01-28 08:28:00 +03:00
|
|
|
, mCompositeCount(1)
|
2016-04-19 02:51:16 +03:00
|
|
|
, mLayers(nsStyleAutoArray<Layer>::WITH_SINGLE_INITIAL_ELEMENT)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-01-28 08:24:00 +03:00
|
|
|
MOZ_COUNT_CTOR(nsStyleImageLayers);
|
2016-06-03 18:56:54 +03:00
|
|
|
|
|
|
|
// Ensure first layer is initialized as specified layer type
|
|
|
|
mLayers[0].Initialize(aType);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::nsStyleImageLayers(const nsStyleImageLayers &aSource)
|
2009-02-20 08:29:21 +03:00
|
|
|
: mAttachmentCount(aSource.mAttachmentCount)
|
|
|
|
, mClipCount(aSource.mClipCount)
|
|
|
|
, mOriginCount(aSource.mOriginCount)
|
|
|
|
, mRepeatCount(aSource.mRepeatCount)
|
2016-04-29 21:12:10 +03:00
|
|
|
, mPositionXCount(aSource.mPositionXCount)
|
|
|
|
, mPositionYCount(aSource.mPositionYCount)
|
2009-02-20 08:29:21 +03:00
|
|
|
, mImageCount(aSource.mImageCount)
|
2009-05-28 22:09:05 +04:00
|
|
|
, mSizeCount(aSource.mSizeCount)
|
2016-01-28 08:28:00 +03:00
|
|
|
, mMaskModeCount(aSource.mMaskModeCount)
|
2013-11-08 19:07:36 +04:00
|
|
|
, mBlendModeCount(aSource.mBlendModeCount)
|
2016-01-28 08:28:00 +03:00
|
|
|
, mCompositeCount(aSource.mCompositeCount)
|
2009-02-20 08:29:21 +03:00
|
|
|
, mLayers(aSource.mLayers) // deep copy
|
|
|
|
{
|
2016-01-28 08:24:00 +03:00
|
|
|
MOZ_COUNT_CTOR(nsStyleImageLayers);
|
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);
|
2016-04-29 21:12:10 +03:00
|
|
|
mPositionXCount = std::max(mPositionXCount, count);
|
|
|
|
mPositionYCount = std::max(mPositionYCount, count);
|
2013-01-15 16:22:03 +04:00
|
|
|
mImageCount = std::max(mImageCount, count);
|
|
|
|
mSizeCount = std::max(mSizeCount, count);
|
2016-01-28 08:28:00 +03:00
|
|
|
mMaskModeCount = std::max(mMaskModeCount, count);
|
2016-01-28 08:24:00 +03:00
|
|
|
mBlendModeCount = std::max(mBlendModeCount, count);
|
2016-01-28 08:28:00 +03:00
|
|
|
mCompositeCount = std::max(mCompositeCount, count);
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-01-28 08:28:00 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleImageLayers::CalcDifference(const nsStyleImageLayers& aNewLayers,
|
2016-09-22 13:24:52 +03:00
|
|
|
nsStyleImageLayers::LayerType aType) const
|
2016-01-28 08:28:00 +03:00
|
|
|
{
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
|
|
|
const nsStyleImageLayers& moreLayers =
|
2016-06-21 04:47:54 +03:00
|
|
|
mImageCount > aNewLayers.mImageCount ?
|
|
|
|
*this : aNewLayers;
|
2016-01-28 08:28:00 +03:00
|
|
|
const nsStyleImageLayers& lessLayers =
|
2016-06-21 04:47:54 +03:00
|
|
|
mImageCount > aNewLayers.mImageCount ?
|
|
|
|
aNewLayers : *this;
|
2016-01-28 08:28:00 +03:00
|
|
|
|
|
|
|
NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, moreLayers) {
|
|
|
|
if (i < lessLayers.mImageCount) {
|
|
|
|
nsChangeHint layerDifference =
|
2016-10-13 13:35:35 +03:00
|
|
|
moreLayers.mLayers[i].CalcDifference(lessLayers.mLayers[i]);
|
2016-01-28 08:28:00 +03:00
|
|
|
hint |= layerDifference;
|
|
|
|
if (layerDifference &&
|
|
|
|
((moreLayers.mLayers[i].mImage.GetType() == eStyleImageType_Element) ||
|
|
|
|
(lessLayers.mLayers[i].mImage.GetType() == eStyleImageType_Element))) {
|
|
|
|
hint |= nsChangeHint_UpdateEffects | nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
if (moreLayers.mLayers[i].mImage.GetType() == eStyleImageType_Element) {
|
|
|
|
hint |= nsChangeHint_UpdateEffects | nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 13:24:52 +03:00
|
|
|
if (aType == nsStyleImageLayers::LayerType::Mask &&
|
|
|
|
mImageCount != aNewLayers.mImageCount) {
|
|
|
|
hint |= nsChangeHint_UpdateEffects;
|
|
|
|
}
|
|
|
|
|
2016-01-28 08:28:00 +03:00
|
|
|
if (hint) {
|
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mAttachmentCount != aNewLayers.mAttachmentCount ||
|
|
|
|
mBlendModeCount != aNewLayers.mBlendModeCount ||
|
|
|
|
mClipCount != aNewLayers.mClipCount ||
|
|
|
|
mCompositeCount != aNewLayers.mCompositeCount ||
|
|
|
|
mMaskModeCount != aNewLayers.mMaskModeCount ||
|
|
|
|
mOriginCount != aNewLayers.mOriginCount ||
|
|
|
|
mRepeatCount != aNewLayers.mRepeatCount ||
|
|
|
|
mPositionXCount != aNewLayers.mPositionXCount ||
|
|
|
|
mPositionYCount != aNewLayers.mPositionYCount ||
|
|
|
|
mSizeCount != aNewLayers.mSizeCount) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2016-01-28 08:28:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
2016-11-07 17:32:15 +03:00
|
|
|
nsStyleImageLayers&
|
|
|
|
nsStyleImageLayers::operator=(const nsStyleImageLayers& aOther)
|
|
|
|
{
|
|
|
|
mAttachmentCount = aOther.mAttachmentCount;
|
|
|
|
mClipCount = aOther.mClipCount;
|
|
|
|
mOriginCount = aOther.mOriginCount;
|
|
|
|
mRepeatCount = aOther.mRepeatCount;
|
|
|
|
mPositionXCount = aOther.mPositionXCount;
|
|
|
|
mPositionYCount = aOther.mPositionYCount;
|
|
|
|
mImageCount = aOther.mImageCount;
|
|
|
|
mSizeCount = aOther.mSizeCount;
|
|
|
|
mMaskModeCount = aOther.mMaskModeCount;
|
|
|
|
mBlendModeCount = aOther.mBlendModeCount;
|
|
|
|
mCompositeCount = aOther.mCompositeCount;
|
|
|
|
mLayers = aOther.mLayers;
|
|
|
|
|
|
|
|
uint32_t count = mLayers.Length();
|
|
|
|
if (count != aOther.mLayers.Length()) {
|
|
|
|
NS_WARNING("truncating counts due to out-of-memory");
|
|
|
|
mAttachmentCount = std::max(mAttachmentCount, count);
|
|
|
|
mClipCount = std::max(mClipCount, count);
|
|
|
|
mOriginCount = std::max(mOriginCount, count);
|
|
|
|
mRepeatCount = std::max(mRepeatCount, count);
|
|
|
|
mPositionXCount = std::max(mPositionXCount, count);
|
|
|
|
mPositionYCount = std::max(mPositionYCount, count);
|
|
|
|
mImageCount = std::max(mImageCount, count);
|
|
|
|
mSizeCount = std::max(mSizeCount, count);
|
|
|
|
mMaskModeCount = std::max(mMaskModeCount, count);
|
|
|
|
mBlendModeCount = std::max(mBlendModeCount, count);
|
|
|
|
mCompositeCount = std::max(mCompositeCount, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2017-01-06 12:53:30 +03:00
|
|
|
nsStyleImageLayers&
|
|
|
|
nsStyleImageLayers::operator=(nsStyleImageLayers&& aOther)
|
|
|
|
{
|
|
|
|
mAttachmentCount = aOther.mAttachmentCount;
|
|
|
|
mClipCount = aOther.mClipCount;
|
|
|
|
mOriginCount = aOther.mOriginCount;
|
|
|
|
mRepeatCount = aOther.mRepeatCount;
|
|
|
|
mPositionXCount = aOther.mPositionXCount;
|
|
|
|
mPositionYCount = aOther.mPositionYCount;
|
|
|
|
mImageCount = aOther.mImageCount;
|
|
|
|
mSizeCount = aOther.mSizeCount;
|
|
|
|
mMaskModeCount = aOther.mMaskModeCount;
|
|
|
|
mBlendModeCount = aOther.mBlendModeCount;
|
|
|
|
mCompositeCount = aOther.mCompositeCount;
|
2018-05-30 22:15:35 +03:00
|
|
|
mLayers = std::move(aOther.mLayers);
|
2017-01-06 12:53:30 +03:00
|
|
|
|
|
|
|
uint32_t count = mLayers.Length();
|
|
|
|
if (count != aOther.mLayers.Length()) {
|
|
|
|
NS_WARNING("truncating counts due to out-of-memory");
|
|
|
|
mAttachmentCount = std::max(mAttachmentCount, count);
|
|
|
|
mClipCount = std::max(mClipCount, count);
|
|
|
|
mOriginCount = std::max(mOriginCount, count);
|
|
|
|
mRepeatCount = std::max(mRepeatCount, count);
|
|
|
|
mPositionXCount = std::max(mPositionXCount, count);
|
|
|
|
mPositionYCount = std::max(mPositionYCount, count);
|
|
|
|
mImageCount = std::max(mImageCount, count);
|
|
|
|
mSizeCount = std::max(mSizeCount, count);
|
|
|
|
mMaskModeCount = std::max(mMaskModeCount, count);
|
|
|
|
mBlendModeCount = std::max(mBlendModeCount, count);
|
|
|
|
mCompositeCount = std::max(mCompositeCount, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nsStyleImageLayers::operator==(const nsStyleImageLayers& aOther) const
|
|
|
|
{
|
|
|
|
if (mAttachmentCount != aOther.mAttachmentCount ||
|
|
|
|
mClipCount != aOther.mClipCount ||
|
|
|
|
mOriginCount != aOther.mOriginCount ||
|
|
|
|
mRepeatCount != aOther.mRepeatCount ||
|
|
|
|
mPositionXCount != aOther.mPositionXCount ||
|
|
|
|
mPositionYCount != aOther.mPositionYCount ||
|
|
|
|
mImageCount != aOther.mImageCount ||
|
|
|
|
mSizeCount != aOther.mSizeCount ||
|
|
|
|
mMaskModeCount != aOther.mMaskModeCount ||
|
|
|
|
mBlendModeCount != aOther.mBlendModeCount) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mLayers.Length() != aOther.mLayers.Length()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mLayers.Length(); i++) {
|
|
|
|
if (mLayers[i].mPosition != aOther.mLayers[i].mPosition ||
|
2017-03-30 20:50:21 +03:00
|
|
|
!DefinitelyEqualURIs(mLayers[i].mImage.GetURLValue(),
|
|
|
|
aOther.mLayers[i].mImage.GetURLValue()) ||
|
2017-01-06 12:53:30 +03:00
|
|
|
mLayers[i].mImage != aOther.mLayers[i].mImage ||
|
|
|
|
mLayers[i].mSize != aOther.mLayers[i].mSize ||
|
|
|
|
mLayers[i].mClip != aOther.mLayers[i].mClip ||
|
|
|
|
mLayers[i].mOrigin != aOther.mLayers[i].mOrigin ||
|
|
|
|
mLayers[i].mAttachment != aOther.mLayers[i].mAttachment ||
|
|
|
|
mLayers[i].mBlendMode != aOther.mLayers[i].mBlendMode ||
|
|
|
|
mLayers[i].mComposite != aOther.mLayers[i].mComposite ||
|
|
|
|
mLayers[i].mMaskMode != aOther.mLayers[i].mMaskMode ||
|
|
|
|
mLayers[i].mRepeat != aOther.mLayers[i].mRepeat) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-28 08:28:00 +03:00
|
|
|
bool
|
2016-08-25 12:59:51 +03:00
|
|
|
nsStyleImageLayers::IsInitialPositionForLayerType(Position aPosition, LayerType aType)
|
|
|
|
{
|
2016-10-13 18:13:11 +03:00
|
|
|
if (aPosition.mXPosition.mPercent == 0.0f &&
|
2016-08-25 12:59:51 +03:00
|
|
|
aPosition.mXPosition.mLength == 0 &&
|
|
|
|
aPosition.mXPosition.mHasPercent &&
|
2016-10-13 18:13:11 +03:00
|
|
|
aPosition.mYPosition.mPercent == 0.0f &&
|
2016-08-25 12:59:51 +03:00
|
|
|
aPosition.mYPosition.mLength == 0 &&
|
|
|
|
aPosition.mYPosition.mHasPercent) {
|
2016-08-15 10:33:03 +03:00
|
|
|
return true;
|
2016-01-28 08:28:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-08-06 01:57:18 +04:00
|
|
|
void
|
2016-08-25 12:59:51 +03:00
|
|
|
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
|
2016-08-25 12:59:51 +03:00
|
|
|
Position::SetInitialZeroValues()
|
2014-02-04 05:54:22 +04:00
|
|
|
{
|
|
|
|
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
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::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;
|
2016-11-02 11:58:32 +03:00
|
|
|
if (imgRequestProxy* req = aImage.GetImageData()) {
|
|
|
|
req->GetImage(getter_AddRefs(imgContainer));
|
|
|
|
}
|
2011-01-13 13:40:12 +03:00
|
|
|
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
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Size::SetInitialValues()
|
2009-05-28 22:09:05 +04:00
|
|
|
{
|
|
|
|
mWidthType = mHeightType = eAuto;
|
|
|
|
}
|
|
|
|
|
2010-09-15 19:11:26 +04:00
|
|
|
bool
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Size::operator==(const Size& aOther) const
|
2009-05-28 22:09:05 +04:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Layer::Layer()
|
2017-03-16 10:18:10 +03:00
|
|
|
: mClip(StyleGeometryBox::BorderBox)
|
2018-05-09 01:05:33 +03:00
|
|
|
, mAttachment(StyleImageLayerAttachment::Scroll)
|
2016-06-03 18:56:54 +03:00
|
|
|
, mBlendMode(NS_STYLE_BLEND_NORMAL)
|
|
|
|
, mComposite(NS_STYLE_MASK_COMPOSITE_ADD)
|
|
|
|
, mMaskMode(NS_STYLE_MASK_MODE_MATCH_SOURCE)
|
2009-02-20 08:29:21 +03:00
|
|
|
{
|
2016-01-28 08:24:00 +03:00
|
|
|
mImage.SetNull();
|
|
|
|
mSize.SetInitialValues();
|
2009-02-20 08:29:21 +03:00
|
|
|
}
|
|
|
|
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::Layer::~Layer()
|
2009-02-20 08:29:21 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
void
|
|
|
|
nsStyleImageLayers::Layer::Initialize(nsStyleImageLayers::LayerType aType)
|
|
|
|
{
|
2016-10-13 17:57:10 +03:00
|
|
|
mRepeat.SetInitialValues();
|
2016-06-03 18:56:54 +03:00
|
|
|
|
2016-10-13 18:13:11 +03:00
|
|
|
mPosition.SetInitialPercentValues(0.0f);
|
2016-08-15 10:33:03 +03:00
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
if (aType == LayerType::Background) {
|
2017-03-16 10:18:10 +03:00
|
|
|
mOrigin = StyleGeometryBox::PaddingBox;
|
2016-06-03 18:56:54 +03:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(aType == LayerType::Mask, "unsupported layer type.");
|
2017-03-16 10:18:10 +03:00
|
|
|
mOrigin = StyleGeometryBox::BorderBox;
|
2016-06-03 18:56:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::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() ||
|
2016-06-02 03:09:00 +03:00
|
|
|
mSize.DependsOnPositioningAreaSize(mImage) ||
|
|
|
|
mRepeat.DependsOnPositioningAreaSize();
|
2010-10-07 02:18:52 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2016-01-28 08:24:00 +03:00
|
|
|
nsStyleImageLayers::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 &&
|
2016-01-28 08:28:00 +03:00
|
|
|
mImage == aOther.mImage &&
|
|
|
|
mMaskMode == aOther.mMaskMode &&
|
2017-03-30 20:50:21 +03:00
|
|
|
mComposite == aOther.mComposite;
|
2009-08-01 19:53:40 +04:00
|
|
|
}
|
|
|
|
|
2017-11-20 08:53:58 +03:00
|
|
|
template <class ComputedValueItem>
|
|
|
|
static void
|
|
|
|
FillImageLayerList(
|
|
|
|
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
|
|
|
|
ComputedValueItem nsStyleImageLayers::Layer::* aResultLocation,
|
|
|
|
uint32_t aItemCount, uint32_t aFillCount)
|
|
|
|
{
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(aFillCount <= aLayers.Length(), "unexpected array length");
|
2017-11-20 08:53:58 +03:00
|
|
|
for (uint32_t sourceLayer = 0, destLayer = aItemCount;
|
|
|
|
destLayer < aFillCount;
|
|
|
|
++sourceLayer, ++destLayer) {
|
|
|
|
aLayers[destLayer].*aResultLocation =
|
|
|
|
aLayers[sourceLayer].*aResultLocation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The same as FillImageLayerList, but for values stored in
|
|
|
|
// layer.mPosition.*aResultLocation instead of layer.*aResultLocation.
|
|
|
|
static void
|
|
|
|
FillImageLayerPositionCoordList(
|
|
|
|
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
|
|
|
|
Position::Coord
|
|
|
|
Position::* aResultLocation,
|
|
|
|
uint32_t aItemCount, uint32_t aFillCount)
|
|
|
|
{
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(aFillCount <= aLayers.Length(), "unexpected array length");
|
2017-11-20 08:53:58 +03:00
|
|
|
for (uint32_t sourceLayer = 0, destLayer = aItemCount;
|
|
|
|
destLayer < aFillCount;
|
|
|
|
++sourceLayer, ++destLayer) {
|
|
|
|
aLayers[destLayer].mPosition.*aResultLocation =
|
|
|
|
aLayers[sourceLayer].mPosition.*aResultLocation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsStyleImageLayers::FillAllLayers(uint32_t aMaxItemCount)
|
|
|
|
{
|
|
|
|
// Delete any extra items. We need to keep layers in which any
|
|
|
|
// property was specified.
|
|
|
|
mLayers.TruncateLengthNonZero(aMaxItemCount);
|
|
|
|
|
|
|
|
uint32_t fillCount = mImageCount;
|
|
|
|
FillImageLayerList(mLayers,
|
2017-11-21 12:11:40 +03:00
|
|
|
&Layer::mImage,
|
2017-11-20 08:53:58 +03:00
|
|
|
mImageCount, fillCount);
|
|
|
|
FillImageLayerList(mLayers,
|
2017-11-21 12:11:40 +03:00
|
|
|
&Layer::mRepeat,
|
2017-11-20 08:53:58 +03:00
|
|
|
mRepeatCount, fillCount);
|
|
|
|
FillImageLayerList(mLayers,
|
2017-11-21 12:11:40 +03:00
|
|
|
&Layer::mAttachment,
|
2017-11-20 08:53:58 +03:00
|
|
|
mAttachmentCount, fillCount);
|
|
|
|
FillImageLayerList(mLayers,
|
2017-11-21 12:11:40 +03:00
|
|
|
&Layer::mClip,
|
2017-11-20 08:53:58 +03:00
|
|
|
mClipCount, fillCount);
|
|
|
|
FillImageLayerList(mLayers,
|
2017-11-21 12:11:40 +03:00
|
|
|
&Layer::mBlendMode,
|
2017-11-20 08:53:58 +03:00
|
|
|
mBlendModeCount, fillCount);
|
|
|
|
FillImageLayerList(mLayers,
|
2017-11-21 12:11:40 +03:00
|
|
|
&Layer::mOrigin,
|
2017-11-20 08:53:58 +03:00
|
|
|
mOriginCount, fillCount);
|
|
|
|
FillImageLayerPositionCoordList(mLayers,
|
|
|
|
&Position::mXPosition,
|
|
|
|
mPositionXCount, fillCount);
|
|
|
|
FillImageLayerPositionCoordList(mLayers,
|
|
|
|
&Position::mYPosition,
|
|
|
|
mPositionYCount, fillCount);
|
|
|
|
FillImageLayerList(mLayers,
|
2017-11-21 12:11:40 +03:00
|
|
|
&Layer::mSize,
|
2017-11-20 08:53:58 +03:00
|
|
|
mSizeCount, fillCount);
|
|
|
|
FillImageLayerList(mLayers,
|
2017-11-21 12:11:40 +03:00
|
|
|
&Layer::mMaskMode,
|
2017-11-20 08:53:58 +03:00
|
|
|
mMaskModeCount, fillCount);
|
|
|
|
FillImageLayerList(mLayers,
|
2017-11-21 12:11:40 +03:00
|
|
|
&Layer::mComposite,
|
2017-11-20 08:53:58 +03:00
|
|
|
mCompositeCount, fillCount);
|
|
|
|
}
|
|
|
|
|
2015-11-02 19:36:35 +03:00
|
|
|
nsChangeHint
|
2016-10-13 13:35:35 +03:00
|
|
|
nsStyleImageLayers::Layer::CalcDifference(const nsStyleImageLayers::Layer& aNewLayer) const
|
2015-11-02 19:36:35 +03:00
|
|
|
{
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2017-03-30 20:50:21 +03:00
|
|
|
if (!DefinitelyEqualURIs(mImage.GetURLValue(),
|
|
|
|
aNewLayer.mImage.GetURLValue())) {
|
2016-09-22 13:24:52 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame | nsChangeHint_UpdateEffects;
|
2016-07-19 07:35:44 +03:00
|
|
|
|
2017-04-11 10:38:07 +03:00
|
|
|
// If mImage links to an SVG mask, the URL in mImage must have a fragment.
|
|
|
|
// Not vice versa.
|
|
|
|
// Here are examples of URI contains a fragment, two of them link to an
|
|
|
|
// SVG mask:
|
2016-07-19 07:35:44 +03:00
|
|
|
// mask:url(a.svg#maskID); // The fragment of this URI is an ID of a mask
|
|
|
|
// // element in a.svg.
|
|
|
|
// mask:url(#localMaskID); // The fragment of this URI is an ID of a mask
|
|
|
|
// // element in local document.
|
|
|
|
// mask:url(b.svg#viewBoxID); // The fragment of this URI is an ID of a
|
|
|
|
// // viewbox defined in b.svg.
|
2017-04-11 10:38:07 +03:00
|
|
|
// That is, if the URL in mImage has a fragment, it may link to an SVG
|
|
|
|
// mask; If not, it "must" not link to an SVG mask.
|
2016-07-19 07:35:44 +03:00
|
|
|
bool maybeSVGMask = false;
|
2017-03-30 20:50:21 +03:00
|
|
|
if (mImage.GetURLValue()) {
|
2017-04-10 11:41:51 +03:00
|
|
|
maybeSVGMask = mImage.GetURLValue()->MightHaveRef();
|
2016-07-19 07:35:44 +03:00
|
|
|
}
|
2016-08-06 01:38:44 +03:00
|
|
|
|
2017-03-30 20:50:21 +03:00
|
|
|
if (!maybeSVGMask && aNewLayer.mImage.GetURLValue()) {
|
2017-04-10 11:41:51 +03:00
|
|
|
maybeSVGMask = aNewLayer.mImage.GetURLValue()->MightHaveRef();
|
2016-07-19 07:35:44 +03:00
|
|
|
}
|
|
|
|
|
2016-09-22 13:24:52 +03:00
|
|
|
// Return nsChangeHint_UpdateOverflow if either URI might link to an SVG
|
|
|
|
// mask.
|
2016-07-19 07:35:44 +03:00
|
|
|
if (maybeSVGMask) {
|
|
|
|
// Mask changes require that we update the PreEffectsBBoxProperty,
|
|
|
|
// which is done during overflow computation.
|
|
|
|
hint |= nsChangeHint_UpdateOverflow;
|
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
} else if (mAttachment != aNewLayer.mAttachment ||
|
|
|
|
mClip != aNewLayer.mClip ||
|
|
|
|
mOrigin != aNewLayer.mOrigin ||
|
|
|
|
mRepeat != aNewLayer.mRepeat ||
|
|
|
|
mBlendMode != aNewLayer.mBlendMode ||
|
|
|
|
mSize != aNewLayer.mSize ||
|
|
|
|
mImage != aNewLayer.mImage ||
|
|
|
|
mMaskMode != aNewLayer.mMaskMode ||
|
|
|
|
mComposite != aNewLayer.mComposite) {
|
2015-11-02 19:36:35 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
2016-01-28 08:37:00 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mPosition != aNewLayer.mPosition) {
|
2016-10-13 13:35:35 +03:00
|
|
|
hint |= nsChangeHint_UpdateBackgroundPosition;
|
2015-11-02 19:36:35 +03:00
|
|
|
}
|
2016-01-28 08:37:00 +03:00
|
|
|
|
2015-11-02 19:36:35 +03:00
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
2016-01-28 08:24:00 +03:00
|
|
|
// --------------------
|
|
|
|
// nsStyleBackground
|
|
|
|
//
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleBackground::nsStyleBackground(const nsPresContext* aContext)
|
2016-06-03 18:56:54 +03:00
|
|
|
: mImage(nsStyleImageLayers::LayerType::Background)
|
2016-12-29 18:03:29 +03:00
|
|
|
, mBackgroundColor(StyleComplexColor::FromColor(NS_RGBA(0, 0, 0, 0)))
|
2016-01-28 08:24:00 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleBackground);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::nsStyleBackground(const nsStyleBackground& aSource)
|
2016-01-28 08:39:00 +03:00
|
|
|
: mImage(aSource.mImage)
|
2016-01-28 08:24:00 +03:00
|
|
|
, mBackgroundColor(aSource.mBackgroundColor)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleBackground);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleBackground::~nsStyleBackground()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleBackground);
|
|
|
|
}
|
|
|
|
|
2016-11-02 11:58:32 +03:00
|
|
|
void
|
2018-02-22 21:44:44 +03:00
|
|
|
nsStyleBackground::FinishStyle(
|
|
|
|
nsPresContext* aPresContext, const nsStyleBackground* aOldStyle)
|
2016-11-02 11:58:32 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2018-02-22 21:44:44 +03:00
|
|
|
mImage.ResolveImages(aPresContext, aOldStyle ? &aOldStyle->mImage : nullptr);
|
2016-11-02 11:58:32 +03:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleBackground::CalcDifference(const nsStyleBackground& aNewData) const
|
2016-01-28 08:24:00 +03:00
|
|
|
{
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBackgroundColor != aNewData.mBackgroundColor) {
|
2016-01-28 08:24:00 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
hint |= mImage.CalcDifference(aNewData.mImage,
|
2016-09-22 13:24:52 +03:00
|
|
|
nsStyleImageLayers::LayerType::Background);
|
2016-01-28 08:24:00 +03:00
|
|
|
|
2016-01-28 08:28:00 +03:00
|
|
|
return hint;
|
2016-01-28 08:24:00 +03:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
bool
|
|
|
|
nsStyleBackground::HasFixedBackground(nsIFrame* aFrame) const
|
2016-01-28 08:24:00 +03:00
|
|
|
{
|
2016-01-28 08:39:00 +03:00
|
|
|
NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, mImage) {
|
|
|
|
const nsStyleImageLayers::Layer &layer = mImage.mLayers[i];
|
2018-05-09 01:05:33 +03:00
|
|
|
if (layer.mAttachment == StyleImageLayerAttachment::Fixed &&
|
2016-04-26 00:20:13 +03:00
|
|
|
!layer.mImage.IsEmpty() &&
|
|
|
|
!nsLayoutUtils::IsTransformed(aFrame)) {
|
2016-01-28 08:24:00 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-12-29 18:03:29 +03:00
|
|
|
nscolor
|
|
|
|
nsStyleBackground::BackgroundColor(const nsIFrame* aFrame) const
|
|
|
|
{
|
2018-04-27 05:07:20 +03:00
|
|
|
return mBackgroundColor.CalcColor(aFrame);
|
2016-12-29 18:03:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nscolor
|
2018-03-22 21:20:41 +03:00
|
|
|
nsStyleBackground::BackgroundColor(mozilla::ComputedStyle* aStyle) const
|
2016-12-29 18:03:29 +03:00
|
|
|
{
|
2018-04-27 05:07:20 +03:00
|
|
|
return mBackgroundColor.CalcColor(aStyle);
|
2016-12-29 18:03:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsStyleBackground::IsTransparent(const nsIFrame* aFrame) const
|
|
|
|
{
|
2018-03-22 21:20:41 +03:00
|
|
|
return IsTransparent(aFrame->Style());
|
2016-12-29 18:03:29 +03:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
bool
|
2018-03-22 21:20:41 +03:00
|
|
|
nsStyleBackground::IsTransparent(mozilla::ComputedStyle* aStyle) const
|
2016-01-28 08:24:00 +03:00
|
|
|
{
|
|
|
|
return BottomLayer().mImage.IsEmpty() &&
|
2016-01-28 08:39:00 +03:00
|
|
|
mImage.mImageCount == 1 &&
|
2018-03-22 21:20:41 +03:00
|
|
|
NS_GET_A(BackgroundColor(aStyle)) == 0;
|
2016-01-28 08:24:00 +03:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03: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;
|
2017-02-24 09:34:08 +03:00
|
|
|
mStepsOrFrames = 1;
|
2011-04-12 10:18:42 +04:00
|
|
|
return;
|
2015-09-29 05:20:13 +03:00
|
|
|
default:
|
2015-11-23 08:33:47 +03:00
|
|
|
MOZ_FALLTHROUGH_ASSERT("aTimingFunctionType must be a keyword value");
|
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;
|
2017-02-24 09:34:08 +03:00
|
|
|
mStepsOrFrames = 1;
|
2011-04-12 10:18:42 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-07-25 09:22:34 +03:00
|
|
|
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
|
2016-07-25 09:22:34 +03:00
|
|
|
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-09-05 07:48:43 +04:00
|
|
|
bool
|
2016-07-25 09:26:05 +03:00
|
|
|
StyleTransition::operator==(const StyleTransition& aOther) const
|
2014-09-05 07:48:43 +04:00
|
|
|
{
|
|
|
|
return mTimingFunction == aOther.mTimingFunction &&
|
|
|
|
mDuration == aOther.mDuration &&
|
|
|
|
mDelay == aOther.mDelay &&
|
|
|
|
mProperty == aOther.mProperty &&
|
|
|
|
(mProperty != eCSSProperty_UNKNOWN ||
|
|
|
|
mUnknownProperty == aOther.mUnknownProperty);
|
|
|
|
}
|
|
|
|
|
2016-07-25 09:26:05 +03:00
|
|
|
StyleAnimation::StyleAnimation(const 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
|
2016-07-25 09:22:34 +03:00
|
|
|
StyleAnimation::SetInitialValues()
|
2011-04-12 10:18:42 +04:00
|
|
|
{
|
|
|
|
mTimingFunction = nsTimingFunction(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE);
|
|
|
|
mDuration = 0.0;
|
|
|
|
mDelay = 0.0;
|
2017-10-10 11:00:28 +03:00
|
|
|
mName = nsGkAtoms::_empty;
|
2015-11-20 08:09:00 +03:00
|
|
|
mDirection = dom::PlaybackDirection::Normal;
|
|
|
|
mFillMode = dom::FillMode::None;
|
2011-04-12 10:18:42 +04:00
|
|
|
mPlayState = NS_STYLE_ANIMATION_PLAY_STATE_RUNNING;
|
|
|
|
mIterationCount = 1.0f;
|
|
|
|
}
|
|
|
|
|
2014-09-05 07:48:43 +04:00
|
|
|
bool
|
2016-07-25 09:26:05 +03:00
|
|
|
StyleAnimation::operator==(const StyleAnimation& aOther) const
|
2014-09-05 07:48:43 +04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:29 +03:00
|
|
|
// --------------------
|
|
|
|
// nsStyleDisplay
|
|
|
|
//
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleDisplay::nsStyleDisplay(const nsPresContext* aContext)
|
2016-08-28 05:31:50 +03:00
|
|
|
: mDisplay(StyleDisplay::Inline)
|
|
|
|
, mOriginalDisplay(StyleDisplay::Inline)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mContain(NS_STYLE_CONTAIN_NONE)
|
2017-05-21 12:15:00 +03:00
|
|
|
, mAppearance(NS_THEME_NONE)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mPosition(NS_STYLE_POSITION_STATIC)
|
2016-09-03 21:46:58 +03:00
|
|
|
, mFloat(StyleFloat::None)
|
|
|
|
, mOriginalFloat(StyleFloat::None)
|
|
|
|
, mBreakType(StyleClear::None)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mBreakInside(NS_STYLE_PAGE_BREAK_AUTO)
|
|
|
|
, mBreakBefore(false)
|
|
|
|
, mBreakAfter(false)
|
|
|
|
, mOverflowX(NS_STYLE_OVERFLOW_VISIBLE)
|
|
|
|
, mOverflowY(NS_STYLE_OVERFLOW_VISIBLE)
|
2017-12-05 23:08:41 +03:00
|
|
|
, mOverflowClipBoxBlock(NS_STYLE_OVERFLOW_CLIP_BOX_PADDING_BOX)
|
|
|
|
, mOverflowClipBoxInline(NS_STYLE_OVERFLOW_CLIP_BOX_PADDING_BOX)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mResize(NS_STYLE_RESIZE_NONE)
|
2016-10-28 07:17:20 +03:00
|
|
|
, mOrient(StyleOrient::Inline)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mIsolation(NS_STYLE_ISOLATION_AUTO)
|
|
|
|
, mTopLayer(NS_STYLE_TOP_LAYER_NONE)
|
|
|
|
, mWillChangeBitField(0)
|
|
|
|
, mTouchAction(NS_STYLE_TOUCH_ACTION_AUTO)
|
|
|
|
, mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO)
|
2017-11-23 03:01:11 +03:00
|
|
|
, mOverscrollBehaviorX(StyleOverscrollBehavior::Auto)
|
|
|
|
, mOverscrollBehaviorY(StyleOverscrollBehavior::Auto)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mScrollSnapTypeX(NS_STYLE_SCROLL_SNAP_TYPE_NONE)
|
|
|
|
, mScrollSnapTypeY(NS_STYLE_SCROLL_SNAP_TYPE_NONE)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mScrollSnapPointsX(eStyleUnit_None)
|
|
|
|
, mScrollSnapPointsY(eStyleUnit_None)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mBackfaceVisibility(NS_STYLE_BACKFACE_VISIBILITY_VISIBLE)
|
|
|
|
, mTransformStyle(NS_STYLE_TRANSFORM_STYLE_FLAT)
|
2017-03-16 10:18:10 +03:00
|
|
|
, mTransformBox(StyleGeometryBox::BorderBox)
|
2016-10-12 22:33:00 +03:00
|
|
|
, mTransformOrigin{ {0.5f, eStyleUnit_Percent}, // Transform is centered on origin
|
|
|
|
{0.5f, eStyleUnit_Percent},
|
|
|
|
{0, nsStyleCoord::CoordConstructor} }
|
2016-05-03 12:26:30 +03:00
|
|
|
, mChildPerspective(eStyleUnit_None)
|
2016-10-12 22:33:00 +03:00
|
|
|
, mPerspectiveOrigin{ {0.5f, eStyleUnit_Percent},
|
|
|
|
{0.5f, eStyleUnit_Percent} }
|
2016-05-03 12:26:30 +03:00
|
|
|
, mVerticalAlign(NS_STYLE_VERTICAL_ALIGN_BASELINE, eStyleUnit_Enumerated)
|
2016-04-19 02:51:16 +03:00
|
|
|
, mTransitions(nsStyleAutoArray<StyleTransition>::WITH_SINGLE_INITIAL_ELEMENT)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mTransitionTimingFunctionCount(1)
|
|
|
|
, mTransitionDurationCount(1)
|
|
|
|
, mTransitionDelayCount(1)
|
|
|
|
, mTransitionPropertyCount(1)
|
2016-04-19 02:51:16 +03:00
|
|
|
, mAnimations(nsStyleAutoArray<StyleAnimation>::WITH_SINGLE_INITIAL_ELEMENT)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mAnimationTimingFunctionCount(1)
|
|
|
|
, mAnimationDurationCount(1)
|
|
|
|
, mAnimationDelayCount(1)
|
|
|
|
, mAnimationNameCount(1)
|
|
|
|
, mAnimationDirectionCount(1)
|
|
|
|
, mAnimationFillModeCount(1)
|
|
|
|
, mAnimationPlayStateCount(1)
|
|
|
|
, mAnimationIterationCountCount(1)
|
2018-02-08 04:27:04 +03:00
|
|
|
, mShapeMargin(0, nsStyleCoord::CoordConstructor)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleDisplay);
|
2016-05-03 12:26:30 +03:00
|
|
|
|
2014-02-04 05:54:22 +04:00
|
|
|
// 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[0].SetInitialValues();
|
2011-04-12 10:18:42 +04:00
|
|
|
mAnimations[0].SetInitialValues();
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
2012-07-07 03:31:54 +04:00
|
|
|
: mBinding(aSource.mBinding)
|
|
|
|
, 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)
|
2016-06-19 00:16:20 +03:00
|
|
|
, mFloat(aSource.mFloat)
|
|
|
|
, mOriginalFloat(aSource.mOriginalFloat)
|
2012-07-07 03:31:54 +04:00
|
|
|
, 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)
|
2017-12-05 23:08:41 +03:00
|
|
|
, mOverflowClipBoxBlock(aSource.mOverflowClipBoxBlock)
|
|
|
|
, mOverflowClipBoxInline(aSource.mOverflowClipBoxInline)
|
2012-07-07 03:31:54 +04:00
|
|
|
, mResize(aSource.mResize)
|
|
|
|
, mOrient(aSource.mOrient)
|
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)
|
2017-11-23 03:01:11 +03:00
|
|
|
, mOverscrollBehaviorX(aSource.mOverscrollBehaviorX)
|
|
|
|
, mOverscrollBehaviorY(aSource.mOverscrollBehaviorY)
|
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)
|
2017-12-06 12:17:34 +03:00
|
|
|
, mSpecifiedRotate(aSource.mSpecifiedRotate)
|
|
|
|
, mSpecifiedTranslate(aSource.mSpecifiedTranslate)
|
|
|
|
, mSpecifiedScale(aSource.mSpecifiedScale)
|
2018-01-24 10:22:46 +03:00
|
|
|
, mCombinedTransform(aSource.mCombinedTransform)
|
2016-10-12 22:33:00 +03:00
|
|
|
, mTransformOrigin{ aSource.mTransformOrigin[0],
|
|
|
|
aSource.mTransformOrigin[1],
|
|
|
|
aSource.mTransformOrigin[2] }
|
2015-03-20 07:12:17 +03:00
|
|
|
, mChildPerspective(aSource.mChildPerspective)
|
2016-10-12 22:33:00 +03:00
|
|
|
, mPerspectiveOrigin{ aSource.mPerspectiveOrigin[0],
|
|
|
|
aSource.mPerspectiveOrigin[1] }
|
2016-04-12 08:52:41 +03:00
|
|
|
, mVerticalAlign(aSource.mVerticalAlign)
|
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)
|
2017-11-27 10:01:25 +03:00
|
|
|
, mShapeImageThreshold(aSource.mShapeImageThreshold)
|
2018-02-08 04:27:04 +03:00
|
|
|
, mShapeMargin(aSource.mShapeMargin)
|
2016-07-22 10:40:01 +03:00
|
|
|
, mShapeOutside(aSource.mShapeOutside)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleDisplay);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2017-12-07 05:22:49 +03:00
|
|
|
|
|
|
|
static
|
|
|
|
void ReleaseSharedListOnMainThread(const char* aName,
|
|
|
|
RefPtr<nsCSSValueSharedList>& aList)
|
2017-02-08 06:25:45 +03:00
|
|
|
{
|
|
|
|
// We don't allow releasing nsCSSValues with refcounted data in the Servo
|
|
|
|
// traversal, since the refcounts aren't threadsafe. Since Servo may trigger
|
|
|
|
// the deallocation of style structs during styling, we need to handle it
|
|
|
|
// here.
|
2017-12-07 05:22:49 +03:00
|
|
|
if (aList && ServoStyleSet::IsInServoTraversal()) {
|
2017-07-14 09:49:22 +03:00
|
|
|
// The default behavior of NS_ReleaseOnMainThreadSystemGroup is to only
|
|
|
|
// proxy the release if we're not already on the main thread. This is a nice
|
2017-02-08 06:25:45 +03:00
|
|
|
// optimization for the cases we happen to be doing a sequential traversal
|
|
|
|
// (i.e. a single-core machine), but it trips our assertions which check
|
|
|
|
// whether we're in a Servo traversal, parallel or not. So we
|
|
|
|
// unconditionally proxy in debug builds.
|
|
|
|
bool alwaysProxy =
|
|
|
|
#ifdef DEBUG
|
|
|
|
true;
|
|
|
|
#else
|
|
|
|
false;
|
|
|
|
#endif
|
2017-12-07 05:22:49 +03:00
|
|
|
NS_ReleaseOnMainThreadSystemGroup(aName, aList.forget(), alwaysProxy);
|
2017-02-08 06:25:45 +03:00
|
|
|
}
|
2017-12-07 05:22:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleDisplay::~nsStyleDisplay()
|
|
|
|
{
|
|
|
|
ReleaseSharedListOnMainThread("nsStyleDisplay::mSpecifiedTransform",
|
|
|
|
mSpecifiedTransform);
|
2017-12-06 12:17:34 +03:00
|
|
|
ReleaseSharedListOnMainThread("nsStyleDisplay::mSpecifiedRotate",
|
|
|
|
mSpecifiedRotate);
|
|
|
|
ReleaseSharedListOnMainThread("nsStyleDisplay::mSpecifiedTranslate",
|
|
|
|
mSpecifiedTranslate);
|
|
|
|
ReleaseSharedListOnMainThread("nsStyleDisplay::mSpecifiedScale",
|
|
|
|
mSpecifiedScale);
|
2018-01-24 10:22:46 +03:00
|
|
|
ReleaseSharedListOnMainThread("nsStyleDisplay::mCombinedTransform",
|
|
|
|
mCombinedTransform);
|
2017-02-08 06:25:45 +03:00
|
|
|
|
|
|
|
MOZ_COUNT_DTOR(nsStyleDisplay);
|
|
|
|
}
|
|
|
|
|
2017-11-17 11:34:37 +03:00
|
|
|
void
|
2018-02-22 21:44:44 +03:00
|
|
|
nsStyleDisplay::FinishStyle(
|
|
|
|
nsPresContext* aPresContext, const nsStyleDisplay* aOldStyle)
|
2017-11-17 11:34:37 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
if (mShapeOutside.GetType() == StyleShapeSourceType::Image) {
|
|
|
|
const UniquePtr<nsStyleImage>& shapeImage = mShapeOutside.GetShapeImage();
|
|
|
|
if (shapeImage) {
|
2018-02-01 00:08:01 +03:00
|
|
|
// Bug 1434963: The CORS mode should instead be set when the
|
|
|
|
// ImageValue is created, in both Gecko and Stylo. That will
|
|
|
|
// avoid doing a mutation here.
|
|
|
|
if (shapeImage->GetType() == eStyleImageType_Image) {
|
2018-05-16 15:28:50 +03:00
|
|
|
shapeImage->ImageRequest()->GetImageValue()->SetCORSMode(
|
2018-02-01 00:08:01 +03:00
|
|
|
CORSMode::CORS_ANONYMOUS);
|
|
|
|
}
|
2018-02-22 21:44:44 +03:00
|
|
|
const nsStyleImage* oldShapeImage =
|
|
|
|
(aOldStyle &&
|
|
|
|
aOldStyle->mShapeOutside.GetType() == StyleShapeSourceType::Image)
|
|
|
|
? &*aOldStyle->mShapeOutside.GetShapeImage() : nullptr;
|
|
|
|
shapeImage->ResolveImage(aPresContext, oldShapeImage);
|
2017-11-17 11:34:37 +03:00
|
|
|
}
|
|
|
|
}
|
2018-01-24 10:22:46 +03:00
|
|
|
|
|
|
|
GenerateCombinedTransform();
|
2017-11-17 11:34:37 +03:00
|
|
|
}
|
|
|
|
|
2017-12-06 12:17:34 +03:00
|
|
|
static inline nsChangeHint
|
|
|
|
CompareTransformValues(const RefPtr<nsCSSValueSharedList>& aList,
|
|
|
|
const RefPtr<nsCSSValueSharedList>& aNewList)
|
|
|
|
{
|
|
|
|
nsChangeHint result = nsChangeHint(0);
|
|
|
|
if (!aList != !aNewList || (aList && *aList != *aNewList)) {
|
|
|
|
result |= nsChangeHint_UpdateTransformLayer;
|
|
|
|
if (aList && aNewList) {
|
|
|
|
result |= nsChangeHint_UpdatePostTransformOverflow;
|
|
|
|
} else {
|
|
|
|
result |= nsChangeHint_UpdateOverflow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleDisplay::CalcDifference(const nsStyleDisplay& aNewData) 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
|
|
|
|
2017-11-24 17:15:38 +03:00
|
|
|
if (!DefinitelyEqualURIsAndPrincipal(mBinding, aNewData.mBinding)
|
2016-06-21 04:47:54 +03:00
|
|
|
|| mPosition != aNewData.mPosition
|
|
|
|
|| mDisplay != aNewData.mDisplay
|
|
|
|
|| mContain != aNewData.mContain
|
2016-09-03 21:46:58 +03:00
|
|
|
|| (mFloat == StyleFloat::None) != (aNewData.mFloat == StyleFloat::None)
|
2016-06-21 04:47:54 +03:00
|
|
|
|| mScrollBehavior != aNewData.mScrollBehavior
|
|
|
|
|| mScrollSnapTypeX != aNewData.mScrollSnapTypeX
|
|
|
|
|| mScrollSnapTypeY != aNewData.mScrollSnapTypeY
|
|
|
|
|| mScrollSnapPointsX != aNewData.mScrollSnapPointsX
|
|
|
|
|| mScrollSnapPointsY != aNewData.mScrollSnapPointsY
|
|
|
|
|| mScrollSnapDestination != aNewData.mScrollSnapDestination
|
|
|
|
|| mTopLayer != aNewData.mTopLayer
|
2016-07-06 08:06:13 +03:00
|
|
|
|| mResize != aNewData.mResize) {
|
2017-07-15 03:16:47 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
|
|
|
}
|
|
|
|
|
2018-02-05 23:39:07 +03:00
|
|
|
if ((mAppearance == NS_THEME_TEXTFIELD &&
|
|
|
|
aNewData.mAppearance != NS_THEME_TEXTFIELD) ||
|
|
|
|
(mAppearance != NS_THEME_TEXTFIELD &&
|
|
|
|
aNewData.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'.
|
2017-07-15 03:16:47 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2002-09-30 15:56:37 +04:00
|
|
|
|
2017-05-10 23:53:27 +03:00
|
|
|
if (mOverflowX != aNewData.mOverflowX
|
|
|
|
|| mOverflowY != aNewData.mOverflowY) {
|
|
|
|
hint |= nsChangeHint_CSSOverflowChange;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mFloat != aNewData.mFloat) {
|
2017-07-15 03:20:35 +03:00
|
|
|
// Changing which side we're floating on (float:none was handled above).
|
|
|
|
hint |= nsChangeHint_ReflowHintsForFloatAreaChange;
|
2009-08-04 05:22:13 +04:00
|
|
|
}
|
2003-11-15 01:55:46 +03:00
|
|
|
|
2017-11-27 10:01:25 +03:00
|
|
|
if (mShapeOutside != aNewData.mShapeOutside ||
|
2018-02-08 04:27:04 +03:00
|
|
|
mShapeMargin != aNewData.mShapeMargin ||
|
2017-11-27 10:01:25 +03:00
|
|
|
mShapeImageThreshold != aNewData.mShapeImageThreshold) {
|
2017-07-15 03:26:30 +03:00
|
|
|
if (aNewData.mFloat != StyleFloat::None) {
|
2018-02-08 04:27:04 +03:00
|
|
|
// If we are floating, and our shape-outside, shape-margin, or
|
|
|
|
// shape-image-threshold are changed, our descendants are not impacted,
|
|
|
|
// but our ancestor and siblings are.
|
2017-11-27 10:01:25 +03:00
|
|
|
//
|
2017-07-15 03:26:30 +03:00
|
|
|
// This is similar to a float-only change, but since the ISize of the
|
|
|
|
// float area changes arbitrarily along its block axis, more is required
|
|
|
|
// to get the siblings to adjust properly. Hinting overflow change is
|
|
|
|
// sufficient to trigger the correct calculation, but may be too
|
|
|
|
// heavyweight.
|
|
|
|
|
|
|
|
// XXX What is the minimum hint to ensure mShapeInfo is regenerated in
|
|
|
|
// the next reflow?
|
|
|
|
hint |= nsChangeHint_ReflowHintsForFloatAreaChange |
|
|
|
|
nsChangeHint_CSSOverflowChange;
|
|
|
|
} else {
|
2018-02-08 04:27:04 +03:00
|
|
|
// shape-outside or shape-margin or shape-image-threshold changed,
|
|
|
|
// but we don't need to reflow because we're not floating.
|
2017-07-15 03:26:30 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mVerticalAlign != aNewData.mVerticalAlign) {
|
2016-04-12 08:52:41 +03:00
|
|
|
// XXX Can this just be AllReflowHints + RepaintFrame, and be included in
|
|
|
|
// the block below?
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_REFLOW;
|
2016-04-12 08:52:41 +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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mBreakType != aNewData.mBreakType
|
|
|
|
|| mBreakInside != aNewData.mBreakInside
|
|
|
|
|| mBreakBefore != aNewData.mBreakBefore
|
|
|
|
|| mBreakAfter != aNewData.mBreakAfter
|
|
|
|
|| mAppearance != aNewData.mAppearance
|
|
|
|
|| mOrient != aNewData.mOrient
|
2017-12-05 23:08:41 +03:00
|
|
|
|| mOverflowClipBoxBlock != aNewData.mOverflowClipBoxBlock
|
|
|
|
|| mOverflowClipBoxInline != aNewData.mOverflowClipBoxInline) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_AllReflowHints |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2002-09-30 15:56:37 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mIsolation != aNewData.mIsolation) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
2014-09-24 17:48:00 +04:00
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*/
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasTransformStyle() != aNewData.HasTransformStyle()) {
|
2015-03-20 07:12:17 +03:00
|
|
|
// We do not need to apply nsChangeHint_UpdateTransformLayer since
|
|
|
|
// nsChangeHint_RepaintFrame will forcibly invalidate the frame area and
|
|
|
|
// ensure layers are rebuilt (or removed).
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateContainingBlock |
|
2016-09-30 00:15:32 +03:00
|
|
|
nsChangeHint_AddOrRemoveTransform |
|
2016-05-23 06:26:03 +03:00
|
|
|
nsChangeHint_UpdateOverflow |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2015-03-20 07:12:17 +03:00
|
|
|
} 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);
|
|
|
|
|
2017-12-06 12:17:34 +03:00
|
|
|
transformHint |= CompareTransformValues(mSpecifiedTransform,
|
|
|
|
aNewData.mSpecifiedTransform);
|
|
|
|
transformHint |= CompareTransformValues(mSpecifiedRotate, aNewData.
|
|
|
|
mSpecifiedRotate);
|
|
|
|
transformHint |= CompareTransformValues(mSpecifiedTranslate,
|
|
|
|
aNewData.mSpecifiedTranslate);
|
|
|
|
transformHint |= CompareTransformValues(mSpecifiedScale,
|
|
|
|
aNewData.mSpecifiedScale);
|
2015-03-20 07:12:17 +03:00
|
|
|
|
|
|
|
const nsChangeHint kUpdateOverflowAndRepaintHint =
|
2016-05-23 06:26:03 +03:00
|
|
|
nsChangeHint_UpdateOverflow | nsChangeHint_RepaintFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
for (uint8_t index = 0; index < 3; ++index) {
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTransformOrigin[index] != aNewData.mTransformOrigin[index]) {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= nsChangeHint_UpdateTransformLayer |
|
|
|
|
nsChangeHint_UpdatePostTransformOverflow;
|
2015-03-20 07:12:17 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for (uint8_t index = 0; index < 2; ++index) {
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mPerspectiveOrigin[index] != aNewData.mPerspectiveOrigin[index]) {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= kUpdateOverflowAndRepaintHint;
|
2015-03-20 07:12:17 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2015-03-20 07:12:17 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasPerspectiveStyle() != aNewData.HasPerspectiveStyle()) {
|
2015-08-05 00:29:16 +03:00
|
|
|
// A change from/to being a containing block for position:fixed.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateContainingBlock;
|
2015-08-05 00:29:16 +03:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mChildPerspective != aNewData.mChildPerspective ||
|
|
|
|
mTransformStyle != aNewData.mTransformStyle ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mTransformBox != aNewData.mTransformBox) {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= kUpdateOverflowAndRepaintHint;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2015-03-20 07:12:17 +03:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mBackfaceVisibility != aNewData.mBackfaceVisibility) {
|
2016-05-23 06:26:03 +03:00
|
|
|
transformHint |= nsChangeHint_RepaintFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2015-03-20 07:12:17 +03:00
|
|
|
|
|
|
|
if (transformHint) {
|
|
|
|
if (HasTransformStyle()) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= transformHint;
|
2015-03-20 07:12:17 +03:00
|
|
|
} else {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2015-03-20 07:12:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-27 04:13:04 +03:00
|
|
|
// Note that the HasTransformStyle() != aNewData.HasTransformStyle()
|
2015-03-20 07:12:17 +03:00
|
|
|
// test above handles relevant changes in the
|
2016-07-27 04:13:04 +03:00
|
|
|
// NS_STYLE_WILL_CHANGE_TRANSFORM bit, which in turn handles frame
|
|
|
|
// reconstruction for changes in the containing block of
|
2015-12-01 02:46:44 +03:00
|
|
|
// fixed-positioned elements.
|
2015-03-20 07:12:17 +03:00
|
|
|
uint8_t willChangeBitsChanged =
|
2016-06-21 04:47:54 +03:00
|
|
|
mWillChangeBitField ^ aNewData.mWillChangeBitField;
|
2015-12-01 02:46:44 +03:00
|
|
|
if (willChangeBitsChanged & (NS_STYLE_WILL_CHANGE_STACKING_CONTEXT |
|
|
|
|
NS_STYLE_WILL_CHANGE_SCROLL |
|
|
|
|
NS_STYLE_WILL_CHANGE_OPACITY)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
2015-03-20 07:12:17 +03:00
|
|
|
}
|
|
|
|
|
2015-12-01 02:46:44 +03:00
|
|
|
if (willChangeBitsChanged & NS_STYLE_WILL_CHANGE_FIXPOS_CB) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateContainingBlock;
|
2015-12-01 02:46:44 +03:00
|
|
|
}
|
|
|
|
|
2016-06-01 20:13:14 +03:00
|
|
|
// If touch-action is changed, we need to regenerate the event regions on
|
|
|
|
// the layers and send it over to the compositor for APZ to handle.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTouchAction != aNewData.mTouchAction) {
|
2016-06-01 20:13:14 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2017-11-23 03:06:43 +03:00
|
|
|
// If overscroll-behavior has changed, the changes are picked up
|
|
|
|
// during a repaint.
|
|
|
|
if (mOverscrollBehaviorX != aNewData.mOverscrollBehaviorX ||
|
|
|
|
mOverscrollBehaviorY != aNewData.mOverscrollBehaviorY) {
|
|
|
|
hint |= nsChangeHint_SchedulePaint;
|
|
|
|
}
|
|
|
|
|
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
|
2018-03-23 16:49:21 +03:00
|
|
|
// of any ComputedStyle change anyway.
|
2011-04-12 10:18:42 +04:00
|
|
|
|
|
|
|
// Note: Likewise, for animation-*, the animation manager gets
|
2018-03-23 16:49:21 +03:00
|
|
|
// notified about every new ComputedStyle constructed, and it uses
|
2011-04-12 10:18:42 +04:00
|
|
|
// 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 &&
|
2016-06-21 04:47:54 +03:00
|
|
|
(mOriginalDisplay != aNewData.mOriginalDisplay ||
|
|
|
|
mOriginalFloat != aNewData.mOriginalFloat ||
|
|
|
|
mTransitions != aNewData.mTransitions ||
|
2014-09-05 07:48:43 +04:00
|
|
|
mTransitionTimingFunctionCount !=
|
2016-06-21 04:47:54 +03:00
|
|
|
aNewData.mTransitionTimingFunctionCount ||
|
|
|
|
mTransitionDurationCount != aNewData.mTransitionDurationCount ||
|
|
|
|
mTransitionDelayCount != aNewData.mTransitionDelayCount ||
|
|
|
|
mTransitionPropertyCount != aNewData.mTransitionPropertyCount ||
|
|
|
|
mAnimations != aNewData.mAnimations ||
|
|
|
|
mAnimationTimingFunctionCount != aNewData.mAnimationTimingFunctionCount ||
|
|
|
|
mAnimationDurationCount != aNewData.mAnimationDurationCount ||
|
|
|
|
mAnimationDelayCount != aNewData.mAnimationDelayCount ||
|
|
|
|
mAnimationNameCount != aNewData.mAnimationNameCount ||
|
|
|
|
mAnimationDirectionCount != aNewData.mAnimationDirectionCount ||
|
|
|
|
mAnimationFillModeCount != aNewData.mAnimationFillModeCount ||
|
|
|
|
mAnimationPlayStateCount != aNewData.mAnimationPlayStateCount ||
|
|
|
|
mAnimationIterationCountCount != aNewData.mAnimationIterationCountCount ||
|
2017-07-15 03:26:30 +03:00
|
|
|
mScrollSnapCoordinate != aNewData.mScrollSnapCoordinate)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2014-09-05 07:48:43 +04:00
|
|
|
}
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2018-01-24 10:22:46 +03:00
|
|
|
void
|
|
|
|
nsStyleDisplay::GenerateCombinedTransform()
|
|
|
|
{
|
2018-02-22 21:44:44 +03:00
|
|
|
// FIXME(emilio): This should probably be called from somewhere like what we
|
|
|
|
// do for image layers, instead of FinishStyle.
|
|
|
|
//
|
|
|
|
// This does and undoes the work a ton of times in Stylo.
|
2018-01-24 10:22:46 +03:00
|
|
|
mCombinedTransform = nullptr;
|
|
|
|
|
|
|
|
// Follow the order defined in the spec to append transform functions.
|
|
|
|
// https://drafts.csswg.org/css-transforms-2/#ctm
|
|
|
|
AutoTArray<nsCSSValueSharedList*, 4> shareLists;
|
|
|
|
if (mSpecifiedTranslate) {
|
|
|
|
shareLists.AppendElement(mSpecifiedTranslate.get());
|
|
|
|
}
|
|
|
|
if (mSpecifiedRotate) {
|
|
|
|
shareLists.AppendElement(mSpecifiedRotate.get());
|
|
|
|
}
|
|
|
|
if (mSpecifiedScale) {
|
|
|
|
shareLists.AppendElement(mSpecifiedScale.get());
|
|
|
|
}
|
|
|
|
if (mSpecifiedTransform) {
|
|
|
|
shareLists.AppendElement(mSpecifiedTransform.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shareLists.Length() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shareLists.Length() == 1) {
|
|
|
|
mCombinedTransform = shareLists[0];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In common, we may have 3 transform functions(for rotate, translate and
|
|
|
|
// scale) in mSpecifiedTransform, one rotate function in mSpecifiedRotate,
|
|
|
|
// one translate function in mSpecifiedTranslate, and one scale function in
|
|
|
|
// mSpecifiedScale. So 6 slots are enough for the most cases.
|
|
|
|
AutoTArray<nsCSSValueList*, 6> valueLists;
|
|
|
|
for (auto list: shareLists) {
|
|
|
|
if (list) {
|
|
|
|
valueLists.AppendElement(list->mHead->Clone());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check we have at least one list or else valueLists.Length() - 1 below will
|
|
|
|
// underflow.
|
|
|
|
MOZ_ASSERT(valueLists.Length());
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < valueLists.Length() - 1; i++) {
|
|
|
|
valueLists[i]->mNext = valueLists[i + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
mCombinedTransform = new nsCSSValueSharedList(valueLists[0]);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleVisibility
|
|
|
|
//
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleVisibility::nsStyleVisibility(const nsPresContext* aContext)
|
|
|
|
: mDirection(aContext->GetBidi() == IBMBIDI_TEXTDIRECTION_RTL
|
2016-05-03 12:26:29 +03:00
|
|
|
? NS_STYLE_DIRECTION_RTL
|
|
|
|
: NS_STYLE_DIRECTION_LTR)
|
|
|
|
, mVisible(NS_STYLE_VISIBILITY_VISIBLE)
|
|
|
|
, mImageRendering(NS_STYLE_IMAGE_RENDERING_AUTO)
|
|
|
|
, mWritingMode(NS_STYLE_WRITING_MODE_HORIZONTAL_TB)
|
|
|
|
, mTextOrientation(NS_STYLE_TEXT_ORIENTATION_MIXED)
|
|
|
|
, mColorAdjust(NS_STYLE_COLOR_ADJUST_ECONOMY)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleVisibility);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mImageOrientation(aSource.mImageOrientation)
|
|
|
|
, mDirection(aSource.mDirection)
|
|
|
|
, mVisible(aSource.mVisible)
|
|
|
|
, mImageRendering(aSource.mImageRendering)
|
|
|
|
, mWritingMode(aSource.mWritingMode)
|
|
|
|
, mTextOrientation(aSource.mTextOrientation)
|
|
|
|
, mColorAdjust(aSource.mColorAdjust)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleVisibility);
|
2016-05-03 12:26:29 +03:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleVisibility::CalcDifference(const nsStyleVisibility& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2010-12-11 03:25:25 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mDirection != aNewData.mDirection || mWritingMode != aNewData.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).
|
2017-02-28 20:58:30 +03:00
|
|
|
// Also, the used writing-mode value is now a field on nsIFrame and some
|
|
|
|
// classes (e.g. table rows/cells) copy their value from an ancestor.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_ReconstructFrame;
|
2013-05-24 21:31:33 +04:00
|
|
|
} else {
|
2016-06-21 04:47:54 +03:00
|
|
|
if ((mImageOrientation != aNewData.mImageOrientation)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_AllReflowHints |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2013-08-29 02:39:06 +04:00
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mVisible != aNewData.mVisible) {
|
2018-02-09 04:43:10 +03:00
|
|
|
if (mVisible == NS_STYLE_VISIBILITY_VISIBLE ||
|
|
|
|
aNewData.mVisible == NS_STYLE_VISIBILITY_VISIBLE) {
|
|
|
|
hint |= nsChangeHint_VisibilityChange;
|
|
|
|
}
|
2013-05-24 21:31:33 +04:00
|
|
|
if ((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||
|
2016-06-21 04:47:54 +03:00
|
|
|
(NS_STYLE_VISIBILITY_COLLAPSE == aNewData.mVisible)) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_REFLOW;
|
2013-05-24 21:31:33 +04:00
|
|
|
} else {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_VISUAL;
|
2013-05-24 21:31:33 +04:00
|
|
|
}
|
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextOrientation != aNewData.mTextOrientation) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_REFLOW;
|
2014-12-11 21:56:19 +03:00
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mImageRendering != aNewData.mImageRendering) {
|
2016-04-12 08:52:40 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mColorAdjust != aNewData.mColorAdjust) {
|
2016-03-08 20:25:24 +03:00
|
|
|
// color-adjust only affects media where dynamic changes can't happen.
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2016-03-08 20:25:24 +03:00
|
|
|
}
|
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()
|
|
|
|
{
|
2016-08-16 23:57:31 +03:00
|
|
|
MOZ_COUNT_DTOR(nsStyleContentData);
|
2016-10-21 03:14:56 +03:00
|
|
|
|
2004-07-15 02:19:22 +04:00
|
|
|
if (mType == eStyleContentType_Image) {
|
2018-04-12 22:04:22 +03:00
|
|
|
// FIXME(emilio): Is this needed now that URLs are not main thread only?
|
2017-07-14 09:49:22 +03:00
|
|
|
NS_ReleaseOnMainThreadSystemGroup(
|
2017-06-14 04:27:17 +03:00
|
|
|
"nsStyleContentData::mContent.mImage", dont_AddRef(mContent.mImage));
|
2017-03-12 09:40:54 +03:00
|
|
|
mContent.mImage = nullptr;
|
2005-04-02 03:07:00 +04:00
|
|
|
} else if (mType == eStyleContentType_Counter ||
|
|
|
|
mType == eStyleContentType_Counters) {
|
|
|
|
mContent.mCounters->Release();
|
2018-04-03 20:50:06 +03:00
|
|
|
} else if (mType == eStyleContentType_String) {
|
2015-04-01 08:29:55 +03:00
|
|
|
free(mContent.mString);
|
2018-04-03 20:50:06 +03:00
|
|
|
} else if (mType == eStyleContentType_Attr) {
|
|
|
|
delete mContent.mAttr;
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(mContent.mString == nullptr, "Leaking due to missing case");
|
2004-07-15 02:19:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-16 23:57:31 +03:00
|
|
|
nsStyleContentData::nsStyleContentData(const nsStyleContentData& aOther)
|
|
|
|
: mType(aOther.mType)
|
2004-07-15 02:19:22 +04:00
|
|
|
{
|
2016-08-16 23:57:31 +03:00
|
|
|
MOZ_COUNT_CTOR(nsStyleContentData);
|
2018-04-12 22:04:22 +03:00
|
|
|
switch (mType) {
|
|
|
|
case eStyleContentType_Image:
|
|
|
|
mContent.mImage = aOther.mContent.mImage;
|
|
|
|
mContent.mImage->AddRef();
|
|
|
|
break;
|
|
|
|
case eStyleContentType_Counter:
|
|
|
|
case eStyleContentType_Counters:
|
|
|
|
mContent.mCounters = aOther.mContent.mCounters;
|
|
|
|
mContent.mCounters->AddRef();
|
|
|
|
break;
|
|
|
|
case eStyleContentType_Attr:
|
2018-04-30 21:41:08 +03:00
|
|
|
mContent.mAttr = new nsStyleContentAttr(*aOther.mContent.mAttr);
|
2018-04-12 22:04:22 +03:00
|
|
|
break;
|
|
|
|
case eStyleContentType_String:
|
|
|
|
mContent.mString = NS_strdup(aOther.mContent.mString);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(!aOther.mContent.mString);
|
|
|
|
mContent.mString = nullptr;
|
2004-07-15 02:19:22 +04:00
|
|
|
}
|
2016-08-16 23:57:31 +03:00
|
|
|
}
|
|
|
|
|
2017-05-22 15:51:20 +03:00
|
|
|
bool
|
|
|
|
nsStyleContentData::
|
|
|
|
CounterFunction::operator==(const CounterFunction& aOther) const
|
|
|
|
{
|
|
|
|
return mIdent == aOther.mIdent &&
|
|
|
|
mSeparator == aOther.mSeparator &&
|
2017-05-27 16:33:25 +03:00
|
|
|
mCounterStyle == aOther.mCounterStyle;
|
2017-05-22 15:51:20 +03:00
|
|
|
}
|
|
|
|
|
2016-08-16 23:57:31 +03:00
|
|
|
nsStyleContentData&
|
|
|
|
nsStyleContentData::operator=(const nsStyleContentData& aOther)
|
|
|
|
{
|
|
|
|
if (this == &aOther) {
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
this->~nsStyleContentData();
|
|
|
|
new (this) nsStyleContentData(aOther);
|
|
|
|
|
2004-07-15 02:19:22 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
bool
|
|
|
|
nsStyleContentData::operator==(const nsStyleContentData& aOther) const
|
2004-07-15 02:19:22 +04:00
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mType != aOther.mType) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2004-07-15 02:19:22 +04:00
|
|
|
if (mType == eStyleContentType_Image) {
|
2016-10-21 03:14:56 +03:00
|
|
|
return DefinitelyEqualImages(mContent.mImage, aOther.mContent.mImage);
|
2004-07-15 02:19:22 +04:00
|
|
|
}
|
2018-04-12 22:04:22 +03:00
|
|
|
if (mType == eStyleContentType_Attr) {
|
|
|
|
return *mContent.mAttr == *aOther.mContent.mAttr;
|
|
|
|
}
|
2005-04-02 03:07:00 +04:00
|
|
|
if (mType == eStyleContentType_Counter ||
|
2016-07-06 08:06:13 +03:00
|
|
|
mType == eStyleContentType_Counters) {
|
2005-04-02 03:07:00 +04:00
|
|
|
return *mContent.mCounters == *aOther.mContent.mCounters;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2018-04-12 22:04:22 +03:00
|
|
|
if (mType == eStyleContentType_String) {
|
|
|
|
return NS_strcmp(mContent.mString, aOther.mContent.mString) == 0;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(!mContent.mString && !aOther.mContent.mString);
|
|
|
|
return true;
|
2004-07-15 02:19:22 +04:00
|
|
|
}
|
|
|
|
|
2017-05-22 17:32:05 +03:00
|
|
|
void
|
2018-02-22 21:44:44 +03:00
|
|
|
nsStyleContentData::Resolve(
|
|
|
|
nsPresContext* aPresContext, const nsStyleContentData* aOldStyle)
|
2017-05-22 17:32:05 +03:00
|
|
|
{
|
|
|
|
switch (mType) {
|
|
|
|
case eStyleContentType_Image:
|
|
|
|
if (!mContent.mImage->IsResolved()) {
|
2018-02-22 21:44:44 +03:00
|
|
|
const nsStyleImageRequest* oldRequest =
|
|
|
|
(aOldStyle && aOldStyle->mType == eStyleContentType_Image)
|
|
|
|
? aOldStyle->mContent.mImage : nullptr;
|
|
|
|
mContent.mImage->Resolve(aPresContext, oldRequest);
|
2017-05-22 17:32:05 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case eStyleContentType_Counter:
|
|
|
|
case eStyleContentType_Counters: {
|
2017-05-27 16:33:25 +03:00
|
|
|
mContent.mCounters->
|
|
|
|
mCounterStyle.Resolve(aPresContext->CounterStyleManager());
|
2017-05-22 17:32:05 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-06 21:27:01 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleContent
|
|
|
|
//
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleContent::nsStyleContent(const nsPresContext* aContext)
|
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
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleContent::~nsStyleContent()
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleContent);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2017-03-12 09:40:54 +03:00
|
|
|
void
|
2018-02-22 21:44:44 +03:00
|
|
|
nsStyleContent::FinishStyle(nsPresContext* aPresContext, const nsStyleContent* aOldStyle)
|
2017-03-12 09:40:54 +03:00
|
|
|
{
|
2018-02-22 21:44:44 +03:00
|
|
|
for (size_t i = 0; i < mContents.Length(); ++i) {
|
|
|
|
const nsStyleContentData* oldData =
|
|
|
|
(aOldStyle && aOldStyle->mContents.Length() > i)
|
|
|
|
? &aOldStyle->mContents[i]
|
|
|
|
: nullptr;
|
|
|
|
mContents[i].Resolve(aPresContext, oldData);
|
2017-03-12 09:40:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleContent::nsStyleContent(const nsStyleContent& aSource)
|
2016-10-21 13:04:46 +03:00
|
|
|
: mContents(aSource.mContents)
|
2016-08-16 23:57:31 +03:00
|
|
|
, mIncrements(aSource.mIncrements)
|
|
|
|
, mResets(aSource.mResets)
|
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
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleContent::CalcDifference(const nsStyleContent& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2016-09-23 13:08:01 +03:00
|
|
|
// In ElementRestyler::Restyle we assume that if there's no existing
|
2010-06-18 20:23:05 +04:00
|
|
|
// ::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,
|
2016-09-23 13:08:01 +03:00
|
|
|
// the optimization in ElementRestyler::Restyle is ok. But if we ever
|
2010-06-18 20:23:05 +04:00
|
|
|
// change this code to not reconstruct frames on changes to the
|
|
|
|
// 'content' property, then we will need to revisit the optimization
|
2016-09-23 13:08:01 +03:00
|
|
|
// in ElementRestyler::Restyle.
|
2010-06-18 20:23:05 +04:00
|
|
|
|
2016-08-16 23:57:31 +03:00
|
|
|
// Unfortunately we need to reframe even if the content lengths are the same;
|
|
|
|
// a simple reflow will not pick up different text or different image URLs,
|
|
|
|
// since we set all that up in the CSSFrameConstructor
|
2017-05-23 03:08:50 +03:00
|
|
|
//
|
|
|
|
// Also note that we also rely on this to return ReconstructFrame when
|
|
|
|
// content changes to ensure that nsCounterUseNode wouldn't reference
|
|
|
|
// to stale counter stylex.
|
2016-08-16 23:57:31 +03:00
|
|
|
if (mContents != aNewData.mContents ||
|
|
|
|
mIncrements != aNewData.mIncrements ||
|
|
|
|
mResets != aNewData.mResets) {
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2005-04-02 03:07:00 +04:00
|
|
|
}
|
|
|
|
|
2016-08-16 23:57:31 +03:00
|
|
|
return nsChangeHint(0);
|
2016-08-19 10:23:42 +03:00
|
|
|
}
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
// --------------------
|
|
|
|
// nsStyleTextReset
|
|
|
|
//
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleTextReset::nsStyleTextReset(const nsPresContext* aContext)
|
2018-05-23 08:23:26 +03:00
|
|
|
: mTextOverflow()
|
|
|
|
, mTextDecorationLine(NS_STYLE_TEXT_DECORATION_LINE_NONE)
|
2016-09-27 13:19:48 +03:00
|
|
|
, mTextDecorationStyle(NS_STYLE_TEXT_DECORATION_STYLE_SOLID)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mUnicodeBidi(NS_STYLE_UNICODE_BIDI_NORMAL)
|
2016-07-28 10:23:36 +03:00
|
|
|
, mInitialLetterSink(0)
|
|
|
|
, mInitialLetterSize(0.0f)
|
2016-09-27 13:19:48 +03:00
|
|
|
, mTextDecorationColor(StyleComplexColor::CurrentColor())
|
2016-05-03 12:26:29 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTextReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:29 +03:00
|
|
|
nsStyleTextReset::nsStyleTextReset(const nsStyleTextReset& aSource)
|
2018-05-23 08:23:26 +03:00
|
|
|
: mTextOverflow(aSource.mTextOverflow)
|
|
|
|
, mTextDecorationLine(aSource.mTextDecorationLine)
|
|
|
|
, mTextDecorationStyle(aSource.mTextDecorationStyle)
|
|
|
|
, mUnicodeBidi(aSource.mUnicodeBidi)
|
|
|
|
, mInitialLetterSink(aSource.mInitialLetterSink)
|
|
|
|
, mInitialLetterSize(aSource.mInitialLetterSize)
|
|
|
|
, mTextDecorationColor(aSource.mTextDecorationColor)
|
2016-05-03 12:26:29 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleTextReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleTextReset::~nsStyleTextReset()
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleTextReset);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2016-04-12 08:52:41 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleTextReset::CalcDifference(const nsStyleTextReset& aNewData) const
|
2016-04-12 08:52:41 +03:00
|
|
|
{
|
2016-07-28 10:23:36 +03:00
|
|
|
if (mUnicodeBidi != aNewData.mUnicodeBidi ||
|
|
|
|
mInitialLetterSink != aNewData.mInitialLetterSink ||
|
|
|
|
mInitialLetterSize != aNewData.mInitialLetterSize) {
|
2016-04-12 08:52:41 +03:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
|
|
|
}
|
2011-03-31 16:26:35 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextDecorationLine != aNewData.mTextDecorationLine ||
|
2016-09-27 13:19:48 +03:00
|
|
|
mTextDecorationStyle != aNewData.mTextDecorationStyle) {
|
2016-04-12 08:52:41 +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.
|
|
|
|
return nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_UpdateSubtreeOverflow |
|
|
|
|
nsChangeHint_SchedulePaint;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Repaint for decoration color changes
|
2016-09-27 13:19:48 +03:00
|
|
|
if (mTextDecorationColor != aNewData.mTextDecorationColor) {
|
2016-04-12 08:52:41 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
|
|
|
}
|
2008-03-30 00:25:15 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextOverflow != aNewData.mTextOverflow) {
|
2016-04-12 08:52:41 +03:00
|
|
|
return nsChangeHint_RepaintFrame;
|
2008-03-30 00:25:15 +03:00
|
|
|
}
|
2016-04-12 08:52:41 +03:00
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2016-07-06 08:06:13 +03:00
|
|
|
if (lhs == rhs) {
|
2015-10-02 06:05:28 +03:00
|
|
|
return true;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-07-08 04:56:52 +04:00
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (!lhs || !rhs || lhs->Length() != rhs->Length()) {
|
2015-10-02 06:05:28 +03:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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) {
|
2016-07-06 08:06:13 +03:00
|
|
|
if (*lhs->ShadowAt(i) != *rhs->ShadowAt(i)) {
|
2015-10-02 06:05:28 +03:00
|
|
|
return false;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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
|
|
|
|
//
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleText::nsStyleText(const nsPresContext* aContext)
|
2016-05-11 07:03:34 +03:00
|
|
|
: mTextAlign(NS_STYLE_TEXT_ALIGN_START)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mTextAlignLast(NS_STYLE_TEXT_ALIGN_AUTO)
|
|
|
|
, mTextAlignTrue(false)
|
|
|
|
, mTextAlignLastTrue(false)
|
2017-03-01 15:58:25 +03:00
|
|
|
, mTextJustify(StyleTextJustify::Auto)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mTextTransform(NS_STYLE_TEXT_TRANSFORM_NONE)
|
2017-06-01 21:47:54 +03:00
|
|
|
, mWhiteSpace(StyleWhiteSpace::Normal)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mWordBreak(NS_STYLE_WORDBREAK_NORMAL)
|
2016-05-24 03:27:21 +03:00
|
|
|
, mOverflowWrap(NS_STYLE_OVERFLOWWRAP_NORMAL)
|
2017-01-04 18:55:16 +03:00
|
|
|
, mHyphens(StyleHyphens::Manual)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mRubyAlign(NS_STYLE_RUBY_ALIGN_SPACE_AROUND)
|
|
|
|
, mRubyPosition(NS_STYLE_RUBY_POSITION_OVER)
|
|
|
|
, mTextSizeAdjust(NS_STYLE_TEXT_SIZE_ADJUST_AUTO)
|
|
|
|
, mTextCombineUpright(NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE)
|
2017-11-20 05:46:45 +03:00
|
|
|
, mControlCharacterVisibility(nsLayoutUtils::ControlCharVisibilityDefault())
|
2016-05-03 12:26:29 +03:00
|
|
|
, mTextEmphasisStyle(NS_STYLE_TEXT_EMPHASIS_STYLE_NONE)
|
|
|
|
, mTextRendering(NS_STYLE_TEXT_RENDERING_AUTO)
|
2016-09-16 07:40:45 +03:00
|
|
|
, mTextEmphasisColor(StyleComplexColor::CurrentColor())
|
|
|
|
, mWebkitTextFillColor(StyleComplexColor::CurrentColor())
|
|
|
|
, mWebkitTextStrokeColor(StyleComplexColor::CurrentColor())
|
2016-11-25 07:23:14 +03:00
|
|
|
, mTabSize(float(NS_STYLE_TABSIZE_INITIAL), eStyleUnit_Factor)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mWordSpacing(0, nsStyleCoord::CoordConstructor)
|
|
|
|
, mLetterSpacing(eStyleUnit_Normal)
|
|
|
|
, mLineHeight(eStyleUnit_Normal)
|
|
|
|
, mTextIndent(0, nsStyleCoord::CoordConstructor)
|
2016-11-29 15:08:08 +03:00
|
|
|
, mWebkitTextStrokeWidth(0)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mTextShadow(nullptr)
|
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleText);
|
2017-10-03 01:05:19 +03:00
|
|
|
RefPtr<nsAtom> language = aContext->GetContentLanguage();
|
2015-11-28 03:56:33 +03:00
|
|
|
mTextEmphasisPosition = language &&
|
2016-07-21 08:03:25 +03:00
|
|
|
nsStyleUtil::MatchesLanguagePrefix(language, u"zh") ?
|
2015-11-28 03:56:33 +03:00
|
|
|
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT_ZH :
|
|
|
|
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT;
|
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)
|
2016-05-03 12:26:29 +03:00
|
|
|
: mTextAlign(aSource.mTextAlign)
|
|
|
|
, mTextAlignLast(aSource.mTextAlignLast)
|
|
|
|
, mTextAlignTrue(false)
|
|
|
|
, mTextAlignLastTrue(false)
|
2017-03-01 15:58:25 +03:00
|
|
|
, mTextJustify(aSource.mTextJustify)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mTextTransform(aSource.mTextTransform)
|
|
|
|
, mWhiteSpace(aSource.mWhiteSpace)
|
|
|
|
, mWordBreak(aSource.mWordBreak)
|
2016-05-24 03:27:21 +03:00
|
|
|
, mOverflowWrap(aSource.mOverflowWrap)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mHyphens(aSource.mHyphens)
|
|
|
|
, mRubyAlign(aSource.mRubyAlign)
|
|
|
|
, mRubyPosition(aSource.mRubyPosition)
|
|
|
|
, mTextSizeAdjust(aSource.mTextSizeAdjust)
|
|
|
|
, mTextCombineUpright(aSource.mTextCombineUpright)
|
|
|
|
, mControlCharacterVisibility(aSource.mControlCharacterVisibility)
|
|
|
|
, mTextEmphasisPosition(aSource.mTextEmphasisPosition)
|
|
|
|
, mTextEmphasisStyle(aSource.mTextEmphasisStyle)
|
|
|
|
, mTextRendering(aSource.mTextRendering)
|
|
|
|
, mTextEmphasisColor(aSource.mTextEmphasisColor)
|
|
|
|
, mWebkitTextFillColor(aSource.mWebkitTextFillColor)
|
|
|
|
, mWebkitTextStrokeColor(aSource.mWebkitTextStrokeColor)
|
2016-11-25 07:23:14 +03:00
|
|
|
, mTabSize(aSource.mTabSize)
|
2016-05-03 12:26:29 +03:00
|
|
|
, mWordSpacing(aSource.mWordSpacing)
|
|
|
|
, mLetterSpacing(aSource.mLetterSpacing)
|
|
|
|
, mLineHeight(aSource.mLineHeight)
|
|
|
|
, mTextIndent(aSource.mTextIndent)
|
|
|
|
, mWebkitTextStrokeWidth(aSource.mWebkitTextStrokeWidth)
|
|
|
|
, mTextShadow(aSource.mTextShadow)
|
|
|
|
, mTextEmphasisStyleString(aSource.mTextEmphasisStyleString)
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleText);
|
|
|
|
}
|
2008-06-06 03:06:34 +04:00
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleText::~nsStyleText()
|
2009-08-07 18:38:44 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleText);
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleText::CalcDifference(const nsStyleText& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2012-09-07 09:42:19 +04:00
|
|
|
if (WhiteSpaceOrNewlineIsSignificant() !=
|
2016-06-21 04:47:54 +03:00
|
|
|
aNewData.WhiteSpaceOrNewlineIsSignificant()) {
|
2009-06-13 13:16:34 +04:00
|
|
|
// This may require construction of suppressed text frames
|
2016-07-06 08:06:14 +03:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
2009-06-13 13:16:34 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextCombineUpright != aNewData.mTextCombineUpright ||
|
|
|
|
mControlCharacterVisibility != aNewData.mControlCharacterVisibility) {
|
2013-08-19 14:26:44 +04:00
|
|
|
return nsChangeHint_ReconstructFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if ((mTextAlign != aNewData.mTextAlign) ||
|
|
|
|
(mTextAlignLast != aNewData.mTextAlignLast) ||
|
|
|
|
(mTextAlignTrue != aNewData.mTextAlignTrue) ||
|
|
|
|
(mTextAlignLastTrue != aNewData.mTextAlignLastTrue) ||
|
|
|
|
(mTextTransform != aNewData.mTextTransform) ||
|
|
|
|
(mWhiteSpace != aNewData.mWhiteSpace) ||
|
|
|
|
(mWordBreak != aNewData.mWordBreak) ||
|
|
|
|
(mOverflowWrap != aNewData.mOverflowWrap) ||
|
|
|
|
(mHyphens != aNewData.mHyphens) ||
|
|
|
|
(mRubyAlign != aNewData.mRubyAlign) ||
|
|
|
|
(mRubyPosition != aNewData.mRubyPosition) ||
|
|
|
|
(mTextSizeAdjust != aNewData.mTextSizeAdjust) ||
|
|
|
|
(mLetterSpacing != aNewData.mLetterSpacing) ||
|
|
|
|
(mLineHeight != aNewData.mLineHeight) ||
|
|
|
|
(mTextIndent != aNewData.mTextIndent) ||
|
2017-03-01 15:58:25 +03:00
|
|
|
(mTextJustify != aNewData.mTextJustify) ||
|
2016-06-21 04:47:54 +03:00
|
|
|
(mWordSpacing != aNewData.mWordSpacing) ||
|
2016-07-06 08:06:13 +03:00
|
|
|
(mTabSize != aNewData.mTabSize)) {
|
2008-06-06 03:06:34 +04:00
|
|
|
return NS_STYLE_HINT_REFLOW;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2008-06-06 03:06:34 +04:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasTextEmphasis() != aNewData.HasTextEmphasis() ||
|
2015-12-08 20:55:01 +03:00
|
|
|
(HasTextEmphasis() &&
|
2016-06-21 04:47:54 +03:00
|
|
|
mTextEmphasisPosition != aNewData.mTextEmphasisPosition)) {
|
2015-12-08 20:55:01 +03:00
|
|
|
// Text emphasis position change could affect line height calculation.
|
|
|
|
return nsChangeHint_AllReflowHints |
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-04-12 08:52:41 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
|
|
|
// text-rendering changes require a reflow since they change SVG
|
|
|
|
// frames' rects.
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextRendering != aNewData.mTextRendering) {
|
2016-04-12 08:52:41 +03:00
|
|
|
hint |= nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow | // XXX remove me: bug 876085
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (!AreShadowArraysEqual(mTextShadow, aNewData.mTextShadow) ||
|
|
|
|
mTextEmphasisStyle != aNewData.mTextEmphasisStyle ||
|
|
|
|
mTextEmphasisStyleString != aNewData.mTextEmphasisStyleString ||
|
|
|
|
mWebkitTextStrokeWidth != aNewData.mWebkitTextStrokeWidth) {
|
2016-04-12 08:52:41 +03:00
|
|
|
hint |= nsChangeHint_UpdateSubtreeOverflow |
|
|
|
|
nsChangeHint_SchedulePaint |
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
|
|
|
|
// We don't add any other hints below.
|
|
|
|
return hint;
|
2015-11-28 03:56:33 +03:00
|
|
|
}
|
|
|
|
|
2016-09-16 07:40:45 +03:00
|
|
|
if (mTextEmphasisColor != aNewData.mTextEmphasisColor ||
|
2016-06-21 04:47:54 +03:00
|
|
|
mWebkitTextFillColor != aNewData.mWebkitTextFillColor ||
|
|
|
|
mWebkitTextStrokeColor != aNewData.mWebkitTextStrokeColor) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_SchedulePaint |
|
|
|
|
nsChangeHint_RepaintFrame;
|
2016-04-12 08:52:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hint) {
|
|
|
|
return hint;
|
2015-11-28 03:56:33 +03:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mTextEmphasisPosition != aNewData.mTextEmphasisPosition) {
|
2015-12-08 20:55:01 +03:00
|
|
|
return nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-07-17 17:20:21 +03:00
|
|
|
return nsChangeHint(0);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2015-11-28 03:56:33 +03:00
|
|
|
LogicalSide
|
|
|
|
nsStyleText::TextEmphasisSide(WritingMode aWM) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(
|
|
|
|
(!(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_LEFT) !=
|
|
|
|
!(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_RIGHT)) &&
|
|
|
|
(!(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_OVER) !=
|
|
|
|
!(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_UNDER)));
|
2016-02-25 03:09:34 +03:00
|
|
|
mozilla::Side side = aWM.IsVertical() ?
|
2015-11-28 03:56:33 +03:00
|
|
|
(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_LEFT
|
|
|
|
? eSideLeft : eSideRight) :
|
|
|
|
(mTextEmphasisPosition & NS_STYLE_TEXT_EMPHASIS_POSITION_OVER
|
|
|
|
? eSideTop : eSideBottom);
|
|
|
|
LogicalSide result = aWM.LogicalSideForPhysicalSide(side);
|
|
|
|
MOZ_ASSERT(IsBlock(result));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
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)
|
2016-11-21 09:34:11 +03:00
|
|
|
, mImage(aOther.mImage)
|
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;
|
2016-11-21 09:34:11 +03:00
|
|
|
mImage = aOther.mImage;
|
2010-08-16 20:19:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2016-09-29 05:55:55 +03:00
|
|
|
bool
|
|
|
|
nsCursorImage::operator==(const nsCursorImage& aOther) const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mHaveHotspot ||
|
|
|
|
(mHotspotX == 0 && mHotspotY == 0),
|
|
|
|
"expected mHotspot{X,Y} to be 0 when mHaveHotspot is false");
|
|
|
|
NS_ASSERTION(aOther.mHaveHotspot ||
|
|
|
|
(aOther.mHotspotX == 0 && aOther.mHotspotY == 0),
|
|
|
|
"expected mHotspot{X,Y} to be 0 when mHaveHotspot is false");
|
|
|
|
return mHaveHotspot == aOther.mHaveHotspot &&
|
|
|
|
mHotspotX == aOther.mHotspotX &&
|
|
|
|
mHotspotY == aOther.mHotspotY &&
|
2016-11-21 09:34:11 +03:00
|
|
|
DefinitelyEqualImages(mImage, aOther.mImage);
|
2016-09-29 05:55:55 +03:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleUserInterface::nsStyleUserInterface(const nsPresContext* aContext)
|
2016-10-23 01:08:18 +03:00
|
|
|
: mUserInput(StyleUserInput::Auto)
|
2016-10-23 23:41:49 +03:00
|
|
|
, mUserModify(StyleUserModify::ReadOnly)
|
2016-09-03 21:46:58 +03:00
|
|
|
, mUserFocus(StyleUserFocus::None)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mPointerEvents(NS_STYLE_POINTER_EVENTS_AUTO)
|
|
|
|
, mCursor(NS_STYLE_CURSOR_AUTO)
|
2016-12-22 03:04:15 +03:00
|
|
|
, mCaretColor(StyleComplexColor::Auto())
|
2018-05-10 03:40:17 +03:00
|
|
|
, mScrollbarFaceColor(StyleComplexColor::Auto())
|
|
|
|
, mScrollbarTrackColor(StyleComplexColor::Auto())
|
2016-05-03 12:26:30 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUserInterface);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleUserInterface::nsStyleUserInterface(const nsStyleUserInterface& aSource)
|
|
|
|
: mUserInput(aSource.mUserInput)
|
|
|
|
, mUserModify(aSource.mUserModify)
|
|
|
|
, mUserFocus(aSource.mUserFocus)
|
|
|
|
, mPointerEvents(aSource.mPointerEvents)
|
|
|
|
, mCursor(aSource.mCursor)
|
2016-09-29 05:55:55 +03:00
|
|
|
, mCursorImages(aSource.mCursorImages)
|
2016-12-22 03:04:15 +03:00
|
|
|
, mCaretColor(aSource.mCaretColor)
|
2018-05-10 03:40:17 +03:00
|
|
|
, mScrollbarFaceColor(aSource.mScrollbarFaceColor)
|
|
|
|
, mScrollbarTrackColor(aSource.mScrollbarTrackColor)
|
2016-05-03 12:26:30 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUserInterface);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleUserInterface::~nsStyleUserInterface()
|
2016-05-03 12:26:30 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleUserInterface);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-11-21 09:34:11 +03:00
|
|
|
void
|
2018-02-22 21:44:44 +03:00
|
|
|
nsStyleUserInterface::FinishStyle(
|
|
|
|
nsPresContext* aPresContext, const nsStyleUserInterface* aOldStyle)
|
2016-11-21 09:34:11 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2018-02-22 21:44:44 +03:00
|
|
|
for (size_t i = 0; i < mCursorImages.Length(); ++i) {
|
|
|
|
nsCursorImage& cursor = mCursorImages[i];
|
|
|
|
|
2016-11-21 09:34:11 +03:00
|
|
|
if (cursor.mImage && !cursor.mImage->IsResolved()) {
|
2018-02-22 21:44:44 +03:00
|
|
|
const nsCursorImage* oldCursor =
|
|
|
|
(aOldStyle && aOldStyle->mCursorImages.Length() > i)
|
|
|
|
? &aOldStyle->mCursorImages[i]
|
|
|
|
: nullptr;
|
|
|
|
cursor.mImage->Resolve(
|
|
|
|
aPresContext, oldCursor ? oldCursor->mImage.get() : nullptr);
|
2016-11-21 09:34:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleUserInterface::CalcDifference(const nsStyleUserInterface& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2004-12-28 16:48:25 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mCursor != aNewData.mCursor) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateCursor;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
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.
|
2016-09-29 05:55:55 +03:00
|
|
|
if (mCursorImages != aNewData.mCursorImages) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_UpdateCursor;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2004-12-31 00:56:11 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mPointerEvents != aNewData.mPointerEvents) {
|
2016-12-18 14:11:47 +03:00
|
|
|
// SVGGeometryFrame's mRect depends on stroke _and_ on the value
|
|
|
|
// of pointer-events. See SVGGeometryFrame::ReflowSVG's use of
|
2016-04-12 08:52:41 +03:00
|
|
|
// GetHitTestFlags. (Only a reflow, no visual change.)
|
|
|
|
hint |= nsChangeHint_NeedReflow |
|
|
|
|
nsChangeHint_NeedDirtyReflow; // XXX remove me: bug 876085
|
|
|
|
}
|
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mUserModify != aNewData.mUserModify) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= NS_STYLE_HINT_VISUAL;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mUserInput != aNewData.mUserInput) {
|
2016-10-23 01:08:18 +03:00
|
|
|
if (StyleUserInput::None == mUserInput ||
|
|
|
|
StyleUserInput::None == aNewData.mUserInput) {
|
2016-07-06 08:06:14 +03:00
|
|
|
hint |= nsChangeHint_ReconstructFrame;
|
2014-09-05 07:48:43 +04:00
|
|
|
} else {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2014-09-05 07:48:43 +04:00
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mUserFocus != aNewData.mUserFocus) {
|
2016-05-23 06:26:03 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
2014-09-05 07:48:43 +04:00
|
|
|
}
|
2004-12-28 16:48:25 +03:00
|
|
|
|
2018-05-10 03:40:17 +03:00
|
|
|
if (mCaretColor != aNewData.mCaretColor ||
|
|
|
|
mScrollbarFaceColor != aNewData.mScrollbarFaceColor ||
|
|
|
|
mScrollbarTrackColor != aNewData.mScrollbarTrackColor) {
|
2016-12-22 03:04:15 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2004-12-28 16:48:25 +03:00
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------
|
|
|
|
// nsStyleUIReset
|
|
|
|
//
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleUIReset::nsStyleUIReset(const nsPresContext* aContext)
|
2016-08-10 19:12:21 +03:00
|
|
|
: mUserSelect(StyleUserSelect::Auto)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mForceBrokenImageIcon(0)
|
|
|
|
, mIMEMode(NS_STYLE_IME_MODE_AUTO)
|
2016-10-29 11:51:05 +03:00
|
|
|
, mWindowDragging(StyleWindowDragging::Default)
|
2016-05-03 12:26:30 +03:00
|
|
|
, mWindowShadow(NS_STYLE_WINDOW_SHADOW_DEFAULT)
|
2017-06-19 04:04:40 +03:00
|
|
|
, mWindowOpacity(1.0)
|
2017-06-19 08:44:22 +03:00
|
|
|
, mSpecifiedWindowTransform(nullptr)
|
|
|
|
, mWindowTransformOrigin{ {0.5f, eStyleUnit_Percent}, // Transform is centered on origin
|
|
|
|
{0.5f, eStyleUnit_Percent} }
|
2016-05-03 12:26:30 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUIReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleUIReset::nsStyleUIReset(const nsStyleUIReset& aSource)
|
|
|
|
: mUserSelect(aSource.mUserSelect)
|
|
|
|
, mForceBrokenImageIcon(aSource.mForceBrokenImageIcon)
|
|
|
|
, mIMEMode(aSource.mIMEMode)
|
|
|
|
, mWindowDragging(aSource.mWindowDragging)
|
|
|
|
, mWindowShadow(aSource.mWindowShadow)
|
2017-06-19 04:04:40 +03:00
|
|
|
, mWindowOpacity(aSource.mWindowOpacity)
|
2017-06-19 08:44:22 +03:00
|
|
|
, mSpecifiedWindowTransform(aSource.mSpecifiedWindowTransform)
|
|
|
|
, mWindowTransformOrigin{ aSource.mWindowTransformOrigin[0],
|
|
|
|
aSource.mWindowTransformOrigin[1] }
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_CTOR(nsStyleUIReset);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:26:30 +03:00
|
|
|
nsStyleUIReset::~nsStyleUIReset()
|
2016-05-03 12:26:30 +03:00
|
|
|
{
|
2009-08-07 18:38:44 +04:00
|
|
|
MOZ_COUNT_DTOR(nsStyleUIReset);
|
2017-06-19 08:44:22 +03:00
|
|
|
|
2017-12-07 05:22:49 +03:00
|
|
|
ReleaseSharedListOnMainThread("nsStyleUIReset::mSpecifiedWindowTransform",
|
|
|
|
mSpecifiedWindowTransform);
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
|
|
|
|
2016-06-03 18:56:54 +03:00
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleUIReset::CalcDifference(const nsStyleUIReset& aNewData) const
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2017-06-19 04:04:40 +03:00
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mForceBrokenImageIcon != aNewData.mForceBrokenImageIcon) {
|
2017-06-19 04:04:40 +03:00
|
|
|
hint |= nsChangeHint_ReconstructFrame;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mWindowShadow != aNewData.mWindowShadow) {
|
2008-10-14 18:44:25 +04:00
|
|
|
// We really need just an nsChangeHint_SyncFrameView, except
|
|
|
|
// on an ancestor of the frame, so we get that by doing a
|
|
|
|
// reflow.
|
2017-06-19 04:04:40 +03:00
|
|
|
hint |= NS_STYLE_HINT_REFLOW;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2016-07-06 08:06:13 +03:00
|
|
|
if (mUserSelect != aNewData.mUserSelect) {
|
2017-06-19 04:04:40 +03:00
|
|
|
hint |= NS_STYLE_HINT_VISUAL;
|
2016-07-06 08:06:13 +03:00
|
|
|
}
|
2016-01-27 13:58:33 +03:00
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mWindowDragging != aNewData.mWindowDragging) {
|
2017-06-19 04:04:40 +03:00
|
|
|
hint |= nsChangeHint_SchedulePaint;
|
2017-01-19 11:13:02 +03:00
|
|
|
}
|
|
|
|
|
2017-06-19 08:44:22 +03:00
|
|
|
if (mWindowOpacity != aNewData.mWindowOpacity ||
|
|
|
|
!mSpecifiedWindowTransform != !aNewData.mSpecifiedWindowTransform ||
|
|
|
|
(mSpecifiedWindowTransform &&
|
|
|
|
*mSpecifiedWindowTransform != *aNewData.mSpecifiedWindowTransform)) {
|
2017-06-19 04:04:40 +03:00
|
|
|
hint |= nsChangeHint_UpdateWidgetProperties;
|
2017-06-19 08:44:22 +03:00
|
|
|
} else {
|
|
|
|
for (uint8_t index = 0; index < 2; ++index) {
|
|
|
|
if (mWindowTransformOrigin[index] !=
|
|
|
|
aNewData.mWindowTransformOrigin[index]) {
|
|
|
|
hint |= nsChangeHint_UpdateWidgetProperties;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-06-19 04:04:40 +03:00
|
|
|
}
|
|
|
|
|
2017-06-19 04:04:40 +03:00
|
|
|
if (!hint &&
|
|
|
|
mIMEMode != aNewData.mIMEMode) {
|
|
|
|
hint |= nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hint;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2013-12-12 06:09:40 +04:00
|
|
|
|
2016-04-12 08:52:42 +03:00
|
|
|
//-----------------------
|
|
|
|
// nsStyleEffects
|
|
|
|
//
|
|
|
|
|
2017-01-04 22:52:27 +03:00
|
|
|
nsStyleEffects::nsStyleEffects(const nsPresContext* aContext)
|
2016-04-12 08:52:42 +03:00
|
|
|
: mBoxShadow(nullptr)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mClip(0, 0, 0, 0)
|
2016-04-12 08:52:43 +03:00
|
|
|
, mOpacity(1.0f)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mClipFlags(NS_STYLE_CLIP_AUTO)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mMixBlendMode(NS_STYLE_BLEND_NORMAL)
|
2016-04-12 08:52:42 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleEffects);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleEffects::nsStyleEffects(const nsStyleEffects& aSource)
|
2016-04-12 08:52:43 +03:00
|
|
|
: mFilters(aSource.mFilters)
|
|
|
|
, mBoxShadow(aSource.mBoxShadow)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mClip(aSource.mClip)
|
2016-04-12 08:52:43 +03:00
|
|
|
, mOpacity(aSource.mOpacity)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mClipFlags(aSource.mClipFlags)
|
2016-04-12 08:52:42 +03:00
|
|
|
, mMixBlendMode(aSource.mMixBlendMode)
|
2016-04-12 08:52:42 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsStyleEffects);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleEffects::~nsStyleEffects()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsStyleEffects);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsChangeHint
|
2016-06-21 04:47:54 +03:00
|
|
|
nsStyleEffects::CalcDifference(const nsStyleEffects& aNewData) const
|
2016-04-12 08:52:42 +03:00
|
|
|
{
|
|
|
|
nsChangeHint hint = nsChangeHint(0);
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (!AreShadowArraysEqual(mBoxShadow, aNewData.mBoxShadow)) {
|
2016-04-12 08:52:42 +03:00
|
|
|
// Update overflow regions & trigger DLBI to be sure it's noticed.
|
|
|
|
// 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.)
|
|
|
|
hint |= nsChangeHint_UpdateOverflow |
|
|
|
|
nsChangeHint_SchedulePaint |
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mClipFlags != aNewData.mClipFlags) {
|
2016-04-12 08:52:42 +03:00
|
|
|
hint |= nsChangeHint_AllReflowHints |
|
|
|
|
nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (!mClip.IsEqualInterior(aNewData.mClip)) {
|
2016-04-12 08:52:42 +03:00
|
|
|
// If the clip has changed, we just need to update overflow areas. DLBI
|
|
|
|
// will handle the invalidation.
|
|
|
|
hint |= nsChangeHint_UpdateOverflow |
|
|
|
|
nsChangeHint_SchedulePaint;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mOpacity != aNewData.mOpacity) {
|
2016-04-12 08:52:43 +03: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.
|
2016-06-21 04:47:54 +03:00
|
|
|
if ((mOpacity >= 0.99f && mOpacity < 1.0f && aNewData.mOpacity == 1.0f) ||
|
|
|
|
(aNewData.mOpacity >= 0.99f && aNewData.mOpacity < 1.0f && mOpacity == 1.0f)) {
|
2016-04-12 08:52:43 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
} else {
|
|
|
|
hint |= nsChangeHint_UpdateOpacityLayer;
|
2016-06-21 04:47:54 +03:00
|
|
|
if ((mOpacity == 1.0f) != (aNewData.mOpacity == 1.0f)) {
|
2016-04-12 08:52:43 +03:00
|
|
|
hint |= nsChangeHint_UpdateUsesOpacity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (HasFilters() != aNewData.HasFilters()) {
|
2016-04-12 08:52:43 +03:00
|
|
|
// A change from/to being a containing block for position:fixed.
|
|
|
|
hint |= nsChangeHint_UpdateContainingBlock;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mFilters != aNewData.mFilters) {
|
2016-04-12 08:52:43 +03:00
|
|
|
hint |= nsChangeHint_UpdateEffects |
|
|
|
|
nsChangeHint_RepaintFrame |
|
|
|
|
nsChangeHint_UpdateOverflow;
|
|
|
|
}
|
|
|
|
|
2016-06-21 04:47:54 +03:00
|
|
|
if (mMixBlendMode != aNewData.mMixBlendMode) {
|
2016-04-12 08:52:42 +03:00
|
|
|
hint |= nsChangeHint_RepaintFrame;
|
|
|
|
}
|
|
|
|
|
2016-04-12 08:52:42 +03:00
|
|
|
if (!hint &&
|
2016-06-21 04:47:54 +03:00
|
|
|
!mClip.IsEqualEdges(aNewData.mClip)) {
|
2016-04-12 08:52:42 +03:00
|
|
|
hint |= nsChangeHint_NeutralChange;
|
|
|
|
}
|
|
|
|
|
2016-04-12 08:52:42 +03:00
|
|
|
return hint;
|
|
|
|
}
|