⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webhtmlview.mm

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 MM
📖 第 1 页 / 共 5 页
字号:
- (DOMCSSStyleDeclaration *)_emptyStyle;- (NSString *)_colorAsString:(NSColor *)color;@end@interface NSView (WebHTMLViewFileInternal)- (void)_web_addDescendantWebHTMLViewsToArray:(NSMutableArray *) array;@end@interface NSMutableDictionary (WebHTMLViewFileInternal)- (void)_web_setObjectIfNotNil:(id)object forKey:(id)key;@end// Handles the complete: text command@interface WebTextCompleteController : NSObject <NSTableViewDelegate, NSTableViewDataSource> {@private    WebHTMLView *_view;    NSWindow *_popupWindow;    NSTableView *_tableView;    NSArray *_completions;    NSString *_originalString;    int prefixLength;}- (id)initWithHTMLView:(WebHTMLView *)view;- (void)doCompletion;- (void)endRevertingChange:(BOOL)revertChange moveLeft:(BOOL)goLeft;- (BOOL)popupWindowIsOpen;- (BOOL)filterKeyDown:(NSEvent *)event;- (void)_reflectSelection;@endstruct WebHTMLViewInterpretKeyEventsParameters {    KeyboardEvent* event;    BOOL eventWasHandled;    BOOL shouldSaveCommand;    // The Input Method may consume an event and not tell us, in    // which case we should not bubble the event up the DOM    BOOL consumedByIM;};@interface WebHTMLViewPrivate : NSObject {@public    BOOL closed;    BOOL needsLayout;    BOOL needsToApplyStyles;    BOOL ignoringMouseDraggedEvents;    BOOL printing;    BOOL avoidingPrintOrphan;    BOOL observingMouseMovedNotifications;    BOOL observingSuperviewNotifications;    BOOL observingWindowNotifications;    BOOL resigningFirstResponder;        id savedSubviews;    BOOL subviewsSetAside;    #if USE(ACCELERATED_COMPOSITING)    NSView *layerHostingView;#endif    NSEvent *mouseDownEvent; // Kept after handling the event.    BOOL handlingMouseDownEvent;    NSEvent *keyDownEvent; // Kept after handling the event.        NSSize lastLayoutSize;    NSPoint lastScrollPosition;    WebPluginController *pluginController;        NSString *toolTip;    NSToolTipTag lastToolTipTag;    id trackingRectOwner;    void *trackingRectUserData;        NSTimer *autoscrollTimer;    NSEvent *autoscrollTriggerEvent;        NSArray *pageRects;    NSMutableDictionary *highlighters;#ifdef BUILDING_ON_TIGER    BOOL nextResponderDisabledOnce;#endif        WebTextCompleteController *compController;        BOOL transparentBackground;    WebHTMLViewInterpretKeyEventsParameters* interpretKeyEventsParameters;    BOOL receivedNOOP;        WebDataSource *dataSource;    WebCore::CachedImage* promisedDragTIFFDataSource;        CFRunLoopTimerRef updateFocusedAndActiveStateTimer;    CFRunLoopTimerRef updateMouseoverTimer;    SEL selectorForDoCommandBySelector;#ifndef NDEBUG    BOOL enumeratingSubviews;#endif}- (void)clear;@endstatic NSCellStateValue kit(TriState state){    switch (state) {        case FalseTriState:            return NSOffState;        case TrueTriState:            return NSOnState;        case MixedTriState:            return NSMixedState;    }    ASSERT_NOT_REACHED();    return NSOffState;}@implementation WebHTMLViewPrivate+ (void)initialize{    JSC::initializeThreading();#ifndef BUILDING_ON_TIGER    WebCoreObjCFinalizeOnMainThread(self);#endif    if (!oldSetCursorIMP) {#ifdef BUILDING_ON_TIGER        Method setCursorMethod = class_getInstanceMethod([NSCursor class], @selector(set));#else        Method setCursorMethod = class_getInstanceMethod([NSWindow class], @selector(_setCursorForMouseLocation:));#endif        ASSERT(setCursorMethod);        oldSetCursorIMP = method_setImplementation(setCursorMethod, (IMP)setCursor);        ASSERT(oldSetCursorIMP);    }    #ifdef BUILDING_ON_TIGER    if (!oldResetCursorRectsIMP) {        Method resetCursorRectsMethod = class_getInstanceMethod([NSWindow class], @selector(resetCursorRects));        ASSERT(resetCursorRectsMethod);        oldResetCursorRectsIMP = method_setImplementation(resetCursorRectsMethod, (IMP)resetCursorRects);        ASSERT(oldResetCursorRectsIMP);    }#endif}- (void)dealloc{    if (WebCoreObjCScheduleDeallocateOnMainThread([WebHTMLViewPrivate class], self))        return;    ASSERT(!autoscrollTimer);    ASSERT(!autoscrollTriggerEvent);    ASSERT(!updateFocusedAndActiveStateTimer);    ASSERT(!updateMouseoverTimer);        [mouseDownEvent release];    [keyDownEvent release];    [pluginController release];    [toolTip release];    [compController release];    [dataSource release];    [highlighters release];    if (promisedDragTIFFDataSource)        promisedDragTIFFDataSource->removeClient(promisedDataClient());    [super dealloc];}- (void)finalize{    ASSERT_MAIN_THREAD();    if (promisedDragTIFFDataSource)        promisedDragTIFFDataSource->removeClient(promisedDataClient());    [super finalize];}- (void)clear{    [mouseDownEvent release];    [keyDownEvent release];    [pluginController release];    [toolTip release];    [compController release];    [dataSource release];    [highlighters release];    if (promisedDragTIFFDataSource)        promisedDragTIFFDataSource->removeClient(promisedDataClient());    mouseDownEvent = nil;    keyDownEvent = nil;    pluginController = nil;    toolTip = nil;    compController = nil;    dataSource = nil;    highlighters = nil;    promisedDragTIFFDataSource = 0;#if USE(ACCELERATED_COMPOSITING)    layerHostingView = nil;#endif}@end@implementation WebHTMLView (WebHTMLViewFileInternal)- (DOMRange *)_documentRange{    return [[[self _frame] DOMDocument] _documentRange];}- (BOOL)_imageExistsAtPaths:(NSArray *)paths{    NSEnumerator *enumerator = [paths objectEnumerator];    NSString *path;        while ((path = [enumerator nextObject]) != nil) {        NSString *MIMEType = WKGetMIMETypeForExtension([path pathExtension]);        if (MIMETypeRegistry::isSupportedImageResourceMIMEType(MIMEType))            return YES;    }        return NO;}- (WebDataSource *)_dataSource{    return _private->dataSource;}- (WebView *)_webView{    return [_private->dataSource _webView];}- (WebFrameView *)_frameView{    return [[_private->dataSource webFrame] frameView];}- (DOMDocumentFragment *)_documentFragmentWithPaths:(NSArray *)paths{    DOMDocumentFragment *fragment;    NSEnumerator *enumerator = [paths objectEnumerator];    NSMutableArray *domNodes = [[NSMutableArray alloc] init];    NSString *path;        while ((path = [enumerator nextObject]) != nil) {        // Non-image file types; _web_userVisibleString is appropriate here because this will        // be pasted as visible text.        NSString *url = [[[NSURL fileURLWithPath:path] _webkit_canonicalize] _web_userVisibleString];        [domNodes addObject:[[[self _frame] DOMDocument] createTextNode: url]];    }        fragment = [[self _frame] _documentFragmentWithNodesAsParagraphs:domNodes];         [domNodes release];        return [fragment firstChild] != nil ? fragment : nil;}+ (NSArray *)_excludedElementsForAttributedStringConversion{    static NSArray *elements = nil;    if (elements == nil) {        elements = [[NSArray alloc] initWithObjects:            // Omit style since we want style to be inline so the fragment can be easily inserted.            @"style",            // Omit xml so the result is not XHTML.            @"xml",             // Omit tags that will get stripped when converted to a fragment anyway.            @"doctype", @"html", @"head", @"body",            // Omit deprecated tags.            @"applet", @"basefont", @"center", @"dir", @"font", @"isindex", @"menu", @"s", @"strike", @"u",            // Omit object so no file attachments are part of the fragment.            @"object", nil];        CFRetain(elements);    }    return elements;}static NSURL* uniqueURLWithRelativePart(NSString *relativePart){    CFUUIDRef UUIDRef = CFUUIDCreate(kCFAllocatorDefault);    NSString *UUIDString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUIDRef);    CFRelease(UUIDRef);    NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/%@", WebDataProtocolScheme, UUIDString, relativePart]];    CFRelease(UUIDString);    return URL;}- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard                                               inContext:(DOMRange *)context                                          allowPlainText:(BOOL)allowPlainText{    NSArray *types = [pasteboard types];    DOMDocumentFragment *fragment = nil;    if ([types containsObject:WebArchivePboardType] &&        (fragment = [self _documentFragmentFromPasteboard:pasteboard                                                   forType:WebArchivePboardType                                                inContext:context                                             subresources:0]))        return fragment;                                               if ([types containsObject:NSFilenamesPboardType] &&        (fragment = [self _documentFragmentFromPasteboard:pasteboard                                                   forType:NSFilenamesPboardType                                                inContext:context                                             subresources:0]))        return fragment;        if ([types containsObject:NSHTMLPboardType] &&        (fragment = [self _documentFragmentFromPasteboard:pasteboard                                                   forType:NSHTMLPboardType                                                inContext:context                                             subresources:0]))        return fragment;        if ([types containsObject:NSRTFPboardType] &&        (fragment = [self _documentFragmentFromPasteboard:pasteboard                                                   forType:NSRTFPboardType                                                inContext:context                                             subresources:0]))        return fragment;    if ([types containsObject:NSRTFDPboardType] &&        (fragment = [self _documentFragmentFromPasteboard:pasteboard                                                   forType:NSRTFDPboardType                                                inContext:context                                             subresources:0]))        return fragment;    if ([types containsObject:NSTIFFPboardType] &&        (fragment = [self _documentFragmentFromPasteboard:pasteboard                                                   forType:NSTIFFPboardType

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -