|
Lines 259-265
static Ref<DocumentFragment> createFragmentForImageAttachment(Frame& frame, Docu
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec1
|
| 259 |
frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), contentType, defaultImageAttachmentName, WTFMove(buffer)); |
259 |
frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), contentType, defaultImageAttachmentName, WTFMove(buffer)); |
| 260 |
if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) { |
260 |
if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) { |
| 261 |
auto image = HTMLImageElement::create(document); |
261 |
auto image = HTMLImageElement::create(document); |
| 262 |
image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, Blob::create(buffer.get(), contentType))); |
262 |
image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, Blob::create(document.sessionID(), buffer.get(), contentType))); |
| 263 |
image->setAttachmentElement(WTFMove(attachment)); |
263 |
image->setAttachmentElement(WTFMove(attachment)); |
| 264 |
if (preferredSize.width) |
264 |
if (preferredSize.width) |
| 265 |
image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width)); |
265 |
image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width)); |
|
Lines 271-277
static Ref<DocumentFragment> createFragmentForImageAttachment(Frame& frame, Docu
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec2
|
| 271 |
fragment->appendChild(WTFMove(attachment)); |
271 |
fragment->appendChild(WTFMove(attachment)); |
| 272 |
} |
272 |
} |
| 273 |
} else { |
273 |
} else { |
| 274 |
attachment->setFile(File::create(Blob::create(buffer.get(), contentType), defaultImageAttachmentName), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); |
274 |
attachment->setFile(File::create(Blob::create(document.sessionID(), buffer.get(), contentType), defaultImageAttachmentName), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); |
| 275 |
fragment->appendChild(WTFMove(attachment)); |
275 |
fragment->appendChild(WTFMove(attachment)); |
| 276 |
} |
276 |
} |
| 277 |
return fragment; |
277 |
return fragment; |
|
Lines 365-371
static void replaceRichContentWithAttachments(Frame& frame, DocumentFragment& fr
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec3
|
| 365 |
if (supportsClientSideAttachmentData(frame)) { |
365 |
if (supportsClientSideAttachmentData(frame)) { |
| 366 |
if (is<HTMLImageElement>(originalElement.get()) && contentTypeIsSuitableForInlineImageRepresentation(info.contentType)) { |
366 |
if (is<HTMLImageElement>(originalElement.get()) && contentTypeIsSuitableForInlineImageRepresentation(info.contentType)) { |
| 367 |
auto& image = downcast<HTMLImageElement>(originalElement.get()); |
367 |
auto& image = downcast<HTMLImageElement>(originalElement.get()); |
| 368 |
image.setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(*frame.document(), Blob::create(info.data, info.contentType))); |
368 |
image.setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(*frame.document(), Blob::create(fragment.document().sessionID(), info.data, info.contentType))); |
| 369 |
image.setAttachmentElement(attachment.copyRef()); |
369 |
image.setAttachmentElement(attachment.copyRef()); |
| 370 |
} else { |
370 |
} else { |
| 371 |
attachment->updateAttributes(info.data->size(), info.contentType, info.fileName); |
371 |
attachment->updateAttributes(info.data->size(), info.contentType, info.fileName); |
|
Lines 373-379
static void replaceRichContentWithAttachments(Frame& frame, DocumentFragment& fr
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec4
|
| 373 |
} |
373 |
} |
| 374 |
frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), WTFMove(info.contentType), WTFMove(info.fileName), WTFMove(info.data)); |
374 |
frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), WTFMove(info.contentType), WTFMove(info.fileName), WTFMove(info.data)); |
| 375 |
} else { |
375 |
} else { |
| 376 |
attachment->setFile(File::create(Blob::create(WTFMove(info.data), WTFMove(info.contentType)), WTFMove(info.fileName)), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); |
376 |
attachment->setFile(File::create(Blob::create(fragment.document().sessionID(), WTFMove(info.data), WTFMove(info.contentType)), WTFMove(info.fileName)), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); |
| 377 |
parent->replaceChild(WTFMove(attachment), WTFMove(originalElement)); |
377 |
parent->replaceChild(WTFMove(attachment), WTFMove(originalElement)); |
| 378 |
} |
378 |
} |
| 379 |
} |
379 |
} |
|
Lines 415-421
RefPtr<DocumentFragment> createFragmentAndAddResources(Frame& frame, NSAttribute
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec5
|
| 415 |
|
415 |
|
| 416 |
HashMap<AtomString, AtomString> blobURLMap; |
416 |
HashMap<AtomString, AtomString> blobURLMap; |
| 417 |
for (const Ref<ArchiveResource>& subresource : fragmentAndResources.resources) { |
417 |
for (const Ref<ArchiveResource>& subresource : fragmentAndResources.resources) { |
| 418 |
auto blob = Blob::create(subresource->data(), subresource->mimeType()); |
418 |
auto blob = Blob::create(document.sessionID(), subresource->data(), subresource->mimeType()); |
| 419 |
String blobURL = DOMURL::createObjectURL(document, blob); |
419 |
String blobURL = DOMURL::createObjectURL(document, blob); |
| 420 |
blobURLMap.set(subresource->url().string(), blobURL); |
420 |
blobURLMap.set(subresource->url().string(), blobURL); |
| 421 |
} |
421 |
} |
|
Lines 464-470
static String sanitizeMarkupWithArchive(Frame& frame, Document& destinationDocum
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec6
|
| 464 |
auto& subresourceURL = subresource->url(); |
464 |
auto& subresourceURL = subresource->url(); |
| 465 |
if (!shouldReplaceSubresourceURL(subresourceURL)) |
465 |
if (!shouldReplaceSubresourceURL(subresourceURL)) |
| 466 |
continue; |
466 |
continue; |
| 467 |
auto blob = Blob::create(subresource->data(), subresource->mimeType()); |
467 |
auto blob = Blob::create(destinationDocument.sessionID(), subresource->data(), subresource->mimeType()); |
| 468 |
String blobURL = DOMURL::createObjectURL(destinationDocument, blob); |
468 |
String blobURL = DOMURL::createObjectURL(destinationDocument, blob); |
| 469 |
blobURLMap.set(subresourceURL.string(), blobURL); |
469 |
blobURLMap.set(subresourceURL.string(), blobURL); |
| 470 |
} |
470 |
} |
|
Lines 491-497
static String sanitizeMarkupWithArchive(Frame& frame, Document& destinationDocum
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec7
|
| 491 |
Vector<uint8_t> blobBuffer; |
491 |
Vector<uint8_t> blobBuffer; |
| 492 |
blobBuffer.reserveCapacity(utf8.length()); |
492 |
blobBuffer.reserveCapacity(utf8.length()); |
| 493 |
blobBuffer.append(reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length()); |
493 |
blobBuffer.append(reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length()); |
| 494 |
auto blob = Blob::create(WTFMove(blobBuffer), type); |
494 |
auto blob = Blob::create(destinationDocument.sessionID(), WTFMove(blobBuffer), type); |
| 495 |
|
495 |
|
| 496 |
String subframeBlobURL = DOMURL::createObjectURL(destinationDocument, blob); |
496 |
String subframeBlobURL = DOMURL::createObjectURL(destinationDocument, blob); |
| 497 |
blobURLMap.set(subframeURL.string(), subframeBlobURL); |
497 |
blobURLMap.set(subframeURL.string(), subframeBlobURL); |
|
Lines 688-694
bool WebContentReader::readImage(Ref<SharedBuffer>&& buffer, const String& type,
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec8
|
| 688 |
if (shouldReplaceRichContentWithAttachments()) |
688 |
if (shouldReplaceRichContentWithAttachments()) |
| 689 |
addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type, preferredPresentationSize)); |
689 |
addFragment(createFragmentForImageAttachment(frame, document, WTFMove(buffer), type, preferredPresentationSize)); |
| 690 |
else |
690 |
else |
| 691 |
addFragment(createFragmentForImageAndURL(document, DOMURL::createObjectURL(document, Blob::create(buffer.get(), type)), preferredPresentationSize)); |
691 |
addFragment(createFragmentForImageAndURL(document, DOMURL::createObjectURL(document, Blob::create(document.sessionID(), buffer.get(), type)), preferredPresentationSize)); |
| 692 |
|
692 |
|
| 693 |
return fragment; |
693 |
return fragment; |
| 694 |
} |
694 |
} |
|
Lines 709-715
static Ref<HTMLElement> attachmentForFilePath(Frame& frame, const String& path,
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec9
|
| 709 |
auto document = makeRef(*frame.document()); |
709 |
auto document = makeRef(*frame.document()); |
| 710 |
auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document); |
710 |
auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document); |
| 711 |
if (!supportsClientSideAttachmentData(frame)) { |
711 |
if (!supportsClientSideAttachmentData(frame)) { |
| 712 |
attachment->setFile(File::create(path), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); |
712 |
attachment->setFile(File::create(document->sessionID(), path), HTMLAttachmentElement::UpdateDisplayAttributes::Yes); |
| 713 |
return attachment; |
713 |
return attachment; |
| 714 |
} |
714 |
} |
| 715 |
|
715 |
|
|
Lines 736-742
static Ref<HTMLElement> attachmentForFilePath(Frame& frame, const String& path,
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec10
|
| 736 |
|
736 |
|
| 737 |
if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) { |
737 |
if (contentTypeIsSuitableForInlineImageRepresentation(contentType)) { |
| 738 |
auto image = HTMLImageElement::create(document); |
738 |
auto image = HTMLImageElement::create(document); |
| 739 |
image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(path))); |
739 |
image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(document->sessionID(), path))); |
| 740 |
image->setAttachmentElement(WTFMove(attachment)); |
740 |
image->setAttachmentElement(WTFMove(attachment)); |
| 741 |
if (preferredSize.width) |
741 |
if (preferredSize.width) |
| 742 |
image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width)); |
742 |
image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width)); |
|
Lines 765-771
static Ref<HTMLElement> attachmentForData(Frame& frame, SharedBuffer& buffer, co
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec11
|
| 765 |
fileName = name; |
765 |
fileName = name; |
| 766 |
|
766 |
|
| 767 |
if (!supportsClientSideAttachmentData(frame)) { |
767 |
if (!supportsClientSideAttachmentData(frame)) { |
| 768 |
attachment->setFile(File::create(Blob::create(buffer, WTFMove(attachmentType)), fileName)); |
768 |
attachment->setFile(File::create(Blob::create(document->sessionID(), buffer, WTFMove(attachmentType)), fileName)); |
| 769 |
return attachment; |
769 |
return attachment; |
| 770 |
} |
770 |
} |
| 771 |
|
771 |
|
|
Lines 773-779
static Ref<HTMLElement> attachmentForData(Frame& frame, SharedBuffer& buffer, co
a/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm_sec12
|
| 773 |
|
773 |
|
| 774 |
if (contentTypeIsSuitableForInlineImageRepresentation(attachmentType)) { |
774 |
if (contentTypeIsSuitableForInlineImageRepresentation(attachmentType)) { |
| 775 |
auto image = HTMLImageElement::create(document); |
775 |
auto image = HTMLImageElement::create(document); |
| 776 |
image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(Blob::create(buffer, WTFMove(attachmentType)), WTFMove(fileName)))); |
776 |
image->setAttributeWithoutSynchronization(HTMLNames::srcAttr, DOMURL::createObjectURL(document, File::create(Blob::create(document->sessionID(), buffer, WTFMove(attachmentType)), WTFMove(fileName)))); |
| 777 |
image->setAttachmentElement(WTFMove(attachment)); |
777 |
image->setAttachmentElement(WTFMove(attachment)); |
| 778 |
if (preferredSize.width) |
778 |
if (preferredSize.width) |
| 779 |
image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width)); |
779 |
image->setAttributeWithoutSynchronization(HTMLNames::widthAttr, AtomString::number(*preferredSize.width)); |