nsresult nsSHistory::CompareFrames(nsISHEntry * aPrevEntry, nsISHEntry * aNextEntry, nsIDocShell * aParent, long aLoadType, PRBool * aIsFrameFound) { if (!aPrevEntry || !aNextEntry || !aParent) return PR_FALSE; nsresult result = NS_OK; PRUint32 prevID, nextID; aPrevEntry->GetID(&prevID); aNextEntry->GetID(&nextID); // Check the IDs to verify if the pages are different. if (prevID != nextID) { if (aIsFrameFound) *aIsFrameFound = PR_TRUE; // Set the Subframe flag of the entry to indicate that // it is subframe navigation aNextEntry->SetIsSubFrame(PR_TRUE); InitiateLoad(aNextEntry, aParent, aLoadType); return NS_OK; } /* The root entries are the same, so compare any child frames */ PRInt32 pcnt=0, ncnt=0, dsCount=0; nsCOMPtr<nsISHContainer> prevContainer(do_QueryInterface(aPrevEntry)); nsCOMPtr<nsISHContainer> nextContainer(do_QueryInterface(aNextEntry)); nsCOMPtr<nsIDocShellTreeNode> dsTreeNode(do_QueryInterface(aParent)); if (!dsTreeNode) return NS_ERROR_FAILURE; if (!prevContainer || !nextContainer) return NS_ERROR_FAILURE; prevContainer->GetChildCount(&pcnt); nextContainer->GetChildCount(&ncnt); dsTreeNode->GetChildCount(&dsCount); //XXX What to do if the children count don't match for (PRInt32 i=0; i<ncnt; i++){ nsCOMPtr<nsISHEntry> pChild, nChild; nsCOMPtr<nsIDocShellTreeItem> dsTreeItemChild; prevContainer->GetChildAt(i, getter_AddRefs(pChild)); nextContainer->GetChildAt(i, getter_AddRefs(nChild)); if (dsCount > 0) dsTreeNode->GetChildAt(i, getter_AddRefs(dsTreeItemChild)); if (!dsTreeItemChild) return NS_ERROR_FAILURE; nsCOMPtr<nsIDocShell> dsChild(do_QueryInterface(dsTreeItemChild)); CompareFrames(pChild, nChild, dsChild, aLoadType, aIsFrameFound); } return result; }
void handleKeyboard(int key) { char cKey = (char)key; // ESC if(cKey == 27) { b_running = false; return; } // toggle mode if(cKey == 'm') { mode = (mode + 1) % 2; std::stringstream ss; ss << "mode: " << (mode == MODE_SAMPLES ? "samples" : "glint"); animator.setText(ss.str()); return; } if(cKey == 'd') { // delete sample deleteSample(); bUpdateGraphics = true; } // see which mode if(mode == MODE_SAMPLES) { if(cKey == 'S') { // right arrow nextSample(); bUpdateGraphics = true; } else if(cKey == 'Q') { // left arrow prevSample(); bUpdateGraphics = true; } else if(cKey == 'R') { // up arrow nextContainer(); bUpdateGraphics = true; } else if(cKey == 'T') { // down arrow prevContainer(); bUpdateGraphics = true; } } else if(mode == MODE_GLINT) { calib::LEDCalibSample &sample = LEDContainers[indContainer].getSamples()[indSample]; if(cKey == 'S') { // right arrow int sugg = sample.glint.x + 1; if(sugg < 640) { sample.glint.x = sugg; } bUpdateGraphics = true; } else if(cKey == 'Q') { // left arrow int sugg = sample.glint.x - 1; if(sugg >= 0) { sample.glint.x = sugg; } bUpdateGraphics = true; } else if(cKey == 'R') { // up arrow int sugg = sample.glint.y - 1; if(sugg >= 0) { sample.glint.y = sugg; } bUpdateGraphics = true; } else if(cKey == 'T') { // down arrow int sugg = sample.glint.y + 1; if(sugg < 480) { sample.glint.y = sugg; } bUpdateGraphics = true; } } }