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

Unified Diff: third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp

Issue 2104103003: Fix zoom in CSS paint worklets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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: third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp
diff --git a/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp b/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp
index 7da77ddd4e7984fc8c4db12c8f2b3bfb11788796..4c5fd43241a0457ea988c8699645e58340c18ecc 100644
--- a/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp
+++ b/third_party/WebKit/Source/modules/csspaint/CSSPaintDefinition.cpp
@@ -21,6 +21,17 @@
namespace blink {
+namespace {
+
+IntSize adjustSizeForZoom(const IntSize& size, float zoom)
+{
+ IntSize newSize(size);
+ newSize.scale(1 / zoom);
+ return newSize;
+}
+
+} // namespace
+
CSSPaintDefinition* CSSPaintDefinition::create(ScriptState* scriptState, v8::Local<v8::Function> constructor, v8::Local<v8::Function> paint, Vector<CSSPropertyID>& nativeInvalidationProperties, Vector<AtomicString>& customInvalidationProperties)
{
return new CSSPaintDefinition(scriptState, constructor, paint, nativeInvalidationProperties, customInvalidationProperties);
@@ -39,8 +50,10 @@ CSSPaintDefinition::~CSSPaintDefinition()
{
}
-PassRefPtr<Image> CSSPaintDefinition::paint(const LayoutObject& layoutObject, const IntSize& size)
+PassRefPtr<Image> CSSPaintDefinition::paint(const LayoutObject& layoutObject, const IntSize& size, float zoom)
{
+ const auto adjustedSize = adjustSizeForZoom(size, zoom);
ikilpatrick 2016/06/30 17:24:54 add a comment as to why we are doing this.
Gleb Lanbin 2016/06/30 23:57:20 renamed the function and variable to make clear ou
+
ScriptState::Scope scope(m_scriptState.get());
maybeCreatePaintInstance();
@@ -56,8 +69,8 @@ PassRefPtr<Image> CSSPaintDefinition::paint(const LayoutObject& layoutObject, co
DCHECK(layoutObject.node());
PaintRenderingContext2D* renderingContext = PaintRenderingContext2D::create(
- ImageBuffer::create(wrapUnique(new RecordingImageBufferSurface(size))));
- PaintSize* paintSize = PaintSize::create(size);
+ ImageBuffer::create(wrapUnique(new RecordingImageBufferSurface(size))), zoom);
+ PaintSize* paintSize = PaintSize::create(adjustedSize);
StylePropertyMap* styleMap = FilteredComputedStylePropertyMap::create(
CSSComputedStyleDeclaration::create(layoutObject.node()),
m_nativeInvalidationProperties, m_customInvalidationProperties);
@@ -81,7 +94,7 @@ PassRefPtr<Image> CSSPaintDefinition::paint(const LayoutObject& layoutObject, co
return nullptr;
}
- return PaintGeneratedImage::create(renderingContext->imageBuffer()->getPicture(), size);
+ return PaintGeneratedImage::create(renderingContext->imageBuffer()->getPicture(), adjustedSize);
}
void CSSPaintDefinition::maybeCreatePaintInstance()

Powered by Google App Engine
This is Rietveld 408576698