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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp

Issue 2878573003: Initial skeleton of high-contrast mode. (Closed)
Patch Set: Don't pass settings to GraphicsLayer, address other feedback from chrishtr Created 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/PaintLayerPainter.h" 5 #include "core/paint/PaintLayerPainter.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/LocalFrame.h"
9 #include "core/frame/Settings.h"
8 #include "core/layout/LayoutView.h" 10 #include "core/layout/LayoutView.h"
9 #include "core/paint/ClipPathClipper.h" 11 #include "core/paint/ClipPathClipper.h"
10 #include "core/paint/FilterPainter.h" 12 #include "core/paint/FilterPainter.h"
11 #include "core/paint/LayerClipRecorder.h" 13 #include "core/paint/LayerClipRecorder.h"
12 #include "core/paint/LayoutObjectDrawingRecorder.h" 14 #include "core/paint/LayoutObjectDrawingRecorder.h"
13 #include "core/paint/ObjectPaintProperties.h" 15 #include "core/paint/ObjectPaintProperties.h"
14 #include "core/paint/PaintInfo.h" 16 #include "core/paint/PaintInfo.h"
15 #include "core/paint/PaintLayer.h" 17 #include "core/paint/PaintLayer.h"
16 #include "core/paint/ScrollRecorder.h" 18 #include "core/paint/ScrollRecorder.h"
17 #include "core/paint/ScrollableAreaPainter.h" 19 #include "core/paint/ScrollableAreaPainter.h"
18 #include "core/paint/Transform3DRecorder.h" 20 #include "core/paint/Transform3DRecorder.h"
19 #include "platform/RuntimeEnabledFeatures.h" 21 #include "platform/RuntimeEnabledFeatures.h"
20 #include "platform/geometry/FloatPoint3D.h" 22 #include "platform/geometry/FloatPoint3D.h"
21 #include "platform/graphics/GraphicsLayer.h" 23 #include "platform/graphics/GraphicsLayer.h"
22 #include "platform/graphics/paint/CompositingRecorder.h" 24 #include "platform/graphics/paint/CompositingRecorder.h"
23 #include "platform/graphics/paint/DisplayItemCacheSkipper.h" 25 #include "platform/graphics/paint/DisplayItemCacheSkipper.h"
24 #include "platform/graphics/paint/PaintChunkProperties.h" 26 #include "platform/graphics/paint/PaintChunkProperties.h"
25 #include "platform/graphics/paint/ScopedPaintChunkProperties.h" 27 #include "platform/graphics/paint/ScopedPaintChunkProperties.h"
26 #include "platform/graphics/paint/SubsequenceRecorder.h" 28 #include "platform/graphics/paint/SubsequenceRecorder.h"
27 #include "platform/graphics/paint/Transform3DDisplayItem.h" 29 #include "platform/graphics/paint/Transform3DDisplayItem.h"
28 #include "platform/wtf/Optional.h" 30 #include "platform/wtf/Optional.h"
29 31
30 namespace blink { 32 namespace blink {
31 33
34 static HighContrastSettings InitHighContrastSettingsFromSettings(
35 Settings* settings) {
36 HighContrastSettings result;
37 if (settings) {
38 result.mode = settings->GetHighContrastMode();
39 result.grayscale = settings->GetHighContrastGrayscale();
40 result.contrast = settings->GetHighContrastContrast();
41 } else {
42 result.mode = HighContrastMode::kOff;
43 result.grayscale = false;
44 result.contrast = 0.0;
45 }
46 return result;
47 }
48
32 static inline bool ShouldSuppressPaintingLayer(const PaintLayer& layer) { 49 static inline bool ShouldSuppressPaintingLayer(const PaintLayer& layer) {
33 // Avoid painting descendants of the root layer when stylesheets haven't 50 // Avoid painting descendants of the root layer when stylesheets haven't
34 // loaded. This avoids some FOUC. It's ok not to draw, because later on, when 51 // loaded. This avoids some FOUC. It's ok not to draw, because later on, when
35 // all the stylesheets do load, Document::styleResolverMayHaveChanged() will 52 // all the stylesheets do load, Document::styleResolverMayHaveChanged() will
36 // invalidate all painted output via a call to 53 // invalidate all painted output via a call to
37 // LayoutView::invalidatePaintForViewAndCompositedLayers(). We also avoid 54 // LayoutView::invalidatePaintForViewAndCompositedLayers(). We also avoid
38 // caching subsequences in this mode; see shouldCreateSubsequence(). 55 // caching subsequences in this mode; see shouldCreateSubsequence().
39 if (layer.GetLayoutObject().GetDocument().DidLayoutWithPendingStylesheets() && 56 if (layer.GetLayoutObject().GetDocument().DidLayoutWithPendingStylesheets() &&
40 !layer.IsRootLayer() && !layer.GetLayoutObject().IsDocumentElement()) 57 !layer.IsRootLayer() && !layer.GetLayoutObject().IsDocumentElement())
41 return true; 58 return true;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 PaintResult PaintLayerPainter::PaintLayerContents( 283 PaintResult PaintLayerPainter::PaintLayerContents(
267 GraphicsContext& context, 284 GraphicsContext& context,
268 const PaintLayerPaintingInfo& painting_info_arg, 285 const PaintLayerPaintingInfo& painting_info_arg,
269 PaintLayerFlags paint_flags, 286 PaintLayerFlags paint_flags,
270 FragmentPolicy fragment_policy) { 287 FragmentPolicy fragment_policy) {
271 PaintResult result = kFullyPainted; 288 PaintResult result = kFullyPainted;
272 289
273 if (paint_layer_.GetLayoutObject().GetFrameView()->ShouldThrottleRendering()) 290 if (paint_layer_.GetLayoutObject().GetFrameView()->ShouldThrottleRendering())
274 return result; 291 return result;
275 292
293 HighContrastSettings high_contrast_settings =
294 InitHighContrastSettingsFromSettings(paint_layer_.GetLayoutObject()
295 .GetFrameView()
296 ->GetFrame()
297 .GetSettings());
298 context.SetHighContrast(high_contrast_settings);
299
276 Optional<ScopedPaintChunkProperties> scoped_paint_chunk_properties; 300 Optional<ScopedPaintChunkProperties> scoped_paint_chunk_properties;
277 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && 301 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
278 RuntimeEnabledFeatures::rootLayerScrollingEnabled() && 302 RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
279 paint_layer_.GetLayoutObject().IsLayoutView()) { 303 paint_layer_.GetLayoutObject().IsLayoutView()) {
280 const auto* local_border_box_properties = 304 const auto* local_border_box_properties =
281 paint_layer_.GetLayoutObject().LocalBorderBoxProperties(); 305 paint_layer_.GetLayoutObject().LocalBorderBoxProperties();
282 DCHECK(local_border_box_properties); 306 DCHECK(local_border_box_properties);
283 PaintChunkProperties properties( 307 PaintChunkProperties properties(
284 context.GetPaintController().CurrentPaintChunkProperties()); 308 context.GetPaintController().CurrentPaintChunkProperties());
285 properties.property_tree_state = *local_border_box_properties; 309 properties.property_tree_state = *local_border_box_properties;
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 context, layout_object, kPaintPhaseClippingMask)) 1278 context, layout_object, kPaintPhaseClippingMask))
1255 return; 1279 return;
1256 1280
1257 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); 1281 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect());
1258 LayoutObjectDrawingRecorder drawing_recorder( 1282 LayoutObjectDrawingRecorder drawing_recorder(
1259 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect); 1283 context, layout_object, kPaintPhaseClippingMask, snapped_clip_rect);
1260 context.FillRect(snapped_clip_rect, Color::kBlack); 1284 context.FillRect(snapped_clip_rect, Color::kBlack);
1261 } 1285 }
1262 1286
1263 } // namespace blink 1287 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698