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/page/Chrome.h" |
| 30 #include "core/page/Page.h" |
29 #include "core/rendering/RenderBlockFlow.h" | 31 #include "core/rendering/RenderBlockFlow.h" |
30 | 32 |
| 33 #include "public/platform/WebScreenInfo.h" |
| 34 |
31 using namespace blink; | 35 using namespace blink; |
32 | 36 |
33 class RenderFullScreenPlaceholder FINAL : public RenderBlockFlow { | 37 class RenderFullScreenPlaceholder FINAL : public RenderBlockFlow { |
34 public: | 38 public: |
35 RenderFullScreenPlaceholder(RenderFullScreen* owner) | 39 RenderFullScreenPlaceholder(RenderFullScreen* owner) |
36 : RenderBlockFlow(0) | 40 : RenderBlockFlow(0) |
37 , m_owner(owner) | 41 , m_owner(owner) |
38 { | 42 { |
39 setDocumentForAnonymous(&owner->document()); | 43 setDocumentForAnonymous(&owner->document()); |
40 } | 44 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 85 |
82 // RenderObjects are unretained, so notify the document (which holds a point
er to a RenderFullScreen) | 86 // RenderObjects are unretained, so notify the document (which holds a point
er to a RenderFullScreen) |
83 // if its RenderFullScreen is destroyed. | 87 // if its RenderFullScreen is destroyed. |
84 Fullscreen& fullscreen = Fullscreen::from(document()); | 88 Fullscreen& fullscreen = Fullscreen::from(document()); |
85 if (fullscreen.fullScreenRenderer() == this) | 89 if (fullscreen.fullScreenRenderer() == this) |
86 fullscreen.fullScreenRendererDestroyed(); | 90 fullscreen.fullScreenRendererDestroyed(); |
87 | 91 |
88 RenderFlexibleBox::willBeDestroyed(); | 92 RenderFlexibleBox::willBeDestroyed(); |
89 } | 93 } |
90 | 94 |
91 static PassRefPtr<RenderStyle> createFullScreenStyle() | 95 void RenderFullScreen::updateStyle() |
92 { | 96 { |
93 RefPtr<RenderStyle> fullscreenStyle = RenderStyle::createDefaultStyle(); | 97 RefPtr<RenderStyle> fullscreenStyle = RenderStyle::createDefaultStyle(); |
94 | 98 |
95 // Create a stacking context: | 99 // Create a stacking context: |
96 fullscreenStyle->setZIndex(INT_MAX); | 100 fullscreenStyle->setZIndex(INT_MAX); |
97 | 101 |
98 fullscreenStyle->setFontDescription(FontDescription()); | 102 fullscreenStyle->setFontDescription(FontDescription()); |
99 fullscreenStyle->font().update(nullptr); | 103 fullscreenStyle->font().update(nullptr); |
100 | 104 |
101 fullscreenStyle->setDisplay(FLEX); | 105 fullscreenStyle->setDisplay(FLEX); |
102 fullscreenStyle->setJustifyContent(JustifyCenter); | 106 fullscreenStyle->setJustifyContent(JustifyCenter); |
103 fullscreenStyle->setAlignItems(ItemPositionCenter); | 107 fullscreenStyle->setAlignItems(ItemPositionCenter); |
104 fullscreenStyle->setFlexDirection(FlowColumn); | 108 fullscreenStyle->setFlexDirection(FlowColumn); |
105 | 109 |
106 fullscreenStyle->setPosition(FixedPosition); | 110 fullscreenStyle->setPosition(FixedPosition); |
107 fullscreenStyle->setWidth(Length(100.0, Percent)); | |
108 fullscreenStyle->setHeight(Length(100.0, Percent)); | |
109 fullscreenStyle->setLeft(Length(0, blink::Fixed)); | 111 fullscreenStyle->setLeft(Length(0, blink::Fixed)); |
110 fullscreenStyle->setTop(Length(0, blink::Fixed)); | 112 fullscreenStyle->setTop(Length(0, blink::Fixed)); |
111 | 113 |
| 114 IntSize screenSize = IntRect(document().page()->chrome().screenInfo().rect).
size(); |
| 115 fullscreenStyle->setWidth(Length(screenSize.width(), blink::Fixed)); |
| 116 fullscreenStyle->setHeight(Length(screenSize.height(), blink::Fixed)); |
| 117 |
112 fullscreenStyle->setBackgroundColor(StyleColor(Color::black)); | 118 fullscreenStyle->setBackgroundColor(StyleColor(Color::black)); |
113 | 119 |
114 return fullscreenStyle.release(); | 120 setStyle(fullscreenStyle); |
115 } | 121 } |
116 | 122 |
117 RenderObject* RenderFullScreen::wrapRenderer(RenderObject* object, RenderObject*
parent, Document* document) | 123 RenderObject* RenderFullScreen::wrapRenderer(RenderObject* object, RenderObject*
parent, Document* document) |
118 { | 124 { |
119 // FIXME: We should not modify the structure of the render tree during | 125 // FIXME: We should not modify the structure of the render tree during |
120 // layout. crbug.com/370459 | 126 // layout. crbug.com/370459 |
121 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; | 127 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
122 | 128 |
123 RenderFullScreen* fullscreenRenderer = RenderFullScreen::createAnonymous(doc
ument); | 129 RenderFullScreen* fullscreenRenderer = RenderFullScreen::createAnonymous(doc
ument); |
124 fullscreenRenderer->setStyle(createFullScreenStyle()); | 130 fullscreenRenderer->updateStyle(); |
125 if (parent && !parent->isChildAllowed(fullscreenRenderer, fullscreenRenderer
->style())) { | 131 if (parent && !parent->isChildAllowed(fullscreenRenderer, fullscreenRenderer
->style())) { |
126 fullscreenRenderer->destroy(); | 132 fullscreenRenderer->destroy(); |
127 return 0; | 133 return 0; |
128 } | 134 } |
129 if (object) { | 135 if (object) { |
130 // |object->parent()| can be null if the object is not yet attached | 136 // |object->parent()| can be null if the object is not yet attached |
131 // to |parent|. | 137 // to |parent|. |
132 if (RenderObject* parent = object->parent()) { | 138 if (RenderObject* parent = object->parent()) { |
133 RenderBlock* containingBlock = object->containingBlock(); | 139 RenderBlock* containingBlock = object->containingBlock(); |
134 ASSERT(containingBlock); | 140 ASSERT(containingBlock); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (!m_placeholder) { | 199 if (!m_placeholder) { |
194 m_placeholder = new RenderFullScreenPlaceholder(this); | 200 m_placeholder = new RenderFullScreenPlaceholder(this); |
195 m_placeholder->setStyle(style); | 201 m_placeholder->setStyle(style); |
196 if (parent()) { | 202 if (parent()) { |
197 parent()->addChild(m_placeholder, this); | 203 parent()->addChild(m_placeholder, this); |
198 parent()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
); | 204 parent()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
); |
199 } | 205 } |
200 } else | 206 } else |
201 m_placeholder->setStyle(style); | 207 m_placeholder->setStyle(style); |
202 } | 208 } |
OLD | NEW |