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 |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 class RenderFullScreenPlaceholder final : public RenderBlockFlow { | 39 class RenderFullScreenPlaceholder final : public RenderBlockFlow { |
40 public: | 40 public: |
41 RenderFullScreenPlaceholder(RenderFullScreen* owner) | 41 RenderFullScreenPlaceholder(RenderFullScreen* owner) |
42 : RenderBlockFlow(0) | 42 : RenderBlockFlow(0) |
43 , m_owner(owner) | 43 , m_owner(owner) |
44 { | 44 { |
45 setDocumentForAnonymous(&owner->document()); | 45 setDocumentForAnonymous(&owner->document()); |
46 } | 46 } |
47 private: | 47 private: |
48 virtual bool isOfType(RenderObjectType type) const override { return type ==
RenderObjectRenderFullScreenPlaceholder || RenderBlockFlow::isOfType(type); } | 48 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectRenderFullScreenPlaceholder || RenderBlockFlow::isOfType(type); } |
49 virtual void willBeDestroyed() override; | 49 virtual void willBeDestroyed() override; |
50 RenderFullScreen* m_owner; | 50 RenderFullScreen* m_owner; |
51 }; | 51 }; |
52 | 52 |
53 void RenderFullScreenPlaceholder::willBeDestroyed() | 53 void RenderFullScreenPlaceholder::willBeDestroyed() |
54 { | 54 { |
55 m_owner->setPlaceholder(0); | 55 m_owner->setPlaceholder(0); |
56 RenderBlockFlow::willBeDestroyed(); | 56 RenderBlockFlow::willBeDestroyed(); |
57 } | 57 } |
58 | 58 |
(...skipping 13 matching lines...) Expand all Loading... |
72 | 72 |
73 void RenderFullScreen::willBeDestroyed() | 73 void RenderFullScreen::willBeDestroyed() |
74 { | 74 { |
75 if (m_placeholder) { | 75 if (m_placeholder) { |
76 remove(); | 76 remove(); |
77 if (!m_placeholder->beingDestroyed()) | 77 if (!m_placeholder->beingDestroyed()) |
78 m_placeholder->destroy(); | 78 m_placeholder->destroy(); |
79 ASSERT(!m_placeholder); | 79 ASSERT(!m_placeholder); |
80 } | 80 } |
81 | 81 |
82 // RenderObjects are unretained, so notify the document (which holds a point
er to a RenderFullScreen) | 82 // LayoutObjects are unretained, so notify the document (which holds a point
er to a RenderFullScreen) |
83 // if its RenderFullScreen is destroyed. | 83 // if its RenderFullScreen is destroyed. |
84 Fullscreen& fullscreen = Fullscreen::from(document()); | 84 Fullscreen& fullscreen = Fullscreen::from(document()); |
85 if (fullscreen.fullScreenRenderer() == this) | 85 if (fullscreen.fullScreenRenderer() == this) |
86 fullscreen.fullScreenRendererDestroyed(); | 86 fullscreen.fullScreenRendererDestroyed(); |
87 | 87 |
88 RenderFlexibleBox::willBeDestroyed(); | 88 RenderFlexibleBox::willBeDestroyed(); |
89 } | 89 } |
90 | 90 |
91 void RenderFullScreen::updateStyle() | 91 void RenderFullScreen::updateStyle() |
92 { | 92 { |
(...skipping 20 matching lines...) Expand all Loading... |
113 } else { | 113 } else { |
114 fullscreenStyle->setWidth(Length(100.0, Percent)); | 114 fullscreenStyle->setWidth(Length(100.0, Percent)); |
115 fullscreenStyle->setHeight(Length(100.0, Percent)); | 115 fullscreenStyle->setHeight(Length(100.0, Percent)); |
116 } | 116 } |
117 | 117 |
118 fullscreenStyle->setBackgroundColor(StyleColor(Color::black)); | 118 fullscreenStyle->setBackgroundColor(StyleColor(Color::black)); |
119 | 119 |
120 setStyle(fullscreenStyle); | 120 setStyle(fullscreenStyle); |
121 } | 121 } |
122 | 122 |
123 RenderObject* RenderFullScreen::wrapRenderer(RenderObject* object, RenderObject*
parent, Document* document) | 123 LayoutObject* RenderFullScreen::wrapRenderer(LayoutObject* object, LayoutObject*
parent, Document* document) |
124 { | 124 { |
125 // 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 |
126 // layout. crbug.com/370459 | 126 // layout. crbug.com/370459 |
127 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; | 127 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
128 | 128 |
129 RenderFullScreen* fullscreenRenderer = RenderFullScreen::createAnonymous(doc
ument); | 129 RenderFullScreen* fullscreenRenderer = RenderFullScreen::createAnonymous(doc
ument); |
130 fullscreenRenderer->updateStyle(); | 130 fullscreenRenderer->updateStyle(); |
131 if (parent && !parent->isChildAllowed(fullscreenRenderer, fullscreenRenderer
->styleRef())) { | 131 if (parent && !parent->isChildAllowed(fullscreenRenderer, fullscreenRenderer
->styleRef())) { |
132 fullscreenRenderer->destroy(); | 132 fullscreenRenderer->destroy(); |
133 return 0; | 133 return 0; |
134 } | 134 } |
135 if (object) { | 135 if (object) { |
136 // |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 |
137 // to |parent|. | 137 // to |parent|. |
138 if (RenderObject* parent = object->parent()) { | 138 if (LayoutObject* parent = object->parent()) { |
139 RenderBlock* containingBlock = object->containingBlock(); | 139 RenderBlock* containingBlock = object->containingBlock(); |
140 ASSERT(containingBlock); | 140 ASSERT(containingBlock); |
141 // Since we are moving the |object| to a new parent |fullscreenRende
rer|, | 141 // Since we are moving the |object| to a new parent |fullscreenRende
rer|, |
142 // the line box tree underneath our |containingBlock| is not longer
valid. | 142 // the line box tree underneath our |containingBlock| is not longer
valid. |
143 containingBlock->deleteLineBoxTree(); | 143 containingBlock->deleteLineBoxTree(); |
144 | 144 |
145 parent->addChild(fullscreenRenderer, object); | 145 parent->addChild(fullscreenRenderer, object); |
146 object->remove(); | 146 object->remove(); |
147 | 147 |
148 // Always just do a full layout to ensure that line boxes get delete
d properly. | 148 // Always just do a full layout to ensure that line boxes get delete
d properly. |
(...skipping 11 matching lines...) Expand all Loading... |
160 return fullscreenRenderer; | 160 return fullscreenRenderer; |
161 } | 161 } |
162 | 162 |
163 void RenderFullScreen::unwrapRenderer() | 163 void RenderFullScreen::unwrapRenderer() |
164 { | 164 { |
165 // FIXME: We should not modify the structure of the render tree during | 165 // FIXME: We should not modify the structure of the render tree during |
166 // layout. crbug.com/370459 | 166 // layout. crbug.com/370459 |
167 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; | 167 DeprecatedDisableModifyRenderTreeStructureAsserts disabler; |
168 | 168 |
169 if (parent()) { | 169 if (parent()) { |
170 for (RenderObject* child = firstChild(); child; child = firstChild()) { | 170 for (LayoutObject* child = firstChild(); child; child = firstChild()) { |
171 // We have to clear the override size, because as a flexbox, we | 171 // We have to clear the override size, because as a flexbox, we |
172 // may have set one on the child, and we don't want to leave that | 172 // may have set one on the child, and we don't want to leave that |
173 // lying around on the child. | 173 // lying around on the child. |
174 if (child->isBox()) | 174 if (child->isBox()) |
175 toRenderBox(child)->clearOverrideSize(); | 175 toRenderBox(child)->clearOverrideSize(); |
176 child->remove(); | 176 child->remove(); |
177 parent()->addChild(child, this); | 177 parent()->addChild(child, this); |
178 parent()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
); | 178 parent()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
); |
179 } | 179 } |
180 } | 180 } |
(...skipping 18 matching lines...) Expand all Loading... |
199 if (!m_placeholder) { | 199 if (!m_placeholder) { |
200 m_placeholder = new RenderFullScreenPlaceholder(this); | 200 m_placeholder = new RenderFullScreenPlaceholder(this); |
201 m_placeholder->setStyle(style); | 201 m_placeholder->setStyle(style); |
202 if (parent()) { | 202 if (parent()) { |
203 parent()->addChild(m_placeholder, this); | 203 parent()->addChild(m_placeholder, this); |
204 parent()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
); | 204 parent()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
); |
205 } | 205 } |
206 } else | 206 } else |
207 m_placeholder->setStyle(style); | 207 m_placeholder->setStyle(style); |
208 } | 208 } |
OLD | NEW |