Attachment #509083: WIP Patch for bug #556743

View | Details | Raw Unified | Return to bug 556743
Collapse All | Expand All

(-)a/content/base/src/nsGkAtomList.h (+1 lines)
Line     Link Here 
 Lines 480-495   GK_ATOM(keepcurrentinview, "keepcurrenti Link Here 
480
GK_ATOM(key, "key")
480
GK_ATOM(key, "key")
481
GK_ATOM(keycode, "keycode")
481
GK_ATOM(keycode, "keycode")
482
GK_ATOM(keydown, "keydown")
482
GK_ATOM(keydown, "keydown")
483
GK_ATOM(keypress, "keypress")
483
GK_ATOM(keypress, "keypress")
484
GK_ATOM(keyset, "keyset")
484
GK_ATOM(keyset, "keyset")
485
GK_ATOM(keytext, "keytext")
485
GK_ATOM(keytext, "keytext")
486
GK_ATOM(keyup, "keyup")
486
GK_ATOM(keyup, "keyup")
487
GK_ATOM(label, "label")
487
GK_ATOM(label, "label")
488
GK_ATOM(labels, "labels")
488
GK_ATOM(lang, "lang")
489
GK_ATOM(lang, "lang")
489
GK_ATOM(last, "last")
490
GK_ATOM(last, "last")
490
GK_ATOM(layer, "layer")
491
GK_ATOM(layer, "layer")
491
GK_ATOM(layout, "layout")
492
GK_ATOM(layout, "layout")
492
GK_ATOM(leading, "leading")
493
GK_ATOM(leading, "leading")
493
GK_ATOM(leaf, "leaf")
494
GK_ATOM(leaf, "leaf")
494
GK_ATOM(left, "left")
495
GK_ATOM(left, "left")
495
GK_ATOM(leftmargin, "leftmargin")
496
GK_ATOM(leftmargin, "leftmargin")
(-)a/content/html/content/public/Makefile.in (+1 lines)
Line     Link Here 
 Lines 62-72   EXPORTS = \ Link Here 
62
		nsIFileControlElement.h \
62
		nsIFileControlElement.h \
63
		nsFormSubmission.h \
63
		nsFormSubmission.h \
64
		nsIFrameSetElement.h \
64
		nsIFrameSetElement.h \
65
		nsHTMLAudioElement.h \
65
		nsHTMLAudioElement.h \
66
		nsHTMLCanvasElement.h \
66
		nsHTMLCanvasElement.h \
67
		nsHTMLMediaElement.h \
67
		nsHTMLMediaElement.h \
68
		nsHTMLVideoElement.h \
68
		nsHTMLVideoElement.h \
69
		nsIHTMLCollection.h \
69
		nsIHTMLCollection.h \
70
		nsILabelableElement.h \
70
		$(NULL)
71
		$(NULL)
71
72
72
include $(topsrcdir)/config/rules.mk
73
include $(topsrcdir)/config/rules.mk
(-)a/content/html/content/public/nsILabelableElement.h (+155 lines)
Line     Link Here 
Line 0    Link Here 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version
6
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 * the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/MPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is mozilla.org code.
16
 *
17
 * The Initial Developer of the Original Code is Mozilla Foundation
18
 * Portions created by the Initial Developer are Copyright (C) 2010
19
 * the Initial Developer. All Rights Reserved.
20
 *
21
 * Contributor(s):
22
 *   Mounir Lamouri <mounir.lamouri@mozilla.com> (original author)
23
 *
24
 * Alternatively, the contents of this file may be used under the terms of
25
 * either of the GNU General Public License Version 2 or later (the "GPL"),
26
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 * of those above. If you wish to allow use of your version of this file only
29
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 * use your version of this file under the terms of the MPL, indicate your
31
 * decision by deleting the provisions above and replace them with the notice
32
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 * the provisions above, a recipient may use your version of this file under
34
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 *
36
 * ***** END LICENSE BLOCK ***** */
37
38
#ifndef nsILabelableElement_h___
39
#define nsILabelableElement_h___
40
41
#include "nsISupports.h"
42
#include "nsIContent.h"
43
44
class nsHTMLLabelElement;
45
46
#define NS_ILABELABLEELEMENT_IID \
47
{ 0x6108a3d2, 0xf607, 0x4215, \
48
 { 0xa6, 0xdc, 0xa3, 0xb7, 0xca, 0x1e, 0x0c, 0x8e } }
49
50
51
/**
52
 * Interface which labelable form controls have to use.
53
 */
54
class nsILabelableElement : public nsISupports
55
{
56
public:
57
58
  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILABELABLEELEMENT_IID);
59
60
  void AppendLabel(nsIContent* aContent)
61
  {
62
//    mLabelList.AppendElement(aContent);
63
  }
64
65
  void RemoveLabel(nsIContent* aContent)
66
  {
67
//    mLabelList.RemoveElement(aContent);
68
  }
69
70
protected:
71
72
  nsILabelableElement() { }
73
74
  virtual ~nsILabelableElement() { }
75
76
//  nsBaseContentList   mLabelList;
77
78
//private:
79
80
  class nsLabelsCollection : public nsIDOMHTMLCollection
81
  {
82
  public:
83
    NS_DECL_ISUPPORTS_INHERITED
84
85
    // nsIDOMHTMLCollection implementation.
86
    nsresult GetLength(PRUint32 *aValue)
87
    {
88
      *aValue = mElements.Count();
89
      return NS_OK;
90
    }
91
92
    nsresult Item(PRUint32 aIndex, nsIDOMNode** aNode)
93
    {
94
      *aNode = static_cast<nsIDOMNode*>(mElements.ElementAt(aIndex));
95
      return NS_OK;
96
    }
97
98
    nsresult NamedItem(const nsAString& aName, nsIDOMNode** aNode)
99
    {
100
      PRUint32 size = mElements.Count();
101
102
      nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
103
      NS_ENSURE_TRUE(name, NS_ERROR_UNEXPECTED);
104
105
      for (PRUint32 i=0; i<size; ++i) {
106
        nsIContent* content =
107
          static_cast<nsIContent*>(mElements.FastElementAt(i));
108
        if (content && content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id,
109
                                            name, eCaseMatters)) {
110
          //*aNode = static_cast<nsIDOMNode*>(content);
111
          printf(" === found something\n");
112
          return NS_OK;
113
        }
114
      }
115
116
      return NS_OK;
117
    }
118
119
    void AppendLabel(nsHTMLLabelElement* aLabel)
120
    {
121
#ifdef DEBUG
122
      PRBool res =
123
#endif // DEBUG
124
      mElements.AppendElement(aLabel);
125
#ifdef DEBUG
126
      if (!res) {
127
        NS_WARNING("The label was not added to nsLabelCollection! Why?");
128
      }
129
#endif // DEBUG
130
    }
131
132
    void RemoveLabel(nsHTMLLabelElement* aLabel)
133
    {
134
#ifdef DEBUG
135
      PRBool res =
136
#endif // DEBUG
137
      mElements.RemoveElement(aLabel);
138
#ifdef DEBUG
139
      if (!res) {
140
        NS_WARNING("The label was not removed from nsLabelCollection! Not present?");
141
      }
142
#endif // DEBUG
143
    }
144
145
  protected:
146
    nsVoidArray mElements;
147
  };
148
149
  nsLabelsCollection mLabels;
150
};
151
152
NS_DEFINE_STATIC_IID_ACCESSOR(nsILabelableElement, NS_ILABELABLEELEMENT_IID)
153
154
#endif /* nsILabelableElement_h___ */
155
(-)a/content/html/content/src/nsGenericHTMLElement.cpp (-6 / +8 lines)
Line     Link Here 
 Lines 2715-2747   nsGenericHTMLFormElement::IsSingleLineTe Link Here 
2715
{
2715
{
2716
  return IsSingleLineTextControlInternal(aExcludePassword, GetType());
2716
  return IsSingleLineTextControlInternal(aExcludePassword, GetType());
2717
}
2717
}
2718
2718
2719
PRBool
2719
PRBool
2720
nsGenericHTMLFormElement::IsLabelableControl() const
2720
nsGenericHTMLFormElement::IsLabelableControl() const
2721
{
2721
{
2722
  // Check for non-labelable form controls as they are not numerous.
2722
  // Check for non-labelable form controls as they are not numerous.
2723
  // TODO: datalist should be added to this list.
2723
  // TODO: Add keygen, meter, progress when implemented.
2724
  PRInt32 type = GetType();
2724
  PRInt32 type = GetType();
2725
  return type != NS_FORM_FIELDSET &&
2725
  return (type & NS_FORM_BUTTON_ELEMENT) != 0 ||
2726
         type != NS_FORM_LABEL &&
2726
         (type & NS_FORM_INPUT_ELEMENT) != 0 ||
2727
         type != NS_FORM_OBJECT;
2727
         type == NS_FORM_OUTPUT ||
2728
         type == NS_FORM_SELECT ||
2729
         type == NS_FORM_TEXTAREA;
2728
}
2730
}
2729
2731
2730
PRBool
2732
PRBool
2731
nsGenericHTMLFormElement::IsSubmittableControl() const
2733
nsGenericHTMLFormElement::IsSubmittableControl() const
2732
{
2734
{
2733
  // TODO: keygen should be in that list, see bug 101019.
2735
  // TODO: keygen should be in that list, see bug 101019.
2734
  PRInt32 type = GetType();
2736
  PRInt32 type = GetType();
2735
  return type == NS_FORM_OBJECT ||
2737
  return type == NS_FORM_OBJECT ||
2736
         type == NS_FORM_TEXTAREA ||
2738
         type == NS_FORM_TEXTAREA ||
2737
         type == NS_FORM_SELECT ||
2739
         type == NS_FORM_SELECT ||
2738
         type & NS_FORM_BUTTON_ELEMENT ||
2740
         (type & NS_FORM_BUTTON_ELEMENT) != 0 ||
2739
         type & NS_FORM_INPUT_ELEMENT;
2741
         (type & NS_FORM_INPUT_ELEMENT) != 0;
2740
}
2742
}
2741
2743
2742
PRInt32
2744
PRInt32
2743
nsGenericHTMLFormElement::IntrinsicState() const
2745
nsGenericHTMLFormElement::IntrinsicState() const
2744
{
2746
{
2745
  // If you add attribute-dependent states here, you need to add them them to
2747
  // If you add attribute-dependent states here, you need to add them them to
2746
  // AfterSetAttr too.  And add them to AfterSetAttr for all subclasses that
2748
  // AfterSetAttr too.  And add them to AfterSetAttr for all subclasses that
2747
  // implement IntrinsicState() and are affected by that attribute.
2749
  // implement IntrinsicState() and are affected by that attribute.
(-)a/content/html/content/src/nsGenericHTMLElement.h (+12 lines)
Line     Link Here 
 Lines 1275-1290   NS_NewHTML##_elementName##Element(alread Link Here 
1275
    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
1275
    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
1276
    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
1276
    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
1277
    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
1277
    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
1278
    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
1278
    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
1279
    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
1279
    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
1280
    NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
1280
    NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
1281
  NS_OFFSET_AND_INTERFACE_TABLE_END
1281
  NS_OFFSET_AND_INTERFACE_TABLE_END
1282
1282
1283
#define NS_HTML_CONTENT_INTERFACE_TABLE7(_class, _i1, _i2, _i3, _i4, _i5,     \
1284
                                         _i6, _i7)                            \
1285
  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
1286
    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
1287
    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
1288
    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
1289
    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
1290
    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
1291
    NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
1292
    NS_INTERFACE_TABLE_ENTRY(_class, _i7)                                     \
1293
  NS_OFFSET_AND_INTERFACE_TABLE_END
1294
1283
#define NS_HTML_CONTENT_INTERFACE_TABLE8(_class, _i1, _i2, _i3, _i4, _i5,     \
1295
#define NS_HTML_CONTENT_INTERFACE_TABLE8(_class, _i1, _i2, _i3, _i4, _i5,     \
1284
                                         _i6, _i7, _i8)                       \
