OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "core/rendering/RenderFullScreen.h" | 26 #include "core/rendering/RenderFullScreen.h" |
27 | 27 |
28 #include "core/dom/Fullscreen.h" | 28 #include "core/dom/Fullscreen.h" |
| 29 #include "core/frame/FrameHost.h" |
| 30 #include "core/frame/Settings.h" |
| 31 #include "core/page/Chrome.h" |
| 32 #include "core/page/Page.h" |
29 #include "core/rendering/RenderBlockFlow.h" | 33 #include "core/rendering/RenderBlockFlow.h" |
30 | 34 |
| 35 #include "public/platform/WebScreenInfo.h" |
| 36 |
31 using namespace blink; | 37 using namespace blink; |
32 | 38 |
33 class RenderFullScreenPlaceholder final : public RenderBlockFlow { | 39 class RenderFullScreenPlaceholder final : public RenderBlockFlow { |
34 public: | 40 public: |
35 RenderFullScreenPlaceholder(RenderFullScreen* owner) | 41 RenderFullScreenPlaceholder(RenderFullScreen* owner) |
36 : RenderBlockFlow(0) | 42 : RenderBlockFlow(0) |
37 , m_owner(owner) | 43 , m_owner(owner) |
38 { | 44 { |
39 setDocumentForAnonymous(&owner->document()); | 45 setDocumentForAnonymous(&owner->document()); |
40 } | 46 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 87 |
82 // RenderObjects are unretained, so notify the document (which holds a point
er to a RenderFullScreen) | 88 // RenderObjects are unretained, so notify the document (which holds a point
er to a RenderFullScreen) |
83 // if its RenderFullScreen is destroyed. | 89 // if its RenderFullScreen is destroyed. |
84 Fullscreen& fullscreen = Fullscreen::from(document()); | 90 Fullscreen& fullscreen = Fullscreen::from(document()); |
85 if (fullscreen.fullScreenRenderer() == this) | 91 if (fullscreen.fullScreenRenderer() == this) |
86 fullscreen.fullScreenRendererDestroyed(); | 92 fullscreen.fullScreenRendererDestroyed(); |
87 | 93 |
88 RenderFlexibleBox::willBeDestroyed(); | 94 RenderFlexibleBox::willBeDestroyed(); |
89 } | 95 } |
90 | 96 |
91 static PassRefPtr<RenderStyle> createFullScreenStyle() | 97 void RenderFullScreen::updateStyle() |
92 { | 98 { |
93 RefPtr<RenderStyle> fullscreenStyle = RenderStyle::createDefaultStyle(); | 99 RefPtr<RenderStyle> fullscreenStyle = RenderStyle::createDefaultStyle(); |
94 | 100 |
95 // Create a stacking context: | 101 // Create a stacking context: |
96 fullscreenStyle->setZIndex(INT_MAX); | 102 fullscreenStyle->setZIndex(INT_MAX); |
97 | 103 |
98 fullscreenStyle->setFontDescription(FontDescription()); | 104 fullscreenStyle->setFontDescription(FontDescription()); |
99 fullscreenStyle->font().update(nullptr); | 105 fullscreenStyle->font().update(nullptr); |
100 | 106 |
101 fullscreenStyle->setDisplay(FLEX); | 107 fullscreenStyle->setDisplay(FLEX); |
102 fullscreenStyle->setJustifyContent(JustifyCenter); | 108 fullscreenStyle->setJustifyContent(JustifyCenter); |
103 fullscreenStyle->setAlignItems(ItemPositionCenter); | 109 fullscreenStyle->setAlignItems(ItemPositionCenter); |
104 fullscreenStyle->setFlexDirection(FlowColumn); | 110 fullscreenStyle->setFlexDirection(FlowColumn); |
105 | 111 |
106 fullscreenStyle->setPosition(FixedPosition); | 112 fullscreenStyle->setPosition(FixedPosition); |
107 fullscreenStyle->setWidth(Length(100.0, Percent)); | |
108 fullscreenStyle->setHeight(Length(100.0, Percent)); | |
109 fullscreenStyle->setLeft(Length(0, blink::Fixed)); | 113 fullscreenStyle->setLeft(Length(0, blink::Fixed)); |
110 fullscreenStyle->setTop(Length(0, blink::Fixed)); | 114 fullscreenStyle->setTop(Length(0, blink::Fixed)); |
| 115 if (document().page()->settings().pinchVirtualViewportEnabled()) { |
| 116 IntSize viewportSize = document().page()->frameHost().pinchViewport().si
ze(); |
| 117 fullscreenStyle->setWidth(Length(viewportSize.width(), blink::Fixed)); |
| 118 fullscreenStyle->setHeight(Length(viewportSize.height(), blink::Fixed)); |
| 119 } else { |
| 120 fullscreenStyle->setWidth(Length(100.0, Percent)); |
| 121 fullscreenStyle->setHeight(Length(100.0, Percent)); |
| 122 } |
111 | 123 |
112 fullscreenStyle->setBackgroundColor(StyleColor(Color::black)); | 124 fullscreenStyle->setBackgroundColor(StyleColor(Color::black)); |
113 | 125 |
114 return fullscreenStyle.release(); | 126 setStyle(fullscreenStyle); |
115 } | 127 } |
116 | 128 |
117 RenderObject* RenderFullScreen::wrapRenderer(RenderObject* object, RenderObject*
parent, Document* document) | 129 RenderObject* RenderFullScreen::wrapRenderer(RenderObject* object, RenderObject*
parent, Document* document) |
118 { | 130 { |
119 // FIXME: We should not modify the structure of the render tree during | 131 // FIXME: We should not modify the structure of the render tree during |
120 // layout. crbug.com/370459 | 132 // layout. crbug.com/370459 |
121 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; | 133 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
122 | 134 |
123 RenderFullScreen* fullscreenRenderer = RenderFullScreen::createAnonymous(doc
ument); | 135 RenderFullScreen* fullscreenRenderer = RenderFullScreen::createAnonymous(doc
ument); |
124 fullscreenRenderer->setStyle(createFullScreenStyle()); | 136 fullscreenRenderer->updateStyle(); |
125 if (parent && !parent->isChildAllowed(fullscreenRenderer, fullscreenRenderer
->style())) { | 137 if (parent && !parent->isChildAllowed(fullscreenRenderer, fullscreenRenderer
->style())) { |
126 fullscreenRenderer->destroy(); | 138 fullscreenRenderer->destroy(); |
127 return 0; | 139 return 0; |
128 } | 140 } |
129 if (object) { | 141 if (object) { |
130 // |object->parent()| can be null if the object is not yet attached | 142 // |object->parent()| can be null if the object is not yet attached |
131 // to |parent|. | 143 // to |parent|. |
132 if (RenderObject* parent = object->parent()) { | 144 if (RenderObject* parent = object->parent()) { |
133 RenderBlock* containingBlock = object->containingBlock(); | 145 RenderBlock* containingBlock = object->containingBlock(); |
134 ASSERT(containingBlock); | 146 ASSERT(containingBlock); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (!m_placeholder) { | 205 if (!m_placeholder) { |
194 m_placeholder = new RenderFullScreenPlaceholder(this); | 206 m_placeholder = new RenderFullScreenPlaceholder(this); |
195 m_placeholder->setStyle(style); | 207 m_placeholder->setStyle(style); |
196 if (parent()) { | 208 if (parent()) { |
197 parent()->addChild(m_placeholder, this); | 209 parent()->addChild(m_placeholder, this); |
198 parent()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
); | 210 parent()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
); |
199 } | 211 } |
200 } else | 212 } else |
201 m_placeholder->setStyle(style); | 213 m_placeholder->setStyle(style); |
202 } | 214 } |
OLD | NEW |