1 /* 2 * Copyright (C) 2012 Intel Corporation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above 12 * copyright notice, this list of conditions and the following 13 * disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_VIEWPORT_STYLE_RESOLVER_H_ 31 #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_VIEWPORT_STYLE_RESOLVER_H_ 32 33 #include "third_party/blink/renderer/core/core_export.h" 34 #include "third_party/blink/renderer/core/css/css_property_names.h" 35 #include "third_party/blink/renderer/core/css/rule_set.h" 36 #include "third_party/blink/renderer/core/page/viewport_description.h" 37 #include "third_party/blink/renderer/platform/geometry/length.h" 38 39 namespace blink { 40 41 class ComputedStyle; 42 class Document; 43 class DocumentStyleSheetCollection; 44 class MutableCSSPropertyValueSet; 45 class StyleRuleViewport; 46 47 class CORE_EXPORT ViewportStyleResolver final 48 : public GarbageCollected<ViewportStyleResolver> { 49 public: 50 explicit ViewportStyleResolver(Document&); 51 52 void InitialStyleChanged(); 53 void InitialViewportChanged(); 54 void SetNeedsCollectRules(); NeedsUpdate()55 bool NeedsUpdate() const { return needs_update_; } 56 void UpdateViewport(DocumentStyleSheetCollection&); 57 58 void CollectViewportRulesFromAuthorSheet(const CSSStyleSheet&); 59 60 void Trace(Visitor*) const; 61 62 private: 63 void Reset(); 64 void Resolve(); 65 66 enum Origin { kUserAgentOrigin, kAuthorOrigin }; 67 enum UpdateType { kNoUpdate, kResolve, kCollectRules }; 68 69 void CollectViewportRulesFromUASheets(); 70 void CollectViewportChildRules(const HeapVector<Member<StyleRuleBase>>&, 71 Origin); 72 void CollectViewportRulesFromImports(StyleSheetContents&); 73 void CollectViewportRulesFromAuthorSheetContents(StyleSheetContents&); 74 void AddViewportRule(StyleRuleViewport&, Origin); 75 76 float ViewportArgumentValue(CSSPropertyID) const; 77 Length ViewportLengthValue(CSSPropertyID); 78 mojom::ViewportFit ViewportFitValue() const; 79 80 Member<Document> document_; 81 Member<MutableCSSPropertyValueSet> property_set_; 82 Member<MediaQueryEvaluator> initial_viewport_medium_; 83 scoped_refptr<ComputedStyle> initial_style_; 84 MediaQueryResultList viewport_dependent_media_query_results_; 85 MediaQueryResultList device_dependent_media_query_results_; 86 bool has_author_style_ = false; 87 bool has_viewport_units_ = false; 88 UpdateType needs_update_ = kCollectRules; 89 }; 90 91 } // namespace blink 92 93 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_VIEWPORT_STYLE_RESOLVER_H_ 94