1296
                                         _i6, _i7, _i8)                       \
1285
  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
1297
  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
1286
    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
1298
    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
1287
    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
1299
    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
1288
    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
1300
    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
1289
    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
1301
    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
1290
    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
1302
    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
(-)a/content/html/content/src/nsHTMLButtonElement.cpp (-3 / +14 lines)
Line     Link Here 
 Lines 58-90    Link Here 
58
#include "nsUnicharUtils.h"
58
#include "nsUnicharUtils.h"
59
#include "nsLayoutUtils.h"
59
#include "nsLayoutUtils.h"
60
#include "nsEventDispatcher.h"
60
#include "nsEventDispatcher.h"
61
#include "nsPresState.h"
61
#include "nsPresState.h"
62
#include "nsLayoutErrors.h"
62
#include "nsLayoutErrors.h"
63
#include "nsFocusManager.h"
63
#include "nsFocusManager.h"
64
#include "nsHTMLFormElement.h"
64
#include "nsHTMLFormElement.h"
65
#include "nsIConstraintValidation.h"
65
#include "nsIConstraintValidation.h"
66
#include "nsILabelableElement.h"
66
67
67
#define NS_IN_SUBMIT_CLICK      (1 << 0)
68
#define NS_IN_SUBMIT_CLICK      (1 << 0)
68
#define NS_OUTER_ACTIVATE_EVENT (1 << 1)
69
#define NS_OUTER_ACTIVATE_EVENT (1 << 1)
69
70
70
static const nsAttrValue::EnumTable kButtonTypeTable[] = {
71
static const nsAttrValue::EnumTable kButtonTypeTable[] = {
71
  { "button", NS_FORM_BUTTON_BUTTON },
72
  { "button", NS_FORM_BUTTON_BUTTON },
72
  { "reset", NS_FORM_BUTTON_RESET },
73
  { "reset", NS_FORM_BUTTON_RESET },
73
  { "submit", NS_FORM_BUTTON_SUBMIT },
74
  { "submit", NS_FORM_BUTTON_SUBMIT },
74
  { 0 }
75
  { 0 }
75
};
76
};
76
77
77
// Default type is 'submit'.
78
// Default type is 'submit'.
78
static const nsAttrValue::EnumTable* kButtonDefaultType = &kButtonTypeTable[2];
79
static const nsAttrValue::EnumTable* kButtonDefaultType = &kButtonTypeTable[2];
79
80
80
class nsHTMLButtonElement : public nsGenericHTMLFormElement,
81
class nsHTMLButtonElement : public nsGenericHTMLFormElement,
81
                            public nsIDOMHTMLButtonElement,
82
                            public nsIDOMHTMLButtonElement,
82
                            public nsIConstraintValidation
83
                            public nsIConstraintValidation,
84
                            public nsILabelableElement
83
{
85
{
84
public:
86
public:
85
  nsHTMLButtonElement(already_AddRefed<nsINodeInfo> aNodeInfo);
87
  nsHTMLButtonElement(already_AddRefed<nsINodeInfo> aNodeInfo);
86
  virtual ~nsHTMLButtonElement();
88
  virtual ~nsHTMLButtonElement();
87
89
88
  // nsISupports
90
  // nsISupports
89
  NS_DECL_ISUPPORTS_INHERITED
91
  NS_DECL_ISUPPORTS_INHERITED
90
92
 Lines 178-196   nsHTMLButtonElement::~nsHTMLButtonElemen Link Here 
178
NS_IMPL_ADDREF_INHERITED(nsHTMLButtonElement, nsGenericElement)
180
NS_IMPL_ADDREF_INHERITED(nsHTMLButtonElement, nsGenericElement)
179
NS_IMPL_RELEASE_INHERITED(nsHTMLButtonElement, nsGenericElement)
181
NS_IMPL_RELEASE_INHERITED(nsHTMLButtonElement, nsGenericElement)
180
182
181
183
182
DOMCI_NODE_DATA(HTMLButtonElement, nsHTMLButtonElement)
184
DOMCI_NODE_DATA(HTMLButtonElement, nsHTMLButtonElement)
183
185
184
// QueryInterface implementation for nsHTMLButtonElement
186
// QueryInterface implementation for nsHTMLButtonElement
185
NS_INTERFACE_TABLE_HEAD(nsHTMLButtonElement)
187
NS_INTERFACE_TABLE_HEAD(nsHTMLButtonElement)
186
  NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLButtonElement,
188
  NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLButtonElement,
187
                                   nsIDOMHTMLButtonElement,
189
                                   nsIDOMHTMLButtonElement,
188
                                   nsIConstraintValidation)
190
                                   nsIConstraintValidation,
191
                                   nsILabelableElement)
189
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLButtonElement,
192
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLButtonElement,
190
                                               nsGenericHTMLFormElement)
193
                                               nsGenericHTMLFormElement)
191
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLButtonElement)
194
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLButtonElement)
192
195
193
// nsIConstraintValidation
196
// nsIConstraintValidation
194
NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLButtonElement)
197
NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLButtonElement)
195
198
196
// nsIDOMHTMLButtonElement
199
// nsIDOMHTMLButtonElement
 Lines 202-217   NS_IMPL_ELEMENT_CLONE(nsHTMLButtonElemen Link Here 
202
// nsIDOMHTMLButtonElement
205
// nsIDOMHTMLButtonElement
203
206
204
NS_IMETHODIMP
207
NS_IMETHODIMP
205
nsHTMLButtonElement::GetForm(nsIDOMHTMLFormElement** aForm)
208
nsHTMLButtonElement::GetForm(nsIDOMHTMLFormElement** aForm)
206
{
209
{
207
  return nsGenericHTMLFormElement::GetForm(aForm);
210
  return nsGenericHTMLFormElement::GetForm(aForm);
208
}
211
}
209
212
213
NS_IMETHODIMP
214
nsHTMLButtonElement::GetLabels(nsIDOMHTMLCollection** aLabels)
215
{
216
  *aLabels = nsnull;
217
218
  return NS_OK;
219
}
220
210
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, AccessKey, accesskey)
221
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, AccessKey, accesskey)
211
NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Autofocus, autofocus)
222
NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Autofocus, autofocus)
212
NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Disabled, disabled)
223
NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Disabled, disabled)
213
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, FormAction, formaction)
224
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, FormAction, formaction)
214
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLButtonElement, FormEnctype, formenctype,
225
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLButtonElement, FormEnctype, formenctype,
215
                                kFormDefaultEnctype->tag)
226
                                kFormDefaultEnctype->tag)
216
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLButtonElement, FormMethod, formmethod,
227
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLButtonElement, FormMethod, formmethod,
217
                                kFormDefaultMethod->tag)
228
                                kFormDefaultMethod->tag)
(-)a/content/html/content/src/nsHTMLInputElement.cpp (-10 / +21 lines)
Line     Link Here 
 Lines 292-317   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END Link Here 
292
NS_IMPL_ADDREF_INHERITED(nsHTMLInputElement, nsGenericElement) 
292
NS_IMPL_ADDREF_INHERITED(nsHTMLInputElement, nsGenericElement) 
293
NS_IMPL_RELEASE_INHERITED(nsHTMLInputElement, nsGenericElement) 
293
NS_IMPL_RELEASE_INHERITED(nsHTMLInputElement, nsGenericElement) 
294
294
295
295
296
DOMCI_NODE_DATA(HTMLInputElement, nsHTMLInputElement)
296
DOMCI_NODE_DATA(HTMLInputElement, nsHTMLInputElement)
297
297
298
// QueryInterface implementation for nsHTMLInputElement
298
// QueryInterface implementation for nsHTMLInputElement
299
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLInputElement)
299
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLInputElement)
300
  NS_HTML_CONTENT_INTERFACE_TABLE9(nsHTMLInputElement,
300
  NS_HTML_CONTENT_INTERFACE_TABLE10(nsHTMLInputElement,
301
                                   nsIDOMHTMLInputElement,
301
                                    nsIDOMHTMLInputElement,
302
                                   nsITextControlElement,
302
                                    nsITextControlElement,
303
                                   nsIFileControlElement,
303
                                    nsIFileControlElement,
304
                                   nsIPhonetic,
304
                                    nsIPhonetic,
305
                                   imgIDecoderObserver,
305
                                    imgIDecoderObserver,
306
                                   nsIImageLoadingContent,
306
                                    nsIImageLoadingContent,
307
                                   imgIContainerObserver,
307
                                    imgIContainerObserver,
308
                                   nsIDOMNSEditableElement,
308
                                    nsIDOMNSEditableElement,
309
                                   nsIConstraintValidation)
309
                                    nsIConstraintValidation,
310
                                    nsILabelableElement)
