summaryrefslogtreecommitdiffstats
path: root/layout/style
diff options
context:
space:
mode:
Diffstat (limited to 'layout/style')
-rw-r--r--layout/style/FontFaceSet.cpp15
-rw-r--r--layout/style/nsCSSPropList.h2
-rw-r--r--layout/style/nsComputedDOMStyle.cpp67
-rw-r--r--layout/style/nsComputedDOMStyle.h12
-rw-r--r--layout/style/nsRuleNode.cpp3
-rw-r--r--layout/style/nsStyleStruct.h2
-rw-r--r--layout/style/test/property_database.js4
7 files changed, 63 insertions, 42 deletions
diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp
index 1645adfef..81c5ede0e 100644
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -583,6 +583,19 @@ FontFaceSet::StartLoad(gfxUserFontEntry* aUserFontEntry,
nsCOMPtr<nsIStreamLoader> streamLoader;
nsCOMPtr<nsILoadGroup> loadGroup(mDocument->GetDocumentLoadGroup());
+ // We're determining the security flags for font loading here based on
+ // scheme, because we want to allow fonts to be loaded using file:
+ // even if unique origins for file: access is enforced (allow CORS
+ // bypass in this case).
+ uint32_t securityFlags = 0;
+ bool isFile = false;
+ if (NS_SUCCEEDED(aFontFaceSrc->mURI->SchemeIs("file", &isFile)) &&
+ isFile) {
+ securityFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
+ } else {
+ securityFlags = nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS;
+ }
+
nsCOMPtr<nsIChannel> channel;
// Note we are calling NS_NewChannelWithTriggeringPrincipal() with both a
// node and a principal. This is because the document where the font is
@@ -592,7 +605,7 @@ FontFaceSet::StartLoad(gfxUserFontEntry* aUserFontEntry,
aFontFaceSrc->mURI,
mDocument,
aUserFontEntry->GetPrincipal(),
- nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS,
+ securityFlags,
nsIContentPolicy::TYPE_FONT,
loadGroup);
NS_ENSURE_SUCCESS(rv, rv);
diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h
index 2049f70e8..07db6d3dd 100644
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -1499,7 +1499,7 @@ CSS_PROP_COLUMN(
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_VALUE_NONNEGATIVE,
"",
- VARIANT_HL | VARIANT_NORMAL | VARIANT_CALC,
+ VARIANT_HLP | VARIANT_NORMAL | VARIANT_CALC,
nullptr,
offsetof(nsStyleColumn, mColumnGap),
eStyleAnimType_Coord)
diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp
index 65c1d698c..647f7f6dc 100644
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -64,13 +64,13 @@ using namespace mozilla::dom;
*/
already_AddRefed<nsComputedDOMStyle>
-NS_NewComputedDOMStyle(dom::Element* aElement, const nsAString& aPseudoElt,
- nsIPresShell* aPresShell,
+NS_NewComputedDOMStyle(dom::Element* aElement,
+ const nsAString& aPseudoElt,
+ nsIDocument* aDocument,
nsComputedDOMStyle::StyleType aStyleType)
{
RefPtr<nsComputedDOMStyle> computedStyle;
- computedStyle = new nsComputedDOMStyle(aElement, aPseudoElt, aPresShell,
- aStyleType);
+ computedStyle = new nsComputedDOMStyle(aElement, aPseudoElt, aDocument, aStyleType);
return computedStyle.forget();
}
@@ -243,7 +243,7 @@ nsComputedStyleMap::Update()
nsComputedDOMStyle::nsComputedDOMStyle(dom::Element* aElement,
const nsAString& aPseudoElt,
- nsIPresShell* aPresShell,
+ nsIDocument* aDocument,
StyleType aStyleType)
: mDocumentWeak(nullptr)
, mOuterFrame(nullptr)
@@ -254,11 +254,13 @@ nsComputedDOMStyle::nsComputedDOMStyle(dom::Element* aElement,
, mExposeVisitedStyle(false)
, mResolvedStyleContext(false)
{
- MOZ_ASSERT(aElement && aPresShell);
+ MOZ_ASSERT(aElement);
+ MOZ_ASSERT(aDocument);
+ // TODO(emilio, bug 548397, https://github.com/w3c/csswg-drafts/issues/2403):
+ // Should use aElement->OwnerDoc() instead.
+ mDocumentWeak = do_GetWeakReference(aDocument);
- mDocumentWeak = do_GetWeakReference(aPresShell->GetDocument());
-
- mContent = aElement;
+ mElement = aElement;
if (!DOMStringIsNull(aPseudoElt) && !aPseudoElt.IsEmpty() &&
aPseudoElt.First() == char16_t(':')) {
@@ -285,8 +287,6 @@ nsComputedDOMStyle::nsComputedDOMStyle(dom::Element* aElement,
mPseudo = nullptr;
}
}
-
- MOZ_ASSERT(aPresShell->GetPresContext());
}
nsComputedDOMStyle::~nsComputedDOMStyle()
@@ -297,13 +297,13 @@ nsComputedDOMStyle::~nsComputedDOMStyle()
NS_IMPL_CYCLE_COLLECTION_CLASS(nsComputedDOMStyle)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsComputedDOMStyle)
- tmp->ClearStyleContext(); // remove observer before clearing mContent
- NS_IMPL_CYCLE_COLLECTION_UNLINK(mContent)
+ tmp->ClearStyleContext(); // remove observer before clearing mElement
+ NS_IMPL_CYCLE_COLLECTION_UNLINK(mElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsComputedDOMStyle)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContent)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsComputedDOMStyle)
@@ -366,8 +366,6 @@ nsComputedDOMStyle::SetCssText(const nsAString& aCssText)
NS_IMETHODIMP
nsComputedDOMStyle::GetLength(uint32_t* aLength)
{
- NS_PRECONDITION(aLength, "Null aLength! Prepare to die!");
-
uint32_t length = GetComputedStyleMap()->Length();
// Make sure we have up to date style so that we can include custom
@@ -375,6 +373,8 @@ nsComputedDOMStyle::GetLength(uint32_t* aLength)
UpdateCurrentStyleSources(false);
if (mStyleContext) {
length += StyleVariables()->mVariables.Count();
+ } else {
+ length = 0;
}
*aLength = length;
@@ -616,7 +616,7 @@ nsComputedDOMStyle::ClearStyleContext()
{
if (mResolvedStyleContext) {
mResolvedStyleContext = false;
- mContent->RemoveMutationObserver(this);
+ mElement->RemoveMutationObserver(this);
}
mStyleContext = nullptr;
}
@@ -626,7 +626,7 @@ nsComputedDOMStyle::SetResolvedStyleContext(RefPtr<nsStyleContext>&& aContext)
{
if (!mResolvedStyleContext) {
mResolvedStyleContext = true;
- mContent->AddMutationObserver(this);
+ mElement->AddMutationObserver(this);
}
mStyleContext = aContext;
}
@@ -651,7 +651,7 @@ nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush)
// Flush _before_ getting the presshell, since that could create a new
// presshell. Also note that we want to flush the style on the document
- // we're computing style in, not on the document mContent is in -- the two
+ // we're computing style in, not on the document mElement is in -- the two
// may be different.
document->FlushPendingNotifications(
aNeedsLayoutFlush ? Flush_Layout : Flush_Style);
@@ -659,7 +659,7 @@ nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush)
mFlushedPendingReflows = aNeedsLayoutFlush;
#endif
- nsCOMPtr<nsIPresShell> presShellForContent = GetPresShellForContent(mContent);
+ nsCOMPtr<nsIPresShell> presShellForContent = GetPresShellForContent(mElement);
if (presShellForContent && presShellForContent != document->GetShell()) {
presShellForContent->FlushPendingNotifications(Flush_Style);
}
@@ -674,7 +674,11 @@ nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush)
mPresShell->GetPresContext()->GetRestyleGeneration();
if (mStyleContext) {
- if (mStyleContextGeneration == currentGeneration) {
+ // We can't rely on the undisplayed restyle generation if mElement is
+ // out-of-document, since that generation is not incremented for DOM changes
+ // on out-of-document elements.
+ if (mStyleContextGeneration == currentGeneration &&
+ mElement->IsInComposedDoc()) {
// Our cached style context is still valid.
return;
}
@@ -683,12 +687,12 @@ nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush)
mStyleContext = nullptr;
}
- // XXX the !mContent->IsHTMLElement(nsGkAtoms::area)
+ // XXX the !mElement->IsHTMLElement(nsGkAtoms::area)
// check is needed due to bug 135040 (to avoid using
// mPrimaryFrame). Remove it once that's fixed.
if (!mPseudo && mStyleType == eAll &&
- !mContent->IsHTMLElement(nsGkAtoms::area)) {
- mOuterFrame = mContent->GetPrimaryFrame();
+ !mElement->IsHTMLElement(nsGkAtoms::area)) {
+ mOuterFrame = mElement->GetPrimaryFrame();
mInnerFrame = mOuterFrame;
if (mOuterFrame) {
nsIAtom* type = mOuterFrame->GetType();
@@ -731,7 +735,7 @@ nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush)
// Need to resolve a style context
RefPtr<nsStyleContext> resolvedStyleContext =
nsComputedDOMStyle::GetStyleContextForElementNoFlush(
- mContent->AsElement(),
+ mElement,
mPseudo,
presShellForContent ? presShellForContent.get() : mPresShell,
mStyleType);
@@ -824,7 +828,6 @@ nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName, ErrorRes
UpdateCurrentStyleSources(needsLayoutFlush);
if (!mStyleContext) {
- aRv.Throw(NS_ERROR_NOT_AVAILABLE);
return nullptr;
}
@@ -2861,7 +2864,7 @@ nsComputedDOMStyle::DoGetGridTemplateColumns()
nsGridContainerFrame* gridFrame =
nsGridContainerFrame::GetGridFrameWithComputedInfo(
- mContent->GetPrimaryFrame());
+ mElement->GetPrimaryFrame());
if (gridFrame) {
info = gridFrame->GetComputedTemplateColumns();
@@ -2877,7 +2880,7 @@ nsComputedDOMStyle::DoGetGridTemplateRows()
nsGridContainerFrame* gridFrame =
nsGridContainerFrame::GetGridFrameWithComputedInfo(
- mContent->GetPrimaryFrame());
+ mElement->GetPrimaryFrame());
if (gridFrame) {
info = gridFrame->GetComputedTemplateRows();
@@ -5214,8 +5217,10 @@ nsComputedDOMStyle::GetLineHeightCoord(nscoord& aCoord)
// lie about font size inflation since we lie about font size (since
// the inflation only applies to text)
- aCoord = ReflowInput::CalcLineHeight(mContent, mStyleContext,
- blockHeight, 1.0f);
+ aCoord = ReflowInput::CalcLineHeight(mElement,
+ mStyleContext,
+ blockHeight,
+ 1.0f);
// CalcLineHeight uses font->mFont.size, but we want to use
// font->mSize as the font size. Adjust for that. Also adjust for
@@ -6642,7 +6647,7 @@ nsComputedDOMStyle::DoGetCustomProperty(const nsAString& aPropertyName)
void
nsComputedDOMStyle::ParentChainChanged(nsIContent* aContent)
{
- NS_ASSERTION(mContent == aContent, "didn't we register mContent?");
+ NS_ASSERTION(mElement == aContent, "didn't we register mElement?");
NS_ASSERTION(mResolvedStyleContext,
"should have only registered an observer when "
"mResolvedStyleContext is true");
diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h
index 77df71ec8..7fbf49afe 100644
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -76,12 +76,12 @@ public:
nsComputedDOMStyle(mozilla::dom::Element* aElement,
const nsAString& aPseudoElt,
- nsIPresShell* aPresShell,
+ nsIDocument* aDocument,
StyleType aStyleType);
- virtual nsINode *GetParentObject() override
+ nsINode *GetParentObject() override
{
- return mContent;
+ return mElement;
}
static already_AddRefed<nsStyleContext>
@@ -667,9 +667,9 @@ private:
// We don't really have a good immutable representation of "presentation".
// Given the way GetComputedStyle is currently used, we should just grab the
- // 0th presshell, if any, from the document.
+ // presshell, if any, from the document.
nsWeakPtr mDocumentWeak;
- nsCOMPtr<nsIContent> mContent;
+ RefPtr<mozilla::dom::Element> mElement;
/**
* Strong reference to the style context we access data from. This can be
@@ -735,7 +735,7 @@ private:
already_AddRefed<nsComputedDOMStyle>
NS_NewComputedDOMStyle(mozilla::dom::Element* aElement,
const nsAString& aPseudoElt,
- nsIPresShell* aPresShell,
+ nsIDocument* aDocument,
nsComputedDOMStyle::StyleType aStyleType =
nsComputedDOMStyle::eAll);
diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp
index 08400635b..a0f65c069 100644
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -67,6 +67,9 @@
#define alloca _alloca
#endif
#endif
+#ifdef XP_SOLARIS
+#include <alloca.h>
+#endif
using std::max;
using std::min;
diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h
index c8182b8f1..b257c6bb5 100644
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -3495,7 +3495,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColumn
uint32_t mColumnCount; // [reset] see nsStyleConsts.h
nsStyleCoord mColumnWidth; // [reset] coord, auto
- nsStyleCoord mColumnGap; // [reset] coord, normal
+ nsStyleCoord mColumnGap; // [reset] <length-percentage> | normal
mozilla::StyleComplexColor mColumnRuleColor; // [reset]
uint8_t mColumnRuleStyle; // [reset]
diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js
index 272931c15..c75f7b498 100644
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -1438,7 +1438,7 @@ var gCSSProperties = {
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: [ "normal", "1em", "calc(-2em + 3em)" ],
- other_values: [ "2px", "4em",
+ other_values: [ "2px", "1em", "4em", "3%", "calc(3%)", "calc(1em - 3%)",
"calc(2px)",
"calc(-2px)",
"calc(0px)",
@@ -1448,7 +1448,7 @@ var gCSSProperties = {
"calc(25px*3)",
"calc(3*25px + 5em)",
],
- invalid_values: [ "3%", "-1px", "4" ]
+ invalid_values: [ "-3%", "-1px", "4" ]
},
"-moz-column-gap": {
domProp: "MozColumnGap",