This source file includes following definitions.
- create
- isDisabledFormControl
- rendererIsFocusable
- childrenChanged
- parseAttribute
- recalcSelectOptions
- attach
- detach
- updateNonRenderStyle
- nonRendererStyle
- customStyleForRenderer
- groupLabelText
- ownerSelectElement
- accessKeyAction
#include "config.h"
#include "core/html/HTMLOptGroupElement.h"
#include "HTMLNames.h"
#include "core/dom/Document.h"
#include "core/dom/NodeRenderStyle.h"
#include "core/html/HTMLSelectElement.h"
#include "wtf/StdLibExtras.h"
namespace WebCore {
using namespace HTMLNames;
inline HTMLOptGroupElement::HTMLOptGroupElement(Document& document)
: HTMLElement(optgroupTag, document)
{
setHasCustomStyleCallbacks();
ScriptWrappable::init(this);
}
PassRefPtr<HTMLOptGroupElement> HTMLOptGroupElement::create(Document& document)
{
return adoptRef(new HTMLOptGroupElement(document));
}
bool HTMLOptGroupElement::isDisabledFormControl() const
{
return fastHasAttribute(disabledAttr);
}
bool HTMLOptGroupElement::rendererIsFocusable() const
{
return renderStyle() && renderStyle()->display() != NONE;
}
void HTMLOptGroupElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
recalcSelectOptions();
HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
}
void HTMLOptGroupElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
HTMLElement::parseAttribute(name, value);
recalcSelectOptions();
if (name == disabledAttr)
didAffectSelector(AffectedSelectorDisabled | AffectedSelectorEnabled);
}
void HTMLOptGroupElement::recalcSelectOptions()
{
if (HTMLSelectElement* select = Traversal<HTMLSelectElement>::firstAncestor(*this))
select->setRecalcListItems();
}
void HTMLOptGroupElement::attach(const AttachContext& context)
{
if (context.resolvedStyle) {
ASSERT(!m_style || m_style == context.resolvedStyle);
m_style = context.resolvedStyle;
}
HTMLElement::attach(context);
}
void HTMLOptGroupElement::detach(const AttachContext& context)
{
m_style.clear();
HTMLElement::detach(context);
}
void HTMLOptGroupElement::updateNonRenderStyle()
{
m_style = originalStyleForRenderer();
}
RenderStyle* HTMLOptGroupElement::nonRendererStyle() const
{
return m_style.get();
}
PassRefPtr<RenderStyle> HTMLOptGroupElement::customStyleForRenderer()
{
updateNonRenderStyle();
return m_style;
}
String HTMLOptGroupElement::groupLabelText() const
{
String itemText = getAttribute(labelAttr);
itemText = itemText.stripWhiteSpace();
itemText = itemText.simplifyWhiteSpace();
return itemText;
}
HTMLSelectElement* HTMLOptGroupElement::ownerSelectElement() const
{
return Traversal<HTMLSelectElement>::firstAncestor(*this);
}
void HTMLOptGroupElement::accessKeyAction(bool)
{
HTMLSelectElement* select = ownerSelectElement();
if (select && !select->focused())
select->accessKeyAction(false);
}
}