Changeset 238377 in webkit


Ignore:
Timestamp:
Nov 19, 2018 12:42:53 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Setting document.title should have no effect for non SVG/HTML documents
https://bugs.webkit.org/show_bug.cgi?id=191643

Patch by Rob Buis <rbuis@igalia.com> on 2018-11-19
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

  • web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg-expected.txt: Added.
  • web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html: Added.

Source/WebCore:

Setting document.title should have no effect for non SVG/HTML documents,
see https://html.spec.whatwg.org/multipage/dom.html#document.title.

Behavior matches Firefox and Chrome.

Test: imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html

  • dom/Document.cpp:

(WebCore::Document::setTitle):

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r238365 r238377  
     12018-11-19  Rob Buis  <rbuis@igalia.com>
     2
     3        Setting document.title should have no effect for non SVG/HTML documents
     4        https://bugs.webkit.org/show_bug.cgi?id=191643
     5
     6        Reviewed by Chris Dumez.
     7
     8        * web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg-expected.txt: Added.
     9        * web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html: Added.
     10
    1112018-11-18  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r238375 r238377  
     12018-11-19  Rob Buis  <rbuis@igalia.com>
     2
     3        Setting document.title should have no effect for non SVG/HTML documents
     4        https://bugs.webkit.org/show_bug.cgi?id=191643
     5
     6        Reviewed by Chris Dumez.
     7
     8        Setting document.title should have no effect for non SVG/HTML documents,
     9        see https://html.spec.whatwg.org/multipage/dom.html#document.title.
     10
     11        Behavior matches Firefox and Chrome.
     12
     13        Test: imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html
     14
     15        * dom/Document.cpp:
     16        (WebCore::Document::setTitle):
     17
    1182018-11-19  Wenson Hsieh  <wenson_hsieh@apple.com>
    219
  • trunk/Source/WebCore/dom/Document.cpp

    r238322 r238377  
    15811581void Document::setTitle(const String& title)
    15821582{
    1583     if (!m_titleElement) {
    1584         if (isHTMLDocument() || isXHTMLDocument()) {
     1583    auto* element = documentElement();
     1584    if (is<SVGSVGElement>(element)) {
     1585        if (!m_titleElement) {
     1586            m_titleElement = SVGTitleElement::create(SVGNames::titleTag, *this);
     1587            element->insertBefore(*m_titleElement, element->firstChild());
     1588        }
     1589        m_titleElement->setTextContent(title);
     1590    } else if (is<HTMLElement>(element)) {
     1591        if (!m_titleElement) {
    15851592            auto* headElement = head();
    15861593            if (!headElement)
     
    15881595            m_titleElement = HTMLTitleElement::create(HTMLNames::titleTag, *this);
    15891596            headElement->appendChild(*m_titleElement);
    1590         } else if (isSVGDocument()) {
    1591             auto* element = documentElement();
    1592             if (!is<SVGSVGElement>(element))
    1593                 return;
    1594             m_titleElement = SVGTitleElement::create(SVGNames::titleTag, *this);
    1595             element->insertBefore(*m_titleElement, element->firstChild());
    15961597        }
    1597     } else if (!isHTMLDocument() && !isXHTMLDocument() && !isSVGDocument()) {
    1598         // FIXME: What exactly is the point of this? This seems like a strange moment
    1599         // in time to demote something from being m_titleElement, when setting the
    1600         // value of the title attribute. Do we have test coverage for this?
    1601         m_titleElement = nullptr;
    1602     }
    1603 
    1604     if (is<HTMLTitleElement>(m_titleElement.get()))
    1605         downcast<HTMLTitleElement>(*m_titleElement).setTextContent(title);
    1606     else if (is<SVGTitleElement>(m_titleElement.get()))
    1607         downcast<SVGTitleElement>(*m_titleElement).setTextContent(title);
    1608     else
    1609         updateTitle({ title, TextDirection::LTR });
     1598        m_titleElement->setTextContent(title);
     1599    }
    16101600}
    16111601
Note: See TracChangeset for help on using the changeset viewer.