Skip to content

Commit

Permalink
Sync for validator/cpp/engine (#33283)
Browse files Browse the repository at this point in the history
* Fix missing dependencies in bazel

PiperOrigin-RevId: 361950699

* Fix compile errors by using re2::StringPiece

PiperOrigin-RevId: 362134025

Co-authored-by: Boxiao Cao <caoboxiao@google.com>
  • Loading branch information
Greg Grothaus and caoboxiao committed Mar 16, 2021
1 parent f83aa2c commit e3f6871
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions validator/cpp/engine/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ cc_library(
hdrs = [
"testing-utils.h",
],
data = [
"@validator//:testdata_files",
"@amphtml-extensions//:testdata_files",
],
deps = [
":error-formatter",
"@com_google_absl//absl/strings",
Expand Down
4 changes: 3 additions & 1 deletion validator/cpp/engine/parse-layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ CssLength::CssLength()
is_fluid(false),
numeral(std::numeric_limits<double>::quiet_NaN()),
unit(kUnitPx) {}
CssLength::CssLength(string_view input, bool allow_auto, bool allow_fluid)
CssLength::CssLength(
re2::StringPiece input,
bool allow_auto, bool allow_fluid)
: is_valid(false),
is_set(false),
is_auto(false),
Expand Down
6 changes: 4 additions & 2 deletions validator/cpp/engine/parse-layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "absl/strings/string_view.h"
#include "validator.pb.h"
#include "re2/re2.h"

namespace amp::validator::parse_layout {

Expand Down Expand Up @@ -50,8 +51,9 @@ struct CssLength {
// Parses a given |input| value. |allow_auto| determines whether 'auto'
// is accepted as a value. |allow_fluid| determines whether 'fluid' is
// accepted as a value.
explicit CssLength(absl::string_view input, bool allow_auto,
bool allow_fluid);
explicit CssLength(
re2::StringPiece input,
bool allow_auto, bool allow_fluid);
};

// Interprets a |layout| string, such as fixed-height, as
Expand Down
4 changes: 3 additions & 1 deletion validator/cpp/engine/parse-srcset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ using std::vector;

namespace amp::validator::parse_srcset {
// If parsing fails, returns false in SrcsetParsingResult.status.
SrcsetParsingResult ParseSourceSet(absl::string_view srcset) {
SrcsetParsingResult ParseSourceSet(
re2::StringPiece srcset
) {
// Regex for leading spaces, followed by an optional comma and whitespace,
// followed by an URL*, followed by an optional space, followed by an
// optional width or pixel density**, followed by spaces, followed by an
Expand Down
5 changes: 4 additions & 1 deletion validator/cpp/engine/parse-srcset.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "absl/strings/string_view.h"
#include "validator.pb.h"
#include "re2/re2.h"

namespace amp::validator::parse_srcset {

Expand Down Expand Up @@ -56,7 +57,9 @@ struct SrcsetParsingResult {
// will be non-empty.
//
// Returns SrcsetParsingResult.
SrcsetParsingResult ParseSourceSet(absl::string_view srcset);
SrcsetParsingResult ParseSourceSet(
re2::StringPiece srcset
);

} // namespace amp::validator::parse_srcset

Expand Down

0 comments on commit e3f6871

Please sign in to comment.