Last Comment Bug 344615 - Implement <input type="url">
: Implement <input type="url">
Status: RESOLVED FIXED
[parity-opera]
: dev-doc-complete, html5
Product: Core
Classification: Components
Component: DOM: Core & HTML (show other bugs)
: Trunk
: All All
: -- normal with 5 votes (vote)
: mozilla2.0b5
Assigned To: Mounir Lamouri (:mounir)
:
Mentors:
http://www.whatwg.org/specs/web-forms...
Depends on: 345624 345822
Blocks: html5forms 561586 561620 562625 558370 558651 558788 559309 559745 561635 566348 581596 583610
  Show dependency treegraph
 
Reported: 2006-07-13 17:25 PDT by Alex Vincent [:WeirdAl]
Modified: 2010-11-03 14:44 PDT (History)
23 users (show)
mounir: in‑testsuite+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Tests v1 (6.75 KB, patch)
2010-04-17 17:24 PDT, Mounir Lamouri (:mounir)
no flags Details | Diff | Review
Patch v1 (16.72 KB, patch)
2010-04-17 17:28 PDT, Mounir Lamouri (:mounir)
no flags Details | Diff | Review
Tests v1.1 (8.59 KB, patch)
2010-04-20 05:06 PDT, Mounir Lamouri (:mounir)
jonas: review+
Details | Diff | Review
Patch v1.1 (18.12 KB, patch)
2010-04-20 05:07 PDT, Mounir Lamouri (:mounir)
jonas: review+
Details | Diff | Review
Tests v1.2 (8.94 KB, patch)
2010-04-25 04:16 PDT, Mounir Lamouri (:mounir)
no flags Details | Diff | Review
Patch v1.2 (18.14 KB, patch)
2010-04-25 04:18 PDT, Mounir Lamouri (:mounir)
bugs: superreview+
Details | Diff | Review
Patch v1.3 (27.13 KB, patch)
2010-07-28 07:02 PDT, Mounir Lamouri (:mounir)
no flags Details | Diff | Review
Patch v1.3 (26.65 KB, patch)
2010-08-01 11:05 PDT, Mounir Lamouri (:mounir)
no flags Details | Diff | Review

Description Alex Vincent [:WeirdAl] 2006-07-13 17:25:12 PDT
I'm willing to take a shot at implementing <input type="uri"> as described in Web Forms 2.0.
Comment 1 Alex Vincent [:WeirdAl] 2006-07-20 11:29:54 PDT
So I'm having a little trouble with overriding HTML layout.

http://mozilla.pastebin.ca/93708 XML binding (inputBinding.xml)
http://mozilla.pastebin.ca/93709 XHTML test page (inputBinding.xhtml)

The binding works for <implementation/> (I can execute a dump() safely via the constructor), but the <content/> of the binding never appears.

I did some preliminary debugging, and discovered nsCSSFrameConstructor::CreateInputFrame.  control->GetType() returns NS_FORM_INPUT_TEXT, and so CreateInputFrame proceeds to construct the HTML text input frame instead of the XBL-based layout I want.

roc, I think this is something you can help with.  I'm thinking this really is a separate bug, but I want someone who's familiar with layout to affirm that before I file.
Comment 2 Robert O'Callahan (:roc) (Exited; email my personal email if necessary) 2006-07-20 17:29:38 PDT
Yeah, nsCSSFrameConstructor needs to be changed. Ping me about it in a couple of weeks, OK?
Comment 3 Robert O'Callahan (:roc) (Exited; email my personal email if necessary) 2006-07-20 18:32:46 PDT
Actually, maybe it doesn't. Try changing the XBL base tag of your binding to something other than an HTML <input>, e.g., a <span>
Comment 4 Alex Vincent [:WeirdAl] 2006-07-20 18:57:27 PDT
If you mean change:

    <p>HTML input: 
      <input type="uri" size="20" value="http://www.w3.org"/>
    </p>

to

    <p>HTML input: 
      <span type="uri" size="20" value="http://www.w3.org"/>
    </p>

then yes, it does work, but it defeats the purpose of Web Forms 2.0 - which is about extending the HTML input types.

If you mean changing the binding from:

    <content>
      <html:input type="text" xbl:inherits="value,size"/>
      <xul:hbox><xul:button label="Test"/></xul:hbox>
    </content>

to:

    <content>
      <html:span>
        <html:input type="text" xbl:inherits="value,size"/>
        <xul:hbox><xul:button label="Test" oncommand="alert('button clicked')"/></xul:hbox>
      </html:span>
    </content>

That doesn't affect the layout of the HTML input widget at this point.
Comment 5 Robert O'Callahan (:roc) (Exited; email my personal email if necessary) 2006-07-20 19:20:32 PDT
I think I mean the latter.
Comment 6 Thomas K. (:tom) 2009-09-02 18:50:02 PDT
Gmail is now using this, and Opera supports it: http://my.opera.com/dbloom/blog/2009/09/02/secret-opera-only-feature-in-gmail
Comment 7 d 2010-02-19 07:42:40 PST
The way Opera has done it, with the autocomplete URL feature is very good. Do you think we could get the Awesomebar functionality in there? (And perhaps an icon, like Opera have too.)
Comment 8 Mounir Lamouri (:mounir) 2010-04-15 17:29:56 PDT
According to HTML5 specs, a valid URL is a valid URI (RFC3986) or a valid IRI (RFC3987). I'm wondering if url parser are following these RFC's.
I've seen only one comment related to one of these RFC's in the code base: http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.js#2183
Comment 9 Boris Zbarsky [:bz] 2010-04-15 19:30:57 PDT
I believe we implement more or less RFC 1738 last I checked.
Comment 10 Mounir Lamouri (:mounir) 2010-04-17 17:24:08 PDT
Created attachment 439737 [details] [diff] [review]
Tests v1
Comment 11 Mounir Lamouri (:mounir) 2010-04-17 17:28:19 PDT
Created attachment 439738 [details] [diff] [review]
Patch v1

