Changeset 180785 in webkit
- Timestamp:
- Feb 27, 2015 3:07:03 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r180783 r180785 1 2015-02-27 Enrica Casucci <enrica@apple.com> 2 3 Adding support for serializing HTMLAttachment elements. 4 https://bugs.webkit.org/show_bug.cgi?id=142026 5 6 Reviewed by Tim Horton. 7 8 * editing/pasteboard/copy-paste-attachment-expected.txt: Added. 9 * editing/pasteboard/copy-paste-attachment.html: Added. 10 1 11 2015-02-27 Brady Eidson <beidson@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r180784 r180785 1 2015-02-27 Enrica Casucci <enrica@apple.com> 2 3 Adding support for serializing HTMLAttachment elements. 4 https://bugs.webkit.org/show_bug.cgi?id=142026 5 6 Reviewed by Tim Horton. 7 8 Test: editing/pasteboard/copy-paste-attachment.html 9 10 Adding support to serialize the attachment element 11 and properly handle it when converting a DOM range 12 to NSAttributedString. 13 14 * editing/cocoa/HTMLConverter.mm: 15 (HTMLConverter::_processElement): 16 * editing/markup.cpp: 17 (WebCore::StyledMarkupAccumulator::appendCustomAttributes): Create new attribute 18 for attachment element when serializating. 19 (WebCore::StyledMarkupAccumulator::appendElement): 20 (WebCore::createFragmentFromMarkup): Remove the attribute from the attachment element 21 when creating the fragment. 22 * html/HTMLAttachmentElement.cpp: 23 (WebCore::HTMLAttachmentElement::file): Added const to file() to 24 use it in appendCustonAttributes where the element is a const reference. 25 * html/HTMLAttachmentElement.h: 26 * html/HTMLAttributeNames.in: 27 1 28 2015-02-27 Timothy Horton <timothy_horton@apple.com> 2 29 -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm
r179364 r180785 38 38 #import "Element.h" 39 39 #import "ElementTraversal.h" 40 #import "File.h" 40 41 #import "FontCascade.h" 41 42 #import "Frame.h" 42 43 #import "FrameLoader.h" 44 #import "HTMLAttachmentElement.h" 43 45 #import "HTMLElement.h" 44 46 #import "HTMLFrameElementBase.h" … … 1962 1964 _addTableForElement(nil); 1963 1965 _addTableCellForElement(&element); 1966 #if ENABLE(ATTACHMENT_ELEMENT) 1967 } else if (is<HTMLAttachmentElement>(element)) { 1968 HTMLAttachmentElement& attachment = downcast<HTMLAttachmentElement>(element); 1969 if (attachment.file()) { 1970 NSURL *url = [NSURL fileURLWithPath:attachment.file()->path()]; 1971 if (url) 1972 _addAttachmentForElement(element, url, isBlockLevel, NO); 1973 } 1974 retval = NO; 1975 #endif 1964 1976 } else if (element.hasTagName(imgTag)) { 1965 1977 NSString *urlString = element.getAttribute(srcAttr); -
trunk/Source/WebCore/editing/markup.cpp
r179143 r180785 42 42 #include "ExceptionCode.h" 43 43 #include "ExceptionCodePlaceholder.h" 44 #include "File.h" 44 45 #include "Frame.h" 46 #include "HTMLAttachmentElement.h" 45 47 #include "HTMLBodyElement.h" 46 48 #include "HTMLDivElement.h" … … 52 54 #include "URL.h" 53 55 #include "MarkupAccumulator.h" 56 #include "NodeList.h" 54 57 #include "Range.h" 55 58 #include "RenderBlock.h" … … 136 139 137 140 void appendElement(StringBuilder& out, const Element&, bool addDisplayInline, RangeFullySelectsNode); 141 virtual void appendCustomAttributes(StringBuilder&, const Element&, Namespaces*) override; 138 142 139 143 virtual void appendText(StringBuilder& out, const Text&) override; … … 293 297 } 294 298 299 void StyledMarkupAccumulator::appendCustomAttributes(StringBuilder& out, const Element&element, Namespaces* namespaces) 300 { 301 #if ENABLE(ATTACHMENT_ELEMENT) 302 if (!is<HTMLAttachmentElement>(element)) 303 return; 304 305 const HTMLAttachmentElement& attachment = downcast<HTMLAttachmentElement>(element); 306 if (attachment.file()) 307 appendAttribute(out, element, Attribute(webkitattachmentpathAttr, attachment.file()->path()), namespaces); 308 #else 309 UNUSED_PARAM(out); 310 UNUSED_PARAM(element); 311 UNUSED_PARAM(namespaces); 312 #endif 313 } 314 295 315 void StyledMarkupAccumulator::appendElement(StringBuilder& out, const Element& element, bool addDisplayInline, RangeFullySelectsNode rangeFullySelectsNode) 296 316 { 297 317 const bool documentIsHTML = element.document().isHTMLDocument(); 298 318 appendOpenTag(out, element, 0); 319 320 appendCustomAttributes(out, element, nullptr); 299 321 300 322 const bool shouldAnnotateOrForceInline = element.isHTMLElement() && (shouldAnnotate() || addDisplayInline); … … 659 681 fragment->parseHTML(markup, fakeBody.get(), parserContentPolicy); 660 682 683 #if ENABLE(ATTACHMENT_ELEMENT) 684 // When creating a fragment we must strip the webkit-attachment-path attribute after restoring the File object. 685 RefPtr<NodeList> nodes = fragment->getElementsByTagName("attachment"); 686 for (size_t i = 0; i < nodes->length(); ++i) { 687 if (!is<HTMLAttachmentElement>(*nodes->item(i))) 688 continue; 689 HTMLAttachmentElement& element = downcast<HTMLAttachmentElement>(*nodes->item(i)); 690 element.setFile(File::create(element.fastGetAttribute(webkitattachmentpathAttr)).ptr()); 691 element.removeAttribute(webkitattachmentpathAttr); 692 } 693 #endif 661 694 if (!baseURL.isEmpty() && baseURL != blankURL() && baseURL != document.baseURL()) 662 695 completeURLs(fragment.get(), baseURL); -
trunk/Source/WebCore/html/HTMLAttachmentElement.cpp
r180720 r180785 57 57 } 58 58 59 File* HTMLAttachmentElement::file() 59 File* HTMLAttachmentElement::file() const 60 60 { 61 61 return m_file.get(); -
trunk/Source/WebCore/html/HTMLAttachmentElement.h
r180601 r180785 38 38 public: 39 39 static Ref<HTMLAttachmentElement> create(const QualifiedName&, Document&); 40 41 File* file() ;40 virtual bool canContainRangeEndPoint() const override { return false; } 41 File* file() const; 42 42 void setFile(File*); 43 43 -
trunk/Source/WebCore/html/HTMLAttributeNames.in
r177622 r180785 350 350 vspace 351 351 webkitallowfullscreen 352 webkitattachmentpath 352 353 width 353 354 wrap
Note: See TracChangeset
for help on using the changeset viewer.