| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 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 17 matching lines...) Expand all Loading... |
| 28 #include "core/rendering/compositing/RenderLayerCompositor.h" | 28 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 29 | 29 |
| 30 #include "CSSPropertyNames.h" | 30 #include "CSSPropertyNames.h" |
| 31 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
| 32 #include "RuntimeEnabledFeatures.h" | 32 #include "RuntimeEnabledFeatures.h" |
| 33 #include "core/animation/ActiveAnimations.h" | 33 #include "core/animation/ActiveAnimations.h" |
| 34 #include "core/animation/DocumentAnimations.h" | 34 #include "core/animation/DocumentAnimations.h" |
| 35 #include "core/dom/FullscreenElementStack.h" | 35 #include "core/dom/FullscreenElementStack.h" |
| 36 #include "core/dom/NodeList.h" | 36 #include "core/dom/NodeList.h" |
| 37 #include "core/dom/ScriptForbiddenScope.h" | 37 #include "core/dom/ScriptForbiddenScope.h" |
| 38 #include "core/frame/DeprecatedScheduleStyleRecalcDuringCompositingUpdate.h" | |
| 39 #include "core/frame/FrameView.h" | 38 #include "core/frame/FrameView.h" |
| 40 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 41 #include "core/frame/Settings.h" | 40 #include "core/frame/Settings.h" |
| 42 #include "core/html/HTMLCanvasElement.h" | 41 #include "core/html/HTMLCanvasElement.h" |
| 43 #include "core/html/HTMLIFrameElement.h" | 42 #include "core/html/HTMLIFrameElement.h" |
| 44 #include "core/html/HTMLMediaElement.h" | 43 #include "core/html/HTMLMediaElement.h" |
| 45 #include "core/html/canvas/CanvasRenderingContext.h" | 44 #include "core/html/canvas/CanvasRenderingContext.h" |
| 46 #include "core/inspector/InspectorInstrumentation.h" | 45 #include "core/inspector/InspectorInstrumentation.h" |
| 47 #include "core/inspector/InspectorNodeIds.h" | 46 #include "core/inspector/InspectorNodeIds.h" |
| 48 #include "core/page/Chrome.h" | 47 #include "core/page/Chrome.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 return m_compositing; | 140 return m_compositing; |
| 142 } | 141 } |
| 143 | 142 |
| 144 void RenderLayerCompositor::setCompositingModeEnabled(bool enable) | 143 void RenderLayerCompositor::setCompositingModeEnabled(bool enable) |
| 145 { | 144 { |
| 146 if (enable == m_compositing) | 145 if (enable == m_compositing) |
| 147 return; | 146 return; |
| 148 | 147 |
| 149 m_compositing = enable; | 148 m_compositing = enable; |
| 150 | 149 |
| 150 // RenderPart::requiresAcceleratedCompositing is used to determine self-pain
tingness |
| 151 // and bases it's return value for frames on the m_compositing bit here. |
| 152 if (HTMLFrameOwnerElement* ownerElement = m_renderView.document().ownerEleme
nt()) { |
| 153 if (RenderPart* renderer = ownerElement->renderPart()) |
| 154 renderer->layer()->updateSelfPaintingLayer(); |
| 155 } |
| 156 |
| 151 if (m_compositing) | 157 if (m_compositing) |
| 152 ensureRootLayer(); | 158 ensureRootLayer(); |
| 153 else | 159 else |
| 154 destroyRootLayer(); | 160 destroyRootLayer(); |
| 155 | 161 |
| 156 notifyIFramesOfCompositingChange(); | 162 // Compositing also affects the answer to RenderIFrame::requiresAcceleratedC
ompositing(), so |
| 163 // we need to schedule a style recalc in our parent document. |
| 164 if (HTMLFrameOwnerElement* ownerElement = m_renderView.document().ownerEleme
nt()) |
| 165 ownerElement->setNeedsCompositingUpdate(); |
| 157 } | 166 } |
| 158 | 167 |
| 159 void RenderLayerCompositor::enableCompositingModeIfNeeded() | 168 void RenderLayerCompositor::enableCompositingModeIfNeeded() |
| 160 { | 169 { |
| 161 if (!m_rootShouldAlwaysCompositeDirty) | 170 if (!m_rootShouldAlwaysCompositeDirty) |
| 162 return; | 171 return; |
| 163 | 172 |
| 164 m_rootShouldAlwaysCompositeDirty = false; | 173 m_rootShouldAlwaysCompositeDirty = false; |
| 165 if (m_compositing) | 174 if (m_compositing) |
| 166 return; | 175 return; |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 LocalFrame& frame = m_renderView.frameView()->frame(); | 1264 LocalFrame& frame = m_renderView.frameView()->frame(); |
| 1256 Page* page = frame.page(); | 1265 Page* page = frame.page(); |
| 1257 if (!page) | 1266 if (!page) |
| 1258 return; | 1267 return; |
| 1259 page->chrome().client().attachRootGraphicsLayer(rootGraphicsLayer())
; | 1268 page->chrome().client().attachRootGraphicsLayer(rootGraphicsLayer())
; |
| 1260 break; | 1269 break; |
| 1261 } | 1270 } |
| 1262 case RootLayerAttachedViaEnclosingFrame: { | 1271 case RootLayerAttachedViaEnclosingFrame: { |
| 1263 HTMLFrameOwnerElement* ownerElement = m_renderView.document().ownerE
lement(); | 1272 HTMLFrameOwnerElement* ownerElement = m_renderView.document().ownerE
lement(); |
| 1264 ASSERT(ownerElement); | 1273 ASSERT(ownerElement); |
| 1265 DeprecatedScheduleStyleRecalcDuringCompositingUpdate marker(ownerEle
ment->document().lifecycle()); | |
| 1266 // The layer will get hooked up via CompositedLayerMapping::updateGr
aphicsLayerConfiguration() | 1274 // The layer will get hooked up via CompositedLayerMapping::updateGr
aphicsLayerConfiguration() |
| 1267 // for the frame's renderer in the parent document. | 1275 // for the frame's renderer in the parent document. |
| 1268 ownerElement->scheduleLayerUpdate(); | 1276 ownerElement->setNeedsCompositingUpdate(); |
| 1269 break; | 1277 break; |
| 1270 } | 1278 } |
| 1271 } | 1279 } |
| 1272 | 1280 |
| 1273 m_rootLayerAttachment = attachment; | 1281 m_rootLayerAttachment = attachment; |
| 1274 } | 1282 } |
| 1275 | 1283 |
| 1276 void RenderLayerCompositor::detachRootLayer() | 1284 void RenderLayerCompositor::detachRootLayer() |
| 1277 { | 1285 { |
| 1278 if (!m_rootContentLayer || m_rootLayerAttachment == RootLayerUnattached) | 1286 if (!m_rootContentLayer || m_rootLayerAttachment == RootLayerUnattached) |
| 1279 return; | 1287 return; |
| 1280 | 1288 |
| 1281 switch (m_rootLayerAttachment) { | 1289 switch (m_rootLayerAttachment) { |
| 1282 case RootLayerAttachedViaEnclosingFrame: { | 1290 case RootLayerAttachedViaEnclosingFrame: { |
| 1283 // The layer will get unhooked up via CompositedLayerMapping::updateGrap
hicsLayerConfiguration() | 1291 // The layer will get unhooked up via CompositedLayerMapping::updateGrap
hicsLayerConfiguration() |
| 1284 // for the frame's renderer in the parent document. | 1292 // for the frame's renderer in the parent document. |
| 1285 if (m_overflowControlsHostLayer) | 1293 if (m_overflowControlsHostLayer) |
| 1286 m_overflowControlsHostLayer->removeFromParent(); | 1294 m_overflowControlsHostLayer->removeFromParent(); |
| 1287 else | 1295 else |
| 1288 m_rootContentLayer->removeFromParent(); | 1296 m_rootContentLayer->removeFromParent(); |
| 1289 | 1297 |
| 1290 if (HTMLFrameOwnerElement* ownerElement = m_renderView.document().ownerE
lement()) { | 1298 if (HTMLFrameOwnerElement* ownerElement = m_renderView.document().ownerE
lement()) |
| 1291 DeprecatedScheduleStyleRecalcDuringCompositingUpdate marker(ownerEle
ment->document().lifecycle()); | 1299 ownerElement->setNeedsCompositingUpdate(); |
| 1292 ownerElement->scheduleLayerUpdate(); | |
| 1293 } | |
| 1294 break; | 1300 break; |
| 1295 } | 1301 } |
| 1296 case RootLayerAttachedViaChromeClient: { | 1302 case RootLayerAttachedViaChromeClient: { |
| 1297 LocalFrame& frame = m_renderView.frameView()->frame(); | 1303 LocalFrame& frame = m_renderView.frameView()->frame(); |
| 1298 Page* page = frame.page(); | 1304 Page* page = frame.page(); |
| 1299 if (!page) | 1305 if (!page) |
| 1300 return; | 1306 return; |
| 1301 page->chrome().client().attachRootGraphicsLayer(0); | 1307 page->chrome().client().attachRootGraphicsLayer(0); |
| 1302 } | 1308 } |
| 1303 break; | 1309 break; |
| 1304 case RootLayerUnattached: | 1310 case RootLayerUnattached: |
| 1305 break; | 1311 break; |
| 1306 } | 1312 } |
| 1307 | 1313 |
| 1308 m_rootLayerAttachment = RootLayerUnattached; | 1314 m_rootLayerAttachment = RootLayerUnattached; |
| 1309 } | 1315 } |
| 1310 | 1316 |
| 1311 void RenderLayerCompositor::updateRootLayerAttachment() | 1317 void RenderLayerCompositor::updateRootLayerAttachment() |
| 1312 { | 1318 { |
| 1313 ensureRootLayer(); | 1319 ensureRootLayer(); |
| 1314 } | 1320 } |
| 1315 | 1321 |
| 1316 // IFrames are special, because we hook compositing layers together across ifram
e boundaries | |
| 1317 // when both parent and iframe content are composited. So when this frame become
s composited, we have | |
| 1318 // to use a synthetic style change to get the iframes into RenderLayers in order
to allow them to composite. | |
| 1319 void RenderLayerCompositor::notifyIFramesOfCompositingChange() | |
| 1320 { | |
| 1321 if (!m_renderView.frameView()) | |
| 1322 return; | |
| 1323 LocalFrame& frame = m_renderView.frameView()->frame(); | |
| 1324 | |
| 1325 for (LocalFrame* child = frame.tree().firstChild(); child; child = child->tr
ee().traverseNext(&frame)) { | |
| 1326 if (!child->document()) | |
| 1327 continue; // FIXME: Can this happen? | |
| 1328 if (HTMLFrameOwnerElement* ownerElement = child->document()->ownerElemen
t()) { | |
| 1329 DeprecatedScheduleStyleRecalcDuringCompositingUpdate marker(ownerEle
ment->document().lifecycle()); | |
| 1330 ownerElement->scheduleLayerUpdate(); | |
| 1331 } | |
| 1332 } | |
| 1333 | |
| 1334 // Compositing also affects the answer to RenderIFrame::requiresAcceleratedC
ompositing(), so | |
| 1335 // we need to schedule a style recalc in our parent document. | |
| 1336 if (HTMLFrameOwnerElement* ownerElement = m_renderView.document().ownerEleme
nt()) { | |
| 1337 ownerElement->document().renderView()->compositor()->setNeedsToRecompute
CompositingRequirements(); | |
| 1338 DeprecatedScheduleStyleRecalcDuringCompositingUpdate marker(ownerElement
->document().lifecycle()); | |
| 1339 ownerElement->scheduleLayerUpdate(); | |
| 1340 } | |
| 1341 } | |
| 1342 | |
| 1343 ScrollingCoordinator* RenderLayerCompositor::scrollingCoordinator() const | 1322 ScrollingCoordinator* RenderLayerCompositor::scrollingCoordinator() const |
| 1344 { | 1323 { |
| 1345 if (Page* page = this->page()) | 1324 if (Page* page = this->page()) |
| 1346 return page->scrollingCoordinator(); | 1325 return page->scrollingCoordinator(); |
| 1347 | 1326 |
| 1348 return 0; | 1327 return 0; |
| 1349 } | 1328 } |
| 1350 | 1329 |
| 1351 GraphicsLayerFactory* RenderLayerCompositor::graphicsLayerFactory() const | 1330 GraphicsLayerFactory* RenderLayerCompositor::graphicsLayerFactory() const |
| 1352 { | 1331 { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 } else if (graphicsLayer == m_scrollLayer.get()) { | 1368 } else if (graphicsLayer == m_scrollLayer.get()) { |
| 1390 name = "LocalFrame Scrolling Layer"; | 1369 name = "LocalFrame Scrolling Layer"; |
| 1391 } else { | 1370 } else { |
| 1392 ASSERT_NOT_REACHED(); | 1371 ASSERT_NOT_REACHED(); |
| 1393 } | 1372 } |
| 1394 | 1373 |
| 1395 return name; | 1374 return name; |
| 1396 } | 1375 } |
| 1397 | 1376 |
| 1398 } // namespace WebCore | 1377 } // namespace WebCore |
| OLD | NEW |