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

Unified Diff: Source/core/rendering/RenderHTMLCanvas.cpp

Issue 22482004: Add support for the object-fit CSS property. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Oops, sorry! Forgot to update UseCounter.cpp Created 7 years, 4 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
Index: Source/core/rendering/RenderHTMLCanvas.cpp
diff --git a/Source/core/rendering/RenderHTMLCanvas.cpp b/Source/core/rendering/RenderHTMLCanvas.cpp
index d75685a635b81ffe799288356696dbfa771bed69..0561728d757457964fecc6cc50ec4373170f096d 100644
--- a/Source/core/rendering/RenderHTMLCanvas.cpp
+++ b/Source/core/rendering/RenderHTMLCanvas.cpp
@@ -55,18 +55,32 @@ bool RenderHTMLCanvas::requiresLayer() const
void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- LayoutRect rect = contentBoxRect();
- rect.moveBy(paintOffset);
+ GraphicsContext* context = paintInfo.context;
+
+ LayoutRect contentRect = contentBoxRect();
+ contentRect.moveBy(paintOffset);
+ LayoutRect paintRect = replacedContentRect();
+ paintRect.moveBy(paintOffset);
+
+ bool clip = !contentRect.contains(paintRect);
+ if (clip) {
+ // Not allowed to overflow the content box.
+ paintInfo.context->save();
+ paintInfo.context->clip(pixelSnappedIntRect(contentRect));
+ }
if (Frame* frame = this->frame()) {
if (Page* page = frame->page()) {
if (paintInfo.phase == PaintPhaseForeground)
- page->addRelevantRepaintedObject(this, rect);
+ page->addRelevantRepaintedObject(this, intersection(paintRect, contentRect));
}
}
bool useLowQualityScale = style()->imageRendering() == ImageRenderingOptimizeContrast;
- toHTMLCanvasElement(node())->paint(paintInfo.context, rect, useLowQualityScale);
+ toHTMLCanvasElement(node())->paint(context, paintRect, useLowQualityScale);
+
+ if (clip)
+ context->restore();
}
void RenderHTMLCanvas::canvasSizeChanged()

Powered by Google App Engine
This is Rietveld 408576698