コード例 #1
0
ファイル: Document.cs プロジェクト: zidanfei/AngleSharp
 internal Document(IBrowsingContext context, TextSource source)
     : base(null, "#document", NodeType.Document)
 {
     _async             = true;
     _designMode        = false;
     _firedUnload       = false;
     _salvageable       = true;
     _shown             = false;
     _context           = context;
     _source            = source;
     Referrer           = String.Empty;
     ContentType        = MimeTypeNames.ApplicationXml;
     _ready             = DocumentReadyState.Loading;
     _sandbox           = Sandboxes.None;
     _quirksMode        = QuirksMode.Off;
     _loadingScripts    = new Queue <HtmlScriptElement>();
     _location          = new Location("about:blank");
     _ranges            = new List <WeakReference <Range> >();
     _location.Changed += LocationChanged;
     _view              = new Window(this);
     _loader            = context.CreateService <IResourceLoader>();
     _loop              = context.CreateService <IEventLoop>();
     _mutations         = new MutationHost(_loop);
     _subtasks          = new List <Task>();
     _statusCode        = HttpStatusCode.OK;
 }
コード例 #2
0
ファイル: StringExtensions.cs プロジェクト: lahma/AngleSharp
        /// <summary>
        /// Retrieves a string describing the compatibility mode of the given quirksmode.
        /// </summary>
        /// <param name="mode">A specific quriks mode.</param>
        /// <returns>The compatibility string.</returns>
        internal static String GetCompatiblity(this QuirksMode mode)
        {
            var field       = typeof(QuirksMode).GetField(mode.ToString());
            var description = field.GetCustomAttribute <DomDescriptionAttribute>()?.Description;

            return(description ?? "CSS1Compat");
        }
コード例 #3
0
 public static void SetQuirksMode(this DomDocument self, QuirksMode value)
 {
     self.RemoveAnnotations <QuirksModeAnnotation>();
     if (value != QuirksMode.None)
     {
         self.AddAnnotation(new QuirksModeAnnotation(value));
     }
 }
コード例 #4
0
ファイル: StringExtensions.cs プロジェクト: zzc000/AngleSharp
        /// <summary>
        /// Retrieves a string describing the compatibility mode of the given quirksmode.
        /// </summary>
        /// <param name="mode">A specific quriks mode.</param>
        /// <returns>The compatibility string.</returns>
        public static String GetCompatiblity(this QuirksMode mode)
        {
            var type        = typeof(QuirksMode).GetTypeInfo();
            var field       = type.GetDeclaredField(mode.ToString());
            var description = field.GetCustomAttribute <DomDescriptionAttribute>()?.Description;

            return(description ?? "CSS1Compat");
        }
コード例 #5
0
ファイル: StringExtensions.cs プロジェクト: howej/AngleSharp
        /// <summary>
        /// Retrieves a string describing the compatibility mode of the given quirksmode.
        /// </summary>
        /// <param name="mode">A specific quriks mode.</param>
        /// <returns>The compatibility string.</returns>
        public static String GetCompatiblity(this QuirksMode mode)
        {
            var attr = typeof(QuirksMode).GetTypeInfo().GetDeclaredField(mode.ToString()).GetCustomAttribute <DomDescriptionAttribute>();

            if (attr != null)
            {
                return(attr.Description);
            }

            return("CSS1Compat");
        }
コード例 #6
0
 /// <summary>
 /// Creates a new document node.
 /// </summary>
 internal Document()
 {
     _owner          = this;
     _type           = NodeType.Document;
     Async           = true;
     _referrer       = string.Empty;
     _ready          = Readiness.Complete;
     _name           = "#document";
     _implementation = new DOMImplementation();
     _styleSheets    = new StyleSheetList();
     _quirksMode     = QuirksMode.Off;
 }
