private void visit(cef_domvisitor_t *self, cef_domdocument_t *document) { CheckSelf(self); var m_document = CefDomDocument.FromNative(document); Visit(m_document); m_document.Dispose(); }
/// <summary> /// Method executed for visiting the DOM. The document object passed to this /// method represents a snapshot of the DOM at the time this method is /// executed. DOM objects are only valid for the scope of this method. Do not /// keep references to or attempt to access any DOM objects outside the scope /// of this method. /// </summary> protected abstract void Visit(CefDomDocument document);
protected override void Visit(CefDomDocument document) { CefDomNode element; switch (_businID) { case CwbBusinStyle.bsGetElementValue: Global.Result = ""; element = document.GetElementById(_elementID); if (element == null) { Global.flag = true; return; } Global.Result = element.Value; if (element.ElementTagName.ToLower() != "input") Global.Result = element.InnerText; Global.flag = true; break; case CwbBusinStyle.bsSetElementValue: element = document.GetElementById(_elementID); if (element == null) return; if (element.IsEditable) element.SetAttribute("value", _elementValue); else { string code = "document.getElementById('{0}').innerHTML = '{1}';"; code = string.Format(code,_elementID,_elementValue); Global.instance.ExecuteScript(code); } break; case CwbBusinStyle.bsAddElementEvent: element = document.GetElementById(_item.id); if (element == null) return; element.AddEventListener(_item.eventName,new RSEventListener(_item.elementListener),true); break; case CwbBusinStyle.bsVisitDocument: Global.flag = false; CefDomNode root = document.Root; CwbElement Root = CreateElement(root); if (Global.RootList.ContainsKey(browser.Identifier)) { Global.RootList[ browser.Identifier ] = Root; } else { Global.RootList.Add(browser.Identifier, Root); } string indexPath = "0"; Root.IndexPath = indexPath; AppendAllChildElement(root, Root, indexPath); Global.flag = true; break; case CwbBusinStyle.bsAttachElementEvent: CefDomNode root1 = document.Root; string indexPath1 = "0"; AttachEventHandler(root1, indexPath1, new RSEventListener(_item.elementListener)); Global.flag = true; break; } _businID = CwbBusinStyle.bsNone; }