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

Unified Diff: third_party/WebKit/Source/core/style/FillLayer.cpp

Issue 1787733003: Consolidate background fill layer opaqueness into one method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix windows build Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/style/FillLayer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/style/FillLayer.cpp
diff --git a/third_party/WebKit/Source/core/style/FillLayer.cpp b/third_party/WebKit/Source/core/style/FillLayer.cpp
index fd248537ea206ce98593c9aa8954f2487f991b5f..64717004d712602149dc9c76ce1047272d126911 100644
--- a/third_party/WebKit/Source/core/style/FillLayer.cpp
+++ b/third_party/WebKit/Source/core/style/FillLayer.cpp
@@ -21,6 +21,7 @@
#include "core/style/FillLayer.h"
+#include "core/layout/LayoutObject.h"
#include "core/style/DataEquivalency.h"
namespace blink {
@@ -370,29 +371,44 @@ bool FillLayer::imagesAreLoaded() const
return true;
}
-bool FillLayer::hasOpaqueImage(const LayoutObject* layoutObject) const
+bool FillLayer::imageIsOpaque(const LayoutObject& layoutObject) const
{
- if (!m_image)
- return false;
+ // Returns true if we have an image that will cover the content below it when
+ // m_composite == CompositeSourceOver && m_blendMode == WebBlendModeNormal.
+ // Otherwise false.
+ return m_image->knownToBeOpaque(layoutObject)
+ && !m_image->imageSize(layoutObject, layoutObject.style()->effectiveZoom(), LayoutSize()).isEmpty();
+}
- // TODO(trchen): Should check blend mode before composite mode.
- if (m_composite == CompositeClear || m_composite == CompositeCopy)
- return true;
+bool FillLayer::imageTilesLayer() const
+{
+ // Returns true if an image will be tiled such that it covers any sized rectangle.
+ // TODO(schenney) We could relax the repeat mode requirement if we also knew the rect we
+ // had to fill, and the portion of the image we need to use, and know that the latter
+ // covers the former
+ return (m_repeatX == RepeatFill || m_repeatX == RoundFill)
+ && (m_repeatY == RepeatFill || m_repeatY == RoundFill);
+
+}
- if (m_blendMode != WebBlendModeNormal)
+bool FillLayer::imageOccludesNextLayers(const LayoutObject& layoutObject) const
+{
+ // We can't cover without an image, regardless of other parameters
+ if (!m_image || !m_image->canRender())
return false;
- if (m_composite == CompositeSourceOver)
- return m_image->knownToBeOpaque(*layoutObject);
+ switch (m_composite) {
+ case CompositeClear:
+ case CompositeCopy:
+ return imageTilesLayer();
+ case CompositeSourceOver:
+ return (m_blendMode == WebBlendModeNormal) && imageTilesLayer() && imageIsOpaque(layoutObject);
+ default: { }
+ }
return false;
}
-bool FillLayer::hasRepeatXY() const
-{
- return m_repeatX == RepeatFill && m_repeatY == RepeatFill;
-}
-
static inline bool layerImagesIdentical(const FillLayer& layer1, const FillLayer& layer2)
{
// We just care about pointer equivalency.
« no previous file with comments | « third_party/WebKit/Source/core/style/FillLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698