310
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLInputElement,
311
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLInputElement,
311
                                               nsGenericHTMLFormElement)
312
                                               nsGenericHTMLFormElement)
312
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLInputElement)
313
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLInputElement)
313
314
314
// nsIConstraintValidation
315
// nsIConstraintValidation
315
NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLInputElement)
316
NS_IMPL_NSICONSTRAINTVALIDATION_EXCEPT_SETCUSTOMVALIDITY(nsHTMLInputElement)
316
317
317
// nsIDOMNode
318
// nsIDOMNode
 Lines 2422-2437   nsHTMLInputElement::GetPhonetic(nsAStrin Link Here 
2422
    nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
2423
    nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
2423
    if (textControlFrame)
2424
    if (textControlFrame)
2424
      textControlFrame->GetPhonetic(aPhonetic);
2425
      textControlFrame->GetPhonetic(aPhonetic);
2425
  }
2426
  }
2426
2427
2427
  return NS_OK;
2428
  return NS_OK;
2428
}
2429
}
2429
2430
2431
NS_IMETHODIMP
2432
nsHTMLInputElement::GetLabels(nsIDOMHTMLCollection** aLabels)
2433
{
2434
  *aLabels = nsnull;
2435
  // Use mLabelList from nsILabelableElement.
2436
  NS_IF_ADDREF(*aLabels = &mLabels);
2437
2438
  return NS_OK;
2439
}
2440
2430
#ifdef ACCESSIBILITY
2441
#ifdef ACCESSIBILITY
2431
/*static*/ nsresult
2442
/*static*/ nsresult
2432
FireEventForAccessibility(nsIDOMHTMLInputElement* aTarget,
2443
FireEventForAccessibility(nsIDOMHTMLInputElement* aTarget,
2433
                          nsPresContext* aPresContext,
2444
                          nsPresContext* aPresContext,
2434
                          const nsAString& aEventType)
2445
                          const nsAString& aEventType)
2435
{
2446
{
2436
  nsCOMPtr<nsIDOMEvent> event;
2447
  nsCOMPtr<nsIDOMEvent> event;
2437
  if (NS_SUCCEEDED(nsEventDispatcher::CreateEvent(aPresContext, nsnull,
2448
  if (NS_SUCCEEDED(nsEventDispatcher::CreateEvent(aPresContext, nsnull,
(-)a/content/html/content/src/nsHTMLInputElement.h (-1 / +3 lines)
Line     Link Here 
 Lines 45-60    Link Here 
45
#include "nsITextControlElement.h"
45
#include "nsITextControlElement.h"
46
#include "nsIPhonetic.h"
46
#include "nsIPhonetic.h"
47
#include "nsIDOMNSEditableElement.h"
47
#include "nsIDOMNSEditableElement.h"
48
#include "nsIFileControlElement.h"
48
#include "nsIFileControlElement.h"
49
49
50
#include "nsTextEditorState.h"
50
#include "nsTextEditorState.h"
51
#include "nsCOMPtr.h"
51
#include "nsCOMPtr.h"
52
#include "nsIConstraintValidation.h"
52
#include "nsIConstraintValidation.h"
53
#include "nsILabelableElement.h"
53
54
54
//
55
//
55
// Accessors for mBitField
56
// Accessors for mBitField
56
//
57
//
57
#define BF_DISABLED_CHANGED 0
58
#define BF_DISABLED_CHANGED 0
58
#define BF_HANDLING_CLICK 1
59
#define BF_HANDLING_CLICK 1
59
#define BF_VALUE_CHANGED 2
60
#define BF_VALUE_CHANGED 2
60
#define BF_CHECKED_CHANGED 3
61
#define BF_CHECKED_CHANGED 3
 Lines 77-93   class nsDOMFileList; Link Here 
77
78
78
class nsHTMLInputElement : public nsGenericHTMLFormElement,
79
class nsHTMLInputElement : public nsGenericHTMLFormElement,
79
                           public nsImageLoadingContent,
80
                           public nsImageLoadingContent,
80
                           public nsIDOMHTMLInputElement,
81
                           public nsIDOMHTMLInputElement,
81
                           public nsITextControlElement,
82
                           public nsITextControlElement,
82
                           public nsIPhonetic,
83
                           public nsIPhonetic,
83
                           public nsIDOMNSEditableElement,
84
                           public nsIDOMNSEditableElement,
84
                           public nsIFileControlElement,
85
                           public nsIFileControlElement,
85
                           public nsIConstraintValidation
86
                           public nsIConstraintValidation,
87
                           public nsILabelableElement
86
{
88
{
87
public:
89
public:
88
  nsHTMLInputElement(already_AddRefed<nsINodeInfo> aNodeInfo,
90
  nsHTMLInputElement(already_AddRefed<nsINodeInfo> aNodeInfo,
89
                     PRUint32 aFromParser);
91
                     PRUint32 aFromParser);
90
  virtual ~nsHTMLInputElement();
92
  virtual ~nsHTMLInputElement();
91
93
92
  // nsISupports
94
  // nsISupports
93
  NS_DECL_ISUPPORTS_INHERITED
95
  NS_DECL_ISUPPORTS_INHERITED
(-)a/content/html/content/src/nsHTMLLabelElement.cpp (-4 / +39 lines)
Line     Link Here 
 Lines 90-115   public: Link Here 
90
90
91
  virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
91
  virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
92
92
93
  nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
93
  nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
94
                   const nsAString& aValue, PRBool aNotify)
94
                   const nsAString& aValue, PRBool aNotify)
95
  {
95
  {
96
    return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
96
    return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
97
  }
97
  }
98
  virtual nsresult BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
99
                                 const nsAString* aValue, PRBool aNotify);
98
  virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
100
  virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
99
                           nsIAtom* aPrefix, const nsAString& aValue,
101
                           nsIAtom* aPrefix, const nsAString& aValue,
100
                           PRBool aNotify);
102
                           PRBool aNotify);
103
  virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
104
                                const nsAString* aValue, PRBool aNotify);
101
  virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
105
  virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
102
                             PRBool aNotify);
106
                             PRBool aNotify);
103
  virtual void PerformAccesskey(PRBool aKeyCausesActivation,
107
  virtual void PerformAccesskey(PRBool aKeyCausesActivation,
104
                                PRBool aIsTrustedEvent);
108
                                PRBool aIsTrustedEvent);
105
  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
109
  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
106
110
107
  virtual nsXPCClassInfo* GetClassInfo();
111
  virtual nsXPCClassInfo* GetClassInfo();
112
108
protected:
113
protected:
109
  already_AddRefed<nsIContent> GetControlContent();
114
  already_AddRefed<nsIContent> GetControlContent();
110
  already_AddRefed<nsIContent> GetFirstFormControl(nsIContent *current);
115
  already_AddRefed<nsIContent> GetFirstFormControl(nsIContent *current);
111
116
112
  // XXX It would be nice if we could use an event flag instead.
117
  // XXX It would be nice if we could use an event flag instead.
113
  PRPackedBool mHandlingEvent;
118
  PRPackedBool mHandlingEvent;
114
};
119
};
115
120
 Lines 126-145   nsHTMLLabelElement::nsHTMLLabelElement(a Link Here 
126
}
131
}
127
132
128
nsHTMLLabelElement::~nsHTMLLabelElement()
133
nsHTMLLabelElement::~nsHTMLLabelElement()
129
{
134
{
130
}
135
}
131
136
132
// nsISupports 
137
// nsISupports 
133
138
134
139
NS_IMPL_ADDREF_INHERITED(nsHTMLLabelElement, nsGenericElement)
135
NS_IMPL_ADDREF_INHERITED(nsHTMLLabelElement, nsGenericElement) 
140
NS_IMPL_RELEASE_INHERITED(nsHTMLLabelElement, nsGenericElement)
136
NS_IMPL_RELEASE_INHERITED(nsHTMLLabelElement, nsGenericElement) 
137
138
141
139
DOMCI_NODE_DATA(HTMLLabelElement, nsHTMLLabelElement)
142
DOMCI_NODE_DATA(HTMLLabelElement, nsHTMLLabelElement)
140
143
141
// QueryInterface implementation for nsHTMLLabelElement
144
// QueryInterface implementation for nsHTMLLabelElement
142
NS_INTERFACE_TABLE_HEAD(nsHTMLLabelElement)
145
NS_INTERFACE_TABLE_HEAD(nsHTMLLabelElement)
143
  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLLabelElement,
146
  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLLabelElement,
144
                                   nsIDOMHTMLLabelElement)
147
                                   nsIDOMHTMLLabelElement)
145
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLabelElement,
148
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLabelElement,
 Lines 200-225   nsHTMLLabelElement::BindToTree(nsIDocume Link Here 
200
                                                     aBindingParent,
203
                                                     aBindingParent,
201
                                                     aCompileEventHandlers);
204
                                                     aCompileEventHandlers);
202
  NS_ENSURE_SUCCESS(rv, rv);
205
  NS_ENSURE_SUCCESS(rv, rv);
203
206
204
  if (aDocument) {
207
  if (aDocument) {
205
    RegAccessKey();
208
    RegAccessKey();
206
  }
209
  }
207
210
211
  if (HasAttr(kNameSpaceID_None, nsGkAtoms::_for)) {
212
    printf(" === added to tree with @for\n");
213
  }
214
208
  return rv;
215
  return rv;
