mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1420026 - Part 3: Report canvas color parsing errors to the console. r=TYLin
MozReview-Commit-ID: BcWat5wfGJJ --HG-- extra : rebase_source : 6ac8d7e8db6c2c08fb23670bbb0b3486b59a938d
This commit is contained in:
parent
040ca098ab
commit
9993c9819d
@ -1163,9 +1163,8 @@ bool
|
||||
CanvasRenderingContext2D::ParseColor(const nsAString& aString,
|
||||
nscolor* aColor)
|
||||
{
|
||||
nsIDocument* document = mCanvasElement
|
||||
? mCanvasElement->OwnerDoc()
|
||||
: nullptr;
|
||||
nsIDocument* document = mCanvasElement ? mCanvasElement->OwnerDoc() : nullptr;
|
||||
css::Loader* loader = document ? document->CSSLoader() : nullptr;
|
||||
|
||||
if (document->IsStyledByServo()) {
|
||||
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
|
||||
@ -1174,7 +1173,7 @@ CanvasRenderingContext2D::ParseColor(const nsAString& aString,
|
||||
// First, try computing the color without handling currentcolor.
|
||||
bool wasCurrentColor = false;
|
||||
if (!ServoCSSParser::ComputeColor(set, NS_RGB(0, 0, 0), aString, aColor,
|
||||
&wasCurrentColor)) {
|
||||
&wasCurrentColor, loader)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1190,7 +1189,7 @@ CanvasRenderingContext2D::ParseColor(const nsAString& aString,
|
||||
|
||||
// Pass the CSS Loader object to the parser, to allow parser error
|
||||
// reports to include the outer window ID.
|
||||
nsCSSParser parser(document ? document->CSSLoader() : nullptr);
|
||||
nsCSSParser parser(loader);
|
||||
nsCSSValue value;
|
||||
if (!parser.ParseColorString(aString, nullptr, 0, value)) {
|
||||
return false;
|
||||
|
@ -745,7 +745,8 @@ SERVO_BINDING_FUNC(Servo_ComputeColor, bool,
|
||||
nscolor current_color,
|
||||
const nsAString* value,
|
||||
nscolor* result_color,
|
||||
bool* was_current_color);
|
||||
bool* was_current_color,
|
||||
mozilla::css::Loader* loader)
|
||||
SERVO_BINDING_FUNC(Servo_ParseIntersectionObserverRootMargin, bool,
|
||||
const nsAString* value,
|
||||
nsCSSRect* result);
|
||||
|
@ -21,11 +21,12 @@ ServoCSSParser::ComputeColor(ServoStyleSet* aStyleSet,
|
||||
nscolor aCurrentColor,
|
||||
const nsAString& aValue,
|
||||
nscolor* aResultColor,
|
||||
bool* aWasCurrentColor)
|
||||
bool* aWasCurrentColor,
|
||||
css::Loader* aLoader)
|
||||
{
|
||||
return Servo_ComputeColor(aStyleSet ? aStyleSet->RawSet() : nullptr,
|
||||
aCurrentColor, &aValue, aResultColor,
|
||||
aWasCurrentColor);
|
||||
aWasCurrentColor, aLoader);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
|
@ -11,6 +11,12 @@
|
||||
|
||||
#include "mozilla/ServoBindings.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace css {
|
||||
class Loader;
|
||||
} // namespace css
|
||||
} // namespace mozilla
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ServoCSSParser
|
||||
@ -34,13 +40,17 @@ public:
|
||||
* @param aResultColor The resulting computed color value.
|
||||
* @param aWasCurrentColor Whether aValue was currentcolor. Can be nullptr
|
||||
* if the caller doesn't care.
|
||||
* @param aLoader The CSS loader for document we're parsing a color for,
|
||||
* so that parse errors can be reported to the console. If nullptr, errors
|
||||
* won't be reported to the console.
|
||||
* @return Whether aValue was successfully parsed and aResultColor was set.
|
||||
*/
|
||||
static bool ComputeColor(ServoStyleSet* aStyleSet,
|
||||
nscolor aCurrentColor,
|
||||
const nsAString& aValue,
|
||||
nscolor* aResultColor,
|
||||
bool* aWasCurrentColor = nullptr);
|
||||
bool* aWasCurrentColor = nullptr,
|
||||
css::Loader* aLoader = nullptr);
|
||||
|
||||
/**
|
||||
* Parses a IntersectionObserver's initialization dictionary's rootMargin
|
||||
|
Loading…
Reference in New Issue
Block a user