HTMLConverter.h revision 2bde8e466a4451c7319e3a072d118917957d6554
1/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#import "DOM.h"
27#import "DOMDocument.h"
28#import "DOMRange.h"
29
30namespace WebCore {
31class DocumentLoader;
32}
33
34@interface WebHTMLConverter : NSObject {
35    NSMutableAttributedString *_attrStr;
36    NSURL *_baseURL;
37    DOMDocument *_document;
38    DOMRange *_domRange;
39    NSMutableArray *_domStartAncestors;
40    WebCore::DocumentLoader *_dataSource;
41    NSString *_standardFontFamily;
42    CGFloat _textSizeMultiplier;
43    CGFloat _webViewTextSizeMultiplier;
44    CGFloat _defaultTabInterval;
45    CGFloat _defaultFontSize;
46    CGFloat _minimumFontSize;
47    NSMutableArray *_textLists;
48    NSMutableArray *_textBlocks;
49    NSMutableArray *_textTables;
50    NSMutableDictionary *_textTableFooters;
51    NSMutableArray *_textTableSpacings;
52    NSMutableArray *_textTablePaddings;
53    NSMutableArray *_textTableRows;
54    NSMutableArray *_textTableRowArrays;
55    NSMutableArray *_textTableRowBackgroundColors;
56    NSMutableDictionary *_computedStylesForElements;
57    NSMutableDictionary *_specifiedStylesForElements;
58    NSMutableDictionary *_stringsForNodes;
59    NSMutableDictionary *_floatsForNodes;
60    NSMutableDictionary *_colorsForNodes;
61    NSMutableDictionary *_attributesForElements;
62    NSMutableDictionary *_elementIsBlockLevel;
63    NSMutableDictionary *_fontCache;
64    NSMutableArray *_writingDirectionArray;
65    NSUInteger _domRangeStartIndex;
66    NSInteger _indexingLimit;
67    NSUInteger _thumbnailLimit;
68    NSInteger _errorCode;
69    NSInteger _quoteLevel;
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- (id)init;
83- (id)initWithDOMRange:(DOMRange *)domRange;
84
85- (NSAttributedString *)attributedString;
86
87@end
88
89