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

📄 resource.js

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 JS
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (C) 2007, 2008 Apple Inc.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1.  Redistributions of source code must retain the above copyright *     notice, this list of conditions and the following disclaimer.  * 2.  Redistributions in binary form must reproduce the above copyright *     notice, this list of conditions and the following disclaimer in the *     documentation and/or other materials provided with the distribution.  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of *     its contributors may be used to endorse or promote products derived *     from this software without specific prior written permission.  * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */WebInspector.Resource = function(requestHeaders, url, domain, path, lastPathComponent, identifier, mainResource, cached){    this.identifier = identifier;    this.startTime = -1;    this.endTime = -1;    this.mainResource = mainResource;    this.requestHeaders = requestHeaders;    this.url = url;    this.domain = domain;    this.path = path;    this.lastPathComponent = lastPathComponent;    this.cached = cached;    this.category = WebInspector.resourceCategories.other;}// Keep these in sync with WebCore::InspectorResource::TypeWebInspector.Resource.Type = {    Document:   0,    Stylesheet: 1,    Image:      2,    Font:       3,    Script:     4,    XHR:        5,    Other:      6,    isTextType: function(type)    {        return (type === this.Document) || (type === this.Stylesheet) || (type === this.Script) || (type === this.XHR);    },    toString: function(type)    {        switch (type) {            case this.Document:                return WebInspector.UIString("document");            case this.Stylesheet:                return WebInspector.UIString("stylesheet");            case this.Image:                return WebInspector.UIString("image");            case this.Font:                return WebInspector.UIString("font");            case this.Script:                return WebInspector.UIString("script");            case this.XHR:                return WebInspector.UIString("XHR");            case this.Other:            default:                return WebInspector.UIString("other");        }    }}WebInspector.Resource.prototype = {    get url()    {        return this._url;    },    set url(x)    {        if (this._url === x)            return;        var oldURL = this._url;        this._url = x;        // FIXME: We should make the WebInspector object listen for the "url changed" event.        // Then resourceURLChanged can be removed.        WebInspector.resourceURLChanged(this, oldURL);        this.dispatchEventToListeners("url changed");    },    get domain()    {        return this._domain;    },    set domain(x)    {        if (this._domain === x)            return;        this._domain = x;    },    get lastPathComponent()    {        return this._lastPathComponent;    },    set lastPathComponent(x)    {        if (this._lastPathComponent === x)            return;        this._lastPathComponent = x;        this._lastPathComponentLowerCase = x ? x.toLowerCase() : null;    },    get displayName()    {        var title = this.lastPathComponent;        if (!title)            title = this.displayDomain;        if (!title && this.url)            title = this.url.trimURL(WebInspector.mainResource ? WebInspector.mainResource.domain : "");        if (title === "/")            title = this.url;        return title;    },    get displayDomain()    {        // WebInspector.Database calls this, so don't access more than this.domain.        if (this.domain && (!WebInspector.mainResource || (WebInspector.mainResource && this.domain !== WebInspector.mainResource.domain)))            return this.domain;        return "";    },    get startTime()    {        return this._startTime || -1;    },    set startTime(x)    {        if (this._startTime === x)            return;        this._startTime = x;        if (WebInspector.panels.resources)            WebInspector.panels.resources.refreshResource(this);    },    get responseReceivedTime()    {        return this._responseReceivedTime || -1;    },    set responseReceivedTime(x)    {        if (this._responseReceivedTime === x)            return;        this._responseReceivedTime = x;        if (WebInspector.panels.resources)            WebInspector.panels.resources.refreshResource(this);    },    get endTime()    {        return this._endTime || -1;    },    set endTime(x)    {        if (this._endTime === x)            return;        this._endTime = x;        if (WebInspector.panels.resources)            WebInspector.panels.resources.refreshResource(this);    },    get duration()    {        if (this._endTime === -1 || this._startTime === -1)            return -1;        return this._endTime - this._startTime;    },    get latency()    {        if (this._responseReceivedTime === -1 || this._startTime === -1)            return -1;        return this._responseReceivedTime - this._startTime;    },    get contentLength()    {        return this._contentLength || 0;    },    set contentLength(x)    {        if (this._contentLength === x)            return;        this._contentLength = x;        if (WebInspector.panels.resources)            WebInspector.panels.resources.refreshResource(this);    },    get expectedContentLength()    {        return this._expectedContentLength || 0;    },    set expectedContentLength(x)    {        if (this._expectedContentLength === x)            return;        this._expectedContentLength = x;    },    get finished()    {        return this._finished;    },    set finished(x)    {        if (this._finished === x)            return;        this._finished = x;        if (x) {            this._checkTips();            this._checkWarnings();            this.dispatchEventToListeners("finished");        }    },    get failed()    {        return this._failed;    },    set failed(x)    {        this._failed = x;    },    get category()    {        return this._category;    },    set category(x)    {        if (this._category === x)            return;        var oldCategory = this._category;        if (oldCategory)            oldCategory.removeResource(this);        this._category = x;        if (this._category)            this._category.addResource(this);        if (WebInspector.panels.resources) {            WebInspector.panels.resources.refreshResource(this);            WebInspector.panels.resources.recreateViewForResourceIfNeeded(this);        }    },    get mimeType()    {        return this._mimeType;    },    set mimeType(x)    {        if (this._mimeType === x)            return;        this._mimeType = x;    },    get type()    {        return this._type;    },    set type(x)    {        if (this._type === x)

⌨️ 快捷键说明

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