зеркало из https://github.com/mozilla/pjs.git
Fix for 29737 -- selecting is slow in large files in composer. r=mjudge, akkana, a=jar.
This commit is contained in:
Родитель
b48f7aab7b
Коммит
afc6a88b45
|
@ -73,6 +73,7 @@ CPPSRCS = \
|
||||||
EXTRA_DSO_LDOPTS = \
|
EXTRA_DSO_LDOPTS = \
|
||||||
$(MOZ_NECKO_UTIL_LIBS) \
|
$(MOZ_NECKO_UTIL_LIBS) \
|
||||||
$(MOZ_COMPONENT_LIBS) \
|
$(MOZ_COMPONENT_LIBS) \
|
||||||
|
$(MOZ_TIMER_LIBS) \
|
||||||
-lmozjs \
|
-lmozjs \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,7 @@ LLIBS= \
|
||||||
$(DIST)\lib\js3250.lib \
|
$(DIST)\lib\js3250.lib \
|
||||||
$(DIST)\lib\gkparser.lib \
|
$(DIST)\lib\gkparser.lib \
|
||||||
$(DIST)\lib\raptorwidget_s.lib \
|
$(DIST)\lib\raptorwidget_s.lib \
|
||||||
|
$(DIST)\lib\timer_s.lib \
|
||||||
$(LIBNSPR)
|
$(LIBNSPR)
|
||||||
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
|
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
|
||||||
LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib
|
LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "nsIDOMXULCommandDispatcher.h"
|
#include "nsIDOMXULCommandDispatcher.h"
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIScriptGlobalObject.h"
|
||||||
#include "nsIDOMWindow.h"
|
#include "nsIDOMWindow.h"
|
||||||
|
#include "nsITimer.h"
|
||||||
|
|
||||||
#include "nsIEditor.h"
|
#include "nsIEditor.h"
|
||||||
#include "nsIHTMLEditor.h"
|
#include "nsIHTMLEditor.h"
|
||||||
|
@ -63,11 +64,14 @@ nsInterfaceState::nsInterfaceState()
|
||||||
|
|
||||||
nsInterfaceState::~nsInterfaceState()
|
nsInterfaceState::~nsInterfaceState()
|
||||||
{
|
{
|
||||||
|
// cancel any outstanding udpate timer
|
||||||
|
if (mUpdateTimer)
|
||||||
|
mUpdateTimer->Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsInterfaceState);
|
NS_IMPL_ADDREF(nsInterfaceState);
|
||||||
NS_IMPL_RELEASE(nsInterfaceState);
|
NS_IMPL_RELEASE(nsInterfaceState);
|
||||||
NS_IMPL_QUERY_INTERFACE3(nsInterfaceState, nsIDOMSelectionListener, nsIDocumentStateListener, nsITransactionListener);
|
NS_IMPL_QUERY_INTERFACE4(nsInterfaceState, nsIDOMSelectionListener, nsIDocumentStateListener, nsITransactionListener, nsITimerCallback);
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInterfaceState::Init(nsIHTMLEditor* aEditor, nsIDOMXULDocument *aChromeDoc)
|
nsInterfaceState::Init(nsIHTMLEditor* aEditor, nsIDOMXULDocument *aChromeDoc)
|
||||||
|
@ -113,16 +117,12 @@ nsInterfaceState::NotifyDocumentStateChanged(PRBool aNowDirty)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInterfaceState::NotifySelectionChanged()
|
nsInterfaceState::NotifySelectionChanged()
|
||||||
{
|
{
|
||||||
// if the selection state has changed, update stuff
|
return PrimeUpdateTimer();
|
||||||
PRBool isCollapsed = SelectionIsCollapsed();
|
|
||||||
if (isCollapsed != mSelectionCollapsed)
|
|
||||||
{
|
|
||||||
CallUpdateCommands(nsAutoString("select"));
|
|
||||||
mSelectionCollapsed = isCollapsed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ForceUpdate();
|
#ifdef XP_MAC
|
||||||
}
|
#pragma mark -
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsInterfaceState::WillDo(nsITransactionManager *aManager,
|
NS_IMETHODIMP nsInterfaceState::WillDo(nsITransactionManager *aManager,
|
||||||
|
@ -217,6 +217,44 @@ NS_IMETHODIMP nsInterfaceState::DidMerge(nsITransactionManager *aManager,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XP_MAC
|
||||||
|
#pragma mark -
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
nsresult nsInterfaceState::PrimeUpdateTimer()
|
||||||
|
{
|
||||||
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
if (mUpdateTimer)
|
||||||
|
{
|
||||||
|
// i'd love to be able to just call SetDelay on the existing timer, but
|
||||||
|
// i think i have to tear it down and make a new one.
|
||||||
|
mUpdateTimer->Cancel();
|
||||||
|
mUpdateTimer = NULL; // free it
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = NS_NewTimer(getter_AddRefs(mUpdateTimer));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
const PRUint32 kUpdateTimerDelay = 150;
|
||||||
|
return mUpdateTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kUpdateTimerDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void nsInterfaceState::TimerCallback()
|
||||||
|
{
|
||||||
|
// if the selection state has changed, update stuff
|
||||||
|
PRBool isCollapsed = SelectionIsCollapsed();
|
||||||
|
if (isCollapsed != mSelectionCollapsed)
|
||||||
|
{
|
||||||
|
CallUpdateCommands(nsAutoString("select"));
|
||||||
|
mSelectionCollapsed = isCollapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)ForceUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
nsresult nsInterfaceState::CallUpdateCommands(const nsString& aCommand)
|
nsresult nsInterfaceState::CallUpdateCommands(const nsString& aCommand)
|
||||||
{
|
{
|
||||||
|
@ -252,13 +290,16 @@ nsInterfaceState::ForceUpdate()
|
||||||
|
|
||||||
// update bold
|
// update bold
|
||||||
rv = UpdateTextState("b", "Editor:Bold", "bold", mBoldState);
|
rv = UpdateTextState("b", "Editor:Bold", "bold", mBoldState);
|
||||||
|
|
||||||
// update italic
|
// update italic
|
||||||
rv = UpdateTextState("i", "Editor:Italic", "italic", mItalicState);
|
rv = UpdateTextState("i", "Editor:Italic", "italic", mItalicState);
|
||||||
|
|
||||||
// update underline
|
// update underline
|
||||||
rv = UpdateTextState("u", "Editor:Underline", "underline", mUnderlineState);
|
rv = UpdateTextState("u", "Editor:Underline", "underline", mUnderlineState);
|
||||||
|
|
||||||
// update the paragraph format popup
|
// update the paragraph format popup
|
||||||
rv = UpdateParagraphState("Editor:Paragraph:Format", "format", mParagraphFormat);
|
rv = UpdateParagraphState("Editor:Paragraph:Format", "format", mParagraphFormat);
|
||||||
|
|
||||||
// udpate the font face
|
// udpate the font face
|
||||||
rv = UpdateFontFace("Editor:Font:Face", "font", mFontString);
|
rv = UpdateFontFace("Editor:Font:Face", "font", mFontString);
|
||||||
|
|
||||||
|
@ -473,6 +514,24 @@ nsInterfaceState::UnsetNodeAttribute(const char* nodeID, const char* attributeNa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XP_MAC
|
||||||
|
#pragma mark -
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
nsInterfaceState::Notify(nsITimer *timer)
|
||||||
|
{
|
||||||
|
NS_ASSERTION(timer == mUpdateTimer.get(), "Hey, this ain't my timer!");
|
||||||
|
mUpdateTimer = NULL; // release my hold
|
||||||
|
TimerCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef XP_MAC
|
||||||
|
#pragma mark -
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMXULDocument* aChromeDoc, nsIDOMSelectionListener** aInstancePtrResult)
|
nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMXULDocument* aChromeDoc, nsIDOMSelectionListener** aInstancePtrResult)
|
||||||
{
|
{
|
||||||
nsInterfaceState* newThang = new nsInterfaceState;
|
nsInterfaceState* newThang = new nsInterfaceState;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "nsIDocumentStateListener.h"
|
#include "nsIDocumentStateListener.h"
|
||||||
#include "nsITransactionListener.h"
|
#include "nsITransactionListener.h"
|
||||||
#include "nsIWebShell.h"
|
#include "nsIWebShell.h"
|
||||||
|
#include "nsITimerCallback.h"
|
||||||
|
|
||||||
class nsIHTMLEditor;
|
class nsIHTMLEditor;
|
||||||
class nsIDOMXULDocument;
|
class nsIDOMXULDocument;
|
||||||
|
@ -38,7 +39,8 @@ class nsIDOMXULDocument;
|
||||||
|
|
||||||
class nsInterfaceState : public nsIDOMSelectionListener,
|
class nsInterfaceState : public nsIDOMSelectionListener,
|
||||||
public nsIDocumentStateListener,
|
public nsIDocumentStateListener,
|
||||||
public nsITransactionListener
|
public nsITransactionListener,
|
||||||
|
public nsITimerCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -59,6 +61,8 @@ public:
|
||||||
|
|
||||||
NS_DECL_NSIDOCUMENTSTATELISTENER
|
NS_DECL_NSIDOCUMENTSTATELISTENER
|
||||||
|
|
||||||
|
// nsITimerCallback interfaces
|
||||||
|
NS_IMETHOD_(void) Notify(nsITimer *timer);
|
||||||
|
|
||||||
/** nsITransactionListener interfaces
|
/** nsITransactionListener interfaces
|
||||||
*/
|
*/
|
||||||
|
@ -100,6 +104,9 @@ protected:
|
||||||
|
|
||||||
nsresult CallUpdateCommands(const nsString& aCommand);
|
nsresult CallUpdateCommands(const nsString& aCommand);
|
||||||
|
|
||||||
|
nsresult PrimeUpdateTimer();
|
||||||
|
void TimerCallback();
|
||||||
|
|
||||||
// this class should not hold references to the editor or editorShell. Doing
|
// this class should not hold references to the editor or editorShell. Doing
|
||||||
// so would result in cirular reference chains.
|
// so would result in cirular reference chains.
|
||||||
|
|
||||||
|
@ -108,6 +115,8 @@ protected:
|
||||||
|
|
||||||
nsIDOMWindow* mDOMWindow; // nsIDOMWindow used for calling UpdateCommands
|
nsIDOMWindow* mDOMWindow; // nsIDOMWindow used for calling UpdateCommands
|
||||||
|
|
||||||
|
nsCOMPtr<nsITimer> mUpdateTimer;
|
||||||
|
|
||||||
// current state
|
// current state
|
||||||
PRInt8 mBoldState;
|
PRInt8 mBoldState;
|
||||||
PRInt8 mItalicState;
|
PRInt8 mItalicState;
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "nsIDOMXULCommandDispatcher.h"
|
#include "nsIDOMXULCommandDispatcher.h"
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIScriptGlobalObject.h"
|
||||||
#include "nsIDOMWindow.h"
|
#include "nsIDOMWindow.h"
|
||||||
|
#include "nsITimer.h"
|
||||||
|
|
||||||
#include "nsIEditor.h"
|
#include "nsIEditor.h"
|
||||||
#include "nsIHTMLEditor.h"
|
#include "nsIHTMLEditor.h"
|
||||||
|
@ -63,11 +64,14 @@ nsInterfaceState::nsInterfaceState()
|
||||||
|
|
||||||
nsInterfaceState::~nsInterfaceState()
|
nsInterfaceState::~nsInterfaceState()
|
||||||
{
|
{
|
||||||
|
// cancel any outstanding udpate timer
|
||||||
|
if (mUpdateTimer)
|
||||||
|
mUpdateTimer->Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsInterfaceState);
|
NS_IMPL_ADDREF(nsInterfaceState);
|
||||||
NS_IMPL_RELEASE(nsInterfaceState);
|
NS_IMPL_RELEASE(nsInterfaceState);
|
||||||
NS_IMPL_QUERY_INTERFACE3(nsInterfaceState, nsIDOMSelectionListener, nsIDocumentStateListener, nsITransactionListener);
|
NS_IMPL_QUERY_INTERFACE4(nsInterfaceState, nsIDOMSelectionListener, nsIDocumentStateListener, nsITransactionListener, nsITimerCallback);
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInterfaceState::Init(nsIHTMLEditor* aEditor, nsIDOMXULDocument *aChromeDoc)
|
nsInterfaceState::Init(nsIHTMLEditor* aEditor, nsIDOMXULDocument *aChromeDoc)
|
||||||
|
@ -113,16 +117,12 @@ nsInterfaceState::NotifyDocumentStateChanged(PRBool aNowDirty)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInterfaceState::NotifySelectionChanged()
|
nsInterfaceState::NotifySelectionChanged()
|
||||||
{
|
{
|
||||||
// if the selection state has changed, update stuff
|
return PrimeUpdateTimer();
|
||||||
PRBool isCollapsed = SelectionIsCollapsed();
|
|
||||||
if (isCollapsed != mSelectionCollapsed)
|
|
||||||
{
|
|
||||||
CallUpdateCommands(nsAutoString("select"));
|
|
||||||
mSelectionCollapsed = isCollapsed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ForceUpdate();
|
#ifdef XP_MAC
|
||||||
}
|
#pragma mark -
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsInterfaceState::WillDo(nsITransactionManager *aManager,
|
NS_IMETHODIMP nsInterfaceState::WillDo(nsITransactionManager *aManager,
|
||||||
|
@ -217,6 +217,44 @@ NS_IMETHODIMP nsInterfaceState::DidMerge(nsITransactionManager *aManager,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XP_MAC
|
||||||
|
#pragma mark -
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
nsresult nsInterfaceState::PrimeUpdateTimer()
|
||||||
|
{
|
||||||
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
if (mUpdateTimer)
|
||||||
|
{
|
||||||
|
// i'd love to be able to just call SetDelay on the existing timer, but
|
||||||
|
// i think i have to tear it down and make a new one.
|
||||||
|
mUpdateTimer->Cancel();
|
||||||
|
mUpdateTimer = NULL; // free it
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = NS_NewTimer(getter_AddRefs(mUpdateTimer));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
const PRUint32 kUpdateTimerDelay = 150;
|
||||||
|
return mUpdateTimer->Init(NS_STATIC_CAST(nsITimerCallback*, this), kUpdateTimerDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void nsInterfaceState::TimerCallback()
|
||||||
|
{
|
||||||
|
// if the selection state has changed, update stuff
|
||||||
|
PRBool isCollapsed = SelectionIsCollapsed();
|
||||||
|
if (isCollapsed != mSelectionCollapsed)
|
||||||
|
{
|
||||||
|
CallUpdateCommands(nsAutoString("select"));
|
||||||
|
mSelectionCollapsed = isCollapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)ForceUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
nsresult nsInterfaceState::CallUpdateCommands(const nsString& aCommand)
|
nsresult nsInterfaceState::CallUpdateCommands(const nsString& aCommand)
|
||||||
{
|
{
|
||||||
|
@ -252,13 +290,16 @@ nsInterfaceState::ForceUpdate()
|
||||||
|
|
||||||
// update bold
|
// update bold
|
||||||
rv = UpdateTextState("b", "Editor:Bold", "bold", mBoldState);
|
rv = UpdateTextState("b", "Editor:Bold", "bold", mBoldState);
|
||||||
|
|
||||||
// update italic
|
// update italic
|
||||||
rv = UpdateTextState("i", "Editor:Italic", "italic", mItalicState);
|
rv = UpdateTextState("i", "Editor:Italic", "italic", mItalicState);
|
||||||
|
|
||||||
// update underline
|
// update underline
|
||||||
rv = UpdateTextState("u", "Editor:Underline", "underline", mUnderlineState);
|
rv = UpdateTextState("u", "Editor:Underline", "underline", mUnderlineState);
|
||||||
|
|
||||||
// update the paragraph format popup
|
// update the paragraph format popup
|
||||||
rv = UpdateParagraphState("Editor:Paragraph:Format", "format", mParagraphFormat);
|
rv = UpdateParagraphState("Editor:Paragraph:Format", "format", mParagraphFormat);
|
||||||
|
|
||||||
// udpate the font face
|
// udpate the font face
|
||||||
rv = UpdateFontFace("Editor:Font:Face", "font", mFontString);
|
rv = UpdateFontFace("Editor:Font:Face", "font", mFontString);
|
||||||
|
|
||||||
|
@ -473,6 +514,24 @@ nsInterfaceState::UnsetNodeAttribute(const char* nodeID, const char* attributeNa
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XP_MAC
|
||||||
|
#pragma mark -
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
nsInterfaceState::Notify(nsITimer *timer)
|
||||||
|
{
|
||||||
|
NS_ASSERTION(timer == mUpdateTimer.get(), "Hey, this ain't my timer!");
|
||||||
|
mUpdateTimer = NULL; // release my hold
|
||||||
|
TimerCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef XP_MAC
|
||||||
|
#pragma mark -
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMXULDocument* aChromeDoc, nsIDOMSelectionListener** aInstancePtrResult)
|
nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMXULDocument* aChromeDoc, nsIDOMSelectionListener** aInstancePtrResult)
|
||||||
{
|
{
|
||||||
nsInterfaceState* newThang = new nsInterfaceState;
|
nsInterfaceState* newThang = new nsInterfaceState;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "nsIDocumentStateListener.h"
|
#include "nsIDocumentStateListener.h"
|
||||||
#include "nsITransactionListener.h"
|
#include "nsITransactionListener.h"
|
||||||
#include "nsIWebShell.h"
|
#include "nsIWebShell.h"
|
||||||
|
#include "nsITimerCallback.h"
|
||||||
|
|
||||||
class nsIHTMLEditor;
|
class nsIHTMLEditor;
|
||||||
class nsIDOMXULDocument;
|
class nsIDOMXULDocument;
|
||||||
|
@ -38,7 +39,8 @@ class nsIDOMXULDocument;
|
||||||
|
|
||||||
class nsInterfaceState : public nsIDOMSelectionListener,
|
class nsInterfaceState : public nsIDOMSelectionListener,
|
||||||
public nsIDocumentStateListener,
|
public nsIDocumentStateListener,
|
||||||
public nsITransactionListener
|
public nsITransactionListener,
|
||||||
|
public nsITimerCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -59,6 +61,8 @@ public:
|
||||||
|
|
||||||
NS_DECL_NSIDOCUMENTSTATELISTENER
|
NS_DECL_NSIDOCUMENTSTATELISTENER
|
||||||
|
|
||||||
|
// nsITimerCallback interfaces
|
||||||
|
NS_IMETHOD_(void) Notify(nsITimer *timer);
|
||||||
|
|
||||||
/** nsITransactionListener interfaces
|
/** nsITransactionListener interfaces
|
||||||
*/
|
*/
|
||||||
|
@ -100,6 +104,9 @@ protected:
|
||||||
|
|
||||||
nsresult CallUpdateCommands(const nsString& aCommand);
|
nsresult CallUpdateCommands(const nsString& aCommand);
|
||||||
|
|
||||||
|
nsresult PrimeUpdateTimer();
|
||||||
|
void TimerCallback();
|
||||||
|
|
||||||
// this class should not hold references to the editor or editorShell. Doing
|
// this class should not hold references to the editor or editorShell. Doing
|
||||||
// so would result in cirular reference chains.
|
// so would result in cirular reference chains.
|
||||||
|
|
||||||
|
@ -108,6 +115,8 @@ protected:
|
||||||
|
|
||||||
nsIDOMWindow* mDOMWindow; // nsIDOMWindow used for calling UpdateCommands
|
nsIDOMWindow* mDOMWindow; // nsIDOMWindow used for calling UpdateCommands
|
||||||
|
|
||||||
|
nsCOMPtr<nsITimer> mUpdateTimer;
|
||||||
|
|
||||||
// current state
|
// current state
|
||||||
PRInt8 mBoldState;
|
PRInt8 mBoldState;
|
||||||
PRInt8 mItalicState;
|
PRInt8 mItalicState;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче