| 92 | } |
| 93 | |
| 94 | int Element::IsDisplayed(bool ignore_opacity, bool* result) { |
| 95 | LOG(TRACE) << "Entering Element::IsDisplayed"; |
| 96 | |
| 97 | int status_code = WD_SUCCESS; |
| 98 | |
| 99 | // The atom is just the definition of an anonymous |
| 100 | // function: "function() {...}"; Wrap it in another function so we can |
| 101 | // invoke it with our arguments without polluting the current namespace. |
| 102 | std::wstring script_source(L"(function() { return ("); |
| 103 | script_source += atoms::asString(atoms::IS_DISPLAYED); |
| 104 | script_source += L")})();"; |
| 105 | |
| 106 | CComPtr<IHTMLDocument2> doc; |
| 107 | this->GetContainingDocument(false, &doc); |
| 108 | // N.B., The second argument to the IsDisplayed atom is "ignoreOpacity". |
| 109 | Script script_wrapper(doc, script_source, 2); |
| 110 | script_wrapper.AddArgument(this->element_); |
| 111 | script_wrapper.AddArgument(ignore_opacity); |
| 112 | status_code = script_wrapper.Execute(); |
| 113 | |
| 114 | if (status_code == WD_SUCCESS) { |
| 115 | *result = script_wrapper.result().boolVal == VARIANT_TRUE; |
| 116 | } else { |
| 117 | LOG(WARN) << "Failed to determine is element displayed"; |
| 118 | } |
| 119 | |
| 120 | return status_code; |
| 121 | } |
| 122 | |
| 123 | std::string Element::GetTagName() { |
| 124 | LOG(TRACE) << "Entering Element::GetTagName"; |
no test coverage detected