209
}
216
}
210
217
211
void
218
void
212
nsHTMLLabelElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
219
nsHTMLLabelElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
213
{
220
{
214
  if (IsInDoc()) {
221
  if (IsInDoc()) {
215
    UnregAccessKey();
222
    UnregAccessKey();
216
  }
223
  }
217
224
225
  if (HasAttr(kNameSpaceID_None, nsGkAtoms::_for)) {
226
    printf(" === removed from the tree with @for\n");
227
  }
228
218
  nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
229
  nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent);
219
}
230
}
220
231
221
static PRBool
232
static PRBool
222
EventTargetIn(nsEvent *aEvent, nsIContent *aChild, nsIContent *aStop)
233
EventTargetIn(nsEvent *aEvent, nsIContent *aChild, nsIContent *aStop)
223
{
234
{
224
  nsCOMPtr<nsIContent> c = do_QueryInterface(aEvent->target);
235
  nsCOMPtr<nsIContent> c = do_QueryInterface(aEvent->target);
225
  nsIContent *content = c;
236
  nsIContent *content = c;
 Lines 346-361   nsHTMLLabelElement::Reset() Link Here 
346
357
347
NS_IMETHODIMP
358
NS_IMETHODIMP
348
nsHTMLLabelElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
359
nsHTMLLabelElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
349
{
360
{
350
  return NS_OK;
361
  return NS_OK;
351
}
362
}
352
363
353
nsresult
364
nsresult
365
nsHTMLLabelElement::BeforeSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
366
                                  const nsAString* aValue, PRBool aNotify)
367
{
368
  if (aName == nsGkAtoms::_for) {
369
    printf(" === before set @for\n");
370
  }
371
372
  return nsGenericHTMLFormElement::BeforeSetAttr(aNameSpaceID, aName, aValue,
373
                                                 aNotify);
374
}
375
376
nsresult
354
nsHTMLLabelElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix,
377
nsHTMLLabelElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix,
355
                            const nsAString& aValue, PRBool aNotify)
378
                            const nsAString& aValue, PRBool aNotify)
356
{
379
{
357
  if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID) {
380
  if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID) {
358
    UnregAccessKey();
381
    UnregAccessKey();
359
  }
382
  }
360
383
361
  nsresult rv =
384
  nsresult rv =
 Lines 367-382   nsHTMLLabelElement::SetAttr(PRInt32 aNam Link Here 
367
    SetFlags(NODE_HAS_ACCESSKEY);
390
    SetFlags(NODE_HAS_ACCESSKEY);
368
    RegAccessKey();
391
    RegAccessKey();
369
  }
392
  }
370
393
371
  return rv;
394
  return rv;
372
}
395
}
373
396
374
nsresult
397
nsresult
398
nsHTMLLabelElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
399
                                 const nsAString* aValue, PRBool aNotify)
400
{
401
  if (aName == nsGkAtoms::_for) {
402
    printf(" === after set @for\n");
403
  }
404
405
  return nsGenericHTMLFormElement::AfterSetAttr(aNameSpaceID, aName, aValue,
406
                                                aNotify);
407
}
408
409
nsresult
375
nsHTMLLabelElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
410
nsHTMLLabelElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
376
                              PRBool aNotify)
411
                              PRBool aNotify)
377
{
412
{
378
  if (aAttribute == nsGkAtoms::accesskey &&
413
  if (aAttribute == nsGkAtoms::accesskey &&
379
      kNameSpaceID_None == aNameSpaceID) {
414
      kNameSpaceID_None == aNameSpaceID) {
380
    // Have to unregister before clearing flag. See UnregAccessKey
415
    // Have to unregister before clearing flag. See UnregAccessKey
381
    UnregAccessKey();
416
    UnregAccessKey();
382
    UnsetFlags(NODE_HAS_ACCESSKEY);
417
    UnsetFlags(NODE_HAS_ACCESSKEY);
(-)a/content/html/content/src/nsHTMLOutputElement.cpp (-3 / +14 lines)
Line     Link Here 
 Lines 36-57    Link Here 
36
 * ***** END LICENSE BLOCK ***** */
36
 * ***** END LICENSE BLOCK ***** */
37
37
38
#include "nsIDOMHTMLOutputElement.h"
38
#include "nsIDOMHTMLOutputElement.h"
39
#include "nsGenericHTMLElement.h"
39
#include "nsGenericHTMLElement.h"
40
#include "nsFormSubmission.h"
40
#include "nsFormSubmission.h"
41
#include "nsDOMSettableTokenList.h"
41
#include "nsDOMSettableTokenList.h"
42
#include "nsStubMutationObserver.h"
42
#include "nsStubMutationObserver.h"
43
#include "nsIConstraintValidation.h"
43
#include "nsIConstraintValidation.h"
44
#include "nsILabelableElement.h"
44
45
45
46
46
class nsHTMLOutputElement : public nsGenericHTMLFormElement,
47
class nsHTMLOutputElement : public nsGenericHTMLFormElement,
47
                            public nsIDOMHTMLOutputElement,
48
                            public nsIDOMHTMLOutputElement,
48
                            public nsStubMutationObserver,
49
                            public nsStubMutationObserver,
49
                            public nsIConstraintValidation
50
                            public nsIConstraintValidation,
51
                            public nsILabelableElement
50
{
52
{
51
public:
53
public:
52
  nsHTMLOutputElement(already_AddRefed<nsINodeInfo> aNodeInfo);
54
  nsHTMLOutputElement(already_AddRefed<nsINodeInfo> aNodeInfo);
53
  virtual ~nsHTMLOutputElement();
55
  virtual ~nsHTMLOutputElement();
54
56
55
  // nsISupports
57
  // nsISupports
56
  NS_DECL_ISUPPORTS_INHERITED
58
  NS_DECL_ISUPPORTS_INHERITED
57
59
 Lines 125-144   nsHTMLOutputElement::~nsHTMLOutputElemen Link Here 
125
127
126
128
127
NS_IMPL_ADDREF_INHERITED(nsHTMLOutputElement, nsGenericElement)
129
NS_IMPL_ADDREF_INHERITED(nsHTMLOutputElement, nsGenericElement)
128
NS_IMPL_RELEASE_INHERITED(nsHTMLOutputElement, nsGenericElement)
130
NS_IMPL_RELEASE_INHERITED(nsHTMLOutputElement, nsGenericElement)
129
131
130
DOMCI_NODE_DATA(HTMLOutputElement, nsHTMLOutputElement)
132
DOMCI_NODE_DATA(HTMLOutputElement, nsHTMLOutputElement)
131
133
132
NS_INTERFACE_TABLE_HEAD(nsHTMLOutputElement)
134
NS_INTERFACE_TABLE_HEAD(nsHTMLOutputElement)
133
  NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLOutputElement,
135
  NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLOutputElement,
134
                                   nsIDOMHTMLOutputElement,
136
                                   nsIDOMHTMLOutputElement,
135
                                   nsIMutationObserver,
137
                                   nsIMutationObserver,
136
                                   nsIConstraintValidation)
138
                                   nsIConstraintValidation,
139
                                   nsILabelableElement)
137
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLOutputElement,
140
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLOutputElement,
138
                                               nsGenericHTMLFormElement)
141
                                               nsGenericHTMLFormElement)
139
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLOutputElement)
142
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLOutputElement)
140
143
141
NS_IMPL_ELEMENT_CLONE(nsHTMLOutputElement)
144
NS_IMPL_ELEMENT_CLONE(nsHTMLOutputElement)
142
145
143
146
144
NS_IMPL_STRING_ATTR(nsHTMLOutputElement, Name, name)
147
NS_IMPL_STRING_ATTR(nsHTMLOutputElement, Name, name)
 Lines 229-244   nsHTMLOutputElement::GetHtmlFor(nsIDOMDO Link Here 
229
    mTokenList = new nsDOMSettableTokenList(this, nsGkAtoms::_for);
232
    mTokenList = new nsDOMSettableTokenList(this, nsGkAtoms::_for);
230
  }
233
  }
231
234
232
  NS_ADDREF(*aResult = mTokenList);
235
  NS_ADDREF(*aResult = mTokenList);
233
236
234
  return NS_OK;
237
  return NS_OK;
235
}
238
}
236
239
240
NS_IMETHODIMP
241
nsHTMLOutputElement::GetLabels(nsIDOMHTMLCollection** aLabels)
242
{
243
  *aLabels = nsnull;
244
245
  return NS_OK;
246
}
247
237
void nsHTMLOutputElement::DescendantsChanged()
248
void nsHTMLOutputElement::DescendantsChanged()
238
{
249
{
239
  if (mValueModeFlag == eModeDefault) {
250
  if (mValueModeFlag == eModeDefault) {
240
    nsContentUtils::GetNodeTextContent(this, PR_TRUE, mDefaultValue);
251
    nsContentUtils::GetNodeTextContent(this, PR_TRUE, mDefaultValue);
241
  }
252
  }
242
}
253
}
243
254
244
// nsIMutationObserver
255
// nsIMutationObserver
(-)a/content/html/content/src/nsHTMLSelectElement.cpp (-2 / +10 lines)
Line     Link Here 
 Lines 176-195   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END Link Here 
176
NS_IMPL_ADDREF_INHERITED(nsHTMLSelectElement, nsGenericElement)
176
NS_IMPL_ADDREF_INHERITED(nsHTMLSelectElement, nsGenericElement)
177
NS_IMPL_RELEASE_INHERITED(nsHTMLSelectElement, nsGenericElement)
177
NS_IMPL_RELEASE_INHERITED(nsHTMLSelectElement, nsGenericElement)
178
178
179
179
180
DOMCI_NODE_DATA(HTMLSelectElement, nsHTMLSelectElement)
180
DOMCI_NODE_DATA(HTMLSelectElement, nsHTMLSelectElement)
181
181
182
// QueryInterface implementation for nsHTMLSelectElement
182
// QueryInterface implementation for nsHTMLSelectElement
183
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLSelectElement)
183
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLSelectElement)
184
  NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLSelectElement,
184
  NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLSelectElement,
185
                                   nsIDOMHTMLSelectElement,
185
                                   nsIDOMHTMLSelectElement,
186
                                   nsISelectElement,
186
                                   nsISelectElement,
187
                                   nsIConstraintValidation)
187
                                   nsIConstraintValidation,
188
                                   nsILabelableElement)
188
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLSelectElement,
189
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLSelectElement,
189
                                               nsGenericHTMLFormElement)
190
                                               nsGenericHTMLFormElement)
