зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1408312 - Part 1: Add ServoCSSParser utility class. r=xidorn
MozReview-Commit-ID: KzM9332hBSx --HG-- extra : rebase_source : c048323e36bef9dceb3c86d3cc9ee66aa39efb51
This commit is contained in:
Родитель
19dcaa9aa1
Коммит
b9be378e65
|
@ -682,6 +682,14 @@ SERVO_BINDING_FUNC(Servo_ReleaseArcStringData, void,
|
|||
SERVO_BINDING_FUNC(Servo_CloneArcStringData, mozilla::ServoRawOffsetArc<RustString>,
|
||||
const mozilla::ServoRawOffsetArc<RustString>* string);
|
||||
|
||||
// CSS parsing utility functions.
|
||||
SERVO_BINDING_FUNC(Servo_IsValidCSSColor, bool, const nsAString* value);
|
||||
SERVO_BINDING_FUNC(Servo_ComputeColor, bool,
|
||||
RawServoStyleSetBorrowedOrNull set,
|
||||
nscolor current_color,
|
||||
const nsAString* value,
|
||||
nscolor* result_color);
|
||||
|
||||
// AddRef / Release functions
|
||||
#define SERVO_ARC_TYPE(name_, type_) \
|
||||
SERVO_BINDING_FUNC(Servo_##name_##_AddRef, void, type_##Borrowed) \
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
/* CSS parsing utility functions */
|
||||
|
||||
#include "ServoCSSParser.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
/* static */ bool
|
||||
ServoCSSParser::IsValidCSSColor(const nsAString& aValue)
|
||||
{
|
||||
return Servo_IsValidCSSColor(&aValue);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
ServoCSSParser::ComputeColor(ServoStyleSet* aStyleSet,
|
||||
nscolor aCurrentColor,
|
||||
const nsAString& aValue,
|
||||
nscolor* aResultColor)
|
||||
{
|
||||
return Servo_ComputeColor(aStyleSet ? aStyleSet->RawSet() : nullptr,
|
||||
aCurrentColor, &aValue, aResultColor);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
/* CSS parsing utility functions */
|
||||
|
||||
#ifndef mozilla_ServoCSSParser_h
|
||||
#define mozilla_ServoCSSParser_h
|
||||
|
||||
#include "mozilla/ServoBindings.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ServoCSSParser
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Returns whether the specified string can be parsed as a valid CSS
|
||||
* <color> value.
|
||||
*
|
||||
* This includes Mozilla-specific keywords such as -moz-default-color.
|
||||
*/
|
||||
static bool IsValidCSSColor(const nsAString& aValue);
|
||||
|
||||
/**
|
||||
* Computes an nscolor from the given CSS <color> value.
|
||||
*
|
||||
* @param aStyleSet The style set whose nsPresContext will be used to
|
||||
* compute system colors and other special color values.
|
||||
* @param aCurrentColor The color value that currentcolor should compute to.
|
||||
* @param aValue The CSS <color> value.
|
||||
* @param aResultColor The resulting computed color value.
|
||||
* @return Whether aValue was successfully parsed and aResultColor was set.
|
||||
*/
|
||||
static bool ComputeColor(ServoStyleSet* aStyleSet,
|
||||
nscolor aCurrentColor,
|
||||
const nsAString& aValue,
|
||||
nscolor* aResultColor);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_ServoCSSParser_h
|
|
@ -103,6 +103,7 @@ EXPORTS.mozilla += [
|
|||
'ServoBindingList.h',
|
||||
'ServoBindings.h',
|
||||
'ServoBindingTypes.h',
|
||||
'ServoCSSParser.h',
|
||||
'ServoCSSRuleList.h',
|
||||
'ServoDeclarationBlock.h',
|
||||
'ServoDocumentRule.h',
|
||||
|
@ -249,6 +250,7 @@ UNIFIED_SOURCES += [
|
|||
'RuleNodeCacheConditions.cpp',
|
||||
'RuleProcessorCache.cpp',
|
||||
'ServoBindings.cpp',
|
||||
'ServoCSSParser.cpp',
|
||||
'ServoCSSRuleList.cpp',
|
||||
'ServoDeclarationBlock.cpp',
|
||||
'ServoDocumentRule.cpp',
|
||||
|
|
Загрузка…
Ссылка в новой задаче