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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 1830333002: Correct visual rects for scroll corner/resizer and non-frame composited scroll bars. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't create a LayoutScrollbartPart if we've no scrollable area. Created 4 years, 8 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
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "core/plugins/PluginView.h" 57 #include "core/plugins/PluginView.h"
58 #include "platform/LengthFunctions.h" 58 #include "platform/LengthFunctions.h"
59 #include "platform/RuntimeEnabledFeatures.h" 59 #include "platform/RuntimeEnabledFeatures.h"
60 #include "platform/fonts/FontCache.h" 60 #include "platform/fonts/FontCache.h"
61 #include "platform/geometry/TransformState.h" 61 #include "platform/geometry/TransformState.h"
62 #include "platform/graphics/BitmapImage.h" 62 #include "platform/graphics/BitmapImage.h"
63 #include "platform/graphics/CompositorMutableProperties.h" 63 #include "platform/graphics/CompositorMutableProperties.h"
64 #include "platform/graphics/GraphicsContext.h" 64 #include "platform/graphics/GraphicsContext.h"
65 #include "platform/graphics/paint/ClipDisplayItem.h" 65 #include "platform/graphics/paint/ClipDisplayItem.h"
66 #include "platform/graphics/paint/CullRect.h" 66 #include "platform/graphics/paint/CullRect.h"
67 #include "platform/graphics/paint/DrawingRecorder.h"
67 #include "platform/graphics/paint/PaintController.h" 68 #include "platform/graphics/paint/PaintController.h"
69 #include "platform/graphics/paint/SkPictureBuilder.h"
68 #include "platform/graphics/paint/TransformDisplayItem.h" 70 #include "platform/graphics/paint/TransformDisplayItem.h"
69 #include "wtf/CurrentTime.h" 71 #include "wtf/CurrentTime.h"
70 #include "wtf/text/StringBuilder.h" 72 #include "wtf/text/StringBuilder.h"
71 73
72 namespace blink { 74 namespace blink {
73 75
74 using namespace HTMLNames; 76 using namespace HTMLNames;
75 77
76 static IntRect clipBox(LayoutBox* layoutObject); 78 static IntRect clipBox(LayoutBox* layoutObject);
77 79
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 return previousInterestRect; 2304 return previousInterestRect;
2303 } 2305 }
2304 2306
2305 LayoutSize CompositedLayerMapping::subpixelAccumulation() const 2307 LayoutSize CompositedLayerMapping::subpixelAccumulation() const
2306 { 2308 {
2307 return m_owningLayer.subpixelAccumulation(); 2309 return m_owningLayer.subpixelAccumulation();
2308 } 2310 }
2309 2311
2310 bool CompositedLayerMapping::needsRepaint(const GraphicsLayer& graphicsLayer) co nst 2312 bool CompositedLayerMapping::needsRepaint(const GraphicsLayer& graphicsLayer) co nst
2311 { 2313 {
2312 // TODO(wkorman): Delegate needsRepaint() for scrollbar-affiliated layers. 2314 return isScrollableAreaLayer(&graphicsLayer) ? true : m_owningLayer.needsRep aint();
wkorman 2016/04/05 19:03:04 Since last review: - updated this line. Is always
2313 return m_owningLayer.needsRepaint();
2314 } 2315 }
2315 2316
2316 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& interestRect) const 2317 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G raphicsContext& context,
2318 GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& intere stRect) const
2317 { 2319 {
2318 // https://code.google.com/p/chromium/issues/detail?id=343772 2320 // https://code.google.com/p/chromium/issues/detail?id=343772
2319 DisableCompositingQueryAsserts disabler; 2321 DisableCompositingQueryAsserts disabler;
2320 #if ENABLE(ASSERT) 2322 #if ENABLE(ASSERT)
2321 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead. 2323 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead.
2322 if (Page* page = layoutObject()->frame()->page()) 2324 if (Page* page = layoutObject()->frame()->page())
2323 page->setIsPainting(true); 2325 page->setIsPainting(true);
2324 #endif 2326 #endif
2325 2327
2326 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer)); 2328 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer));
(...skipping 27 matching lines...) Expand all
2354 GraphicsLayerPaintInfo paintInfo; 2356 GraphicsLayerPaintInfo paintInfo;
2355 paintInfo.paintLayer = &m_owningLayer; 2357 paintInfo.paintLayer = &m_owningLayer;
2356 paintInfo.compositedBounds = compositedBounds(); 2358 paintInfo.compositedBounds = compositedBounds();
2357 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject (); 2359 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject ();
2358 2360
2359 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 2361 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
2360 doPaintTask(paintInfo, *graphicsLayer, paintLayerFlags, context, interes tRect); 2362 doPaintTask(paintInfo, *graphicsLayer, paintLayerFlags, context, interes tRect);
2361 } else if (graphicsLayer == m_squashingLayer.get()) { 2363 } else if (graphicsLayer == m_squashingLayer.get()) {
2362 for (size_t i = 0; i < m_squashedLayers.size(); ++i) 2364 for (size_t i = 0; i < m_squashedLayers.size(); ++i)
2363 doPaintTask(m_squashedLayers[i], *graphicsLayer, paintLayerFlags, co ntext, interestRect); 2365 doPaintTask(m_squashedLayers[i], *graphicsLayer, paintLayerFlags, co ntext, interestRect);
2364 } else if (graphicsLayer == layerForHorizontalScrollbar()) { 2366 } else if (isScrollableAreaLayer(graphicsLayer)) {
2365 paintScrollbar(m_owningLayer.getScrollableArea()->horizontalScrollbar(), context, interestRect); 2367 paintScrollableArea(graphicsLayer, context, interestRect);
2366 } else if (graphicsLayer == layerForVerticalScrollbar()) {
2367 paintScrollbar(m_owningLayer.getScrollableArea()->verticalScrollbar(), c ontext, interestRect);
2368 } else if (graphicsLayer == layerForScrollCorner()) {
2369 IntPoint scrollCornerAndResizerLocation = m_owningLayer.getScrollableAre a()->scrollCornerAndResizerRect().location();
2370 CullRect cullRect(enclosingIntRect(interestRect));
2371 ScrollableAreaPainter(*m_owningLayer.getScrollableArea()).paintScrollCor ner(context, -scrollCornerAndResizerLocation, cullRect);
2372 ScrollableAreaPainter(*m_owningLayer.getScrollableArea()).paintResizer(c ontext, -scrollCornerAndResizerLocation, cullRect);
2373 } 2368 }
2374 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay er, context, LayoutRect(interestRect)); 2369 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay er, context, LayoutRect(interestRect));
2375 #if ENABLE(ASSERT) 2370 #if ENABLE(ASSERT)
2376 if (Page* page = layoutObject()->frame()->page()) 2371 if (Page* page = layoutObject()->frame()->page())
2377 page->setIsPainting(false); 2372 page->setIsPainting(false);
2378 #endif 2373 #endif
2379 } 2374 }
2380 2375
2376 void CompositedLayerMapping::paintScrollableArea(const GraphicsLayer* graphicsLa yer,
2377 GraphicsContext& context, const IntRect& interestRect) const
2378 {
2379 // Note the composited scrollable area painted here is never associated with a frame. For
2380 // painting frame ScrollableAreas, see PaintLayerCompositor::paintContents.
2381
2382 if (DrawingRecorder::useCachedDrawingIfPossible(context, *graphicsLayer, Dis playItem::ScrollbarCompositedScrollbar))
2383 return;
2384
2385 FloatRect layerBounds(FloatPoint(), graphicsLayer->size());
2386 SkPictureBuilder pictureBuilder(layerBounds, nullptr, &context);
2387 PaintLayerScrollableArea* scrollableArea = m_owningLayer.getScrollableArea() ;
2388 if (graphicsLayer == layerForHorizontalScrollbar()) {
2389 paintScrollbar(scrollableArea->horizontalScrollbar(), pictureBuilder.con text(), interestRect);
2390 } else if (graphicsLayer == layerForVerticalScrollbar()) {
2391 paintScrollbar(scrollableArea->verticalScrollbar(), pictureBuilder.conte xt(), interestRect);
2392 } else if (graphicsLayer == layerForScrollCorner()) {
2393 // Note that scroll corners always paint into local space, whereas scrol lbars paint in the space of their containing frame.
2394 IntPoint scrollCornerAndResizerLocation = scrollableArea->scrollCornerAn dResizerRect().location();
2395 CullRect cullRect(enclosingIntRect(interestRect));
2396 ScrollableAreaPainter(*scrollableArea).paintScrollCorner(pictureBuilder. context(), -scrollCornerAndResizerLocation, cullRect);
2397 ScrollableAreaPainter(*scrollableArea).paintResizer(pictureBuilder.conte xt(), -scrollCornerAndResizerLocation, cullRect);
2398 }
2399 // Replay the painted scrollbar content with the GraphicsLayer backing as th e DisplayItemClient
2400 // in order for the resulting DrawingDisplayItem to produce the correct visu alRect (i.e., the
2401 // bounds of the involved GraphicsLayer).
2402 DrawingRecorder drawingRecorder(context, *graphicsLayer, DisplayItem::Scroll barCompositedScrollbar, layerBounds);
2403 pictureBuilder.endRecording()->playback(context.canvas());
2404 }
2405
2406 bool CompositedLayerMapping::isScrollableAreaLayer(const GraphicsLayer* graphics Layer) const
2407 {
2408 return graphicsLayer == layerForHorizontalScrollbar()
2409 || graphicsLayer == layerForVerticalScrollbar()
2410 || graphicsLayer == layerForScrollCorner();
2411 }
2412
2381 bool CompositedLayerMapping::isTrackingPaintInvalidations() const 2413 bool CompositedLayerMapping::isTrackingPaintInvalidations() const
2382 { 2414 {
2383 GraphicsLayerClient* client = compositor(); 2415 GraphicsLayerClient* client = compositor();
2384 return client ? client->isTrackingPaintInvalidations() : false; 2416 return client ? client->isTrackingPaintInvalidations() : false;
2385 } 2417 }
2386 2418
2387 #if ENABLE(ASSERT) 2419 #if ENABLE(ASSERT)
2388 void CompositedLayerMapping::verifyNotPainting() 2420 void CompositedLayerMapping::verifyNotPainting()
2389 { 2421 {
2390 ASSERT(!layoutObject()->frame()->page() || !layoutObject()->frame()->page()- >isPainting()); 2422 ASSERT(!layoutObject()->frame()->page() || !layoutObject()->frame()->page()- >isPainting());
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2576 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2545 name = "Scrolling Contents Layer"; 2577 name = "Scrolling Contents Layer";
2546 } else { 2578 } else {
2547 ASSERT_NOT_REACHED(); 2579 ASSERT_NOT_REACHED();
2548 } 2580 }
2549 2581
2550 return name; 2582 return name;
2551 } 2583 }
2552 2584
2553 } // namespace blink 2585 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698