This patch is unfortunately not checking the URI as the HTML5 specifications want it to. Considering the needed RFC's (3886 and 3987) are improving the RFC's we are following at the moment (see Boris' comment) it is probably better to check the URI as we can and improve that later.
Comment 12 Mounir Lamouri (:mounir) 2010-04-20 05:06:25 PDT
Created attachment 440191 [details] [diff] [review]
Tests v1.1

The tests are now adding url-related tests for the required attribute tests.
Comment 13 Mounir Lamouri (:mounir) 2010-04-20 05:07:20 PDT
Created attachment 440192 [details] [diff] [review]
Patch v1.1

This patch has to be applied on top of the required attribute patch (bug 34582).
Comment 14 Jonas Sicking (:sicking) 2010-04-20 16:57:00 PDT
Comment on attachment 440192 [details] [diff] [review]
Patch v1.1

>+    /**
>+     * TODO:
>+     * The URL is not checked as the HTML5 specifications want it to be because
>+     * there is no code to check for a valid URI/IRI according to 3986 and 3987
>+     * RFC's at the moment.
>+     *
>+     * RFC 3987 (IRI) implementation: bug 42899
>+     *
>+     * HTML5 specifications:
>+     * http://dev.w3.org/html5/spec/infrastructure.html#valid-url
>+     */

Could you file a bug and reference it here?


>@@ -3498,19 +3534,26 @@ nsHTMLInputElement::GetValidationMessage
>       rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
>                                               key.get(), message);
>       aValidationMessage = message;
>       break;
>     }
>     case VALIDATION_MESSAGE_TYPE_MISMATCH:
>     {
>       nsXPIDLString message;
>+      nsCAutoString key;
>+      if (mType == NS_FORM_INPUT_EMAIL) {
>+        key.Assign("ElementSuffersFromInvalidEmail");
>+      } else if (mType == NS_FORM_INPUT_URL) {
>+        key.Assign("ElementSuffersFromInvalidURL");
>+      } else {
>+        return NS_ERROR_UNEXPECTED;
>+      }

Use key.AssignLiteral(...)
Comment 15 Jonas Sicking (:sicking) 2010-04-20 16:59:17 PDT
Comment on attachment 440192 [details] [diff] [review]
Patch v1.1

With that, looks good.

Though please file a followup to create actual UI for this. We probably want to hook up the global history as validation.
Comment 16 Jonas Sicking (:sicking) 2010-04-20 17:01:08 PDT
Hmm.. though.. doesn't the spec require that the user can only enter valid URIs? In other words, if the user types something that isn't a valid uri then .value shouldn't be updated until this is corrected?
Comment 17 Mounir Lamouri (:mounir) 2010-04-20 17:06:24 PDT
(In reply to comment #16)
> Hmm.. though.. doesn't the spec require that the user can only enter valid
> URIs? In other words, if the user types something that isn't a valid uri then
> .value shouldn't be updated until this is corrected?

No, email and url types can suffer from type mismatch so the user can type anything. If this is not valid, the element will suffer from type mismatch. Input types which can't have a valid value are the ones with a specific UI which are number, range, color and all date/time ones.

And thank you for the review :)
Comment 18 Jonas Sicking (:sicking) 2010-04-20 17:06:28 PDT
Comment on attachment 440191 [details] [diff] [review]
Tests v1.1

Tests look good. Though we'll need tests for UI once that arrives.
Comment 19 Jonas Sicking (:sicking) 2010-04-20 17:32:07 PDT
Ah, you are indeed correct.

It does say though that the UA may "escape characters entered by the user so that the value is always a valid absolute URL" which I think would be cool to do. Though definitely not required in this bug.
Comment 20 Mounir Lamouri (:mounir) 2010-04-25 04:16:59 PDT
Created attachment 441348 [details] [diff] [review]
Tests v1.2

Minor changes in the tests: I've added a check for the invalid event.
Comment 21 Mounir Lamouri (:mounir) 2010-04-25 04:18:35 PDT
Created attachment 441349 [details] [diff] [review]
Patch v1.2

r=sicking

Requested changes have been done.
Comment 22 Mounir Lamouri (:mounir) 2010-07-28 07:02:54 PDT
Created attachment 460867 [details] [diff] [review]
Patch v1.3

Updated to apply against current tip.
Merged with test patch.
Comment 23 Mounir Lamouri (:mounir) 2010-08-01 11:05:55 PDT
Created attachment 461908 [details] [diff] [review]
Patch v1.3

In the last update, I've added value sanitizing related code and tests. This is now in bug 583610 to simplify the review process.
Comment 24 Mounir Lamouri (:mounir) 2010-08-19 14:22:38 PDT
This is now in the tree.
rev: http://hg.mozilla.org/mozilla-central/rev/acc8ccecdc90

Note You need to log in before you can comment on or make changes to this bug.