190
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLSelectElement)
191
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLSelectElement)
191
192
192
193
193
// nsIDOMHTMLSelectElement
194
// nsIDOMHTMLSelectElement
194
195
195
196
 Lines 1219-1234   nsHTMLSelectElement::SetValue(const nsAS Link Here 
1219
        }
1220
        }
1220
      }
1221
      }
1221
    }
1222
    }
1222
  }
1223
  }
1223
1224
1224
  return rv;
1225
  return rv;
1225
}
1226
}
1226
1227
1228
NS_IMETHODIMP
1229
nsHTMLSelectElement::GetLabels(nsIDOMHTMLCollection** aLabels)
1230
{
1231
  *aLabels = nsnull;
1232
1233
  return NS_OK;
1234
}
1227
1235
1228
NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Autofocus, autofocus)
1236
NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Autofocus, autofocus)
1229
NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Disabled, disabled)
1237
NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Disabled, disabled)
1230
NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Multiple, multiple)
1238
NS_IMPL_BOOL_ATTR(nsHTMLSelectElement, Multiple, multiple)
1231
NS_IMPL_STRING_ATTR(nsHTMLSelectElement, Name, name)
1239
NS_IMPL_STRING_ATTR(nsHTMLSelectElement, Name, name)
1232
NS_IMPL_POSITIVE_INT_ATTR_DEFAULT_VALUE(nsHTMLSelectElement, Size, size,
1240
NS_IMPL_POSITIVE_INT_ATTR_DEFAULT_VALUE(nsHTMLSelectElement, Size, size,
1233
                                        GetDefaultSize())
1241
                                        GetDefaultSize())
1234
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLSelectElement, TabIndex, tabindex, 0)
1242
NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLSelectElement, TabIndex, tabindex, 0)
(-)a/content/html/content/src/nsHTMLSelectElement.h (-1 / +3 lines)
Line     Link Here 
 Lines 48-63    Link Here 
48
#include "nsIDOMHTMLFormElement.h"
48
#include "nsIDOMHTMLFormElement.h"
49
#include "nsIDOMHTMLOptionElement.h"
49
#include "nsIDOMHTMLOptionElement.h"
50
#include "nsIDOMHTMLOptionsCollection.h"
50
#include "nsIDOMHTMLOptionsCollection.h"
51
#include "nsIDOMNSHTMLOptionCollectn.h"
51
#include "nsIDOMNSHTMLOptionCollectn.h"
52
#include "nsISelectControlFrame.h"
52
#include "nsISelectControlFrame.h"
53
#include "nsContentUtils.h"
53
#include "nsContentUtils.h"
54
#include "nsIHTMLCollection.h"
54
#include "nsIHTMLCollection.h"
55
#include "nsIConstraintValidation.h"
55
#include "nsIConstraintValidation.h"
56
#include "nsILabelableElement.h"
56
57
57
// PresState
58
// PresState
58
#include "nsXPCOM.h"
59
#include "nsXPCOM.h"
59
#include "nsPresState.h"
60
#include "nsPresState.h"
60
#include "nsIComponentManager.h"
61
#include "nsIComponentManager.h"
61
#include "nsCheapSets.h"
62
#include "nsCheapSets.h"
62
#include "nsLayoutErrors.h"
63
#include "nsLayoutErrors.h"
63
#include "nsHTMLOptionElement.h"
64
#include "nsHTMLOptionElement.h"
 Lines 233-249   private: Link Here 
233
234
234
235
235
/**
236
/**
236
 * Implementation of &lt;select&gt;
237
 * Implementation of &lt;select&gt;
237
 */
238
 */
238
class nsHTMLSelectElement : public nsGenericHTMLFormElement,
239
class nsHTMLSelectElement : public nsGenericHTMLFormElement,
239
                            public nsIDOMHTMLSelectElement,
240
                            public nsIDOMHTMLSelectElement,
240
                            public nsISelectElement,
241
                            public nsISelectElement,
241
                            public nsIConstraintValidation
242
                            public nsIConstraintValidation,
243
                            public nsILabelableElement
242
{
244
{
243
public:
245
public:
244
  nsHTMLSelectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
246
  nsHTMLSelectElement(already_AddRefed<nsINodeInfo> aNodeInfo,
245
                      PRUint32 aFromParser = 0);
247
                      PRUint32 aFromParser = 0);
246
  virtual ~nsHTMLSelectElement();
248
  virtual ~nsHTMLSelectElement();
247
249
248
  // nsISupports
250
  // nsISupports
249
  NS_DECL_ISUPPORTS_INHERITED
251
  NS_DECL_ISUPPORTS_INHERITED
(-)a/content/html/content/src/nsHTMLTextAreaElement.cpp (-3 / +14 lines)
Line     Link Here 
 Lines 73-102    Link Here 
73
#include "nsLayoutUtils.h"
73
#include "nsLayoutUtils.h"
74
#include "nsLayoutErrors.h"
74
#include "nsLayoutErrors.h"
75
#include "nsStubMutationObserver.h"
75
#include "nsStubMutationObserver.h"
76
#include "nsDOMError.h"
76
#include "nsDOMError.h"
77
#include "mozAutoDocUpdate.h"
77
#include "mozAutoDocUpdate.h"
78
#include "nsISupportsPrimitives.h"
78
#include "nsISupportsPrimitives.h"
79
#include "nsContentCreatorFunctions.h"
79
#include "nsContentCreatorFunctions.h"
80
#include "nsIConstraintValidation.h"
80
#include "nsIConstraintValidation.h"
81
#include "nsILabelableElement.h"
81
82
82
#include "nsTextEditorState.h"
83
#include "nsTextEditorState.h"
83
84
84
static NS_DEFINE_CID(kXULControllersCID,  NS_XULCONTROLLERS_CID);
85
static NS_DEFINE_CID(kXULControllersCID,  NS_XULCONTROLLERS_CID);
85
86
86
#define NS_NO_CONTENT_DISPATCH (1 << 0)
87
#define NS_NO_CONTENT_DISPATCH (1 << 0)
87
88
88
class nsHTMLTextAreaElement : public nsGenericHTMLFormElement,
89
class nsHTMLTextAreaElement : public nsGenericHTMLFormElement,
89
                              public nsIDOMHTMLTextAreaElement,
90
                              public nsIDOMHTMLTextAreaElement,
90
                              public nsIDOMNSHTMLTextAreaElement,
91
                              public nsIDOMNSHTMLTextAreaElement,
91
                              public nsITextControlElement,
92
                              public nsITextControlElement,
92
                              public nsIDOMNSEditableElement,
93
                              public nsIDOMNSEditableElement,
93
                              public nsStubMutationObserver,
94
                              public nsStubMutationObserver,
94
                              public nsIConstraintValidation
95
                              public nsIConstraintValidation,
96
                              public nsILabelableElement
95
{
97
{
96
public:
98
public:
97
  nsHTMLTextAreaElement(already_AddRefed<nsINodeInfo> aNodeInfo,
99
  nsHTMLTextAreaElement(already_AddRefed<nsINodeInfo> aNodeInfo,
98
                        PRUint32 aFromParser = 0);
100
                        PRUint32 aFromParser = 0);
99
101
100
  // nsISupports
102
  // nsISupports
101
  NS_DECL_ISUPPORTS_INHERITED
103
  NS_DECL_ISUPPORTS_INHERITED
102
104
 Lines 295-317   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END Link Here 
295
NS_IMPL_ADDREF_INHERITED(nsHTMLTextAreaElement, nsGenericElement) 
297
NS_IMPL_ADDREF_INHERITED(nsHTMLTextAreaElement, nsGenericElement) 
296
NS_IMPL_RELEASE_INHERITED(nsHTMLTextAreaElement, nsGenericElement) 
298
NS_IMPL_RELEASE_INHERITED(nsHTMLTextAreaElement, nsGenericElement) 
297
299
298
300
299
DOMCI_NODE_DATA(HTMLTextAreaElement, nsHTMLTextAreaElement)
301
DOMCI_NODE_DATA(HTMLTextAreaElement, nsHTMLTextAreaElement)
300
302
301
// QueryInterface implementation for nsHTMLTextAreaElement
303
// QueryInterface implementation for nsHTMLTextAreaElement
302
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTextAreaElement)
304
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTextAreaElement)
303
  NS_HTML_CONTENT_INTERFACE_TABLE6(nsHTMLTextAreaElement,
305
  NS_HTML_CONTENT_INTERFACE_TABLE7(nsHTMLTextAreaElement,
304
                                   nsIDOMHTMLTextAreaElement,
306
                                   nsIDOMHTMLTextAreaElement,
305
                                   nsIDOMNSHTMLTextAreaElement,
307
                                   nsIDOMNSHTMLTextAreaElement,
306
                                   nsITextControlElement,
308
                                   nsITextControlElement,
307
                                   nsIDOMNSEditableElement,
309
                                   nsIDOMNSEditableElement,
308
                                   nsIMutationObserver,
310
                                   nsIMutationObserver,
309
                                   nsIConstraintValidation)
311
                                   nsIConstraintValidation,
312
                                   nsILabelableElement)
310
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTextAreaElement,
313
  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTextAreaElement,
311
                                               nsGenericHTMLFormElement)
314
                                               nsGenericHTMLFormElement)
312
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTextAreaElement)
315
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTextAreaElement)
313
316
314
317
315
// nsIDOMHTMLTextAreaElement
318
// nsIDOMHTMLTextAreaElement
316
319
317
320
 Lines 408-423   nsHTMLTextAreaElement::IsHTMLFocusable(P Link Here 
408
    return PR_TRUE;
411
    return PR_TRUE;
409
  }
412
  }
410
413
411
  // disabled textareas are not focusable
414
  // disabled textareas are not focusable
412
  *aIsFocusable = !HasAttr(kNameSpaceID_None, nsGkAtoms::disabled);
415
  *aIsFocusable = !HasAttr(kNameSpaceID_None, nsGkAtoms::disabled);
413
  return PR_FALSE;
416
  return PR_FALSE;
