diff options
author | davve <davve@opera.com> | 2015-11-21 09:19:49 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-21 17:20:47 +0000 |
commit | fec9b1244e99826e0c070c320d1babf09630bbc1 (patch) | |
tree | 2acb94ffc1915c9cdd1f7d4d97938a5cc56eebe5 | |
parent | a22a72fad19dd5deff2af11416470a8d0675f279 (diff) | |
download | chromium_src-fec9b1244e99826e0c070c320d1babf09630bbc1.zip chromium_src-fec9b1244e99826e0c070c320d1babf09630bbc1.tar.gz chromium_src-fec9b1244e99826e0c070c320d1babf09630bbc1.tar.bz2 |
Simplify ImageResource::canRender()
Assume that neither image rotation nor scale can affect the image size
emptiness. This makes it easier to further simplify
imageSizeForLayoutObject later.
BUG=559131
Review URL: https://codereview.chromium.org/1463793002
Cr-Commit-Position: refs/heads/master@{#361025}
13 files changed, 20 insertions, 22 deletions
diff --git a/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp b/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp index d4875fa..6afcd5a 100644 --- a/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp +++ b/third_party/WebKit/Source/core/css/CSSCrossfadeValue.cpp @@ -88,9 +88,7 @@ static Image* renderableImageForCSSValue(CSSValue* value, const LayoutObject* la { ImageResource* cachedImage = cachedImageForCSSValue(value, &layoutObject->document()); - // If the image can be rendered at 1 zoom it will have non-empty dimension - // and should be able to render at other scales as well. - if (!cachedImage || !cachedImage->canRender(*layoutObject, 1)) + if (!cachedImage || !cachedImage->canRender()) return nullptr; return cachedImage->image(); diff --git a/third_party/WebKit/Source/core/fetch/ImageResource.h b/third_party/WebKit/Source/core/fetch/ImageResource.h index 5cfe9ca..43eeabf 100644 --- a/third_party/WebKit/Source/core/fetch/ImageResource.h +++ b/third_party/WebKit/Source/core/fetch/ImageResource.h @@ -67,7 +67,8 @@ public: static std::pair<blink::Image*, float> brokenImage(float deviceScaleFactor); // Returns an image and the image's resolution scale factor. bool willPaintBrokenImage() const; - bool canRender(const LayoutObject& layoutObject, float multiplier) { return !errorOccurred() && !imageSizeForLayoutObject(&layoutObject, multiplier).isEmpty(); } + // Assumes that image rotation or scale doesn't effect the image size being empty or not. + bool canRender() { return !errorOccurred() && !imageSizeForLayoutObject(nullptr, 1).isEmpty(); } bool usesImageContainerSize() const; bool imageHasRelativeWidth() const; diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp index 84aa10f..4a4f729 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp @@ -4762,7 +4762,7 @@ inline bool LayoutBox::mustInvalidateFillLayersPaintOnWidthChange(const FillLaye // Make sure we have a valid image. StyleImage* img = layer.image(); - if (!img || !img->canRender(*this, style()->effectiveZoom())) + if (!img || !img->canRender()) return false; if (layer.repeatX() != RepeatFill && layer.repeatX() != NoRepeatFill) @@ -4837,7 +4837,7 @@ bool LayoutBox::canRenderBorderImage() const return false; StyleImage* borderImage = style()->borderImage().image(); - return borderImage && borderImage->canRender(*this, style()->effectiveZoom()) && borderImage->isLoaded(); + return borderImage && borderImage->canRender() && borderImage->isLoaded(); } ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp index efec9b1..d3ba572 100644 --- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp @@ -956,7 +956,7 @@ bool LayoutObject::mustInvalidateFillLayersPaintOnHeightChange(const FillLayer& // Make sure we have a valid image. StyleImage* img = layer.image(); - if (!img || !img->canRender(*this, style()->effectiveZoom())) + if (!img || !img->canRender()) return false; if (layer.repeatY() != RepeatFill && layer.repeatY() != NoRepeatFill) diff --git a/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp b/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp index 21300bb..5a94a49 100644 --- a/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp +++ b/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp @@ -1062,7 +1062,7 @@ bool InlineFlowBox::boxShadowCanBeAppliedToBackground(const FillLayer& lastBackg // The checks here match how paintFillLayer() decides whether to clip (if it does, the shadow // would be clipped out, so it has to be drawn separately). StyleImage* image = lastBackgroundLayer.image(); - bool hasFillImage = image && image->canRender(layoutObject(), layoutObject().style()->effectiveZoom()); + bool hasFillImage = image && image->canRender(); return (!hasFillImage && !layoutObject().style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent(); } diff --git a/third_party/WebKit/Source/core/paint/BoxPainter.cpp b/third_party/WebKit/Source/core/paint/BoxPainter.cpp index c56ba6a..709167a 100644 --- a/third_party/WebKit/Source/core/paint/BoxPainter.cpp +++ b/third_party/WebKit/Source/core/paint/BoxPainter.cpp @@ -143,7 +143,7 @@ void BoxPainter::paintBackground(const PaintInfo& paintInfo, const LayoutRect& p static bool isFillLayerOpaque(const FillLayer& layer, const LayoutObject& imageClient) { return layer.hasOpaqueImage(&imageClient) - && layer.image()->canRender(imageClient, imageClient.style()->effectiveZoom()) + && layer.image()->canRender() && !layer.image()->imageSize(&imageClient, imageClient.style()->effectiveZoom()).isEmpty() && layer.hasRepeatXY(); } @@ -438,7 +438,7 @@ void BoxPainter::paintFillLayerExtended(const LayoutBoxModelObject& obj, const P BackgroundImageGeometry geometry; if (bgImage) geometry.calculate(obj, paintInfo.paintContainer(), paintInfo.globalPaintFlags(), bgLayer, scrolledPaintRect); - bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(obj, obj.style()->effectiveZoom()); + bool shouldPaintBackgroundImage = bgImage && bgImage->canRender(); // Paint the color first underneath all images, culled if background image occludes it. // TODO(trchen): In the !bgLayer.hasRepeatXY() case, we could improve the culling test diff --git a/third_party/WebKit/Source/core/paint/InlineFlowBoxPainter.cpp b/third_party/WebKit/Source/core/paint/InlineFlowBoxPainter.cpp index 8b4c6d8..94e9a2b 100644 --- a/third_party/WebKit/Source/core/paint/InlineFlowBoxPainter.cpp +++ b/third_party/WebKit/Source/core/paint/InlineFlowBoxPainter.cpp @@ -70,7 +70,7 @@ void InlineFlowBoxPainter::paintFillLayer(const PaintInfo& paintInfo, const Colo { LayoutBoxModelObject* boxModel = toLayoutBoxModelObject(LineLayoutPaintShim::layoutObjectFrom(m_inlineFlowBox.boxModelObject())); StyleImage* img = fillLayer.image(); - bool hasFillImage = img && img->canRender(m_inlineFlowBox.layoutObject(), m_inlineFlowBox.lineLayoutItem().style()->effectiveZoom()); + bool hasFillImage = img && img->canRender(); if ((!hasFillImage && !m_inlineFlowBox.lineLayoutItem().style()->hasBorderRadius()) || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m_inlineFlowBox.parent()) { BoxPainter::paintFillLayerExtended(*boxModel, paintInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(), op); } else if (m_inlineFlowBox.lineLayoutItem().style()->boxDecorationBreak() == DCLONE) { @@ -164,8 +164,7 @@ InlineFlowBoxPainter::BorderPaintingType InlineFlowBoxPainter::getBorderPaintTyp if (m_inlineFlowBox.parent() && m_inlineFlowBox.lineLayoutItem().style()->hasBorderDecoration()) { const NinePieceImage& borderImage = m_inlineFlowBox.lineLayoutItem().style()->borderImage(); StyleImage* borderImageSource = borderImage.image(); - const ComputedStyle* styleToUse = m_inlineFlowBox.lineLayoutItem().style(m_inlineFlowBox.isFirstLineStyle()); - bool hasBorderImage = borderImageSource && borderImageSource->canRender(m_inlineFlowBox.layoutObject(), styleToUse->effectiveZoom()); + bool hasBorderImage = borderImageSource && borderImageSource->canRender(); if (hasBorderImage && !borderImageSource->isLoaded()) return DontPaintBorders; @@ -278,7 +277,7 @@ void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); paintFillLayers(paintInfo, Color::transparent, m_inlineFlowBox.lineLayoutItem().style()->maskLayers(), paintRect, compositeOp); - bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(m_inlineFlowBox.layoutObject(), m_inlineFlowBox.lineLayoutItem().style()->effectiveZoom()); + bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(); if (!hasBoxImage || !maskBoxImage->isLoaded()) { if (pushTransparencyLayer) paintInfo.context->endLayer(); diff --git a/third_party/WebKit/Source/core/paint/NinePieceImagePainter.cpp b/third_party/WebKit/Source/core/paint/NinePieceImagePainter.cpp index 8947ad8..afd882d 100644 --- a/third_party/WebKit/Source/core/paint/NinePieceImagePainter.cpp +++ b/third_party/WebKit/Source/core/paint/NinePieceImagePainter.cpp @@ -33,7 +33,7 @@ bool NinePieceImagePainter::paint(GraphicsContext* graphicsContext, const Layout if (!styleImage->isLoaded()) return true; // Never paint a nine-piece image incrementally, but don't paint the fallback borders either. - if (!styleImage->canRender(m_layoutObject, style.effectiveZoom())) + if (!styleImage->canRender()) return false; // Find out if the hasImage() check in ComputedStyle::border*Width had any affect, i.e. if a border is non-zero while border-style is diff --git a/third_party/WebKit/Source/core/style/StyleFetchedImage.cpp b/third_party/WebKit/Source/core/style/StyleFetchedImage.cpp index bcc2857..099b407 100644 --- a/third_party/WebKit/Source/core/style/StyleFetchedImage.cpp +++ b/third_party/WebKit/Source/core/style/StyleFetchedImage.cpp @@ -66,9 +66,9 @@ PassRefPtrWillBeRawPtr<CSSValue> StyleFetchedImage::computedCSSValue() const return cssValue(); } -bool StyleFetchedImage::canRender(const LayoutObject& layoutObject, float multiplier) const +bool StyleFetchedImage::canRender() const { - return m_image->canRender(layoutObject, multiplier); + return m_image->canRender(); } bool StyleFetchedImage::isLoaded() const diff --git a/third_party/WebKit/Source/core/style/StyleFetchedImage.h b/third_party/WebKit/Source/core/style/StyleFetchedImage.h index 9b5c9ab..6d13020 100644 --- a/third_party/WebKit/Source/core/style/StyleFetchedImage.h +++ b/third_party/WebKit/Source/core/style/StyleFetchedImage.h @@ -47,7 +47,7 @@ public: PassRefPtrWillBeRawPtr<CSSValue> cssValue() const override; PassRefPtrWillBeRawPtr<CSSValue> computedCSSValue() const override; - bool canRender(const LayoutObject&, float multiplier) const override; + bool canRender() const override; bool isLoaded() const override; bool errorOccurred() const override; LayoutSize imageSize(const LayoutObject*, float multiplier) const override; diff --git a/third_party/WebKit/Source/core/style/StyleFetchedImageSet.cpp b/third_party/WebKit/Source/core/style/StyleFetchedImageSet.cpp index 6f2688c..b1e2601 100644 --- a/third_party/WebKit/Source/core/style/StyleFetchedImageSet.cpp +++ b/third_party/WebKit/Source/core/style/StyleFetchedImageSet.cpp @@ -69,9 +69,9 @@ PassRefPtrWillBeRawPtr<CSSValue> StyleFetchedImageSet::computedCSSValue() const return m_imageSetValue->valueWithURLsMadeAbsolute(); } -bool StyleFetchedImageSet::canRender(const LayoutObject& layoutObject, float multiplier) const +bool StyleFetchedImageSet::canRender() const { - return m_bestFitImage->canRender(layoutObject, multiplier); + return m_bestFitImage->canRender(); } bool StyleFetchedImageSet::isLoaded() const diff --git a/third_party/WebKit/Source/core/style/StyleFetchedImageSet.h b/third_party/WebKit/Source/core/style/StyleFetchedImageSet.h index 6b5b141..1805cb4 100644 --- a/third_party/WebKit/Source/core/style/StyleFetchedImageSet.h +++ b/third_party/WebKit/Source/core/style/StyleFetchedImageSet.h @@ -59,7 +59,7 @@ public: void clearImageSetValue() { m_imageSetValue = nullptr; } #endif - bool canRender(const LayoutObject&, float multiplier) const override; + bool canRender() const override; bool isLoaded() const override; bool errorOccurred() const override; LayoutSize imageSize(const LayoutObject*, float multiplier) const override; diff --git a/third_party/WebKit/Source/core/style/StyleImage.h b/third_party/WebKit/Source/core/style/StyleImage.h index 8d5df40..d5d96b7 100644 --- a/third_party/WebKit/Source/core/style/StyleImage.h +++ b/third_party/WebKit/Source/core/style/StyleImage.h @@ -53,7 +53,7 @@ public: virtual PassRefPtrWillBeRawPtr<CSSValue> cssValue() const = 0; virtual PassRefPtrWillBeRawPtr<CSSValue> computedCSSValue() const = 0; - virtual bool canRender(const LayoutObject&, float /*multiplier*/) const { return true; } + virtual bool canRender() const { return true; } virtual bool isLoaded() const { return true; } virtual bool errorOccurred() const { return false; } virtual LayoutSize imageSize(const LayoutObject*, float multiplier) const = 0; |