summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/css/parser/SizesAttributeParser.h
blob: 3c7bc4ee260c25283576e9169a1f6818161fe982 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SizesAttributeParser_h
#define SizesAttributeParser_h

#include "core/css/MediaValues.h"
#include "core/css/parser/MediaQueryParser.h"
#include "platform/heap/Handle.h"
#include "wtf/text/WTFString.h"

namespace WebCore {

class SizesAttributeParser {
    STACK_ALLOCATED();
public:
    static unsigned findEffectiveSize(const String& attribute, PassRefPtr<MediaValues>);

private:
    SizesAttributeParser(PassRefPtr<MediaValues> mediaValues)
        : m_mediaValues(mediaValues)
        , m_length(0)
        , m_lengthWasSet(false)
    {
    }

    bool parse(Vector<MediaQueryToken>& tokens);
    bool parseMediaConditionAndLength(MediaQueryTokenIterator startToken, MediaQueryTokenIterator endToken);
    unsigned effectiveSize();
    bool calculateLengthInPixels(MediaQueryTokenIterator startToken, MediaQueryTokenIterator endToken, unsigned& result);
    bool mediaConditionMatches(PassRefPtrWillBeRawPtr<MediaQuerySet> mediaCondition);
    unsigned effectiveSizeDefaultValue();

    RefPtrWillBeMember<MediaQuerySet> m_mediaCondition;
    RefPtr<MediaValues> m_mediaValues;
    unsigned m_length;
    bool m_lengthWasSet;
};

} // namespace

#endif