diff --git a/webshell/tests/viewer/resources.h b/webshell/tests/viewer/resources.h index 759e8d8987bd..f572c1cb6e08 100644 --- a/webshell/tests/viewer/resources.h +++ b/webshell/tests/viewer/resources.h @@ -50,4 +50,10 @@ #define JS_CONSOLE 40100 +#define VIEWER_EDIT_CUT 40201 +#define VIEWER_EDIT_COPY 40202 +#define VIEWER_EDIT_PASTE 40203 +#define VIEWER_EDIT_SELECTALL 40204 +#define VIEWER_EDIT_FINDINPAGE 40205 + #endif /* resources_h___ */ diff --git a/webshell/tests/viewer/viewer.rc b/webshell/tests/viewer/viewer.rc index 45a80afe85cc..fd6b80255469 100644 --- a/webshell/tests/viewer/viewer.rc +++ b/webshell/tests/viewer/viewer.rc @@ -45,6 +45,17 @@ VIEWER MENU DISCARDABLE } MENUITEM "&Exit", VIEWER_EXIT } + POPUP "&Edit" + BEGIN + MENUITEM "Cu&t", VIEWER_EDIT_CUT, GRAYED + MENUITEM "&Copy", VIEWER_EDIT_COPY + MENUITEM "&Paste", VIEWER_EDIT_PASTE, GRAYED + MENUITEM SEPARATOR + MENUITEM "Select &All", VIEWER_EDIT_SELECTALL, HELP + MENUITEM SEPARATOR + MENUITEM "&Find in Page", VIEWER_EDIT_FINDINPAGE + , GRAYED + END POPUP "&Debug" { MENUITEM "&Visual Debugging", VIEWER_VISUAL_DEBUGGING @@ -78,7 +89,7 @@ PRINTPREVIEW MENU DISCARDABLE } } -JSCONSOLE_MENU MENU DISCARDABLE +JSCONSOLE_MENU MENU DISCARDABLE BEGIN POPUP "&File" BEGIN @@ -103,9 +114,9 @@ BEGIN POPUP "&Commands" BEGIN MENUITEM "&Evaluate All\tF5", ID_COMMANDSEVALALL - MENUITEM "Evaluate &Selection\tF10", ID_COMMANDSEVALSEL + MENUITEM "Evaluate &Selection\tF10", ID_COMMANDSEVALSEL MENUITEM SEPARATOR - MENUITEM "&Inspector", ID_COMMANDSINSPECTOR + MENUITEM "&Inspector", ID_COMMANDSINSPECTOR END POPUP "&Help" BEGIN @@ -115,6 +126,6 @@ END ACCELERATOR_TABLE ACCELERATORS BEGIN - VK_F5, ID_COMMANDSEVALALL, VIRTKEY - VK_F10, ID_COMMANDSEVALSEL, VIRTKEY + VK_F5, ID_COMMANDSEVALALL, VIRTKEY + VK_F10, ID_COMMANDSEVALSEL, VIRTKEY END diff --git a/webshell/tests/viewer/winmain.cpp b/webshell/tests/viewer/winmain.cpp index ca6e9cba6083..f12647fae908 100644 --- a/webshell/tests/viewer/winmain.cpp +++ b/webshell/tests/viewer/winmain.cpp @@ -49,6 +49,11 @@ #include "nsIScriptContext.h" #include "nsDocLoader.h" +// Selection Repaint includes +#include "nsIPresShell.h" +#include "nsIFrame.h" +#include "nsIViewManager.h" + // JSConsole window JSConsole *gConsole = NULL; @@ -138,7 +143,7 @@ NS_IMETHODIMP DocObserver::SetTitle(const nsString& aTitle) ::SetWindowText(wd->window, cp); delete cp; } - } + } return NS_OK; } @@ -292,6 +297,80 @@ OpenHTMLFile(WindowData* wd) } } +// Selects all the Content +static void +SelectAll(WindowData* wd) +{ + if (wd->ww != nsnull) { + nsIDocument* doc = wd->ww->GetDocument(); + if (doc != nsnull) { + doc->SelectAll(); + wd->ww->ShowFrameBorders(PR_FALSE); + /*PRInt32 numShells = doc->GetNumberOfShells(); + for (PRInt32 i=0;iGetShellAt(i); + //nsIViewManager * viewMgr = shell->GetViewManager(); + nsIFrame * frame = shell->GetRootFrame(); + nsRect rect; + nsIView * view; + nsPoint pnt; + frame->GetOffsetFromView(pnt, view); + frame->GetRect(rect); + rect.x = pnt.x; + rect.y = pnt.y; + if (view != nsnull) { + nsIViewManager * viewMgr = view->GetViewManager(); + if (viewMgr != nsnull) { + viewMgr->UpdateView(view, rect, 0); + } + } + NS_IF_RELEASE(shell); + //NS_IF_RELEASE(frame); + }*/ + + NS_IF_RELEASE(doc); + } + } +} + +// Selects all the Content +static void +CopyTextContent(WindowData* wd, HWND aHWnd) +{ + HGLOBAL hGlobalMemory; + PSTR pGlobalMemory; + + if (wd->ww != nsnull) { + nsIDocument* doc = wd->ww->GetDocument(); + if (doc != nsnull) { + // Get Text from Selection + nsString text; + doc->GetSelectionText(text); + + // Copy text to Global Memory Area + hGlobalMemory = (HGLOBAL)GlobalAlloc(GHND, text.Length()+1); + if (hGlobalMemory != NULL) { + pGlobalMemory = (PSTR) GlobalLock(hGlobalMemory); + char * str = text.ToNewCString(); + char * s = str; + for (int i=0;i