OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "platform/geometry/IntSize.h" | 37 #include "platform/geometry/IntSize.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 // This class harmonizes the viewport (particularly page scale) constraints from | 41 // This class harmonizes the viewport (particularly page scale) constraints from |
42 // the meta viewport tag and other sources. | 42 // the meta viewport tag and other sources. |
43 class PageScaleConstraintsSet { | 43 class PageScaleConstraintsSet { |
44 public: | 44 public: |
45 PageScaleConstraintsSet(); | 45 PageScaleConstraintsSet(); |
46 | 46 |
47 blink::PageScaleConstraints defaultConstraints() const; | 47 PageScaleConstraints defaultConstraints() const; |
48 | 48 |
49 // Settings defined in the website's viewport tag, if viewport tag support | 49 // Settings defined in the website's viewport tag, if viewport tag support |
50 // is enabled. | 50 // is enabled. |
51 const blink::PageScaleConstraints& pageDefinedConstraints() const { return m
_pageDefinedConstraints; } | 51 const PageScaleConstraints& pageDefinedConstraints() const { return m_pageDe
finedConstraints; } |
52 void updatePageDefinedConstraints(const blink::ViewportDescription&, blink::
Length legacyFallbackWidth); | 52 void updatePageDefinedConstraints(const ViewportDescription&, Length legacyF
allbackWidth); |
53 void adjustForAndroidWebViewQuirks(const blink::ViewportDescription&, int la
youtFallbackWidth, float deviceScaleFactor, bool supportTargetDensityDPI, bool w
ideViewportQuirkEnabled, bool useWideViewport, bool loadWithOverviewMode, bool n
onUserScalableQuirkEnabled); | 53 void adjustForAndroidWebViewQuirks(const ViewportDescription&, int layoutFal
lbackWidth, float deviceScaleFactor, bool supportTargetDensityDPI, bool wideView
portQuirkEnabled, bool useWideViewport, bool loadWithOverviewMode, bool nonUserS
calableQuirkEnabled); |
54 | 54 |
55 // Constraints may also be set from Chromium -- this overrides any | 55 // Constraints may also be set from Chromium -- this overrides any |
56 // page-defined values. | 56 // page-defined values. |
57 const blink::PageScaleConstraints& userAgentConstraints() const { return m_u
serAgentConstraints; } | 57 const PageScaleConstraints& userAgentConstraints() const { return m_userAgen
tConstraints; } |
58 void setUserAgentConstraints(const blink::PageScaleConstraints&); | 58 void setUserAgentConstraints(const PageScaleConstraints&); |
59 | 59 |
60 // Actual computed values, taking into account the above plus the current | 60 // Actual computed values, taking into account the above plus the current |
61 // viewport size and document width. | 61 // viewport size and document width. |
62 const blink::PageScaleConstraints& finalConstraints() const { return m_final
Constraints; } | 62 const PageScaleConstraints& finalConstraints() const { return m_finalConstra
ints; } |
63 void computeFinalConstraints(); | 63 void computeFinalConstraints(); |
64 void adjustFinalConstraintsToContentsSize(blink::IntSize contentsSize, int n
onOverlayScrollbarWidth); | 64 void adjustFinalConstraintsToContentsSize(IntSize contentsSize, int nonOverl
ayScrollbarWidth); |
65 | 65 |
66 void didChangeContentsSize(blink::IntSize contentsSize, float pageScaleFacto
r); | 66 void didChangeContentsSize(IntSize contentsSize, float pageScaleFactor); |
67 | 67 |
68 // This should be set to true on each page load to note that the page scale | 68 // This should be set to true on each page load to note that the page scale |
69 // factor needs to be reset to its initial value. | 69 // factor needs to be reset to its initial value. |
70 void setNeedsReset(bool); | 70 void setNeedsReset(bool); |
71 bool needsReset() const { return m_needsReset; } | 71 bool needsReset() const { return m_needsReset; } |
72 | 72 |
73 // This is set when one of the inputs to finalConstraints changes. | 73 // This is set when one of the inputs to finalConstraints changes. |
74 bool constraintsDirty() const { return m_constraintsDirty; } | 74 bool constraintsDirty() const { return m_constraintsDirty; } |
75 | 75 |
76 void didChangeViewSize(const blink::IntSize&); | 76 void didChangeViewSize(const IntSize&); |
77 | 77 |
78 blink::IntSize mainFrameSize(const blink::IntSize& contentsSize) const; | 78 IntSize mainFrameSize(const IntSize& contentsSize) const; |
79 | 79 |
80 private: | 80 private: |
81 blink::PageScaleConstraints computeConstraintsStack() const; | 81 PageScaleConstraints computeConstraintsStack() const; |
82 | 82 |
83 blink::PageScaleConstraints m_pageDefinedConstraints; | 83 PageScaleConstraints m_pageDefinedConstraints; |
84 blink::PageScaleConstraints m_userAgentConstraints; | 84 PageScaleConstraints m_userAgentConstraints; |
85 blink::PageScaleConstraints m_finalConstraints; | 85 PageScaleConstraints m_finalConstraints; |
86 | 86 |
87 int m_lastContentsWidth; | 87 int m_lastContentsWidth; |
88 blink::IntSize m_viewSize; | 88 IntSize m_viewSize; |
89 | 89 |
90 bool m_needsReset; | 90 bool m_needsReset; |
91 bool m_constraintsDirty; | 91 bool m_constraintsDirty; |
92 }; | 92 }; |
93 | 93 |
94 } // namespace blink | 94 } // namespace blink |
95 | 95 |
96 #endif // PageScaleConstraintsSet_h | 96 #endif // PageScaleConstraintsSet_h |
OLD | NEW |