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 10namespace blink { 11 12class MediaValuesCached FINAL : public MediaValues { 13public: 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 PointerType primaryPointerType; 24 int availablePointerTypes; 25 HoverType primaryHoverType; 26 int availableHoverTypes; 27 int defaultFontSize; 28 bool threeDEnabled; 29 bool strictMode; 30 String mediaType; 31 32 MediaValuesCachedData() 33 : viewportWidth(0) 34 , viewportHeight(0) 35 , deviceWidth(0) 36 , deviceHeight(0) 37 , devicePixelRatio(1.0) 38 , colorBitsPerComponent(24) 39 , monochromeBitsPerComponent(0) 40 , primaryPointerType(PointerTypeNone) 41 , availablePointerTypes(PointerTypeNone) 42 , primaryHoverType(HoverTypeNone) 43 , availableHoverTypes(HoverTypeNone) 44 , defaultFontSize(16) 45 , threeDEnabled(false) 46 , strictMode(true) 47 { 48 } 49 }; 50 51 static PassRefPtr<MediaValues> create(); 52 static PassRefPtr<MediaValues> create(Document&); 53 static PassRefPtr<MediaValues> create(LocalFrame*); 54 static PassRefPtr<MediaValues> create(MediaValuesCachedData&); 55 virtual PassRefPtr<MediaValues> copy() const OVERRIDE; 56 virtual bool isSafeToSendToAnotherThread() const OVERRIDE; 57 virtual bool computeLength(double value, CSSPrimitiveValue::UnitType, int& result) const OVERRIDE; 58 virtual bool computeLength(double value, CSSPrimitiveValue::UnitType, double& result) const OVERRIDE; 59 60 virtual int viewportWidth() const OVERRIDE; 61 virtual int viewportHeight() const OVERRIDE; 62 virtual int deviceWidth() const OVERRIDE; 63 virtual int deviceHeight() const OVERRIDE; 64 virtual float devicePixelRatio() const OVERRIDE; 65 virtual int colorBitsPerComponent() const OVERRIDE; 66 virtual int monochromeBitsPerComponent() const OVERRIDE; 67 virtual PointerType primaryPointerType() const OVERRIDE; 68 virtual int availablePointerTypes() const OVERRIDE; 69 virtual HoverType primaryHoverType() const OVERRIDE; 70 virtual int availableHoverTypes() const OVERRIDE; 71 virtual bool threeDEnabled() const OVERRIDE; 72 virtual bool strictMode() const OVERRIDE; 73 virtual Document* document() const OVERRIDE; 74 virtual bool hasValues() const OVERRIDE; 75 virtual const String mediaType() const OVERRIDE; 76 77protected: 78 MediaValuesCached(); 79 MediaValuesCached(LocalFrame*); 80 MediaValuesCached(const MediaValuesCachedData&); 81 82 MediaValuesCachedData m_data; 83}; 84 85} // namespace 86 87#endif // MediaValuesCached_h 88