diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/HTMLLegendElement.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/html/HTMLLegendElement.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLLegendElement.cpp | 39 |
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 |