diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index dbcf17cc9c9..8a8995da657 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -22,6 +22,7 @@ #include "nsITimer.h" #include "nsITimerCallback.h" +#include "nsIComponentManager.h" #include "nsIFrameSelection.h" #include "nsIFrame.h" #include "nsIDOMNode.h" @@ -35,21 +36,23 @@ #include "nsIView.h" #include "nsIViewManager.h" #include "nsIPresContext.h" - -#include "nsCaretProperties.h" +#include "nsILookAndFeel.h" +#include "nsWidgetsCID.h" // for NS_LOOKANDFEEL_CID #include "nsCaret.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID); static NS_DEFINE_IID(kICaretID, NS_ICARET_IID); +static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); + //----------------------------------------------------------------------------- nsCaret::nsCaret() : mPresShell(nsnull) , mBlinkTimer(nsnull) , mBlinkRate(500) +, mCaretWidth(20) , mVisible(PR_FALSE) , mReadOnly(PR_TRUE) , mDrawn(PR_FALSE) @@ -68,19 +71,26 @@ nsCaret::~nsCaret() } //----------------------------------------------------------------------------- -NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell, nsCaretProperties *inCaretProperties) +NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell) { if (!inPresShell) return NS_ERROR_NULL_POINTER; - - if (!inCaretProperties) - return NS_ERROR_NULL_POINTER; mPresShell = inPresShell; // the presshell owns us, so no addref - mBlinkRate = inCaretProperties->GetCaretBlinkRate(); - mCaretWidth = inCaretProperties->GetCaretWidth(); - + nsILookAndFeel* touchyFeely; + if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, nsILookAndFeel::GetIID(), (void**)&touchyFeely))) + { + PRInt32 tempInt; + + if (NS_SUCCEEDED(touchyFeely->GetMetric(nsILookAndFeel::eMetric_CaretWidthTwips, tempInt))) + mCaretWidth = (nscoord)tempInt; + if (NS_SUCCEEDED(touchyFeely->GetMetric(nsILookAndFeel::eMetric_CaretBlinkTime, tempInt))) + mBlinkRate = (PRUint32)tempInt; + + NS_RELEASE(touchyFeely); + } + // get the selection from the pres shell, and set ourselves up as a selection // listener diff --git a/layout/base/nsCaret.h b/layout/base/nsCaret.h index 3f673eacc69..2a03689da9b 100644 --- a/layout/base/nsCaret.h +++ b/layout/base/nsCaret.h @@ -23,7 +23,6 @@ #include "nsICaret.h" class nsITimer; -class nsCaretProperties; class nsIView; class nsIRenderingContext; @@ -46,7 +45,7 @@ class nsCaret : public nsICaret, public: // nsICaret interface - NS_IMETHOD Init(nsIPresShell *inPresShell, nsCaretProperties *inCaretProperties); + NS_IMETHOD Init(nsIPresShell *inPresShell); NS_IMETHOD SetCaretVisible(PRBool inMakeVisible); NS_IMETHOD SetCaretReadOnly(PRBool inMakeReadonly); diff --git a/layout/base/nsICaret.h b/layout/base/nsICaret.h index 956ea0a4b16..e3d2277fa20 100644 --- a/layout/base/nsICaret.h +++ b/layout/base/nsICaret.h @@ -22,14 +22,12 @@ #define NS_ICARET_IID \ { 0xa6cf90e1, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } -class nsCaretProperties; - class nsICaret: public nsISupports { public: static const nsIID& GetIID() { static nsIID iid = NS_ICARET_IID; return iid; } - NS_IMETHOD Init(nsIPresShell *inPresShell, nsCaretProperties *inCaretProperties) = 0; + NS_IMETHOD Init(nsIPresShell *inPresShell) = 0; /** SetCaretVisible will set the visibility of the caret * @param inMakeVisible PR_TRUE to show the caret, PR_FALSE to hide it diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index bc5361103b7..0340fde6178 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -51,7 +51,6 @@ #include "nsIEventQueueService.h" #include "nsIServiceManager.h" #include "nsICaret.h" -#include "nsCaretProperties.h" #include "nsIDOMHTMLDocument.h" #include "nsIXMLDocument.h" #include "nsIScrollableView.h" @@ -650,19 +649,13 @@ PresShell::Init(nsIDocument* aDocument, return result; // Important: this has to happen after the selection has been set up #ifdef SHOW_CARET - nsCaretProperties *caretProperties = NewCaretProperties(); - // make the caret nsresult err = NS_NewCaret(getter_AddRefs(mCaret)); if (NS_SUCCEEDED(err)) { - mCaret->Init(this, caretProperties); + mCaret->Init(this); } - delete caretProperties; - caretProperties = nsnull; - // do this when we have a way of figuring out how to tell chrome - // from content //SetCaretEnabled(PR_TRUE); // make it show in browser windows #endif //set up selection to be displayed in document diff --git a/layout/base/public/Makefile.in b/layout/base/public/Makefile.in index 51345308b7d..356aebba014 100644 --- a/layout/base/public/Makefile.in +++ b/layout/base/public/Makefile.in @@ -27,7 +27,6 @@ MODULE=layout EXPORTS = \ nslayout.h \ nsICaret.h \ - nsCaretProperties.h \ nsIContent.h \ nsIContentIterator.h \ nsIDiskDocument.h \ diff --git a/layout/base/public/makefile.win b/layout/base/public/makefile.win index 935ce9f4dbf..f6a3c0af1ea 100644 --- a/layout/base/public/makefile.win +++ b/layout/base/public/makefile.win @@ -20,7 +20,6 @@ DEPTH=..\..\.. EXPORTS = \ nslayout.h \ nsICaret.h \ - nsCaretProperties.h \ nsIContent.h \ nsIContentIterator.h \ nsIDiskDocument.h \ diff --git a/layout/base/public/nsICaret.h b/layout/base/public/nsICaret.h index 956ea0a4b16..e3d2277fa20 100644 --- a/layout/base/public/nsICaret.h +++ b/layout/base/public/nsICaret.h @@ -22,14 +22,12 @@ #define NS_ICARET_IID \ { 0xa6cf90e1, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } -class nsCaretProperties; - class nsICaret: public nsISupports { public: static const nsIID& GetIID() { static nsIID iid = NS_ICARET_IID; return iid; } - NS_IMETHOD Init(nsIPresShell *inPresShell, nsCaretProperties *inCaretProperties) = 0; + NS_IMETHOD Init(nsIPresShell *inPresShell) = 0; /** SetCaretVisible will set the visibility of the caret * @param inMakeVisible PR_TRUE to show the caret, PR_FALSE to hide it diff --git a/layout/base/src/Makefile.in b/layout/base/src/Makefile.in index e9cc06a1ace..71a494f15ec 100644 --- a/layout/base/src/Makefile.in +++ b/layout/base/src/Makefile.in @@ -29,7 +29,6 @@ MODULE=layout # Alphabetical list of source files CPPSRCS = \ nsCaret.cpp \ - nsCaretProperties_$(MOZ_WIDGET_TOOLKIT).cpp \ nsCommentNode.cpp \ nsContentIterator.cpp \ nsContentList.cpp \ diff --git a/layout/base/src/makefile.win b/layout/base/src/makefile.win index 5bc7e07fb93..d1bcd3f4d56 100644 --- a/layout/base/src/makefile.win +++ b/layout/base/src/makefile.win @@ -57,7 +57,6 @@ CPPSRCS = \ nsLayoutAtoms.cpp \ nsLayoutDebugger.cpp \ nsCaret.cpp \ - nsCaretProperties_windows.cpp \ nsRange.cpp \ nsTextNode.cpp \ $(NULL) @@ -100,7 +99,6 @@ CPP_OBJS= \ .\$(OBJDIR)\nsLayoutAtoms.obj \ .\$(OBJDIR)\nsLayoutDebugger.obj \ .\$(OBJDIR)\nsCaret.obj \ - .\$(OBJDIR)\nsCaretProperties_windows.obj \ .\$(OBJDIR)\nsRange.obj \ .\$(OBJDIR)\nsTextNode.obj \ $(NULL) diff --git a/layout/base/src/nsCaret.cpp b/layout/base/src/nsCaret.cpp index dbcf17cc9c9..8a8995da657 100644 --- a/layout/base/src/nsCaret.cpp +++ b/layout/base/src/nsCaret.cpp @@ -22,6 +22,7 @@ #include "nsITimer.h" #include "nsITimerCallback.h" +#include "nsIComponentManager.h" #include "nsIFrameSelection.h" #include "nsIFrame.h" #include "nsIDOMNode.h" @@ -35,21 +36,23 @@ #include "nsIView.h" #include "nsIViewManager.h" #include "nsIPresContext.h" - -#include "nsCaretProperties.h" +#include "nsILookAndFeel.h" +#include "nsWidgetsCID.h" // for NS_LOOKANDFEEL_CID #include "nsCaret.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID); static NS_DEFINE_IID(kICaretID, NS_ICARET_IID); +static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); + //----------------------------------------------------------------------------- nsCaret::nsCaret() : mPresShell(nsnull) , mBlinkTimer(nsnull) , mBlinkRate(500) +, mCaretWidth(20) , mVisible(PR_FALSE) , mReadOnly(PR_TRUE) , mDrawn(PR_FALSE) @@ -68,19 +71,26 @@ nsCaret::~nsCaret() } //----------------------------------------------------------------------------- -NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell, nsCaretProperties *inCaretProperties) +NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell) { if (!inPresShell) return NS_ERROR_NULL_POINTER; - - if (!inCaretProperties) - return NS_ERROR_NULL_POINTER; mPresShell = inPresShell; // the presshell owns us, so no addref - mBlinkRate = inCaretProperties->GetCaretBlinkRate(); - mCaretWidth = inCaretProperties->GetCaretWidth(); - + nsILookAndFeel* touchyFeely; + if (NS_SUCCEEDED(nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, nsILookAndFeel::GetIID(), (void**)&touchyFeely))) + { + PRInt32 tempInt; + + if (NS_SUCCEEDED(touchyFeely->GetMetric(nsILookAndFeel::eMetric_CaretWidthTwips, tempInt))) + mCaretWidth = (nscoord)tempInt; + if (NS_SUCCEEDED(touchyFeely->GetMetric(nsILookAndFeel::eMetric_CaretBlinkTime, tempInt))) + mBlinkRate = (PRUint32)tempInt; + + NS_RELEASE(touchyFeely); + } + // get the selection from the pres shell, and set ourselves up as a selection // listener diff --git a/layout/base/src/nsCaret.h b/layout/base/src/nsCaret.h index 3f673eacc69..2a03689da9b 100644 --- a/layout/base/src/nsCaret.h +++ b/layout/base/src/nsCaret.h @@ -23,7 +23,6 @@ #include "nsICaret.h" class nsITimer; -class nsCaretProperties; class nsIView; class nsIRenderingContext; @@ -46,7 +45,7 @@ class nsCaret : public nsICaret, public: // nsICaret interface - NS_IMETHOD Init(nsIPresShell *inPresShell, nsCaretProperties *inCaretProperties); + NS_IMETHOD Init(nsIPresShell *inPresShell); NS_IMETHOD SetCaretVisible(PRBool inMakeVisible); NS_IMETHOD SetCaretReadOnly(PRBool inMakeReadonly); diff --git a/layout/build/dlldeps.cpp b/layout/build/dlldeps.cpp index a333e8eb2af..f11c14f05f0 100644 --- a/layout/build/dlldeps.cpp +++ b/layout/build/dlldeps.cpp @@ -25,7 +25,6 @@ #include "nsIDocument.h" #include "nsHTMLParts.h" #include "nsINameSpaceManager.h" -#include "nsCaretProperties.h" void XXXNeverCalled() { @@ -53,5 +52,4 @@ void XXXNeverCalled() nsINameSpaceManager* nsm; NS_NewNameSpaceManager(&nsm); NS_CreateHTMLElement(nsnull, ""); - NewCaretProperties(); } diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index bc5361103b7..0340fde6178 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -51,7 +51,6 @@ #include "nsIEventQueueService.h" #include "nsIServiceManager.h" #include "nsICaret.h" -#include "nsCaretProperties.h" #include "nsIDOMHTMLDocument.h" #include "nsIXMLDocument.h" #include "nsIScrollableView.h" @@ -650,19 +649,13 @@ PresShell::Init(nsIDocument* aDocument, return result; // Important: this has to happen after the selection has been set up #ifdef SHOW_CARET - nsCaretProperties *caretProperties = NewCaretProperties(); - // make the caret nsresult err = NS_NewCaret(getter_AddRefs(mCaret)); if (NS_SUCCEEDED(err)) { - mCaret->Init(this, caretProperties); + mCaret->Init(this); } - delete caretProperties; - caretProperties = nsnull; - // do this when we have a way of figuring out how to tell chrome - // from content //SetCaretEnabled(PR_TRUE); // make it show in browser windows #endif //set up selection to be displayed in document diff --git a/layout/macbuild/layout.mcp b/layout/macbuild/layout.mcp index fdda460ccad..01506c8ca5f 100644 Binary files a/layout/macbuild/layout.mcp and b/layout/macbuild/layout.mcp differ diff --git a/webshell/embed/ActiveX/MozillaControl.dsp b/webshell/embed/ActiveX/MozillaControl.dsp index 52da2033ecd..6d0be8daa96 100644 --- a/webshell/embed/ActiveX/MozillaControl.dsp +++ b/webshell/embed/ActiveX/MozillaControl.dsp @@ -918,10 +918,6 @@ SOURCE=..\..\..\dist\include\nsCardDataSource.h # End Source File # Begin Source File -SOURCE=..\..\..\dist\include\nsCaretProperties.h -# End Source File -# Begin Source File - SOURCE=..\..\..\dist\include\nsCCapsManager.h # End Source File # Begin Source File