Home | History | Annotate | Download | only in css
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef MediaValuesCached_h
      6 #define MediaValuesCached_h
      7 
      8 #include "core/css/MediaValues.h"
      9 
     10 namespace WebCore {
     11 
     12 class MediaValuesCached FINAL : public MediaValues {
     13 public:
     14     struct MediaValuesCachedData {
     15         // Members variables must be thread safe, since they're copied to the parser thread
     16         int viewportWidth;
     17         int viewportHeight;
     18         int deviceWidth;
     19         int deviceHeight;
     20         float devicePixelRatio;
     21         int colorBitsPerComponent;
     22         int monochromeBitsPerComponent;
     23         PointerDeviceType pointer;
     24         int defaultFontSize;
     25         bool threeDEnabled;
     26         bool scanMediaType;
     27         bool screenMediaType;
     28         bool printMediaType;
     29         bool strictMode;
     30 
     31         MediaValuesCachedData()
     32             : viewportWidth(0)
     33             , viewportHeight(0)
     34             , deviceWidth(0)
     35             , deviceHeight(0)
     36             , devicePixelRatio(1.0)
     37             , colorBitsPerComponent(24)
     38             , monochromeBitsPerComponent(0)
     39             , pointer(UnknownPointer)
     40             , defaultFontSize(16)
     41             , threeDEnabled(false)
     42             , scanMediaType(false)
     43             , screenMediaType(true)
     44             , printMediaType(false)
     45             , strictMode(true)
     46         {
     47         }
     48     };
     49 
     50     static PassRefPtr<MediaValues> create();
     51     static PassRefPtr<MediaValues> create(Document&);
     52     static PassRefPtr<MediaValues> create(LocalFrame*);
     53     static PassRefPtr<MediaValues> create(MediaValuesCachedData&);
     54     virtual PassRefPtr<MediaValues> copy() const OVERRIDE;
     55     virtual bool isSafeToSendToAnotherThread() const OVERRIDE;
     56     virtual bool computeLength(double value, CSSPrimitiveValue::UnitType, int& result) const OVERRIDE;
     57     virtual bool computeLength(double value, CSSPrimitiveValue::UnitType, double& result) const OVERRIDE;
     58 
     59     virtual int viewportWidth() const OVERRIDE;
     60     virtual int viewportHeight() const OVERRIDE;
     61     virtual int deviceWidth() const OVERRIDE;
     62     virtual int deviceHeight() const OVERRIDE;
     63     virtual float devicePixelRatio() const OVERRIDE;
     64     virtual int colorBitsPerComponent() const OVERRIDE;
     65     virtual int monochromeBitsPerComponent() const OVERRIDE;
     66     virtual PointerDeviceType pointer() const OVERRIDE;
     67     virtual bool threeDEnabled() const OVERRIDE;
     68     virtual bool scanMediaType() const OVERRIDE;
     69     virtual bool screenMediaType() const OVERRIDE;
     70     virtual bool printMediaType() const OVERRIDE;
     71     virtual bool strictMode() const OVERRIDE;
     72     virtual Document* document() const OVERRIDE;
     73     virtual bool hasValues() const OVERRIDE;
     74 
     75 protected:
     76     MediaValuesCached();
     77     MediaValuesCached(LocalFrame*);
     78     MediaValuesCached(const MediaValuesCachedData&);
     79 
     80     MediaValuesCachedData m_data;
     81 };
     82 
     83 } // namespace
     84 
     85 #endif // MediaValuesCached_h
     86