Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: Source/core/rendering/RenderLayerCompositor.cpp

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 destroyRootLayer(); 256 destroyRootLayer();
257 } 257 }
258 } 258 }
259 259
260 void RenderLayerCompositor::cacheAcceleratedCompositingFlags() 260 void RenderLayerCompositor::cacheAcceleratedCompositingFlags()
261 { 261 {
262 bool hasAcceleratedCompositing = false; 262 bool hasAcceleratedCompositing = false;
263 bool showRepaintCounter = false; 263 bool showRepaintCounter = false;
264 bool forceCompositingMode = false; 264 bool forceCompositingMode = false;
265 265
266 if (Settings* settings = m_renderView->document()->settings()) { 266 if (Settings* settings = m_renderView->document().settings()) {
267 hasAcceleratedCompositing = settings->acceleratedCompositingEnabled(); 267 hasAcceleratedCompositing = settings->acceleratedCompositingEnabled();
268 268
269 // We allow the chrome to override the settings, in case the page is ren dered 269 // We allow the chrome to override the settings, in case the page is ren dered
270 // on a chrome that doesn't allow accelerated compositing. 270 // on a chrome that doesn't allow accelerated compositing.
271 if (hasAcceleratedCompositing) { 271 if (hasAcceleratedCompositing) {
272 if (Page* page = this->page()) { 272 if (Page* page = this->page()) {
273 m_compositingTriggers = page->chrome().client().allowedCompositi ngTriggers(); 273 m_compositingTriggers = page->chrome().client().allowedCompositi ngTriggers();
274 hasAcceleratedCompositing = m_compositingTriggers; 274 hasAcceleratedCompositing = m_compositingTriggers;
275 } 275 }
276 } 276 }
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 void RenderLayerCompositor::frameViewDidScroll() 1196 void RenderLayerCompositor::frameViewDidScroll()
1197 { 1197 {
1198 FrameView* frameView = m_renderView->frameView(); 1198 FrameView* frameView = m_renderView->frameView();
1199 IntPoint scrollPosition = frameView->scrollPosition(); 1199 IntPoint scrollPosition = frameView->scrollPosition();
1200 1200
1201 if (!m_scrollLayer) 1201 if (!m_scrollLayer)
1202 return; 1202 return;
1203 1203
1204 bool scrollingCoordinatorHandlesOffset = false; 1204 bool scrollingCoordinatorHandlesOffset = false;
1205 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator( )) { 1205 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator( )) {
1206 if (Settings* settings = m_renderView->document()->settings()) { 1206 if (Settings* settings = m_renderView->document().settings()) {
1207 if (isMainFrame() || settings->compositedScrollingForFramesEnabled() ) 1207 if (isMainFrame() || settings->compositedScrollingForFramesEnabled() )
1208 scrollingCoordinatorHandlesOffset = scrollingCoordinator->scroll ableAreaScrollLayerDidChange(frameView); 1208 scrollingCoordinatorHandlesOffset = scrollingCoordinator->scroll ableAreaScrollLayerDidChange(frameView);
1209 } 1209 }
1210 } 1210 }
1211 1211
1212 // Scroll position = scroll minimum + scroll offset. Adjust the layer's 1212 // Scroll position = scroll minimum + scroll offset. Adjust the layer's
1213 // position to handle whatever the scroll coordinator isn't handling. 1213 // position to handle whatever the scroll coordinator isn't handling.
1214 // The minimum scroll position is non-zero for RTL pages with overflow. 1214 // The minimum scroll position is non-zero for RTL pages with overflow.
1215 if (scrollingCoordinatorHandlesOffset) 1215 if (scrollingCoordinatorHandlesOffset)
1216 m_scrollLayer->setPosition(-frameView->minimumScrollPosition()); 1216 m_scrollLayer->setPosition(-frameView->minimumScrollPosition());
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 if (AnimationController* animController = renderer->animation()) 1900 if (AnimationController* animController = renderer->animation())
1901 return animController->isRunningAcceleratableAnimationOnRenderer(rendere r); 1901 return animController->isRunningAcceleratableAnimationOnRenderer(rendere r);
1902 return false; 1902 return false;
1903 } 1903 }
1904 1904
1905 bool RenderLayerCompositor::requiresCompositingForTransition(RenderObject* rende rer) const 1905 bool RenderLayerCompositor::requiresCompositingForTransition(RenderObject* rende rer) const
1906 { 1906 {
1907 if (!(m_compositingTriggers & ChromeClient::AnimationTrigger)) 1907 if (!(m_compositingTriggers & ChromeClient::AnimationTrigger))
1908 return false; 1908 return false;
1909 1909
1910 if (Settings* settings = m_renderView->document()->settings()) { 1910 if (Settings* settings = m_renderView->document().settings()) {
1911 if (!settings->acceleratedCompositingForTransitionEnabled()) 1911 if (!settings->acceleratedCompositingForTransitionEnabled())
1912 return false; 1912 return false;
1913 } 1913 }
1914 1914
1915 return renderer->style()->transitionForProperty(CSSPropertyOpacity) 1915 return renderer->style()->transitionForProperty(CSSPropertyOpacity)
1916 || renderer->style()->transitionForProperty(CSSPropertyWebkitFilter) 1916 || renderer->style()->transitionForProperty(CSSPropertyWebkitFilter)
1917 || renderer->style()->transitionForProperty(CSSPropertyWebkitTransform); 1917 || renderer->style()->transitionForProperty(CSSPropertyWebkitTransform);
1918 } 1918 }
1919 1919
1920 CompositingReasons RenderLayerCompositor::subtreeReasonsForCompositing(RenderObj ect* renderer, bool hasCompositedDescendants, bool has3DTransformedDescendants) const 1920 CompositingReasons RenderLayerCompositor::subtreeReasonsForCompositing(RenderObj ect* renderer, bool hasCompositedDescendants, bool has3DTransformedDescendants) const
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 EPosition position = renderer->style()->position(); 2023 EPosition position = renderer->style()->position();
2024 bool isFixed = renderer->isOutOfFlowPositioned() && position == FixedPositio n; 2024 bool isFixed = renderer->isOutOfFlowPositioned() && position == FixedPositio n;
2025 if (isFixed && !layer->isStackingContainer()) 2025 if (isFixed && !layer->isStackingContainer())
2026 return false; 2026 return false;
2027 2027
2028 bool isSticky = renderer->isInFlowPositioned() && position == StickyPosition ; 2028 bool isSticky = renderer->isInFlowPositioned() && position == StickyPosition ;
2029 if (!isFixed && !isSticky) 2029 if (!isFixed && !isSticky)
2030 return false; 2030 return false;
2031 2031
2032 // FIXME: acceleratedCompositingForFixedPositionEnabled should probably be r enamed acceleratedCompositingForViewportConstrainedPositionEnabled(). 2032 // FIXME: acceleratedCompositingForFixedPositionEnabled should probably be r enamed acceleratedCompositingForViewportConstrainedPositionEnabled().
2033 if (Settings* settings = m_renderView->document()->settings()) { 2033 if (Settings* settings = m_renderView->document().settings()) {
2034 if (!settings->acceleratedCompositingForFixedPositionEnabled()) 2034 if (!settings->acceleratedCompositingForFixedPositionEnabled())
2035 return false; 2035 return false;
2036 } 2036 }
2037 2037
2038 if (isSticky) 2038 if (isSticky)
2039 return true; 2039 return true;
2040 2040
2041 RenderObject* container = renderer->container(); 2041 RenderObject* container = renderer->container();
2042 // If the renderer is not hooked up yet then we have to wait until it is. 2042 // If the renderer is not hooked up yet then we have to wait until it is.
2043 if (!container) { 2043 if (!container) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 #if ENABLE(RUBBER_BANDING) 2162 #if ENABLE(RUBBER_BANDING)
2163 } else if (graphicsLayer == layerForOverhangAreas()) { 2163 } else if (graphicsLayer == layerForOverhangAreas()) {
2164 ScrollView* view = m_renderView->frameView(); 2164 ScrollView* view = m_renderView->frameView();
2165 view->calculateAndPaintOverhangBackground(&context, clip); 2165 view->calculateAndPaintOverhangBackground(&context, clip);
2166 #endif 2166 #endif
2167 } 2167 }
2168 } 2168 }
2169 2169
2170 bool RenderLayerCompositor::supportsFixedRootBackgroundCompositing() const 2170 bool RenderLayerCompositor::supportsFixedRootBackgroundCompositing() const
2171 { 2171 {
2172 if (Settings* settings = m_renderView->document()->settings()) { 2172 if (Settings* settings = m_renderView->document().settings()) {
2173 if (settings->acceleratedCompositingForFixedRootBackgroundEnabled()) 2173 if (settings->acceleratedCompositingForFixedRootBackgroundEnabled())
2174 return true; 2174 return true;
2175 } 2175 }
2176 return false; 2176 return false;
2177 } 2177 }
2178 2178
2179 bool RenderLayerCompositor::needsFixedRootBackgroundLayer(const RenderLayer* lay er) const 2179 bool RenderLayerCompositor::needsFixedRootBackgroundLayer(const RenderLayer* lay er) const
2180 { 2180 {
2181 if (layer != m_renderView->layer()) 2181 if (layer != m_renderView->layer())
2182 return false; 2182 return false;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 Frame* frame = m_renderView->frameView()->frame(); 2467 Frame* frame = m_renderView->frameView()->frame();
2468 Page* page = frame ? frame->page() : 0; 2468 Page* page = frame ? frame->page() : 0;
2469 if (!page) 2469 if (!page)
2470 return; 2470 return;
2471 page->chrome().client().attachRootGraphicsLayer(frame, rootGraphicsL ayer()); 2471 page->chrome().client().attachRootGraphicsLayer(frame, rootGraphicsL ayer());
2472 break; 2472 break;
2473 } 2473 }
2474 case RootLayerAttachedViaEnclosingFrame: { 2474 case RootLayerAttachedViaEnclosingFrame: {
2475 // The layer will get hooked up via RenderLayerBacking::updateGraphi csLayerConfiguration() 2475 // The layer will get hooked up via RenderLayerBacking::updateGraphi csLayerConfiguration()
2476 // for the frame's renderer in the parent document. 2476 // for the frame's renderer in the parent document.
2477 m_renderView->document()->ownerElement()->scheduleLayerUpdate(); 2477 m_renderView->document().ownerElement()->scheduleLayerUpdate();
2478 break; 2478 break;
2479 } 2479 }
2480 } 2480 }
2481 2481
2482 m_rootLayerAttachment = attachment; 2482 m_rootLayerAttachment = attachment;
2483 } 2483 }
2484 2484
2485 void RenderLayerCompositor::detachRootLayer() 2485 void RenderLayerCompositor::detachRootLayer()
2486 { 2486 {
2487 if (!m_rootContentLayer || m_rootLayerAttachment == RootLayerUnattached) 2487 if (!m_rootContentLayer || m_rootLayerAttachment == RootLayerUnattached)
2488 return; 2488 return;
2489 2489
2490 switch (m_rootLayerAttachment) { 2490 switch (m_rootLayerAttachment) {
2491 case RootLayerAttachedViaEnclosingFrame: { 2491 case RootLayerAttachedViaEnclosingFrame: {
2492 // The layer will get unhooked up via RenderLayerBacking::updateGraphics LayerConfiguration() 2492 // The layer will get unhooked up via RenderLayerBacking::updateGraphics LayerConfiguration()
2493 // for the frame's renderer in the parent document. 2493 // for the frame's renderer in the parent document.
2494 if (m_overflowControlsHostLayer) 2494 if (m_overflowControlsHostLayer)
2495 m_overflowControlsHostLayer->removeFromParent(); 2495 m_overflowControlsHostLayer->removeFromParent();
2496 else 2496 else
2497 m_rootContentLayer->removeFromParent(); 2497 m_rootContentLayer->removeFromParent();
2498 2498
2499 if (HTMLFrameOwnerElement* ownerElement = m_renderView->document()->owne rElement()) 2499 if (HTMLFrameOwnerElement* ownerElement = m_renderView->document().owner Element())
2500 ownerElement->scheduleLayerUpdate(); 2500 ownerElement->scheduleLayerUpdate();
2501 break; 2501 break;
2502 } 2502 }
2503 case RootLayerAttachedViaChromeClient: { 2503 case RootLayerAttachedViaChromeClient: {
2504 Frame* frame = m_renderView->frameView()->frame(); 2504 Frame* frame = m_renderView->frameView()->frame();
2505 Page* page = frame ? frame->page() : 0; 2505 Page* page = frame ? frame->page() : 0;
2506 if (!page) 2506 if (!page)
2507 return; 2507 return;
2508 page->chrome().client().attachRootGraphicsLayer(frame, 0); 2508 page->chrome().client().attachRootGraphicsLayer(frame, 0);
2509 } 2509 }
2510 break; 2510 break;
2511 case RootLayerUnattached: 2511 case RootLayerUnattached:
2512 break; 2512 break;
2513 } 2513 }
2514 2514
2515 m_rootLayerAttachment = RootLayerUnattached; 2515 m_rootLayerAttachment = RootLayerUnattached;
2516 } 2516 }
2517 2517
2518 void RenderLayerCompositor::updateRootLayerAttachment() 2518 void RenderLayerCompositor::updateRootLayerAttachment()
2519 { 2519 {
2520 ensureRootLayer(); 2520 ensureRootLayer();
2521 } 2521 }
2522 2522
2523 bool RenderLayerCompositor::isMainFrame() const 2523 bool RenderLayerCompositor::isMainFrame() const
2524 { 2524 {
2525 return !m_renderView->document()->ownerElement(); 2525 return !m_renderView->document().ownerElement();
2526 } 2526 }
2527 2527
2528 // IFrames are special, because we hook compositing layers together across ifram e boundaries 2528 // IFrames are special, because we hook compositing layers together across ifram e boundaries
2529 // when both parent and iframe content are composited. So when this frame become s composited, we have 2529 // when both parent and iframe content are composited. So when this frame become s composited, we have
2530 // to use a synthetic style change to get the iframes into RenderLayers in order to allow them to composite. 2530 // to use a synthetic style change to get the iframes into RenderLayers in order to allow them to composite.
2531 void RenderLayerCompositor::notifyIFramesOfCompositingChange() 2531 void RenderLayerCompositor::notifyIFramesOfCompositingChange()
2532 { 2532 {
2533 Frame* frame = m_renderView->frameView() ? m_renderView->frameView()->frame( ) : 0; 2533 Frame* frame = m_renderView->frameView() ? m_renderView->frameView()->frame( ) : 0;
2534 if (!frame) 2534 if (!frame)
2535 return; 2535 return;
2536 2536
2537 for (Frame* child = frame->tree()->firstChild(); child; child = child->tree( )->traverseNext(frame)) { 2537 for (Frame* child = frame->tree()->firstChild(); child; child = child->tree( )->traverseNext(frame)) {
2538 if (child->document() && child->document()->ownerElement()) 2538 if (child->document() && child->document()->ownerElement())
2539 child->document()->ownerElement()->scheduleLayerUpdate(); 2539 child->document()->ownerElement()->scheduleLayerUpdate();
2540 } 2540 }
2541 2541
2542 // Compositing also affects the answer to RenderIFrame::requiresAcceleratedC ompositing(), so 2542 // Compositing also affects the answer to RenderIFrame::requiresAcceleratedC ompositing(), so
2543 // we need to schedule a style recalc in our parent document. 2543 // we need to schedule a style recalc in our parent document.
2544 if (HTMLFrameOwnerElement* ownerElement = m_renderView->document()->ownerEle ment()) 2544 if (HTMLFrameOwnerElement* ownerElement = m_renderView->document().ownerElem ent())
2545 ownerElement->scheduleLayerUpdate(); 2545 ownerElement->scheduleLayerUpdate();
2546 } 2546 }
2547 2547
2548 bool RenderLayerCompositor::layerHas3DContent(const RenderLayer* layer) const 2548 bool RenderLayerCompositor::layerHas3DContent(const RenderLayer* layer) const
2549 { 2549 {
2550 const RenderStyle* style = layer->renderer()->style(); 2550 const RenderStyle* style = layer->renderer()->style();
2551 2551
2552 if (style && 2552 if (style &&
2553 (style->transformStyle3D() == TransformStyle3DPreserve3D || 2553 (style->transformStyle3D() == TransformStyle3DPreserve3D ||
2554 style->hasPerspective() || 2554 style->hasPerspective() ||
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2735 } else if (graphicsLayer == m_scrollLayer.get()) { 2735 } else if (graphicsLayer == m_scrollLayer.get()) {
2736 name = "Frame Scrolling Layer"; 2736 name = "Frame Scrolling Layer";
2737 } else { 2737 } else {
2738 ASSERT_NOT_REACHED(); 2738 ASSERT_NOT_REACHED();
2739 } 2739 }
2740 2740
2741 return name; 2741 return name;
2742 } 2742 }
2743 2743
2744 } // namespace WebCore 2744 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayerBacking.cpp ('k') | Source/core/rendering/RenderLayerFilterInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698