Changeset 226097 in webkit
- Timestamp:
- Dec 18, 2017 9:38:47 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r226096 r226097 1 2017-12-18 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Attachment Support] The 'webkitattachmentbloburl' attribute should not persist after markup serialization 4 https://bugs.webkit.org/show_bug.cgi?id=180924 5 <rdar://problem/36099093> 6 7 Reviewed by Tim Horton. 8 9 Work towards dragging Blob-backed attachment elements as files on iOS and Mac. It doesn't make sense for the 10 attachment blob URL to stick around on the element after markup serialization, so this patch removes logic that 11 eagerly sets the blob URL upon setting an attachment's File. Instead, we just append this attribute when 12 generating markup. 13 14 This patch also augments existing WKAttachmentTests to ensure that these attributes are not present. 15 16 * editing/markup.cpp: 17 (WebCore::StyledMarkupAccumulator::appendCustomAttributes): 18 (WebCore::createFragmentFromMarkup): 19 * html/HTMLAttachmentElement.cpp: 20 (WebCore::HTMLAttachmentElement::setFile): 21 * rendering/HitTestResult.cpp: 22 23 Fixes a related issue where an attachment is backed by Blob data (and not a file path) would specify "file:///" 24 as its attachment file path in DragController when starting a drag. Instead, if there is no file path, fall back 25 to the blob URL. 26 27 This will be tested in a future patch once a WK2 dragging simulator for Mac is implemented, and support for 28 dragging out Blob-backed attachments as (platform) files is implemented. 29 30 (WebCore::HitTestResult::absoluteAttachmentURL const): 31 1 32 2017-12-18 Chris Dumez <cdumez@apple.com> 2 33 -
trunk/Source/WebCore/editing/markup.cpp
r224755 r226097 372 372 } 373 373 374 void StyledMarkupAccumulator::appendCustomAttributes(StringBuilder& out, const Element& element, Namespaces* namespaces)374 void StyledMarkupAccumulator::appendCustomAttributes(StringBuilder& out, const Element& element, Namespaces* namespaces) 375 375 { 376 376 #if ENABLE(ATTACHMENT_ELEMENT) … … 379 379 380 380 const HTMLAttachmentElement& attachment = downcast<HTMLAttachmentElement>(element); 381 if (attachment.file()) 382 appendAttribute(out, element, Attribute(webkitattachmentpathAttr, attachment.file()->path()), namespaces); 381 if (auto* file = attachment.file()) { 382 // These attributes are only intended for File deserialization, and are removed from the generated attachment 383 // element after we've deserialized and set its backing File. 384 appendAttribute(out, element, { webkitattachmentpathAttr, file->path() }, namespaces); 385 appendAttribute(out, element, { webkitattachmentbloburlAttr, { file->url() }}, namespaces); 386 } 383 387 #else 384 388 UNUSED_PARAM(out); … … 765 769 for (auto& attachment : attachments) { 766 770 auto attachmentPath = attachment->attachmentPath(); 767 if (attachmentPath.isEmpty()) 768 attachment->setFile(File::deserialize({ }, attachment->blobURL(), attachment->attachmentType(), attachment->attachmentTitle())); 769 else 771 auto blobURL = attachment->blobURL(); 772 if (!attachmentPath.isEmpty()) 770 773 attachment->setFile(File::create(attachmentPath)); 774 else if (!blobURL.isEmpty()) 775 attachment->setFile(File::deserialize({ }, blobURL, attachment->attachmentType(), attachment->attachmentTitle())); 771 776 attachment->removeAttribute(webkitattachmentpathAttr); 777 attachment->removeAttribute(webkitattachmentbloburlAttr); 772 778 } 773 779 #endif -
trunk/Source/WebCore/html/HTMLAttachmentElement.cpp
r226085 r226097 121 121 m_file = WTFMove(file); 122 122 123 setAttributeWithoutSynchronization(HTMLNames::webkitattachmentbloburlAttr, m_file ? m_file->url() : emptyString());124 125 123 if (updateAttributes == UpdateDisplayAttributes::Yes) { 126 124 if (m_file) { -
trunk/Source/WebCore/rendering/HitTestResult.cpp
r225837 r226097 357 357 return URL(); 358 358 359 return URL::fileURLWithFileSystemPath(attachmentFile->path()); 359 auto filepath = attachmentFile->path(); 360 if (!filepath.isEmpty()) 361 return URL::fileURLWithFileSystemPath(filepath); 362 363 ASSERT(attachmentFile->url().protocolIsBlob()); 364 return attachmentFile->url(); 360 365 } 361 366 #endif -
trunk/Tools/ChangeLog
r226093 r226097 1 2017-12-18 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [Attachment Support] The 'webkitattachmentbloburl' attribute should not persist after markup serialization 4 https://bugs.webkit.org/show_bug.cgi?id=180924 5 <rdar://problem/36099093> 6 7 Reviewed by Tim Horton. 8 9 Tweaks some existing tests to check that temporary attachment serialization attributes don't stick around on the 10 attachment elements. 11 12 * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm: 13 (-[TestWKWebView hasAttribute:forQuerySelector:]): 14 (TestWebKitAPI::TEST): 15 1 16 2017-12-18 Wenson Hsieh <wenson_hsieh@apple.com> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm
r226093 r226097 225 225 } 226 226 227 - (BOOL)hasAttribute:(NSString *)attributeName forQuerySelector:(NSString *)querySelector 228 { 229 return [self stringByEvaluatingJavaScript:[NSString stringWithFormat:@"document.querySelector('%@').hasAttribute('%@')", querySelector, attributeName]].boolValue; 230 } 231 227 232 - (NSString *)valueOfAttribute:(NSString *)attributeName forQuerySelector:(NSString *)querySelector 228 233 { … … 426 431 [firstAttachment expectRequestedDataToBe:nil]; 427 432 [secondAttachment expectRequestedDataToBe:testImageData()]; 433 EXPECT_FALSE([webView hasAttribute:@"webkitattachmentbloburl" forQuerySelector:@"attachment"]); 434 EXPECT_FALSE([webView hasAttribute:@"webkitattachmentpath" forQuerySelector:@"attachment"]); 428 435 } 429 436 … … 491 498 [webView expectUpdatesAfterCommand:@"ToggleUnderline" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]]; 492 499 [attachment expectRequestedDataToBe:testHTMLData()]; 500 EXPECT_FALSE([webView hasAttribute:@"webkitattachmentbloburl" forQuerySelector:@"attachment"]); 501 EXPECT_FALSE([webView hasAttribute:@"webkitattachmentpath" forQuerySelector:@"attachment"]); 493 502 494 503 // Inserting text should delete the current selection, removing the attachment in the process. … … 512 521 [webView expectUpdatesAfterCommand:@"InsertUnorderedList" withArgument:nil expectedRemovals:@[] expectedInsertions:@[]]; 513 522 [attachment expectRequestedDataToBe:testHTMLData()]; 523 EXPECT_FALSE([webView hasAttribute:@"webkitattachmentbloburl" forQuerySelector:@"attachment"]); 524 EXPECT_FALSE([webView hasAttribute:@"webkitattachmentpath" forQuerySelector:@"attachment"]); 514 525 } 515 526 … … 524 535 observer.expectAttachmentUpdates(@[ ], @[attachment.get()]); 525 536 } 537 EXPECT_FALSE([webView hasAttribute:@"webkitattachmentbloburl" forQuerySelector:@"attachment"]); 538 EXPECT_FALSE([webView hasAttribute:@"webkitattachmentpath" forQuerySelector:@"attachment"]); 526 539 { 527 540 ObserveAttachmentUpdatesForScope observer(webView.get()); … … 556 569 } 557 570 [attachment expectRequestedDataToBe:testHTMLData()]; 571 EXPECT_FALSE([webView hasAttribute:@"webkitattachmentbloburl" forQuerySelector:@"attachment"]); 572 EXPECT_FALSE([webView hasAttribute:@"webkitattachmentpath" forQuerySelector:@"attachment"]); 558 573 } 559 574
Note: See TracChangeset
for help on using the changeset viewer.