| 570 | } |
| 571 | |
| 572 | int Element::GetAttributeValue(const std::string& attribute_name, |
| 573 | VARIANT* attribute_value) { |
| 574 | LOG(TRACE) << "Entering Element::GetAttributeValue"; |
| 575 | |
| 576 | std::wstring wide_attribute_name = StringUtilities::ToWString(attribute_name); |
| 577 | int status_code = WD_SUCCESS; |
| 578 | |
| 579 | // The atom is just the definition of an anonymous |
| 580 | // function: "function() {...}"; Wrap it in another function so we can |
| 581 | // invoke it with our arguments without polluting the current namespace. |
| 582 | std::wstring script_source(L"(function() { return ("); |
| 583 | script_source += atoms::asString(atoms::GET_ATTRIBUTE); |
| 584 | script_source += L")})();"; |
| 585 | |
| 586 | CComPtr<IHTMLDocument2> doc; |
| 587 | this->GetContainingDocument(false, &doc); |
| 588 | Script script_wrapper(doc, script_source, 2); |
| 589 | script_wrapper.AddArgument(this->element_); |
| 590 | script_wrapper.AddArgument(wide_attribute_name); |
| 591 | status_code = script_wrapper.Execute(); |
| 592 | |
| 593 | if (status_code == WD_SUCCESS) { |
| 594 | ::VariantCopy(attribute_value, &script_wrapper.result()); |
| 595 | } else { |
| 596 | LOG(WARN) << "Failed to determine element attribute"; |
| 597 | } |
| 598 | |
| 599 | return WD_SUCCESS; |
| 600 | } |
| 601 | |
| 602 | int Element::GetPropertyValue(const std::string& property_name, |
| 603 | VARIANT* property_value) { |
no test coverage detected