414
}
417
}
415
418
419
NS_IMETHODIMP
420
nsHTMLTextAreaElement::GetLabels(nsIDOMHTMLCollection** aLabels)
421
{
422
  *aLabels = nsnull;
423
424
  return NS_OK;
425
}
426
416
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, AccessKey, accesskey)
427
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, AccessKey, accesskey)
417
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Autofocus, autofocus)
428
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Autofocus, autofocus)
418
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Cols, cols)
429
NS_IMPL_INT_ATTR(nsHTMLTextAreaElement, Cols, cols)
419
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Disabled, disabled)
430
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Disabled, disabled)
420
NS_IMPL_NON_NEGATIVE_INT_ATTR(nsHTMLTextAreaElement, MaxLength, maxlength)
431
NS_IMPL_NON_NEGATIVE_INT_ATTR(nsHTMLTextAreaElement, MaxLength, maxlength)
421
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, Name, name)
432
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, Name, name)
422
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, ReadOnly, readonly)
433
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, ReadOnly, readonly)
423
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Required, required)
434
NS_IMPL_BOOL_ATTR(nsHTMLTextAreaElement, Required, required)
(-)a/content/html/content/test/Makefile.in (+1 lines)
Line     Link Here 
 Lines 200-211   _TEST_FILES = \ Link Here 
200
		test_bug345512.html \
200
		test_bug345512.html \
201
		test_bug566064.html \
201
		test_bug566064.html \
202
		test_bug566160.html \
202
		test_bug566160.html \
203
		test_bug582412-1.html \
203
		test_bug582412-1.html \
204
		test_bug582412-2.html \
204
		test_bug582412-2.html \
205
		test_bug558788-1.html \
205
		test_bug558788-1.html \
206
		test_bug558788-2.html \
206
		test_bug558788-2.html \
207
		test_bug561634.html \
207
		test_bug561634.html \
208
		test_bug556743.html \
208
		$(NULL)
209
		$(NULL)
209
210
210
libs:: $(_TEST_FILES)
211
libs:: $(_TEST_FILES)
211
	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
212
	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
(-)a/content/html/content/test/test_bug556743.html (+453 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE HTML>
2
<html>
3
<!--
4
https://bugzilla.mozilla.org/show_bug.cgi?id=556743
5
-->
6
<head>
7
  <title>Test for Bug 556743</title>
8
  <script type="application/javascript" src="/MochiKit/packed.js"></script>
9
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11
</head>
12
<body>
13
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=556743">Mozilla Bug 556743</a>
14
<p id="display"></p>
15
<div id="content" style="display: none">
16
</div>
17
<pre id="test">
18
<script type="application/javascript">
19
20
/** Test for Bug 556743 **/
21
22
/**
23
 * TODO:
24
 * - check <label><element><script>element.labels<\/script><\/label>
25
 */
26
27
/**
28
 * All functions take an array of elements in first argument and an array of
29
 * labels in second argument.
30
 * Then, it returns an array containing an array of elements and an array of
31
 * array of labels. The array represent the label association with elements
32
 * like this:
33
 * [ [ form1, form2 ], [ [ elmt1ofForm1, elmt2ofForm2 ], [ elmtofForm2 ] ] ]
34
 */
35
36
/**
37
 * This function test that, when an element is not a descendant of a form
38
 * element and has @form set to a valid form id, it's form owner is the form
39
 * which has the id.
40
 */
41
function test1(aForms, aElements)
42
{
43
  // <form id='f'></form><element id='f'>
44
  aForms[0].id = 'f';
45
  aElements[0].setAttribute('form', 'f');
46
47
  return [[aForms[0]], [[aElements[0]]]];
48
}
49
50
/**
51
 * This function test that, when an element is a descendant of a form
52
 * element and has @form set to a valid form id (not it's descendant), it's form
53
 * owner is the form which has the id.
54
 */
55
function test2(aForms, aElements)
56
{
57
  // <form id='f'></form><form><element form='f'></form>
58
  aForms[0].id = 'f';
59
  aForms[1].appendChild(aElements[0]);
60
  aElements[0].setAttribute('form', 'f');
61
62
  return [[aForms[0], aForms[1]], [[aElements[0]],[]]];
63
}
64
65
/**
66
 * This function test that, when an element is a descendant of a form
67
 * element and has @form set to a valid form id (not it's descendant), then the
68
 * form attribute is removed, it does not have a form owner.
69
 */
70
function test3(aForms, aElements)
71
{
72
  // <form id='f'></form><form><element form='f'></form>
73
  aForms[0].id = 'f';
74
  aForms[1].appendChild(aElements[0]);
75
  aElements[0].setAttribute('form', 'f');
76
  aElements[0].removeAttribute('form');
77
78
  return [[aForms[0], aForms[1]], [[],[aElements[0]]]];
79
}
80
81
/**
82
 * This function test that, when an element is a descendant of a form
83
 * element and has @form set to a valid form id (not it's descendant), then the
84
 * form's id attribute is removed, it does not have a form owner.
85
 */
86
function test4(aForms, aElements)
87
{
88
  // <form id='f'></form><form><element form='f'></form>
89
  aForms[0].id = 'f';
90
  aForms[1].appendChild(aElements[0]);
91
  aElements[0].setAttribute('form', 'f');
92
  aForms[0].removeAttribute('id');
93
94
  return [[aForms[0], aForms[1]], [[],[]]];
95
}
96
97
/**
98
 * This function test that, when an element is a descendant of a form
99
 * element and has @form set to an invalid form id, then it does not have a form
100
 * owner.
101
 */
102
function test5(aForms, aElements)
103
{
104
  // <form id='f'></form><form><element form='foo'></form>
105
  aForms[0].id = 'f';
106
  aForms[1].appendChild(aElements[0]);
107
  aElements[0].setAttribute('form', 'foo');
108
109
  return [[aForms[0], aForms[1]], [[],[]]];
110
}
111
112
/**
113
 * This function test that, when an element is a descendant of a form
114
 * element and has @form set to a valid form id (not it's descendant), then the
115
 * form id attribute is changed to an invalid id, it does not have a form owner.
116
 */
117
function test6(aForms, aElements)
118
{
119
  // <form id='f'></form><form><element form='f'></form>
120
  aForms[0].id = 'f';
121
  aForms[1].appendChild(aElements[0]);
122
  aElements[0].setAttribute('form', 'f');
123
  aElements[0].setAttribute('form', 'foo');
124
125
  return [[aForms[0], aForms[1]], [[],[]]];
126
}
127
128
/**
129
 * This function test that, when an element is a descendant of a form
130
 * element and has @form set to an invalid form id, then the form id attribute
131
 * is changed to a valid form id, it's form owner is the form which has this id.
132
 */
133
function test7(aForms, aElements)
134
{
135
  // <form id='f'></form><form><element form='foo'></form>
136
  aForms[0].id = 'f';
137
  aForms[1].appendChild(aElements[0]);
138
  aElements[0].setAttribute('form', 'foo');
139
  aElements[0].setAttribute('form', 'f');
140
141
  return [[aForms[0], aForms[1]], [[aElements[0]],[]]];
142
}
143
144
/**
145
 * This function test that, when an element is a descendant of a form
146
 * element and has @form set to a list of ids containing one valid form, then
147
 * it does not have a form owner.
148
 */
149
function test8(aForms, aElements)
150
{
151
  // <form id='f'></form><form><element form='f foo'></form>
152
  aForms[0].id = 'f';
153
  aForms[1].appendChild(aElements[0]);
154
  aElements[0].setAttribute('form', 'f foo');
155
156
  return [[aForms[0], aForms[1]], [[],[]]];
157
}
158
159
/**
160
 * This function test that, when an element is a descendant of a form
161
 * element and has @form set to a form id which is valid in a case insensitive
162
 * way, then it does not have a form owner.
163
 */
164
function test9(aForms, aElements)
165
{
166
  // <form id='f'></form><form><element form='F'></form>
167
  aForms[0].id = 'f';
168
  aForms[1].appendChild(aElements[0]);
169
  aElements[0].setAttribute('form', 'F');
170
171
  return [[aForms[0], aForms[1]], [[],[]]];
172
}
173
174
/**
175
 * This function test that, when an element is a descendant of a form
176
 * element and has @form set to a form id which is not a valid id, then it's
177
 * form owner is it does not have a form owner.
178
 */
179
function test10(aForms, aElements)
180
{
181
  // <form id='F'></form><form><element form='f'></form>
182
  aForms[0].id = 'F';
183
  aForms[1].appendChild(aElements[0]);
184
  aElements[0].setAttribute('form', 'f');
185
186
  return [[aForms[0], aForms[1]], [[],[]]];
187
}
188
189
/**
190
 * This function test that, when an element is a descendant of a form
191
 * element and has @form set to a form id which is not a valid id, then it's
192
 * form owner is it does not have a form owner.
193
 */
194
function test11(aForms, aElements)
195
{
196
  // <form id='foo bar'></form><form><element form='foo bar'></form>
197
  aForms[0].id = 'foo bar';
198
  aForms[1].appendChild(aElements[0]);
199
  aElements[0].setAttribute('form', 'foo bar');
200
201
  return [[aForms[0], aForms[1]], [[aElements[0]],[]]];
202
}
203
204
/**
205
 * This function test that, when an element is a descendant of a form
206
 * element and has @form set to a valid form id and the form id change, then
207
 * it does not have a form owner.
208
 */
209
function test12(aForms, aElements)
210
{
211
  // <form id='f'></form><form><element form='f'></form>
212
  aForms[0].id = 'f';
213
  aForms[1].appendChild(aElements[0]);
214
  aElements[0].setAttribute('form', 'f');
215
  aForms[0].id = 'foo';
216
217
  return [[aForms[0], aForms[1]], [[],[]]];
218
}
219
220
/**
221
 * This function test that, when an element is a descendant of a form
222
 * element and has @form set to an invalid form id and the form id change to a
223
 * valid one, then it's form owner is the form which has the id.
224
 */
225
function test13(aForms, aElements)
226
{
227
  // <form id='foo'></form><form><element form='f'></form>
228
  aForms[0].id = 'foo';
229
  aForms[1].appendChild(aElements[0]);
230
  aElements[0].setAttribute('form', 'f');
231
  aForms[0].id = 'f';
232
233
  return [[aForms[0], aForms[1]], [[aElements[0]],[]]];
234
}
235
236
/**
237
 * This function test that, when an element is a descendant of a form
238
 * element and has @form set to a valid form id and a form with the same id is
239
 * inserted before in the tree, then it's form owner is the form which has the
240
 * id.
241
 */
242
function test14(aForms, aElements)
243
{
244
  // <form id='f'></form><form><element form='f'></form>
245
  aForms[0].id = 'f';
246
  aForms[1].appendChild(aElements[0]);
247
  aElements[0].setAttribute('form', 'f');
248
  aForms[2].id = 'f';
249
250
  document.getElementById('content').insertBefore(aForms[2], aForms[0]);
251
252
  return [[aForms[0], aForms[1], aForms[2]], [[],[],[aElements[0]]]];
253
}
254
255
/**
256
 * This function test that, when an element is a descendant of a form
257
 * element and has @form set to a valid form id and an element with the same id is
258
 * inserted before in the tree, then it does not have a form owner.
259
 */
260
function test15(aForms, aElements)
261
{
262
  // <form id='f'></form><form><element form='f'></form>
263
  aForms[0].id = 'f';
264
  aForms[1].appendChild(aElements[0]);
265
  aElements[0].setAttribute('form', 'f');
266
  aElements[1].id = 'f';
267
268
  document.getElementById('content').insertBefore(aElements[1], aForms[0]);
269
270
  return [[aForms[0], aForms[1]], [[],[]]];
271
}
272
273
/**
274
 * This function test that, when an element is a descendant of a form
275
 * element and has @form set to a valid form id and the form is removed from
276
 * the tree, then it does not have a form owner.
277
 */
278
function test16(aForms, aElements)
279
{
280
  // <form id='f'></form><form><element form='f'></form>
281
  aForms[0].id = 'f';
282
  aForms[1].appendChild(aElements[0]);
283
  aElements[0].setAttribute('form', 'f');
284
  aElements[1].id = 'f';
285
286
  document.getElementById('content').removeChild(aForms[0]);
287
288
  return [[aForms[0], aForms[1]], [[],[]]];
289
}
290
291
/**
292
 * This function test that, when an element is a descendant of a form element
293
 * and has @form set to the empty string, it does not have a form owner.
294
 */
295
function test17(aForms, aElements)
296
{
297
  // <form><element form=''></form>
298
  aForms[0].appendChild(aElements[0]);
299
  aElements[0].setAttribute('form', '');
300
301
  return [[aForms[0]], [[]]];
302
}
303
304
/**
305
 * This function test that, when an element is a descendant of a form element
306
 * and has @form set to the empty string, it does not have a form owner even if
307
 * it's parent has its id equals to the empty string.
308
 */
309
function test18(aForms, aElements)
310
{
311
  // <form id=''><element form=''></form>
312
  aForms[0].id = '';
313
  aForms[0].appendChild(aElements[0]);
314
  aElements[0].setAttribute('form', '');
315
316
  return [[aForms[0]], [[]]];
317
}
318
319
/**
320
 * This function test that, when an element is a descendant of a form element
321
 * and has @form set to a valid form id and the element is being moving inside
322
 * it's parent, it's form owner will remain the form with the id.
323
 */
324
function test19(aForms, aElements)
325
{
326
  // <form id='f'></form><form><element form='f'><element></form>
327
  aForms[0].id = 'f';
328
  aForms[1].appendChild(aElements[0]);
329
  aForms[1].appendChild(aElements[1]);
330
  aElements[0].setAttribute('form', 'f');
331
  aForms[1].appendChild(aElements[0]);
332
333
  return [[aForms[0],aForms[1]],[[aElements[0]],[aElements[1]]]];
334
}
335
336
/**
337
 * This function test that, when an element is a descendant of a form element
338
 * and has @form set to a valid form id and the element is being moving inside
339
 * another form, it's form owner will remain the form with the id.
340
 */
341
function test20(aForms, aElements)
342
{
343
  // <form id='f'></form><form><element form='f'><element></form>
344
  aForms[0].id = 'f';
345
  aForms[1].appendChild(aElements[0]);
346
  aForms[1].appendChild(aElements[1]);
347
  aElements[0].setAttribute('form', 'f');
348
  aForms[2].appendChild(aElements[0]);
349
350
  return [[aForms[0],aForms[1],aForms[2]],[[aElements[0]],[aElements[1]],[]]];
351
}
352
353
var functions = [
354
  test1, test2, test3, test4, test5, test6, test7, test8, test9,
355
  test10, test11, test12, test13, test14, test15, test16, test17, test18, test19,
356
  test20,
357
];
358
359
// Global variable to have an easy access to <div id='content'>.
360
var content = document.getElementById('content');
361
362
// Initializing the needed labels.
363
var labels = [
364
  document.createElement('label'),
365
  document.createElement('label'),
366
];
367
368
var elementNames = [
369
  'button', 'input', 'output', 'select', 'textarea',
370
];
371
372
var notElementNames = [
373
  'fieldset', 'label', 'object', 'option', 'optgroup', 'legend',
374
];
375
376
var todoElements = [
377
  ['keygen', 'Keygen'],
378
  ['meter', 'Meter'],
379
  ['progress', 'Progress'],
380
];
381
382
for each(var e in todoElements) {
383
  var node = document.createElement(e[0]);
384
  var nodeString = HTMLElement.prototype.toString.apply(node);
385
  nodeString = nodeString.replace(/Element[\] ].*/, "Element");
386
  todo_is(nodeString, "[object HTML" + e[1] + "Element",
387
          e[0] + " should not be implemented");
388
}
389
390
for each(var e in notElementNames) {
391
  var element = document.createElement(e);
392
  ok(!("labels" in element), "labels should not be an IDL attribute for " + e +
393
                             " elements");
394
}
395
396
for each(var name in elementNames) {
397
  var elements = [
398
    document.createElement(name),
399
    document.createElement(name),
400
  ];
401
402
  ok("labels" in elements[0], "labels should be an IDL attribute for " + e +
403
                              " elements");
404
  if (!("labels" in elements[0])) {
405
    // No need to try anything else if labels isn't an IDL attribute.
406
    continue;
407
  }
408
409
  for each(var func in functions) {
410
    // Clean-up.
411
    while (content.firstChild) {
412
      content.removeChild(content.firstChild);
413
    }
414
    for each(label in labels) {
415
      content.appendChild(label);
416
      label.removeAttribute('for');
417
      is(label.control, null, "The label should have no control.");
418
    }
419
    for each(e in elements) {
420
      content.appendChild(e);
421
      e.removeAttribute('id');
422
      is(e.labels,length, 0, "The element should not be labeled");
423
    }
424
425
    // Calling the test.
426
    var results = func(elements, labels);
427
428
    // Checking the results.
429
    var elementsList = results[0];
430
    for (var i=0; i<elementsList.length; ++i) {
431
      var labelsList = results[1][i];
432
      is(elementsList[i].labels.length, labelsList.length,
433
         "The elements should be labeled by " + labelsList.length + " labels");
434
      for (var j=0; j<labelsList.length; ++j) {
435
        is(elementsList[i].labels[j], labelsList[j],
436
           "The labels list should contain " + elementsList[j]);
437
        is(labelsList[j].control, elementsList[i],
438
           "The control labeled by the label should be " + elementsList[i]);
439
      }
440
    }
441
  }
442
443
  // Cleaning-up.
444
  for each(e in elements) {
445
    e.parentNode.removeChild(e);
446
    e = null;
447
  }
448
}
449
450
</script>
451
</pre>
452
</body>
453
</html>
(-)a/dom/interfaces/html/nsIDOMHTMLButtonElement.idl (-1 / +3 lines)
Line     Link Here 
 Lines 44-60    Link Here 
