| 168 | } |
| 169 | |
| 170 | bool Element::IsXmlDocument(IHTMLDocument2* doc) { |
| 171 | LOG(TRACE) << "Entering Element::IsXmlDocument"; |
| 172 | // If the document has an xmlVersion property, it can be either an XML |
| 173 | // document or an XHTML document. Otherwise, it's an HTML document. |
| 174 | CComPtr<IHTMLDocument7> xml_version_document; |
| 175 | HRESULT hr = doc->QueryInterface<IHTMLDocument7>(&xml_version_document); |
| 176 | if (SUCCEEDED(hr) && xml_version_document) { |
| 177 | CComBSTR xml_version = ""; |
| 178 | hr = xml_version_document->get_xmlVersion(&xml_version); |
| 179 | if (SUCCEEDED(hr) && xml_version && xml_version != L"") { |
| 180 | // The document is either XML or XHTML, so to differentiate between |
| 181 | // the two cases, check for a doctype of "html". If we can't find |
| 182 | // a doctype property, or the doctype is anything other than "html", |
| 183 | // the document is an XML document. |
| 184 | CComPtr<IHTMLDocument5> doc_type_document; |
| 185 | hr = doc->QueryInterface<IHTMLDocument5>(&doc_type_document); |
| 186 | if (SUCCEEDED(hr) && doc_type_document) { |
| 187 | CComPtr<IHTMLDOMNode> doc_type_dom_node; |
| 188 | hr = doc_type_document->get_doctype(&doc_type_dom_node); |
| 189 | if (SUCCEEDED(hr) && doc_type_dom_node) { |
| 190 | CComPtr<IDOMDocumentType> doc_type; |
| 191 | hr = doc_type_dom_node->QueryInterface<IDOMDocumentType>(&doc_type); |
| 192 | if (SUCCEEDED(hr) && doc_type) { |
| 193 | CComBSTR type_name_bstr = L""; |
| 194 | hr = doc_type->get_name(&type_name_bstr); |
| 195 | type_name_bstr.ToLower(); |
| 196 | std::wstring type_name(type_name_bstr); |
| 197 | LOG(INFO) << LOGWSTRING(type_name); |
| 198 | if (SUCCEEDED(hr) && type_name != L"html") { |
| 199 | return true; |
| 200 | } |
| 201 | } |
| 202 | } else { |
| 203 | return true; |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | return false; |
| 209 | } |
| 210 | |
| 211 | bool Element::IsInteractable() { |
| 212 | LOG(TRACE) << "Entering Element::IsInteractable"; |
no test coverage detected