chromium/third_party/blink/renderer/core/css/media_query_exp.h

/*
 * CSS Media Query
 *
 * Copyright (C) 2006 Kimmo Kinnunen <[email protected]>.
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_MEDIA_QUERY_EXP_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_MEDIA_QUERY_EXP_H_

#include <optional>

#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/css/css_length_resolver.h"
#include "third_party/blink/renderer/core/css/css_numeric_literal_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/css_ratio_value.h"
#include "third_party/blink/renderer/core/css/css_value.h"
#include "third_party/blink/renderer/core/css/media_feature_names.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/core/layout/geometry/axis.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"

namespace WTF {
class StringBuilder;
}  // namespace WTF

namespace blink {

class CSSParserContext;
class CSSParserTokenRange;
class CSSParserTokenOffsets;

class CORE_EXPORT MediaQueryExpValue {};

// https://drafts.csswg.org/mediaqueries-4/#mq-syntax
enum class MediaQueryOperator {};

// This represents the following part of a <media-feature> (example):
//
//  (width >= 10px)
//         ^^^^^^^
//
struct CORE_EXPORT MediaQueryExpComparison {};

// There exists three types of <media-feature>s.
//
//  1) Boolean features, which is just the feature name, e.g. (color)
//  2) Plain features, which can appear in two different forms:
//       - Feature with specific value, e.g. (width: 100px)
//       - Feature with min/max prefix, e.g. (min-width: 100px)
//  3) Range features, which can appear in three different forms:
//       - Feature compared with value, e.g. (width >= 100px)
//       - Feature compared with value (reversed), e.g. (100px <= width)
//       - Feature within a certain range, e.g. (100px < width < 200px)
//
// In the first case, both |left| and |right| values are not set.
// In the second case, only |right| is set.
// In the third case, either |left| is set, |right| is set, or both, depending
// on the form.
//
// https://drafts.csswg.org/mediaqueries-4/#typedef-media-feature
struct CORE_EXPORT MediaQueryExpBounds {};

class CORE_EXPORT MediaQueryExp {};

// MediaQueryExpNode representing a tree of MediaQueryExp objects capable of
// nested/compound expressions.
class CORE_EXPORT MediaQueryExpNode
    : public GarbageCollected<MediaQueryExpNode> {};

class CORE_EXPORT MediaQueryFeatureExpNode : public MediaQueryExpNode {};

class CORE_EXPORT MediaQueryUnaryExpNode : public MediaQueryExpNode {};

class CORE_EXPORT MediaQueryNestedExpNode : public MediaQueryUnaryExpNode {};

class CORE_EXPORT MediaQueryFunctionExpNode : public MediaQueryUnaryExpNode {};

class CORE_EXPORT MediaQueryNotExpNode : public MediaQueryUnaryExpNode {};

class CORE_EXPORT MediaQueryCompoundExpNode : public MediaQueryExpNode {};

class CORE_EXPORT MediaQueryAndExpNode : public MediaQueryCompoundExpNode {};

class CORE_EXPORT MediaQueryOrExpNode : public MediaQueryCompoundExpNode {};

class CORE_EXPORT MediaQueryUnknownExpNode : public MediaQueryExpNode {};

template <>
struct DowncastTraits<MediaQueryFeatureExpNode> {};

template <>
struct DowncastTraits<MediaQueryNestedExpNode> {};

template <>
struct DowncastTraits<MediaQueryFunctionExpNode> {};

template <>
struct DowncastTraits<MediaQueryNotExpNode> {};

template <>
struct DowncastTraits<MediaQueryAndExpNode> {};

template <>
struct DowncastTraits<MediaQueryOrExpNode> {};

template <>
struct DowncastTraits<MediaQueryUnknownExpNode> {};

}  // namespace blink

WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS()
WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS()
WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS()
WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS()

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_MEDIA_QUERY_EXP_H_