コード例 #7
0
ファイル: Document.cs プロジェクト: zhlm119/AngleSharp
 /// <summary>
 /// Creates a new document node.
 /// </summary>
 internal Document()
 {
     _owner       = this;
     _type        = NodeType.Document;
     Async        = true;
     _referrer    = string.Empty;
     _ready       = Readiness.Complete;
     _name        = "#document";
     _styleSheets = new StyleSheetList(this);
     _quirksMode  = QuirksMode.Off;
     _location    = new Location("file://localhost/");
     _options     = Configuration.Default;
 }
コード例 #8
0
        /// <summary>
        /// Retrieves a string describing the compatibility mode of the given quirksmode.
        /// </summary>
        /// <param name="mode">A specific quriks mode.</param>
        /// <returns>The compatibility string.</returns>
        internal static String GetCompatiblity(this QuirksMode mode)
        {
            var description = "CSS1Compat";

            var fieldName = mode.ToString();

            if (fieldName != null)
            {
                var field = typeof(QuirksMode).GetField(fieldName);

                if (field != null)
                {
                    var domDescriptionAttribute = field.GetCustomAttribute <DomDescriptionAttribute>();

                    if (domDescriptionAttribute != null)
                    {
                        description = domDescriptionAttribute.Description;
                    }
                }
            }

            return(description);
        }
コード例 #9
0
 /// <summary>
 /// Creates a new document node.
 /// </summary>
 /// <param name="context">The context of the document.</param>
 /// <param name="source">The underlying source.</param>
 internal Document(IBrowsingContext context, TextSource source)
     : base(null, "#document", NodeType.Document)
 {
     _async = true;
     _designMode = false;
     _firedUnload = false;
     _salvageable = true;
     _shown = false;
     _preferredStyleSheetSet = String.Empty;
     _context = context ?? BrowsingContext.New();
     _source = source;
     _referrer = String.Empty;
     _contentType = MimeTypes.ApplicationXml;
     _ready = DocumentReadyState.Loading;
     _sandbox = Sandboxes.None;
     _quirksMode = QuirksMode.Off;
     _tasks = new CancellableTasks();
     _mutations = new MutationHost(Options);
     _loadingScripts = new Queue<HtmlScriptElement>();
     _location = new Location(AboutBlank);
     _ranges = new List<WeakReference<Range>>();
     _location.Changed += LocationChanged;
     _styleSheets = this.CreateStyleSheets();
     _view = this.CreateWindow();
     _loader = this.CreateLoader();
 }
コード例 #10
0
 public QuirksModeAnnotation(QuirksMode value)
 {
     Value = value;
 }
コード例 #11
0
ファイル: Document.cs プロジェクト: zymemail/itext7-dotnet
 public virtual Document QuirksMode(QuirksMode quirksMode)
 {
     this.quirksMode = quirksMode;
     return(this);
 }
コード例 #12
0
        static VariableRef?GetVariable([NotNull] Compilation cc, [NotNull] ZilObject expr, QuirksMode quirks = QuirksMode.None)
        {
            if (!(expr is ZilAtom atom) &&
                ((quirks & QuirksMode.Global) == 0 || !expr.IsGVAL(out atom)) &&
                ((quirks & QuirksMode.Local) == 0 || !expr.IsLVAL(out atom)))
            {
                return(null);
            }

            if (quirks == QuirksMode.Global)
            {
                // prefer global over local
                if (cc.Globals.TryGetValue(atom, out var gb))
                {
                    return(new VariableRef(gb));
                }
                if (cc.Locals.TryGetValue(atom, out var lbr))
                {
                    return(new VariableRef(lbr.LocalBuilder));
                }
            }
            else
            {
                if (cc.Locals.TryGetValue(atom, out var lbr))
                {
                    return(new VariableRef(lbr.LocalBuilder));
                }
                if (cc.Globals.TryGetValue(atom, out var gb))
                {
                    return(new VariableRef(gb));
                }
            }

            if (cc.SoftGlobals.TryGetValue(atom, out var sg))
            {
                return(new VariableRef(sg));
            }

            return(null);
        }