Skip to content

Commit

Permalink
Inline URLUtilsReadOnly
Browse files Browse the repository at this point in the history
The URLUtils abstraction is not working out. See #164 and whatwg/url#62 for details.
  • Loading branch information
annevk committed Sep 25, 2015
1 parent 1e865ed commit 32a7a20
Showing 1 changed file with 136 additions and 15 deletions.
151 changes: 136 additions & 15 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2695,6 +2695,8 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<li>The <dfn data-noexport="" data-x="concept-url-fragment">fragment</dfn> component of a <span>parsed URL</span>
<li><dfn data-noexport="" data-x="concept-url-parse-error">Parse errors</dfn> from the <span>URL parser</span>
<li>The <dfn data-noexport="" data-x="concept-url-serialiser">URL serialiser</dfn>
<li>The <dfn data-noexport="" data-x="host serialiser" data-x-href="https://url.spec.whatwg.org/#concept-host-serializer">host serialiser</dfn>
<li>The <dfn data-noexport="" data-x="serialise an integer" data-x-href="https://url.spec.whatwg.org/#serialize-an-integer">serialise an integer</dfn>
<li><dfn data-noexport="">Default encode set</dfn>
<li><dfn data-noexport="">Percent encode</dfn>
<li><dfn data-noexport="">UTF-8 percent encode</dfn>
Expand Down Expand Up @@ -95256,9 +95258,13 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> {
<code>WorkerGlobalScope</code> object itself.</p>

<p>The <dfn><code data-x="dom-WorkerGlobalScope-location">location</code></dfn> attribute must
return the <code>WorkerLocation</code> object created for the <code>WorkerGlobalScope</code>
object when the worker was created. It represents the <code>WorkerGlobalScope</code> object's
<span data-x="concept-WorkerGlobalScope-url">url</span>.</p>
return the <code>WorkerLocation</code> object whose associated <span
data-x="concept-WorkerLocation-WorkerGlobalScope"><code>WorkerGlobalScope</code> object</span> is
the <code>WorkerGlobalScope</code> object.</p>

<p class="note">While the <code>WorkerLocation</code> object is created after the
<code>WorkerGlobalScope</code> object, this is not problematic as it cannot be observed from
script.</p>

<hr>

Expand Down Expand Up @@ -95572,6 +95578,9 @@ interface <dfn>WorkerGlobalScope</dfn> : <span>EventTarget</span> {
environment</span>. (In either case, by definition, it is a <span>worker
environment</span>.)</p></li>

<li><p>Create a new <code>WorkerLocation</code> object and associate it with <var>worker global
scope</var>.</p>

<li><!-- SCRIPT EXEC -->

<p>Let <var>script</var> be a new <span data-x="concept-script">script</span>.</p>
Expand Down Expand Up @@ -96393,22 +96402,134 @@ interface <dfn>WorkerNavigator</dfn> {};
<h4>Worker locations</h4>

<pre class="idl">[Exposed=Worker]
interface <dfn>WorkerLocation</dfn> { };
<span>WorkerLocation</span> implements <span>URLUtilsReadOnly</span>;</pre>
interface <dfn>WorkerLocation</dfn> {
stringifier readonly attribute USVString <span data-x="dom-WorkerLocation-href">href</span>;
readonly attribute USVString <span data-x="dom-WorkerLocation-origin">origin</span>;
readonly attribute USVString <span data-x="dom-WorkerLocation-protocol">protocol</span>;
readonly attribute USVString <span data-x="dom-WorkerLocation-host">host</span>;
readonly attribute USVString <span data-x="dom-WorkerLocation-hostname">hostname</span>;
readonly attribute USVString <span data-x="dom-WorkerLocation-port">port</span>;
readonly attribute USVString <span data-x="dom-WorkerLocation-pathname">pathname</span>;
readonly attribute USVString <span data-x="dom-WorkerLocation-search">search</span>;
readonly attribute USVString <span data-x="dom-WorkerLocation-hash">hash</span>;
};</pre>

<p>A <code>WorkerLocation</code> object has an associated <dfn
data-x="concept-WorkerLocation-WorkerGlobalScope"><code>WorkerGlobalScope</code> object</dfn> (a
<code>WorkerGlobalScope</code> object).

<p>The <dfn><code data-x="dom-WorkerLocation-href">href</code></dfn> attribute's getter must
return the associated <span
data-x="concept-WorkerLocation-WorkerGlobalScope"><code>WorkerGlobalScope</code> object</span>'s
<span data-x="concept-WorkerGlobalScope-url">url</span>, <span
data-x="concept-url-serialiser">serialised</span>.</p>

<p>The <dfn><code data-x="dom-WorkerLocation-origin">origin</code></dfn> attribute's getter must
return the <span data-x="Unicode serialisation of an origin">Unicode serialization</span> of the
associated <span data-x="concept-WorkerLocation-WorkerGlobalScope"><code>WorkerGlobalScope</code>
object</span>'s <span data-x="concept-WorkerGlobalScope-url">url</span>'s <a
data-x="concept-url-origin">origin</a>.</p>

<p class="note no-backref">It returns the Unicode rather than the ASCII serialisation for
compatibility with <code>MessageEvent</code>.</p>

<p>The <dfn><code data-x="dom-WorkerLocation-protocol">protocol</code></dfn> attribute's getter
must run return the associated <span
data-x="concept-WorkerLocation-WorkerGlobalScope"><code>WorkerGlobalScope</code> object</span>'s
<span data-x="concept-WorkerGlobalScope-url">url</span>'s <span
data-x="concept-url-scheme">scheme</span>, followed by "<code data-x="">:</code>".</p>

<p>The <dfn><code data-x="dom-WorkerLocation-host">host</code></dfn> attribute's getter must run
these steps:</p>

<ol>
<li><p>Let <var>url</var> be the associated <span
data-x="concept-WorkerLocation-WorkerGlobalScope"><code>WorkerGlobalScope</code> object</span>'s
<span data-x="concept-WorkerGlobalScope-url">url</span>.</p></li>

<li><p>If <var>url</var>'s <span data-x="concept-url-host">host</span> is null, return the empty
string.</p></li>

<li><p>If <var>url</var>'s <span data-x="concept-url-port">port</span> is null, return
<var>url</var>'s <span data-x="concept-url-host">host</span>, <span data-x="host
serialiser">serialised</span>.</p></li>

<li><p>Return <var>url</var>'s <span data-x="concept-url-host">host</span>, <span data-x="host
serialiser">serialised</span>, followed by "<code data-x="">:</code>" and <var>url</var>'s <span
data-x="concept-url-port">port</span>, <span data-x="serialise an
integer">serialised</span>.</p></li>
</ol>

<p>The <dfn><code data-x="dom-WorkerLocation-hostname">hostname</code></dfn> attribute's getter
must run these steps:</p>

<ol>
<li><p>Let <var>host</var> be the associated <span
data-x="concept-WorkerLocation-WorkerGlobalScope"><code>WorkerGlobalScope</code> object</span>'s
<span data-x="concept-WorkerGlobalScope-url">url</span>'s <span
data-x="concept-url-host">host</span>.</p></li>

<li><p>If <var>host</var> is null, return the empty string.</p></li>

<li><p>Return <var>host</var> <span data-x="host serialiser">serialised</span>.</p></li>
</ol>

<p>The <dfn><code data-x="dom-WorkerLocation-port">port</code></dfn> attribute's getter must run
these steps:</p>

<ol>
<li><p>Let <var>port</var> be the <code>WorkerGlobalScope</code> object's <span
data-x="concept-WorkerGlobalScope-url">url</span>'s <span
data-x="concept-url-port">port</span>.</p></li>

<li><p>If <var>port</var> is null, return the empty string.</p></li>

<li><p>Return <var>port</var>, <span data-x="serialise an integer">serialised</span>.</p></li>
</ol>

<p>The <dfn><code data-x="dom-WorkerLocation-pathname">pathname</code></dfn> attribute's getter
must run these steps:</p>

<ol>
<li><p>Let <var>url</var> be the associated <span
data-x="concept-WorkerLocation-WorkerGlobalScope"><code>WorkerGlobalScope</code> object</span>'s
<span data-x="concept-WorkerGlobalScope-url">url</span>.</p></li>

<li><p>If <var>url</var>'s <span>non-relative flag</span> is set, return the first string in
<var>url</var>'s <span data-x="concept-url-path">path</span>.</p></li>

<p>A <code>WorkerLocation</code> object represents the <code>WorkerGlobalScope</code> object's
<span data-x="concept-WorkerGlobalScope-url">url</span>.
<li><p>Return "<code data-x="">/</code>", followed by the strings in <var>url</var>'s <span
data-x="concept-url-path">path</span> (including empty strings), separated from each other by
"<code data-x="">/</code>".</p></li>
</ol>

<p>The <dfn><code data-x="dom-WorkerLocation-search">search</code></dfn> attribute's getter must
run these steps:</p>

<p>The <code>WorkerLocation</code> interface supports the <code>URLUtilsReadOnly</code>
interface. <ref spec=URL></p>
<ol>
<li><p>Let <var>query</var> be the associated <span
data-x="concept-WorkerLocation-WorkerGlobalScope"><code>WorkerGlobalScope</code> object</span>'s
<span data-x="concept-WorkerGlobalScope-url">url</span>'s <span
data-x="concept-url-query">query</span>.</p></li>

<li><p>If <var>query</var> is either null or the empty string, return the empty string.</p></li>

<p>When the object is created, the user agent must invoke the element's
<code>URLUtilsReadOnly</code> interface's <span data-x="concept-uu-set-the-input">set the
input</span> algorithm with the <span>absolute URL</span> that the <code>WorkerLocation</code>
object represents as the given value.</p>
<li><p>Return "<code data-x="">?</code>", followed by <var>query</var>.</p></li>
</ol>

<p>The element's <code>URLUtilsReadOnly</code> interface's <span
data-x="concept-uu-get-the-base">get the base</span> algorithm must return null.</p>
<p>The <dfn><code data-x="dom-WorkerLocation-hash">hash</code></dfn> attribute's getter must run
these steps:</p>

<ol>
<li><p>Let <var>fragment</var> be the associated <span
data-x="concept-WorkerLocation-WorkerGlobalScope"><code>WorkerGlobalScope</code> object</span>'s
<span data-x="concept-WorkerGlobalScope-url">url</span>'s <span
data-x="concept-url-fragment">fragment</span>.</p></li>

<li><p>If <var>fragment</var> is either null or the empty string, return the empty string.</p></li>

<li><p>Return "<code data-x="">#</code>", followed by <var>fragment</var>.</p></li>
</ol>


<!--REMOVE-TOPIC:Workers-->
Expand Down

2 comments on commit 32a7a20

@ArkadiuszMichalski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So URLUtilsReadOnly in 2.2.2 Dependencies is no longer needed:
https://html.spec.whatwg.org/multipage/infrastructure.html#urlutilsreadonly

@annevk
Copy link
Member Author

@annevk annevk commented on 32a7a20 Oct 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ArkadiuszMichalski. Will fix it as part of #221.

Please sign in to comment.