summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLOptionElement.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Source/WebCore/html/HTMLOptionElement.cpp
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
downloadqtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebCore/html/HTMLOptionElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLOptionElement.cpp56
1 files changed, 17 insertions, 39 deletions
diff --git a/Source/WebCore/html/HTMLOptionElement.cpp b/Source/WebCore/html/HTMLOptionElement.cpp
index c1e7a3712..bfa9a9f00 100644
--- a/Source/WebCore/html/HTMLOptionElement.cpp
+++ b/Source/WebCore/html/HTMLOptionElement.cpp
@@ -32,16 +32,17 @@
#include "ExceptionCode.h"
#include "HTMLDataListElement.h"
#include "HTMLNames.h"
+#include "HTMLOptGroupElement.h"
#include "HTMLParserIdioms.h"
#include "HTMLSelectElement.h"
#include "NodeRenderStyle.h"
#include "NodeRenderingContext.h"
+#include "NodeTraversal.h"
#include "RenderMenuList.h"
#include "RenderTheme.h"
#include "ScriptElement.h"
#include "StyleResolver.h"
#include "Text.h"
-#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
#include <wtf/text/StringBuilder.h>
@@ -55,7 +56,7 @@ HTMLOptionElement::HTMLOptionElement(const QualifiedName& tagName, Document* doc
, m_isSelected(false)
{
ASSERT(hasTagName(optionTag));
- setHasCustomCallbacks();
+ setHasCustomStyleCallbacks();
}
PassRefPtr<HTMLOptionElement> HTMLOptionElement::create(Document* document)
@@ -89,9 +90,9 @@ PassRefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document
return element.release();
}
-void HTMLOptionElement::attach()
+void HTMLOptionElement::attach(const AttachContext& context)
{
- HTMLElement::attach();
+ HTMLElement::attach(context);
// If after attaching nothing called styleForRenderer() on this node we
// manually cache the value. This happens if our parent doesn't have a
// renderer like <optgroup> or if it doesn't allow children like <select>.
@@ -99,15 +100,10 @@ void HTMLOptionElement::attach()
updateNonRenderStyle();
}
-void HTMLOptionElement::detach()
+void HTMLOptionElement::detach(const AttachContext& context)
{
m_style.clear();
- HTMLElement::detach();
-}
-
-bool HTMLOptionElement::supportsFocus() const
-{
- return HTMLElement::supportsFocus();
+ HTMLElement::detach(context);
}
bool HTMLOptionElement::isFocusable() const
@@ -180,7 +176,7 @@ int HTMLOptionElement::index() const
const Vector<HTMLElement*>& items = selectElement->listItems();
size_t length = items.size();
for (size_t i = 0; i < length; ++i) {
- if (!items[i]->hasTagName(optionTag))
+ if (!isHTMLOptionElement(items[i]))
continue;
if (items[i] == this)
return optionIndex;
@@ -202,8 +198,7 @@ void HTMLOptionElement::parseAttribute(const QualifiedName& name, const AtomicSt
bool oldDisabled = m_disabled;
m_disabled = !value.isNull();
if (oldDisabled != m_disabled) {
- setNeedsStyleRecalc();
- invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureDisabled | SelectRuleFeatureSet::RuleFeatureEnabled);
+ didAffectSelector(AffectedSelectorDisabled | AffectedSelectorEnabled);
if (renderer() && renderer()->style()->hasAppearance())
renderer()->theme()->stateChanged(renderer(), EnabledState);
}
@@ -256,8 +251,7 @@ void HTMLOptionElement::setSelectedState(bool selected)
return;
m_isSelected = selected;
- setNeedsStyleRecalc();
- invalidateParentDistributionIfNecessary(this, SelectRuleFeatureSet::RuleFeatureChecked);
+ didAffectSelector(AffectedSelectorChecked);
if (HTMLSelectElement* select = ownerSelectElement())
select->invalidateSelectedItems();
@@ -313,7 +307,7 @@ void HTMLOptionElement::setLabel(const String& label)
void HTMLOptionElement::updateNonRenderStyle()
{
- m_style = document()->styleResolver()->styleForElement(this);
+ m_style = document()->ensureStyleResolver()->styleForElement(this);
}
RenderStyle* HTMLOptionElement::nonRendererStyle() const
@@ -342,12 +336,12 @@ void HTMLOptionElement::didRecalcStyle(StyleChange)
String HTMLOptionElement::textIndentedToRespectGroupLabel() const
{
ContainerNode* parent = parentNode();
- if (parent && parent->hasTagName(optgroupTag))
+ if (parent && isHTMLOptGroupElement(parent))
return " " + text();
return text();
}
-bool HTMLOptionElement::disabled() const
+bool HTMLOptionElement::isDisabledFormControl() const
{
if (ownElementDisabled())
return true;
@@ -356,7 +350,7 @@ bool HTMLOptionElement::disabled() const
return false;
HTMLElement* parentElement = static_cast<HTMLElement*>(parentNode());
- return parentElement->hasTagName(optgroupTag) && parentElement->disabled();
+ return isHTMLOptGroupElement(parentElement) && parentElement->isDisabledFormControl();
}
Node::InsertionNotificationRequest HTMLOptionElement::insertedInto(ContainerNode* insertionPoint)
@@ -382,28 +376,12 @@ String HTMLOptionElement::collectOptionInnerText() const
if (node->isTextNode())
text.append(node->nodeValue());
// Text nodes inside script elements are not part of the option text.
- if (node->isElementNode() && toScriptElement(toElement(node)))
- node = node->traverseNextSibling(this);
+ if (node->isElementNode() && toScriptElementIfPossible(toElement(node)))
+ node = NodeTraversal::nextSkippingChildren(node, this);
else
- node = node->traverseNextNode(this);
+ node = NodeTraversal::next(node, this);
}
return text.toString();
}
-#ifndef NDEBUG
-
-HTMLOptionElement* toHTMLOptionElement(Node* node)
-{
- ASSERT(!node || node->hasTagName(optionTag));
- return static_cast<HTMLOptionElement*>(node);
-}
-
-const HTMLOptionElement* toHTMLOptionElement(const Node* node)
-{
- ASSERT(!node || node->hasTagName(optionTag));
- return static_cast<const HTMLOptionElement*>(node);
-}
-
-#endif
-
} // namespace