OLD | NEW |
---|---|
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 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2067 if (!result.hitTestRequest().listBased()) | 2067 if (!result.hitTestRequest().listBased()) |
2068 result = tempResult; | 2068 result = tempResult; |
2069 if (!depthSortDescendants) | 2069 if (!depthSortDescendants) |
2070 break; | 2070 break; |
2071 } | 2071 } |
2072 } | 2072 } |
2073 | 2073 |
2074 return resultLayer; | 2074 return resultLayer; |
2075 } | 2075 } |
2076 | 2076 |
2077 FloatRect PaintLayer::boxForFilter() const | |
2078 { | |
2079 return FloatRect(physicalBoundingBoxIncludingReflectionAndStackingChildren( | |
2080 LayoutPoint(), PaintLayer::CalculateBoundsOptions::IncludeTransformsAndC ompositedChildLayers)); | |
2081 } | |
2082 | |
2077 LayoutRect PaintLayer::boxForClipPath() const | 2083 LayoutRect PaintLayer::boxForClipPath() const |
2078 { | 2084 { |
2079 if (!layoutObject()->isBox()) { | 2085 if (!layoutObject()->isBox()) { |
2080 SECURITY_DCHECK(layoutObject()->isLayoutInline()); | 2086 SECURITY_DCHECK(layoutObject()->isLayoutInline()); |
2081 const LayoutInline& layoutInline = toLayoutInline(*layoutObject()); | 2087 const LayoutInline& layoutInline = toLayoutInline(*layoutObject()); |
2082 // This somewhat convoluted computation matches what Gecko does. | 2088 // This somewhat convoluted computation matches what Gecko does. |
2083 // See crbug.com/641907. | 2089 // See crbug.com/641907. |
2084 LayoutRect inlineBBox = layoutInline.linesBoundingBox(); | 2090 LayoutRect inlineBBox = layoutInline.linesBoundingBox(); |
2085 const InlineFlowBox* flowBox = layoutInline.firstLineBox(); | 2091 const InlineFlowBox* flowBox = layoutInline.firstLineBox(); |
2086 inlineBBox.setHeight(flowBox ? flowBox->frameRect().height() : LayoutUni t(0)); | 2092 inlineBBox.setHeight(flowBox ? flowBox->frameRect().height() : LayoutUni t(0)); |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2678 bool PaintLayer::scrollsOverflow() const | 2684 bool PaintLayer::scrollsOverflow() const |
2679 { | 2685 { |
2680 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) | 2686 if (PaintLayerScrollableArea* scrollableArea = this->getScrollableArea()) |
2681 return scrollableArea->scrollsOverflow(); | 2687 return scrollableArea->scrollsOverflow(); |
2682 | 2688 |
2683 return false; | 2689 return false; |
2684 } | 2690 } |
2685 | 2691 |
2686 namespace { | 2692 namespace { |
2687 | 2693 |
2688 FilterOperations resolveReferenceFilters(const FilterOperations& filters, float effectiveZoom, Node* enclosingNode) | 2694 FilterOperations resolveReferenceFilters( |
2695 const FilterOperations& filters, float effectiveZoom, Element& element, cons t FloatRect& zoomedReferenceBox) | |
2689 { | 2696 { |
2690 if (filters.hasReferenceFilter()) { | 2697 DCHECK(filters.hasReferenceFilter()); |
2691 for (size_t i = 0; i < filters.size(); ++i) { | 2698 |
2692 FilterOperation* filterOperation = filters.operations().at(i).get(); | 2699 for (FilterOperation* filterOperation : filters.operations()) { |
2693 if (filterOperation->type() != FilterOperation::REFERENCE) | 2700 if (filterOperation->type() != FilterOperation::REFERENCE) |
2694 continue; | 2701 continue; |
2695 ReferenceFilterOperation& referenceOperation = toReferenceFilterOper ation(*filterOperation); | 2702 ReferenceFilterOperation& referenceOperation = toReferenceFilterOperatio n(*filterOperation); |
2696 // FIXME: Cache the Filter if it didn't change. | 2703 // TODO(fs): Cache the Filter if it didn't change. |
2697 Filter* referenceFilter = FilterEffectBuilder::buildReferenceFilter( referenceOperation, nullptr, nullptr, nullptr, *toElement(enclosingNode), nullpt r, effectiveZoom); | 2704 Filter* referenceFilter = FilterEffectBuilder::buildReferenceFilter(refe renceOperation, zoomedReferenceBox, nullptr, nullptr, element, nullptr, effectiv eZoom); |
2698 referenceOperation.setFilter(referenceFilter); | 2705 referenceOperation.setFilter(referenceFilter); |
2699 } | |
2700 } | 2706 } |
2701 return filters; | 2707 return filters; |
2702 } | 2708 } |
2703 | 2709 |
2704 } // unnamed namespace | 2710 } // unnamed namespace |
2705 | 2711 |
2706 FilterOperations PaintLayer::computeFilterOperations(const ComputedStyle& style) const | 2712 FilterOperations PaintLayer::addReflectionToFilterOperations(const ComputedStyle & style) const |
2707 { | 2713 { |
2708 FilterOperations filterOperations = style.filter(); | 2714 FilterOperations filterOperations = style.filter(); |
2709 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && layoutObject()-> hasReflection() && layoutObject()->isBox()) { | 2715 if (RuntimeEnabledFeatures::cssBoxReflectFilterEnabled() && layoutObject()-> hasReflection() && layoutObject()->isBox()) { |
2710 BoxReflection reflection = boxReflectionForPaintLayer(*this, style); | 2716 BoxReflection reflection = boxReflectionForPaintLayer(*this, style); |
2711 filterOperations.operations().append(BoxReflectFilterOperation::create(r eflection)); | 2717 filterOperations.operations().append(BoxReflectFilterOperation::create(r eflection)); |
2712 } | 2718 } |
2713 return resolveReferenceFilters(filterOperations, style.effectiveZoom(), encl osingNode()); | 2719 return filterOperations; |
2714 } | 2720 } |
2715 | 2721 |
2716 CompositorFilterOperations PaintLayer::createCompositorFilterOperationsForFilter (const ComputedStyle& style) | 2722 CompositorFilterOperations PaintLayer::createCompositorFilterOperationsForFilter (const ComputedStyle& style) |
2717 { | 2723 { |
2718 return SkiaImageFilterBuilder::buildFilterOperations(computeFilterOperations (style)); | 2724 FilterOperations filterOperations = addReflectionToFilterOperations(style); |
2725 if (filterOperations.hasReferenceFilter()) | |
2726 filterOperations = resolveReferenceFilters(filterOperations, style.effec tiveZoom(), toElement(*enclosingNode()), boxForFilter()); | |
2727 return SkiaImageFilterBuilder::buildFilterOperations(filterOperations); | |
2719 } | 2728 } |
2720 | 2729 |
2721 CompositorFilterOperations PaintLayer::createCompositorFilterOperationsForBackdr opFilter(const ComputedStyle& style) | 2730 CompositorFilterOperations PaintLayer::createCompositorFilterOperationsForBackdr opFilter(const ComputedStyle& style) |
2722 { | 2731 { |
2723 FilterOperations operations = resolveReferenceFilters(style.backdropFilter() , style.effectiveZoom(), enclosingNode()); | 2732 FilterOperations operations = style.backdropFilter(); |
2733 if (operations.hasReferenceFilter()) | |
2734 operations = resolveReferenceFilters(operations, style.effectiveZoom(), toElement(*enclosingNode()), boxForFilter()); | |
2724 return SkiaImageFilterBuilder::buildFilterOperations(operations); | 2735 return SkiaImageFilterBuilder::buildFilterOperations(operations); |
2725 } | 2736 } |
2726 | 2737 |
2727 PaintLayerFilterInfo& PaintLayer::ensureFilterInfo() | 2738 PaintLayerFilterInfo& PaintLayer::ensureFilterInfo() |
2728 { | 2739 { |
2729 PaintLayerRareData& rareData = ensureRareData(); | 2740 PaintLayerRareData& rareData = ensureRareData(); |
2730 if (!rareData.filterInfo) | 2741 if (!rareData.filterInfo) |
2731 rareData.filterInfo = new PaintLayerFilterInfo(this); | 2742 rareData.filterInfo = new PaintLayerFilterInfo(this); |
2732 return *rareData.filterInfo; | 2743 return *rareData.filterInfo; |
2733 } | 2744 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2773 | 2784 |
2774 // Should have been added by updateOrRemoveFilterEffectBuilder(). | 2785 // Should have been added by updateOrRemoveFilterEffectBuilder(). |
2775 ASSERT(filterInfo); | 2786 ASSERT(filterInfo); |
2776 | 2787 |
2777 if (filterInfo->builder()) | 2788 if (filterInfo->builder()) |
2778 return filterInfo->builder(); | 2789 return filterInfo->builder(); |
2779 | 2790 |
2780 filterInfo->setBuilder(FilterEffectBuilder::create()); | 2791 filterInfo->setBuilder(FilterEffectBuilder::create()); |
2781 | 2792 |
2782 const ComputedStyle& style = layoutObject()->styleRef(); | 2793 const ComputedStyle& style = layoutObject()->styleRef(); |
2783 if (!filterInfo->builder()->build(toElement(enclosingNode()), computeFilterO perations(style), style.effectiveZoom())) | 2794 Element* element = toElement(enclosingNode()); |
2795 FilterOperations operations = addReflectionToFilterOperations(style); | |
2796 FloatRect zoomedReferenceBox; | |
2797 if (style.filter().hasReferenceFilter()) { | |
2798 zoomedReferenceBox = boxForFilter(); | |
2799 operations = resolveReferenceFilters(operations, style.effectiveZoom(), *element, zoomedReferenceBox); | |
2800 } | |
2801 if (!filterInfo->builder()->build(element, operations, style.effectiveZoom() , zoomedReferenceBox)) | |
2784 filterInfo->setBuilder(nullptr); | 2802 filterInfo->setBuilder(nullptr); |
2785 | 2803 |
2786 return filterInfo->builder(); | 2804 return filterInfo->builder(); |
2787 } | 2805 } |
2788 | 2806 |
2789 FilterEffect* PaintLayer::lastFilterEffect() const | 2807 FilterEffect* PaintLayer::lastFilterEffect() const |
2790 { | 2808 { |
2791 FilterEffectBuilder* builder = updateFilterEffectBuilder(); | 2809 FilterEffectBuilder* builder = updateFilterEffectBuilder(); |
2792 if (!builder) | 2810 if (!builder) |
2793 return nullptr; | 2811 return nullptr; |
2794 return builder->lastEffect(); | 2812 return builder->lastEffect(); |
2795 } | 2813 } |
2796 | 2814 |
2797 FloatRect PaintLayer::mapRectForFilter(const FloatRect& rect) const | 2815 FloatRect PaintLayer::mapRectForFilter(const FloatRect& rect) const |
2798 { | 2816 { |
2799 if (!hasFilterThatMovesPixels()) | 2817 if (!hasFilterThatMovesPixels()) |
2800 return rect; | 2818 return rect; |
2819 | |
2801 // Ensure the filter-chain is refreshed wrt reference filters. | 2820 // Ensure the filter-chain is refreshed wrt reference filters. |
2802 updateFilterEffectBuilder(); | 2821 updateFilterEffectBuilder(); |
2803 | 2822 |
2804 FilterOperations filterOperations = computeFilterOperations(layoutObject()-> styleRef()); | 2823 FilterOperations filterOperations = addReflectionToFilterOperations(layoutOb ject()->styleRef()); |
Stephen White
2016/09/16 19:14:23
Isn't this already handled by the call to updateFi
Stephen White
2016/09/16 19:16:54
Oh, I see now that the computed filter operations
fs
2016/09/16 19:20:37
It isn't handled because there (in updateFilterEff
| |
2805 return filterOperations.mapRect(rect); | 2824 return filterOperations.mapRect(rect); |
2806 } | 2825 } |
2807 | 2826 |
2808 LayoutRect PaintLayer::mapLayoutRectForFilter(const LayoutRect& rect) const | 2827 LayoutRect PaintLayer::mapLayoutRectForFilter(const LayoutRect& rect) const |
2809 { | 2828 { |
2810 if (!hasFilterThatMovesPixels()) | 2829 if (!hasFilterThatMovesPixels()) |
2811 return rect; | 2830 return rect; |
2812 return enclosingLayoutRect(mapRectForFilter(FloatRect(rect))); | 2831 return enclosingLayoutRect(mapRectForFilter(FloatRect(rect))); |
2813 } | 2832 } |
2814 | 2833 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2988 | 3007 |
2989 void showLayerTree(const blink::LayoutObject* layoutObject) | 3008 void showLayerTree(const blink::LayoutObject* layoutObject) |
2990 { | 3009 { |
2991 if (!layoutObject) { | 3010 if (!layoutObject) { |
2992 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); | 3011 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); |
2993 return; | 3012 return; |
2994 } | 3013 } |
2995 showLayerTree(layoutObject->enclosingLayer()); | 3014 showLayerTree(layoutObject->enclosingLayer()); |
2996 } | 3015 } |
2997 #endif | 3016 #endif |
OLD | NEW |