44
 * button element.
44
 * button element.
45
 *
45
 *
46
 * For more information on this interface please see
46
 * For more information on this interface please see
47
 * http://www.w3.org/TR/DOM-Level-2-HTML/
47
 * http://www.w3.org/TR/DOM-Level-2-HTML/
48
 */
48
 */
49
49
50
interface nsIDOMValidityState;
50
interface nsIDOMValidityState;
51
51
52
[scriptable, uuid(d76a7412-f70b-43fe-becb-d30dac13cc7b)]
52
[scriptable, uuid(41693745-9c56-43c9-9c64-6b303afabf6e)]
53
interface nsIDOMHTMLButtonElement : nsIDOMHTMLElement
53
interface nsIDOMHTMLButtonElement : nsIDOMHTMLElement
54
{
54
{
55
           attribute boolean               autofocus;
55
           attribute boolean               autofocus;
56
           attribute boolean               disabled;
56
           attribute boolean               disabled;
57
  readonly attribute nsIDOMHTMLFormElement form;
57
  readonly attribute nsIDOMHTMLFormElement form;
58
           attribute DOMString             formAction;
58
           attribute DOMString             formAction;
59
           attribute DOMString             formEnctype;
59
           attribute DOMString             formEnctype;
60
           attribute DOMString             formMethod;
60
           attribute DOMString             formMethod;
 Lines 73-82   interface nsIDOMHTMLButtonElement : nsID Link Here 
73
73
74
  // The following lines are parte of the constraint validation API, see:
74
  // The following lines are parte of the constraint validation API, see:
75
  // http://dev.w3.org/html5/spec/forms.html#the-constraint-validation-api
75
  // http://dev.w3.org/html5/spec/forms.html#the-constraint-validation-api
76
  readonly attribute boolean             willValidate;
76
  readonly attribute boolean             willValidate;
77
  readonly attribute nsIDOMValidityState validity;
77
  readonly attribute nsIDOMValidityState validity;
78
  readonly attribute DOMString           validationMessage;
78
  readonly attribute DOMString           validationMessage;
79
  boolean checkValidity();
79
  boolean checkValidity();
80
  void setCustomValidity(in DOMString error);
80
  void setCustomValidity(in DOMString error);
81
82
  readonly attribute nsIDOMHTMLCollection  labels;
81
};
83
};
82
84
(-)a/dom/interfaces/html/nsIDOMHTMLInputElement.idl (-1 / +3 lines)
Line     Link Here 
 Lines 46-62   interface nsIDOMValidityState; Link Here 
