summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLLegendElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/HTMLLegendElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLLegendElement.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/Source/WebCore/html/HTMLLegendElement.cpp b/Source/WebCore/html/HTMLLegendElement.cpp
index 5973bc207..090e0c72d 100644
--- a/Source/WebCore/html/HTMLLegendElement.cpp
+++ b/Source/WebCore/html/HTMLLegendElement.cpp
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
* (C) 2006 Alexey Proskuryakov (ap@nypop.com)
*
* This library is free software; you can redistribute it and/or
@@ -31,18 +31,15 @@
namespace WebCore {
-using namespace HTMLNames;
-
-
inline HTMLLegendElement::HTMLLegendElement(const QualifiedName& tagName, Document& document)
: HTMLElement(tagName, document)
{
- ASSERT(hasTagName(legendTag));
+ ASSERT(hasTagName(HTMLNames::legendTag));
}
-PassRefPtr<HTMLLegendElement> HTMLLegendElement::create(const QualifiedName& tagName, Document& document)
+Ref<HTMLLegendElement> HTMLLegendElement::create(const QualifiedName& tagName, Document& document)
{
- return adoptRef(new HTMLLegendElement(tagName, document));
+ return adoptRef(*new HTMLLegendElement(tagName, document));
}
HTMLFormControlElement* HTMLLegendElement::associatedControl()
@@ -57,32 +54,36 @@ HTMLFormControlElement* HTMLLegendElement::associatedControl()
return descendantsOfType<HTMLFormControlElement>(*enclosingFieldset).first();
}
-void HTMLLegendElement::focus(bool, FocusDirection direction)
+void HTMLLegendElement::focus(bool restorePreviousSelection, FocusDirection direction)
{
- if (isFocusable())
- Element::focus(true, direction);
-
+ if (document().haveStylesheetsLoaded()) {
+ document().updateLayoutIgnorePendingStylesheets();
+ if (isFocusable()) {
+ Element::focus(restorePreviousSelection, direction);
+ return;
+ }
+ }
+
// To match other browsers' behavior, never restore previous selection.
- if (HTMLFormControlElement* control = associatedControl())
+ if (auto* control = associatedControl())
control->focus(false, direction);
}
void HTMLLegendElement::accessKeyAction(bool sendMouseEvents)
{
- if (HTMLFormControlElement* control = associatedControl())
+ if (auto* control = associatedControl())
control->accessKeyAction(sendMouseEvents);
}
-HTMLFormElement* HTMLLegendElement::virtualForm() const
+HTMLFormElement* HTMLLegendElement::form() const
{
// According to the specification, If the legend has a fieldset element as
// its parent, then the form attribute must return the same value as the
// form attribute on that fieldset element. Otherwise, it must return null.
- ContainerNode* fieldset = parentNode();
- if (!fieldset || !fieldset->hasTagName(fieldsetTag))
- return 0;
-
- return toHTMLFieldSetElement(fieldset)->form();
+ auto* fieldset = parentNode();
+ if (!is<HTMLFieldSetElement>(fieldset))
+ return nullptr;
+ return downcast<HTMLFieldSetElement>(*fieldset).form();
}
} // namespace