2017-01-11 01:48:29 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
|
|
|
|
// Main header first:
|
|
|
|
#include "SVGImageContext.h"
|
|
|
|
|
|
|
|
// Keep others in (case-insensitive) order:
|
|
|
|
#include "gfxUtils.h"
|
2017-04-05 10:44:16 +00:00
|
|
|
#include "nsContentUtils.h"
|
2017-03-08 04:10:29 +00:00
|
|
|
#include "nsIFrame.h"
|
2017-01-11 01:48:29 +00:00
|
|
|
#include "nsPresContext.h"
|
2017-04-12 11:47:32 +00:00
|
|
|
#include "nsStyleStruct.h"
|
2017-01-11 01:48:29 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2017-03-06 13:49:21 +00:00
|
|
|
/* static */ void
|
2017-03-28 10:43:15 +00:00
|
|
|
SVGImageContext::MaybeStoreContextPaint(Maybe<SVGImageContext>& aContext,
|
|
|
|
nsIFrame* aFromFrame,
|
|
|
|
imgIContainer* aImgContainer)
|
2017-01-11 01:48:29 +00:00
|
|
|
{
|
2017-04-13 18:47:51 +00:00
|
|
|
// This check is cheap, so we put it first:
|
2017-04-12 11:47:32 +00:00
|
|
|
if (!aFromFrame->StyleSVG()->ExposesContextProperties()) {
|
|
|
|
// Content must have '-moz-context-properties' set to the names of the
|
|
|
|
// properties it wants to expose to images it links to.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-06 13:49:21 +00:00
|
|
|
if (aImgContainer->GetType() != imgIContainer::TYPE_VECTOR) {
|
|
|
|
// Avoid this overhead for raster images.
|
|
|
|
return;
|
2017-01-11 01:48:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool haveContextPaint = false;
|
|
|
|
|
|
|
|
RefPtr<SVGEmbeddingContextPaint> contextPaint = new SVGEmbeddingContextPaint();
|
|
|
|
|
|
|
|
const nsStyleSVG* style = aFromFrame->StyleSVG();
|
|
|
|
|
|
|
|
// XXX don't set values for properties not listed in 'context-properties'.
|
|
|
|
|
|
|
|
if (style->mFill.Type() == eStyleSVGPaintType_Color) {
|
|
|
|
haveContextPaint = true;
|
|
|
|
contextPaint->SetFill(style->mFill.GetColor());
|
|
|
|
}
|
|
|
|
if (style->mStroke.Type() == eStyleSVGPaintType_Color) {
|
|
|
|
haveContextPaint = true;
|
|
|
|
contextPaint->SetStroke(style->mStroke.GetColor());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (haveContextPaint) {
|
2017-03-28 10:43:15 +00:00
|
|
|
if (!aContext) {
|
|
|
|
aContext.emplace();
|
|
|
|
}
|
2017-03-06 13:49:21 +00:00
|
|
|
aContext->mContextPaint = contextPaint.forget();
|
2017-01-11 01:48:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla
|