Unreviewed, rolling out r213633.
[WebKit-https.git] / Source / WebCore / rendering / RenderLayer.cpp
index 5f93a18..8f3e34e 100644 (file)
@@ -4375,6 +4375,9 @@ void RenderLayer::paintLayerContents(GraphicsContext& context, const LayerPainti
         else if (localPaintFlags & PaintLayerPaintingRootBackgroundOnly)
             paintBehavior |= PaintBehaviorRootBackgroundOnly;
 
+        if (paintingInfo.paintBehavior & PaintBehaviorExcludeSelection)
+            paintBehavior |= PaintBehaviorExcludeSelection;
+
         LayoutRect paintDirtyRect = localPaintingInfo.paintDirtyRect;
         if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars) {
             // Collect the fragments. This will compute the clip rectangles and paint offsets for each layer fragment, as well as whether or not the content of each
@@ -4771,6 +4774,9 @@ void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragmen
     else
         localPaintBehavior = paintBehavior;
 
+    if (localPaintingInfo.paintBehavior & PaintBehaviorExcludeSelection)
+        localPaintBehavior |= PaintBehaviorExcludeSelection;
+
     // Optimize clipping for the single fragment case.
     bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && layerFragments[0].shouldPaintContent && !layerFragments[0].foregroundRect.isEmpty();
     ClipRect clippedRect;
@@ -6587,19 +6593,12 @@ static bool styleHasSmoothingTextMode(const RenderStyle& style)
 }
 
 // Constrain the depth and breadth of the search for performance.
-static const int maxDescendentDepth = 3;
-static const int maxSiblingCount = 20;
+static const unsigned maxRendererTraversalCount = 200;
 
-static void determineNonLayerDescendantsPaintedContent(const RenderElement& renderer, int depth, RenderLayer::PaintedContentRequest& request)
+static void determineNonLayerDescendantsPaintedContent(const RenderElement& renderer, unsigned& renderersTraversed, RenderLayer::PaintedContentRequest& request)
 {
-    if (depth > maxDescendentDepth) {
-        request.makeStatesUndetermined();
-        return;
-    }
-    
-    int siblingCount = 0;
     for (const auto& child : childrenOfType<RenderObject>(renderer)) {
-        if (++siblingCount > maxSiblingCount) {
+        if (++renderersTraversed > maxRendererTraversalCount) {
             request.makeStatesUndetermined();
             return;
         }
@@ -6651,7 +6650,7 @@ static void determineNonLayerDescendantsPaintedContent(const RenderElement& rend
                 return;
         }
 
-        determineNonLayerDescendantsPaintedContent(renderElementChild, depth + 1, request);
+        determineNonLayerDescendantsPaintedContent(renderElementChild, renderersTraversed, request);
         if (request.isSatisfied())
             return;
     }
@@ -6659,7 +6658,8 @@ static void determineNonLayerDescendantsPaintedContent(const RenderElement& rend
 
 bool RenderLayer::hasNonEmptyChildRenderers(PaintedContentRequest& request) const
 {
-    determineNonLayerDescendantsPaintedContent(renderer(), 0, request);
+    unsigned renderersTraversed = 0;
+    determineNonLayerDescendantsPaintedContent(renderer(), renderersTraversed, request);
     return request.probablyHasPaintedContent();
 }