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