diff --git third_party/blink/public/web/web_element.h third_party/blink/public/web/web_element.h index 75e28e8088848..9abea1a35f11b 100644 --- third_party/blink/public/web/web_element.h +++ third_party/blink/public/web/web_element.h @@ -83,6 +83,9 @@ class BLINK_EXPORT WebElement : public WebNode { WebString TextContent() const; WebString TextContentAbridged(unsigned int max_length) const; WebString InnerHTML() const; + WebString AttributeLocalName(unsigned index) const; + WebString AttributeValue(unsigned index) const; + unsigned AttributeCount() const; void Focus(); diff --git third_party/blink/renderer/core/exported/web_element.cc third_party/blink/renderer/core/exported/web_element.cc index 6859e192048d3..2b14176b6aa0d 100644 --- third_party/blink/renderer/core/exported/web_element.cc +++ third_party/blink/renderer/core/exported/web_element.cc @@ -124,6 +124,24 @@ void WebElement::SetAttribute(const WebString& attr_name, IGNORE_EXCEPTION_FOR_TESTING); } +unsigned WebElement::AttributeCount() const { + if (!ConstUnwrap()->hasAttributes()) + return 0; + return ConstUnwrap()->Attributes().size(); +} + +WebString WebElement::AttributeLocalName(unsigned index) const { + if (index >= AttributeCount()) + return WebString(); + return ConstUnwrap()->Attributes().at(index).LocalName(); +} + +WebString WebElement::AttributeValue(unsigned index) const { + if (index >= AttributeCount()) + return WebString(); + return ConstUnwrap()->Attributes().at(index).Value(); +} + WebString WebElement::TextContent() const { return ConstUnwrap()->textContent(); }