diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 47aee641859..3bb2d445bef 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -136,6 +136,7 @@ public: NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD CollapseToStart(); NS_IMETHOD CollapseToEnd(); + NS_IMETHOD SelectAllChildren(nsIDOMNode* parentNode); NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aAYes); NS_IMETHOD DeleteFromDocument(); @@ -1468,14 +1469,12 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA case nsIDOMKeyEvent::DOM_VK_HOME : InvalidateDesiredX(); pos.mAmount = eSelectBeginLine; - InvalidateDesiredX(); mHint = HINTRIGHT;//stick to opposite of movement PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_END : InvalidateDesiredX(); pos.mAmount = eSelectEndLine; - InvalidateDesiredX(); mHint = HINTLEFT;//stick to this line PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); break; @@ -1627,7 +1626,6 @@ nsDOMSelection::GetHint(PRBool *aHintRight) return rv; } - NS_IMETHODIMP nsSelection::HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, PRUint32 aContentEndOffset, PRBool aContinueSelection, @@ -5520,6 +5518,45 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) return mFrameSelection->NotifySelectionListeners(GetType()); } +static inline nsresult GetChildOffset(nsIDOMNode *aChild, nsIDOMNode *aParent, PRInt32 &aOffset) +{ + NS_ASSERTION((aChild && aParent), "bad args"); + if (!aChild || !aParent) return NS_ERROR_NULL_POINTER; + nsCOMPtr content = do_QueryInterface(aParent); + nsCOMPtr cChild = do_QueryInterface(aChild); + if (!cChild || !content) return NS_ERROR_NULL_POINTER; + nsresult res = content->IndexOf(cChild, aOffset); + return res; +} + +NS_IMETHODIMP +nsDOMSelection::SelectAllChildren(nsIDOMNode* aParentNode) +{ + NS_ENSURE_ARG_POINTER(aParentNode); + + if (mFrameSelection) + { + mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + } + nsresult result = Collapse(aParentNode, 0); + if (NS_SUCCEEDED(result)) + { + nsCOMPtrlastChild; + result = aParentNode->GetLastChild(getter_AddRefs(lastChild)); + if ((NS_SUCCEEDED(result)) && lastChild) + { + PRInt32 numBodyChildren=0; + GetChildOffset(lastChild, aParentNode, numBodyChildren); + if (mFrameSelection) + { + mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + } + result = Extend(aParentNode, numBodyChildren+1); + } + } + return result; +} + NS_IMETHODIMP nsDOMSelection::ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aYes) { diff --git a/mozilla/dom/public/idl/range/Selection.idl b/mozilla/dom/public/idl/range/Selection.idl index 227cfb2ab2a..c43a18b5de1 100644 --- a/mozilla/dom/public/idl/range/Selection.idl +++ b/mozilla/dom/public/idl/range/Selection.idl @@ -19,10 +19,11 @@ void collapse(in Node parentNode, in long offset); void extend(in Node parentNode, in long offset); - void collapseToStart(); - void collapseToEnd(); + void collapseToStart(); + void collapseToEnd(); + void selectAllChildren(in Node parentNode); - boolean containsNode(in Node node, in boolean recursive); + boolean containsNode(in Node node, in boolean recursive); void deleteFromDocument(); diff --git a/mozilla/dom/public/idl/range/SelectionListener.idl b/mozilla/dom/public/idl/range/SelectionListener.idl index e0bdb63886f..b318c3daef8 100644 --- a/mozilla/dom/public/idl/range/SelectionListener.idl +++ b/mozilla/dom/public/idl/range/SelectionListener.idl @@ -6,6 +6,7 @@ const short MOUSEDOWN_REASON=2;/*bitflags*/ const short MOUSEUP_REASON=4;/*bitflags*/ const short KEYPRESS_REASON=8;/*bitflags*/ + const short SELECTALL_REASON=16;/*bitflags*/ /* Select All special command */ void notifySelectionChanged(in Document doc, in Selection sel, in short reason); }; diff --git a/mozilla/dom/public/nsDOMPropEnums.h b/mozilla/dom/public/nsDOMPropEnums.h index 959eb962ee3..679bb74010f 100644 --- a/mozilla/dom/public/nsDOMPropEnums.h +++ b/mozilla/dom/public/nsDOMPropEnums.h @@ -908,6 +908,7 @@ enum nsDOMProp { NS_DOM_PROP_SELECTION_RANGECOUNT, NS_DOM_PROP_SELECTION_REMOVERANGE, NS_DOM_PROP_SELECTION_REMOVESELECTIONLISTENER, + NS_DOM_PROP_SELECTION_SELECTALLCHILDREN, NS_DOM_PROP_SELECTION_SETHINT, NS_DOM_PROP_SELECTION_STARTBATCHCHANGES, NS_DOM_PROP_SELECTION_TOSTRING, diff --git a/mozilla/dom/public/nsDOMPropNames.h b/mozilla/dom/public/nsDOMPropNames.h index 89f107d1f8e..732a7a0ceed 100644 --- a/mozilla/dom/public/nsDOMPropNames.h +++ b/mozilla/dom/public/nsDOMPropNames.h @@ -906,6 +906,7 @@ "selection.rangecount", \ "selection.removerange", \ "selection.removeselectionlistener", \ + "selection.selectallchildren", \ "selection.sethint", \ "selection.startbatchchanges", \ "selection.tostring", \ diff --git a/mozilla/dom/public/range/nsIDOMSelection.h b/mozilla/dom/public/range/nsIDOMSelection.h index 144c2f22f61..74e9ad75d22 100644 --- a/mozilla/dom/public/range/nsIDOMSelection.h +++ b/mozilla/dom/public/range/nsIDOMSelection.h @@ -65,6 +65,8 @@ public: NS_IMETHOD CollapseToEnd()=0; + NS_IMETHOD SelectAllChildren(nsIDOMNode* aParentNode)=0; + NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aReturn)=0; NS_IMETHOD DeleteFromDocument()=0; @@ -104,6 +106,7 @@ public: NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset); \ NS_IMETHOD CollapseToStart(); \ NS_IMETHOD CollapseToEnd(); \ + NS_IMETHOD SelectAllChildren(nsIDOMNode* aParentNode); \ NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aReturn); \ NS_IMETHOD DeleteFromDocument(); \ NS_IMETHOD AddRange(nsIDOMRange* aRange); \ @@ -132,6 +135,7 @@ public: NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) { return _to Extend(aParentNode, aOffset); } \ NS_IMETHOD CollapseToStart() { return _to CollapseToStart(); } \ NS_IMETHOD CollapseToEnd() { return _to CollapseToEnd(); } \ + NS_IMETHOD SelectAllChildren(nsIDOMNode* aParentNode) { return _to SelectAllChildren(aParentNode); } \ NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aReturn) { return _to ContainsNode(aNode, aRecursive, aReturn); } \ NS_IMETHOD DeleteFromDocument() { return _to DeleteFromDocument(); } \ NS_IMETHOD AddRange(nsIDOMRange* aRange) { return _to AddRange(aRange); } \ diff --git a/mozilla/dom/public/range/nsIDOMSelectionListener.h b/mozilla/dom/public/range/nsIDOMSelectionListener.h index 2d5d055e743..cd4eb436e0d 100644 --- a/mozilla/dom/public/range/nsIDOMSelectionListener.h +++ b/mozilla/dom/public/range/nsIDOMSelectionListener.h @@ -43,7 +43,8 @@ public: DRAG_REASON = 1, MOUSEDOWN_REASON = 2, MOUSEUP_REASON = 4, - KEYPRESS_REASON = 8 + KEYPRESS_REASON = 8, + SELECTALL_REASON = 16 }; NS_IMETHOD NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelection* aSel, PRInt16 aReason)=0; diff --git a/mozilla/dom/src/range/nsJSSelection.cpp b/mozilla/dom/src/range/nsJSSelection.cpp index a66eaaad1b0..66e1819919a 100644 --- a/mozilla/dom/src/range/nsJSSelection.cpp +++ b/mozilla/dom/src/range/nsJSSelection.cpp @@ -485,6 +485,53 @@ SelectionCollapseToEnd(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js } +// +// Native method SelectAllChildren +// +PR_STATIC_CALLBACK(JSBool) +SelectionSelectAllChildren(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); + nsresult result = NS_OK; + nsCOMPtr b0; + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + { + *rval = JSVAL_NULL; + nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); + if (!secMan) + return PR_FALSE; + result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_SELECTALLCHILDREN, PR_FALSE); + if (NS_FAILED(result)) { + return nsJSUtils::nsReportError(cx, obj, result); + } + if (argc < 1) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0), + kINodeIID, + NS_ConvertASCIItoUCS2("Node"), + cx, + argv[0])) { + return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); + } + + result = nativeThis->SelectAllChildren(b0); + if (NS_FAILED(result)) { + return nsJSUtils::nsReportError(cx, obj, result); + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + // // Native method ContainsNode // @@ -1005,6 +1052,7 @@ static JSFunctionSpec SelectionMethods[] = {"extend", SelectionExtend, 2}, {"collapseToStart", SelectionCollapseToStart, 0}, {"collapseToEnd", SelectionCollapseToEnd, 0}, + {"selectAllChildren", SelectionSelectAllChildren, 1}, {"containsNode", SelectionContainsNode, 2}, {"deleteFromDocument", SelectionDeleteFromDocument, 0}, {"addRange", SelectionAddRange, 1}, diff --git a/mozilla/dom/src/range/nsJSSelectionListener.cpp b/mozilla/dom/src/range/nsJSSelectionListener.cpp index 01c7d8111da..7e475cc4a06 100644 --- a/mozilla/dom/src/range/nsJSSelectionListener.cpp +++ b/mozilla/dom/src/range/nsJSSelectionListener.cpp @@ -304,6 +304,9 @@ extern "C" NS_DOM nsresult NS_InitSelectionListenerClass(nsIScriptContext *aCont vp = INT_TO_JSVAL(nsIDOMSelectionListener::KEYPRESS_REASON); JS_SetProperty(jscontext, constructor, "KEYPRESS_REASON", &vp); + vp = INT_TO_JSVAL(nsIDOMSelectionListener::SELECTALL_REASON); + JS_SetProperty(jscontext, constructor, "SELECTALL_REASON", &vp); + } } diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index 23dda5472e1..777e314af0e 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -2991,18 +2991,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection) nsCOMPtrbodyNode = do_QueryInterface(bodyElement); if (bodyNode) { - result = aSelection->Collapse(bodyNode, 0); - if (NS_SUCCEEDED(result)) - { - PRInt32 numBodyChildren=0; - nsCOMPtrlastChild; - result = bodyNode->GetLastChild(getter_AddRefs(lastChild)); - if ((NS_SUCCEEDED(result)) && lastChild) - { - GetChildOffset(lastChild, bodyNode, numBodyChildren); - result = aSelection->Extend(bodyNode, numBodyChildren+1); - } - } + result = aSelection->SelectAllChildren(bodyNode); } else { return NS_ERROR_NO_INTERFACE; diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 23dda5472e1..777e314af0e 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -2991,18 +2991,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection) nsCOMPtrbodyNode = do_QueryInterface(bodyElement); if (bodyNode) { - result = aSelection->Collapse(bodyNode, 0); - if (NS_SUCCEEDED(result)) - { - PRInt32 numBodyChildren=0; - nsCOMPtrlastChild; - result = bodyNode->GetLastChild(getter_AddRefs(lastChild)); - if ((NS_SUCCEEDED(result)) && lastChild) - { - GetChildOffset(lastChild, bodyNode, numBodyChildren); - result = aSelection->Extend(bodyNode, numBodyChildren+1); - } - } + result = aSelection->SelectAllChildren(bodyNode); } else { return NS_ERROR_NO_INTERFACE; diff --git a/mozilla/layout/base/src/nsSelection.cpp b/mozilla/layout/base/src/nsSelection.cpp index 47aee641859..3bb2d445bef 100644 --- a/mozilla/layout/base/src/nsSelection.cpp +++ b/mozilla/layout/base/src/nsSelection.cpp @@ -136,6 +136,7 @@ public: NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD CollapseToStart(); NS_IMETHOD CollapseToEnd(); + NS_IMETHOD SelectAllChildren(nsIDOMNode* parentNode); NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aAYes); NS_IMETHOD DeleteFromDocument(); @@ -1468,14 +1469,12 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA case nsIDOMKeyEvent::DOM_VK_HOME : InvalidateDesiredX(); pos.mAmount = eSelectBeginLine; - InvalidateDesiredX(); mHint = HINTRIGHT;//stick to opposite of movement PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_END : InvalidateDesiredX(); pos.mAmount = eSelectEndLine; - InvalidateDesiredX(); mHint = HINTLEFT;//stick to this line PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); break; @@ -1627,7 +1626,6 @@ nsDOMSelection::GetHint(PRBool *aHintRight) return rv; } - NS_IMETHODIMP nsSelection::HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, PRUint32 aContentEndOffset, PRBool aContinueSelection, @@ -5520,6 +5518,45 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) return mFrameSelection->NotifySelectionListeners(GetType()); } +static inline nsresult GetChildOffset(nsIDOMNode *aChild, nsIDOMNode *aParent, PRInt32 &aOffset) +{ + NS_ASSERTION((aChild && aParent), "bad args"); + if (!aChild || !aParent) return NS_ERROR_NULL_POINTER; + nsCOMPtr content = do_QueryInterface(aParent); + nsCOMPtr cChild = do_QueryInterface(aChild); + if (!cChild || !content) return NS_ERROR_NULL_POINTER; + nsresult res = content->IndexOf(cChild, aOffset); + return res; +} + +NS_IMETHODIMP +nsDOMSelection::SelectAllChildren(nsIDOMNode* aParentNode) +{ + NS_ENSURE_ARG_POINTER(aParentNode); + + if (mFrameSelection) + { + mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + } + nsresult result = Collapse(aParentNode, 0); + if (NS_SUCCEEDED(result)) + { + nsCOMPtrlastChild; + result = aParentNode->GetLastChild(getter_AddRefs(lastChild)); + if ((NS_SUCCEEDED(result)) && lastChild) + { + PRInt32 numBodyChildren=0; + GetChildOffset(lastChild, aParentNode, numBodyChildren); + if (mFrameSelection) + { + mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + } + result = Extend(aParentNode, numBodyChildren+1); + } + } + return result; +} + NS_IMETHODIMP nsDOMSelection::ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aYes) { diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 47aee641859..3bb2d445bef 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -136,6 +136,7 @@ public: NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD CollapseToStart(); NS_IMETHOD CollapseToEnd(); + NS_IMETHOD SelectAllChildren(nsIDOMNode* parentNode); NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aAYes); NS_IMETHOD DeleteFromDocument(); @@ -1468,14 +1469,12 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA case nsIDOMKeyEvent::DOM_VK_HOME : InvalidateDesiredX(); pos.mAmount = eSelectBeginLine; - InvalidateDesiredX(); mHint = HINTRIGHT;//stick to opposite of movement PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_END : InvalidateDesiredX(); pos.mAmount = eSelectEndLine; - InvalidateDesiredX(); mHint = HINTLEFT;//stick to this line PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); break; @@ -1627,7 +1626,6 @@ nsDOMSelection::GetHint(PRBool *aHintRight) return rv; } - NS_IMETHODIMP nsSelection::HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, PRUint32 aContentEndOffset, PRBool aContinueSelection, @@ -5520,6 +5518,45 @@ nsDOMSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) return mFrameSelection->NotifySelectionListeners(GetType()); } +static inline nsresult GetChildOffset(nsIDOMNode *aChild, nsIDOMNode *aParent, PRInt32 &aOffset) +{ + NS_ASSERTION((aChild && aParent), "bad args"); + if (!aChild || !aParent) return NS_ERROR_NULL_POINTER; + nsCOMPtr content = do_QueryInterface(aParent); + nsCOMPtr cChild = do_QueryInterface(aChild); + if (!cChild || !content) return NS_ERROR_NULL_POINTER; + nsresult res = content->IndexOf(cChild, aOffset); + return res; +} + +NS_IMETHODIMP +nsDOMSelection::SelectAllChildren(nsIDOMNode* aParentNode) +{ + NS_ENSURE_ARG_POINTER(aParentNode); + + if (mFrameSelection) + { + mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + } + nsresult result = Collapse(aParentNode, 0); + if (NS_SUCCEEDED(result)) + { + nsCOMPtrlastChild; + result = aParentNode->GetLastChild(getter_AddRefs(lastChild)); + if ((NS_SUCCEEDED(result)) && lastChild) + { + PRInt32 numBodyChildren=0; + GetChildOffset(lastChild, aParentNode, numBodyChildren); + if (mFrameSelection) + { + mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + } + result = Extend(aParentNode, numBodyChildren+1); + } + } + return result; +} + NS_IMETHODIMP nsDOMSelection::ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aYes) { diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp index 05148a209e9..dd3a8adb93d 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp @@ -296,8 +296,7 @@ nsTextInputListener::KeyPress(nsIDOMEvent* aKeyEvent) //END KeyListener -//BEGIN NS_IDOMSELECITONLISTENER - +//BEGIN NS_IDOMSELECTIONLISTENER NS_IMETHODIMP nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelection* aSel, PRInt16 aReason) @@ -309,31 +308,39 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelectio // Fire the select event // The specs don't exactly say when we should fire the select event. // IE: Whenever you add/remove a character to/from the selection. Also - // if you get to the end of the text field you will get new event for each - // keypress or a continuous stream of events if you use the mouse. IE will - // fire select event when the selection collapses to nothing if you are holding down + // each time for select all. Also if you get to the end of the text + // field you will get new event for each keypress or a continuous + // stream of events if you use the mouse. IE will fire select event + // when the selection collapses to nothing if you are holding down // the shift or mouse button. // Mozilla: If we have non-empty selection we will fire a new event for each - // keypress (or mouseup) if the selection changed. Mozilla will never - // create an event if the selection collapses to nothing. - if (!collapsed && ((aReason & MOUSEUP_REASON) || (aReason & KEYPRESS_REASON))) { + // keypress (or mouseup) if the selection changed. Mozilla will also + // create the event each time select all is called, even if everything + // was previously selected, becase technically select all will first collapse + // and then extend. Mozilla will never create an event if the selection + // collapses to nothing. + if (!collapsed && (aReason & (nsIDOMSelectionListener::MOUSEUP_REASON | + nsIDOMSelectionListener::KEYPRESS_REASON | + nsIDOMSelectionListener::SELECTALL_REASON))) + { nsCOMPtr content; mFrame->GetFormContent(*getter_AddRefs(content)); - if (content) { - nsEventStatus status = nsEventStatus_eIgnore; - nsEvent event; - event.eventStructType = NS_EVENT; - event.message = NS_FORM_SELECTED; - + if (content) + { nsCOMPtr doc; - if (NS_SUCCEEDED(content->GetDocument(*getter_AddRefs(doc)))) { - if (doc) { + if (NS_SUCCEEDED(content->GetDocument(*getter_AddRefs(doc)))) + { + if (doc) + { nsCOMPtr presShell = dont_AddRef(doc->GetShellAt(0)); - if (presShell) { - nsCOMPtr context; - if (NS_SUCCEEDED(presShell->GetPresContext(getter_AddRefs(context)))&& context) { - content->HandleDOMEvent(context, &event, nsnull, NS_EVENT_FLAG_INIT, &status); - } + if (presShell) + { + nsEventStatus status = nsEventStatus_eIgnore; + nsEvent event; + event.eventStructType = NS_EVENT; + event.message = NS_FORM_SELECTED; + + presShell->HandleEventWithTarget(&event,mFrame,content,&status); } } } @@ -343,7 +350,7 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelectio // if the collapsed state did not change, don't fire notifications if (mKnowSelectionCollapsed && collapsed == mSelectionWasCollapsed) return NS_OK; - + mSelectionWasCollapsed = collapsed; mKnowSelectionCollapsed = PR_TRUE; diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.h b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.h index 2f9638337a5..9ca65ddfd4d 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.h +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.h @@ -251,7 +251,6 @@ private: nsFormFrame *mFormFrame; nsTextInputSelectionImpl *mTextSelImpl; nsTextInputListener *mTextListener; - }; #endif