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

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

Issue 303253004: Allow proper highlighting on universal overflow scroll. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: nope Created 6 years, 6 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, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 CompositedLayerMapping::CompositedLayerMapping(RenderLayer& layer) 163 CompositedLayerMapping::CompositedLayerMapping(RenderLayer& layer)
164 : m_owningLayer(layer) 164 : m_owningLayer(layer)
165 , m_isMainFrameRenderViewLayer(false) 165 , m_isMainFrameRenderViewLayer(false)
166 , m_requiresOwnBackingStoreForIntrinsicReasons(true) 166 , m_requiresOwnBackingStoreForIntrinsicReasons(true)
167 , m_requiresOwnBackingStoreForAncestorReasons(true) 167 , m_requiresOwnBackingStoreForAncestorReasons(true)
168 , m_canCompositeFilters(false) 168 , m_canCompositeFilters(false)
169 , m_backgroundLayerPaintsFixedRootBackground(false) 169 , m_backgroundLayerPaintsFixedRootBackground(false)
170 , m_needToUpdateGraphicsLayer(false) 170 , m_needToUpdateGraphicsLayer(false)
171 , m_needToUpdateGraphicsLayerOfAllDecendants(false) 171 , m_needToUpdateGraphicsLayerOfAllDecendants(false)
172 , m_scrollingContentsAreEmpty(false)
172 { 173 {
173 if (layer.isRootLayer() && renderer()->frame()->isMainFrame()) 174 if (layer.isRootLayer() && renderer()->frame()->isMainFrame())
174 m_isMainFrameRenderViewLayer = true; 175 m_isMainFrameRenderViewLayer = true;
175 176
176 createPrimaryGraphicsLayer(); 177 createPrimaryGraphicsLayer();
177 } 178 }
178 179
179 CompositedLayerMapping::~CompositedLayerMapping() 180 CompositedLayerMapping::~CompositedLayerMapping()
180 { 181 {
181 // Hits in compositing/squashing/squash-onto-nephew.html. 182 // Hits in compositing/squashing/squash-onto-nephew.html.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 m_graphicsLayer = nullptr; 246 m_graphicsLayer = nullptr;
246 m_foregroundLayer = nullptr; 247 m_foregroundLayer = nullptr;
247 m_backgroundLayer = nullptr; 248 m_backgroundLayer = nullptr;
248 m_childContainmentLayer = nullptr; 249 m_childContainmentLayer = nullptr;
249 m_childTransformLayer = nullptr; 250 m_childTransformLayer = nullptr;
250 m_maskLayer = nullptr; 251 m_maskLayer = nullptr;
251 m_childClippingMaskLayer = nullptr; 252 m_childClippingMaskLayer = nullptr;
252 253
253 m_scrollingLayer = nullptr; 254 m_scrollingLayer = nullptr;
254 m_scrollingContentsLayer = nullptr; 255 m_scrollingContentsLayer = nullptr;
256 m_scrollingBlockSelectionLayer = nullptr;
255 } 257 }
256 258
257 void CompositedLayerMapping::updateOpacity(const RenderStyle* style) 259 void CompositedLayerMapping::updateOpacity(const RenderStyle* style)
258 { 260 {
259 m_graphicsLayer->setOpacity(compositingOpacity(style->opacity())); 261 m_graphicsLayer->setOpacity(compositingOpacity(style->opacity()));
260 } 262 }
261 263
262 void CompositedLayerMapping::updateTransform(const RenderStyle* style) 264 void CompositedLayerMapping::updateTransform(const RenderStyle* style)
263 { 265 {
264 // FIXME: This could use m_owningLayer.transform(), but that currently has t ransform-origin 266 // FIXME: This could use m_owningLayer.transform(), but that currently has t ransform-origin
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 m_scrollingContentsLayer->setSize(scrollSize); 858 m_scrollingContentsLayer->setSize(scrollSize);
857 // FIXME: The paint offset and the scroll offset should really be separate c oncepts. 859 // FIXME: The paint offset and the scroll offset should really be separate c oncepts.
858 m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, Gra phicsLayer::DontSetNeedsDisplay); 860 m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, Gra phicsLayer::DontSetNeedsDisplay);
859 861
860 if (m_foregroundLayer) { 862 if (m_foregroundLayer) {
861 if (m_foregroundLayer->size() != m_scrollingContentsLayer->size()) 863 if (m_foregroundLayer->size() != m_scrollingContentsLayer->size())
862 m_foregroundLayer->setSize(m_scrollingContentsLayer->size()); 864 m_foregroundLayer->setSize(m_scrollingContentsLayer->size());
863 m_foregroundLayer->setNeedsDisplay(); 865 m_foregroundLayer->setNeedsDisplay();
864 m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->offse tFromRenderer()); 866 m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->offse tFromRenderer());
865 } 867 }
868
869 updateScrollingBlockSelection();
Ian Vollick 2014/06/13 17:07:49 I assume that it's ok that we could early out when
hartmanng 2014/06/13 17:55:13 Yeah, that's true. The selection layer should only
866 } 870 }
867 871
868 void CompositedLayerMapping::updateChildClippingMaskLayerGeometry() 872 void CompositedLayerMapping::updateChildClippingMaskLayerGeometry()
869 { 873 {
870 if (!m_childClippingMaskLayer || !renderer()->style()->clipPath()) 874 if (!m_childClippingMaskLayer || !renderer()->style()->clipPath())
871 return; 875 return;
872 RenderBox* renderBox = toRenderBox(renderer()); 876 RenderBox* renderBox = toRenderBox(renderer());
873 IntRect clientBox = enclosingIntRect(renderBox->clientBoxRect()); 877 IntRect clientBox = enclosingIntRect(renderBox->clientBoxRect());
874 878
875 m_childClippingMaskLayer->setPosition(m_graphicsLayer->position()); 879 m_childClippingMaskLayer->setPosition(m_graphicsLayer->position());
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 } 1008 }
1005 1009
1006 void CompositedLayerMapping::updatePaintingPhases() 1010 void CompositedLayerMapping::updatePaintingPhases()
1007 { 1011 {
1008 m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer()); 1012 m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
1009 if (m_scrollingContentsLayer) { 1013 if (m_scrollingContentsLayer) {
1010 GraphicsLayerPaintingPhase paintPhase = GraphicsLayerPaintOverflowConten ts | GraphicsLayerPaintCompositedScroll; 1014 GraphicsLayerPaintingPhase paintPhase = GraphicsLayerPaintOverflowConten ts | GraphicsLayerPaintCompositedScroll;
1011 if (!m_foregroundLayer) 1015 if (!m_foregroundLayer)
1012 paintPhase |= GraphicsLayerPaintForeground; 1016 paintPhase |= GraphicsLayerPaintForeground;
1013 m_scrollingContentsLayer->setPaintingPhase(paintPhase); 1017 m_scrollingContentsLayer->setPaintingPhase(paintPhase);
1018 m_scrollingBlockSelectionLayer->setPaintingPhase(paintPhase);
1014 } 1019 }
1015 } 1020 }
1016 1021
1017 void CompositedLayerMapping::updateContentsRect() 1022 void CompositedLayerMapping::updateContentsRect()
1018 { 1023 {
1019 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox())); 1024 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox()));
1020 } 1025 }
1021 1026
1027 void CompositedLayerMapping::updateScrollingBlockSelection()
1028 {
1029 if (!m_scrollingBlockSelectionLayer)
1030 return;
1031
1032 if (!m_scrollingContentsAreEmpty) {
1033 // In this case, the selection will be painted directly into m_scrolling ContentsLayer.
1034 m_scrollingBlockSelectionLayer->setDrawsContent(false);
1035 return;
1036 }
1037
1038 const IntRect blockSelectionGapsBounds = m_owningLayer.blockSelectionGapsBou nds();
1039 const bool shouldDrawContent = !blockSelectionGapsBounds.isEmpty();
1040 m_scrollingBlockSelectionLayer->setDrawsContent(shouldDrawContent);
1041 if (!shouldDrawContent)
1042 return;
1043
1044 const IntPoint position = blockSelectionGapsBounds.location() + m_owningLaye r.scrollableArea()->adjustedScrollOffset();
1045 if (m_scrollingBlockSelectionLayer->size() == blockSelectionGapsBounds.size( ) && m_scrollingBlockSelectionLayer->position() == position)
1046 return;
1047
1048 m_scrollingBlockSelectionLayer->setPosition(position);
1049 m_scrollingBlockSelectionLayer->setSize(blockSelectionGapsBounds.size());
1050 m_scrollingBlockSelectionLayer->setOffsetFromRenderer(toIntSize(blockSelecti onGapsBounds.location()), GraphicsLayer::SetNeedsDisplay);
1051 }
1052
1022 void CompositedLayerMapping::updateDrawsContent() 1053 void CompositedLayerMapping::updateDrawsContent()
1023 { 1054 {
1024 if (m_scrollingLayer) { 1055 if (m_scrollingLayer) {
1025 // We don't have to consider overflow controls, because we know that the scrollbars are drawn elsewhere. 1056 // We don't have to consider overflow controls, because we know that the scrollbars are drawn elsewhere.
1026 // m_graphicsLayer only needs backing store if the non-scrolling parts ( background, outlines, borders, shadows etc) need to paint. 1057 // m_graphicsLayer only needs backing store if the non-scrolling parts ( background, outlines, borders, shadows etc) need to paint.
1027 // m_scrollingLayer never has backing store. 1058 // m_scrollingLayer never has backing store.
1028 // m_scrollingContentsLayer only needs backing store if the scrolled con tents need to paint. 1059 // m_scrollingContentsLayer only needs backing store if the scrolled con tents need to paint.
1029 bool hasNonScrollingPaintedContent = m_owningLayer.hasVisibleContent() & & m_owningLayer.hasBoxDecorationsOrBackground(); 1060 bool hasNonScrollingPaintedContent = m_owningLayer.hasVisibleContent() & & m_owningLayer.hasBoxDecorationsOrBackground();
1030 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); 1061 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent);
1031 1062
1032 bool hasScrollingPaintedContent = m_owningLayer.hasVisibleContent() && ( renderer()->hasBackground() || paintsChildren()); 1063 m_scrollingContentsAreEmpty = !m_owningLayer.hasVisibleContent() || !(re nderer()->hasBackground() || paintsChildren());
1033 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); 1064 m_scrollingContentsLayer->setDrawsContent(!m_scrollingContentsAreEmpty);
1065
1066 updateScrollingBlockSelection();
1034 return; 1067 return;
1035 } 1068 }
1036 1069
1037 bool hasPaintedContent = containsPaintedContent(); 1070 bool hasPaintedContent = containsPaintedContent();
1038 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { 1071 if (hasPaintedContent && isAcceleratedCanvas(renderer())) {
1039 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node() )->renderingContext(); 1072 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node() )->renderingContext();
1040 // Content layer may be null if context is lost. 1073 // Content layer may be null if context is lost.
1041 if (blink::WebLayer* contentLayer = context->platformLayer()) { 1074 if (blink::WebLayer* contentLayer = context->platformLayer()) {
1042 Color bgColor(Color::transparent); 1075 Color bgColor(Color::transparent);
1043 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { 1076 if (contentLayerSupportsDirectBackgroundComposition(renderer())) {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 // Outer layer which corresponds with the scroll view. 1440 // Outer layer which corresponds with the scroll view.
1408 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForScro llingContainer); 1441 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForScro llingContainer);
1409 m_scrollingLayer->setDrawsContent(false); 1442 m_scrollingLayer->setDrawsContent(false);
1410 m_scrollingLayer->setMasksToBounds(true); 1443 m_scrollingLayer->setMasksToBounds(true);
1411 1444
1412 // Inner layer which renders the content that scrolls. 1445 // Inner layer which renders the content that scrolls.
1413 m_scrollingContentsLayer = createGraphicsLayer(CompositingReasonLaye rForScrollingContents); 1446 m_scrollingContentsLayer = createGraphicsLayer(CompositingReasonLaye rForScrollingContents);
1414 m_scrollingContentsLayer->setDrawsContent(true); 1447 m_scrollingContentsLayer->setDrawsContent(true);
1415 m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); 1448 m_scrollingLayer->addChild(m_scrollingContentsLayer.get());
1416 1449
1450 m_scrollingBlockSelectionLayer = createGraphicsLayer(CompositingReas onLayerForScrollingBlockSelection);
1451 m_scrollingBlockSelectionLayer->setDrawsContent(true);
1452 m_scrollingContentsLayer->addChild(m_scrollingBlockSelectionLayer.ge t());
1453
1417 layerChanged = true; 1454 layerChanged = true;
1418 if (scrollingCoordinator) 1455 if (scrollingCoordinator)
1419 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_ownin gLayer.scrollableArea()); 1456 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_ownin gLayer.scrollableArea());
1420 } 1457 }
1421 } else if (m_scrollingLayer) { 1458 } else if (m_scrollingLayer) {
1422 m_scrollingLayer = nullptr; 1459 m_scrollingLayer = nullptr;
1423 m_scrollingContentsLayer = nullptr; 1460 m_scrollingContentsLayer = nullptr;
1461 m_scrollingBlockSelectionLayer = nullptr;
1424 layerChanged = true; 1462 layerChanged = true;
1425 if (scrollingCoordinator) 1463 if (scrollingCoordinator)
1426 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLay er.scrollableArea()); 1464 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLay er.scrollableArea());
1427 } 1465 }
1428 1466
1429 return layerChanged; 1467 return layerChanged;
1430 } 1468 }
1431 1469
1432 static void updateScrollParentForGraphicsLayer(GraphicsLayer* layer, GraphicsLay er* topmostLayer, RenderLayer* scrollParent, ScrollingCoordinator* scrollingCoor dinator) 1470 static void updateScrollParentForGraphicsLayer(GraphicsLayer* layer, GraphicsLay er* topmostLayer, RenderLayer* scrollParent, ScrollingCoordinator* scrollingCoor dinator)
1433 { 1471 {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 1766
1729 LayoutRect CompositedLayerMapping::contentsBox() const 1767 LayoutRect CompositedLayerMapping::contentsBox() const
1730 { 1768 {
1731 LayoutRect contentsBox = contentsRect(renderer()); 1769 LayoutRect contentsBox = contentsRect(renderer());
1732 contentsBox.move(contentOffsetInCompositingLayer()); 1770 contentsBox.move(contentOffsetInCompositingLayer());
1733 return contentsBox; 1771 return contentsBox;
1734 } 1772 }
1735 1773
1736 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const 1774 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const
1737 { 1775 {
1776 if (m_scrollingBlockSelectionLayer)
1777 return m_scrollingBlockSelectionLayer.get();
1778
1738 if (m_scrollingContentsLayer) 1779 if (m_scrollingContentsLayer)
1739 return m_scrollingContentsLayer.get(); 1780 return m_scrollingContentsLayer.get();
1740 1781
1741 if (m_childContainmentLayer) 1782 if (m_childContainmentLayer)
1742 return m_childContainmentLayer.get(); 1783 return m_childContainmentLayer.get();
1743 1784
1744 if (m_childTransformLayer) 1785 if (m_childTransformLayer)
1745 return m_childTransformLayer.get(); 1786 return m_childTransformLayer.get();
1746 1787
1747 return m_graphicsLayer.get(); 1788 return m_graphicsLayer.get();
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Paint", "data" , InspectorPaintEvent::data(m_owningLayer.renderer(), clip, graphicsLayer)); 2088 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Paint", "data" , InspectorPaintEvent::data(m_owningLayer.renderer(), clip, graphicsLayer));
2048 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack()); 2089 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack());
2049 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 2090 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
2050 InspectorInstrumentation::willPaint(m_owningLayer.renderer(), graphicsLayer) ; 2091 InspectorInstrumentation::willPaint(m_owningLayer.renderer(), graphicsLayer) ;
2051 2092
2052 if (graphicsLayer == m_graphicsLayer.get() 2093 if (graphicsLayer == m_graphicsLayer.get()
2053 || graphicsLayer == m_foregroundLayer.get() 2094 || graphicsLayer == m_foregroundLayer.get()
2054 || graphicsLayer == m_backgroundLayer.get() 2095 || graphicsLayer == m_backgroundLayer.get()
2055 || graphicsLayer == m_maskLayer.get() 2096 || graphicsLayer == m_maskLayer.get()
2056 || graphicsLayer == m_childClippingMaskLayer.get() 2097 || graphicsLayer == m_childClippingMaskLayer.get()
2057 || graphicsLayer == m_scrollingContentsLayer.get()) { 2098 || graphicsLayer == m_scrollingContentsLayer.get()
2099 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2058 2100
2059 GraphicsLayerPaintInfo paintInfo; 2101 GraphicsLayerPaintInfo paintInfo;
2060 paintInfo.renderLayer = &m_owningLayer; 2102 paintInfo.renderLayer = &m_owningLayer;
2061 paintInfo.compositedBounds = compositedBounds(); 2103 paintInfo.compositedBounds = compositedBounds();
2062 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); 2104 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer();
2063 paintInfo.paintingPhase = paintingPhase; 2105 paintInfo.paintingPhase = paintingPhase;
2064 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); 2106 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer);
2065 2107
2066 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 2108 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
2067 doPaintTask(paintInfo, &context, clip); 2109 doPaintTask(paintInfo, &context, clip);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 } else if (graphicsLayer == m_layerForHorizontalScrollbar.get()) { 2251 } else if (graphicsLayer == m_layerForHorizontalScrollbar.get()) {
2210 name = "Horizontal Scrollbar Layer"; 2252 name = "Horizontal Scrollbar Layer";
2211 } else if (graphicsLayer == m_layerForVerticalScrollbar.get()) { 2253 } else if (graphicsLayer == m_layerForVerticalScrollbar.get()) {
2212 name = "Vertical Scrollbar Layer"; 2254 name = "Vertical Scrollbar Layer";
2213 } else if (graphicsLayer == m_layerForScrollCorner.get()) { 2255 } else if (graphicsLayer == m_layerForScrollCorner.get()) {
2214 name = "Scroll Corner Layer"; 2256 name = "Scroll Corner Layer";
2215 } else if (graphicsLayer == m_scrollingLayer.get()) { 2257 } else if (graphicsLayer == m_scrollingLayer.get()) {
2216 name = "Scrolling Layer"; 2258 name = "Scrolling Layer";
2217 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2259 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2218 name = "Scrolling Contents Layer"; 2260 name = "Scrolling Contents Layer";
2261 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2262 name = "Scrolling Block Selection Layer";
2219 } else { 2263 } else {
2220 ASSERT_NOT_REACHED(); 2264 ASSERT_NOT_REACHED();
2221 } 2265 }
2222 2266
2223 return name; 2267 return name;
2224 } 2268 }
2225 2269
2226 } // namespace WebCore 2270 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698