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

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: TestExpectations 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 m_scrollingContentsLayer->setSize(scrollSize); 853 m_scrollingContentsLayer->setSize(scrollSize);
852 // FIXME: The paint offset and the scroll offset should really be separate c oncepts. 854 // FIXME: The paint offset and the scroll offset should really be separate c oncepts.
853 m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, Gra phicsLayer::DontSetNeedsDisplay); 855 m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset, Gra phicsLayer::DontSetNeedsDisplay);
854 856
855 if (m_foregroundLayer) { 857 if (m_foregroundLayer) {
856 if (m_foregroundLayer->size() != m_scrollingContentsLayer->size()) 858 if (m_foregroundLayer->size() != m_scrollingContentsLayer->size())
857 m_foregroundLayer->setSize(m_scrollingContentsLayer->size()); 859 m_foregroundLayer->setSize(m_scrollingContentsLayer->size());
858 m_foregroundLayer->setNeedsDisplay(); 860 m_foregroundLayer->setNeedsDisplay();
859 m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->offse tFromRenderer()); 861 m_foregroundLayer->setOffsetFromRenderer(m_scrollingContentsLayer->offse tFromRenderer());
860 } 862 }
863
864 updateScrollingBlockSelection();
861 } 865 }
862 866
863 void CompositedLayerMapping::updateChildClippingMaskLayerGeometry() 867 void CompositedLayerMapping::updateChildClippingMaskLayerGeometry()
864 { 868 {
865 if (!m_childClippingMaskLayer || !renderer()->style()->clipPath()) 869 if (!m_childClippingMaskLayer || !renderer()->style()->clipPath())
866 return; 870 return;
867 RenderBox* renderBox = toRenderBox(renderer()); 871 RenderBox* renderBox = toRenderBox(renderer());
868 IntRect clientBox = enclosingIntRect(renderBox->clientBoxRect()); 872 IntRect clientBox = enclosingIntRect(renderBox->clientBoxRect());
869 873
870 m_childClippingMaskLayer->setPosition(m_graphicsLayer->position()); 874 m_childClippingMaskLayer->setPosition(m_graphicsLayer->position());
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 } 1003 }
1000 1004
1001 void CompositedLayerMapping::updatePaintingPhases() 1005 void CompositedLayerMapping::updatePaintingPhases()
1002 { 1006 {
1003 m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer()); 1007 m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
1004 if (m_scrollingContentsLayer) { 1008 if (m_scrollingContentsLayer) {
1005 GraphicsLayerPaintingPhase paintPhase = GraphicsLayerPaintOverflowConten ts | GraphicsLayerPaintCompositedScroll; 1009 GraphicsLayerPaintingPhase paintPhase = GraphicsLayerPaintOverflowConten ts | GraphicsLayerPaintCompositedScroll;
1006 if (!m_foregroundLayer) 1010 if (!m_foregroundLayer)
1007 paintPhase |= GraphicsLayerPaintForeground; 1011 paintPhase |= GraphicsLayerPaintForeground;
1008 m_scrollingContentsLayer->setPaintingPhase(paintPhase); 1012 m_scrollingContentsLayer->setPaintingPhase(paintPhase);
1013 m_scrollingBlockSelectionLayer->setPaintingPhase(paintPhase);
1009 } 1014 }
1010 } 1015 }
1011 1016
1012 void CompositedLayerMapping::updateContentsRect() 1017 void CompositedLayerMapping::updateContentsRect()
1013 { 1018 {
1014 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox())); 1019 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox()));
1015 } 1020 }
1016 1021
1022 void CompositedLayerMapping::updateScrollingBlockSelection()
1023 {
1024 if (!m_scrollingBlockSelectionLayer)
1025 return;
1026
1027 if (!m_scrollingContentsAreEmpty) {
1028 m_scrollingBlockSelectionLayer->setDrawsContent(false);
Ian Vollick 2014/06/12 14:54:57 A comment explaining that the selection will be pa
hartmanng 2014/06/13 14:51:38 Done.
1029 return;
1030 }
1031
1032 const IntRect blockSelectionGapsBounds = m_owningLayer.blockSelectionGapsBou nds();
1033 const bool shouldDrawContent = !blockSelectionGapsBounds.isEmpty();
1034 m_scrollingBlockSelectionLayer->setDrawsContent(shouldDrawContent);
1035 if (!shouldDrawContent)
1036 return;
1037
1038 const IntPoint position = blockSelectionGapsBounds.location() + m_owningLaye r.scrollableArea()->adjustedScrollOffset();
1039 if (m_scrollingBlockSelectionLayer->size() == blockSelectionGapsBounds.size( ) && m_scrollingBlockSelectionLayer->position() == position)
1040 return;
1041
1042 m_scrollingBlockSelectionLayer->setPosition(position);
1043 m_scrollingBlockSelectionLayer->setSize(blockSelectionGapsBounds.size());
1044 m_scrollingBlockSelectionLayer->setOffsetFromRenderer(toIntSize(blockSelecti onGapsBounds.location()), GraphicsLayer::SetNeedsDisplay);
1045 }
1046
1017 void CompositedLayerMapping::updateDrawsContent() 1047 void CompositedLayerMapping::updateDrawsContent()
1018 { 1048 {
1019 if (m_scrollingLayer) { 1049 if (m_scrollingLayer) {
1020 // We don't have to consider overflow controls, because we know that the scrollbars are drawn elsewhere. 1050 // We don't have to consider overflow controls, because we know that the scrollbars are drawn elsewhere.
1021 // m_graphicsLayer only needs backing store if the non-scrolling parts ( background, outlines, borders, shadows etc) need to paint. 1051 // m_graphicsLayer only needs backing store if the non-scrolling parts ( background, outlines, borders, shadows etc) need to paint.
1022 // m_scrollingLayer never has backing store. 1052 // m_scrollingLayer never has backing store.
1023 // m_scrollingContentsLayer only needs backing store if the scrolled con tents need to paint. 1053 // m_scrollingContentsLayer only needs backing store if the scrolled con tents need to paint.
1024 bool hasNonScrollingPaintedContent = m_owningLayer.hasVisibleContent() & & m_owningLayer.hasBoxDecorationsOrBackground(); 1054 bool hasNonScrollingPaintedContent = m_owningLayer.hasVisibleContent() & & m_owningLayer.hasBoxDecorationsOrBackground();
1025 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); 1055 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent);
1026 1056
1027 bool hasScrollingPaintedContent = m_owningLayer.hasVisibleContent() && ( renderer()->hasBackground() || paintsChildren()); 1057 bool hasScrollingPaintedContent = m_owningLayer.hasVisibleContent() && ( renderer()->hasBackground() || paintsChildren());
Ian Vollick 2014/06/12 14:54:57 I don't think you need the temporary if you're goi
hartmanng 2014/06/13 14:51:38 Done.
1028 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); 1058 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent);
1059
1060 m_scrollingContentsAreEmpty = !hasScrollingPaintedContent;
1061 updateScrollingBlockSelection();
1029 return; 1062 return;
1030 } 1063 }
1031 1064
1032 bool hasPaintedContent = containsPaintedContent(); 1065 bool hasPaintedContent = containsPaintedContent();
1033 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { 1066 if (hasPaintedContent && isAcceleratedCanvas(renderer())) {
1034 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node() )->renderingContext(); 1067 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node() )->renderingContext();
1035 // Content layer may be null if context is lost. 1068 // Content layer may be null if context is lost.
1036 if (blink::WebLayer* contentLayer = context->platformLayer()) { 1069 if (blink::WebLayer* contentLayer = context->platformLayer()) {
1037 Color bgColor(Color::transparent); 1070 Color bgColor(Color::transparent);
1038 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { 1071 if (contentLayerSupportsDirectBackgroundComposition(renderer())) {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 // Outer layer which corresponds with the scroll view. 1435 // Outer layer which corresponds with the scroll view.
1403 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForScro llingContainer); 1436 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForScro llingContainer);
1404 m_scrollingLayer->setDrawsContent(false); 1437 m_scrollingLayer->setDrawsContent(false);
1405 m_scrollingLayer->setMasksToBounds(true); 1438 m_scrollingLayer->setMasksToBounds(true);
1406 1439
1407 // Inner layer which renders the content that scrolls. 1440 // Inner layer which renders the content that scrolls.
1408 m_scrollingContentsLayer = createGraphicsLayer(CompositingReasonLaye rForScrollingContents); 1441 m_scrollingContentsLayer = createGraphicsLayer(CompositingReasonLaye rForScrollingContents);
1409 m_scrollingContentsLayer->setDrawsContent(true); 1442 m_scrollingContentsLayer->setDrawsContent(true);
1410 m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); 1443 m_scrollingLayer->addChild(m_scrollingContentsLayer.get());
1411 1444
1445 m_scrollingBlockSelectionLayer = createGraphicsLayer(CompositingReas onLayerForScrollingBlockSelection);
Ian Vollick 2014/06/12 14:54:57 Is it possible to create this only when we have a
hartmanng 2014/06/13 14:51:38 I'm not really sure. I tried for a while, but coul
1446 m_scrollingBlockSelectionLayer->setDrawsContent(true);
1447 m_scrollingContentsLayer->addChild(m_scrollingBlockSelectionLayer.ge t());
1448
1412 layerChanged = true; 1449 layerChanged = true;
1413 if (scrollingCoordinator) 1450 if (scrollingCoordinator)
1414 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_ownin gLayer.scrollableArea()); 1451 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_ownin gLayer.scrollableArea());
1415 } 1452 }
1416 } else if (m_scrollingLayer) { 1453 } else if (m_scrollingLayer) {
1417 m_scrollingLayer = nullptr; 1454 m_scrollingLayer = nullptr;
1418 m_scrollingContentsLayer = nullptr; 1455 m_scrollingContentsLayer = nullptr;
1456 m_scrollingBlockSelectionLayer = nullptr;
1419 layerChanged = true; 1457 layerChanged = true;
1420 if (scrollingCoordinator) 1458 if (scrollingCoordinator)
1421 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLay er.scrollableArea()); 1459 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_owningLay er.scrollableArea());
1422 } 1460 }
1423 1461
1424 return layerChanged; 1462 return layerChanged;
1425 } 1463 }
1426 1464
1427 static void updateScrollParentForGraphicsLayer(GraphicsLayer* layer, GraphicsLay er* topmostLayer, RenderLayer* scrollParent, ScrollingCoordinator* scrollingCoor dinator) 1465 static void updateScrollParentForGraphicsLayer(GraphicsLayer* layer, GraphicsLay er* topmostLayer, RenderLayer* scrollParent, ScrollingCoordinator* scrollingCoor dinator)
1428 { 1466 {
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Paint", "data" , InspectorPaintEvent::data(m_owningLayer.renderer(), clip, graphicsLayer)); 2080 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Paint", "data" , InspectorPaintEvent::data(m_owningLayer.renderer(), clip, graphicsLayer));
2043 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack()); 2081 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack());
2044 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 2082 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
2045 InspectorInstrumentation::willPaint(m_owningLayer.renderer(), graphicsLayer) ; 2083 InspectorInstrumentation::willPaint(m_owningLayer.renderer(), graphicsLayer) ;
2046 2084
2047 if (graphicsLayer == m_graphicsLayer.get() 2085 if (graphicsLayer == m_graphicsLayer.get()
2048 || graphicsLayer == m_foregroundLayer.get() 2086 || graphicsLayer == m_foregroundLayer.get()
2049 || graphicsLayer == m_backgroundLayer.get() 2087 || graphicsLayer == m_backgroundLayer.get()
2050 || graphicsLayer == m_maskLayer.get() 2088 || graphicsLayer == m_maskLayer.get()
2051 || graphicsLayer == m_childClippingMaskLayer.get() 2089 || graphicsLayer == m_childClippingMaskLayer.get()
2052 || graphicsLayer == m_scrollingContentsLayer.get()) { 2090 || graphicsLayer == m_scrollingContentsLayer.get()
2091 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2053 2092
2054 GraphicsLayerPaintInfo paintInfo; 2093 GraphicsLayerPaintInfo paintInfo;
2055 paintInfo.renderLayer = &m_owningLayer; 2094 paintInfo.renderLayer = &m_owningLayer;
2056 paintInfo.compositedBounds = compositedBounds(); 2095 paintInfo.compositedBounds = compositedBounds();
2057 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); 2096 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer();
2058 paintInfo.paintingPhase = paintingPhase; 2097 paintInfo.paintingPhase = paintingPhase;
2059 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); 2098 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer);
2060 2099
2061 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 2100 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
2062 doPaintTask(paintInfo, &context, clip); 2101 doPaintTask(paintInfo, &context, clip);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 } else if (graphicsLayer == m_layerForHorizontalScrollbar.get()) { 2243 } else if (graphicsLayer == m_layerForHorizontalScrollbar.get()) {
2205 name = "Horizontal Scrollbar Layer"; 2244 name = "Horizontal Scrollbar Layer";
2206 } else if (graphicsLayer == m_layerForVerticalScrollbar.get()) { 2245 } else if (graphicsLayer == m_layerForVerticalScrollbar.get()) {
2207 name = "Vertical Scrollbar Layer"; 2246 name = "Vertical Scrollbar Layer";
2208 } else if (graphicsLayer == m_layerForScrollCorner.get()) { 2247 } else if (graphicsLayer == m_layerForScrollCorner.get()) {
2209 name = "Scroll Corner Layer"; 2248 name = "Scroll Corner Layer";
2210 } else if (graphicsLayer == m_scrollingLayer.get()) { 2249 } else if (graphicsLayer == m_scrollingLayer.get()) {
2211 name = "Scrolling Layer"; 2250 name = "Scrolling Layer";
2212 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2251 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2213 name = "Scrolling Contents Layer"; 2252 name = "Scrolling Contents Layer";
2253 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2254 name = "Scrolling Block Selection Layer";
2214 } else { 2255 } else {
2215 ASSERT_NOT_REACHED(); 2256 ASSERT_NOT_REACHED();
2216 } 2257 }
2217 2258
2218 return name; 2259 return name;
2219 } 2260 }
2220 2261
2221 } // namespace WebCore 2262 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698