Changeset 202895 in webkit
- Timestamp:
- Jul 6, 2016 10:55:30 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r202893 r202895 1 2016-07-06 Chris Dumez <cdumez@apple.com> 2 3 Document.title setter does not work for SVG documents 4 https://bugs.webkit.org/show_bug.cgi?id=159503 5 <rdar://problem/27212313> 6 7 Reviewed by Ryosuke Niwa. 8 9 Rebaseline W3C test now that all checks are passing. 10 11 * web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-09-expected.txt: 12 1 13 2016-07-06 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-09-expected.txt
r194580 r202895 1 1 2 FAIL No title element in SVG document assert_equals: expected "title" but got "x-child" 3 FAIL Title element in SVG document assert_equals: expected "foobar" but got "foo" 4 FAIL Title element not child of SVG root assert_equals: expected "" but got "foo" 5 FAIL Title element not in SVG namespace assert_equals: expected "" but got "foo" 6 FAIL Root element not named "svg" assert_equals: expected "" but got "foo" 2 PASS No title element in SVG document 3 PASS Title element in SVG document 4 PASS Title element not child of SVG root 5 PASS Title element not in SVG namespace 6 PASS Root element not named "svg" 7 7 -
trunk/Source/WebCore/ChangeLog
r202893 r202895 1 2016-07-06 Chris Dumez <cdumez@apple.com> 2 3 Document.title setter does not work for SVG documents 4 https://bugs.webkit.org/show_bug.cgi?id=159503 5 <rdar://problem/27212313> 6 7 Reviewed by Ryosuke Niwa. 8 9 Document.title setter should work for SVG documents: 10 - https://html.spec.whatwg.org/multipage/dom.html#document.title 11 12 This patch aligns our behavior with the specification 13 and with Firefox / Chrome. 14 15 No new tests, rebaselined existing test. 16 17 * dom/Document.cpp: 18 (WebCore::Document::setTitle): 19 - Reverse the if conditions for clarity. 20 - If the document element is an SVG svg element, create a 21 SVGTitleElement and insert it as first child of the 22 document element. 23 - Call SVGTitleElement::setText() instead of 24 HTMLTitleElement::setText() at the end of the method if 25 m_titleElement is a SVGTitleElement. 26 27 (WebCore::Document::updateTitleElement): 28 - If document element is an SVG svg element, use the first 29 child of the document element that is a SVGTitleElement. 30 31 * svg/SVGTitleElement.cpp: 32 (WebCore::SVGTitleElement::setText): 33 * svg/SVGTitleElement.h: 34 Add SVGTitleElement::setText() method that does the same 35 thing as HTMLTitleElement::setText(). 36 1 37 2016-07-06 Chris Dumez <cdumez@apple.com> 2 38 -
trunk/Source/WebCore/dom/Document.cpp
r202893 r202895 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 6 * Copyright (C) 2004-201 5Apple Inc. All rights reserved.6 * Copyright (C) 2004-2016 Apple Inc. All rights reserved. 7 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 8 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. … … 147 147 #include "SVGElementFactory.h" 148 148 #include "SVGNames.h" 149 #include "SVGSVGElement.h" 149 150 #include "SVGTitleElement.h" 150 151 #include "SVGZoomEvent.h" … … 1621 1622 void Document::setTitle(const String& title) 1622 1623 { 1623 if (!isHTMLDocument() && !isXHTMLDocument()) 1624 if (!m_titleElement) { 1625 if (isHTMLDocument() || isXHTMLDocument()) { 1626 auto* headElement = head(); 1627 if (!headElement) 1628 return; 1629 m_titleElement = HTMLTitleElement::create(HTMLNames::titleTag, *this); 1630 headElement->appendChild(*m_titleElement); 1631 } else if (isSVGDocument()) { 1632 auto* element = documentElement(); 1633 if (!is<SVGSVGElement>(element)) 1634 return; 1635 m_titleElement = SVGTitleElement::create(SVGNames::titleTag, *this); 1636 element->insertBefore(*m_titleElement, element->firstChild()); 1637 } 1638 } else if (!isHTMLDocument() && !isXHTMLDocument() && !isSVGDocument()) 1624 1639 m_titleElement = nullptr; 1625 else if (!m_titleElement) {1626 auto* headElement = head();1627 if (!headElement)1628 return;1629 m_titleElement = createElement(titleTag, false);1630 headElement->appendChild(*m_titleElement, ASSERT_NO_EXCEPTION);1631 }1632 1640 1633 1641 // The DOM API has no method of specifying direction, so assume LTR. … … 1636 1644 if (is<HTMLTitleElement>(m_titleElement.get())) 1637 1645 downcast<HTMLTitleElement>(*m_titleElement).setText(title); 1646 else if (is<SVGTitleElement>(m_titleElement.get())) 1647 downcast<SVGTitleElement>(*m_titleElement).setText(title); 1638 1648 } 1639 1649 1640 1650 void Document::updateTitleElement(Element* newTitleElement) 1641 1651 { 1642 // Only allow the first title element in tree order to change the title -- others have no effect. 1643 if (m_titleElement) { 1644 if (isHTMLDocument() || isXHTMLDocument()) 1645 m_titleElement = descendantsOfType<HTMLTitleElement>(*this).first(); 1646 else if (isSVGDocument()) 1647 m_titleElement = descendantsOfType<SVGTitleElement>(*this).first(); 1648 } else 1649 m_titleElement = newTitleElement; 1652 if (is<SVGSVGElement>(documentElement())) 1653 m_titleElement = childrenOfType<SVGTitleElement>(*documentElement()).first(); 1654 else { 1655 if (m_titleElement) { 1656 if (isHTMLDocument() || isXHTMLDocument()) 1657 m_titleElement = descendantsOfType<HTMLTitleElement>(*this).first(); 1658 } else 1659 m_titleElement = newTitleElement; 1660 } 1650 1661 1651 1662 updateTitleFromTitleElement(); -
trunk/Source/WebCore/html/HTMLTitleElement.cpp
r202167 r202895 101 101 // We make a copy here because entity of "value" argument can be Document::m_title, 102 102 // which goes empty during removeChildren() invocation below, 103 // which causes HTMLTitleElement::childrenChanged(), which ends up Document::setTitle().103 // which causes HTMLTitleElement::childrenChanged(), which ends up calling Document::setTitle(). 104 104 String valueCopy(value); 105 105 -
trunk/Source/WebCore/svg/SVGTitleElement.cpp
r189680 r202895 2 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> 3 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 4 * Copyright (C) 2016 Apple Inc. All rights reserved. 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 24 25 #include "Document.h" 25 26 #include "SVGNames.h" 27 #include "Text.h" 26 28 27 29 namespace WebCore { … … 62 64 } 63 65 66 void SVGTitleElement::setText(const String& value) 67 { 68 Ref<SVGTitleElement> protectedThis(*this); 69 70 if (!value.isEmpty() && hasOneChild() && is<Text>(*firstChild())) { 71 downcast<Text>(*firstChild()).setData(value); 72 return; 73 } 74 75 // We make a copy here because entity of "value" argument can be Document::m_title, 76 // which goes empty during removeChildren() invocation below, 77 // which causes SVGTitleElement::childrenChanged(), which ends up calling Document::setTitle(). 78 String valueCopy(value); 79 80 if (hasChildNodes()) 81 removeChildren(); 82 83 if (!valueCopy.isEmpty()) 84 appendChild(document().createTextNode(valueCopy), IGNORE_EXCEPTION); 64 85 } 86 87 } -
trunk/Source/WebCore/svg/SVGTitleElement.h
r197563 r202895 31 31 static Ref<SVGTitleElement> create(const QualifiedName&, Document&); 32 32 33 void setText(const String&); 34 33 35 private: 34 36 SVGTitleElement(const QualifiedName&, Document&);
Note: See TracChangeset
for help on using the changeset viewer.