46
 /**
46
 /**
47
  * The nsIDOMHTMLInputElement interface is the interface to a [X]HTML
47
  * The nsIDOMHTMLInputElement interface is the interface to a [X]HTML
48
  * input element.
48
  * input element.
49
  *
49
  *
50
  * For more information on this interface please see
50
  * For more information on this interface please see
51
  * http://www.w3.org/TR/DOM-Level-2-HTML/
51
  * http://www.w3.org/TR/DOM-Level-2-HTML/
52
  */
52
  */
53
 
53
 
54
[scriptable, uuid(e5079711-e6a9-4d3a-9b62-b4a8ef08fa7d)]
54
[scriptable, uuid(7daebcd1-a917-45fa-bdc6-df7c8e15d3ae)]
55
interface nsIDOMHTMLInputElement : nsIDOMHTMLElement
55
interface nsIDOMHTMLInputElement : nsIDOMHTMLElement
56
{
56
{
57
           attribute DOMString             accept;
57
           attribute DOMString             accept;
58
           attribute DOMString             alt;
58
           attribute DOMString             alt;
59
59
60
           attribute boolean               autofocus;
60
           attribute boolean               autofocus;
61
           attribute boolean               defaultChecked;
61
           attribute boolean               defaultChecked;
62
           attribute boolean               checked;
62
           attribute boolean               checked;
 Lines 94-109   interface nsIDOMHTMLInputElement : nsIDO Link Here 
94
  // The following lines are parte of the constraint validation API, see:
94
  // The following lines are parte of the constraint validation API, see:
95
  // http://dev.w3.org/html5/spec/forms.html#the-constraint-validation-api
95
  // http://dev.w3.org/html5/spec/forms.html#the-constraint-validation-api
96
  readonly attribute boolean             willValidate;
96
  readonly attribute boolean             willValidate;
97
  readonly attribute nsIDOMValidityState validity;
97
  readonly attribute nsIDOMValidityState validity;
98
  readonly attribute DOMString           validationMessage;
98
  readonly attribute DOMString           validationMessage;
99
  boolean checkValidity();
99
  boolean checkValidity();
100
  void setCustomValidity(in DOMString error);
100
  void setCustomValidity(in DOMString error);
101
101
102
  readonly attribute nsIDOMHTMLCollection  labels;
103
102
  void select();
104
  void select();
103
           attribute long                  selectionStart;
105
           attribute long                  selectionStart;
104
           attribute long                  selectionEnd;
106
           attribute long                  selectionEnd;
105
  void setSelectionRange(in long selectionStart, in long selectionEnd);
107
  void setSelectionRange(in long selectionStart, in long selectionEnd);
106
          
108
          
107
109
108
           attribute long                  tabIndex;
110
           attribute long                  tabIndex;
109
           attribute DOMString             useMap;
111
           attribute DOMString             useMap;
(-)a/dom/interfaces/html/nsIDOMHTMLOutputElement.idl (-5 / +2 lines)
Line     Link Here 
 Lines 45-75    Link Here 
45
 * http://dev.w3.org/html5/spec/forms.html#the-output-element
45
 * http://dev.w3.org/html5/spec/forms.html#the-output-element
46
 *
46
 *
47
 * @status UNDER_DEVELOPMENT
47
 * @status UNDER_DEVELOPMENT
48
 */
48
 */
49
49
50
interface nsIDOMDOMSettableTokenList;
50
interface nsIDOMDOMSettableTokenList;
51
interface nsIDOMValidityState;
51
interface nsIDOMValidityState;
52
52
53
[scriptable, uuid(0f7f15a9-ea72-4feb-b2b5-2fcbc9c10ab8)]
53
[scriptable, uuid(ca1a9f35-510d-4730-b450-5999e6447392)]
54
interface nsIDOMHTMLOutputElement : nsIDOMHTMLElement
54
interface nsIDOMHTMLOutputElement : nsIDOMHTMLElement
55
{
55
{
56
  readonly attribute nsIDOMDOMSettableTokenList htmlFor;
56
  readonly attribute nsIDOMDOMSettableTokenList htmlFor;
57
  readonly attribute nsIDOMHTMLFormElement      form;
57
  readonly attribute nsIDOMHTMLFormElement      form;
58
           attribute DOMString                  name;
58
           attribute DOMString                  name;
59
59
60
  readonly attribute DOMString                  type;
60
  readonly attribute DOMString                  type;
61
           attribute DOMString                  defaultValue;
61
           attribute DOMString                  defaultValue;
62
           attribute DOMString                  value;
62
           attribute DOMString                  value;
63
63
64
  readonly attribute boolean                    willValidate;
64
  readonly attribute boolean                    willValidate;
65
  readonly attribute nsIDOMValidityState        validity;
65
  readonly attribute nsIDOMValidityState        validity;
66
  readonly attribute DOMString                  validationMessage;
66
  readonly attribute DOMString                  validationMessage;
67
  boolean  checkValidity();
67
  boolean  checkValidity();
68
  void     setCustomValidity(in DOMString error);
68
  void     setCustomValidity(in DOMString error);
69
69
70
  /**
70
  readonly attribute nsIDOMHTMLCollection       labels;
71
   * The labels IDL attribute will be added with bug 556743.
72
   */
73
  //readonly attribute nsIDOMNodeList             labels;
74
};
71
};
75
72
(-)a/dom/interfaces/html/nsIDOMHTMLSelectElement.idl (-1 / +3 lines)
Line     Link Here 
 Lines 45-61    Link Here 
45
 * select element.
45
 * select element.
46
 *
46
 *
47
 * For more information on this interface please see
47
 * For more information on this interface please see
48
 * http://www.w3.org/TR/DOM-Level-2-HTML/
48
 * http://www.w3.org/TR/DOM-Level-2-HTML/
49
 */
49
 */
50
50
51
interface nsIDOMValidityState;
51
interface nsIDOMValidityState;
52
52
53
[scriptable, uuid(e3c6d960-972c-4a5e-a8f4-6ca65d578abf)]
53
[scriptable, uuid(8e1faa12-f704-45c0-9f81-334b8c9abcd7)]
54
interface nsIDOMHTMLSelectElement : nsIDOMHTMLElement
54
interface nsIDOMHTMLSelectElement : nsIDOMHTMLElement
55
{
55
{
56
           attribute boolean                     autofocus;
56
           attribute boolean                     autofocus;
57
           attribute boolean                     disabled;
57
           attribute boolean                     disabled;
58
  readonly attribute nsIDOMHTMLFormElement       form;
58
  readonly attribute nsIDOMHTMLFormElement       form;
59
           attribute boolean                     multiple;
59
           attribute boolean                     multiple;
60
           attribute DOMString                   name;
60
           attribute DOMString                   name;
61
           attribute long                        size;
61
           attribute long                        size;
 Lines 80-88   interface nsIDOMHTMLSelectElement : nsID Link Here 
80
80
81
  // The following lines are parte of the constraint validation API, see:
81
  // The following lines are parte of the constraint validation API, see:
82
  // http://dev.w3.org/html5/spec/forms.html#the-constraint-validation-api
82
  // http://dev.w3.org/html5/spec/forms.html#the-constraint-validation-api
83
  readonly attribute boolean             willValidate;
83
  readonly attribute boolean             willValidate;
84
  readonly attribute nsIDOMValidityState validity;
84
  readonly attribute nsIDOMValidityState validity;
85
  readonly attribute DOMString           validationMessage;
85
  readonly attribute DOMString           validationMessage;
86
  boolean checkValidity();
86
  boolean checkValidity();
87
  void setCustomValidity(in DOMString error);
87
  void setCustomValidity(in DOMString error);
88
89
  readonly attribute nsIDOMHTMLCollection        labels;
88
};
90
};
(-)a/dom/interfaces/html/nsIDOMHTMLTextAreaElement.idl (-1 / +3 lines)
Line     Link Here 
 Lines 42-58    Link Here 
42
/**
42
/**
43
 * The nsIDOMHTMLTextAreaElement interface is the interface to a
43
 * The nsIDOMHTMLTextAreaElement interface is the interface to a
44
 * [X]HTML textarea element.
44
 * [X]HTML textarea element.
45
 *
45
 *
46
 * For more information on this interface please see
46
 * For more information on this interface please see
47
 * http://www.w3.org/TR/DOM-Level-2-HTML/
47
 * http://www.w3.org/TR/DOM-Level-2-HTML/
48
 */
48
 */
49
49
50
[scriptable, uuid(a6cf9094-15b3-11d2-932e-00805f8add32)]
50
[scriptable, uuid(9bc51cd7-6191-4328-a029-464ddd23a3b1)]
51
interface nsIDOMHTMLTextAreaElement : nsIDOMHTMLElement
51
interface nsIDOMHTMLTextAreaElement : nsIDOMHTMLElement
52
{
52
{
53
  // Modified in DOM Level 2:
53
  // Modified in DOM Level 2:
54
           attribute DOMString             defaultValue;
54
           attribute DOMString             defaultValue;
55
  readonly attribute nsIDOMHTMLFormElement form;
55
  readonly attribute nsIDOMHTMLFormElement form;
56
           attribute DOMString             accessKey;
56
           attribute DOMString             accessKey;
57
           attribute long                  cols;
57
           attribute long                  cols;
58
           attribute boolean               disabled;
58
           attribute boolean               disabled;
 Lines 60-68   interface nsIDOMHTMLTextAreaElement : ns Link Here 
60
           attribute boolean               readOnly;
60
           attribute boolean               readOnly;
61
           attribute long                  rows;
61
           attribute long                  rows;
62
           attribute long                  tabIndex;
62
           attribute long                  tabIndex;
63
  readonly attribute DOMString             type;
63
  readonly attribute DOMString             type;
64
           attribute DOMString             value;
64
           attribute DOMString             value;
65
  void                      blur();
65
  void                      blur();
66
  void                      focus();
66
  void                      focus();
67
  void                      select();
67
  void                      select();
68
69
  readonly attribute nsIDOMHTMLCollection  labels;
68
};
70
};

Return to bug 556743