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

Unified Diff: sky/engine/core/rendering/RenderImage.cpp

Issue 732163004: Teach HTMLImageElement that it doesn't need ::attach. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Swap logic. Created 6 years, 1 month 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 | « sky/engine/core/rendering/RenderImage.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/rendering/RenderImage.cpp
diff --git a/sky/engine/core/rendering/RenderImage.cpp b/sky/engine/core/rendering/RenderImage.cpp
index a4645cd59761627d087e7d2129344e60014b666e..a3a8bb85882e7c97de462d704029cbb11623114f 100644
--- a/sky/engine/core/rendering/RenderImage.cpp
+++ b/sky/engine/core/rendering/RenderImage.cpp
@@ -28,6 +28,7 @@
#include "config.h"
#include "core/rendering/RenderImage.h"
+#include "core/HTMLNames.h"
#include "core/editing/FrameSelection.h"
#include "core/fetch/ImageResource.h"
#include "core/fetch/ResourceLoader.h"
@@ -72,6 +73,12 @@ void RenderImage::destroy()
RenderReplaced::destroy();
}
+void RenderImage::intrinsicSizeChanged()
+{
+ if (m_imageResource)
+ imageChanged(m_imageResource->imagePtr());
+}
+
void RenderImage::setImageResource(PassOwnPtr<RenderImageResource> imageResource)
{
ASSERT(!m_imageResource);
@@ -84,9 +91,6 @@ void RenderImage::imageChanged(WrappedImagePtr newImage, const IntRect* rect)
if (documentBeingDestroyed())
return;
- if (hasBoxDecorationBackground() || hasMask())
- RenderReplaced::imageChanged(newImage, rect);
-
if (!m_imageResource)
return;
@@ -98,6 +102,17 @@ void RenderImage::imageChanged(WrappedImagePtr newImage, const IntRect* rect)
if (m_imageResource->cachedImage() && m_imageResource->cachedImage()->hasDevicePixelRatioHeaderValue())
m_imageDevicePixelRatio = 1 / m_imageResource->cachedImage()->devicePixelRatioHeaderValue();
+ // If the RenderImage was just created we don't have style() or a parent()
+ // yet so all we can do is update our intrinsic size. Once we're inserted
+ // the resulting layout will do the rest of the work.
+ if (!parent()) {
+ updateIntrinsicSizeIfNeeded(m_imageResource->intrinsicSize());
+ return;
+ }
+
+ if (hasBoxDecorationBackground() || hasMask())
+ RenderReplaced::imageChanged(newImage, rect);
ojan 2014/11/18 03:34:47 This makes me a little future-proof nervous. If so
+
paintInvalidationOrMarkForLayout(rect);
}
@@ -119,17 +134,12 @@ void RenderImage::updateInnerContentRect()
void RenderImage::paintInvalidationOrMarkForLayout(const IntRect* rect)
{
+ ASSERT(isRooted());
+
LayoutSize oldIntrinsicSize = intrinsicSize();
LayoutSize newIntrinsicSize = m_imageResource->intrinsicSize();
updateIntrinsicSizeIfNeeded(newIntrinsicSize);
- // In the case of generated image content using :before/:after/content, we might not be
- // in the render tree yet. In that case, we just need to update our intrinsic size.
- // layout() will be called after we are inserted in the tree which will take care of
- // what we are doing here.
- if (!containingBlock())
- return;
-
bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize;
if (imageSourceHasChangedSize)
setPreferredLogicalWidthsDirty();
« no previous file with comments | « sky/engine/core/rendering/RenderImage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698