U.S. patent application number 16/938162 was filed with the patent office on 2020-11-12 for rendering based on a document object model.
The applicant listed for this patent is Citrix Systems, Inc.. Invention is credited to Lee Laborczfalvi.
Application Number | 20200356720 16/938162 |
Document ID | / |
Family ID | 1000004976615 |
Filed Date | 2020-11-12 |
![](/patent/app/20200356720/US20200356720A1-20201112-D00000.png)
![](/patent/app/20200356720/US20200356720A1-20201112-D00001.png)
![](/patent/app/20200356720/US20200356720A1-20201112-D00002.png)
![](/patent/app/20200356720/US20200356720A1-20201112-D00003.png)
![](/patent/app/20200356720/US20200356720A1-20201112-D00004.png)
![](/patent/app/20200356720/US20200356720A1-20201112-D00005.png)
![](/patent/app/20200356720/US20200356720A1-20201112-D00006.png)
![](/patent/app/20200356720/US20200356720A1-20201112-D00007.png)
United States Patent
Application |
20200356720 |
Kind Code |
A1 |
Laborczfalvi; Lee |
November 12, 2020 |
Rendering Based on a Document Object Model
Abstract
Methods and devices for rendering content are described herein.
In some embodiments, the method may include receiving an email or
other markup language based content. The method may create a
document object model (DOM) corresponding to the content using an
off screen browser. The method may cause the off screen browser to
indicate that the DOM has been created before the off screen
browser retrieves any external content. The method may extract a
portion of the content from the DOM, and then render the portion of
the content using predefined formatting rules.
Inventors: |
Laborczfalvi; Lee;
(Freiburg, DE) |
|
Applicant: |
Name |
City |
State |
Country |
Type |
Citrix Systems, Inc. |
Fort Lauderdale |
FL |
US |
|
|
Family ID: |
1000004976615 |
Appl. No.: |
16/938162 |
Filed: |
July 24, 2020 |
Related U.S. Patent Documents
|
|
|
|
|
|
Application
Number |
Filing Date |
Patent Number |
|
|
15045558 |
Feb 17, 2016 |
10769351 |
|
|
16938162 |
|
|
|
|
62158695 |
May 8, 2015 |
|
|
|
Current U.S.
Class: |
1/1 |
Current CPC
Class: |
G06F 40/103 20200101;
G06F 40/154 20200101; G06F 9/44 20130101; G06F 40/14 20200101 |
International
Class: |
G06F 40/14 20060101
G06F040/14; G06F 40/103 20060101 G06F040/103; G06F 40/154 20060101
G06F040/154; G06F 9/44 20060101 G06F009/44 |
Claims
1. A method, comprising: generating, by a computing device, a
document object model (DOM) for a document; cancelling, by the
computing device, at least one network request to download content
from an external resource, the downloaded content to be included in
a rendering of the document in a web browser; extracting, by the
computing device, a portion of the document or the DOM in response
to cancellation of the at least one network request and receipt of
a notification indicative of the DOM being available; and
rendering, by the computing device, the extracted portion of the
document or the DOM using the web browser.
2. The method of claim 1, wherein cancelling the at least one
network request comprises: executing a script configured to cause
the web browser to cancel the at least one network request.
3. The method of claim 2, wherein the script comprises a JavaScript
event listener or a JavaScript event handler.
4. The method of claim 1, wherein the DOM is generated using a
first web browser.
5. The method of claim 4, wherein the first web browser is an
off-screen web browser.
6. The method of claim 1, wherein extracting the portion of the
document or the DOM further comprises extracting content included
in a body portion of the document or the DOM, without extracting
style sheet content.
7. The method of claim 1, further comprising: receiving a style
sheet; and applying the style sheet to the extracted portion of the
document or the DOM.
8. The method of claim 7, further comprising: receiving a
completion block indicating that the DOM is available; and in
response to receiving the completion block, applying the style
sheet to the extracted portion of the document or the DOM.
9. A computing device comprising: a processor; and a memory storing
computer-executable instructions that, when executed by the
processor, cause the computing device to: generate a document
object model (DOM) for a document; cancel at least one network
request to download content from an external resource, the
downloaded content to be included in a rendering of the document in
a web browser; extract a portion of the document or the DOM in
response to cancellation of the at least one network request and
receipt of a notification indicative of the DOM being available;
and render the extracted portion of the document or the DOM using
the web browser.
10. The computing device of claim 9, wherein the instructions cause
the computing device to cancel the at least one network request by
executing a script configured to cancel the at least one network
request.
11. The computing device of claim 10, wherein the script comprises
a JavaScript event listener or a JavaScript event handler.
12. The computing device of claim 9, wherein the instructions cause
the computing device to generate the DOM using a first web
browser.
13. The computing device of claim 12, wherein the first web browser
is an off-screen web browser.
14. The computing device of claim 9, wherein the instructions cause
the computing device to extract the portion of the document or the
DOM without extracting style sheet content.
15. The computing device of claim 9, wherein the instructions
further cause the computing device to: receive, via an application
program interface (API), a style sheet; and apply the style sheet
to the extracted portion of the document or the DOM.
16. A computing device comprising: a processor; and memory storing
computer-executable instructions that, when executed by the
processor, cause the computing device to: generate, using a first
web browser and in response to receiving, from the first web
browser, an indication that parsing of an email is in progress, a
document object model (DOM) corresponding to the email; cancel,
during generation of the DOM corresponding to the email, one or
more network requests for information, from an external source,
referenced in the email; and render the email from content
extracted from a portion of the DOM.
17. The computing device of claim 16, wherein the instructions
cause the computing device to cancel the one or more network
requests by executing a script configured to cancel the one or more
network requests.
18. The computing device of claim 16, wherein the first web browser
is an off-screen web browser.
19. The computing device of claim 16, wherein the instructions
further cause the computing device to: prior to rendering the email
from the content extracted from the portion of the DOM: extract,
from the DOM, content included in a body portion of the DOM,
without extracting style sheet content.
20. The computing device of claim 16, wherein the instructions
further cause the computing device to: receive, via an application
program interface (API), a style sheet; and apply the style sheet
to the content extracted from the portion of the DOM.
Description
CROSS-REFERENCE TO RELATED APPLICATIONS
[0001] This application is a continuation of and claims priority to
U.S. patent application Ser. No. 15/045,558, filed Feb. 17, 2016,
and entitled "Rendering Based on a Document Object Model," which
claims priority to U.S. Provisional Patent Application No.
62/158,695, filed May 8, 2015, and entitled "Email Rendering Based
on a Document Object Model," both of which are incorporated herein
by reference in their entirety.
FIELD
[0002] Aspects described herein generally relate to rendering
content for display by a computing device. More specifically,
aspects described herein relate to pre-generating a Document Object
Model (DOM) for content to expedite the rendering process.
BACKGROUND
[0003] An email or portions of an email may be received in a
HyperText Markup Language (HTML) format. Conventional systems, when
rendering the email, render portions twice. The email may first be
rendered with styles or scripts that are included in the HTML
email. When rendering the email, external content such as images
may be downloaded. After retrieving all the content and rendering
the email once, the system may apply a custom style or script to
the HTML email, and the email may be rendered a second time with
the system's desired formatting. The external content may be
downloaded a second time as well. Rendering twice and downloading
external content twice is inefficient. Further, displaying the
email both times that it is rendered may present a flickering
effect or changing the display to a user. Similar problems are
encountered with non-email content as well.
SUMMARY
[0004] The following presents a simplified summary of various
aspects described herein. This summary is not an extensive
overview, and is not intended to identify key or critical elements
or to delineate the scope of the claims. The following summary
merely presents some concepts in a simplified form as an
introductory prelude to the more detailed description provided
below.
[0005] To overcome limitations in the prior art described above,
and to overcome other limitations that will be apparent upon
reading and understanding the present specification, aspects
described herein are directed towards rendering content using a
document object model.
[0006] Aspects of the disclosure relate to various techniques and
technologies for a method for rendering content for display. In one
implementation, the method may include receiving HTML-based
content. The method may create a document object model (DOM)
corresponding to the content using an off screen browser. The
method may cause the off screen browser to indicate that the DOM
has been created before the off screen browser retrieves any
external content. The method may extract a portion of the content
from the DOM, and render the portion of the content using
predefined formatting rules.
[0007] Aspects of the disclosure also relate to various techniques
and technologies for a method for rendering an email. In one
implementation, the method may include adding a script to an email.
The script is configured to prevent a web browser from retrieving
external content linked within the email. The method may load the
email using the web browser to generate a DOM corresponding to the
email. The method may also render the email based on the DOM.
[0008] Aspects of the disclosure also relate to various techniques
and technologies for a method for rendering a document having
markup language content. The method may include invoking a first
web browser to generate a DOM based on the markup language content.
The generating is performed without downloading external content by
the first web browser. The method may extract style-neutral content
from the DOM. The method may apply a style to the style-neutral
content. The method may also render the style-neutral content based
on the applied style using a second web browser.
[0009] These and additional aspects will be appreciated with the
benefit of the disclosures discussed in further detail below.
BRIEF DESCRIPTION OF THE DRAWINGS
[0010] A more complete understanding of aspects described herein
and the advantages thereof may be acquired by referring to the
following description in consideration of the accompanying
drawings, in which like reference numbers indicate like features,
and wherein:
[0011] FIG. 1 depicts an illustrative computer system architecture
that may be used in accordance with one or more illustrative
aspects described herein.
[0012] FIG. 2 depicts an illustrative remote-access system
architecture that may be used in accordance with one or more
illustrative aspects described herein.
[0013] FIG. 3 illustrates a method and data flow for generating a
Document Object Model (DOM) and loading external content according
to one or more illustrative aspects described herein.
[0014] FIG. 4 illustrates a method and data flow for displaying a
Hyper Text Markup Language (HTML) email according to one or more
illustrative aspects described herein.
[0015] FIG. 5 illustrates a method and data flow for creating a DOM
according to one or more illustrative aspects described herein.
[0016] FIG. 6 depicts examples of HTML and a corresponding DOM
according to one or more illustrative aspects described herein.
[0017] FIG. 7 illustrates an example of a script that may stop
pending network requests according to one or more illustrative
aspects described herein.
[0018] FIG. 8 illustrates an example of a script that may issue a
detectable error code according to one or more illustrative aspects
described herein.
DETAILED DESCRIPTION
[0019] In the following description of the various embodiments,
reference is made to the accompanying drawings identified above and
which form a part hereof, and in which is shown, by way of
illustration, various embodiments in which aspects described herein
may be practiced. It is to be understood that other embodiments may
be utilized and structural and functional modifications may be made
without departing from the scope described herein. Various aspects
are capable of other embodiments and of being practiced or being
carried out in various different ways.
[0020] It is to be understood that the phraseology and terminology
used herein are for the purpose of description and should not be
regarded as limiting. Rather, the phrases and terms used herein are
to be given their broadest interpretation and meaning. The use of
"including" and "comprising" and variations thereof is meant to
encompass the items listed thereafter and equivalents thereof as
well as additional items and equivalents thereof. The use of the
terms "mounted," "connected," "coupled," "positioned," "engaged"
and similar terms, is meant to include both direct and indirect
mounting, connecting, coupling, positioning and engaging.
[0021] Computing Architecture
[0022] Computer software, hardware, and networks may be utilized in
a variety of different system environments, including standalone,
networked, remote-access (aka, remote desktop), virtualized, and/or
cloud-based environments, among others. FIG. 1 illustrates one
example of a system architecture and data processing device that
may be used to implement one or more illustrative aspects described
herein in a standalone and/or networked environment. Various
network nodes 103, 105, 107, and 109 may be interconnected via a
wide area network (WAN) 101, such as the Internet. Other networks
may also or alternatively be used, including private intranets,
corporate networks, local area networks (LANs), metropolitan area
networks (MANs), wireless networks, personal area networks (PANs),
and the like. Network 101 is for illustration purposes and may be
replaced with fewer or additional computer networks. A local area
network may have one or more of any known LAN topology and may use
one or more of a variety of different protocols, such as Ethernet.
Devices 103, 105, 107, 109 and other devices (not shown) may be
connected to one or more of the networks via twisted pair wires,
coaxial cable, fiber optics, radio waves or other communication
media.
[0023] The term "network" as used herein and depicted in the
drawings refers not only to systems in which remote storage devices
are coupled together via one or more communication paths, but also
to stand-alone devices that may be coupled, from time to time, to
such systems that have storage capability. Consequently, the term
"network" includes not only a "physical network" but also a
"content network," which is comprised of the data--attributable to
a single entity--which resides across all physical networks.
[0024] The components may include data server 103, web server 105,
and client computers 107, 109. Data server 103 provides overall
access, control and administration of databases and control
software for performing one or more illustrative aspects describe
herein. Data server 103 may be connected to web server 105 through
which users interact with and obtain data as requested.
Alternatively, data server 103 may act as a web server itself and
be directly connected to the Internet. Data server 103 may be
connected to web server 105 through the network 101 (e.g., the
Internet), via direct or indirect connection, or via some other
network. Users may interact with the data server 103 using remote
computers 107, 109, e.g., using a web browser to connect to the
data server 103 via one or more externally exposed web sites hosted
by web server 105. Client computers 107, 109 may be used in concert
with data server 103 to access data stored therein, or may be used
for other purposes. For example, from client device 107 a user may
access web server 105 using an Internet browser, as is known in the
art, or by executing a software application that communicates with
web server 105 and/or data server 103 over a computer network (such
as the Internet).
[0025] Servers and applications may be combined on the same
physical machines, and retain separate virtual or logical
addresses, or may reside on separate physical machines. FIG. 1
illustrates just one example of a network architecture that may be
used, and those of skill in the art will appreciate that the
specific network architecture and data processing devices used may
vary, and are secondary to the functionality that they provide, as
further described herein. For example, services provided by web
server 105 and data server 103 may be combined on a single
server.
[0026] Each component 103, 105, 107, 109 may be any type of known
computer, server, or data processing device. Data server 103, e.g.,
may include a processor 111 controlling overall operation of the
rate server 103. Data server 103 may further include random access
memory (RAM) 113, read only memory (ROM) 115, network interface
117, input/output interfaces 119 (e.g., keyboard, mouse, display,
printer, etc.), and memory 121. Input/output (I/O) 119 may include
a variety of interface units and drives for reading, writing,
displaying, and/or printing data or files. Memory 121 may further
store operating system software 123 for controlling overall
operation of the data processing device 103, control logic 125 for
instructing data server 103 to perform aspects described herein,
and other application software 127 providing secondary, support,
and/or other functionality which may or might not be used in
conjunction with aspects described herein. The control logic may
also be referred to herein as the data server software 125.
Functionality of the data server software may refer to operations
or decisions made automatically based on rules coded into the
control logic, made manually by a user providing input into the
system, and/or a combination of automatic processing based on user
input (e.g., queries, data updates, etc.).
[0027] Memory 121 may also store data used in performance of one or
more aspects described herein, including a first database 129 and a
second database 131. In some embodiments, the first database may
include the second database (e.g., as a separate table, report,
etc.). That is, the information can be stored in a single database,
or separated into different logical, virtual, or physical
databases, depending on system design. Devices 105, 107, 109 may
have similar or different architecture as described with respect to
device 103. Those of skill in the art will appreciate that the
functionality of data processing device 103 (or device 105, 107,
109) as described herein may be spread across multiple data
processing devices, for example, to distribute processing load
across multiple computers, to segregate transactions based on
geographic location, user access level, quality of service (QoS),
etc.
[0028] One or more aspects may be embodied in computer-usable or
readable data and/or computer-executable instructions, such as in
one or more program modules, executed by one or more computers or
other devices as described herein. Generally, program modules
include routines, programs, objects, components, data structures,
etc. that perform particular tasks or implement particular abstract
data types when executed by a processor in a computer or other
device. The modules may be written in a source code programming
language that is subsequently compiled for execution, or may be
written in a scripting language such as (but not limited to)
HyperText Markup Language (HTML) or Extensible Markup Language
(XML). The computer executable instructions may be stored on a
computer readable medium such as a nonvolatile storage device. Any
suitable computer readable storage media may be utilized, including
hard disks, CD-ROMs, optical storage devices, magnetic storage
devices, and/or any combination thereof. In addition, various
transmission (non-storage) media representing data or events as
described herein may be transferred between a source and a
destination in the form of electromagnetic waves traveling through
signal-conducting media such as metal wires, optical fibers, and/or
wireless transmission media (e.g., air and/or space). Various
aspects described herein may be embodied as a method, a data
processing system, or a computer program product. Therefore,
various functionalities may be embodied in whole or in part in
software, firmware and/or hardware or hardware equivalents such as
integrated circuits, field programmable gate arrays (FPGA), and the
like. Particular data structures may be used to more effectively
implement one or more aspects described herein, and such data
structures are contemplated within the scope of computer executable
instructions and computer-usable data described herein.
[0029] With further reference to FIG. 2, one or more aspects
described herein may be implemented in a remote-access environment.
FIG. 2 depicts an example system architecture including a generic
computing device 201 in an illustrative computing environment 200
that may be used according to one or more illustrative aspects
described herein. Generic computing device 201 may be used as a
server 206a in a single-server or multi-server desktop
virtualization system (e.g., a remote access or cloud system)
configured to provide virtual machines for client access devices.
The generic computing device 201 may have a processor 203 for
controlling overall operation of the server and its associated
components, including RAM 205, ROM 207, I/O module 209, and memory
215.
[0030] I/O module 209 may include a mouse, keypad, touch screen,
scanner, optical reader, and/or stylus (or other input device(s))
through which a user of generic computing device 201 may provide
input, and may also include one or more of a speaker for providing
audio output and a video display device for providing textual,
audiovisual, and/or graphical output. Software may be stored within
memory 215 and/or other storage to provide instructions to
processor 203 for configuring generic computing device 201 into a
special purpose computing device in order to perform various
functions as described herein. For example, memory 215 may store
software used by the computing device 201, such as an operating
system 217, application programs 219, and an associated database
221.
[0031] Computing device 201 may operate in a networked environment
supporting connections to one or more remote computers, such as
terminals 240 (also referred to as client devices). The terminals
240 may be personal computers, mobile devices, laptop computers,
tablets, or servers that include many or all of the elements
described above with respect to the generic computing device 103 or
201. The network connections depicted in FIG. 2 include a local
area network (LAN) 225 and a wide area network (WAN) 229, but may
also include other networks. When used in a LAN networking
environment, computing device 201 may be connected to the LAN 225
through a network interface or adapter 223. When used in a WAN
networking environment, computing device 201 may include a modem
227 or other wide area network interface for establishing
communications over the WAN 229, such as computer network 230
(e.g., the Internet). It will be appreciated that the network
connections shown are illustrative and other means of establishing
a communications link between the computers may be used. Computing
device 201 and/or terminals 240 may also be mobile terminals (e.g.,
mobile phones, smartphones, personal digital assistants (PDAs),
notebooks, etc.) including various other components, such as a
battery, speaker, and antennas (not shown).
[0032] Aspects described herein may also be operational with
numerous other general purpose or special purpose computing system
environments or configurations. Examples of other computing
systems, environments, and/or configurations that may be suitable
for use with aspects described herein include, but are not limited
to, personal computers, server computers, hand-held or laptop
devices, multiprocessor systems, microprocessor-based systems, set
top boxes, programmable consumer electronics, network personal
computers (PCs), minicomputers, mainframe computers, distributed
computing environments that include any of the above systems or
devices, and the like.
[0033] As shown in FIG. 2, one or more client devices 240 may be in
communication with one or more servers 206a-206n (generally
referred to herein as "server(s) 206"). In one embodiment, the
computing environment 200 may include a network appliance installed
between the server(s) 206 and client machine(s) 240. The network
appliance may manage client/server connections, and in some cases
can load balance client connections amongst a plurality of backend
servers 206.
[0034] The client machine(s) 240 may in some embodiments be
referred to as a single client machine 240 or a single group of
client machines 240, while server(s) 206 may be referred to as a
single server 206 or a single group of servers 206. In one
embodiment a single client machine 240 communicates with more than
one server 206, while in another embodiment a single server 206
communicates with more than one client machine 240. In yet another
embodiment, a single client machine 240 communicates with a single
server 206.
[0035] A client machine 240 can, in some embodiments, be referenced
by any one of the following non-exhaustive terms: client
machine(s); client(s); client computer(s); client device(s); client
computing device(s); local machine; remote machine; client node(s);
endpoint(s); or endpoint node(s). The server 206, in some
embodiments, may be referenced by any one of the following
non-exhaustive terms: server(s), local machine; remote machine;
server farm(s), or host computing device(s).
[0036] In one embodiment, the client machine 240 may be a virtual
machine. The virtual machine may be any virtual machine, while in
some embodiments the virtual machine may be any virtual machine
managed by a Type 1 or Type 2 hypervisor, for example, a hypervisor
developed by Citrix Systems, IBM, VMware, or any other hypervisor.
In some aspects, the virtual machine may be managed by a
hypervisor, while in aspects the virtual machine may be managed by
a hypervisor executing on a server 206 or a hypervisor executing on
a client 240.
[0037] Some embodiments include a client device 240 that displays
application output generated by an application remotely executing
on a server 206 or other remotely located machine. In these
embodiments, the client device 240 may execute a virtual machine
receiver program or application to display the output in an
application window, a browser, or other output window. In one
example, the application is a desktop, while in other examples the
application is an application that generates or presents a desktop.
A desktop may include a graphical shell providing a user interface
for an instance of an operating system in which local and/or remote
applications can be integrated. Applications, as used herein, are
programs that execute after an instance of an operating system
(and, optionally, also the desktop) has been loaded.
[0038] The server 206, in some embodiments, uses a remote
presentation protocol or other program to send data to a
thin-client or remote-display application executing on the client
to present display output generated by an application executing on
the server 206. The thin-client or remote-display protocol can be
any one of the following non-exhaustive list of protocols: the
Independent Computing Architecture (ICA) protocol developed by
Citrix Systems, Inc. of Ft. Lauderdale, Fla.; or the Remote Desktop
Protocol (RDP) manufactured by the Microsoft Corporation of
Redmond, Wash.
[0039] A remote computing environment may include more than one
server 206a-206n such that the servers 206a-206n are logically
grouped together into a server farm 206, for example, in a cloud
computing environment. The server farm 206 may include servers 206
that are geographically dispersed while and logically grouped
together, or servers 206 that are located proximate to each other
while logically grouped together. Geographically dispersed servers
206a-206n within a server farm 206 can, in some embodiments,
communicate using a WAN (wide), MAN (metropolitan), or LAN (local),
where different geographic regions can be characterized as:
different continents; different regions of a continent; different
countries; different states; different cities; different campuses;
different rooms; or any combination of the preceding geographical
locations. In some embodiments the server farm 206 may be
administered as a single entity, while in other embodiments the
server farm 206 can include multiple server farms.
[0040] In some embodiments, a server farm may include servers 206
that execute a substantially similar type of operating system
platform (e.g., WINDOWS, UNIX, LINUX, iOS, ANDROID, SYMBIAN, etc.)
In other embodiments, server farm 206 may include a first group of
one or more servers that execute a first type of operating system
platform, and a second group of one or more servers that execute a
second type of operating system platform.
[0041] Server 206 may be configured as any type of server, as
needed, e.g., a file server, an application server, a web server, a
proxy server, an appliance, a network appliance, a gateway, an
application gateway, a gateway server, a virtualization server, a
deployment server, a Secure Sockets Layer (SSL) VPN server, a
firewall, a web server, an application server or as a master
application server, a server executing an active directory, or a
server executing an application acceleration program that provides
firewall functionality, application functionality, or load
balancing functionality. Other server types may also be used.
[0042] Some embodiments include a first server 106a that receives
requests from a client machine 240, forwards the request to a
second server 106b, and responds to the request generated by the
client machine 240 with a response from the second server 106b.
First server 106a may acquire an enumeration of applications
available to the client machine 240 as well as address information
associated with an application server 206 hosting an application
identified within the enumeration of applications. First server
106a can then present a response to the client's request using a
web interface, and communicate directly with the client 240 to
provide the client 240 with access to an identified application.
One or more clients 240 and/or one or more servers 206 may transmit
data over network 230, e.g., network 101.
[0043] FIG. 2 shows a high-level architecture of an illustrative
desktop virtualization system. As shown, the desktop virtualization
system may be single-server or multi-server system, or cloud
system, including at least one virtualization server 206 configured
to provide virtual desktops and/or virtual applications to one or
more client access devices 240. As used herein, a desktop refers to
a graphical environment or space in which one or more applications
may be hosted and/or executed. A desktop may include a graphical
shell providing a user interface for an instance of an operating
system in which local and/or remote applications can be integrated.
Applications may include programs that execute after an instance of
an operating system (and, optionally, also the desktop) has been
loaded. Each instance of the operating system may be physical
(e.g., one operating system per device) or virtual (e.g., many
instances of an OS running on a single device). Each application
may be executed on a local device, or executed on a remotely
located device (e.g., remoted).
[0044] Generating a Document Object Model
[0045] FIG. 3 illustrates a method 300 of data flow for generating
a Document Object Model (DOM) and loading external content
according to one or more illustrative aspects described herein.
When displaying an HTML web page, a web browser will generate a DOM
using a method similar to method 300.
[0046] At step 310, a web page or a selection of a web page to load
is received. For example, a user or a program may enter a URL of a
web page into a web browser. At step 320, a "shouldStartLoading" or
platform equivalent callback may be issued to verify that the page
load should begin. If a verification that the page load should
begin is received, the method 300 may proceed to step 330.
[0047] At step 330, a DOM for the page received at step 310 may be
generated, e.g., by the browser engine. At step 340, pending
network requests for external content may be generated based on the
DOM. The browser may scan the DOM to determine external content
linked to in the page, such as images or scripts, and generate a
list of pending network requests for the external content.
[0048] At step 350, the pending network requests may be issued. By
issuing the pending network requests, the external content may be
retrieved. During execution, this step may consume a relatively
large portion of the time and resources used by method 300. For
example, step 350 may take longer to perform than the other steps
in method 300. At step 360, a "didFinishLoad" callback may be
issued, indicating that the web page has been loaded.
[0049] Typically, after the "didFinishLoad" callback, the DOM will
be available for retrieval by an external application. For example,
the DOM may be retrieved using a browser developer tools feature of
a web browser.
[0050] Generating a Document Object Model without Loading External
Content
[0051] Aspects described herein may be used to render any content
that benefits from an HTML document object model (DOM) being
pre-rendered. While aspects described herein are discussed in the
context of an email client, the features herein may also be used
with other types of content that rely on an HTML DOM for rendering.
This may include, without limitation, any application that supports
HTML format documents to which the application may want to apply
custom styles. For example, an application that is used to show
notes taken in another application may want to apply its own styles
to the notes that it receives in HTML format, and may therefore
benefit from aspects described herein.
[0052] An email client may use one or more web browsers to render
and/or display HTML content in emails. The email client may apply a
set of uniform styles to the HTML before displaying the HTML. The
email client may prevent JavaScript in the email from executing,
including JavaScript contained in Cascading Style Sheets (CSS). For
example, the email client may prevent JavaScript from executing for
security reasons. Additionally, the email client may remove content
from HTML in an email. To apply styles, prevent JavaScript from
executing, or remove content, the email client may interpret, or
parse, the HTML in the email.
[0053] Interpreting HTML documents using regular expressions may be
difficult due to variations in HTML tags. FIG. 6 illustrates
examples of variations in HTML tags. HTML is an irregular language,
and thus may be difficult to parse consistently using regular
expressions. A DOM corresponding to an HTML document may be more
consistent, or regular, than the original HTML document.
[0054] As described in FIG. 3, a DOM may be generated by a web
browser loading an HTML document. Although a DOM may be constructed
prior to the browser retrieving external content, typically, the
DOM is only available after the external content has been
retrieved. In certain instances, it may be desirable to retrieve
the DOM prior to or without the browser issuing the list of pending
network requests for external content at step 350. Issuing the list
of pending network requests at step 350 may be time consuming. For
example, loading external resources while generating a DOM may
cause delays. For certain applications, it may be preferable to
generate a DOM without performing the actions described at step
350. By performing method 300 without step 350, a DOM may be
generated without issuing pending network requests.
[0055] In certain implementations, email clients may display an
HTML email twice. First, the web page generated by a browser
creating the DOM is displayed, and then, a web page generated using
the DOM and custom styles or scripts is displayed. This may result
in a flickering, or changing, display. Displaying an HTML email
once rather than twice results in a user interface without
flickering or changing emails, thereby providing an improved user
experience.
[0056] FIG. 4 illustrates a method and data flow 400 for displaying
an HTML email according to one or more illustrative aspects
described herein. At step 410, an HTML email may be received,
selected, or opened. For example, a user may select an HTML email
to view at step 410. Although step 410 describes an HTML email, any
HTML document may be received at step 410. Additionally, documents
in another markup language may be received at step 410. For
example, an extensible hypertext markup language (XHTML) document
may be received at step 410. Other markup languages for which a DOM
or similar construct can be generated may also be used.
[0057] At step 420, script may be injected, or inserted, in the
HTML email received at step 410. The script may prevent a browser
loading the HTML email from downloading external content. For
example, the script may cause the browser to stop any pending
network requests. In one implementation, the script may be a
JavaScript DOMContentLoaded event handler that causes the browser
to call a "window.stop( )" function. FIG. 7, described below,
illustrates an example of a script that may be injected at step
420.
[0058] At step 430, the HTML email with the injected script may be
loaded in a first browser. An indication that parsing is underway
may be issued. For example, a value may be returned indicating that
parsing is underway. The first browser may then generate a DOM
corresponding to the HTML email. For example, portions of method
300 may be used to generate the DOM. FIG. 6, described below,
illustrates examples of disparate HTML documents and a
corresponding common DOM that is created based on each.
[0059] The first browser may be an off-screen browser, which may be
referred to as a headless HTML parser. For example, the first
browser might not be displayed on a screen, have a user interface,
or be viewable by a user. The first browser may be a background
application. The injected script may cause the browser to cancel
any network requests for external content that are issued while
generating the DOM.
[0060] FIG. 5 illustrates a method and data flow 500 for creating a
DOM according to one or more illustrative aspects described herein.
In one implementation, method 500 may be executed at step 430 of
method 400. In this implementation, method 400 and method 500 may
execute asynchronously, or portions of method 400 and portions of
method 500 may execute asynchronously.
[0061] At step 510, the first browser begins loading an HTML
document with JavaScript. In one implementation, the JavaScript may
respond to a DOMContentLoaded event. An example of JavaScript that
may be contained in an HTML document is described below in FIG. 7.
Although step 510 describes an HTML document with JavaScript, other
types of script may be used to perform method 500.
[0062] At step 520, the first browser may begin generating a DOM
corresponding to the HTML document. When the first browser is
generating the DOM, the browser may fire, or execute, the
DOMContentLoaded event. The event may be fired during the DOM
rendering process when the DOM has been assembled into an object
model and before network requests have been made. For example, if
the first browser is generating a DOM using method 300, the
DOMContentLoaded event may be fired between steps 340 and 350.
[0063] At step 530, the DOMContentLoaded event causes a function to
be called that stops the first browser from loading external
content. For example, a "windows.stop( )" function may be called to
stop further processing of the HTML by the first browser while
leaving the DOM intact. In this example, when the "windows.stop( )"
function is called, pending network requests may be canceled and
the DOM tree may be available.
[0064] At step 540, the first browser may indicate that the DOM is
available. For example, the first browser may invoke an error
delegate with a cancelled error code. FIG. 8, described below,
illustrates an example of a script that may cause an error code to
be issued when the DOM is available.
[0065] Returning to method 400, at step 440, a notification may be
received that the HTML email has been loaded in the first browser.
The notification may indicate that the DOM generated at step 430 is
available for retrieval. For example, if an email client loads an
HTML email message in the first browser, the first browser may
transmit a message to the email client indicating that the DOM is
available. In one implementation, a completion block received
through an Application Program Interface (API) may be used to
indicate that the DOM is available.
[0066] At step 450, the DOM generated by the first browser may be
used to extract a portion of the HTML in the HTML email, or a
portion of the DOM. For example, HTML that is between the "body"
tags in the DOM may be extracted. CSS or JavaScript content
contained within the HTML email received at step 410 might not be
included in the extracted HTML. For example, if CSS code is
included in a header of the HTML email received at step 410, the
CSS code might not be included in the extracted HTML. The extracted
content may be style-neutral insofar as it may comprise text or
other content without any formatting.
[0067] At step 460, custom parsing logic may be applied to the HTML
extracted at step 450. For example, a CSS stylesheet or other
predefined formatting rules may be applied to the HTML extracted at
step 450. An email client may use custom CSS to display emails with
consistent formatting. By removing CSS included in an HTML email at
step 450, the email client may be able to apply the custom CSS to
the HTML email. After the custom parsing and processing is
completed, a completion callback may be invoked.
[0068] At step 470, a second browser may display the portion of the
HTML extracted at step 450 with the custom parsing logic applied at
step 460. All or portions of the second browser may be displayed.
For example, an email client may use the second browser to display
the HTML that is generated at step 460. In one implementation, the
first browser and the second browser may be the same browser, or
multiple instances of a browser.
[0069] Portions of method 400 may be implemented using an API. For
example, an API may receive an HTML document or email, receive
logic to apply to the HTML document, such as CSS, and receive a
completion block to invoke after parsing of the HTML document is
completed.
[0070] FIG. 6 depicts examples of HTML and a corresponding DOM
according to one or more illustrative aspects described herein.
HTML examples 610, 620, and 630 are examples of HTML that may be
used to form a webpage with the text "hello." HTML 610 includes
both opening and closing body tags. HTML 620 includes a closing
body tag without an opening body tag. HTML 630 includes neither an
opening nor a closing body tag. Although HTML examples 610, 620,
and 630 all include different tags, a DOM 640 corresponding to
examples 610, 620, and 630 is the same.
[0071] As described above, interpreting HTML documents using
regular expressions may be difficult due to variations in HTML
tags. In FIG. 6, the body of the HTML examples 610, 620, and 630
comprises the text "hello," but the text is surrounded by different
tags in the examples. Regardless of whether or not tags are missing
in 610, 620, or 630, the DOM 640 comprises the text "hello" between
an opening and closing body tag. Parsing a DOM, or applying logic
to the DOM, may result in more consistency than directly parsing
HTML.
[0072] FIG. 7 illustrates an example of a script that may stop
pending network requests according to one or more illustrative
aspects described herein. The script in FIG. 7 may be inserted into
an HTML document to prevent a browser loading the HTML document
from requesting external content. In the code in FIG. 7, a
"window.stop( )" command may be issued when a "DOMContentLoaded"
event is detected. The "window.stop( )" command may cause the
browser to stop or cancel any pending network requests related to
the HTML document.
[0073] FIG. 8 illustrates an example of a script that may issue a
detectable error code according to one or more illustrative aspects
described herein. The script illustrated in FIG. 8 may be used to
detect that DOM content is available on iOS. The script may cause
an error code to be issued in response to a load cancellation.
After receiving the error code, further requests may be issued to
parse the DOM. For example, JavaScript requests may be used to
parse the DOM. Other platforms, such as Android, may provide a
different interface for detecting a browser load completion
event.
[0074] Although the subject matter has been described in language
specific to structural features and/or methodological acts, it is
to be understood that the subject matter defined in the appended
claims is not necessarily limited to the specific features or acts
described above. Rather, the specific features and acts described
above are described as example implementations of the following
claims.
* * * * *