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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.cpp

Issue 2097393002: Pass origin clean flag of ImageBitmap when structure clone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/ScriptValueSerializer.h" 5 #include "bindings/core/v8/ScriptValueSerializer.h"
6 6
7 #include "bindings/core/v8/Transferables.h" 7 #include "bindings/core/v8/Transferables.h"
8 #include "bindings/core/v8/V8ArrayBuffer.h" 8 #include "bindings/core/v8/V8ArrayBuffer.h"
9 #include "bindings/core/v8/V8ArrayBufferView.h" 9 #include "bindings/core/v8/V8ArrayBufferView.h"
10 #include "bindings/core/v8/V8Blob.h" 10 #include "bindings/core/v8/V8Blob.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 doWriteUint32(pixelDataLength); 305 doWriteUint32(pixelDataLength);
306 append(pixelData, pixelDataLength); 306 append(pixelData, pixelDataLength);
307 } 307 }
308 308
309 void SerializedScriptValueWriter::writeImageData(uint32_t width, uint32_t height , const uint8_t* pixelData, uint32_t pixelDataLength) 309 void SerializedScriptValueWriter::writeImageData(uint32_t width, uint32_t height , const uint8_t* pixelData, uint32_t pixelDataLength)
310 { 310 {
311 append(ImageDataTag); 311 append(ImageDataTag);
312 doWriteImageData(width, height, pixelData, pixelDataLength); 312 doWriteImageData(width, height, pixelData, pixelDataLength);
313 } 313 }
314 314
315 void SerializedScriptValueWriter::writeImageBitmap(uint32_t width, uint32_t heig ht, const uint8_t* pixelData, uint32_t pixelDataLength) 315 void SerializedScriptValueWriter::writeImageBitmap(uint32_t width, uint32_t heig ht, uint32_t isOriginClean, const uint8_t* pixelData, uint32_t pixelDataLength)
316 { 316 {
317 append(ImageBitmapTag); 317 append(ImageBitmapTag);
318 append(isOriginClean);
318 doWriteImageData(width, height, pixelData, pixelDataLength); 319 doWriteImageData(width, height, pixelData, pixelDataLength);
319 } 320 }
320 321
321 void SerializedScriptValueWriter::writeRegExp(v8::Local<v8::String> pattern, v8: :RegExp::Flags flags) 322 void SerializedScriptValueWriter::writeRegExp(v8::Local<v8::String> pattern, v8: :RegExp::Flags flags)
322 { 323 {
323 append(RegExpTag); 324 append(RegExpTag);
324 v8::String::Utf8Value patternUtf8Value(pattern); 325 v8::String::Utf8Value patternUtf8Value(pattern);
325 doWriteString(*patternUtf8Value, patternUtf8Value.length()); 326 doWriteString(*patternUtf8Value, patternUtf8Value.length());
326 doWriteUint32(static_cast<uint32_t>(flags)); 327 doWriteUint32(static_cast<uint32_t>(flags));
327 } 328 }
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 return nullptr; 1139 return nullptr;
1139 if (imageBitmap->isNeutered()) 1140 if (imageBitmap->isNeutered())
1140 return handleError(Status::DataCloneError, "An ImageBitmap is detached a nd could not be cloned.", next); 1141 return handleError(Status::DataCloneError, "An ImageBitmap is detached a nd could not be cloned.", next);
1141 1142
1142 uint32_t index; 1143 uint32_t index;
1143 if (m_transferredImageBitmaps.tryGet(object, &index)) { 1144 if (m_transferredImageBitmaps.tryGet(object, &index)) {
1144 m_writer.writeTransferredImageBitmap(index); 1145 m_writer.writeTransferredImageBitmap(index);
1145 } else { 1146 } else {
1146 greyObject(object); 1147 greyObject(object);
1147 std::unique_ptr<uint8_t[]> pixelData = imageBitmap->copyBitmapData(Premu ltiplyAlpha); 1148 std::unique_ptr<uint8_t[]> pixelData = imageBitmap->copyBitmapData(Premu ltiplyAlpha);
1148 m_writer.writeImageBitmap(imageBitmap->width(), imageBitmap->height(), p ixelData.get(), imageBitmap->width() * imageBitmap->height() * 4); 1149 m_writer.writeImageBitmap(imageBitmap->width(), imageBitmap->height(), s tatic_cast<uint32_t>(imageBitmap->originClean()), pixelData.get(), imageBitmap-> width() * imageBitmap->height() * 4);
1149 } 1150 }
1150 return nullptr; 1151 return nullptr;
1151 } 1152 }
1152 1153
1153 void ScriptValueSerializer::writeRegExp(v8::Local<v8::Value> value) 1154 void ScriptValueSerializer::writeRegExp(v8::Local<v8::Value> value)
1154 { 1155 {
1155 v8::Local<v8::RegExp> regExp = value.As<v8::RegExp>(); 1156 v8::Local<v8::RegExp> regExp = value.As<v8::RegExp>();
1156 m_writer.writeRegExp(regExp->GetSource(), regExp->GetFlags()); 1157 m_writer.writeRegExp(regExp->GetSource(), regExp->GetFlags());
1157 } 1158 }
1158 1159
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 { 1775 {
1775 ImageData* imageData = doReadImageData(); 1776 ImageData* imageData = doReadImageData();
1776 if (!imageData) 1777 if (!imageData)
1777 return false; 1778 return false;
1778 *value = toV8(imageData, m_scriptState->context()->Global(), isolate()); 1779 *value = toV8(imageData, m_scriptState->context()->Global(), isolate());
1779 return !value->IsEmpty(); 1780 return !value->IsEmpty();
1780 } 1781 }
1781 1782
1782 bool SerializedScriptValueReader::readImageBitmap(v8::Local<v8::Value>* value) 1783 bool SerializedScriptValueReader::readImageBitmap(v8::Local<v8::Value>* value)
1783 { 1784 {
1785 uint32_t isOriginClean;
1786 if (!doReadUint32(&isOriginClean))
1787 return false;
1784 ImageData* imageData = doReadImageData(); 1788 ImageData* imageData = doReadImageData();
1785 if (!imageData) 1789 if (!imageData)
1786 return false; 1790 return false;
1787 ImageBitmapOptions options; 1791 ImageBitmapOptions options;
1788 options.setPremultiplyAlpha("none"); 1792 options.setPremultiplyAlpha("none");
1789 ImageBitmap* imageBitmap = ImageBitmap::create(imageData, IntRect(0, 0, imag eData->width(), imageData->height()), options, true); 1793 ImageBitmap* imageBitmap = ImageBitmap::create(imageData, IntRect(0, 0, imag eData->width(), imageData->height()), options, true, isOriginClean);
1790 if (!imageBitmap) 1794 if (!imageBitmap)
1791 return false; 1795 return false;
1792 *value = toV8(imageBitmap, m_scriptState->context()->Global(), isolate()); 1796 *value = toV8(imageBitmap, m_scriptState->context()->Global(), isolate());
1793 return !value->IsEmpty(); 1797 return !value->IsEmpty();
1794 } 1798 }
1795 1799
1796 bool SerializedScriptValueReader::readCompositorProxy(v8::Local<v8::Value>* valu e) 1800 bool SerializedScriptValueReader::readCompositorProxy(v8::Local<v8::Value>* valu e)
1797 { 1801 {
1798 uint32_t attributes; 1802 uint32_t attributes;
1799 uint64_t element; 1803 uint64_t element;
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
2438 return false; 2442 return false;
2439 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe renceStack.size() - 1]; 2443 uint32_t objectReference = m_openCompositeReferenceStack[m_openCompositeRefe renceStack.size() - 1];
2440 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - 1); 2444 m_openCompositeReferenceStack.shrink(m_openCompositeReferenceStack.size() - 1);
2441 if (objectReference >= m_objectPool.size()) 2445 if (objectReference >= m_objectPool.size())
2442 return false; 2446 return false;
2443 *object = m_objectPool[objectReference]; 2447 *object = m_objectPool[objectReference];
2444 return true; 2448 return true;
2445 } 2449 }
2446 2450
2447 } // namespace blink 2451 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptValueSerializer.h ('k') | third_party/WebKit/Source/core/frame/ImageBitmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698