Changeset 242831 in webkit
- Timestamp:
- Mar 12, 2019 3:42:49 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242830 r242831 1 2019-03-12 Timothy Hatcher <timothy@apple.com> 2 3 Expose document attributes and body background color through HTMLConverter. 4 https://bugs.webkit.org/show_bug.cgi?id=195636 5 rdar://problem/45055697 6 7 Reviewed by Tim Horton. 8 9 * editing/cocoa/HTMLConverter.h: 10 * editing/cocoa/HTMLConverter.mm: 11 (HTMLConverter::convert): 12 (WebCore::attributedStringFromRange): 13 (WebCore::attributedStringFromSelection): 14 (WebCore::attributedStringBetweenStartAndEnd): 15 1 16 2019-03-12 Antti Koivisto <antti@apple.com> 2 17 -
trunk/Source/WebCore/PAL/ChangeLog
r242801 r242831 1 2019-03-12 Timothy Hatcher <timothy@apple.com> 2 3 Expose document attributes and body background color through HTMLConverter. 4 https://bugs.webkit.org/show_bug.cgi?id=195636 5 rdar://problem/45055697 6 7 Reviewed by Tim Horton. 8 9 * pal/spi/cocoa/NSAttributedStringSPI.h: 10 (NSBackgroundColorDocumentAttribute): Added. 11 1 12 2019-03-12 Jennifer Moore <jennifer.moore@apple.com> 2 13 -
trunk/Source/WebCore/PAL/pal/spi/cocoa/NSAttributedStringSPI.h
r237266 r242831 92 92 SOFT_LINK_CONSTANT(UIFoundation, NSCocoaVersionDocumentAttribute, NSString *) 93 93 #define NSCocoaVersionDocumentAttribute getNSCocoaVersionDocumentAttribute() 94 SOFT_LINK_CONSTANT(UIFoundation, NSBackgroundColorDocumentAttribute, NSString *) 95 #define NSBackgroundColorDocumentAttribute getNSBackgroundColorDocumentAttribute() 94 96 95 97 // We don't softlink NSSuperscriptAttributeName because UIFoundation stopped exporting it. -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.h
r239149 r242831 36 36 enum class IncludeImagesInAttributedString { Yes, No }; 37 37 38 NSAttributedString *attributedStringFromSelection(const VisibleSelection& );38 NSAttributedString *attributedStringFromSelection(const VisibleSelection&, NSDictionary** documentAttributes = nullptr); 39 39 40 40 // For testing purpose only 41 WEBCORE_EXPORT NSAttributedString *attributedStringBetweenStartAndEnd(const Position&, const Position& );41 WEBCORE_EXPORT NSAttributedString *attributedStringBetweenStartAndEnd(const Position&, const Position&, NSDictionary** documentAttributes = nullptr); 42 42 43 WEBCORE_EXPORT NSAttributedString *attributedStringFromRange(Range& );43 WEBCORE_EXPORT NSAttributedString *attributedStringFromRange(Range&, NSDictionary** documentAttributes = nullptr); 44 44 #if !PLATFORM(IOS_FAMILY) 45 45 WEBCORE_EXPORT NSAttributedString *editingAttributedStringFromRange(Range&, IncludeImagesInAttributedString = IncludeImagesInAttributedString::Yes); -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm
r241183 r242831 277 277 HTMLConverter(const Position&, const Position&); 278 278 ~HTMLConverter(); 279 280 NSAttributedString* convert( );281 279 280 NSAttributedString* convert(NSDictionary** documentAttributes = nullptr); 281 282 282 private: 283 283 Position m_start; … … 397 397 } 398 398 399 NSAttributedString *HTMLConverter::convert( )399 NSAttributedString *HTMLConverter::convert(NSDictionary** documentAttributes) 400 400 { 401 401 if (comparePositions(m_start, m_end) > 0) … … 408 408 if (!m_dataSource) 409 409 return nil; 410 411 Document& document = commonAncestorContainer->document(); 412 if (auto* body = document.bodyOrFrameset()) { 413 if (PlatformColor *backgroundColor = _colorForElement(*body, CSSPropertyBackgroundColor)) 414 [_documentAttrs setObject:backgroundColor forKey:NSBackgroundColorDocumentAttribute]; 415 } 410 416 411 417 _domRangeStartIndex = 0; … … 413 419 if (_domRangeStartIndex > 0 && _domRangeStartIndex <= [_attrStr length]) 414 420 [_attrStr deleteCharactersInRange:NSMakeRange(0, _domRangeStartIndex)]; 421 422 if (documentAttributes) 423 *documentAttributes = [[_documentAttrs retain] autorelease]; 415 424 416 425 return [[_attrStr retain] autorelease]; … … 2376 2385 2377 2386 namespace WebCore { 2378 2387 2379 2388 // This function supports more HTML features than the editing variant below, such as tables. 2380 NSAttributedString *attributedStringFromRange(Range& range )2381 { 2382 return HTMLConverter { range.startPosition(), range.endPosition() }.convert( );2383 } 2384 2385 NSAttributedString *attributedStringFromSelection(const VisibleSelection& selection )2386 { 2387 return attributedStringBetweenStartAndEnd(selection.start(), selection.end() );2388 } 2389 2390 NSAttributedString *attributedStringBetweenStartAndEnd(const Position& start, const Position& end )2391 { 2392 return HTMLConverter { start, end }.convert( );2393 } 2394 2389 NSAttributedString *attributedStringFromRange(Range& range, NSDictionary** documentAttributes) 2390 { 2391 return HTMLConverter { range.startPosition(), range.endPosition() }.convert(documentAttributes); 2392 } 2393 2394 NSAttributedString *attributedStringFromSelection(const VisibleSelection& selection, NSDictionary** documentAttributes) 2395 { 2396 return attributedStringBetweenStartAndEnd(selection.start(), selection.end(), documentAttributes); 2397 } 2398 2399 NSAttributedString *attributedStringBetweenStartAndEnd(const Position& start, const Position& end, NSDictionary** documentAttributes) 2400 { 2401 return HTMLConverter { start, end }.convert(documentAttributes); 2402 } 2403 2395 2404 #if !PLATFORM(IOS_FAMILY) 2396 2405
Note: See TracChangeset
for help on using the changeset viewer.