|
|
|
|
| 47 |
#include "nsIForm.h" |
47 |
#include "nsIForm.h" |
| 48 |
#include "nsIDOMDocument.h" |
48 |
#include "nsIDOMDocument.h" |
| 49 |
#include "nsIDocument.h" |
49 |
#include "nsIDocument.h" |
| 50 |
#include "nsGUIEvent.h" |
50 |
#include "nsGUIEvent.h" |
| 51 |
#include "nsIEventStateManager.h" |
51 |
#include "nsIEventStateManager.h" |
| 52 |
#include "nsEventDispatcher.h" |
52 |
#include "nsEventDispatcher.h" |
| 53 |
#include "nsPIDOMWindow.h" |
53 |
#include "nsPIDOMWindow.h" |
| 54 |
#include "nsFocusManager.h" |
54 |
#include "nsFocusManager.h" |
|
|
55 |
#include "nsILabelableElement.h" |
| 55 |
|
56 |
|
| 56 |
class nsHTMLLabelElement : public nsGenericHTMLFormElement, |
57 |
class nsHTMLLabelElement : public nsGenericHTMLFormElement, |
| 57 |
public nsIDOMHTMLLabelElement, |
58 |
public nsIDOMHTMLLabelElement, |
| 58 |
public nsIDOMNSHTMLLabelElement |
59 |
public nsIDOMNSHTMLLabelElement, |
|
|
60 |
public nsStubMutationObserver |
| 59 |
{ |
61 |
{ |
| 60 |
public: |
62 |
public: |
| 61 |
nsHTMLLabelElement(nsINodeInfo *aNodeInfo); |
63 |
nsHTMLLabelElement(nsINodeInfo *aNodeInfo); |
| 62 |
virtual ~nsHTMLLabelElement(); |
64 |
virtual ~nsHTMLLabelElement(); |
| 63 |
|
65 |
|
| 64 |
// nsISupports |
66 |
// nsISupports |
| 65 |
NS_DECL_ISUPPORTS_INHERITED |
67 |
NS_DECL_ISUPPORTS_INHERITED |
| 66 |
|
68 |
|
|
Lines 105-158
public:
|
Link Here
|
|---|
|
| 105 |
nsIAtom* aPrefix, const nsAString& aValue, |
107 |
nsIAtom* aPrefix, const nsAString& aValue, |
| 106 |
PRBool aNotify); |
108 |
PRBool aNotify); |
| 107 |
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, |
109 |
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, |
| 108 |
PRBool aNotify); |
110 |
PRBool aNotify); |
| 109 |
virtual void PerformAccesskey(PRBool aKeyCausesActivation, |
111 |
virtual void PerformAccesskey(PRBool aKeyCausesActivation, |
| 110 |
PRBool aIsTrustedEvent); |
112 |
PRBool aIsTrustedEvent); |
| 111 |
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; |
113 |
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; |
| 112 |
|
114 |
|
|
|
115 |
// nsIMutationObserver |
| 116 |
void ContentAppended (nsIDocument* aDocument, |
| 117 |
nsIContent* aContainer, |
| 118 |
nsIContent* aFirstNewContent, |
| 119 |
PRInt32 aNewIndexInContainer); |
| 120 |
void ContentInserted (nsIDocument* aDocument, |
| 121 |
nsIContent* aContainer, |
| 122 |
nsIContent* aChild, |
| 123 |
PRInt32 aIndexInContainer); |
| 124 |
void ContentRemoved (nsIDocument* aDocument, |
| 125 |
nsIContent* aContainer, |
| 126 |
nsIContent* aChild, |
| 127 |
PRInt32 aIndexInContainer); |
| 128 |
void NodeWillBeDestroyed(const nsINode* aNode); |
| 129 |
|
| 130 |
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLLabelElement, |
| 131 |
nsGenericHTMLFormElement) |
| 132 |
|
| 113 |
protected: |
133 |
protected: |
| 114 |
already_AddRefed<nsIContent> GetControlContent(); |
134 |
already_AddRefed<nsIContent> GetControlContent(); |
| 115 |
already_AddRefed<nsIContent> GetFirstFormControl(nsIContent *current); |
135 |
already_AddRefed<nsIContent> GetFirstFormControl(nsIContent *current); |
|
|
136 |
void SetControl(); |
| 116 |
|
137 |
|
| 117 |
// XXX It would be nice if we could use an event flag instead. |
138 |
// XXX It would be nice if we could use an event flag instead. |
| 118 |
PRPackedBool mHandlingEvent; |
139 |
PRPackedBool mHandlingEvent; |
|
|
140 |
|
| 141 |
// The form control the label element is labeling. |
| 142 |
nsCOMPtr<nsILabelableElement> mControl; |
| 143 |
|
| 144 |
// Whether we are observing the parent node. |
| 145 |
PRBool mObservingParent; |
| 119 |
}; |
146 |
}; |
| 120 |
|
147 |
|
| 121 |
// construction, destruction |
148 |
// construction, destruction |
| 122 |
|
149 |
|
| 123 |
|
150 |
|
| 124 |
NS_IMPL_NS_NEW_HTML_ELEMENT(Label) |
151 |
NS_IMPL_NS_NEW_HTML_ELEMENT(Label) |
| 125 |
|
152 |
|
| 126 |
|
153 |
|
| 127 |
nsHTMLLabelElement::nsHTMLLabelElement(nsINodeInfo *aNodeInfo) |
154 |
nsHTMLLabelElement::nsHTMLLabelElement(nsINodeInfo *aNodeInfo) |
| 128 |
: nsGenericHTMLFormElement(aNodeInfo) |
155 |
: nsGenericHTMLFormElement(aNodeInfo) |
| 129 |
, mHandlingEvent(PR_FALSE) |
156 |
, mHandlingEvent(PR_FALSE) |
|
|
157 |
, mObservingParent(PR_FALSE) |
| 130 |
{ |
158 |
{ |
| 131 |
} |
159 |
} |
| 132 |
|
160 |
|
| 133 |
nsHTMLLabelElement::~nsHTMLLabelElement() |
161 |
nsHTMLLabelElement::~nsHTMLLabelElement() |
| 134 |
{ |
162 |
{ |
|
|
163 |
if (mControl) { |
| 164 |
mControl->RemoveLabel(this); |
| 165 |
mControl = nsnull; |
| 166 |
} |
| 135 |
} |
167 |
} |
| 136 |
|
168 |
|
| 137 |
// nsISupports |
169 |
// nsISupports |
| 138 |
|
170 |
|
|
|
171 |
NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLLabelElement) |
| 139 |
|
172 |
|
| 140 |
NS_IMPL_ADDREF_INHERITED(nsHTMLLabelElement, nsGenericElement) |
173 |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLLabelElement, nsGenericHTMLFormElement) |
| 141 |
NS_IMPL_RELEASE_INHERITED(nsHTMLLabelElement, nsGenericElement) |
174 |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mControl) |
|
|
175 |
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
| 176 |
|
| 177 |
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLLabelElement, nsGenericHTMLFormElement) |
| 178 |
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mControl) |
| 179 |
NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
| 180 |
|
| 181 |
NS_IMPL_ADDREF_INHERITED(nsHTMLLabelElement, nsGenericHTMLElement) |
| 182 |
NS_IMPL_RELEASE_INHERITED(nsHTMLLabelElement, nsGenericHTMLElement) |
| 142 |
|
183 |
|
| 143 |
|
184 |
|
| 144 |
DOMCI_DATA(HTMLLabelElement, nsHTMLLabelElement) |
185 |
DOMCI_DATA(HTMLLabelElement, nsHTMLLabelElement) |
| 145 |
|
186 |
|
| 146 |
// QueryInterface implementation for nsHTMLLabelElement |
187 |
// QueryInterface implementation for nsHTMLLabelElement |
| 147 |
NS_INTERFACE_TABLE_HEAD(nsHTMLLabelElement) |
188 |
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLLabelElement) |
| 148 |
NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLLabelElement, |
189 |
NS_HTML_CONTENT_INTERFACE_TABLE3(nsHTMLLabelElement, |
| 149 |
nsIDOMHTMLLabelElement, |
190 |
nsIDOMHTMLLabelElement, |
| 150 |
nsIDOMNSHTMLLabelElement) |
191 |
nsIDOMNSHTMLLabelElement, |
|
|
192 |
nsIMutationObserver) |
| 151 |
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLabelElement, |
193 |
NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLabelElement, |
| 152 |
nsGenericHTMLFormElement) |
194 |
nsGenericHTMLFormElement) |
| 153 |
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLabelElement) |
195 |
NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLabelElement) |
| 154 |
|
196 |
|
| 155 |
|
197 |
|
| 156 |
// nsIDOMHTMLLabelElement |
198 |
// nsIDOMHTMLLabelElement |
| 157 |
|
199 |
|
| 158 |
|
200 |
|
|
Lines 206-231
nsHTMLLabelElement::BindToTree(nsIDocume
|
Link Here
|
|---|
|
| 206 |
aBindingParent, |
248 |
aBindingParent, |
| 207 |
aCompileEventHandlers); |
249 |
aCompileEventHandlers); |
| 208 |
NS_ENSURE_SUCCESS(rv, rv); |
250 |
NS_ENSURE_SUCCESS(rv, rv); |
| 209 |
|
251 |
|
| 210 |
if (aDocument) { |
252 |
if (aDocument) { |
| 211 |
RegUnRegAccessKey(PR_TRUE); |
253 |
RegUnRegAccessKey(PR_TRUE); |
| 212 |
} |
254 |
} |
| 213 |
|
255 |
|
|
|
256 |
if (aParent) { |
| 257 |
aParent->AddMutationObserver(this); |
| 258 |
mObservingParent = PR_TRUE; |
| 259 |
} |
| 260 |
|
| 214 |
return rv; |
261 |
return rv; |
| 215 |
} |
262 |
} |
| 216 |
|
263 |
|
| 217 |
void |
264 |
void |
| 218 |
nsHTMLLabelElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent) |
265 |
nsHTMLLabelElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent) |
| 219 |
{ |
266 |
{ |
| 220 |
if (IsInDoc()) { |
267 |
if (IsInDoc()) { |
| 221 |
RegUnRegAccessKey(PR_FALSE); |
268 |
RegUnRegAccessKey(PR_FALSE); |
| 222 |
} |
269 |
} |
| 223 |
|
270 |
|
|
|
271 |
if (mControl) { |
| 272 |
mControl->RemoveLabel(this); |
| 273 |
} |
| 274 |
|
| 275 |
nsIContent* parent = GetParent(); |
| 276 |
if (mObservingParent && parent) { |
| 277 |
parent->RemoveMutationObserver(this); |
| 278 |
} |
| 279 |
|
| 224 |
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent); |
280 |
nsGenericHTMLFormElement::UnbindFromTree(aDeep, aNullParent); |
| 225 |
} |
281 |
} |
| 226 |
|
282 |
|
| 227 |
static PRBool |
283 |
static PRBool |
| 228 |
EventTargetIn(nsEvent *aEvent, nsIContent *aChild, nsIContent *aStop) |
284 |
EventTargetIn(nsEvent *aEvent, nsIContent *aChild, nsIContent *aStop) |
| 229 |
{ |
285 |
{ |
| 230 |
nsCOMPtr<nsIContent> c = do_QueryInterface(aEvent->target); |
286 |
nsCOMPtr<nsIContent> c = do_QueryInterface(aEvent->target); |
| 231 |
nsIContent *content = c; |
287 |
nsIContent *content = c; |
|
Lines 356-373
nsHTMLLabelElement::SubmitNamesValues(ns
|
Link Here
|
|---|
|
| 356 |
{ |
412 |
{ |
| 357 |
return NS_OK; |
413 |
return NS_OK; |
| 358 |
} |
414 |
} |
| 359 |
|
415 |
|
| 360 |
nsresult |
416 |
nsresult |
| 361 |
nsHTMLLabelElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, |
417 |
nsHTMLLabelElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, |
| 362 |
const nsAString& aValue, PRBool aNotify) |
418 |
const nsAString& aValue, PRBool aNotify) |
| 363 |
{ |
419 |
{ |
| 364 |
if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID) { |
420 |
if (kNameSpaceID_None == aNameSpaceID) { |
| 365 |
RegUnRegAccessKey(PR_FALSE); |
421 |
if (aName == nsGkAtoms::accesskey) { |
|
|
422 |
RegUnRegAccessKey(PR_FALSE); |
| 423 |
} |
| 424 |
if (aName == nsGkAtoms::_for && !aValue.IsEmpty()) { |
| 425 |
if (mControl) { |
| 426 |
mControl->RemoveLabel(this); |
| 427 |
mControl = nsnull; |
| 428 |
} |
| 429 |
} |
| 366 |
} |
430 |
} |
| 367 |
|
431 |
|
| 368 |
nsresult rv = |
432 |
nsresult rv = |
| 369 |
nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue, |
433 |
nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue, |
| 370 |
aNotify); |
434 |
aNotify); |
| 371 |
|
435 |
|
| 372 |
if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID && |
436 |
if (aName == nsGkAtoms::accesskey && kNameSpaceID_None == aNameSpaceID && |
| 373 |
!aValue.IsEmpty()) { |
437 |
!aValue.IsEmpty()) { |
|
Lines 376-394
nsHTMLLabelElement::SetAttr(PRInt32 aNam
|
Link Here
|
|---|
|
| 376 |
|
440 |
|
| 377 |
return rv; |
441 |
return rv; |
| 378 |
} |
442 |
} |
| 379 |
|
443 |
|
| 380 |
nsresult |
444 |
nsresult |
| 381 |
nsHTMLLabelElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, |
445 |
nsHTMLLabelElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, |
| 382 |
PRBool aNotify) |
446 |
PRBool aNotify) |
| 383 |
{ |
447 |
{ |
| 384 |
if (aAttribute == nsGkAtoms::accesskey && |
448 |
if (kNameSpaceID_None == aNameSpaceID) { |
| 385 |
kNameSpaceID_None == aNameSpaceID) { |
449 |
if (aAttribute == nsGkAtoms::accesskey) { |
| 386 |
RegUnRegAccessKey(PR_FALSE); |
450 |
RegUnRegAccessKey(PR_FALSE); |
|
|
451 |
} |
| 452 |
if (aAttribute == nsGkAtoms::_for) { |
| 453 |
SetControl(); |
| 454 |
} |
| 387 |
} |
455 |
} |
| 388 |
|
456 |
|
| 389 |
return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify); |
457 |
return nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aAttribute, aNotify); |
| 390 |
} |
458 |
} |
| 391 |
|
459 |
|
| 392 |
void |
460 |
void |
| 393 |
nsHTMLLabelElement::PerformAccesskey(PRBool aKeyCausesActivation, |
461 |
nsHTMLLabelElement::PerformAccesskey(PRBool aKeyCausesActivation, |
| 394 |
PRBool aIsTrustedEvent) |
462 |
PRBool aIsTrustedEvent) |
|
Lines 410-450
nsHTMLLabelElement::PerformAccesskey(PRB
|
Link Here
|
|---|
|
| 410 |
nsAutoPopupStatePusher popupStatePusher(aIsTrustedEvent ? |
478 |
nsAutoPopupStatePusher popupStatePusher(aIsTrustedEvent ? |
| 411 |
openAllowed : openAbused); |
479 |
openAllowed : openAbused); |
| 412 |
|
480 |
|
| 413 |
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext, |
481 |
nsEventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext, |
| 414 |
&event); |
482 |
&event); |
| 415 |
} |
483 |
} |
| 416 |
} |
484 |
} |
| 417 |
|
485 |
|
|
|
486 |
void |
| 487 |
nsHTMLLabelElement::SetControl() |
| 488 |
{ |
| 489 |
nsAutoString elementId; |
| 490 |
|
| 491 |
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::_for, elementId)) { |
| 492 |
nsCOMPtr<nsIContent> content = GetFirstFormControl(this); |
| 493 |
mControl = do_QueryInterface(content); |
| 494 |
if (mControl) { |
| 495 |
mControl->AppendLabel(this); |
| 496 |
} |
| 497 |
} else { |
| 498 |
if (mControl) { |
| 499 |
mControl->RemoveLabel(this); |
| 500 |
mControl = nsnull; |
| 501 |
} |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 418 |
already_AddRefed<nsIContent> |
505 |
already_AddRefed<nsIContent> |
| 419 |
nsHTMLLabelElement::GetControlContent() |
506 |
nsHTMLLabelElement::GetControlContent() |
| 420 |
{ |
507 |
{ |
| 421 |
nsAutoString elementId; |
508 |
nsAutoString elementId; |
| 422 |
|
509 |
|
| 423 |
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::_for, elementId)) { |
510 |
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::_for, elementId)) { |
| 424 |
// No @for, so we are a label for our first form control element. |
511 |
// No @for, so we are a label for our first form control element. |
| 425 |
// Do a depth-first traversal to look for the first form control element. |
512 |
// Do a depth-first traversal to look for the first form control element. |
| 426 |
return GetFirstFormControl(this); |
513 |
if (!mControl) { |
|
|
514 |
SetControl(); |
| 515 |
} |
| 516 |
nsCOMPtr<nsIContent> content = do_QueryInterface(mControl); |
| 517 |
return content.get(); |
| 427 |
} |
518 |
} |
| 428 |
|
519 |
|
| 429 |
// We have a @for. The id has to be linked to an element in the same document |
520 |
// We have a @for. The id has to be linked to an element in the same document |
| 430 |
// and this element should be a labelable form control. |
521 |
// and this element should be a labelable form control. |
| 431 |
nsIDocument* doc = GetCurrentDoc(); |
522 |
nsIDocument* doc = GetCurrentDoc(); |
| 432 |
if (!doc) { |
523 |
if (!doc) { |
| 433 |
return nsnull; |
524 |
return nsnull; |
| 434 |
} |
525 |
} |
| 435 |
|
526 |
|
| 436 |
nsIContent* content = doc->GetElementById(elementId); |
527 |
nsIContent* content = doc->GetElementById(elementId); |
| 437 |
if (!content) { |
528 |
if (!content) { |
| 438 |
return nsnull; |
529 |
return nsnull; |
| 439 |
} |
530 |
} |
| 440 |
|
531 |
|
| 441 |
nsCOMPtr<nsIFormControl> element = do_QueryInterface(content); |
532 |
nsCOMPtr<nsILabelableElement> element = do_QueryInterface(content); |
| 442 |
if (element && element->IsLabelableControl()) { |
533 |
if (element) { |
| 443 |
NS_ADDREF(content); |
534 |
NS_ADDREF(content); |
| 444 |
return content; |
535 |
return content; |
| 445 |
} |
536 |
} |
| 446 |
|
537 |
|
| 447 |
return nsnull; |
538 |
return nsnull; |
| 448 |
} |
539 |
} |
| 449 |
|
540 |
|
| 450 |
already_AddRefed<nsIContent> |
541 |
already_AddRefed<nsIContent> |
|
Lines 453-475
nsHTMLLabelElement::GetFirstFormControl(
|
Link Here
|
|---|
|
| 453 |
PRUint32 numNodes = current->GetChildCount(); |
544 |
PRUint32 numNodes = current->GetChildCount(); |
| 454 |
|
545 |
|
| 455 |
for (PRUint32 i = 0; i < numNodes; i++) { |
546 |
for (PRUint32 i = 0; i < numNodes; i++) { |
| 456 |
nsIContent *child = current->GetChildAt(i); |
547 |
nsIContent *child = current->GetChildAt(i); |
| 457 |
if (!child) { |
548 |
if (!child) { |
| 458 |
continue; |
549 |
continue; |
| 459 |
} |
550 |
} |
| 460 |
|
551 |
|
| 461 |
nsCOMPtr<nsIFormControl> element = do_QueryInterface(child); |
552 |
nsCOMPtr<nsILabelableElement> element = do_QueryInterface(child); |
| 462 |
if (element && element->IsLabelableControl()) { |
553 |
if (element) { |
| 463 |
NS_ADDREF(child); |
554 |
NS_ADDREF(child); |
| 464 |
return child; |
555 |
return child; |
| 465 |
} |
556 |
} |
| 466 |
|
557 |
|
| 467 |
nsIContent* content = GetFirstFormControl(child).get(); |
558 |
nsIContent* content = GetFirstFormControl(child).get(); |
| 468 |
if (content) { |
559 |
if (content) { |
| 469 |
return content; |
560 |
return content; |
| 470 |
} |
561 |
} |
| 471 |
} |
562 |
} |
| 472 |
|
563 |
|
| 473 |
return nsnull; |
564 |
return nsnull; |
| 474 |
} |
565 |
} |
| 475 |
|
566 |
|
|
|
567 |
// nsIMutationObserver |
| 568 |
|
| 569 |
void |
| 570 |
nsHTMLLabelElement::ContentAppended(nsIDocument* aDocument, |
| 571 |
nsIContent* aContainer, |
| 572 |
nsIContent* aFirstNewContent, |
| 573 |
PRInt32 aNewIndexInContainer) |
| 574 |
{ |
| 575 |
if (mObservingParent && aFirstNewContent == this) { |
| 576 |
GetParent()->RemoveMutationObserver(this); |
| 577 |
AddMutationObserver(this); |
| 578 |
mObservingParent = PR_FALSE; |
| 579 |
} else { |
| 580 |
SetControl(); |
| 581 |
} |
| 582 |
} |
| 583 |
|
| 584 |
void |
| 585 |
nsHTMLLabelElement::ContentInserted(nsIDocument* aDocument, |
| 586 |
nsIContent* aContainer, |
| 587 |
nsIContent* aChild, |
| 588 |
PRInt32 aIndexInContainer) |
| 589 |
{ |
| 590 |
if (mObservingParent) { |
| 591 |
if (aContainer == this) { |
| 592 |
SetControl(); |
| 593 |
} else if (aChild == this) { |
| 594 |
GetParent()->RemoveMutationObserver(this); |
| 595 |
AddMutationObserver(this); |
| 596 |
mObservingParent = PR_FALSE; |
| 597 |
} |
| 598 |
} else { |
| 599 |
SetControl(); |
| 600 |
} |
| 601 |
} |
| 602 |
|
| 603 |
void |
| 604 |
nsHTMLLabelElement::ContentRemoved(nsIDocument* aDocument, |
| 605 |
nsIContent* aContainer, |
| 606 |
nsIContent* aChild, |
| 607 |
PRInt32 aIndexInContainer) |
| 608 |
{ |
| 609 |
if (!mObservingParent) { |
| 610 |
SetControl(); |
| 611 |
} |
| 612 |
} |
| 613 |
|
| 614 |
void |
| 615 |
nsHTMLLabelElement::NodeWillBeDestroyed(const nsINode *aNode) |
| 616 |
{ |
| 617 |
if (!mObservingParent) { |
| 618 |
// TODO: useful ? |
| 619 |
#ifdef DEBUG |
| 620 |
printf(" === nsHTMLLabelElement::NodeWillBeDestroyed\n"); |
| 621 |
#endif // DEBUG |
| 622 |
} |
| 623 |
} |
| 624 |
|