chromium/third_party/blink/renderer/core/paint/compositing/compositing_test.cc

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/containers/span.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "cc/base/features.h"
#include "cc/layers/picture_layer.h"
#include "cc/layers/recording_source.h"
#include "cc/layers/surface_layer.h"
#include "cc/trees/compositor_commit_data.h"
#include "cc/trees/effect_node.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/scroll_node.h"
#include "cc/trees/transform_node.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/web/web_script_source.h"
#include "third_party/blink/renderer/core/dom/dom_node_ids.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/core/testing/fake_remote_frame_host.h"
#include "third_party/blink/renderer/core/testing/scoped_mock_overlay_scrollbars.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"
#include "third_party/blink/renderer/platform/testing/find_cc_layer.h"
#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/text/base64.h"

namespace blink {

#define EXPECT_SKCOLOR4F_NEAR(expected, actual, error)

// Tests the integration between blink and cc where a layer list is sent to cc.
class CompositingTest : public PaintTestConfigurations, public testing::Test {};

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(CompositingTest, DisableAndEnableAcceleratedCompositing) {}

TEST_P(CompositingTest, DidScrollCallbackAfterScrollableAreaChanges) {}

TEST_P(CompositingTest, FrameViewScroll) {}

TEST_P(CompositingTest, WillChangeTransformHint) {}

TEST_P(CompositingTest, WillChangeTransformHintInSVG) {}

TEST_P(CompositingTest, Compositing3DTransformOnSVGModelObject) {}

TEST_P(CompositingTest, Compositing3DTransformOnSVGBlock) {}

// Inlines do not support the transform property and should not be composited
// due to 3D transforms.
TEST_P(CompositingTest, NotCompositing3DTransformOnSVGInline) {}

TEST_P(CompositingTest, PaintPropertiesWhenCompositingSVG) {}

TEST_P(CompositingTest, BackgroundColorInScrollingContentsLayer) {}

TEST_P(CompositingTest, BackgroundColorInGraphicsLayer) {}

TEST_P(CompositingTest, ContainPaintLayerBounds) {}

// https://crbug.com/1422877:
TEST_P(CompositingTest, CompositedOverlayScrollbarUnderNonFastBorderRadius) {}

// https://crbug.com/1459318
TEST_P(CompositingTest,
       FullPACUpdateOnScrollWithSyntheticClipAcrossScrollerSimpleRadius) {}

// https://crbug.com/1459318
TEST_P(CompositingTest,
       FullPACUpdateOnScrollWithSyntheticClipAcrossScrollerComplexRadius) {}

TEST_P(CompositingTest, HitTestOpaqueness) {}

TEST_P(CompositingTest, HitTestOpaquenessOfSolidColorLayer) {}

TEST_P(CompositingTest, HitTestOpaquenessOnChangeOfUsedPointerEvents) {}

// Based on the minimized test case of https://crbug.com/343198769.
TEST_P(CompositingTest,
       NonStackedScrollerWithRelativeChildAboveFixedAndAbsolute) {}

TEST_P(CompositingTest, AnchorPositionAdjustmentTransformIdReference) {}

TEST_P(CompositingTest, ScrollingContentsCullRect) {}

class CompositingSimTest : public PaintTestConfigurations, public SimTest {};

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(CompositingSimTest, LayerUpdatesDoNotInvalidateEarlierLayers) {}

TEST_P(CompositingSimTest, LayerUpdatesDoNotInvalidateLaterLayers) {}

TEST_P(CompositingSimTest,
       NoopChangeDoesNotCauseFullTreeSyncOrPropertyTreeUpdate) {}

// When a property tree change occurs that affects layer transform in the
// general case, all layers associated with the changed property tree node, and
// all layers associated with a descendant of the changed property tree node
// need to have |subtree_property_changed| set for damage tracking. In
// non-layer-list mode, this occurs in BuildPropertyTreesInternal (see:
// SetLayerPropertyChangedForChild).
TEST_P(CompositingSimTest, LayerSubtreeTransformPropertyChanged) {}

// When a property tree change occurs that affects layer transform in a simple
// case (ie before and after transforms both preserve axis alignment), the
// transforms can be directly updated without explicitly marking layers as
// damaged. The ensure damage occurs, the transform node should have
// |transform_changed| set.
TEST_P(CompositingSimTest, DirectTransformPropertyUpdate) {}

// Test that, for simple transform updates with an existing cc transform node,
// we can go from style change to updated cc transform node without running
// the blink property tree builder and without running paint artifact
// compositor.
// This is similar to |DirectTransformPropertyUpdate|, but the update is done
// from style rather than the property tree builder.
TEST_P(CompositingSimTest, FastPathTransformUpdateFromStyle) {}

// Same as the test above but for opacity changes
TEST_P(CompositingSimTest, FastPathOpacityUpdateFromStyle) {}

TEST_P(CompositingSimTest, DirectSVGTransformPropertyUpdate) {}

// This test is similar to |DirectTransformPropertyUpdate| but tests that
// the changed value of a directly updated transform is still set if some other
// change causes PaintArtifactCompositor to run and do non-direct updates.
TEST_P(CompositingSimTest, DirectTransformPropertyUpdateCausesChange) {}

// This test ensures that the correct transform nodes are created and bits set
// so that the browser controls movement adjustments needed by bottom-fixed
// elements will work.
TEST_P(CompositingSimTest, AffectedByOuterViewportBoundsDelta) {}

// When a property tree change occurs that affects layer transform-origin, the
// transform can be directly updated without explicitly marking the layer as
// damaged. The ensure damage occurs, the transform node should have
// |transform_changed| set.
TEST_P(CompositingSimTest, DirectTransformOriginPropertyUpdate) {}

// This test is similar to |LayerSubtreeTransformPropertyChanged| but for
// effect property node changes.
TEST_P(CompositingSimTest, LayerSubtreeEffectPropertyChanged) {}

// This test is similar to |LayerSubtreeTransformPropertyChanged| but for
// clip property node changes.
TEST_P(CompositingSimTest, LayerSubtreeClipPropertyChanged) {}

TEST_P(CompositingSimTest, LayerSubtreeOverflowClipPropertyChanged) {}

// This test is similar to |LayerSubtreeClipPropertyChanged| but for cases when
// the clip node itself does not change but the clip node associated with a
// layer changes.
TEST_P(CompositingSimTest, LayerClipPropertyChanged) {}

TEST_P(CompositingSimTest, SafeOpaqueBackgroundColor) {}

TEST_P(CompositingSimTest, SquashingLayerSafeOpaqueBackgroundColor) {}

// Test that a pleasant checkerboard color is used in the presence of blending.
TEST_P(CompositingSimTest, RootScrollingContentsSafeOpaqueBackgroundColor) {}

TEST_P(CompositingSimTest, NonDrawableLayersIgnoredForRenderSurfaces) {}

TEST_P(CompositingSimTest, NoRenderSurfaceWithAxisAlignedTransformAnimation) {}

TEST_P(CompositingSimTest, PromoteCrossOriginIframe) {}

// On initial layout, the iframe is not yet loaded and is not considered
// cross origin. This test ensures the iframe is promoted due to being cross
// origin after the iframe loads.
TEST_P(CompositingSimTest, PromoteCrossOriginIframeAfterLoading) {}

// An iframe that is cross-origin to the parent should be composited. This test
// sets up nested frames with domains A -> B -> A. Both the child and grandchild
// frames should be composited because they are cross-origin to their parent.
TEST_P(CompositingSimTest, PromoteCrossOriginToParent) {}

// Initially the iframe is cross-origin and should be composited. After changing
// to same-origin, the frame should no longer be composited.
TEST_P(CompositingSimTest, PromoteCrossOriginIframeAfterDomainChange) {}

// This test sets up nested frames with domains A -> B -> A. Initially, the
// child frame and grandchild frame should be composited. After changing the
// child frame to A (same-origin), both child and grandchild frames should no
// longer be composited.
TEST_P(CompositingSimTest, PromoteCrossOriginToParentIframeAfterDomainChange) {}

// Regression test for https://crbug.com/1095167. Render surfaces require that
// EffectNode::stable_id is set.
TEST_P(CompositingTest, EffectNodesShouldHaveElementIds) {}

TEST_P(CompositingSimTest, ImplSideScrollSkipsCommit) {}

TEST_P(CompositingSimTest, RasterInducingScrollSkipsCommit) {}

TEST_P(CompositingSimTest, ImplSideScrollUnpaintedSkipsCommit) {}

TEST_P(CompositingSimTest, ImplSideScaleSkipsCommit) {}

// Ensure that updates to page scale coming from the main thread update the
// page scale factor on the transform tree.
TEST_P(CompositingSimTest, MainThreadScaleUpdatesTransformTree) {}

// Similar to above but ensure the transform tree is correctly setup when scale
// already exists when building the tree.
TEST_P(CompositingSimTest, BuildTreeSetsScaleOnTransformTree) {}

TEST_P(CompositingSimTest, ScrollWithMainThreadReasonsNeedsCommit) {}

TEST_P(CompositingSimTest, FrameAttribution) {}

TEST_P(CompositingSimTest, VisibleFrameRootLayers) {}

TEST_P(CompositingSimTest, DecompositedTransformWithChange) {}

// A simple repaint update should use a fast-path in PaintArtifactCompositor.
TEST_P(CompositingSimTest, BackgroundColorChangeUsesRepaintUpdate) {}

// Similar to |BackgroundColorChangeUsesRepaintUpdate| but with multiple paint
// chunks being squashed into a single PendingLayer, and the background coming
// from the last paint chunk.
TEST_P(CompositingSimTest, MultipleChunkBackgroundColorChangeRepaintUpdate) {}

// Similar to |BackgroundColorChangeUsesRepaintUpdate| but with post-paint
// composited SVG. This test changes paint for a composited SVG element, as well
// as a regular HTML element in the presence of composited SVG.
TEST_P(CompositingSimTest, SVGColorChangeUsesRepaintUpdate) {}

TEST_P(CompositingSimTest, ChangingOpaquenessRequiresFullUpdate) {}

TEST_P(CompositingSimTest, ChangingContentsOpaqueForTextRequiresFullUpdate) {}

TEST_P(CompositingSimTest, ChangingDrawsContentRequiresFullUpdate) {}

TEST_P(CompositingSimTest, ContentsOpaqueForTextWithSubpixelSizeSimpleBg) {}

TEST_P(CompositingSimTest, ContentsOpaqueForTextWithSubpixelSizeComplexBg) {}

TEST_P(CompositingSimTest, ContentsOpaqueForTextWithPartialBackground) {}

TEST_P(CompositingSimTest, ContentsOpaqueForTextWithBorderRadiusAndPadding) {}

TEST_P(CompositingSimTest, FullCompositingUpdateReasons) {}

// Similar to |FullCompositingUpdateReasons| but for changes in post-paint
// composited SVG.
TEST_P(CompositingSimTest, FullCompositingUpdateReasonWithCompositedSVG) {}

TEST_P(CompositingSimTest, FullCompositingUpdateForJustCreatedChunks) {}

TEST_P(CompositingSimTest, FullCompositingUpdateForUncachableChunks) {}

TEST_P(CompositingSimTest, DecompositeScrollerInHiddenIframe) {}

TEST_P(CompositingSimTest, ForeignLayersInMovedSubsequence) {}

// While not required for correctness, it is important for performance that
// snapped backgrounds use solid color layers which avoid tiling.
TEST_P(CompositingSimTest, SolidColorLayersWithSnapping) {}

TEST_P(CompositingSimTest, SolidColorLayerWithSubpixelTransform) {}

// While not required for correctness, it is important for performance (e.g.,
// the MotionMark Focus benchmark) that we do not decomposite effect nodes (see:
// |PaintArtifactCompositor::DecompositeEffect|) when the author has specified
// 3D transforms which are frequently used as a generic compositing trigger.
TEST_P(CompositingSimTest, EffectCompositedWith3DTransform) {}

// The main thread will not have a chance to update the painted content of an
// animation running on the compositor, so ensure the cc::Layer with animating
// opacity has content when starting the animation, even if the opacity is
// initially 0.
TEST_P(CompositingSimTest, CompositorAnimationOfOpacityHasPaintedContent) {}

TEST_P(CompositingSimTest, CompositorAnimationOfNonInvertibleTransform) {}

TEST_P(CompositingSimTest, CompositorAnimationRevealsChild) {}

static String ImageFileAsDataURL(const String& filename) {}

TEST_P(CompositingSimTest, CompositedImageWithSubpixelOffset) {}

TEST_P(CompositingSimTest, CompositedImageWithSubpixelOffsetAndOrientation) {}

TEST_P(CompositingSimTest, ScrollingContentsLayerRecordedBounds) {}

TEST_P(CompositingSimTest, NestedBoxReflectCrash) {}

TEST_P(CompositingSimTest, ScrollbarLayerWithDecompositedTransform) {}

}  // namespace blink