зеркало из https://github.com/mozilla/gecko-dev.git
beginning work on ScrollToFrame
This commit is contained in:
Родитель
5d4f949e92
Коммит
8efe480686
|
@ -56,7 +56,7 @@
|
|||
#include "SplitElementTxn.h"
|
||||
#include "JoinElementTxn.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
|
@ -652,7 +652,6 @@ nsEditor::EndTransaction()
|
|||
nsresult nsEditor::ScrollIntoView(PRBool aScrollToBegin)
|
||||
{
|
||||
nsresult result;
|
||||
/*
|
||||
if (mPresShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
|
@ -660,11 +659,30 @@ nsresult nsEditor::ScrollIntoView(PRBool aScrollToBegin)
|
|||
if (NS_SUCCEEDED(result) && selection)
|
||||
{
|
||||
// get the content of the start of the selection
|
||||
// get its layout object
|
||||
// get its frame
|
||||
// scroll that frame into view
|
||||
mPresShell->
|
||||
*/
|
||||
nsCOMPtr<nsIDOMNode>startNode;
|
||||
PRInt32 offset;
|
||||
result = selection->GetAnchorNodeAndOffset(getter_AddRefs(startNode), &offset);
|
||||
if (NS_SUCCEEDED(result) && startNode)
|
||||
{ // get the content from the node
|
||||
nsCOMPtr<nsIContent>startContent;
|
||||
result = startNode->QueryInterface(kIContentIID, getter_AddRefs(startContent));
|
||||
if (NS_SUCCEEDED(result) && startContent)
|
||||
{ // get its frame
|
||||
nsIFrame *frame=nsnull;
|
||||
result = mPresShell->GetPrimaryFrameFor(startContent, &frame);
|
||||
if (NS_SUCCEEDED(result) && frame)
|
||||
{ // scroll that frame into view
|
||||
result = mPresShell->ScrollFrameIntoView(frame,
|
||||
0, NS_PRESSHELL_SCROLL_TOP |NS_PRESSHELL_SCROLL_ANYWHERE,
|
||||
0, NS_PRESSHELL_SCROLL_LEFT|NS_PRESSHELL_SCROLL_ANYWHERE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,9 @@ nsresult nsTextEditor::InsertText(const nsString& aStringToInsert)
|
|||
if (mEditor)
|
||||
{
|
||||
result = mEditor->InsertText(aStringToInsert);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
mEditor->ScrollIntoView(PR_TRUE);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -232,6 +235,9 @@ nsresult nsTextEditor::Undo(PRUint32 aCount)
|
|||
if (mEditor)
|
||||
{
|
||||
result = mEditor->Undo(aCount);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
mEditor->ScrollIntoView(PR_TRUE);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -252,6 +258,9 @@ nsresult nsTextEditor::Redo(PRUint32 aCount)
|
|||
if (mEditor)
|
||||
{
|
||||
result = mEditor->Redo(aCount);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
mEditor->ScrollIntoView(PR_TRUE);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
#include "SplitElementTxn.h"
|
||||
#include "JoinElementTxn.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
|
@ -652,7 +652,6 @@ nsEditor::EndTransaction()
|
|||
nsresult nsEditor::ScrollIntoView(PRBool aScrollToBegin)
|
||||
{
|
||||
nsresult result;
|
||||
/*
|
||||
if (mPresShell)
|
||||
{
|
||||
nsCOMPtr<nsIDOMSelection> selection;
|
||||
|
@ -660,11 +659,30 @@ nsresult nsEditor::ScrollIntoView(PRBool aScrollToBegin)
|
|||
if (NS_SUCCEEDED(result) && selection)
|
||||
{
|
||||
// get the content of the start of the selection
|
||||
// get its layout object
|
||||
// get its frame
|
||||
// scroll that frame into view
|
||||
mPresShell->
|
||||
*/
|
||||
nsCOMPtr<nsIDOMNode>startNode;
|
||||
PRInt32 offset;
|
||||
result = selection->GetAnchorNodeAndOffset(getter_AddRefs(startNode), &offset);
|
||||
if (NS_SUCCEEDED(result) && startNode)
|
||||
{ // get the content from the node
|
||||
nsCOMPtr<nsIContent>startContent;
|
||||
result = startNode->QueryInterface(kIContentIID, getter_AddRefs(startContent));
|
||||
if (NS_SUCCEEDED(result) && startContent)
|
||||
{ // get its frame
|
||||
nsIFrame *frame=nsnull;
|
||||
result = mPresShell->GetPrimaryFrameFor(startContent, &frame);
|
||||
if (NS_SUCCEEDED(result) && frame)
|
||||
{ // scroll that frame into view
|
||||
result = mPresShell->ScrollFrameIntoView(frame,
|
||||
0, NS_PRESSHELL_SCROLL_TOP |NS_PRESSHELL_SCROLL_ANYWHERE,
|
||||
0, NS_PRESSHELL_SCROLL_LEFT|NS_PRESSHELL_SCROLL_ANYWHERE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче