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

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

Issue 209703002: Shrink RenderLayerCompositor by 5% by removing unused code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
« no previous file with comments | « Source/core/rendering/compositing/RenderLayerCompositor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 RootLayerAttachment attachment = isMainFrame() ? RootLayerAttachedViaChr omeClient : RootLayerAttachedViaEnclosingFrame; 1565 RootLayerAttachment attachment = isMainFrame() ? RootLayerAttachedViaChr omeClient : RootLayerAttachedViaEnclosingFrame;
1566 attachRootLayer(attachment); 1566 attachRootLayer(attachment);
1567 } else { 1567 } else {
1568 if (m_rootLayerAttachment == RootLayerUnattached) 1568 if (m_rootLayerAttachment == RootLayerUnattached)
1569 return; 1569 return;
1570 1570
1571 detachRootLayer(); 1571 detachRootLayer();
1572 } 1572 }
1573 } 1573 }
1574 1574
1575 void RenderLayerCompositor::clearMappingForRenderLayerIncludingDescendants(Rende rLayer* layer)
1576 {
1577 if (!layer)
1578 return;
1579
1580 if (layer->hasCompositedLayerMapping()) {
1581 removeViewportConstrainedLayer(layer);
1582 layer->clearCompositedLayerMapping();
1583 }
1584
1585 for (RenderLayer* currLayer = layer->firstChild(); currLayer; currLayer = cu rrLayer->nextSibling())
1586 clearMappingForRenderLayerIncludingDescendants(currLayer);
1587 }
1588
1589 void RenderLayerCompositor::clearMappingForAllRenderLayers()
1590 {
1591 clearMappingForRenderLayerIncludingDescendants(m_renderView.layer());
1592 }
1593
1594 void RenderLayerCompositor::updateRootLayerPosition() 1575 void RenderLayerCompositor::updateRootLayerPosition()
1595 { 1576 {
1596 if (m_rootContentLayer) { 1577 if (m_rootContentLayer) {
1597 const IntRect& documentRect = m_renderView.documentRect(); 1578 const IntRect& documentRect = m_renderView.documentRect();
1598 m_rootContentLayer->setSize(documentRect.size()); 1579 m_rootContentLayer->setSize(documentRect.size());
1599 m_rootContentLayer->setPosition(documentRect.location()); 1580 m_rootContentLayer->setPosition(documentRect.location());
1600 #if USE(RUBBER_BANDING) 1581 #if USE(RUBBER_BANDING)
1601 if (m_layerForOverhangShadow) 1582 if (m_layerForOverhangShadow)
1602 OverscrollTheme::theme()->updateOverhangShadowLayer(m_layerForOverha ngShadow.get(), m_rootContentLayer.get()); 1583 OverscrollTheme::theme()->updateOverhangShadowLayer(m_layerForOverha ngShadow.get(), m_rootContentLayer.get());
1603 #endif 1584 #endif
1604 } 1585 }
1605 if (m_containerLayer) { 1586 if (m_containerLayer) {
1606 FrameView* frameView = m_renderView.frameView(); 1587 FrameView* frameView = m_renderView.frameView();
1607 m_containerLayer->setSize(frameView->unscaledVisibleContentSize()); 1588 m_containerLayer->setSize(frameView->unscaledVisibleContentSize());
1608 } 1589 }
1609 } 1590 }
1610 1591
1611 bool RenderLayerCompositor::has3DContent() const
1612 {
1613 return layerHas3DContent(rootRenderLayer());
1614 }
1615
1616 void RenderLayerCompositor::updateStyleDeterminedCompositingReasons(RenderLayer* layer) 1592 void RenderLayerCompositor::updateStyleDeterminedCompositingReasons(RenderLayer* layer)
1617 { 1593 {
1618 CompositingReasons reasons = m_compositingReasonFinder.styleDeterminedReason s(layer->renderer()); 1594 CompositingReasons reasons = m_compositingReasonFinder.styleDeterminedReason s(layer->renderer());
1619 layer->setCompositingReasons(reasons, CompositingReasonComboAllStyleDetermin edReasons); 1595 layer->setCompositingReasons(reasons, CompositingReasonComboAllStyleDetermin edReasons);
1620 } 1596 }
1621 1597
1622 void RenderLayerCompositor::updateDirectCompositingReasons(RenderLayer* layer) 1598 void RenderLayerCompositor::updateDirectCompositingReasons(RenderLayer* layer)
1623 { 1599 {
1624 CompositingReasons reasons = m_compositingReasonFinder.directReasons(layer, &m_needsToRecomputeCompositingRequirements); 1600 CompositingReasons reasons = m_compositingReasonFinder.directReasons(layer, &m_needsToRecomputeCompositingRequirements);
1625 layer->setCompositingReasons(reasons, CompositingReasonComboAllDirectReasons ); 1601 layer->setCompositingReasons(reasons, CompositingReasonComboAllDirectReasons );
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 2119
2144 // Compositing also affects the answer to RenderIFrame::requiresAcceleratedC ompositing(), so 2120 // Compositing also affects the answer to RenderIFrame::requiresAcceleratedC ompositing(), so
2145 // we need to schedule a style recalc in our parent document. 2121 // we need to schedule a style recalc in our parent document.
2146 if (HTMLFrameOwnerElement* ownerElement = m_renderView.document().ownerEleme nt()) { 2122 if (HTMLFrameOwnerElement* ownerElement = m_renderView.document().ownerEleme nt()) {
2147 ownerElement->document().renderView()->compositor()->setNeedsToRecompute CompositingRequirements(); 2123 ownerElement->document().renderView()->compositor()->setNeedsToRecompute CompositingRequirements();
2148 DeprecatedScheduleStyleRecalcDuringCompositingUpdate marker(ownerElement ->document().lifecycle()); 2124 DeprecatedScheduleStyleRecalcDuringCompositingUpdate marker(ownerElement ->document().lifecycle());
2149 ownerElement->scheduleLayerUpdate(); 2125 ownerElement->scheduleLayerUpdate();
2150 } 2126 }
2151 } 2127 }
2152 2128
2153 bool RenderLayerCompositor::layerHas3DContent(const RenderLayer* layer) const
2154 {
2155 const RenderStyle* style = layer->renderer()->style();
2156 RenderLayerStackingNode* stackingNode = const_cast<RenderLayer*>(layer)->sta ckingNode();
2157
2158 if (style &&
2159 (style->transformStyle3D() == TransformStyle3DPreserve3D ||
2160 style->hasPerspective() ||
2161 style->transform().has3DOperation()))
2162 return true;
2163
2164 stackingNode->updateLayerListsIfNeeded();
2165
2166 #if !ASSERT_DISABLED
2167 LayerListMutationDetector mutationChecker(stackingNode);
2168 #endif
2169
2170 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), AllChildren );
2171 while (RenderLayerStackingNode* curNode = iterator.next()) {
2172 if (layerHas3DContent(curNode->layer()))
2173 return true;
2174 }
2175
2176 return false;
2177 }
2178
2179 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer* layer) 2129 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer* layer)
2180 { 2130 {
2181 if (CompositingReasonFinder::isViewportConstrainedFixedOrStickyLayer(layer)) 2131 if (CompositingReasonFinder::isViewportConstrainedFixedOrStickyLayer(layer))
2182 addViewportConstrainedLayer(layer); 2132 addViewportConstrainedLayer(layer);
2183 else 2133 else
2184 removeViewportConstrainedLayer(layer); 2134 removeViewportConstrainedLayer(layer);
2185 } 2135 }
2186 2136
2187 void RenderLayerCompositor::addViewportConstrainedLayer(RenderLayer* layer) 2137 void RenderLayerCompositor::addViewportConstrainedLayer(RenderLayer* layer)
2188 { 2138 {
2189 m_viewportConstrainedLayers.add(layer); 2139 m_viewportConstrainedLayers.add(layer);
2190 } 2140 }
2191 2141
2192 void RenderLayerCompositor::removeViewportConstrainedLayer(RenderLayer* layer) 2142 void RenderLayerCompositor::removeViewportConstrainedLayer(RenderLayer* layer)
2193 { 2143 {
2194 if (!m_viewportConstrainedLayers.contains(layer)) 2144 if (!m_viewportConstrainedLayers.contains(layer))
2195 return; 2145 return;
2196 2146
2197 m_viewportConstrainedLayers.remove(layer); 2147 m_viewportConstrainedLayers.remove(layer);
2198 } 2148 }
2199 2149
2200 FixedPositionViewportConstraints RenderLayerCompositor::computeFixedViewportCons traints(RenderLayer* layer) const
2201 {
2202 ASSERT(layer->hasCompositedLayerMapping());
2203
2204 FrameView* frameView = m_renderView.frameView();
2205 LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect() ;
2206
2207 FixedPositionViewportConstraints constraints;
2208
2209 GraphicsLayer* graphicsLayer = layer->compositedLayerMapping()->mainGraphics Layer();
2210
2211 constraints.setLayerPositionAtLastLayout(graphicsLayer->position());
2212 constraints.setViewportRectAtLastLayout(viewportRect);
2213
2214 RenderStyle* style = layer->renderer()->style();
2215 if (!style->left().isAuto())
2216 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft);
2217
2218 if (!style->right().isAuto())
2219 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeRight);
2220
2221 if (!style->top().isAuto())
2222 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop);
2223
2224 if (!style->bottom().isAuto())
2225 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeBottom);
2226
2227 // If left and right are auto, use left.
2228 if (style->left().isAuto() && style->right().isAuto())
2229 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeLeft);
2230
2231 // If top and bottom are auto, use top.
2232 if (style->top().isAuto() && style->bottom().isAuto())
2233 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop);
2234
2235 return constraints;
2236 }
2237
2238 StickyPositionViewportConstraints RenderLayerCompositor::computeStickyViewportCo nstraints(RenderLayer* layer) const
2239 {
2240 ASSERT(layer->hasCompositedLayerMapping());
2241 // We should never get here for stickies constrained by an enclosing clippin g layer.
2242 ASSERT(!layer->enclosingOverflowClipLayer(ExcludeSelf));
2243
2244 FrameView* frameView = m_renderView.frameView();
2245 LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect() ;
2246
2247 StickyPositionViewportConstraints constraints;
2248
2249 RenderBoxModelObject* renderer = toRenderBoxModelObject(layer->renderer());
2250
2251 renderer->computeStickyPositionConstraints(constraints, viewportRect);
2252
2253 GraphicsLayer* graphicsLayer = layer->compositedLayerMapping()->mainGraphics Layer();
2254
2255 constraints.setLayerPositionAtLastLayout(graphicsLayer->position());
2256 constraints.setStickyOffsetAtLastLayout(renderer->stickyPositionOffset());
2257
2258 return constraints;
2259 }
2260
2261 ScrollingCoordinator* RenderLayerCompositor::scrollingCoordinator() const 2150 ScrollingCoordinator* RenderLayerCompositor::scrollingCoordinator() const
2262 { 2151 {
2263 if (Page* page = this->page()) 2152 if (Page* page = this->page())
2264 return page->scrollingCoordinator(); 2153 return page->scrollingCoordinator();
2265 2154
2266 return 0; 2155 return 0;
2267 } 2156 }
2268 2157
2269 GraphicsLayerFactory* RenderLayerCompositor::graphicsLayerFactory() const 2158 GraphicsLayerFactory* RenderLayerCompositor::graphicsLayerFactory() const
2270 { 2159 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 } else if (graphicsLayer == m_scrollLayer.get()) { 2196 } else if (graphicsLayer == m_scrollLayer.get()) {
2308 name = "LocalFrame Scrolling Layer"; 2197 name = "LocalFrame Scrolling Layer";
2309 } else { 2198 } else {
2310 ASSERT_NOT_REACHED(); 2199 ASSERT_NOT_REACHED();
2311 } 2200 }
2312 2201
2313 return name; 2202 return name;
2314 } 2203 }
2315 2204
2316 } // namespace WebCore 2205 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/compositing/RenderLayerCompositor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698