Bug 1291280 - Part 1. Move the definition of FragmentOrURL up.
MozReview-Commit-ID: 3TtUtnE2ZBh
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -114,16 +114,112 @@ StyleStructContext::HackilyFindSomeDevic
nsCOMPtr<mozIDOMWindowProxy> win;
appShell->GetHiddenDOMWindow(getter_AddRefs(win));
return nsLayoutUtils::GetDeviceContextForScreenInfo(static_cast<nsPIDOMWindowOuter*>(win.get()));
}
static bool AreShadowArraysEqual(nsCSSShadowArray* lhs, nsCSSShadowArray* rhs);
// --------------------
+// FragmentOrURL
+//
+void
+FragmentOrURL::SetValue(const nsCSSValue* aValue)
+{
+ mozilla::css::URLValue *urlVal = aValue->GetURLStructValue();
+ MOZ_ASSERT_IF(urlVal->GetLocalURLFlag(), urlVal->GetURI());
+ mIsLocalRef = urlVal->GetLocalURLFlag();
+
+ mURL = urlVal->GetURI();
+
+#ifdef DEBUG
+ if (mIsLocalRef) {
+ bool hasRef = false;
+ mURL->GetHasRef(&hasRef);
+ MOZ_ASSERT(hasRef);
+ }
+#endif
+}
+
+void
+FragmentOrURL::SetNull()
+{
+ mURL = nullptr;
+ mIsLocalRef = false;
+}
+
+FragmentOrURL&
+FragmentOrURL::operator=(const FragmentOrURL& aOther)
+{
+ mIsLocalRef = aOther.mIsLocalRef;
+ mURL = aOther.mURL;
+
+ return *this;
+}
+
+bool
+FragmentOrURL::operator==(const FragmentOrURL& aOther) const
+{
+ if (aOther.mIsLocalRef != mIsLocalRef) {
+ return false;
+ }
+
+ return EqualURIs(aOther.mURL, mURL);
+}
+
+bool
+FragmentOrURL::EqualsExceptRef(nsIURI* aURI) const
+{
+ bool ret = false;
+ mURL->EqualsExceptRef(aURI, &ret);
+ return ret;
+}
+
+void
+FragmentOrURL::GetSourceString(nsString &aRef) const
+{
+ MOZ_ASSERT(mURL);
+
+ nsCString cref;
+ if (mIsLocalRef) {
+ mURL->GetRef(cref);
+ cref.Insert('#', 0);
+ } else {
+ mURL->GetSpec(cref);
+ }
+
+ aRef = NS_ConvertUTF8toUTF16(cref);
+}
+
+already_AddRefed<nsIURI>
+FragmentOrURL::Resolve(nsIURI* aURI) const
+{
+ nsCOMPtr<nsIURI> result;
+
+ if (mIsLocalRef) {
+ nsCString ref;
+ mURL->GetRef(ref);
+
+ aURI->Clone(getter_AddRefs(result));
+ result->SetRef(ref);
+ } else {
+ result = mURL;
+ }
+
+ return result.forget();
+}
+
+already_AddRefed<nsIURI>
+FragmentOrURL::Resolve(nsIContent* aContent) const
+{
+ nsCOMPtr<nsIURI> url = aContent->GetBaseURI();
+ return Resolve(url);
+}
+
+// --------------------
// nsStyleFont
//
nsStyleFont::nsStyleFont(const nsFont& aFont, StyleStructContext aContext)
: mFont(aFont)
, mSize(nsStyleFont::ZoomText(aContext, mFont.size))
, mGenericID(kGenericFont_NONE)
, mScriptLevel(0)
, mMathVariant(NS_MATHML_MATHVARIANT_NONE)
@@ -1005,113 +1101,16 @@ nsStyleBasicShape::GetShapeTypeName() co
case nsStyleBasicShape::Type::eInset:
return eCSSKeyword_inset;
}
NS_NOTREACHED("unexpected type");
return eCSSKeyword_UNKNOWN;
}
// --------------------
-// FragmentOrURL
-//
-
-void
-FragmentOrURL::SetValue(const nsCSSValue* aValue)
-{
- mozilla::css::URLValue *urlVal = aValue->GetURLStructValue();
- MOZ_ASSERT_IF(urlVal->GetLocalURLFlag(), urlVal->GetURI());
- mIsLocalRef = urlVal->GetLocalURLFlag();
-
- mURL = urlVal->GetURI();
-
-#ifdef DEBUG
- if (mIsLocalRef) {
- bool hasRef = false;
- mURL->GetHasRef(&hasRef);
- MOZ_ASSERT(hasRef);
- }
-#endif
-}
-
-void
-FragmentOrURL::SetNull()
-{
- mURL = nullptr;
- mIsLocalRef = false;
-}
-
-FragmentOrURL&
-FragmentOrURL::operator=(const FragmentOrURL& aOther)
-{
- mIsLocalRef = aOther.mIsLocalRef;
- mURL = aOther.mURL;
-
- return *this;
-}
-
-bool
-FragmentOrURL::operator==(const FragmentOrURL& aOther) const
-{
- if (aOther.mIsLocalRef != mIsLocalRef) {
- return false;
- }
-
- return EqualURIs(aOther.mURL, mURL);
-}
-
-bool
-FragmentOrURL::EqualsExceptRef(nsIURI* aURI) const
-{
- bool ret = false;
- mURL->EqualsExceptRef(aURI, &ret);
- return ret;
-}
-
-void
-FragmentOrURL::GetSourceString(nsString &aRef) const
-{
- MOZ_ASSERT(mURL);
-
- nsCString cref;
- if (mIsLocalRef) {
- mURL->GetRef(cref);
- cref.Insert('#', 0);
- } else {
- mURL->GetSpec(cref);
- }
-
- aRef = NS_ConvertUTF8toUTF16(cref);
-}
-
-already_AddRefed<nsIURI>
-FragmentOrURL::Resolve(nsIURI* aURI) const
-{
- nsCOMPtr<nsIURI> result;
-
- if (mIsLocalRef) {
- nsCString ref;
- mURL->GetRef(ref);
-
- aURI->Clone(getter_AddRefs(result));
- result->SetRef(ref);
- } else {
- result = mURL;
- }
-
- return result.forget();
-}
-
-already_AddRefed<nsIURI>
-FragmentOrURL::Resolve(nsIContent* aContent) const
-{
- nsCOMPtr<nsIURI> url = aContent->GetBaseURI();
- return Resolve(url);
-}
-
-// --------------------
// nsStyleClipPath
//
nsStyleClipPath::nsStyleClipPath()
: mURL(nullptr)
, mType(StyleClipPathType::None_)
, mSizingBox(StyleClipShapeSizing::NoBox)
{
}
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -105,16 +105,49 @@ static_assert(int(mozilla::SheetType::Co
"NS_RULE_NODE_LEVEL_MASK cannot fit SheetType");
static_assert(NS_STYLE_INHERIT_MASK == (1 << nsStyleStructID_Length) - 1,
"NS_STYLE_INHERIT_MASK is not correct");
static_assert((NS_RULE_NODE_IS_ANIMATION_RULE & NS_STYLE_INHERIT_MASK) == 0,
"NS_RULE_NODE_IS_ANIMATION_RULE must not overlap the style struct bits.");
+struct FragmentOrURL
+{
+ FragmentOrURL() : mIsLocalRef(false) {}
+ FragmentOrURL(const FragmentOrURL& aSource)
+ : mIsLocalRef(false)
+ { *this = aSource; }
+
+ void SetValue(const nsCSSValue* aValue);
+ void SetNull();
+
+ FragmentOrURL& operator=(const FragmentOrURL& aOther);
+ bool operator==(const FragmentOrURL& aOther) const;
+ bool operator!=(const FragmentOrURL& aOther) const {
+ return !(*this == aOther);
+ }
+
+ bool EqualsExceptRef(nsIURI* aURI) const;
+
+ nsIURI* GetSourceURL() const { return mURL; }
+ void GetSourceString(nsString& aRef) const;
+
+ // When matching a url with mIsLocalRef set, resolve it against aURI;
+ // Otherwise, ignore aURL and return mURL directly.
+ already_AddRefed<nsIURI> Resolve(nsIURI* aURI) const;
+ already_AddRefed<nsIURI> Resolve(nsIContent* aContent) const;
+
+ bool IsLocalRef() const { return mIsLocalRef; }
+
+private:
+ nsCOMPtr<nsIURI> mURL;
+ bool mIsLocalRef;
+};
+
// The lifetime of these objects is managed by the presshell's arena.
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleFont
{
nsStyleFont(const nsFont& aFont, StyleStructContext aContext);
nsStyleFont(const nsStyleFont& aStyleFont);
explicit nsStyleFont(StyleStructContext aContext);
~nsStyleFont() {
MOZ_COUNT_DTOR(nsStyleFont);
@@ -3228,49 +3261,16 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
return (IsVisibleBorderStyle(mColumnRuleStyle) ? mColumnRuleWidth : 0);
}
protected:
nscoord mColumnRuleWidth; // [reset] coord
nscoord mTwipsPerPixel;
};
-struct FragmentOrURL
-{
- FragmentOrURL() : mIsLocalRef(false) {}
- FragmentOrURL(const FragmentOrURL& aSource)
- : mIsLocalRef(false)
- { *this = aSource; }
-
- void SetValue(const nsCSSValue* aValue);
- void SetNull();
-
- FragmentOrURL& operator=(const FragmentOrURL& aOther);
- bool operator==(const FragmentOrURL& aOther) const;
- bool operator!=(const FragmentOrURL& aOther) const {
- return !(*this == aOther);
- }
-
- bool EqualsExceptRef(nsIURI* aURI) const;
-
- nsIURI* GetSourceURL() const { return mURL; }
- void GetSourceString(nsString& aRef) const;
-
- // When matching a url with mIsLocalRef set, resolve it against aURI;
- // Otherwise, ignore aURL and return mURL directly.
- already_AddRefed<nsIURI> Resolve(nsIURI* aURI) const;
- already_AddRefed<nsIURI> Resolve(nsIContent* aContent) const;
-
- bool IsLocalRef() const { return mIsLocalRef; }
-
-private:
- nsCOMPtr<nsIURI> mURL;
- bool mIsLocalRef;
-};
-
enum nsStyleSVGPaintType {
eStyleSVGPaintType_None = 1,
eStyleSVGPaintType_Color,
eStyleSVGPaintType_Server,
eStyleSVGPaintType_ContextFill,
eStyleSVGPaintType_ContextStroke
};