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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 } | 72 } |
73 | 73 |
74 // RenderObjects are unretained, so notify the document (which holds a point
er to a RenderFullScreen) | 74 // RenderObjects are unretained, so notify the document (which holds a point
er to a RenderFullScreen) |
75 // if it's RenderFullScreen is destroyed. | 75 // if it's RenderFullScreen is destroyed. |
76 if (document() && document()->fullScreenRenderer() == this) | 76 if (document() && document()->fullScreenRenderer() == this) |
77 document()->fullScreenRendererDestroyed(); | 77 document()->fullScreenRendererDestroyed(); |
78 | 78 |
79 RenderDeprecatedFlexibleBox::willBeDestroyed(); | 79 RenderDeprecatedFlexibleBox::willBeDestroyed(); |
80 } | 80 } |
81 | 81 |
82 PassRefPtr<RenderStyle> RenderFullScreen::createFullScreenStyle() | 82 static PassRefPtr<RenderStyle> createFullScreenStyle() |
83 { | 83 { |
84 RefPtr<RenderStyle> fullscreenStyle = RenderStyle::createDefaultStyle(); | 84 RefPtr<RenderStyle> fullscreenStyle = RenderStyle::createDefaultStyle(); |
85 | 85 |
86 // Create a stacking context: | 86 // Create a stacking context: |
87 fullscreenStyle->setZIndex(INT_MAX); | 87 fullscreenStyle->setZIndex(INT_MAX); |
88 | 88 |
89 fullscreenStyle->setFontDescription(FontDescription()); | 89 fullscreenStyle->setFontDescription(FontDescription()); |
90 fullscreenStyle->font().update(0); | 90 fullscreenStyle->font().update(0); |
91 | 91 |
92 fullscreenStyle->setDisplay(BOX); | 92 fullscreenStyle->setDisplay(BOX); |
93 fullscreenStyle->setBoxPack(BCENTER); | 93 fullscreenStyle->setBoxPack(BCENTER); |
94 fullscreenStyle->setBoxAlign(BCENTER); | 94 fullscreenStyle->setBoxAlign(BCENTER); |
95 fullscreenStyle->setBoxOrient(VERTICAL); | 95 fullscreenStyle->setBoxOrient(VERTICAL); |
96 | 96 |
97 fullscreenStyle->setPosition(FixedPosition); | 97 fullscreenStyle->setPosition(FixedPosition); |
98 fullscreenStyle->setWidth(Length(100.0, Percent)); | 98 fullscreenStyle->setWidth(Length(100.0, Percent)); |
99 fullscreenStyle->setHeight(Length(100.0, Percent)); | 99 fullscreenStyle->setHeight(Length(100.0, Percent)); |
100 fullscreenStyle->setLeft(Length(0, Fixed)); | 100 fullscreenStyle->setLeft(Length(0, WebCore::Fixed)); |
101 fullscreenStyle->setTop(Length(0, Fixed)); | 101 fullscreenStyle->setTop(Length(0, WebCore::Fixed)); |
102 | 102 |
103 fullscreenStyle->setBackgroundColor(Color::black); | 103 fullscreenStyle->setBackgroundColor(Color::black); |
104 | 104 |
105 return fullscreenStyle.release(); | 105 return fullscreenStyle.release(); |
106 } | 106 } |
107 | 107 |
| 108 RenderObject* RenderFullScreen::wrapRenderer(RenderObject* object, Document* doc
ument) |
| 109 { |
| 110 RenderFullScreen* fullscreenRenderer = new (document->renderArena()) RenderF
ullScreen(document); |
| 111 fullscreenRenderer->setStyle(createFullScreenStyle()); |
| 112 if (object) { |
| 113 if (RenderObject* parent = object->parent()) { |
| 114 parent->addChild(fullscreenRenderer, object); |
| 115 object->remove(); |
| 116 } |
| 117 fullscreenRenderer->addChild(object); |
| 118 } |
| 119 document->setFullScreenRenderer(fullscreenRenderer); |
| 120 if (fullscreenRenderer->placeholder()) |
| 121 return fullscreenRenderer->placeholder(); |
| 122 return fullscreenRenderer; |
| 123 } |
| 124 |
| 125 void RenderFullScreen::unwrapRenderer() |
| 126 { |
| 127 RenderObject* wrappedRenderer = firstChild(); |
| 128 if (wrappedRenderer) { |
| 129 wrappedRenderer->remove(); |
| 130 RenderObject* holder = placeholder() ? placeholder() : this; |
| 131 RenderObject* parent = holder->parent(); |
| 132 if (parent) |
| 133 parent->addChild(wrappedRenderer, holder); |
| 134 } |
| 135 remove(); |
| 136 document()->setFullScreenRenderer(0); |
| 137 } |
| 138 |
108 void RenderFullScreen::setPlaceholder(RenderBlock* placeholder) | 139 void RenderFullScreen::setPlaceholder(RenderBlock* placeholder) |
109 { | 140 { |
110 m_placeholder = placeholder; | 141 m_placeholder = placeholder; |
111 } | 142 } |
112 | 143 |
113 void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const In
tRect& frameRect) | 144 void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const In
tRect& frameRect) |
114 { | 145 { |
115 if (style->width().isAuto()) | 146 if (style->width().isAuto()) |
116 style->setWidth(Length(frameRect.width(), Fixed)); | 147 style->setWidth(Length(frameRect.width(), Fixed)); |
117 if (style->height().isAuto()) | 148 if (style->height().isAuto()) |
118 style->setHeight(Length(frameRect.height(), Fixed)); | 149 style->setHeight(Length(frameRect.height(), Fixed)); |
119 | 150 |
120 if (!m_placeholder) { | 151 if (!m_placeholder) { |
121 m_placeholder = new (document()->renderArena()) RenderFullScreenPlacehol
der(this); | 152 m_placeholder = new (document()->renderArena()) RenderFullScreenPlacehol
der(this); |
122 m_placeholder->setStyle(style); | 153 m_placeholder->setStyle(style); |
123 if (parent()) { | 154 if (parent()) { |
124 parent()->addChild(m_placeholder, this); | 155 parent()->addChild(m_placeholder, this); |
125 remove(); | 156 remove(); |
126 } | 157 } |
127 m_placeholder->addChild(this); | 158 m_placeholder->addChild(this); |
128 } else | 159 } else |
129 m_placeholder->setStyle(style); | 160 m_placeholder->setStyle(style); |
130 } | 161 } |
131 | 162 |
132 #endif | 163 #endif |
OLD | NEW |