Bug 183905. Allow horizontal scrolling with mouse sticks. Patch by Dainis_Jonitis, r+sr=roc+moz
git-svn-id: svn://10.0.0.236/trunk@139310 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
5c988b1b21
commit
071d5592f4
@ -198,7 +198,7 @@ public:
|
||||
NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset);
|
||||
NS_IMETHOD CollapseToStart();
|
||||
NS_IMETHOD CollapseToEnd();
|
||||
NS_IMETHOD SelectAllChildren(nsIDOMNode* parentNode);
|
||||
NS_IMETHOD SelectAllChildren(nsIDOMNode* parentNode);
|
||||
NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset);
|
||||
NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aAYes);
|
||||
NS_IMETHOD DeleteFromDocument();
|
||||
@ -236,7 +236,7 @@ public:
|
||||
nsresult RemoveItem(nsIDOMRange *aRange);
|
||||
|
||||
nsresult Clear(nsIPresContext* aPresContext);
|
||||
// methods for convenience. Note, these don't addref
|
||||
// methods for convenience. Note, these don't addref
|
||||
nsIDOMNode* FetchAnchorNode(); //where did the selection begin
|
||||
PRInt32 FetchAnchorOffset();
|
||||
|
||||
@ -471,7 +471,7 @@ private:
|
||||
PRBool GetNotifyFrames(){return mNotifyFrames;}
|
||||
void SetDirty(PRBool aDirty=PR_TRUE){if (mBatching) mChangesDuringBatching = aDirty;}
|
||||
|
||||
nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc?
|
||||
nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc?
|
||||
|
||||
// utility method to lookup frame style
|
||||
nsresult FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSelectionStyle, nsIFrame* *foundFrame);
|
||||
@ -1475,18 +1475,18 @@ nsSelection::ShutDown()
|
||||
NS_IMETHODIMP
|
||||
nsSelection::HandleTextEvent(nsGUIEvent *aGUIEvent)
|
||||
{
|
||||
if (!aGUIEvent)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aGUIEvent)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
#ifdef DEBUG_TAGUE
|
||||
printf("nsSelection: HandleTextEvent\n");
|
||||
printf("nsSelection: HandleTextEvent\n");
|
||||
#endif
|
||||
nsresult result(NS_OK);
|
||||
if (NS_TEXT_EVENT == aGUIEvent->message) {
|
||||
if (NS_TEXT_EVENT == aGUIEvent->message) {
|
||||
PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL);
|
||||
result = mDomSelections[index]->ScrollIntoView();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -2714,7 +2714,7 @@ nsSelection::HandleDrag(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint&
|
||||
result = VisualSelectFrames(aPresContext, newFrame, pos);
|
||||
if (NS_FAILED(result))
|
||||
result = HandleClick(newContent, startPos, contentOffsetEnd, PR_TRUE,
|
||||
PR_FALSE, beginOfContent);
|
||||
PR_FALSE, beginOfContent);
|
||||
mHint = saveHint;
|
||||
}
|
||||
else
|
||||
@ -3098,10 +3098,10 @@ nsSelection::GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHin
|
||||
result = mTracker->GetPrimaryFrameFor(theNode, aReturnFrame);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
|
||||
if (!*aReturnFrame)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
|
||||
// find the child frame containing the offset we want
|
||||
result = (*aReturnFrame)->GetChildFrameContainingOffset(*aReturnOffset, aHint, &aOffset, aReturnFrame);
|
||||
return result;
|
||||
@ -3225,7 +3225,7 @@ nsSelection::CommonPageMove(PRBool aForward,
|
||||
|
||||
// scroll one page
|
||||
|
||||
aScrollableView->ScrollByPages(aForward ? 1 : -1);
|
||||
aScrollableView->ScrollByPages(0, aForward ? 1 : -1);
|
||||
|
||||
// place the caret
|
||||
result = aFrameSel->HandleClick(content, startOffset, startOffset, aExtend, PR_FALSE, PR_TRUE);
|
||||
@ -3343,8 +3343,8 @@ nsSelection::FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSe
|
||||
|
||||
while (thisFrame)
|
||||
{
|
||||
const nsStyleUIReset* userinterface;
|
||||
thisFrame->GetStyleData(eStyleStruct_UIReset, (const nsStyleStruct*&)userinterface);
|
||||
const nsStyleUIReset* userinterface;
|
||||
thisFrame->GetStyleData(eStyleStruct_UIReset, (const nsStyleStruct*&)userinterface);
|
||||
|
||||
if (userinterface->mUserSelect == aSelectionStyle)
|
||||
{
|
||||
@ -4257,7 +4257,7 @@ nsTypedSelection::addTableCellRange(nsIDOMRange *aRange, PRBool *aDidAddRange)
|
||||
// Insert range at appropriate location
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
nsIDOMRange* range = mRangeArray[index];
|
||||
nsIDOMRange* range = mRangeArray[index];
|
||||
if (!range) return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 selectionMode;
|
||||
@ -4697,11 +4697,11 @@ nsTypedSelection::SetPresShell(nsIPresShell *aPresShell)
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::GetAnchorNode(nsIDOMNode** aAnchorNode)
|
||||
{
|
||||
if (!aAnchorNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aAnchorNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aAnchorNode = nsnull;
|
||||
if(!mAnchorFocusRange)
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
|
||||
nsresult result;
|
||||
if (GetDirection() == eDirNext){
|
||||
@ -4710,14 +4710,14 @@ nsTypedSelection::GetAnchorNode(nsIDOMNode** aAnchorNode)
|
||||
else{
|
||||
result = mAnchorFocusRange->GetEndContainer(aAnchorNode);
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::GetAnchorOffset(PRInt32* aAnchorOffset)
|
||||
{
|
||||
if (!aAnchorOffset)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aAnchorOffset)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aAnchorOffset = nsnull;
|
||||
if(!mAnchorFocusRange)
|
||||
return NS_OK;
|
||||
@ -4729,15 +4729,15 @@ nsTypedSelection::GetAnchorOffset(PRInt32* aAnchorOffset)
|
||||
else{
|
||||
result = mAnchorFocusRange->GetEndOffset(aAnchorOffset);
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
// note: this can return a nil focus node
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::GetFocusNode(nsIDOMNode** aFocusNode)
|
||||
{
|
||||
if (!aFocusNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aFocusNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aFocusNode = nsnull;
|
||||
if(!mAnchorFocusRange)
|
||||
return NS_OK;
|
||||
@ -4750,13 +4750,13 @@ nsTypedSelection::GetFocusNode(nsIDOMNode** aFocusNode)
|
||||
result = mAnchorFocusRange->GetStartContainer(aFocusNode);
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTypedSelection::GetFocusOffset(PRInt32* aFocusOffset)
|
||||
{
|
||||
if (!aFocusOffset)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aFocusOffset)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aFocusOffset = nsnull;
|
||||
if(!mAnchorFocusRange)
|
||||
return NS_OK;
|
||||
@ -4768,7 +4768,7 @@ NS_IMETHODIMP nsTypedSelection::GetFocusOffset(PRInt32* aFocusOffset)
|
||||
else{
|
||||
result = mAnchorFocusRange->GetStartOffset(aFocusOffset);
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -4954,7 +4954,7 @@ nsTypedSelection::GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, PRInt32 aOf
|
||||
|
||||
*aReturnFrame = 0;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node = dont_QueryInterface(aNode);
|
||||
|
||||
@ -5905,7 +5905,7 @@ nsTypedSelection::GetEnumerator(nsIEnumerator **aIterator)
|
||||
nsresult status = NS_ERROR_OUT_OF_MEMORY;
|
||||
nsSelectionIterator *iterator = new nsSelectionIterator(this);
|
||||
if ( iterator && NS_FAILED(status = CallQueryInterface(iterator, aIterator)) )
|
||||
delete iterator;
|
||||
delete iterator;
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -5922,11 +5922,11 @@ nsTypedSelection::RemoveAllRanges()
|
||||
GetPresContext(getter_AddRefs(presContext));
|
||||
|
||||
|
||||
nsresult result = Clear(presContext);
|
||||
nsresult result = Clear(presContext);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
return result;
|
||||
|
||||
// Turn off signal for table selection
|
||||
// Turn off signal for table selection
|
||||
mFrameSelection->ClearTableCellSelection();
|
||||
|
||||
return mFrameSelection->NotifySelectionListeners(GetType());
|
||||
@ -6021,7 +6021,7 @@ nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
||||
GetPresContext(getter_AddRefs(presContext));
|
||||
Clear(presContext);
|
||||
|
||||
// Turn off signal for table selection
|
||||
// Turn off signal for table selection
|
||||
if (mFrameSelection)
|
||||
mFrameSelection->ClearTableCellSelection();
|
||||
|
||||
@ -6049,11 +6049,11 @@ nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
||||
content->GetTag(*getter_AddRefs(tag));
|
||||
if (tag)
|
||||
{
|
||||
nsAutoString tagString;
|
||||
tag->ToString(tagString);
|
||||
char * tagCString = ToNewCString(tagString);
|
||||
printf ("Sel. Collapse to %p %s %d\n", content, tagCString, aOffset);
|
||||
delete [] tagCString;
|
||||
nsAutoString tagString;
|
||||
tag->ToString(tagString);
|
||||
char * tagCString = ToNewCString(tagString);
|
||||
printf ("Sel. Collapse to %p %s %d\n", content, tagCString, aOffset);
|
||||
delete [] tagCString;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -6068,8 +6068,8 @@ nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
if (!mFrameSelection)
|
||||
return NS_OK;//nothing to do
|
||||
return mFrameSelection->NotifySelectionListeners(GetType());
|
||||
return NS_OK;//nothing to do
|
||||
return mFrameSelection->NotifySelectionListeners(GetType());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -6082,7 +6082,7 @@ nsTypedSelection::CollapseToStart()
|
||||
PRInt32 cnt;
|
||||
nsresult rv = GetRangeCount(&cnt);
|
||||
if (NS_FAILED(rv) || cnt <= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the first range
|
||||
nsIDOMRange* firstRange = mRangeArray[0];
|
||||
@ -6116,7 +6116,7 @@ nsTypedSelection::CollapseToEnd()
|
||||
PRInt32 cnt;
|
||||
nsresult rv = GetRangeCount(&cnt);
|
||||
if (NS_FAILED(rv) || cnt <= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the last range
|
||||
nsIDOMRange* lastRange = mRangeArray[cnt-1];
|
||||
@ -6146,9 +6146,9 @@ nsTypedSelection::CollapseToEnd()
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::GetIsCollapsed(PRBool* aIsCollapsed)
|
||||
{
|
||||
if (!aIsCollapsed)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!aIsCollapsed)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
PRInt32 cnt = mRangeArray.Count();;
|
||||
if (cnt == 0)
|
||||
{
|
||||
@ -6169,27 +6169,27 @@ NS_IMETHODIMP
|
||||
nsTypedSelection::GetRangeCount(PRInt32* aRangeCount)
|
||||
{
|
||||
if (!aRangeCount)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aRangeCount = mRangeArray.Count();
|
||||
|
||||
return NS_OK;
|
||||
*aRangeCount = mRangeArray.Count();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn)
|
||||
{
|
||||
if (!aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
PRInt32 cnt = mRangeArray.Count();
|
||||
if (aIndex < 0 || aIndex >= cnt)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
PRInt32 cnt = mRangeArray.Count();
|
||||
if (aIndex < 0 || aIndex >= cnt)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*aReturn = mRangeArray[aIndex];
|
||||
*aReturn = mRangeArray[aIndex];
|
||||
NS_IF_ADDREF(*aReturn);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef OLD_SELECTION
|
||||
@ -6839,11 +6839,11 @@ nsTypedSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
||||
content->GetTag(*getter_AddRefs(tag));
|
||||
if (tag)
|
||||
{
|
||||
nsAutoString tagString;
|
||||
tag->ToString(tagString);
|
||||
char * tagCString = ToNewCString(tagString);
|
||||
printf ("Sel. Extend to %p %s %d\n", content, tagCString, aOffset);
|
||||
delete [] tagCString;
|
||||
nsAutoString tagString;
|
||||
tag->ToString(tagString);
|
||||
char * tagCString = ToNewCString(tagString);
|
||||
printf ("Sel. Extend to %p %s %d\n", content, tagCString, aOffset);
|
||||
delete [] tagCString;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -6996,7 +6996,7 @@ nsTypedSelection::GetPresShell(nsIPresShell **aPresShell)
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
rv = presContext->GetShell(getter_AddRefs(shell));
|
||||
mPresShellWeak = getter_AddRefs(NS_GetWeakReference(shell)); // the presshell owns us, so no addref
|
||||
mPresShellWeak = getter_AddRefs(NS_GetWeakReference(shell)); // the presshell owns us, so no addref
|
||||
if (mPresShellWeak)
|
||||
NS_ADDREF(*aPresShell = shell);
|
||||
return rv;
|
||||
@ -7139,13 +7139,13 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n
|
||||
|
||||
nsCOMPtr<nsIDeviceContext> deviceContext;
|
||||
|
||||
rv = presContext->GetDeviceContext(getter_AddRefs(deviceContext));
|
||||
rv = presContext->GetDeviceContext(getter_AddRefs(deviceContext));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!deviceContext)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
//
|
||||
// Now get the closest view with a widget so we can create
|
||||
@ -7183,21 +7183,21 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n
|
||||
// in the frame.
|
||||
//
|
||||
|
||||
nsCOMPtr<nsIRenderingContext> rendContext;
|
||||
nsCOMPtr<nsIRenderingContext> rendContext;
|
||||
|
||||
rv = deviceContext->CreateRenderingContext(closestView, *getter_AddRefs(rendContext));
|
||||
rv = deviceContext->CreateRenderingContext(closestView, *getter_AddRefs(rendContext));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!rendContext)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
//
|
||||
// Now get the point and return!
|
||||
//
|
||||
|
||||
rv = aFrame->GetPointFromOffset(presContext, rendContext, aContentOffset, aPoint);
|
||||
rv = aFrame->GetPointFromOffset(presContext, rendContext, aContentOffset, aPoint);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -7720,7 +7720,7 @@ nsTypedSelection::ScrollIntoView(SelectionRegion aRegion, PRBool aIsSynchronous)
|
||||
presShell->GetCaret(getter_AddRefs(caret));
|
||||
if (caret)
|
||||
{
|
||||
StCaretHider caretHider(caret); // stack-based class hides and shows the caret
|
||||
StCaretHider caretHider(caret); // stack-based class hides and shows the caret
|
||||
|
||||
//
|
||||
// Scroll the selection region into view.
|
||||
@ -7752,7 +7752,7 @@ nsTypedSelection::AddSelectionListener(nsISelectionListener* aNewListener)
|
||||
{
|
||||
if (!aNewListener)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return mSelectionListeners.AppendObject(aNewListener) ? NS_OK : NS_ERROR_FAILURE; // addrefs
|
||||
return mSelectionListeners.AppendObject(aNewListener) ? NS_OK : NS_ERROR_FAILURE; // addrefs
|
||||
}
|
||||
|
||||
|
||||
@ -7762,7 +7762,7 @@ nsTypedSelection::RemoveSelectionListener(nsISelectionListener* aListenerToRemov
|
||||
{
|
||||
if (!aListenerToRemove )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return mSelectionListeners.RemoveObject(aListenerToRemove) ? NS_OK : NS_ERROR_FAILURE; // releases
|
||||
return mSelectionListeners.RemoveObject(aListenerToRemove) ? NS_OK : NS_ERROR_FAILURE; // releases
|
||||
}
|
||||
|
||||
|
||||
@ -7794,9 +7794,9 @@ nsTypedSelection::NotifySelectionListeners()
|
||||
{
|
||||
nsISelectionListener* thisListener = mSelectionListeners[i];
|
||||
if (thisListener)
|
||||
thisListener->NotifySelectionChanged(domdoc, this, reason);
|
||||
thisListener->NotifySelectionChanged(domdoc, this, reason);
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@ -1491,8 +1491,8 @@ nsEventStateManager::ChangeTextSize(PRInt32 change)
|
||||
nsresult
|
||||
nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsMouseScrollEvent* msEvent,
|
||||
PRInt32 numLines, PRBool scrollPage,
|
||||
nsMouseScrollEvent* aMSEvent,
|
||||
PRInt32 aNumLines, PRBool aScrollHorizontal, PRBool aScrollPage,
|
||||
PRBool aUseTargetFrame)
|
||||
{
|
||||
nsCOMPtr<nsIContent> targetContent;
|
||||
@ -1510,23 +1510,23 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
||||
if (event) {
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(event));
|
||||
nsCOMPtr<nsIDOMDocumentView> docView = do_QueryInterface(targetDoc);
|
||||
if (!docView) return nsnull;
|
||||
if (!docView) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIDOMAbstractView> view;
|
||||
docView->GetDefaultView(getter_AddRefs(view));
|
||||
|
||||
if (scrollPage) {
|
||||
if (numLines > 0) {
|
||||
numLines = nsIDOMNSUIEvent::SCROLL_PAGE_DOWN;
|
||||
if (aScrollPage) {
|
||||
if (aNumLines > 0) {
|
||||
aNumLines = nsIDOMNSUIEvent::SCROLL_PAGE_DOWN;
|
||||
} else {
|
||||
numLines = nsIDOMNSUIEvent::SCROLL_PAGE_UP;
|
||||
aNumLines = nsIDOMNSUIEvent::SCROLL_PAGE_UP;
|
||||
}
|
||||
}
|
||||
|
||||
mouseEvent->InitMouseEvent(NS_LITERAL_STRING("DOMMouseScroll"), PR_TRUE, PR_TRUE,
|
||||
view, numLines,
|
||||
msEvent->refPoint.x, msEvent->refPoint.y,
|
||||
msEvent->point.x, msEvent->point.y,
|
||||
msEvent->isControl, msEvent->isAlt, msEvent->isShift, msEvent->isMeta,
|
||||
view, aNumLines,
|
||||
aMSEvent->refPoint.x, aMSEvent->refPoint.y,
|
||||
aMSEvent->point.x, aMSEvent->point.y,
|
||||
aMSEvent->isControl, aMSEvent->isAlt, aMSEvent->isShift, aMSEvent->isMeta,
|
||||
0, nsnull);
|
||||
PRBool allowDefault;
|
||||
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(targetContent));
|
||||
@ -1537,11 +1537,6 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
|
||||
targetDOMDoc->CreateEvent(NS_LITERAL_STRING("MouseScrollEvents"), getter_AddRefs(event));
|
||||
if (event) {
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(event));
|
||||
}
|
||||
|
||||
nsIView* focusView = nsnull;
|
||||
nsIScrollableView* sv = nsnull;
|
||||
nsIFrame* focusFrame = nsnull;
|
||||
@ -1552,7 +1547,7 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
||||
nsMouseEvent mouseOutEvent;
|
||||
mouseOutEvent.eventStructType = NS_MOUSE_EVENT;
|
||||
mouseOutEvent.message = NS_MOUSE_EXIT;
|
||||
mouseOutEvent.widget = msEvent->widget;
|
||||
mouseOutEvent.widget = aMSEvent->widget;
|
||||
mouseOutEvent.clickCount = 0;
|
||||
mouseOutEvent.point = nsPoint(0,0);
|
||||
mouseOutEvent.refPoint = nsPoint(0,0);
|
||||
@ -1623,24 +1618,27 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
||||
nscoord xPos, yPos;
|
||||
sv->GetScrollPosition(xPos, yPos);
|
||||
|
||||
if (scrollPage)
|
||||
sv->ScrollByPages((numLines > 0) ? 1 : -1);
|
||||
else {
|
||||
PRInt32 vertLines = 0, horizLines = 0;
|
||||
|
||||
if (msEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal)
|
||||
horizLines = numLines;
|
||||
PRInt32 scrollX = 0;
|
||||
PRInt32 scrollY = aNumLines;
|
||||
|
||||
if (msEvent->scrollFlags & nsMouseScrollEvent::kIsVertical)
|
||||
vertLines = numLines;
|
||||
|
||||
sv->ScrollByLines(horizLines, vertLines);
|
||||
if (aScrollPage)
|
||||
scrollY = (scrollY > 0) ? 1 : -1;
|
||||
|
||||
if (aScrollHorizontal)
|
||||
{
|
||||
scrollX = scrollY;
|
||||
scrollY = 0;
|
||||
}
|
||||
|
||||
if (aScrollPage)
|
||||
sv->ScrollByPages(scrollX, scrollY);
|
||||
else
|
||||
sv->ScrollByLines(scrollX, scrollY);
|
||||
|
||||
nscoord newXPos, newYPos;
|
||||
sv->GetScrollPosition(newXPos, newYPos);
|
||||
|
||||
if (newYPos != yPos) {
|
||||
if (newXPos != xPos || newYPos != yPos) {
|
||||
if (focusView)
|
||||
ForceViewUpdate(focusView);
|
||||
} else
|
||||
@ -1653,11 +1651,11 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
|
||||
nsIFrame* newFrame = nsnull;
|
||||
nsCOMPtr<nsIPresContext> newPresContext;
|
||||
|
||||
rv = GetParentScrollingView(msEvent, aPresContext, newFrame,
|
||||
rv = GetParentScrollingView(aMSEvent, aPresContext, newFrame,
|
||||
*getter_AddRefs(newPresContext));
|
||||
if (NS_SUCCEEDED(rv) && newFrame)
|
||||
return DoWheelScroll(newPresContext, newFrame, msEvent, numLines,
|
||||
scrollPage, PR_TRUE);
|
||||
return DoWheelScroll(newPresContext, newFrame, aMSEvent, aNumLines,
|
||||
aScrollHorizontal, aScrollPage, PR_TRUE);
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -1921,6 +1919,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
|
||||
case MOUSE_SCROLL_PAGE:
|
||||
{
|
||||
DoWheelScroll(aPresContext, aTargetFrame, msEvent, numLines,
|
||||
(msEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal),
|
||||
(action == MOUSE_SCROLL_PAGE), PR_FALSE);
|
||||
|
||||
}
|
||||
@ -2011,7 +2010,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
|
||||
nsIScrollableView* sv = GetNearestScrollingView(aView);
|
||||
if (sv) {
|
||||
nsKeyEvent * keyEvent = (nsKeyEvent *)aEvent;
|
||||
sv->ScrollByPages((keyEvent->keyCode != NS_VK_PAGE_UP) ? 1 : -1);
|
||||
sv->ScrollByPages(0, (keyEvent->keyCode != NS_VK_PAGE_UP) ? 1 : -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2036,7 +2035,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
|
||||
// force the update to happen now, otherwise multiple scrolls can
|
||||
// occur before the update is processed. (bug #7354)
|
||||
nsIViewManager* vm = nsnull;
|
||||
if (NS_OK == aView->GetViewManager(vm) && nsnull != vm) {
|
||||
if (NS_SUCCEEDED (aView->GetViewManager(vm)) && nsnull != vm) {
|
||||
// I'd use Composite here, but it doesn't always work.
|
||||
// vm->Composite();
|
||||
vm->ForceUpdate();
|
||||
@ -2056,7 +2055,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
|
||||
// force the update to happen now, otherwise multiple scrolls can
|
||||
// occur before the update is processed. (bug #7354)
|
||||
nsIViewManager* vm = nsnull;
|
||||
if (NS_OK == aView->GetViewManager(vm) && nsnull != vm) {
|
||||
if (NS_SUCCEEDED (aView->GetViewManager(vm)) && nsnull != vm) {
|
||||
// I'd use Composite here, but it doesn't always work.
|
||||
// vm->Composite();
|
||||
vm->ForceUpdate();
|
||||
@ -2073,7 +2072,7 @@ nsEventStateManager::PostHandleEvent(nsIPresContext* aPresContext,
|
||||
if (!mCurrentFocus) {
|
||||
nsIScrollableView* sv = GetNearestScrollingView(aView);
|
||||
if (sv) {
|
||||
sv->ScrollByPages(1);
|
||||
sv->ScrollByPages(0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3637,7 +3636,7 @@ nsEventStateManager::GetNextTabIndex(nsIContent* aParent, PRBool forward)
|
||||
nsAutoString tabIndexStr;
|
||||
child->GetAttr(kNameSpaceID_None, nsHTMLAtoms::tabindex, tabIndexStr);
|
||||
PRInt32 ec, val = tabIndexStr.ToInteger(&ec);
|
||||
if (NS_OK == ec && val > mCurrentTabIndex && val != tabIndex) {
|
||||
if (NS_SUCCEEDED (ec) && val > mCurrentTabIndex && val != tabIndex) {
|
||||
tabIndex = (tabIndex == 0 || val < tabIndex) ? val : tabIndex;
|
||||
}
|
||||
}
|
||||
@ -3655,7 +3654,7 @@ nsEventStateManager::GetNextTabIndex(nsIContent* aParent, PRBool forward)
|
||||
nsAutoString tabIndexStr;
|
||||
child->GetAttr(kNameSpaceID_None, nsHTMLAtoms::tabindex, tabIndexStr);
|
||||
PRInt32 ec, val = tabIndexStr.ToInteger(&ec);
|
||||
if (NS_OK == ec) {
|
||||
if (NS_SUCCEEDED (ec)) {
|
||||
if ((mCurrentTabIndex==0 && val > tabIndex) ||
|
||||
(val < mCurrentTabIndex && val > tabIndex) ) {
|
||||
tabIndex = val;
|
||||
@ -4229,13 +4228,13 @@ nsEventStateManager::SendFocusBlur(nsIPresContext* aPresContext, nsIContent *aCo
|
||||
nsAutoString tabIndex;
|
||||
aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::tabindex, tabIndex);
|
||||
PRInt32 ec, val = tabIndex.ToInteger(&ec);
|
||||
if (NS_OK == ec) {
|
||||
if (NS_SUCCEEDED (ec)) {
|
||||
mCurrentTabIndex = val;
|
||||
}
|
||||
|
||||
if (clearFirstFocusEvent) {
|
||||
mFirstFocusEvent = nsnull;
|
||||
}
|
||||
}
|
||||
} else if (!aContent) {
|
||||
//fire focus on document even if the content isn't focusable (ie. text)
|
||||
//see bugzilla bug 93521
|
||||
@ -4368,7 +4367,7 @@ void nsEventStateManager::ForceViewUpdate(nsIView* aView)
|
||||
// occur before the update is processed. (bug #7354)
|
||||
|
||||
nsIViewManager* vm = nsnull;
|
||||
if (NS_OK == aView->GetViewManager(vm) && nsnull != vm) {
|
||||
if (NS_SUCCEEDED (aView->GetViewManager(vm)) && nsnull != vm) {
|
||||
// I'd use Composite here, but it doesn't always work.
|
||||
// vm->Composite();
|
||||
vm->ForceUpdate();
|
||||
|
||||
@ -213,8 +213,8 @@ protected:
|
||||
nsIPresContext* &presCtxOuter);
|
||||
nsresult DoWheelScroll(nsIPresContext* aPresContext,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsMouseScrollEvent* msEvent, PRInt32 numLines,
|
||||
PRBool scrollPage, PRBool aUseTargetFrame);
|
||||
nsMouseScrollEvent* aMSEvent, PRInt32 aNumLines,
|
||||
PRBool aScrollHorizontal, PRBool aScrollPage, PRBool aUseTargetFrame);
|
||||
void ForceViewUpdate(nsIView* aView);
|
||||
nsresult getPrefBranch();
|
||||
nsresult ChangeTextSize(PRInt32 change);
|
||||
|
||||
@ -3694,7 +3694,7 @@ nsDocShell::ScrollByPages(PRInt32 numPages)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(scrollView->ScrollByPages(numPages), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_SUCCESS(scrollView->ScrollByPages(0, numPages), NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2720,7 +2720,7 @@ GlobalWindowImpl::ScrollByPages(PRInt32 numPages)
|
||||
result = GetScrollInfo(&view, &p2t, &t2p);
|
||||
if (view)
|
||||
{
|
||||
result = view->ScrollByPages(numPages);
|
||||
result = view->ScrollByPages(0, numPages);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -3840,7 +3840,7 @@ GlobalWindowImpl::AddEventListenerByIID(nsIDOMEventListener* aListener,
|
||||
{
|
||||
nsCOMPtr<nsIEventListenerManager> manager;
|
||||
|
||||
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
|
||||
if (NS_SUCCEEDED (GetListenerManager(getter_AddRefs(manager)))) {
|
||||
manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -6222,7 +6222,7 @@ nsDOMWindowController::IsCommandEnabled(const char* aCommand,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(editInterface, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
|
||||
|
||||
if (!nsCRT::strcmp(sCopyString,aCommand)) {
|
||||
rv = editInterface->GetCopyable(aResult);
|
||||
}
|
||||
|
||||
@ -703,25 +703,25 @@ public:
|
||||
NS_IMETHOD ScrollPositionDidChange(nsIScrollableView *aView, nscoord aX, nscoord aY);
|
||||
|
||||
// nsICompositeListener methods
|
||||
NS_IMETHOD WillRefreshRegion(nsIViewManager *aViewManager,
|
||||
NS_IMETHOD WillRefreshRegion(nsIViewManager *aViewManager,
|
||||
nsIView *aView,
|
||||
nsIRenderingContext *aContext,
|
||||
nsIRegion *aRegion,
|
||||
PRUint32 aUpdateFlags);
|
||||
|
||||
NS_IMETHOD DidRefreshRegion(nsIViewManager *aViewManager,
|
||||
NS_IMETHOD DidRefreshRegion(nsIViewManager *aViewManager,
|
||||
nsIView *aView,
|
||||
nsIRenderingContext *aContext,
|
||||
nsIRegion *aRegion,
|
||||
PRUint32 aUpdateFlags);
|
||||
|
||||
NS_IMETHOD WillRefreshRect(nsIViewManager *aViewManager,
|
||||
NS_IMETHOD WillRefreshRect(nsIViewManager *aViewManager,
|
||||
nsIView *aView,
|
||||
nsIRenderingContext *aContext,
|
||||
const nsRect *aRect,
|
||||
PRUint32 aUpdateFlags);
|
||||
|
||||
NS_IMETHOD DidRefreshRect(nsIViewManager *aViewManager,
|
||||
NS_IMETHOD DidRefreshRect(nsIViewManager *aViewManager,
|
||||
nsIView *aView,
|
||||
nsIRenderingContext *aContext,
|
||||
const nsRect *aRect,
|
||||
@ -1172,7 +1172,7 @@ public:
|
||||
NS_IMETHOD HandleEvent(nsIView* aView,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus,
|
||||
PRBool aForceHandle,
|
||||
PRBool aForceHandle,
|
||||
PRBool& aHandled);
|
||||
NS_IMETHOD HandleDOMEventWithTarget(nsIContent* aTargetContent,
|
||||
nsEvent* aEvent,
|
||||
@ -1265,7 +1265,7 @@ protected:
|
||||
// utility to determine if we're in the middle of a drag
|
||||
PRBool IsDragInProgress ( ) const ;
|
||||
|
||||
PRBool mCaretEnabled;
|
||||
PRBool mCaretEnabled;
|
||||
#ifdef IBMBIDI
|
||||
PRUint8 mBidiLevel; // The Bidi level of the cursor
|
||||
nsCOMPtr<nsIBidiKeyboard> mBidiKeyboard;
|
||||
@ -1682,7 +1682,7 @@ PresShell::Init(nsIDocument* aDocument,
|
||||
mCaret->Init(this);
|
||||
}
|
||||
|
||||
//SetCaretEnabled(PR_TRUE); // make it show in browser windows
|
||||
//SetCaretEnabled(PR_TRUE); // make it show in browser windows
|
||||
#endif
|
||||
//set up selection to be displayed in document
|
||||
nsCOMPtr<nsISupports> container;
|
||||
@ -2111,7 +2111,7 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj;
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
|
||||
// If the document doesn't have a global object there's no need to
|
||||
// notify its presshell about changes to preferences since the
|
||||
@ -2804,7 +2804,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
nsresult rv=CreateRenderingContext(rootFrame, &rcx);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mIsReflowing = PR_TRUE;
|
||||
|
||||
@ -2905,7 +2905,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
PRBool firstReflow = PR_FALSE;
|
||||
|
||||
// notice that we ignore the result
|
||||
// notice that we ignore the result
|
||||
NotifyReflowObservers(NS_PRESSHELL_RESIZE_REFLOW);
|
||||
mViewManager->CacheWidgetChanges(PR_TRUE);
|
||||
|
||||
@ -3060,7 +3060,7 @@ PresShell::FireResizeEvent()
|
||||
event.time = 0;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj;
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
if (globalObj) {
|
||||
globalObj->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
@ -3123,9 +3123,9 @@ NS_IMETHODIMP PresShell::SetCaretEnabled(PRBool aInEnable)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
PRBool oldEnabled = mCaretEnabled;
|
||||
|
||||
|
||||
mCaretEnabled = aInEnable;
|
||||
|
||||
|
||||
if (mCaret && (mCaretEnabled != oldEnabled))
|
||||
{
|
||||
/* Don't change the caret's selection here! This was an evil side-effect of SetCaretEnabled()
|
||||
@ -3135,7 +3135,7 @@ NS_IMETHODIMP PresShell::SetCaretEnabled(PRBool aInEnable)
|
||||
*/
|
||||
result = mCaret->SetCaretVisible(mCaretEnabled);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -3243,7 +3243,7 @@ PresShell::ScrollPage(PRBool aForward)
|
||||
result = viewManager->GetRootScrollableView(&scrollView);
|
||||
if (NS_SUCCEEDED(result) && scrollView)
|
||||
{
|
||||
scrollView->ScrollByPages(aForward ? 1 : -1);
|
||||
scrollView->ScrollByPages(0, aForward ? 1 : -1);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -3390,7 +3390,7 @@ PresShell::CompleteMove(PRBool aForward, PRBool aExtend)
|
||||
);
|
||||
if (NS_POSITION_BEFORE_TABLE == result) //NS_POSITION_BEFORE_TABLE should ALSO break
|
||||
break;
|
||||
if (NS_OK != result || !pos.mResultFrame )
|
||||
if (NS_FAILED (result) || !pos.mResultFrame )
|
||||
return result?result:NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsILineIteratorNavigator> newIt;
|
||||
//check to see if this is ANOTHER blockframe inside the other one if so then call into its lines
|
||||
@ -3492,7 +3492,7 @@ PresShell::StyleChangeReflow()
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
nsresult rv=CreateRenderingContext(rootFrame, &rcx);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsHTMLReflowState reflowState(mPresContext, rootFrame,
|
||||
eReflowReason_StyleChange, rcx, maxSize);
|
||||
@ -3877,13 +3877,13 @@ NS_IMETHODIMP
|
||||
PresShell::ClearFrameRefs(nsIFrame* aFrame)
|
||||
{
|
||||
nsIEventStateManager *manager;
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||
if (NS_SUCCEEDED (mPresContext->GetEventStateManager(&manager))) {
|
||||
manager->ClearFrameRefs(aFrame);
|
||||
NS_RELEASE(manager);
|
||||
}
|
||||
|
||||
if (mCaret) {
|
||||
mCaret->ClearFrameRefs(aFrame);
|
||||
mCaret->ClearFrameRefs(aFrame);
|
||||
}
|
||||
|
||||
if (aFrame == mCurrentEventFrame) {
|
||||
@ -4274,8 +4274,8 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
||||
content->GetDocument(*getter_AddRefs(document));
|
||||
if(document){
|
||||
nsCOMPtr<nsIFocusController> focusController;
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(ourGlobal);
|
||||
if(ourWindow) {
|
||||
ourWindow->GetRootFocusController(getter_AddRefs(focusController));
|
||||
@ -4696,10 +4696,6 @@ PresShell::SetAnonymousContentFor(nsIContent* aContent, nsISupportsArray* aAnony
|
||||
if (! aContent)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aAnonymousElements != nsnull, "null ptr");
|
||||
if (! aAnonymousElements)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! mAnonymousContentTable) {
|
||||
mAnonymousContentTable = new nsSupportsHashtable;
|
||||
if (! mAnonymousContentTable)
|
||||
@ -4711,26 +4707,33 @@ PresShell::SetAnonymousContentFor(nsIContent* aContent, nsISupportsArray* aAnony
|
||||
nsCOMPtr<nsISupportsArray> oldAnonymousElements =
|
||||
getter_AddRefs(NS_STATIC_CAST(nsISupportsArray*, mAnonymousContentTable->Get(&key)));
|
||||
|
||||
if (oldAnonymousElements) {
|
||||
// If we're trying to set anonymous content for an element that
|
||||
// already had anonymous content, then we need to be sure to clean
|
||||
// up after the old content. (This can happen, for example, when a
|
||||
// reframe occurs.)
|
||||
PRUint32 count;
|
||||
oldAnonymousElements->Count(&count);
|
||||
|
||||
while (PRInt32(--count) >= 0) {
|
||||
nsCOMPtr<nsISupports> isupports( getter_AddRefs(oldAnonymousElements->ElementAt(count)) );
|
||||
nsCOMPtr<nsIContent> content( do_QueryInterface(isupports) );
|
||||
NS_ASSERTION(content != nsnull, "not an nsIContent");
|
||||
if (! content)
|
||||
continue;
|
||||
|
||||
content->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
||||
if (!oldAnonymousElements) {
|
||||
if (aAnonymousElements) {
|
||||
mAnonymousContentTable->Put(&key, aAnonymousElements);
|
||||
}
|
||||
} else {
|
||||
if (aAnonymousElements) {
|
||||
oldAnonymousElements->AppendElements(aAnonymousElements);
|
||||
} else {
|
||||
// If we're trying to clear anonymous content for an element that
|
||||
// already had anonymous content, then we need to be sure to clean
|
||||
// up after the old content. (This can happen, for example, when a
|
||||
// reframe occurs.)
|
||||
PRUint32 count;
|
||||
oldAnonymousElements->Count(&count);
|
||||
|
||||
while (PRInt32(--count) >= 0) {
|
||||
nsCOMPtr<nsISupports> isupports( getter_AddRefs(oldAnonymousElements->ElementAt(count)) );
|
||||
nsCOMPtr<nsIContent> content( do_QueryInterface(isupports) );
|
||||
NS_ASSERTION(content != nsnull, "not an nsIContent");
|
||||
if (! content)
|
||||
continue;
|
||||
|
||||
content->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mAnonymousContentTable->Put(&key, aAnonymousElements);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -5018,7 +5021,7 @@ PresShell::HandlePostedReflowCallbacks()
|
||||
node = node->next;
|
||||
mFirstCallbackEventRequest = node;
|
||||
FreeFrame(sizeof(nsCallbackEventRequest), toFree);
|
||||
if (callback)
|
||||
if (callback)
|
||||
callback->ReflowFinished(this, &shouldFlush);
|
||||
NS_IF_RELEASE(callback);
|
||||
}
|
||||
@ -5830,8 +5833,8 @@ PresShell::GetCurrentEventFrame()
|
||||
NS_IMETHODIMP
|
||||
PresShell::GetEventTargetFrame(nsIFrame** aFrame)
|
||||
{
|
||||
*aFrame = GetCurrentEventFrame();
|
||||
return NS_OK;
|
||||
*aFrame = GetCurrentEventFrame();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -5848,7 +5851,7 @@ PresShell::GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent)
|
||||
*aContent = nsnull;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
@ -5961,7 +5964,7 @@ NS_IMETHODIMP
|
||||
PresShell::HandleEvent(nsIView *aView,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus,
|
||||
PRBool aForceHandle,
|
||||
PRBool aForceHandle,
|
||||
PRBool& aHandled)
|
||||
{
|
||||
void* clientData;
|
||||
@ -6042,7 +6045,7 @@ PresShell::HandleEvent(nsIView *aView,
|
||||
PushCurrentEventInfo(nsnull, nsnull);
|
||||
|
||||
nsCOMPtr<nsIEventStateManager> manager;
|
||||
if (NS_OK == mPresContext->GetEventStateManager(getter_AddRefs(manager))) {
|
||||
if (NS_SUCCEEDED (mPresContext->GetEventStateManager(getter_AddRefs(manager)))) {
|
||||
//change 6-01-00 mjudge,ftang adding ime as an event that needs focused element
|
||||
if (NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent) || aEvent->message == NS_CONTEXTMENU_KEY) {
|
||||
//Key events go to the focused frame, not point based.
|
||||
@ -6129,17 +6132,17 @@ PresShell::HandleEvent(nsIView *aView,
|
||||
eventPoint -= originOffset;
|
||||
|
||||
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FOREGROUND, &mCurrentEventFrame);
|
||||
if (rv != NS_OK) {
|
||||
if (NS_FAILED (rv)) {
|
||||
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FLOATERS, &mCurrentEventFrame);
|
||||
if (rv != NS_OK) {
|
||||
if (NS_FAILED (rv)) {
|
||||
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_BACKGROUND, &mCurrentEventFrame);
|
||||
if (rv != NS_OK) {
|
||||
if (aForceHandle) {
|
||||
mCurrentEventFrame = frame;
|
||||
}
|
||||
else {
|
||||
mCurrentEventFrame = nsnull;
|
||||
}
|
||||
if (NS_FAILED (rv)) {
|
||||
if (aForceHandle) {
|
||||
mCurrentEventFrame = frame;
|
||||
}
|
||||
else {
|
||||
mCurrentEventFrame = nsnull;
|
||||
}
|
||||
aHandled = PR_FALSE;
|
||||
rv = NS_OK;
|
||||
}
|
||||
@ -6202,7 +6205,7 @@ PresShell::HandleEvent(nsIView *aView,
|
||||
// use aView or mCurrentTargetView??
|
||||
if ( (mCurrentTargetRect != oldTargetRect) || (mCurrentTargetView != oldView)) {
|
||||
nsIViewManager *vm;
|
||||
if ((NS_OK == GetViewManager(&vm)) && vm) {
|
||||
if ((NS_SUCCEEDED (GetViewManager(&vm))) && vm) {
|
||||
vm->UpdateView(mCurrentTargetView,mCurrentTargetRect,0);
|
||||
if (oldView)
|
||||
vm->UpdateView(oldView,oldTargetRect,0);
|
||||
@ -6251,19 +6254,19 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, PRUint32 aFlags,
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsIEventStateManager *manager;
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager) && GetCurrentEventFrame()) {
|
||||
if (NS_SUCCEEDED (mPresContext->GetEventStateManager(&manager)) && GetCurrentEventFrame()) {
|
||||
//1. Give event to event manager for pre event state changes and generation of synthetic events.
|
||||
rv = manager->PreHandleEvent(mPresContext, aEvent, mCurrentEventFrame, aStatus, aView);
|
||||
|
||||
//2. Give event to the DOM for third party and JS use.
|
||||
if ((GetCurrentEventFrame()) && NS_OK == rv) {
|
||||
if ((GetCurrentEventFrame()) && NS_SUCCEEDED (rv)) {
|
||||
if (mCurrentEventContent) {
|
||||
rv = mCurrentEventContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
|
||||
aFlags, aStatus);
|
||||
}
|
||||
else {
|
||||
nsIContent* targetContent;
|
||||
if (NS_OK == mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent) && nsnull != targetContent) {
|
||||
if (NS_SUCCEEDED (mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent)) && nsnull != targetContent) {
|
||||
rv = targetContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
|
||||
aFlags, aStatus);
|
||||
NS_RELEASE(targetContent);
|
||||
@ -6279,7 +6282,7 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, PRUint32 aFlags,
|
||||
}
|
||||
else if (mCurrentEventFrame) {
|
||||
nsIContent* targetContent;
|
||||
if (NS_OK == mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent) && nsnull != targetContent) {
|
||||
if (NS_SUCCEEDED (mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent)) && nsnull != targetContent) {
|
||||
rv = targetContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
|
||||
aFlags | NS_EVENT_FLAG_SYSTEM_EVENT, aStatus);
|
||||
NS_RELEASE(targetContent);
|
||||
@ -6289,12 +6292,12 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, PRUint32 aFlags,
|
||||
//3. Give event to the Frames for browser default processing.
|
||||
// XXX The event isn't translated into the local coordinate space
|
||||
// of the frame...
|
||||
if (GetCurrentEventFrame() && NS_OK == rv && aEvent->eventStructType != NS_EVENT) {
|
||||
if (GetCurrentEventFrame() && NS_SUCCEEDED (rv) && aEvent->eventStructType != NS_EVENT) {
|
||||
rv = mCurrentEventFrame->HandleEvent(mPresContext, (nsGUIEvent*)aEvent, aStatus);
|
||||
}
|
||||
|
||||
//4. Give event to event manager for post event state changes and generation of synthetic events.
|
||||
if ((GetCurrentEventFrame()) && NS_OK == rv) {
|
||||
if ((GetCurrentEventFrame()) && NS_SUCCEEDED (rv)) {
|
||||
rv = manager->PostHandleEvent(mPresContext, aEvent, mCurrentEventFrame, aStatus, aView);
|
||||
}
|
||||
}
|
||||
@ -6484,7 +6487,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
|
||||
rootFrame->GetSize(maxSize);
|
||||
|
||||
nsresult rv=CreateRenderingContext(rootFrame, &rcx);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (GetVerifyReflowEnable()) {
|
||||
@ -7204,7 +7207,7 @@ PresShell::VerifyIncrementalReflow()
|
||||
NS_RELEASE(container);
|
||||
}
|
||||
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create presentation context");
|
||||
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation context");
|
||||
nsCOMPtr<nsIDeviceContext> dc;
|
||||
mPresContext->GetDeviceContext(getter_AddRefs(dc));
|
||||
cx->Init(dc);
|
||||
@ -7216,7 +7219,7 @@ PresShell::VerifyIncrementalReflow()
|
||||
nsIScrollableView* scrollView;
|
||||
rv = rootView->QueryInterface(NS_GET_IID(nsIScrollableView),
|
||||
(void**)&scrollView);
|
||||
if (NS_OK == rv) {
|
||||
if (NS_SUCCEEDED (rv)) {
|
||||
scrollView->GetScrollPreference(scrolling);
|
||||
}
|
||||
nsCOMPtr<nsIWidget> rootWidget;
|
||||
@ -7227,13 +7230,9 @@ PresShell::VerifyIncrementalReflow()
|
||||
rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull,
|
||||
NS_GET_IID(nsIViewManager),
|
||||
(void**) &vm);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create view manager");
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create view manager");
|
||||
rv = vm->Init(dc);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to init view manager");
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to init view manager");
|
||||
|
||||
// Create a child window of the parent that is our "root view/window"
|
||||
// Create a view
|
||||
@ -7243,21 +7242,15 @@ PresShell::VerifyIncrementalReflow()
|
||||
rv = nsComponentManager::CreateInstance(kViewCID, nsnull,
|
||||
NS_GET_IID(nsIView),
|
||||
(void **) &view);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create scroll view");
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view");
|
||||
rv = view->Init(vm, tbounds, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to init scroll view");
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to init scroll view");
|
||||
|
||||
//now create the widget for the view
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(mDocument));
|
||||
rv = view->CreateWidget(kWidgetCID, nsnull, nativeParentWidget, PR_TRUE,
|
||||
PR_TRUE, xulDoc? eContentTypeUI: eContentTypeContent);
|
||||
if (NS_OK != rv) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create scroll view widget");
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view widget");
|
||||
|
||||
// Setup hierarchical relationship in view manager
|
||||
vm->SetRootView(view);
|
||||
@ -7275,7 +7268,7 @@ PresShell::VerifyIncrementalReflow()
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to clone style set");
|
||||
rv = mDocument->CreateShell(cx, vm, newSet, &sh);
|
||||
sh->SetVerifyReflowEnable(PR_FALSE); // turn off verify reflow while we're reflowing the test frame tree
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create presentation shell");
|
||||
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation shell");
|
||||
vm->SetViewObserver((nsIViewObserver *)((PresShell*)sh));
|
||||
sh->InitialReflow(r.width, r.height);
|
||||
sh->SetVerifyReflowEnable(PR_TRUE); // turn on verify reflow again now that we're done reflowing the test frame tree
|
||||
@ -7734,7 +7727,7 @@ void ReflowCountMgr::PaintCount(const char * aName,
|
||||
if (counter != nsnull && counter->mName.EqualsWithConversion(aName)) {
|
||||
aRenderingContext->PushState();
|
||||
nsFont font("Times", NS_FONT_STYLE_NORMAL,NS_FONT_VARIANT_NORMAL,
|
||||
NS_FONT_WEIGHT_NORMAL,0,NSIntPointsToTwips(8));
|
||||
NS_FONT_WEIGHT_NORMAL,0,NSIntPointsToTwips(8));
|
||||
|
||||
nsCOMPtr<nsIFontMetrics> fm;
|
||||
aPresContext->GetMetricsFor(font, getter_AddRefs(fm));
|
||||
|
||||
@ -811,7 +811,7 @@ nsTextInputSelectionImpl::ScrollPage(PRBool aForward)
|
||||
if (!scrollableView)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return scrollableView->ScrollByPages(aForward ? 1 : -1);
|
||||
return scrollableView->ScrollByPages(0, aForward ? 1 : -1);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@ -198,7 +198,7 @@ public:
|
||||
NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset);
|
||||
NS_IMETHOD CollapseToStart();
|
||||
NS_IMETHOD CollapseToEnd();
|
||||
NS_IMETHOD SelectAllChildren(nsIDOMNode* parentNode);
|
||||
NS_IMETHOD SelectAllChildren(nsIDOMNode* parentNode);
|
||||
NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset);
|
||||
NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aAYes);
|
||||
NS_IMETHOD DeleteFromDocument();
|
||||
@ -236,7 +236,7 @@ public:
|
||||
nsresult RemoveItem(nsIDOMRange *aRange);
|
||||
|
||||
nsresult Clear(nsIPresContext* aPresContext);
|
||||
// methods for convenience. Note, these don't addref
|
||||
// methods for convenience. Note, these don't addref
|
||||
nsIDOMNode* FetchAnchorNode(); //where did the selection begin
|
||||
PRInt32 FetchAnchorOffset();
|
||||
|
||||
@ -471,7 +471,7 @@ private:
|
||||
PRBool GetNotifyFrames(){return mNotifyFrames;}
|
||||
void SetDirty(PRBool aDirty=PR_TRUE){if (mBatching) mChangesDuringBatching = aDirty;}
|
||||
|
||||
nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc?
|
||||
nsresult NotifySelectionListeners(SelectionType aType); // add parameters to say collapsed etc?
|
||||
|
||||
// utility method to lookup frame style
|
||||
nsresult FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSelectionStyle, nsIFrame* *foundFrame);
|
||||
@ -1475,18 +1475,18 @@ nsSelection::ShutDown()
|
||||
NS_IMETHODIMP
|
||||
nsSelection::HandleTextEvent(nsGUIEvent *aGUIEvent)
|
||||
{
|
||||
if (!aGUIEvent)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aGUIEvent)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
#ifdef DEBUG_TAGUE
|
||||
printf("nsSelection: HandleTextEvent\n");
|
||||
printf("nsSelection: HandleTextEvent\n");
|
||||
#endif
|
||||
nsresult result(NS_OK);
|
||||
if (NS_TEXT_EVENT == aGUIEvent->message) {
|
||||
if (NS_TEXT_EVENT == aGUIEvent->message) {
|
||||
PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL);
|
||||
result = mDomSelections[index]->ScrollIntoView();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -2714,7 +2714,7 @@ nsSelection::HandleDrag(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint&
|
||||
result = VisualSelectFrames(aPresContext, newFrame, pos);
|
||||
if (NS_FAILED(result))
|
||||
result = HandleClick(newContent, startPos, contentOffsetEnd, PR_TRUE,
|
||||
PR_FALSE, beginOfContent);
|
||||
PR_FALSE, beginOfContent);
|
||||
mHint = saveHint;
|
||||
}
|
||||
else
|
||||
@ -3098,10 +3098,10 @@ nsSelection::GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHin
|
||||
result = mTracker->GetPrimaryFrameFor(theNode, aReturnFrame);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
|
||||
if (!*aReturnFrame)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
|
||||
// find the child frame containing the offset we want
|
||||
result = (*aReturnFrame)->GetChildFrameContainingOffset(*aReturnOffset, aHint, &aOffset, aReturnFrame);
|
||||
return result;
|
||||
@ -3225,7 +3225,7 @@ nsSelection::CommonPageMove(PRBool aForward,
|
||||
|
||||
// scroll one page
|
||||
|
||||
aScrollableView->ScrollByPages(aForward ? 1 : -1);
|
||||
aScrollableView->ScrollByPages(0, aForward ? 1 : -1);
|
||||
|
||||
// place the caret
|
||||
result = aFrameSel->HandleClick(content, startOffset, startOffset, aExtend, PR_FALSE, PR_TRUE);
|
||||
@ -3343,8 +3343,8 @@ nsSelection::FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSe
|
||||
|
||||
while (thisFrame)
|
||||
{
|
||||
const nsStyleUIReset* userinterface;
|
||||
thisFrame->GetStyleData(eStyleStruct_UIReset, (const nsStyleStruct*&)userinterface);
|
||||
const nsStyleUIReset* userinterface;
|
||||
thisFrame->GetStyleData(eStyleStruct_UIReset, (const nsStyleStruct*&)userinterface);
|
||||
|
||||
if (userinterface->mUserSelect == aSelectionStyle)
|
||||
{
|
||||
@ -4257,7 +4257,7 @@ nsTypedSelection::addTableCellRange(nsIDOMRange *aRange, PRBool *aDidAddRange)
|
||||
// Insert range at appropriate location
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
nsIDOMRange* range = mRangeArray[index];
|
||||
nsIDOMRange* range = mRangeArray[index];
|
||||
if (!range) return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 selectionMode;
|
||||
@ -4697,11 +4697,11 @@ nsTypedSelection::SetPresShell(nsIPresShell *aPresShell)
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::GetAnchorNode(nsIDOMNode** aAnchorNode)
|
||||
{
|
||||
if (!aAnchorNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aAnchorNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aAnchorNode = nsnull;
|
||||
if(!mAnchorFocusRange)
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
|
||||
nsresult result;
|
||||
if (GetDirection() == eDirNext){
|
||||
@ -4710,14 +4710,14 @@ nsTypedSelection::GetAnchorNode(nsIDOMNode** aAnchorNode)
|
||||
else{
|
||||
result = mAnchorFocusRange->GetEndContainer(aAnchorNode);
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::GetAnchorOffset(PRInt32* aAnchorOffset)
|
||||
{
|
||||
if (!aAnchorOffset)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aAnchorOffset)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aAnchorOffset = nsnull;
|
||||
if(!mAnchorFocusRange)
|
||||
return NS_OK;
|
||||
@ -4729,15 +4729,15 @@ nsTypedSelection::GetAnchorOffset(PRInt32* aAnchorOffset)
|
||||
else{
|
||||
result = mAnchorFocusRange->GetEndOffset(aAnchorOffset);
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
// note: this can return a nil focus node
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::GetFocusNode(nsIDOMNode** aFocusNode)
|
||||
{
|
||||
if (!aFocusNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aFocusNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aFocusNode = nsnull;
|
||||
if(!mAnchorFocusRange)
|
||||
return NS_OK;
|
||||
@ -4750,13 +4750,13 @@ nsTypedSelection::GetFocusNode(nsIDOMNode** aFocusNode)
|
||||
result = mAnchorFocusRange->GetStartContainer(aFocusNode);
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTypedSelection::GetFocusOffset(PRInt32* aFocusOffset)
|
||||
{
|
||||
if (!aFocusOffset)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aFocusOffset)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aFocusOffset = nsnull;
|
||||
if(!mAnchorFocusRange)
|
||||
return NS_OK;
|
||||
@ -4768,7 +4768,7 @@ NS_IMETHODIMP nsTypedSelection::GetFocusOffset(PRInt32* aFocusOffset)
|
||||
else{
|
||||
result = mAnchorFocusRange->GetStartOffset(aFocusOffset);
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -4954,7 +4954,7 @@ nsTypedSelection::GetPrimaryFrameForRangeEndpoint(nsIDOMNode *aNode, PRInt32 aOf
|
||||
|
||||
*aReturnFrame = 0;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node = dont_QueryInterface(aNode);
|
||||
|
||||
@ -5905,7 +5905,7 @@ nsTypedSelection::GetEnumerator(nsIEnumerator **aIterator)
|
||||
nsresult status = NS_ERROR_OUT_OF_MEMORY;
|
||||
nsSelectionIterator *iterator = new nsSelectionIterator(this);
|
||||
if ( iterator && NS_FAILED(status = CallQueryInterface(iterator, aIterator)) )
|
||||
delete iterator;
|
||||
delete iterator;
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -5922,11 +5922,11 @@ nsTypedSelection::RemoveAllRanges()
|
||||
GetPresContext(getter_AddRefs(presContext));
|
||||
|
||||
|
||||
nsresult result = Clear(presContext);
|
||||
nsresult result = Clear(presContext);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
return result;
|
||||
|
||||
// Turn off signal for table selection
|
||||
// Turn off signal for table selection
|
||||
mFrameSelection->ClearTableCellSelection();
|
||||
|
||||
return mFrameSelection->NotifySelectionListeners(GetType());
|
||||
@ -6021,7 +6021,7 @@ nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
||||
GetPresContext(getter_AddRefs(presContext));
|
||||
Clear(presContext);
|
||||
|
||||
// Turn off signal for table selection
|
||||
// Turn off signal for table selection
|
||||
if (mFrameSelection)
|
||||
mFrameSelection->ClearTableCellSelection();
|
||||
|
||||
@ -6049,11 +6049,11 @@ nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
||||
content->GetTag(*getter_AddRefs(tag));
|
||||
if (tag)
|
||||
{
|
||||
nsAutoString tagString;
|
||||
tag->ToString(tagString);
|
||||
char * tagCString = ToNewCString(tagString);
|
||||
printf ("Sel. Collapse to %p %s %d\n", content, tagCString, aOffset);
|
||||
delete [] tagCString;
|
||||
nsAutoString tagString;
|
||||
tag->ToString(tagString);
|
||||
char * tagCString = ToNewCString(tagString);
|
||||
printf ("Sel. Collapse to %p %s %d\n", content, tagCString, aOffset);
|
||||
delete [] tagCString;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -6068,8 +6068,8 @@ nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
if (!mFrameSelection)
|
||||
return NS_OK;//nothing to do
|
||||
return mFrameSelection->NotifySelectionListeners(GetType());
|
||||
return NS_OK;//nothing to do
|
||||
return mFrameSelection->NotifySelectionListeners(GetType());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -6082,7 +6082,7 @@ nsTypedSelection::CollapseToStart()
|
||||
PRInt32 cnt;
|
||||
nsresult rv = GetRangeCount(&cnt);
|
||||
if (NS_FAILED(rv) || cnt <= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the first range
|
||||
nsIDOMRange* firstRange = mRangeArray[0];
|
||||
@ -6116,7 +6116,7 @@ nsTypedSelection::CollapseToEnd()
|
||||
PRInt32 cnt;
|
||||
nsresult rv = GetRangeCount(&cnt);
|
||||
if (NS_FAILED(rv) || cnt <= 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the last range
|
||||
nsIDOMRange* lastRange = mRangeArray[cnt-1];
|
||||
@ -6146,9 +6146,9 @@ nsTypedSelection::CollapseToEnd()
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::GetIsCollapsed(PRBool* aIsCollapsed)
|
||||
{
|
||||
if (!aIsCollapsed)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!aIsCollapsed)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
PRInt32 cnt = mRangeArray.Count();;
|
||||
if (cnt == 0)
|
||||
{
|
||||
@ -6169,27 +6169,27 @@ NS_IMETHODIMP
|
||||
nsTypedSelection::GetRangeCount(PRInt32* aRangeCount)
|
||||
{
|
||||
if (!aRangeCount)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aRangeCount = mRangeArray.Count();
|
||||
|
||||
return NS_OK;
|
||||
*aRangeCount = mRangeArray.Count();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn)
|
||||
{
|
||||
if (!aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if (!aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
PRInt32 cnt = mRangeArray.Count();
|
||||
if (aIndex < 0 || aIndex >= cnt)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
PRInt32 cnt = mRangeArray.Count();
|
||||
if (aIndex < 0 || aIndex >= cnt)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*aReturn = mRangeArray[aIndex];
|
||||
*aReturn = mRangeArray[aIndex];
|
||||
NS_IF_ADDREF(*aReturn);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef OLD_SELECTION
|
||||
@ -6839,11 +6839,11 @@ nsTypedSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)
|
||||
content->GetTag(*getter_AddRefs(tag));
|
||||
if (tag)
|
||||
{
|
||||
nsAutoString tagString;
|
||||
tag->ToString(tagString);
|
||||
char * tagCString = ToNewCString(tagString);
|
||||
printf ("Sel. Extend to %p %s %d\n", content, tagCString, aOffset);
|
||||
delete [] tagCString;
|
||||
nsAutoString tagString;
|
||||
tag->ToString(tagString);
|
||||
char * tagCString = ToNewCString(tagString);
|
||||
printf ("Sel. Extend to %p %s %d\n", content, tagCString, aOffset);
|
||||
delete [] tagCString;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -6996,7 +6996,7 @@ nsTypedSelection::GetPresShell(nsIPresShell **aPresShell)
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
rv = presContext->GetShell(getter_AddRefs(shell));
|
||||
mPresShellWeak = getter_AddRefs(NS_GetWeakReference(shell)); // the presshell owns us, so no addref
|
||||
mPresShellWeak = getter_AddRefs(NS_GetWeakReference(shell)); // the presshell owns us, so no addref
|
||||
if (mPresShellWeak)
|
||||
NS_ADDREF(*aPresShell = shell);
|
||||
return rv;
|
||||
@ -7139,13 +7139,13 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n
|
||||
|
||||
nsCOMPtr<nsIDeviceContext> deviceContext;
|
||||
|
||||
rv = presContext->GetDeviceContext(getter_AddRefs(deviceContext));
|
||||
rv = presContext->GetDeviceContext(getter_AddRefs(deviceContext));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!deviceContext)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
//
|
||||
// Now get the closest view with a widget so we can create
|
||||
@ -7183,21 +7183,21 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n
|
||||
// in the frame.
|
||||
//
|
||||
|
||||
nsCOMPtr<nsIRenderingContext> rendContext;
|
||||
nsCOMPtr<nsIRenderingContext> rendContext;
|
||||
|
||||
rv = deviceContext->CreateRenderingContext(closestView, *getter_AddRefs(rendContext));
|
||||
rv = deviceContext->CreateRenderingContext(closestView, *getter_AddRefs(rendContext));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!rendContext)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
//
|
||||
// Now get the point and return!
|
||||
//
|
||||
|
||||
rv = aFrame->GetPointFromOffset(presContext, rendContext, aContentOffset, aPoint);
|
||||
rv = aFrame->GetPointFromOffset(presContext, rendContext, aContentOffset, aPoint);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -7720,7 +7720,7 @@ nsTypedSelection::ScrollIntoView(SelectionRegion aRegion, PRBool aIsSynchronous)
|
||||
presShell->GetCaret(getter_AddRefs(caret));
|
||||
if (caret)
|
||||
{
|
||||
StCaretHider caretHider(caret); // stack-based class hides and shows the caret
|
||||
StCaretHider caretHider(caret); // stack-based class hides and shows the caret
|
||||
|
||||
//
|
||||
// Scroll the selection region into view.
|
||||
@ -7752,7 +7752,7 @@ nsTypedSelection::AddSelectionListener(nsISelectionListener* aNewListener)
|
||||
{
|
||||
if (!aNewListener)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return mSelectionListeners.AppendObject(aNewListener) ? NS_OK : NS_ERROR_FAILURE; // addrefs
|
||||
return mSelectionListeners.AppendObject(aNewListener) ? NS_OK : NS_ERROR_FAILURE; // addrefs
|
||||
}
|
||||
|
||||
|
||||
@ -7762,7 +7762,7 @@ nsTypedSelection::RemoveSelectionListener(nsISelectionListener* aListenerToRemov
|
||||
{
|
||||
if (!aListenerToRemove )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return mSelectionListeners.RemoveObject(aListenerToRemove) ? NS_OK : NS_ERROR_FAILURE; // releases
|
||||
return mSelectionListeners.RemoveObject(aListenerToRemove) ? NS_OK : NS_ERROR_FAILURE; // releases
|
||||
}
|
||||
|
||||
|
||||
@ -7794,9 +7794,9 @@ nsTypedSelection::NotifySelectionListeners()
|
||||
{
|
||||
nsISelectionListener* thisListener = mSelectionListeners[i];
|
||||
if (thisListener)
|
||||
thisListener->NotifySelectionChanged(domdoc, this, reason);
|
||||
thisListener->NotifySelectionChanged(domdoc, this, reason);
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@ -703,25 +703,25 @@ public:
|
||||
NS_IMETHOD ScrollPositionDidChange(nsIScrollableView *aView, nscoord aX, nscoord aY);
|
||||
|
||||
// nsICompositeListener methods
|
||||
NS_IMETHOD WillRefreshRegion(nsIViewManager *aViewManager,
|
||||
NS_IMETHOD WillRefreshRegion(nsIViewManager *aViewManager,
|
||||
nsIView *aView,
|
||||
nsIRenderingContext *aContext,
|
||||
nsIRegion *aRegion,
|
||||
PRUint32 aUpdateFlags);
|
||||
|
||||
NS_IMETHOD DidRefreshRegion(nsIViewManager *aViewManager,
|
||||
NS_IMETHOD DidRefreshRegion(nsIViewManager *aViewManager,
|
||||
nsIView *aView,
|
||||
nsIRenderingContext *aContext,
|
||||
nsIRegion *aRegion,
|
||||
PRUint32 aUpdateFlags);
|
||||
|
||||
NS_IMETHOD WillRefreshRect(nsIViewManager *aViewManager,
|
||||
NS_IMETHOD WillRefreshRect(nsIViewManager *aViewManager,
|
||||
nsIView *aView,
|
||||
nsIRenderingContext *aContext,
|
||||
const nsRect *aRect,
|
||||
PRUint32 aUpdateFlags);
|
||||
|
||||
NS_IMETHOD DidRefreshRect(nsIViewManager *aViewManager,
|
||||
NS_IMETHOD DidRefreshRect(nsIViewManager *aViewManager,
|
||||
nsIView *aView,
|
||||
nsIRenderingContext *aContext,
|
||||
const nsRect *aRect,
|
||||
@ -1172,7 +1172,7 @@ public:
|
||||
NS_IMETHOD HandleEvent(nsIView* aView,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus,
|
||||
PRBool aForceHandle,
|
||||
PRBool aForceHandle,
|
||||
PRBool& aHandled);
|
||||
NS_IMETHOD HandleDOMEventWithTarget(nsIContent* aTargetContent,
|
||||
nsEvent* aEvent,
|
||||
@ -1265,7 +1265,7 @@ protected:
|
||||
// utility to determine if we're in the middle of a drag
|
||||
PRBool IsDragInProgress ( ) const ;
|
||||
|
||||
PRBool mCaretEnabled;
|
||||
PRBool mCaretEnabled;
|
||||
#ifdef IBMBIDI
|
||||
PRUint8 mBidiLevel; // The Bidi level of the cursor
|
||||
nsCOMPtr<nsIBidiKeyboard> mBidiKeyboard;
|
||||
@ -1682,7 +1682,7 @@ PresShell::Init(nsIDocument* aDocument,
|
||||
mCaret->Init(this);
|
||||
}
|
||||
|
||||
//SetCaretEnabled(PR_TRUE); // make it show in browser windows
|
||||
//SetCaretEnabled(PR_TRUE); // make it show in browser windows
|
||||
#endif
|
||||
//set up selection to be displayed in document
|
||||
nsCOMPtr<nsISupports> container;
|
||||
@ -2111,7 +2111,7 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj;
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
|
||||
// If the document doesn't have a global object there's no need to
|
||||
// notify its presshell about changes to preferences since the
|
||||
@ -2804,7 +2804,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
nsresult rv=CreateRenderingContext(rootFrame, &rcx);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mIsReflowing = PR_TRUE;
|
||||
|
||||
@ -2905,7 +2905,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
PRBool firstReflow = PR_FALSE;
|
||||
|
||||
// notice that we ignore the result
|
||||
// notice that we ignore the result
|
||||
NotifyReflowObservers(NS_PRESSHELL_RESIZE_REFLOW);
|
||||
mViewManager->CacheWidgetChanges(PR_TRUE);
|
||||
|
||||
@ -3060,7 +3060,7 @@ PresShell::FireResizeEvent()
|
||||
event.time = 0;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj;
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
|
||||
if (globalObj) {
|
||||
globalObj->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
@ -3123,9 +3123,9 @@ NS_IMETHODIMP PresShell::SetCaretEnabled(PRBool aInEnable)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
PRBool oldEnabled = mCaretEnabled;
|
||||
|
||||
|
||||
mCaretEnabled = aInEnable;
|
||||
|
||||
|
||||
if (mCaret && (mCaretEnabled != oldEnabled))
|
||||
{
|
||||
/* Don't change the caret's selection here! This was an evil side-effect of SetCaretEnabled()
|
||||
@ -3135,7 +3135,7 @@ NS_IMETHODIMP PresShell::SetCaretEnabled(PRBool aInEnable)
|
||||
*/
|
||||
result = mCaret->SetCaretVisible(mCaretEnabled);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -3243,7 +3243,7 @@ PresShell::ScrollPage(PRBool aForward)
|
||||
result = viewManager->GetRootScrollableView(&scrollView);
|
||||
if (NS_SUCCEEDED(result) && scrollView)
|
||||
{
|
||||
scrollView->ScrollByPages(aForward ? 1 : -1);
|
||||
scrollView->ScrollByPages(0, aForward ? 1 : -1);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -3390,7 +3390,7 @@ PresShell::CompleteMove(PRBool aForward, PRBool aExtend)
|
||||
);
|
||||
if (NS_POSITION_BEFORE_TABLE == result) //NS_POSITION_BEFORE_TABLE should ALSO break
|
||||
break;
|
||||
if (NS_OK != result || !pos.mResultFrame )
|
||||
if (NS_FAILED (result) || !pos.mResultFrame )
|
||||
return result?result:NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsILineIteratorNavigator> newIt;
|
||||
//check to see if this is ANOTHER blockframe inside the other one if so then call into its lines
|
||||
@ -3492,7 +3492,7 @@ PresShell::StyleChangeReflow()
|
||||
nsIRenderingContext* rcx = nsnull;
|
||||
|
||||
nsresult rv=CreateRenderingContext(rootFrame, &rcx);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsHTMLReflowState reflowState(mPresContext, rootFrame,
|
||||
eReflowReason_StyleChange, rcx, maxSize);
|
||||
@ -3877,13 +3877,13 @@ NS_IMETHODIMP
|
||||
PresShell::ClearFrameRefs(nsIFrame* aFrame)
|
||||
{
|
||||
nsIEventStateManager *manager;
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
|
||||
if (NS_SUCCEEDED (mPresContext->GetEventStateManager(&manager))) {
|
||||
manager->ClearFrameRefs(aFrame);
|
||||
NS_RELEASE(manager);
|
||||
}
|
||||
|
||||
if (mCaret) {
|
||||
mCaret->ClearFrameRefs(aFrame);
|
||||
mCaret->ClearFrameRefs(aFrame);
|
||||
}
|
||||
|
||||
if (aFrame == mCurrentEventFrame) {
|
||||
@ -4274,8 +4274,8 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
||||
content->GetDocument(*getter_AddRefs(document));
|
||||
if(document){
|
||||
nsCOMPtr<nsIFocusController> focusController;
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(ourGlobal);
|
||||
if(ourWindow) {
|
||||
ourWindow->GetRootFocusController(getter_AddRefs(focusController));
|
||||
@ -4696,10 +4696,6 @@ PresShell::SetAnonymousContentFor(nsIContent* aContent, nsISupportsArray* aAnony
|
||||
if (! aContent)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aAnonymousElements != nsnull, "null ptr");
|
||||
if (! aAnonymousElements)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! mAnonymousContentTable) {
|
||||
mAnonymousContentTable = new nsSupportsHashtable;
|
||||
if (! mAnonymousContentTable)
|
||||
@ -4711,26 +4707,33 @@ PresShell::SetAnonymousContentFor(nsIContent* aContent, nsISupportsArray* aAnony
|
||||
nsCOMPtr<nsISupportsArray> oldAnonymousElements =
|
||||
getter_AddRefs(NS_STATIC_CAST(nsISupportsArray*, mAnonymousContentTable->Get(&key)));
|
||||
|
||||
if (oldAnonymousElements) {
|
||||
// If we're trying to set anonymous content for an element that
|
||||
// already had anonymous content, then we need to be sure to clean
|
||||
// up after the old content. (This can happen, for example, when a
|
||||
// reframe occurs.)
|
||||
PRUint32 count;
|
||||
oldAnonymousElements->Count(&count);
|
||||
|
||||
while (PRInt32(--count) >= 0) {
|
||||
nsCOMPtr<nsISupports> isupports( getter_AddRefs(oldAnonymousElements->ElementAt(count)) );
|
||||
nsCOMPtr<nsIContent> content( do_QueryInterface(isupports) );
|
||||
NS_ASSERTION(content != nsnull, "not an nsIContent");
|
||||
if (! content)
|
||||
continue;
|
||||
|
||||
content->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
||||
if (!oldAnonymousElements) {
|
||||
if (aAnonymousElements) {
|
||||
mAnonymousContentTable->Put(&key, aAnonymousElements);
|
||||
}
|
||||
} else {
|
||||
if (aAnonymousElements) {
|
||||
oldAnonymousElements->AppendElements(aAnonymousElements);
|
||||
} else {
|
||||
// If we're trying to clear anonymous content for an element that
|
||||
// already had anonymous content, then we need to be sure to clean
|
||||
// up after the old content. (This can happen, for example, when a
|
||||
// reframe occurs.)
|
||||
PRUint32 count;
|
||||
oldAnonymousElements->Count(&count);
|
||||
|
||||
while (PRInt32(--count) >= 0) {
|
||||
nsCOMPtr<nsISupports> isupports( getter_AddRefs(oldAnonymousElements->ElementAt(count)) );
|
||||
nsCOMPtr<nsIContent> content( do_QueryInterface(isupports) );
|
||||
NS_ASSERTION(content != nsnull, "not an nsIContent");
|
||||
if (! content)
|
||||
continue;
|
||||
|
||||
content->SetDocument(nsnull, PR_TRUE, PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mAnonymousContentTable->Put(&key, aAnonymousElements);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -5018,7 +5021,7 @@ PresShell::HandlePostedReflowCallbacks()
|
||||
node = node->next;
|
||||
mFirstCallbackEventRequest = node;
|
||||
FreeFrame(sizeof(nsCallbackEventRequest), toFree);
|
||||
if (callback)
|
||||
if (callback)
|
||||
callback->ReflowFinished(this, &shouldFlush);
|
||||
NS_IF_RELEASE(callback);
|
||||
}
|
||||
@ -5830,8 +5833,8 @@ PresShell::GetCurrentEventFrame()
|
||||
NS_IMETHODIMP
|
||||
PresShell::GetEventTargetFrame(nsIFrame** aFrame)
|
||||
{
|
||||
*aFrame = GetCurrentEventFrame();
|
||||
return NS_OK;
|
||||
*aFrame = GetCurrentEventFrame();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -5848,7 +5851,7 @@ PresShell::GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent)
|
||||
*aContent = nsnull;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
@ -5961,7 +5964,7 @@ NS_IMETHODIMP
|
||||
PresShell::HandleEvent(nsIView *aView,
|
||||
nsGUIEvent* aEvent,
|
||||
nsEventStatus* aEventStatus,
|
||||
PRBool aForceHandle,
|
||||
PRBool aForceHandle,
|
||||
PRBool& aHandled)
|
||||
{
|
||||
void* clientData;
|
||||
@ -6042,7 +6045,7 @@ PresShell::HandleEvent(nsIView *aView,
|
||||
PushCurrentEventInfo(nsnull, nsnull);
|
||||
|
||||
nsCOMPtr<nsIEventStateManager> manager;
|
||||
if (NS_OK == mPresContext->GetEventStateManager(getter_AddRefs(manager))) {
|
||||
if (NS_SUCCEEDED (mPresContext->GetEventStateManager(getter_AddRefs(manager)))) {
|
||||
//change 6-01-00 mjudge,ftang adding ime as an event that needs focused element
|
||||
if (NS_IS_KEY_EVENT(aEvent) || NS_IS_IME_EVENT(aEvent) || aEvent->message == NS_CONTEXTMENU_KEY) {
|
||||
//Key events go to the focused frame, not point based.
|
||||
@ -6129,17 +6132,17 @@ PresShell::HandleEvent(nsIView *aView,
|
||||
eventPoint -= originOffset;
|
||||
|
||||
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FOREGROUND, &mCurrentEventFrame);
|
||||
if (rv != NS_OK) {
|
||||
if (NS_FAILED (rv)) {
|
||||
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_FLOATERS, &mCurrentEventFrame);
|
||||
if (rv != NS_OK) {
|
||||
if (NS_FAILED (rv)) {
|
||||
rv = frame->GetFrameForPoint(mPresContext, eventPoint, NS_FRAME_PAINT_LAYER_BACKGROUND, &mCurrentEventFrame);
|
||||
if (rv != NS_OK) {
|
||||
if (aForceHandle) {
|
||||
mCurrentEventFrame = frame;
|
||||
}
|
||||
else {
|
||||
mCurrentEventFrame = nsnull;
|
||||
}
|
||||
if (NS_FAILED (rv)) {
|
||||
if (aForceHandle) {
|
||||
mCurrentEventFrame = frame;
|
||||
}
|
||||
else {
|
||||
mCurrentEventFrame = nsnull;
|
||||
}
|
||||
aHandled = PR_FALSE;
|
||||
rv = NS_OK;
|
||||
}
|
||||
@ -6202,7 +6205,7 @@ PresShell::HandleEvent(nsIView *aView,
|
||||
// use aView or mCurrentTargetView??
|
||||
if ( (mCurrentTargetRect != oldTargetRect) || (mCurrentTargetView != oldView)) {
|
||||
nsIViewManager *vm;
|
||||
if ((NS_OK == GetViewManager(&vm)) && vm) {
|
||||
if ((NS_SUCCEEDED (GetViewManager(&vm))) && vm) {
|
||||
vm->UpdateView(mCurrentTargetView,mCurrentTargetRect,0);
|
||||
if (oldView)
|
||||
vm->UpdateView(oldView,oldTargetRect,0);
|
||||
@ -6251,19 +6254,19 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, PRUint32 aFlags,
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsIEventStateManager *manager;
|
||||
if (NS_OK == mPresContext->GetEventStateManager(&manager) && GetCurrentEventFrame()) {
|
||||
if (NS_SUCCEEDED (mPresContext->GetEventStateManager(&manager)) && GetCurrentEventFrame()) {
|
||||
//1. Give event to event manager for pre event state changes and generation of synthetic events.
|
||||
rv = manager->PreHandleEvent(mPresContext, aEvent, mCurrentEventFrame, aStatus, aView);
|
||||
|
||||
//2. Give event to the DOM for third party and JS use.
|
||||
if ((GetCurrentEventFrame()) && NS_OK == rv) {
|
||||
if ((GetCurrentEventFrame()) && NS_SUCCEEDED (rv)) {
|
||||
if (mCurrentEventContent) {
|
||||
rv = mCurrentEventContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
|
||||
aFlags, aStatus);
|
||||
}
|
||||
else {
|
||||
nsIContent* targetContent;
|
||||
if (NS_OK == mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent) && nsnull != targetContent) {
|
||||
if (NS_SUCCEEDED (mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent)) && nsnull != targetContent) {
|
||||
rv = targetContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
|
||||
aFlags, aStatus);
|
||||
NS_RELEASE(targetContent);
|
||||
@ -6279,7 +6282,7 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, PRUint32 aFlags,
|
||||
}
|
||||
else if (mCurrentEventFrame) {
|
||||
nsIContent* targetContent;
|
||||
if (NS_OK == mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent) && nsnull != targetContent) {
|
||||
if (NS_SUCCEEDED (mCurrentEventFrame->GetContentForEvent(mPresContext, aEvent, &targetContent)) && nsnull != targetContent) {
|
||||
rv = targetContent->HandleDOMEvent(mPresContext, aEvent, nsnull,
|
||||
aFlags | NS_EVENT_FLAG_SYSTEM_EVENT, aStatus);
|
||||
NS_RELEASE(targetContent);
|
||||
@ -6289,12 +6292,12 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView, PRUint32 aFlags,
|
||||
//3. Give event to the Frames for browser default processing.
|
||||
// XXX The event isn't translated into the local coordinate space
|
||||
// of the frame...
|
||||
if (GetCurrentEventFrame() && NS_OK == rv && aEvent->eventStructType != NS_EVENT) {
|
||||
if (GetCurrentEventFrame() && NS_SUCCEEDED (rv) && aEvent->eventStructType != NS_EVENT) {
|
||||
rv = mCurrentEventFrame->HandleEvent(mPresContext, (nsGUIEvent*)aEvent, aStatus);
|
||||
}
|
||||
|
||||
//4. Give event to event manager for post event state changes and generation of synthetic events.
|
||||
if ((GetCurrentEventFrame()) && NS_OK == rv) {
|
||||
if ((GetCurrentEventFrame()) && NS_SUCCEEDED (rv)) {
|
||||
rv = manager->PostHandleEvent(mPresContext, aEvent, mCurrentEventFrame, aStatus, aView);
|
||||
}
|
||||
}
|
||||
@ -6484,7 +6487,7 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
|
||||
rootFrame->GetSize(maxSize);
|
||||
|
||||
nsresult rv=CreateRenderingContext(rootFrame, &rcx);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (GetVerifyReflowEnable()) {
|
||||
@ -7204,7 +7207,7 @@ PresShell::VerifyIncrementalReflow()
|
||||
NS_RELEASE(container);
|
||||
}
|
||||
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create presentation context");
|
||||
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation context");
|
||||
nsCOMPtr<nsIDeviceContext> dc;
|
||||
mPresContext->GetDeviceContext(getter_AddRefs(dc));
|
||||
cx->Init(dc);
|
||||
@ -7216,7 +7219,7 @@ PresShell::VerifyIncrementalReflow()
|
||||
nsIScrollableView* scrollView;
|
||||
rv = rootView->QueryInterface(NS_GET_IID(nsIScrollableView),
|
||||
(void**)&scrollView);
|
||||
if (NS_OK == rv) {
|
||||
if (NS_SUCCEEDED (rv)) {
|
||||
scrollView->GetScrollPreference(scrolling);
|
||||
}
|
||||
nsCOMPtr<nsIWidget> rootWidget;
|
||||
@ -7227,13 +7230,9 @@ PresShell::VerifyIncrementalReflow()
|
||||
rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull,
|
||||
NS_GET_IID(nsIViewManager),
|
||||
(void**) &vm);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create view manager");
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create view manager");
|
||||
rv = vm->Init(dc);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to init view manager");
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to init view manager");
|
||||
|
||||
// Create a child window of the parent that is our "root view/window"
|
||||
// Create a view
|
||||
@ -7243,21 +7242,15 @@ PresShell::VerifyIncrementalReflow()
|
||||
rv = nsComponentManager::CreateInstance(kViewCID, nsnull,
|
||||
NS_GET_IID(nsIView),
|
||||
(void **) &view);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create scroll view");
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view");
|
||||
rv = view->Init(vm, tbounds, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to init scroll view");
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to init scroll view");
|
||||
|
||||
//now create the widget for the view
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(mDocument));
|
||||
rv = view->CreateWidget(kWidgetCID, nsnull, nativeParentWidget, PR_TRUE,
|
||||
PR_TRUE, xulDoc? eContentTypeUI: eContentTypeContent);
|
||||
if (NS_OK != rv) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create scroll view widget");
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create scroll view widget");
|
||||
|
||||
// Setup hierarchical relationship in view manager
|
||||
vm->SetRootView(view);
|
||||
@ -7275,7 +7268,7 @@ PresShell::VerifyIncrementalReflow()
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to clone style set");
|
||||
rv = mDocument->CreateShell(cx, vm, newSet, &sh);
|
||||
sh->SetVerifyReflowEnable(PR_FALSE); // turn off verify reflow while we're reflowing the test frame tree
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create presentation shell");
|
||||
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation shell");
|
||||
vm->SetViewObserver((nsIViewObserver *)((PresShell*)sh));
|
||||
sh->InitialReflow(r.width, r.height);
|
||||
sh->SetVerifyReflowEnable(PR_TRUE); // turn on verify reflow again now that we're done reflowing the test frame tree
|
||||
@ -7734,7 +7727,7 @@ void ReflowCountMgr::PaintCount(const char * aName,
|
||||
if (counter != nsnull && counter->mName.EqualsWithConversion(aName)) {
|
||||
aRenderingContext->PushState();
|
||||
nsFont font("Times", NS_FONT_STYLE_NORMAL,NS_FONT_VARIANT_NORMAL,
|
||||
NS_FONT_WEIGHT_NORMAL,0,NSIntPointsToTwips(8));
|
||||
NS_FONT_WEIGHT_NORMAL,0,NSIntPointsToTwips(8));
|
||||
|
||||
nsCOMPtr<nsIFontMetrics> fm;
|
||||
aPresContext->GetMetricsFor(font, getter_AddRefs(fm));
|
||||
|
||||
@ -811,7 +811,7 @@ nsTextInputSelectionImpl::ScrollPage(PRBool aForward)
|
||||
if (!scrollableView)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return scrollableView->ScrollByPages(aForward ? 1 : -1);
|
||||
return scrollableView->ScrollByPages(0, aForward ? 1 : -1);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@ -211,23 +211,25 @@ public:
|
||||
NS_IMETHOD GetLineHeight(nscoord *aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Scroll the view up or down by aNumLines lines. positive
|
||||
* values move down in the view. Prevents scrolling off the
|
||||
* end of the view.
|
||||
* @param aNumLines number of lines to scroll the view by
|
||||
* Scroll the view left or right by aNumLinesX columns. Positive values move right.
|
||||
* Scroll the view up or down by aNumLinesY lines. Positive values move down.
|
||||
* Prevents scrolling off the end of the view.
|
||||
* @param aNumLinesX number of lines to scroll the view horizontally
|
||||
* @param aNumLinesY number of lines to scroll the view vertically
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLinexY) = 0;
|
||||
|
||||
/**
|
||||
* Scroll the view up or down by aNumPages pages. a page
|
||||
* is considered to be the amount displayed by the clip view.
|
||||
* positive values move down in the view. Prevents scrolling
|
||||
* off the end of the view.
|
||||
* @param aNumPage number of pages to scroll the view by
|
||||
* Scroll the view left or right by aNumPagesX pages. Positive values move right.
|
||||
* Scroll the view up or down by aNumPagesY pages. Positive values move down.
|
||||
* A page is considered to be the amount displayed by the clip view.
|
||||
* Prevents scrolling off the end of the view.
|
||||
* @param aNumPagesX number of pages to scroll the view horizontally
|
||||
* @param aNumPagesY number of pages to scroll the view vertically
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD ScrollByPages(PRInt32 aNumPages) = 0;
|
||||
NS_IMETHOD ScrollByPages(PRInt32 aNumPagesX, PRInt32 aNumPagesY) = 0;
|
||||
|
||||
/**
|
||||
* Scroll the view to the top or bottom of the document depending
|
||||
|
||||
@ -121,20 +121,20 @@ NS_IMETHODIMP nsScrollPortView::GetClipView(const nsIView** aClipView) const
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::AddScrollPositionListener(nsIScrollPositionListener* aListener)
|
||||
{
|
||||
if (nsnull == mListeners) {
|
||||
nsresult rv = NS_NewISupportsArray(&mListeners);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
return mListeners->AppendElement(aListener);
|
||||
if (nsnull == mListeners) {
|
||||
nsresult rv = NS_NewISupportsArray(&mListeners);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
return mListeners->AppendElement(aListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::RemoveScrollPositionListener(nsIScrollPositionListener* aListener)
|
||||
{
|
||||
if (nsnull != mListeners) {
|
||||
return mListeners->RemoveElement(aListener);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
if (nsnull != mListeners) {
|
||||
return mListeners->RemoveElement(aListener);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::CreateScrollControls(nsNativeWidget aNative)
|
||||
@ -210,123 +210,121 @@ NS_IMETHODIMP nsScrollPortView::GetScrollPreference(nsScrollPreference &aScrollP
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags)
|
||||
{
|
||||
// do nothing if the we aren't scrolling.
|
||||
if (aX == mOffsetX && aY == mOffsetY)
|
||||
return NS_OK;
|
||||
// do nothing if the we aren't scrolling.
|
||||
if (aX == mOffsetX && aY == mOffsetY)
|
||||
return NS_OK;
|
||||
|
||||
nsSize scrolledSize;
|
||||
|
||||
nsSize scrolledSize;
|
||||
PRInt32 dxPx = 0, dyPx = 0;
|
||||
|
||||
PRInt32 dxPx = 0, dyPx = 0;
|
||||
// convert to pixels
|
||||
nsIDeviceContext *dev;
|
||||
float t2p;
|
||||
float p2t;
|
||||
|
||||
// convert to pixels
|
||||
nsIDeviceContext *dev;
|
||||
float t2p;
|
||||
float p2t;
|
||||
|
||||
mViewManager->GetDeviceContext(dev);
|
||||
dev->GetAppUnitsToDevUnits(t2p);
|
||||
dev->GetDevUnitsToAppUnits(p2t);
|
||||
mViewManager->GetDeviceContext(dev);
|
||||
dev->GetAppUnitsToDevUnits(t2p);
|
||||
dev->GetDevUnitsToAppUnits(p2t);
|
||||
|
||||
NS_RELEASE(dev);
|
||||
NS_RELEASE(dev);
|
||||
|
||||
// Update the scrolled view's position
|
||||
// Update the scrolled view's position
|
||||
|
||||
// make sure the new position in in bounds
|
||||
nsView* scrolledView = GetScrolledView();
|
||||
// make sure the new position in in bounds
|
||||
nsView* scrolledView = GetScrolledView();
|
||||
|
||||
#ifdef DEBUG_pollmann
|
||||
NS_ASSERTION(scrolledView, "no scrolled view");
|
||||
NS_ASSERTION(scrolledView, "no scrolled view");
|
||||
#endif
|
||||
|
||||
if (!scrolledView) return NS_ERROR_FAILURE;
|
||||
scrolledView->GetDimensions(scrolledSize);
|
||||
if (!scrolledView) return NS_ERROR_FAILURE;
|
||||
scrolledView->GetDimensions(scrolledSize);
|
||||
|
||||
nsSize portSize;
|
||||
GetDimensions(portSize);
|
||||
nsSize portSize;
|
||||
GetDimensions(portSize);
|
||||
|
||||
nscoord maxX = scrolledSize.width - portSize.width;
|
||||
nscoord maxY = scrolledSize.height - portSize.height;
|
||||
nscoord maxX = scrolledSize.width - portSize.width;
|
||||
nscoord maxY = scrolledSize.height - portSize.height;
|
||||
|
||||
if (aX > maxX)
|
||||
aX = maxX;
|
||||
if (aX > maxX)
|
||||
aX = maxX;
|
||||
|
||||
if (aY > maxY)
|
||||
aY = maxY;
|
||||
if (aY > maxY)
|
||||
aY = maxY;
|
||||
|
||||
if (aX < 0)
|
||||
aX = 0;
|
||||
if (aX < 0)
|
||||
aX = 0;
|
||||
|
||||
if (aY < 0)
|
||||
aY = 0;
|
||||
if (aY < 0)
|
||||
aY = 0;
|
||||
|
||||
// convert aX and aY in pixels
|
||||
nscoord aXpx = NSTwipsToIntPixels(aX, t2p);
|
||||
nscoord aYpx = NSTwipsToIntPixels(aY, t2p);
|
||||
// convert aX and aY in pixels
|
||||
nscoord aXpx = NSTwipsToIntPixels(aX, t2p);
|
||||
nscoord aYpx = NSTwipsToIntPixels(aY, t2p);
|
||||
|
||||
aX = NSIntPixelsToTwips(aXpx,p2t);
|
||||
aY = NSIntPixelsToTwips(aYpx,p2t);
|
||||
aX = NSIntPixelsToTwips(aXpx,p2t);
|
||||
aY = NSIntPixelsToTwips(aYpx,p2t);
|
||||
|
||||
// do nothing if the we aren't scrolling.
|
||||
// this needs to be rechecked because of the clamping and
|
||||
// rounding
|
||||
if (aX == mOffsetX && aY == mOffsetY)
|
||||
return NS_OK;
|
||||
// do nothing if the we aren't scrolling.
|
||||
// this needs to be rechecked because of the clamping and
|
||||
// rounding
|
||||
if (aX == mOffsetX && aY == mOffsetY)
|
||||
return NS_OK;
|
||||
|
||||
// figure out the diff by comparing old pos to new
|
||||
dxPx = mOffsetXpx - aXpx;
|
||||
dyPx = mOffsetYpx - aYpx;
|
||||
// figure out the diff by comparing old pos to new
|
||||
dxPx = mOffsetXpx - aXpx;
|
||||
dyPx = mOffsetYpx - aYpx;
|
||||
|
||||
// notify the listeners.
|
||||
PRUint32 listenerCount;
|
||||
const nsIID& kScrollPositionListenerIID = NS_GET_IID(nsIScrollPositionListener);
|
||||
nsIScrollPositionListener* listener;
|
||||
if (nsnull != mListeners) {
|
||||
if (NS_SUCCEEDED(mListeners->Count(&listenerCount))) {
|
||||
for (PRUint32 i = 0; i < listenerCount; i++) {
|
||||
if (NS_SUCCEEDED(mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener))) {
|
||||
listener->ScrollPositionWillChange(this, aX, aY);
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// notify the listeners.
|
||||
PRUint32 listenerCount;
|
||||
const nsIID& kScrollPositionListenerIID = NS_GET_IID(nsIScrollPositionListener);
|
||||
nsIScrollPositionListener* listener;
|
||||
if (nsnull != mListeners) {
|
||||
if (NS_SUCCEEDED(mListeners->Count(&listenerCount))) {
|
||||
for (PRUint32 i = 0; i < listenerCount; i++) {
|
||||
if (NS_SUCCEEDED(mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener))) {
|
||||
listener->ScrollPositionWillChange(this, aX, aY);
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull != scrolledView)
|
||||
{
|
||||
// move the scrolled view to the new location
|
||||
scrolledView->SetPosition(-aX, -aY);
|
||||
if (nsnull != scrolledView)
|
||||
{
|
||||
// move the scrolled view to the new location
|
||||
scrolledView->SetPosition(-aX, -aY);
|
||||
|
||||
// store old position in pixels. We need to do this to make sure there is no
|
||||
// round off errors. This could cause weird scrolling.
|
||||
mOffsetXpx = aXpx;
|
||||
mOffsetYpx = aYpx;
|
||||
// store old position in pixels. We need to do this to make sure there is no
|
||||
// round off errors. This could cause weird scrolling.
|
||||
mOffsetXpx = aXpx;
|
||||
mOffsetYpx = aYpx;
|
||||
|
||||
// store the new position
|
||||
mOffsetX = aX;
|
||||
mOffsetY = aY;
|
||||
}
|
||||
// store the new position
|
||||
mOffsetX = aX;
|
||||
mOffsetY = aY;
|
||||
}
|
||||
|
||||
Scroll(scrolledView, dxPx, dyPx, t2p, 0);
|
||||
Scroll(scrolledView, dxPx, dyPx, t2p, 0);
|
||||
|
||||
// notify the listeners.
|
||||
if (nsnull != mListeners) {
|
||||
if (NS_SUCCEEDED(mListeners->Count(&listenerCount))) {
|
||||
for (PRUint32 i = 0; i < listenerCount; i++) {
|
||||
if (NS_SUCCEEDED(mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener))) {
|
||||
listener->ScrollPositionDidChange(this, aX, aY);
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// notify the listeners.
|
||||
if (nsnull != mListeners) {
|
||||
if (NS_SUCCEEDED(mListeners->Count(&listenerCount))) {
|
||||
for (PRUint32 i = 0; i < listenerCount; i++) {
|
||||
if (NS_SUCCEEDED(mListeners->QueryElementAt(i, kScrollPositionListenerIID, (void**)&listener))) {
|
||||
listener->ScrollPositionDidChange(this, aX, aY);
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::SetControlInsets(const nsMargin &aInsets)
|
||||
{
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::GetControlInsets(nsMargin &aInsets) const
|
||||
@ -336,7 +334,7 @@ NS_IMETHODIMP nsScrollPortView::GetControlInsets(nsMargin &aInsets) const
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::GetScrollbarVisibility(PRBool *aVerticalVisible,
|
||||
PRBool *aHorizontalVisible) const
|
||||
PRBool *aHorizontalVisible) const
|
||||
{
|
||||
NS_WARNING("Attempt to get scrollbars visibility this is not xp!");
|
||||
return NS_OK;
|
||||
@ -344,8 +342,7 @@ NS_IMETHODIMP nsScrollPortView::GetScrollbarVisibility(PRBool *aVerticalVisible,
|
||||
|
||||
void nsScrollPortView::AdjustChildWidgets(nsScrollPortView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float scale)
|
||||
{
|
||||
|
||||
nscoord offx, offy;
|
||||
nscoord offx, offy;
|
||||
|
||||
if (aScrolling == aView)
|
||||
{
|
||||
@ -374,7 +371,7 @@ void nsScrollPortView::AdjustChildWidgets(nsScrollPortView *aScrolling, nsView *
|
||||
#endif
|
||||
kid->GetBounds(bounds);
|
||||
|
||||
win->Move(NSTwipsToIntPixels((bounds.x + aDx), scale), NSTwipsToIntPixels((bounds.y + aDy), scale));
|
||||
win->Move(NSTwipsToIntPixels((bounds.x + aDx), scale), NSTwipsToIntPixels((bounds.y + aDy), scale));
|
||||
}
|
||||
|
||||
// Don't recurse if the view has a widget, because we adjusted the view's
|
||||
@ -387,7 +384,6 @@ void nsScrollPortView::AdjustChildWidgets(nsScrollPortView *aScrolling, nsView *
|
||||
NS_RELEASE(win);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -448,29 +444,30 @@ NS_IMETHODIMP nsScrollPortView::GetLineHeight(nscoord *aHeight)
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLinesY)
|
||||
{
|
||||
nscoord dx = mLineHeight*aNumLinesX;
|
||||
nscoord dy = mLineHeight*aNumLinesY;
|
||||
nscoord dx = mLineHeight*aNumLinesX;
|
||||
nscoord dy = mLineHeight*aNumLinesY;
|
||||
|
||||
ScrollTo(mOffsetX + dx, mOffsetY + dy, 0);
|
||||
ScrollTo(mOffsetX + dx, mOffsetY + dy, 0);
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::ScrollByPages(PRInt32 aNumPages)
|
||||
NS_IMETHODIMP nsScrollPortView::ScrollByPages(PRInt32 aNumPagesX, PRInt32 aNumPagesY)
|
||||
{
|
||||
nsSize size;
|
||||
GetDimensions(size);
|
||||
nsSize size;
|
||||
GetDimensions(size);
|
||||
|
||||
// scroll % of the window
|
||||
nscoord dy = nscoord(float(size.height)*PAGE_SCROLL_PERCENT);
|
||||
// scroll % of the window
|
||||
nscoord dx = nscoord(float(size.width)*PAGE_SCROLL_PERCENT);
|
||||
nscoord dy = nscoord(float(size.height)*PAGE_SCROLL_PERCENT);
|
||||
|
||||
// put in the number of pages.
|
||||
dy *= aNumPages;
|
||||
// put in the number of pages.
|
||||
dx *= aNumPagesX;
|
||||
dy *= aNumPagesY;
|
||||
|
||||
ScrollTo(mOffsetX, mOffsetY + dy, 0);
|
||||
ScrollTo(mOffsetX + dx, mOffsetY + dy, 0);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::ScrollByWhole(PRBool aTop)
|
||||
@ -484,9 +481,9 @@ NS_IMETHODIMP nsScrollPortView::ScrollByWhole(PRBool aTop)
|
||||
newPos = scrolledSize.height;
|
||||
}
|
||||
|
||||
ScrollTo(0, newPos, 0);
|
||||
ScrollTo(0, newPos, 0);
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsScrollPortView::CannotBitBlt(nsView* aScrolledView)
|
||||
@ -494,9 +491,9 @@ PRBool nsScrollPortView::CannotBitBlt(nsView* aScrolledView)
|
||||
PRUint32 scrolledViewFlags = aScrolledView->GetViewFlags();
|
||||
|
||||
return (mScrollProperties & NS_SCROLL_PROPERTY_NEVER_BLIT) ||
|
||||
(scrolledViewFlags & NS_VIEW_FLAG_DONT_BITBLT) ||
|
||||
(!(mScrollProperties & NS_SCROLL_PROPERTY_ALWAYS_BLIT)
|
||||
&& !mViewManager->CanScrollWithBitBlt(aScrolledView));
|
||||
(scrolledViewFlags & NS_VIEW_FLAG_DONT_BITBLT) ||
|
||||
(!(mScrollProperties & NS_SCROLL_PROPERTY_ALWAYS_BLIT) &&
|
||||
!mViewManager->CanScrollWithBitBlt(aScrolledView));
|
||||
}
|
||||
|
||||
|
||||
@ -520,9 +517,9 @@ void nsScrollPortView::Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, f
|
||||
mViewManager->UpdateView(this, 0);
|
||||
|
||||
} else if (CannotBitBlt(aScrolledView)) {
|
||||
// we can't blit for some reason just update the view and adjust any heavy weight widgets
|
||||
mViewManager->UpdateView(this, 0);
|
||||
AdjustChildWidgets(this, aScrolledView, 0, 0, scale);
|
||||
// we can't blit for some reason just update the view and adjust any heavy weight widgets
|
||||
mViewManager->UpdateView(this, 0);
|
||||
AdjustChildWidgets(this, aScrolledView, 0, 0, scale);
|
||||
} else { // if we can blit and have a scrollwidget then scroll.
|
||||
// Scroll the contents of the widget by the specfied amount, and scroll
|
||||
// the child widgets
|
||||
@ -535,35 +532,35 @@ void nsScrollPortView::Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, f
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
PRUint32 aPaintFlags, PRBool &aResult)
|
||||
PRUint32 aPaintFlags, PRBool &aResult)
|
||||
{
|
||||
PRBool clipEmpty;
|
||||
rc.PushState();
|
||||
nsRect bounds;
|
||||
PRBool clipEmpty;
|
||||
rc.PushState();
|
||||
nsRect bounds;
|
||||
GetDimensions(bounds);
|
||||
bounds.x = bounds.y = 0;
|
||||
rc.SetClipRect(bounds, nsClipCombine_kIntersect, clipEmpty);
|
||||
bounds.x = bounds.y = 0;
|
||||
rc.SetClipRect(bounds, nsClipCombine_kIntersect, clipEmpty);
|
||||
|
||||
nsresult rv = nsView::Paint(rc, rect, aPaintFlags, aResult);
|
||||
nsresult rv = nsView::Paint(rc, rect, aPaintFlags, aResult);
|
||||
|
||||
rc.PopState(clipEmpty);
|
||||
rc.PopState(clipEmpty);
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollPortView::Paint(nsIRenderingContext& aRC, const nsIRegion& aRegion,
|
||||
PRUint32 aPaintFlags, PRBool &aResult)
|
||||
{
|
||||
PRBool clipEmpty;
|
||||
aRC.PushState();
|
||||
nsRect bounds;
|
||||
PRBool clipEmpty;
|
||||
aRC.PushState();
|
||||
nsRect bounds;
|
||||
GetDimensions(bounds);
|
||||
bounds.x = bounds.y = 0;
|
||||
aRC.SetClipRect(bounds, nsClipCombine_kIntersect, clipEmpty);
|
||||
bounds.x = bounds.y = 0;
|
||||
aRC.SetClipRect(bounds, nsClipCombine_kIntersect, clipEmpty);
|
||||
|
||||
nsresult rv = nsView::Paint(aRC, aRegion, aPaintFlags, aResult);
|
||||
|
||||
aRC.PopState(clipEmpty);
|
||||
aRC.PopState(clipEmpty);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public:
|
||||
NS_IMETHOD SetLineHeight(nscoord aHeight);
|
||||
NS_IMETHOD GetLineHeight(nscoord *aHeight);
|
||||
NS_IMETHOD ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLinesY);
|
||||
NS_IMETHOD ScrollByPages(PRInt32 aNumPages);
|
||||
NS_IMETHOD ScrollByPages(PRInt32 aNumPagesX, PRInt32 aNumPagesY);
|
||||
NS_IMETHOD ScrollByWhole(PRBool aTop);
|
||||
|
||||
NS_IMETHOD GetClipView(const nsIView** aClipView) const;
|
||||
|
||||
@ -175,7 +175,7 @@ NS_IMETHODIMP CornerView::ShowQuality(PRBool aShow)
|
||||
mViewManager->SetViewVisibility(this, nsViewVisibility_kShow);
|
||||
|
||||
nsIScrollableView *par;
|
||||
if (NS_OK == mParent->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)&par)) {
|
||||
if (NS_SUCCEEDED (mParent->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)&par))) {
|
||||
par->ComputeScrollOffsets(PR_TRUE);
|
||||
}
|
||||
}
|
||||
@ -211,17 +211,13 @@ void CornerView::Show(PRBool aShow, PRBool aRethink)
|
||||
if (PR_TRUE == aRethink)
|
||||
{
|
||||
nsIScrollableView *par;
|
||||
if (NS_OK == mParent->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)&par)) {
|
||||
if (NS_SUCCEEDED (mParent->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)&par))) {
|
||||
par->ComputeScrollOffsets(PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP CornerView::Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
PRUint32 aPaintFlags, PRBool &aResult)
|
||||
{
|
||||
@ -283,9 +279,9 @@ NS_IMETHODIMP CornerView::Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
|
||||
//this is inefficient, but compact...
|
||||
|
||||
tcolor = NS_RGB((int)min(NS_GET_R(bcolor) + 40, 255),
|
||||
(int)min(NS_GET_G(bcolor) + 40, 255),
|
||||
(int)min(NS_GET_B(bcolor) + 40, 255));
|
||||
tcolor = NS_RGB((int)PR_MIN(NS_GET_R(bcolor) + 40, 255),
|
||||
(int)PR_MIN(NS_GET_G(bcolor) + 40, 255),
|
||||
(int)PR_MIN(NS_GET_B(bcolor) + 40, 255));
|
||||
|
||||
rc.SetColor(tcolor);
|
||||
|
||||
@ -294,9 +290,9 @@ NS_IMETHODIMP CornerView::Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
nscoord(brect.width * 0.28f),
|
||||
nscoord(brect.height * 0.28f));
|
||||
|
||||
tcolor = NS_RGB((int)min(NS_GET_R(bcolor) + 120, 255),
|
||||
(int)min(NS_GET_G(bcolor) + 120, 255),
|
||||
(int)min(NS_GET_B(bcolor) + 120, 255));
|
||||
tcolor = NS_RGB((int)PR_MIN(NS_GET_R(bcolor) + 120, 255),
|
||||
(int)PR_MIN(NS_GET_G(bcolor) + 120, 255),
|
||||
(int)PR_MIN(NS_GET_B(bcolor) + 120, 255));
|
||||
|
||||
rc.SetColor(tcolor);
|
||||
|
||||
@ -314,10 +310,10 @@ NS_IMETHODIMP CornerView::Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
|
||||
NS_IMETHODIMP
|
||||
CornerView::Paint(nsIRenderingContext& rc, const nsIRegion& region,
|
||||
PRUint32 aPaintFlags, PRBool &aResult)
|
||||
PRUint32 aPaintFlags, PRBool &aResult)
|
||||
{
|
||||
// Corner View Paint is overridden to get rid of compiler warnings caused
|
||||
// by overloading Paint then overriding Paint.
|
||||
// Corner View Paint is overridden to get rid of compiler warnings caused
|
||||
// by overloading Paint then overriding Paint.
|
||||
return nsView::Paint(rc, region, aPaintFlags, aResult);
|
||||
}
|
||||
|
||||
@ -446,9 +442,9 @@ nsrefcnt nsScrollingView::Release()
|
||||
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::Init(nsIViewManager* aManager,
|
||||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
nsViewVisibility aVisibilityFlag)
|
||||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
nsViewVisibility aVisibilityFlag)
|
||||
{
|
||||
nsIDeviceContext *dx = nsnull;
|
||||
|
||||
@ -562,7 +558,7 @@ nsScrollingView::SetComponentVisibility(nsView* aView, nsViewVisibility aViewVis
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (nsnull != aView) {
|
||||
// Only set visibility if it's not currently set.
|
||||
// Only set visibility if it's not currently set.
|
||||
nsViewVisibility componentVisibility;
|
||||
aView->GetVisibility(componentVisibility);
|
||||
if (aViewVisibility != componentVisibility) {
|
||||
@ -581,10 +577,10 @@ nsScrollingView::UpdateComponentVisibility(nsViewVisibility aScrollingViewVisibi
|
||||
nsresult rv = NS_OK;
|
||||
if (nsViewVisibility_kHide == aScrollingViewVisibility) {
|
||||
|
||||
// Hide Clip View
|
||||
// Hide Clip View
|
||||
rv = SetComponentVisibility(mClipView, nsViewVisibility_kHide);
|
||||
|
||||
// Hide horizontal scrollbar
|
||||
// Hide horizontal scrollbar
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = SetComponentVisibility(mHScrollBarView, nsViewVisibility_kHide);
|
||||
}
|
||||
@ -600,31 +596,31 @@ nsScrollingView::UpdateComponentVisibility(nsViewVisibility aScrollingViewVisibi
|
||||
}
|
||||
|
||||
} else if (nsViewVisibility_kShow == aScrollingViewVisibility) {
|
||||
// Show clip view if if the scrolling view is visible
|
||||
rv = SetComponentVisibility(mClipView, nsViewVisibility_kShow);
|
||||
// Show clip view if if the scrolling view is visible
|
||||
rv = SetComponentVisibility(mClipView, nsViewVisibility_kShow);
|
||||
|
||||
PRBool horizEnabled = PR_FALSE;
|
||||
PRBool vertEnabled = PR_FALSE;
|
||||
PRBool horizEnabled = PR_FALSE;
|
||||
PRBool vertEnabled = PR_FALSE;
|
||||
|
||||
// Show horizontal scrollbar if it is enabled otherwise hide it
|
||||
if ((NS_SUCCEEDED(rv)) && (nsnull != mHScrollBarView)) {
|
||||
horizEnabled = ((ScrollBarView *)mHScrollBarView)->GetEnabled();
|
||||
rv = SetComponentVisibility(mHScrollBarView, horizEnabled ? nsViewVisibility_kShow : nsViewVisibility_kHide);
|
||||
}
|
||||
// Show horizontal scrollbar if it is enabled otherwise hide it
|
||||
if ((NS_SUCCEEDED(rv)) && (nsnull != mHScrollBarView)) {
|
||||
horizEnabled = ((ScrollBarView *)mHScrollBarView)->GetEnabled();
|
||||
rv = SetComponentVisibility(mHScrollBarView, horizEnabled ? nsViewVisibility_kShow : nsViewVisibility_kHide);
|
||||
}
|
||||
|
||||
// Show vertical scrollbar view if it is enabled otherwise hide it
|
||||
if ((NS_SUCCEEDED(rv)) && (nsnull != mVScrollBarView)) {
|
||||
vertEnabled = ((ScrollBarView *)mVScrollBarView)->GetEnabled();
|
||||
rv = SetComponentVisibility(mVScrollBarView, vertEnabled ? nsViewVisibility_kShow : nsViewVisibility_kHide);
|
||||
}
|
||||
// Show vertical scrollbar view if it is enabled otherwise hide it
|
||||
if ((NS_SUCCEEDED(rv)) && (nsnull != mVScrollBarView)) {
|
||||
vertEnabled = ((ScrollBarView *)mVScrollBarView)->GetEnabled();
|
||||
rv = SetComponentVisibility(mVScrollBarView, vertEnabled ? nsViewVisibility_kShow : nsViewVisibility_kHide);
|
||||
}
|
||||
|
||||
// Show the corner view if both the horizontal and vertical scrollbars are enabled otherwise hide it
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = SetComponentVisibility(mCornerView, (horizEnabled && vertEnabled) ? nsViewVisibility_kShow : nsViewVisibility_kHide);
|
||||
}
|
||||
}
|
||||
// Show the corner view if both the horizontal and vertical scrollbars are enabled otherwise hide it
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = SetComponentVisibility(mCornerView, (horizEnabled && vertEnabled) ? nsViewVisibility_kShow : nsViewVisibility_kHide);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
@ -646,20 +642,20 @@ NS_IMETHODIMP nsScrollingView::GetClipView(const nsIView** aClipView) const
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::AddScrollPositionListener(nsIScrollPositionListener* aListener)
|
||||
{
|
||||
if (nsnull == mListeners) {
|
||||
nsresult rv = NS_NewISupportsArray(&mListeners);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
return mListeners->AppendElement(aListener);
|
||||
if (nsnull == mListeners) {
|
||||
nsresult rv = NS_NewISupportsArray(&mListeners);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
return mListeners->AppendElement(aListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::RemoveScrollPositionListener(nsIScrollPositionListener* aListener)
|
||||
{
|
||||
if (nsnull != mListeners) {
|
||||
return mListeners->RemoveElement(aListener);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
if (nsnull != mListeners) {
|
||||
return mListeners->RemoveElement(aListener);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void nsScrollingView::HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags)
|
||||
@ -787,7 +783,7 @@ NS_IMETHODIMP nsScrollingView::Notify(nsITimer * aTimer)
|
||||
|
||||
nsIViewObserver *obs;
|
||||
|
||||
if (NS_OK == mViewManager->GetViewObserver(obs))
|
||||
if (NS_SUCCEEDED (mViewManager->GetViewObserver(obs)))
|
||||
{
|
||||
PRBool handled;
|
||||
obs->HandleEvent((nsIView *)this, &event, &retval, PR_TRUE, handled);
|
||||
@ -950,24 +946,24 @@ NS_IMETHODIMP nsScrollingView::SetWidget(nsIWidget *aWidget)
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::SetZIndex(PRBool aAuto, PRInt32 aZIndex, PRBool aTopMost)
|
||||
{
|
||||
nsView::SetZIndex(aAuto, aZIndex, aTopMost);
|
||||
|
||||
// inform all views that the z-index has changed.
|
||||
nsView::SetZIndex(aAuto, aZIndex, aTopMost);
|
||||
|
||||
// inform all views that the z-index has changed.
|
||||
// XXX why are we doing this? they're all a child of this view, so they
|
||||
// shouldn't need to be re-z-indexed.
|
||||
if (mClipView) mViewManager->SetViewZIndex(mClipView, aAuto, aZIndex, aTopMost);
|
||||
if (mCornerView) mViewManager->SetViewZIndex(mCornerView, aAuto, aZIndex, aTopMost);
|
||||
if (mVScrollBarView) mViewManager->SetViewZIndex(mVScrollBarView, aAuto, aZIndex, aTopMost);
|
||||
if (mHScrollBarView) mViewManager->SetViewZIndex(mHScrollBarView, aAuto, aZIndex, aTopMost);
|
||||
if (mClipView) mViewManager->SetViewZIndex(mClipView, aAuto, aZIndex, aTopMost);
|
||||
if (mCornerView) mViewManager->SetViewZIndex(mCornerView, aAuto, aZIndex, aTopMost);
|
||||
if (mVScrollBarView) mViewManager->SetViewZIndex(mVScrollBarView, aAuto, aZIndex, aTopMost);
|
||||
if (mHScrollBarView) mViewManager->SetViewZIndex(mHScrollBarView, aAuto, aZIndex, aTopMost);
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
||||
{
|
||||
nsView *scrolledView = GetScrolledView();
|
||||
nsIScrollbar *scrollv = nsnull, *scrollh = nsnull;
|
||||
PRBool hasVertical = PR_TRUE, hasHorizontal = PR_FALSE;
|
||||
PRBool hasVertical = PR_TRUE, hasHorizontal = PR_FALSE;
|
||||
nsIWidget *win;
|
||||
|
||||
if (nsnull != scrolledView)
|
||||
@ -995,7 +991,7 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
||||
mHScrollBarView->GetDimensions(hSize);
|
||||
mHScrollBarView->GetWidget(win);
|
||||
|
||||
if (NS_OK == win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh)) {
|
||||
if (NS_SUCCEEDED (win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh))) {
|
||||
if (((mSizeX > controlRect.width) &&
|
||||
(mScrollPref != nsScrollPreference_kNeverScroll)) ||
|
||||
(mScrollPref == nsScrollPreference_kAlwaysScroll) ||
|
||||
@ -1015,7 +1011,7 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
||||
|
||||
mVScrollBarView->GetWidget(win);
|
||||
|
||||
if (NS_OK == win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv)) {
|
||||
if (NS_SUCCEEDED (win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv))) {
|
||||
if ((mSizeY > (controlRect.height - (hasHorizontal ? hSize.height : 0)))) {
|
||||
// if we are scrollable
|
||||
if (mScrollPref != nsScrollPreference_kNeverScroll) {
|
||||
@ -1089,7 +1085,7 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
||||
offx = mOffsetX;
|
||||
mHScrollBarView->GetWidget(win);
|
||||
|
||||
if (NS_OK == win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh)) {
|
||||
if (NS_SUCCEEDED (win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh))) {
|
||||
if ((mSizeX > (controlRect.width - (hasVertical ? vSize.width : 0)))) {
|
||||
if (mScrollPref != nsScrollPreference_kNeverScroll) {
|
||||
//we need to be able to scroll
|
||||
@ -1196,7 +1192,7 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
||||
((ScrollBarView *)mHScrollBarView)->SetEnabled(PR_FALSE);
|
||||
|
||||
mHScrollBarView->GetWidget(win);
|
||||
if (NS_OK == win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh)) {
|
||||
if (NS_SUCCEEDED (win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh))) {
|
||||
scrollh->SetParameters(0, 0, 0, 0);
|
||||
NS_RELEASE(scrollh);
|
||||
}
|
||||
@ -1208,7 +1204,7 @@ NS_IMETHODIMP nsScrollingView::ComputeScrollOffsets(PRBool aAdjustWidgets)
|
||||
((ScrollBarView *)mVScrollBarView)->SetEnabled(PR_FALSE);
|
||||
|
||||
mVScrollBarView->GetWidget(win);
|
||||
if (NS_OK == win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv))
|
||||
if (NS_SUCCEEDED (win->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv)))
|
||||
{
|
||||
scrollv->SetParameters(0, 0, 0, 0);
|
||||
NS_RELEASE(scrollv);
|
||||
@ -1270,101 +1266,101 @@ NS_IMETHODIMP nsScrollingView::GetScrollPreference(nsScrollPreference &aScrollPr
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags)
|
||||
{
|
||||
nsIDeviceContext *dev;
|
||||
float t2p;
|
||||
float p2t;
|
||||
nsSize clipSize;
|
||||
nsIWidget *widget;
|
||||
PRInt32 dx = 0, dy = 0;
|
||||
nsIDeviceContext *dev;
|
||||
float t2p;
|
||||
float p2t;
|
||||
nsSize clipSize;
|
||||
nsIWidget *widget;
|
||||
PRInt32 dx = 0, dy = 0;
|
||||
|
||||
mViewManager->GetDeviceContext(dev);
|
||||
dev->GetAppUnitsToDevUnits(t2p);
|
||||
dev->GetDevUnitsToAppUnits(p2t);
|
||||
mViewManager->GetDeviceContext(dev);
|
||||
dev->GetAppUnitsToDevUnits(t2p);
|
||||
dev->GetDevUnitsToAppUnits(p2t);
|
||||
|
||||
NS_RELEASE(dev);
|
||||
NS_RELEASE(dev);
|
||||
|
||||
mClipView->GetDimensions(clipSize);
|
||||
|
||||
// Clamp aX
|
||||
// Clamp aX
|
||||
|
||||
if ((aX + clipSize.width) > mSizeX)
|
||||
aX = mSizeX - clipSize.width;
|
||||
if ((aX + clipSize.width) > mSizeX)
|
||||
aX = mSizeX - clipSize.width;
|
||||
|
||||
if (aX < 0)
|
||||
aX = 0;
|
||||
if (aX < 0)
|
||||
aX = 0;
|
||||
|
||||
// Clamp aY
|
||||
// Clamp aY
|
||||
|
||||
if ((aY + clipSize.height) > mSizeY)
|
||||
aY = mSizeY - clipSize.height;
|
||||
if ((aY + clipSize.height) > mSizeY)
|
||||
aY = mSizeY - clipSize.height;
|
||||
|
||||
if (aY < 0)
|
||||
aY = 0;
|
||||
if (aY < 0)
|
||||
aY = 0;
|
||||
|
||||
aX = NSIntPixelsToTwips(NSTwipsToIntPixels(aX, t2p), p2t);
|
||||
aY = NSIntPixelsToTwips(NSTwipsToIntPixels(aY, t2p), p2t);
|
||||
aX = NSIntPixelsToTwips(NSTwipsToIntPixels(aX, t2p), p2t);
|
||||
aY = NSIntPixelsToTwips(NSTwipsToIntPixels(aY, t2p), p2t);
|
||||
|
||||
// do nothing if the we aren't scrolling.
|
||||
if (aX == mOffsetX && aY == mOffsetY)
|
||||
return NS_OK;
|
||||
// do nothing if the we aren't scrolling.
|
||||
if (aX == mOffsetX && aY == mOffsetY)
|
||||
return NS_OK;
|
||||
|
||||
mVScrollBarView->GetWidget(widget);
|
||||
mVScrollBarView->GetWidget(widget);
|
||||
|
||||
if (nsnull != widget) {
|
||||
nsIScrollbar* scrollv = nsnull;
|
||||
if (NS_OK == widget->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv)) {
|
||||
// Move the scrollbar's thumb
|
||||
if (nsnull != widget) {
|
||||
nsIScrollbar* scrollv = nsnull;
|
||||
if (NS_SUCCEEDED (widget->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv))) {
|
||||
// Move the scrollbar's thumb
|
||||
|
||||
PRUint32 oldpos = mOffsetY;
|
||||
PRUint32 oldpos = mOffsetY;
|
||||
|
||||
scrollv->SetPosition(aY);
|
||||
scrollv->SetPosition(aY);
|
||||
|
||||
dy = NSTwipsToIntPixels((oldpos - aY), t2p);
|
||||
dy = NSTwipsToIntPixels((oldpos - aY), t2p);
|
||||
|
||||
NS_RELEASE(scrollv);
|
||||
}
|
||||
NS_RELEASE(scrollv);
|
||||
}
|
||||
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
|
||||
mHScrollBarView->GetWidget(widget);
|
||||
mHScrollBarView->GetWidget(widget);
|
||||
|
||||
if (nsnull != widget) {
|
||||
nsIScrollbar* scrollh = nsnull;
|
||||
if (NS_OK == widget->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh)) {
|
||||
// Move the scrollbar's thumb
|
||||
if (nsnull != widget) {
|
||||
nsIScrollbar* scrollh = nsnull;
|
||||
if (NS_SUCCEEDED (widget->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollh))) {
|
||||
// Move the scrollbar's thumb
|
||||
|
||||
PRUint32 oldpos = mOffsetX;
|
||||
PRUint32 oldpos = mOffsetX;
|
||||
|
||||
scrollh->SetPosition(aX);
|
||||
scrollh->SetPosition(aX);
|
||||
|
||||
dx = NSTwipsToIntPixels((oldpos - aX), t2p);
|
||||
dx = NSTwipsToIntPixels((oldpos - aX), t2p);
|
||||
|
||||
NS_RELEASE(scrollh);
|
||||
}
|
||||
NS_RELEASE(scrollh);
|
||||
}
|
||||
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
|
||||
// Update the scrolled view's position
|
||||
// Update the scrolled view's position
|
||||
|
||||
nsView* scrolledView = GetScrolledView();
|
||||
nsView* scrolledView = GetScrolledView();
|
||||
|
||||
NotifyScrollPositionWillChange(aX, aY);
|
||||
|
||||
if (nsnull != scrolledView)
|
||||
{
|
||||
scrolledView->SetPosition(-aX, -aY);
|
||||
if (nsnull != scrolledView)
|
||||
{
|
||||
scrolledView->SetPosition(-aX, -aY);
|
||||
|
||||
mOffsetX = aX;
|
||||
mOffsetY = aY;
|
||||
}
|
||||
mOffsetX = aX;
|
||||
mOffsetY = aY;
|
||||
}
|
||||
|
||||
Scroll(scrolledView, dx, dy, t2p, 0);
|
||||
Scroll(scrolledView, dx, dy, t2p, 0);
|
||||
|
||||
NotifyScrollPositionDidChange(aX, aY);
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::SetControlInsets(const nsMargin &aInsets)
|
||||
@ -1380,7 +1376,7 @@ NS_IMETHODIMP nsScrollingView::GetControlInsets(nsMargin &aInsets) const
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::GetScrollbarVisibility(PRBool *aVerticalVisible,
|
||||
PRBool *aHorizontalVisible) const
|
||||
PRBool *aHorizontalVisible) const
|
||||
{
|
||||
*aVerticalVisible = mVScrollBarView && ViewIsShowing((ScrollBarView *)mVScrollBarView);
|
||||
*aHorizontalVisible = mHScrollBarView && ViewIsShowing((ScrollBarView *)mHScrollBarView);
|
||||
@ -1390,8 +1386,8 @@ NS_IMETHODIMP nsScrollingView::GetScrollbarVisibility(PRBool *aVerticalVisible,
|
||||
void nsScrollingView::AdjustChildWidgets(nsScrollingView *aScrolling, nsView *aView,
|
||||
nscoord aDx, nscoord aDy, float scale)
|
||||
{
|
||||
nscoord offx, offy;
|
||||
PRBool isscroll = PR_FALSE;
|
||||
nscoord offx, offy;
|
||||
PRBool isscroll = PR_FALSE;
|
||||
|
||||
if (aScrolling == aView)
|
||||
{
|
||||
@ -1579,7 +1575,7 @@ NS_IMETHODIMP nsScrollingView::ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLin
|
||||
nscoord newPosX = 0, newPosY = 0;
|
||||
|
||||
if (aNumLinesX != 0) {
|
||||
if (mHScrollBarView->GetWidget(*getter_AddRefs(widget)) == NS_OK) {
|
||||
if (NS_SUCCEEDED (mHScrollBarView->GetWidget(*getter_AddRefs(widget)))) {
|
||||
nsCOMPtr<nsIScrollbar> scrollh( do_QueryInterface(widget) );
|
||||
if (scrollh) {
|
||||
PRUint32 oldPos = 0;
|
||||
@ -1593,7 +1589,7 @@ NS_IMETHODIMP nsScrollingView::ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLin
|
||||
}
|
||||
}
|
||||
if (aNumLinesY != 0) {
|
||||
if (mVScrollBarView->GetWidget(*getter_AddRefs(widget)) == NS_OK) {
|
||||
if (NS_SUCCEEDED (mVScrollBarView->GetWidget(*getter_AddRefs(widget)))) {
|
||||
nsCOMPtr<nsIScrollbar> scrollv( do_QueryInterface(widget) );
|
||||
if (scrollv) {
|
||||
PRUint32 oldPos = 0;
|
||||
@ -1611,8 +1607,8 @@ NS_IMETHODIMP nsScrollingView::ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLin
|
||||
mClipView->GetDimensions(clipSize);
|
||||
|
||||
//sanity check values
|
||||
if (newPosX > (mSizeX - clipSize.height))
|
||||
newPosX = mSizeX - clipSize.height;
|
||||
if (newPosX > (mSizeX - clipSize.width))
|
||||
newPosX = mSizeX - clipSize.width;
|
||||
else if (newPosX < 0)
|
||||
newPosX = 0;
|
||||
|
||||
@ -1626,53 +1622,71 @@ NS_IMETHODIMP nsScrollingView::ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLin
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::ScrollByPages(PRInt32 aNumPages)
|
||||
NS_IMETHODIMP nsScrollingView::ScrollByPages(PRInt32 aNumPagesX, PRInt32 aNumPagesY)
|
||||
{
|
||||
nsIWidget* widget = nsnull;
|
||||
if (mVScrollBarView->GetWidget(widget) == NS_OK) {
|
||||
nsIScrollbar* scrollv = nsnull;
|
||||
if (widget->QueryInterface(NS_GET_IID(nsIScrollbar), (void **)&scrollv) == NS_OK) {
|
||||
PRUint32 oldPos = 0;
|
||||
nsSize clipSize;
|
||||
nscoord newPos = 0;
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
nscoord newPosX = 0, newPosY = 0;
|
||||
|
||||
scrollv->GetPosition(oldPos);
|
||||
NS_RELEASE(scrollv);
|
||||
|
||||
mClipView->GetDimensions(clipSize);
|
||||
nsSize clipSize;
|
||||
mClipView->GetDimensions(clipSize);
|
||||
|
||||
newPos = oldPos + clipSize.height * aNumPages;
|
||||
if (aNumPagesX != 0) {
|
||||
if (NS_SUCCEEDED (mHScrollBarView->GetWidget(*getter_AddRefs(widget)))) {
|
||||
nsCOMPtr<nsIScrollbar> scrollh( do_QueryInterface(widget) );
|
||||
if (scrollh) {
|
||||
PRUint32 oldPos = 0;
|
||||
|
||||
if (newPos > (mSizeY - clipSize.height))
|
||||
newPos = mSizeY - clipSize.height;
|
||||
scrollh->GetPosition(oldPos);
|
||||
|
||||
if (newPos < 0)
|
||||
newPos = 0;
|
||||
newPosX = oldPos + clipSize.width * aNumPagesX;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aNumPagesY != 0) {
|
||||
if (NS_SUCCEEDED (mVScrollBarView->GetWidget(*getter_AddRefs(widget)))) {
|
||||
nsCOMPtr<nsIScrollbar> scrollv( do_QueryInterface(widget) );
|
||||
if (scrollv) {
|
||||
PRUint32 oldPos = 0;
|
||||
|
||||
ScrollTo(0, newPos, 0);
|
||||
}
|
||||
NS_RELEASE(widget);
|
||||
}
|
||||
scrollv->GetPosition(oldPos);
|
||||
|
||||
return NS_OK;
|
||||
newPosY = oldPos + clipSize.height * aNumPagesY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//sanity check values
|
||||
if (newPosX > (mSizeX - clipSize.width))
|
||||
newPosX = mSizeX - clipSize.width;
|
||||
else if (newPosX < 0)
|
||||
newPosX = 0;
|
||||
|
||||
if (newPosY > (mSizeY - clipSize.height))
|
||||
newPosY = mSizeY - clipSize.height;
|
||||
else if (newPosY < 0)
|
||||
newPosY = 0;
|
||||
|
||||
ScrollTo(newPosX, newPosY, 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView::ScrollByWhole(PRBool aTop)
|
||||
{
|
||||
nscoord newPos = 0;
|
||||
nscoord newPos = 0;
|
||||
|
||||
if (aTop) {
|
||||
newPos = 0;
|
||||
newPos = 0;
|
||||
}
|
||||
else {
|
||||
nsSize clipSize;
|
||||
mClipView->GetDimensions(clipSize);
|
||||
newPos = mSizeY - clipSize.height;
|
||||
nsSize clipSize;
|
||||
mClipView->GetDimensions(clipSize);
|
||||
newPos = mSizeY - clipSize.height;
|
||||
}
|
||||
|
||||
ScrollTo(0, newPos, 0);
|
||||
ScrollTo(0, newPos, 0);
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsScrollingView::CannotBitBlt(nsView* aScrolledView)
|
||||
|
||||
@ -58,9 +58,9 @@ public:
|
||||
|
||||
//overrides
|
||||
NS_IMETHOD Init(nsIViewManager* aManager,
|
||||
const nsRect &aBounds,
|
||||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
|
||||
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
|
||||
virtual void SetDimensions(const nsRect& aRect, PRBool aPaint = PR_TRUE);
|
||||
virtual void SetPosition(nscoord aX, nscoord aY);
|
||||
// SetVisibility is overriden so that it will set it's components visibility (ClipView,
|
||||
@ -94,7 +94,7 @@ public:
|
||||
NS_IMETHOD SetLineHeight(nscoord aHeight);
|
||||
NS_IMETHOD GetLineHeight(nscoord *aHeight);
|
||||
NS_IMETHOD ScrollByLines(PRInt32 aNumLinesX, PRInt32 aNumLinesY);
|
||||
NS_IMETHOD ScrollByPages(PRInt32 aNumPages);
|
||||
NS_IMETHOD ScrollByPages(PRInt32 aNumPagesX, PRInt32 aNumPagesY);
|
||||
NS_IMETHOD ScrollByWhole(PRBool aTop);
|
||||
|
||||
NS_IMETHOD GetClipView(const nsIView** aClipView) const;
|
||||
|
||||
@ -3143,7 +3143,6 @@ PRBool nsWindow::OnVScroll( MPARAM mp1, MPARAM mp2)
|
||||
|
||||
PRBool nsWindow::OnHScroll( MPARAM mp1, MPARAM mp2)
|
||||
{
|
||||
#if 0 /* OS2TODO */
|
||||
if (nsnull != mEventCallback) {
|
||||
nsMouseScrollEvent scrollEvent;
|
||||
scrollEvent.eventStructType = NS_MOUSE_SCROLL_EVENT;
|
||||
@ -3175,7 +3174,6 @@ PRBool nsWindow::OnHScroll( MPARAM mp1, MPARAM mp2)
|
||||
DispatchWindowEvent(&scrollEvent);
|
||||
NS_RELEASE(scrollEvent.widget);
|
||||
}
|
||||
#endif
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user