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

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

Issue 1870793004: Move common logic between BoxReflectFilterOperation and FEBoxReflect into BoxReflection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no-filter-outsets-2
Patch Set: 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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after
2632 2632
2633 } // unnamed namespace 2633 } // unnamed namespace
2634 2634
2635 FilterOperations PaintLayer::computeFilterOperations(const ComputedStyle& style) const 2635 FilterOperations PaintLayer::computeFilterOperations(const ComputedStyle& style) const
2636 { 2636 {
2637 FilterOperations filterOperations = style.filter(); 2637 FilterOperations filterOperations = style.filter();
2638 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && layoutObject()-> hasReflection() && layoutObject()->isBox()) { 2638 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && layoutObject()-> hasReflection() && layoutObject()->isBox()) {
2639 // TODO(jbroman): Incorporate the mask image. 2639 // TODO(jbroman): Incorporate the mask image.
2640 const auto* reflectStyle = style.boxReflect(); 2640 const auto* reflectStyle = style.boxReflect();
2641 FloatRect frameRect(toLayoutBox(layoutObject())->frameRect()); 2641 FloatRect frameRect(toLayoutBox(layoutObject())->frameRect());
2642 ReflectionDirection direction = VerticalReflection; 2642 BoxReflection::ReflectionDirection direction = BoxReflection::VerticalRe flection;
2643 float offset = 0; 2643 float offset = 0;
2644 switch (reflectStyle->direction()) { 2644 switch (reflectStyle->direction()) {
2645 case ReflectionAbove: 2645 case ReflectionAbove:
2646 direction = VerticalReflection; 2646 direction = BoxReflection::VerticalReflection;
2647 offset = -floatValueForLength(reflectStyle->offset(), frameRect.heig ht()); 2647 offset = -floatValueForLength(reflectStyle->offset(), frameRect.heig ht());
2648 break; 2648 break;
2649 case ReflectionBelow: 2649 case ReflectionBelow:
2650 direction = VerticalReflection; 2650 direction = BoxReflection::VerticalReflection;
2651 offset = 2 * frameRect.height() + floatValueForLength(reflectStyle-> offset(), frameRect.height()); 2651 offset = 2 * frameRect.height() + floatValueForLength(reflectStyle-> offset(), frameRect.height());
2652 break; 2652 break;
2653 case ReflectionLeft: 2653 case ReflectionLeft:
2654 direction = HorizontalReflection; 2654 direction = BoxReflection::HorizontalReflection;
2655 offset = -floatValueForLength(reflectStyle->offset(), frameRect.widt h()); 2655 offset = -floatValueForLength(reflectStyle->offset(), frameRect.widt h());
2656 break; 2656 break;
2657 case ReflectionRight: 2657 case ReflectionRight:
2658 direction = HorizontalReflection; 2658 direction = BoxReflection::HorizontalReflection;
2659 offset = 2 * frameRect.width() + floatValueForLength(reflectStyle->o ffset(), frameRect.width()); 2659 offset = 2 * frameRect.width() + floatValueForLength(reflectStyle->o ffset(), frameRect.width());
2660 break; 2660 break;
2661 } 2661 }
2662 2662
2663 // Since the filter origin is the corner of the input bounds, which may 2663 // Since the filter origin is the corner of the input bounds, which may
2664 // include visual overflow (e.g. due to box-shadow), we must adjust the 2664 // include visual overflow (e.g. due to box-shadow), we must adjust the
2665 // offset to also account for this offset (this is equivalent to using 2665 // offset to also account for this offset (this is equivalent to using
2666 // SkLocalMatrixImageFilter, but simpler). 2666 // SkLocalMatrixImageFilter, but simpler).
2667 // The rect used here should match the one used in FilterPainter. 2667 // The rect used here should match the one used in FilterPainter.
2668 LayoutRect filterInputBounds = physicalBoundingBoxIncludingReflectionAnd StackingChildren(LayoutPoint()); 2668 LayoutRect filterInputBounds = physicalBoundingBoxIncludingReflectionAnd StackingChildren(LayoutPoint());
2669 offset -= 2 * (direction == VerticalReflection ? filterInputBounds.y() : filterInputBounds.x()).toFloat(); 2669 offset -= 2 * (direction == BoxReflection::VerticalReflection ? filterIn putBounds.y() : filterInputBounds.x()).toFloat();
2670 2670
2671 filterOperations.operations().append(BoxReflectFilterOperation::create(d irection, offset)); 2671 BoxReflection reflection(direction, offset);
2672 filterOperations.operations().append(BoxReflectFilterOperation::create(r eflection));
2672 } 2673 }
2673 return computeFilterOperationsHandleReferenceFilters(filterOperations, style .effectiveZoom(), enclosingNode()); 2674 return computeFilterOperationsHandleReferenceFilters(filterOperations, style .effectiveZoom(), enclosingNode());
2674 } 2675 }
2675 2676
2676 FilterOperations PaintLayer::computeBackdropFilterOperations(const ComputedStyle & style) const 2677 FilterOperations PaintLayer::computeBackdropFilterOperations(const ComputedStyle & style) const
2677 { 2678 {
2678 return computeFilterOperationsHandleReferenceFilters(style.backdropFilter(), style.effectiveZoom(), enclosingNode()); 2679 return computeFilterOperationsHandleReferenceFilters(style.backdropFilter(), style.effectiveZoom(), enclosingNode());
2679 } 2680 }
2680 2681
2681 PaintLayerFilterInfo& PaintLayer::ensureFilterInfo() 2682 PaintLayerFilterInfo& PaintLayer::ensureFilterInfo()
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2907 2908
2908 void showLayerTree(const blink::LayoutObject* layoutObject) 2909 void showLayerTree(const blink::LayoutObject* layoutObject)
2909 { 2910 {
2910 if (!layoutObject) { 2911 if (!layoutObject) {
2911 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2912 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2912 return; 2913 return;
2913 } 2914 }
2914 showLayerTree(layoutObject->enclosingLayer()); 2915 showLayerTree(layoutObject->enclosingLayer());
2915 } 2916 }
2916 #endif 2917 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698