Changeset 166145 in webkit
- Timestamp:
- Mar 23, 2014 2:41:17 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r166144 r166145 1 2014-03-23 Sam Weinig <sam@webkit.org> 2 3 Simplify the HTMLConverter interface (Part 2) 4 https://bugs.webkit.org/show_bug.cgi?id=130654 5 6 Reviewed by Darin Adler. 7 8 Switch HTMLConverter from using an Objective-C interface to C functions. 9 10 * WebCore.exp.in: 11 * editing/ios/EditorIOS.mm: 12 (WebCore::Editor::writeSelectionToPasteboard): 13 * editing/mac/EditorMac.mm: 14 (WebCore::Editor::dataSelectionForPasteboard): 15 (WebCore::Editor::writeSelectionToPasteboard): 16 * platform/ios/PasteboardIOS.mm: 17 * platform/mac/HTMLConverter.h: 18 * platform/mac/HTMLConverter.mm: 19 (WebCore::attributedStringFromRange): 20 (WebCore::editingAttributedStringFromRange): 21 * platform/mac/PasteboardMac.mm: 22 1 23 2014-03-23 Darin Adler <darin@apple.com> 2 24 -
trunk/Source/WebCore/WebCore.exp.in
r166110 r166145 2110 2110 .objc_class_name_WebCoreFullScreenWindow 2111 2111 .objc_class_name_WebFontCache 2112 .objc_class_name_WebHTMLConverter2113 2112 .objc_class_name_WebWindowFadeAnimation 2114 2113 .objc_class_name_WebWindowScaleAnimation … … 2196 2195 __ZN7WebCore32contextMenuItemTagInspectElementEv 2197 2196 __ZN7WebCore32contextMenuItemTagSmartCopyPasteEv 2197 __ZN7WebCore32editingAttributedStringFromRangeERNS_5RangeE 2198 2198 __ZN7WebCore32useBlockedPlugInContextMenuTitleEv 2199 2199 __ZN7WebCore33contextMenuItemTagTextReplacementEv -
trunk/Source/WebCore/editing/ios/EditorIOS.mm
r166143 r166145 298 298 } 299 299 300 // FIXME: the following fuctions should be shared between Mac and iOS.301 static NSAttributedString *attributedStringForRange(Range& range)302 {303 return [WebHTMLConverter attributedStringFromRange:&range];304 }305 306 300 static PassRefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string) 307 301 { … … 331 325 void Editor::writeSelectionToPasteboard(Pasteboard& pasteboard) 332 326 { 333 NSAttributedString *attributedString = attributedStringF orRange(*selectedRange());327 NSAttributedString *attributedString = attributedStringFromRange(selectedRange()); 334 328 335 329 PasteboardWebContent content; -
trunk/Source/WebCore/editing/mac/EditorMac.mm
r166143 r166145 304 304 return range; 305 305 } 306 307 static NSAttributedString *attributedStringForRange(Range& range) 308 { 309 return [WebHTMLConverter attributedStringFromRange:&range]; 310 } 311 306 312 307 static PassRefPtr<SharedBuffer> dataInRTFDFormat(NSAttributedString *string) 313 308 { … … 336 331 337 332 if (pasteboardType == String(NSRTFDPboardType)) 338 return dataInRTFDFormat(attributedStringF orRange(*adjustedSelectionRange()));333 return dataInRTFDFormat(attributedStringFromRange(*adjustedSelectionRange())); 339 334 340 335 if (pasteboardType == String(NSRTFPboardType)) { 341 NSAttributedString* attributedString = attributedStringF orRange(*adjustedSelectionRange());336 NSAttributedString* attributedString = attributedStringFromRange(*adjustedSelectionRange()); 342 337 // FIXME: Why is this attachment character stripping needed here, but not needed in writeSelectionToPasteboard? 343 338 if ([attributedString containsAttachments]) … … 351 346 void Editor::writeSelectionToPasteboard(Pasteboard& pasteboard) 352 347 { 353 NSAttributedString *attributedString = attributedStringF orRange(*selectedRange());348 NSAttributedString *attributedString = attributedStringFromRange(*selectedRange()); 354 349 355 350 PasteboardWebContent content; -
trunk/Source/WebCore/platform/ios/PasteboardIOS.mm
r162997 r166145 36 36 #import "FrameLoader.h" 37 37 #import "FrameLoaderClient.h" 38 #import "HTMLConverter.h"39 38 #import "HTMLElement.h" 40 39 #import "HTMLNames.h" -
trunk/Source/WebCore/platform/mac/HTMLConverter.h
r166143 r166145 24 24 */ 25 25 26 @class DOMDocument; 27 @class DOMRange; 26 #ifndef HTMLConverter_h 27 #define HTMLConverter_h 28 29 OBJC_CLASS NSAttributedString; 28 30 29 31 namespace WebCore { 30 class DocumentLoader; 31 class Range; 32 33 class Range; 34 35 NSAttributedString *attributedStringFromRange(Range&); 36 #if !PLATFORM(IOS) 37 NSAttributedString *editingAttributedStringFromRange(Range&); 38 #endif 39 32 40 } 33 41 34 class HTMLConverterCaches; 35 36 @interface WebHTMLConverter : NSObject { 37 NSMutableAttributedString *_attrStr; 38 NSMutableDictionary *_documentAttrs; 39 NSURL *_baseURL; 40 DOMDocument *_document; 41 DOMRange *_domRange; 42 NSMutableArray *_domStartAncestors; 43 WebCore::DocumentLoader *_dataSource; 44 NSString *_standardFontFamily; 45 CGFloat _textSizeMultiplier; 46 CGFloat _webViewTextSizeMultiplier; 47 CGFloat _defaultTabInterval; 48 CGFloat _defaultFontSize; 49 CGFloat _minimumFontSize; 50 NSMutableArray *_textLists; 51 NSMutableArray *_textBlocks; 52 NSMutableArray *_textTables; 53 NSMutableDictionary *_textTableFooters; 54 NSMutableArray *_textTableSpacings; 55 NSMutableArray *_textTablePaddings; 56 NSMutableArray *_textTableRows; 57 NSMutableArray *_textTableRowArrays; 58 NSMutableArray *_textTableRowBackgroundColors; 59 NSMutableDictionary *_colorsForNodes; 60 NSMutableDictionary *_attributesForElements; 61 NSMutableDictionary *_fontCache; 62 NSMutableArray *_writingDirectionArray; 63 NSUInteger _domRangeStartIndex; 64 NSInteger _indexingLimit; 65 NSUInteger _thumbnailLimit; 66 NSInteger _errorCode; 67 NSInteger _quoteLevel; 68 69 std::unique_ptr<HTMLConverterCaches> _caches; 70 71 struct { 72 unsigned int isSoft:1; 73 unsigned int reachedStart:1; 74 unsigned int reachedEnd:1; 75 unsigned int isIndexing:1; 76 unsigned int isTesting:1; 77 unsigned int hasTrailingNewline:1; 78 unsigned int pad:26; 79 } _flags; 80 } 81 82 83 + (NSAttributedString *)attributedStringFromRange:(WebCore::Range*)range; 84 #if !PLATFORM(IOS) 85 + (NSAttributedString *)editingAttributedStringFromRange:(WebCore::Range*)range; 86 #endif 87 @end 88 42 #endif // HTMLConverter_h -
trunk/Source/WebCore/platform/mac/HTMLConverter.mm
r166143 r166145 427 427 @interface NSObject(WebMessageDocumentSimulation) 428 428 + (void)document:(NSObject **)outDocument attachment:(NSTextAttachment **)outAttachment forURL:(NSURL *)url; 429 @end 430 431 @interface WebHTMLConverter : NSObject { 432 NSMutableAttributedString *_attrStr; 433 NSMutableDictionary *_documentAttrs; 434 NSURL *_baseURL; 435 DOMDocument *_document; 436 DOMRange *_domRange; 437 NSMutableArray *_domStartAncestors; 438 WebCore::DocumentLoader *_dataSource; 439 NSString *_standardFontFamily; 440 CGFloat _textSizeMultiplier; 441 CGFloat _webViewTextSizeMultiplier; 442 CGFloat _defaultTabInterval; 443 CGFloat _defaultFontSize; 444 CGFloat _minimumFontSize; 445 NSMutableArray *_textLists; 446 NSMutableArray *_textBlocks; 447 NSMutableArray *_textTables; 448 NSMutableDictionary *_textTableFooters; 449 NSMutableArray *_textTableSpacings; 450 NSMutableArray *_textTablePaddings; 451 NSMutableArray *_textTableRows; 452 NSMutableArray *_textTableRowArrays; 453 NSMutableArray *_textTableRowBackgroundColors; 454 NSMutableDictionary *_colorsForNodes; 455 NSMutableDictionary *_attributesForElements; 456 NSMutableDictionary *_fontCache; 457 NSMutableArray *_writingDirectionArray; 458 NSUInteger _domRangeStartIndex; 459 NSInteger _indexingLimit; 460 NSUInteger _thumbnailLimit; 461 NSInteger _errorCode; 462 NSInteger _quoteLevel; 463 464 std::unique_ptr<HTMLConverterCaches> _caches; 465 466 struct { 467 unsigned int isSoft:1; 468 unsigned int reachedStart:1; 469 unsigned int reachedEnd:1; 470 unsigned int isIndexing:1; 471 unsigned int isTesting:1; 472 unsigned int hasTrailingNewline:1; 473 unsigned int pad:26; 474 } _flags; 475 } 476 477 + (NSAttributedString *)attributedStringFromRange:(Range*)range; 478 #if !PLATFORM(IOS) 479 + (NSAttributedString *)editingAttributedStringFromRange:(Range*)range; 480 #endif 429 481 @end 430 482 … … 2579 2631 2580 2632 #endif 2633 2634 namespace WebCore { 2635 2636 NSAttributedString *attributedStringFromRange(Range& range) 2637 { 2638 return [WebHTMLConverter attributedStringFromRange:&range]; 2639 } 2640 2641 #if !PLATFORM(IOS) 2642 NSAttributedString *editingAttributedStringFromRange(Range& range) 2643 { 2644 return [WebHTMLConverter editingAttributedStringFromRange:&range]; 2645 } 2646 #endif 2647 2648 } -
trunk/Source/WebCore/platform/mac/PasteboardMac.mm
r165676 r166145 42 42 #import "HitTestResult.h" 43 43 #import "HTMLAnchorElement.h" 44 #import "HTMLConverter.h"45 44 #import "htmlediting.h" 46 45 #import "HTMLNames.h" -
trunk/Source/WebKit/mac/ChangeLog
r166144 r166145 1 2014-03-23 Sam Weinig <sam@webkit.org> 2 3 Simplify the HTMLConverter interface (Part 2) 4 https://bugs.webkit.org/show_bug.cgi?id=130654 5 6 Reviewed by Darin Adler. 7 8 * WebView/WebHTMLRepresentation.mm: 9 (-[WebHTMLRepresentation attributedStringFrom:startOffset:to:endOffset:]): 10 * WebView/WebHTMLView.mm: 11 (-[WebHTMLView attributedSubstringFromRange:]): 12 (-[WebHTMLView attributedString]): 13 (-[WebHTMLView selectedAttributedString]): 14 1 15 2014-03-23 Darin Adler <darin@apple.com> 2 16 -
trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm
r166047 r166145 278 278 - (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset 279 279 { 280 return [WebHTMLConverter editingAttributedStringFromRange:Range::create(core(startNode)->document(), core(startNode), startOffset, core(endNode), endOffset).get()];280 return editingAttributedStringFromRange(*Range::create(core(startNode)->document(), core(startNode), startOffset, core(endNode), endOffset).get()); 281 281 } 282 282 #endif -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r165676 r166145 6171 6171 } 6172 6172 6173 NSAttributedString *result = [WebHTMLConverter editingAttributedStringFromRange:range.get()];6174 6175 // [WebHTMLConverter editingAttributedStringFromRange:] insists on inserting a trailing6173 NSAttributedString *result = editingAttributedStringFromRange(*range); 6174 6175 // WebCore::editingAttributedStringFromRange() insists on inserting a trailing 6176 6176 // whitespace at the end of the string which breaks the ATOK input method. <rdar://problem/5400551> 6177 6177 // To work around this we truncate the resultant string to the correct length. … … 6643 6643 if (!attributedString) { 6644 6644 Document* coreDocument = core(document); 6645 attributedString = [WebHTMLConverter editingAttributedStringFromRange:Range::create(*coreDocument, coreDocument, 0, coreDocument, coreDocument->childNodeCount()).get()];6645 attributedString = editingAttributedStringFromRange(*Range::create(*coreDocument, coreDocument, 0, coreDocument, coreDocument->childNodeCount()).get()); 6646 6646 } 6647 6647 return attributedString; … … 6662 6662 if (coreFrame) { 6663 6663 RefPtr<Range> range = coreFrame->selection().selection().toNormalizedRange(); 6664 attributedString = [WebHTMLConverter editingAttributedStringFromRange:range.get()]; 6664 if (range) 6665 attributedString = editingAttributedStringFromRange(*range); 6666 else 6667 attributedString = [[[NSAttributedString alloc] init] autorelease]; 6665 6668 } 6666 6669 } -
trunk/Source/WebKit2/ChangeLog
r166140 r166145 1 2014-03-23 Sam Weinig <sam@webkit.org> 2 3 Simplify the HTMLConverter interface (Part 2) 4 https://bugs.webkit.org/show_bug.cgi?id=130654 5 6 Reviewed by Darin Adler. 7 8 * WebProcess/WebPage/WebPage.h: 9 * WebProcess/WebPage/ios/WebPageIOS.mm: 10 (WebKit::WebPage::performDictionaryLookupForRange): 11 * WebProcess/WebPage/mac/WebPageMac.mm: 12 (WebKit::WebPage::getAttributedSubstringFromRange): 13 (WebKit::WebPage::attributedSubstringForCharacterRangeAsync): 14 (WebKit::WebPage::performDictionaryLookupAtLocation): 15 (WebKit::WebPage::performDictionaryLookupForSelection): 16 (WebKit::WebPage::performDictionaryLookupForRange): 17 1 18 2014-03-23 David Kilzer <ddkilzer@apple.com> 2 19 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r166017 r166145 883 883 #if PLATFORM(COCOA) 884 884 void performDictionaryLookupAtLocation(const WebCore::FloatPoint&); 885 void performDictionaryLookupForRange(WebCore::Frame*, WebCore::Range *, NSDictionary *options);885 void performDictionaryLookupForRange(WebCore::Frame*, WebCore::Range&, NSDictionary *options); 886 886 887 887 void windowAndViewFramesChanged(const WebCore::FloatRect& windowFrameInScreenCoordinates, const WebCore::FloatRect& windowFrameInUnflippedScreenCoordinates, const WebCore::FloatRect& viewFrameInWindowCoordinates, const WebCore::FloatPoint& accessibilityViewCoordinates); -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r166110 r166145 172 172 } 173 173 174 void WebPage::performDictionaryLookupForRange(Frame*, Range *, NSDictionary *)174 void WebPage::performDictionaryLookupForRange(Frame*, Range&, NSDictionary *) 175 175 { 176 176 notImplemented(); -
trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
r166002 r166145 348 348 return; 349 349 350 result.string = [WebHTMLConverter editingAttributedStringFromRange:range.get()];350 result.string = editingAttributedStringFromRange(*range); 351 351 NSAttributedString* attributedString = result.string.get(); 352 352 353 // [WebHTMLConverter editingAttributedStringFromRange:] insists on inserting a trailing353 // WebCore::editingAttributedStringFromRange() insists on inserting a trailing 354 354 // whitespace at the end of the string which breaks the ATOK input method. <rdar://problem/5400551> 355 355 // To work around this we truncate the resultant string to the correct length. … … 442 442 } 443 443 444 result.string = [WebHTMLConverter editingAttributedStringFromRange:range.get()];444 result.string = editingAttributedStringFromRange(*range); 445 445 NSAttributedString* attributedString = result.string.get(); 446 446 447 // [WebHTMLConverter editingAttributedStringFromRange:] insists on inserting a trailing447 // WebCore::editingAttributedStringFromRange() insists on inserting a trailing 448 448 // whitespace at the end of the string which breaks the ATOK input method. <rdar://problem/5400551> 449 449 // To work around this we truncate the resultant string to the correct length. … … 553 553 return; 554 554 555 performDictionaryLookupForRange(frame, finalRange.get(), options);555 performDictionaryLookupForRange(frame, *finalRange, options); 556 556 } 557 557 … … 580 580 WKExtractWordDefinitionTokenRangeFromContextualString(fullPlainTextString, rangeToPass, &options); 581 581 582 performDictionaryLookupForRange(frame, selectedRange.get(), options);583 } 584 585 void WebPage::performDictionaryLookupForRange(Frame* frame, Range *range, NSDictionary *options)586 { 587 if (range ->text().stripWhiteSpace().isEmpty())588 return; 589 590 RenderObject* renderer = range ->startContainer()->renderer();582 performDictionaryLookupForRange(frame, *selectedRange, options); 583 } 584 585 void WebPage::performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options) 586 { 587 if (range.text().stripWhiteSpace().isEmpty()) 588 return; 589 590 RenderObject* renderer = range.startContainer()->renderer(); 591 591 const RenderStyle& style = renderer->style(); 592 592 593 593 Vector<FloatQuad> quads; 594 range ->textQuads(quads);594 range.textQuads(quads); 595 595 if (quads.isEmpty()) 596 596 return; … … 602 602 dictionaryPopupInfo.options = (CFDictionaryRef)options; 603 603 604 NSAttributedString *nsAttributedString = [WebHTMLConverter editingAttributedStringFromRange:range];604 NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range); 605 605 606 606 RetainPtr<NSMutableAttributedString> scaledNSAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[nsAttributedString string]]);
Note: See TracChangeset
for help on using the changeset viewer.