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

📄 framemac.mm

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 MM
📖 第 1 页 / 共 2 页
字号:
        NSImage* resultImage;    BEGIN_BLOCK_OBJC_EXCEPTIONS;        NSRect bounds = [view bounds];        // Round image rect size in window coordinate space to avoid pixel cracks at HiDPI (4622794)    rect = [view convertRect:rect toView:nil];    rect.size.height = roundf(rect.size.height);    rect.size.width = roundf(rect.size.width);    rect = [view convertRect:rect fromView:nil];        resultImage = [[[NSImage alloc] initWithSize:rect.size] autorelease];    if (rect.size.width != 0 && rect.size.height != 0) {        [resultImage setFlipped:YES];        [resultImage lockFocus];        CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];        CGContextSaveGState(context);        CGContextTranslateCTM(context, bounds.origin.x - rect.origin.x, bounds.origin.y - rect.origin.y);        // Note: Must not call drawRect: here, because drawRect: assumes that it's called from AppKit's        // display machinery. It calls getRectsBeingDrawn:count:, which can only be called inside        // when a real AppKit display is underway.        [view drawSingleRect:rect];        CGContextRestoreGState(context);        [resultImage unlockFocus];        [resultImage setFlipped:NO];    }    return resultImage;    END_BLOCK_OBJC_EXCEPTIONS;        return nil;}NSImage* Frame::selectionImage(bool forceBlackText) const{    m_view->setPaintRestriction(forceBlackText ? PaintRestrictionSelectionOnlyBlackText : PaintRestrictionSelectionOnly);    m_doc->updateLayout();    NSImage* result = imageFromRect(selectionBounds());    m_view->setPaintRestriction(PaintRestrictionNone);    return result;}NSImage* Frame::snapshotDragImage(Node* node, NSRect* imageRect, NSRect* elementRect) const{    RenderObject* renderer = node->renderer();    if (!renderer)        return nil;        renderer->updateDragState(true);    // mark dragged nodes (so they pick up the right CSS)    m_doc->updateLayout();        // forces style recalc - needed since changing the drag state might                                        // imply new styles, plus JS could have changed other things    IntRect topLevelRect;    NSRect paintingRect = renderer->paintingRootRect(topLevelRect);    m_view->setNodeToDraw(node);              // invoke special sub-tree drawing mode    NSImage* result = imageFromRect(paintingRect);    renderer->updateDragState(false);    m_doc->updateLayout();    m_view->setNodeToDraw(0);    if (elementRect)        *elementRect = topLevelRect;    if (imageRect)        *imageRect = paintingRect;    return result;}NSImage* Frame::nodeImage(Node* node) const{    RenderObject* renderer = node->renderer();    if (!renderer)        return nil;    m_doc->updateLayout(); // forces style recalc    IntRect topLevelRect;    NSRect paintingRect = renderer->paintingRootRect(topLevelRect);    m_view->setNodeToDraw(node); // invoke special sub-tree drawing mode    NSImage* result = imageFromRect(paintingRect);    m_view->setNodeToDraw(0);    return result;}NSDictionary* Frame::fontAttributesForSelectionStart() const{    Node* nodeToRemove;    RenderStyle* style = styleForSelectionStart(nodeToRemove);    if (!style)        return nil;    NSMutableDictionary* result = [NSMutableDictionary dictionary];    if (style->backgroundColor().isValid() && style->backgroundColor().alpha() != 0)        [result setObject:nsColor(style->backgroundColor()) forKey:NSBackgroundColorAttributeName];    if (style->font().primaryFont()->getNSFont())        [result setObject:style->font().primaryFont()->getNSFont() forKey:NSFontAttributeName];    if (style->color().isValid() && style->color() != Color::black)        [result setObject:nsColor(style->color()) forKey:NSForegroundColorAttributeName];    ShadowData* shadow = style->textShadow();    if (shadow) {        NSShadow* s = [[NSShadow alloc] init];        [s setShadowOffset:NSMakeSize(shadow->x, shadow->y)];        [s setShadowBlurRadius:shadow->blur];        [s setShadowColor:nsColor(shadow->color)];        [result setObject:s forKey:NSShadowAttributeName];    }    int decoration = style->textDecorationsInEffect();    if (decoration & LINE_THROUGH)        [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];    int superscriptInt = 0;    switch (style->verticalAlign()) {        case BASELINE:        case BOTTOM:        case BASELINE_MIDDLE:        case LENGTH:        case MIDDLE:        case TEXT_BOTTOM:        case TEXT_TOP:        case TOP:            break;        case SUB:            superscriptInt = -1;            break;        case SUPER:            superscriptInt = 1;            break;    }    if (superscriptInt)        [result setObject:[NSNumber numberWithInt:superscriptInt] forKey:NSSuperscriptAttributeName];    if (decoration & UNDERLINE)        [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];    if (nodeToRemove) {        ExceptionCode ec = 0;        nodeToRemove->remove(ec);        ASSERT(ec == 0);    }    return result;}NSWritingDirection Frame::baseWritingDirectionForSelectionStart() const{    NSWritingDirection result = NSWritingDirectionLeftToRight;    Position pos = selection()->selection().visibleStart().deepEquivalent();    Node* node = pos.node();    if (!node)        return result;    RenderObject* renderer = node->renderer();    if (!renderer)        return result;    if (!renderer->isBlockFlow()) {        renderer = renderer->containingBlock();        if (!renderer)            return result;    }    RenderStyle* style = renderer->style();    if (!style)        return result;            switch (style->direction()) {        case LTR:            result = NSWritingDirectionLeftToRight;            break;        case RTL:            result = NSWritingDirectionRightToLeft;            break;    }    return result;}const short enableRomanKeyboardsOnly = -23;void Frame::setUseSecureKeyboardEntry(bool enable){    if (enable == IsSecureEventInputEnabled())        return;    if (enable) {        EnableSecureEventInput();#ifdef BUILDING_ON_TIGER        KeyScript(enableRomanKeyboardsOnly);#else        CFArrayRef inputSources = TISCreateASCIICapableInputSourceList();        TSMSetDocumentProperty(TSMGetActiveDocument(), kTSMDocumentEnabledInputSourcesPropertyTag, sizeof(CFArrayRef), &inputSources);        CFRelease(inputSources);#endif    } else {        DisableSecureEventInput();#ifdef BUILDING_ON_TIGER        KeyScript(smKeyEnableKybds);#else        TSMRemoveDocumentProperty(TSMGetActiveDocument(), kTSMDocumentEnabledInputSourcesPropertyTag);#endif    }}#if ENABLE(DASHBOARD_SUPPORT)NSMutableDictionary* Frame::dashboardRegionsDictionary(){    Document* doc = document();    const Vector<DashboardRegionValue>& regions = doc->dashboardRegions();    size_t n = regions.size();    // Convert the Vector<DashboardRegionValue> into a NSDictionary of WebDashboardRegions    NSMutableDictionary* webRegions = [NSMutableDictionary dictionaryWithCapacity:n];    for (size_t i = 0; i < n; i++) {        const DashboardRegionValue& region = regions[i];        if (region.type == StyleDashboardRegion::None)            continue;                NSString *label = region.label;        WebDashboardRegionType type = WebDashboardRegionTypeNone;        if (region.type == StyleDashboardRegion::Circle)            type = WebDashboardRegionTypeCircle;        else if (region.type == StyleDashboardRegion::Rectangle)            type = WebDashboardRegionTypeRectangle;        NSMutableArray *regionValues = [webRegions objectForKey:label];        if (!regionValues) {            regionValues = [[NSMutableArray alloc] initWithCapacity:1];            [webRegions setObject:regionValues forKey:label];            [regionValues release];        }                WebDashboardRegion *webRegion = [[WebDashboardRegion alloc] initWithRect:region.bounds clip:region.clip type:type];        [regionValues addObject:webRegion];        [webRegion release];    }        return webRegions;}#endifDragImageRef Frame::dragImageForSelection() {    if (!selection()->isRange())        return nil;    return selectionImage();}void Frame::setUserStyleSheetLocation(const KURL& url){    delete m_userStyleSheetLoader;    m_userStyleSheetLoader = 0;    if (m_doc->docLoader())        m_userStyleSheetLoader = new UserStyleSheetLoader(m_doc, url.string());}void Frame::setUserStyleSheet(const String& styleSheet){    delete m_userStyleSheetLoader;    m_userStyleSheetLoader = 0;    m_doc->setUserStyleSheet(styleSheet);}} // namespace WebCore

⌨️ 快捷键说明

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