~suaweb/nginx/nginx-recipe

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/third_party/css_parser/src/webutil/css/util.h

  • Committer: Frans Elliott
  • Date: 2015-06-12 21:15:13 UTC
  • Revision ID: mastergeek.elliott@gmail.com-20150612211513-un4vguj32deibvb0
Added the actual pagespeed library to the ngx_pagespeed module dir.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright 2010 Google Inc.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
// Copyright 2007 Google Inc. All Rights Reserved.
 
18
// Author: yian@google.com (Yian Huang)
 
19
// Author: dpeng@google.com (Daniel Peng)
 
20
 
 
21
#ifndef WEBUTIL_CSS_UTIL_H__
 
22
#define WEBUTIL_CSS_UTIL_H__
 
23
 
 
24
#include <string>
 
25
#include <vector>
 
26
 
 
27
#include "strings/stringpiece.h"
 
28
#include "webutil/css/string.h"
 
29
 
 
30
class HtmlColor;
 
31
class UnicodeText;
 
32
 
 
33
namespace Css {
 
34
 
 
35
class MediaQueries;
 
36
class Value;
 
37
 
 
38
namespace Util {
 
39
 
 
40
enum COLOR_ATTR {ORIGINAL, TRANSPARENT, UNKNOWN, INHERIT};
 
41
 
 
42
// Parses CSS color value (may be a string, identifier or a color) into
 
43
// HtmlColor. returns def if the color is invalid. set attr to one of the
 
44
// following attributes: ORIGINAL if the color is valid, INHERIT if it is the
 
45
// keyword inherit, UNKNOWN if it is the keywoard unknown, TRANSPARENT
 
46
// if it is invalid otherwise.
 
47
HtmlColor GetCssColor(const Css::Value* val, const HtmlColor& def,
 
48
                      COLOR_ATTR* attr);
 
49
 
 
50
// Converts length or percentage string to absolute px units. Refer to
 
51
// parent_size when seeing 10% (invalid if parent_size is -1). Refer to
 
52
// font_size when seeing 1.2EM or 1.2EX. Invalid if val is NULL or it is not
 
53
// a number. It can also be invalid if can_negative is set and the value is
 
54
// negative, can_unitless works similarly. Returns if parsing succeeds, and
 
55
// if so, size stores the result.
 
56
bool GetCssLength(const Css::Value* val, double parent_size,
 
57
                  double font_size, double unit, bool can_negative,
 
58
                  bool can_unitless, double* size);
 
59
 
 
60
// Updates color with system color specified in colorstr. The change is only
 
61
// done only when the conversion succeeds, indicated by the return value.
 
62
// For a list of system colors, please see
 
63
//   http://www.w3.org/TR/CSS21/ui.html#system-colors
 
64
// Actual system colors depend on OS's graphic environment. For the purpose
 
65
// of hidden text detection, we assume a typical setting based on Windows XP
 
66
// default theme.
 
67
bool GetSystemColor(const string& colorstr, HtmlColor* color);
 
68
 
 
69
// Whether a media string (comma separated list of media) is compatible with
 
70
// screen-oriented applications. It is valid if no media is specified or some
 
71
// medium has the name "screen" or "all".
 
72
bool MediaAppliesToScreen(const StringPiece& media);
 
73
 
 
74
// Whether a media list is compatible with screen-oriented applications. It
 
75
// is valid if no media is specified or some medium has the name "screen" or
 
76
// "all".
 
77
bool MediaAppliesToScreen(const std::vector<UnicodeText>& media);
 
78
 
 
79
// Note: Operates like a naive CSS2 parser, only returning true if media type
 
80
// is "screen" or "all" and there are no qualifiers. Media expressions are
 
81
// ignored.
 
82
bool MediaAppliesToScreen(const Css::MediaQueries& media);
 
83
 
 
84
}  // namespace Util
 
85
}  // namespace Css
 
86
 
 
87
#endif  // WEBUTIL_CSS_UTIL_H__