~ubuntu-branches/ubuntu/feisty/firefox/feisty-updates

« back to all changes in this revision

Viewing changes to content/html/content/src/nsHTMLLabelElement.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2007-10-19 01:09:21 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: james.westby@ubuntu.com-20071019010921-8sglgxbi6kj1pemg
Tags: 2.0.0.8+1nobinonly-0ubuntu1
* New security/stability upstream release (v2.0.0.8)
* MFSA 2007-29 aka CVE-2007-5339 (browser), CVE-2007-5340 (javascript)
* MFSA 2007-30 aka CVE-2007-1095
* MFSA 2007-31 aka CVE-2007-2292
* MFSA 2007-32 aka CVE-2007-3511, CVE-2006-2894
* MFSA 2007-33 aka CVE-2007-5334
* MFSA 2007-34 aka CVE-2007-5337
* MFSA 2007-35 aka CVE-2007-5338
* MFSA 2007-36 aka CVE-2007-4841 (windows only)

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
#include "nsIPresShell.h"
52
52
#include "nsGUIEvent.h"
53
53
#include "nsIEventStateManager.h"
54
 
 
 
54
#include "nsIDOMHTMLInputElement.h"
55
55
 
56
56
class nsHTMLLabelElement : public nsGenericHTMLFormElement,
57
57
                           public nsIDOMHTMLLabelElement
72
72
  // nsIDOMHTMLElement
73
73
  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
74
74
 
 
75
  // nsIDOMNSHTMLElement
 
76
  NS_IMETHOD Focus();
 
77
 
75
78
  // nsIDOMHTMLLabelElement
76
79
  NS_DECL_NSIDOMHTMLLABELELEMENT
77
80
 
108
111
  already_AddRefed<nsIContent> GetFirstFormControl(nsIContent *current);
109
112
 
110
113
  // XXX It would be nice if we could use an event flag instead.
111
 
  PRBool mHandlingEvent;
 
114
  PRPackedBool mHandlingEvent;
 
115
  PRPackedBool mFocusCalled;
112
116
};
113
117
 
114
118
// construction, destruction
119
123
 
120
124
nsHTMLLabelElement::nsHTMLLabelElement(nsINodeInfo *aNodeInfo)
121
125
  : nsGenericHTMLFormElement(aNodeInfo),
122
 
    mHandlingEvent(PR_FALSE)
 
126
    mHandlingEvent(PR_FALSE),
 
127
    mFocusCalled(PR_FALSE)
123
128
{
124
129
}
125
130
 
273
278
  return rv;
274
279
}
275
280
 
 
281
nsresult
 
282
nsHTMLLabelElement::Focus()
 
283
{
 
284
  PRBool oldFocusCalled = mFocusCalled;
 
285
  mFocusCalled = PR_TRUE;
 
286
  nsresult rv = nsGenericHTMLFormElement::Focus();
 
287
  mFocusCalled = oldFocusCalled;
 
288
  return rv;
 
289
}
 
290
 
276
291
void
277
292
nsHTMLLabelElement::SetFocus(nsPresContext* aContext)
278
293
{
279
294
  // Since we don't have '-moz-user-focus: normal', the only time
280
295
  // |SetFocus| will be called is when the accesskey is activated.
281
296
  nsCOMPtr<nsIContent> content = GetForContent();
282
 
  if (content)
 
297
  if (content) {
 
298
    if (mFocusCalled) {
 
299
      // Handle input element in a special way, so that focusing
 
300
      // <input type="file"> doesn't focus the input field but the
 
301
      // 'browse...' button.
 
302
      nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(content);
 
303
      if (input) {
 
304
        input->Focus();
 
305
        return;
 
306
      }
 
307
    }
283
308
    content->SetFocus(aContext);
 
309
  }
284
310
}
285
311
 
286
312
nsresult