OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1280 m_title = canonicalizedTitle<UChar>(this, m_rawTitle); | 1280 m_title = canonicalizedTitle<UChar>(this, m_rawTitle); |
1281 | 1281 |
1282 if (!m_frame || oldTitle == m_title) | 1282 if (!m_frame || oldTitle == m_title) |
1283 return; | 1283 return; |
1284 m_frame->loader().client()->dispatchDidReceiveTitle(m_title); | 1284 m_frame->loader().client()->dispatchDidReceiveTitle(m_title); |
1285 } | 1285 } |
1286 | 1286 |
1287 void Document::setTitle(const String& title) | 1287 void Document::setTitle(const String& title) |
1288 { | 1288 { |
1289 // Title set by JavaScript -- overrides any title elements. | 1289 // Title set by JavaScript -- overrides any title elements. |
1290 if (!isHTMLDocument() && !isXHTMLDocument()) { | 1290 if (!m_titleElement) { |
1291 m_titleElement = nullptr; | 1291 if (isHTMLDocument() || isXHTMLDocument()) { |
1292 } else if (!m_titleElement) { | 1292 HTMLElement* headElement = head(); |
1293 HTMLElement* headElement = head(); | 1293 if (!headElement) |
1294 if (!headElement) | 1294 return; |
1295 return; | 1295 m_titleElement = HTMLTitleElement::create(*this); |
1296 m_titleElement = HTMLTitleElement::create(*this); | 1296 headElement->appendChild(m_titleElement.get()); |
1297 headElement->appendChild(m_titleElement.get()); | 1297 } else if (isSVGDocument()) { |
1298 Element* element = documentElement(); | |
1299 if (!isSVGSVGElement(element)) | |
1300 return; | |
1301 m_titleElement = SVGTitleElement::create(*this); | |
1302 element->insertBefore(m_titleElement.get(), element->firstChild()); | |
1303 } | |
1304 } else { | |
1305 if (!isHTMLDocument() && !isXHTMLDocument() && !isSVGDocument()) | |
1306 m_titleElement = nullptr; | |
1298 } | 1307 } |
1299 | 1308 |
1300 if (isHTMLTitleElement(m_titleElement)) | 1309 if (isHTMLTitleElement(m_titleElement)) |
1301 toHTMLTitleElement(m_titleElement)->setText(title); | 1310 toHTMLTitleElement(m_titleElement)->setText(title); |
1311 else if (isSVGTitleElement(m_titleElement)) | |
1312 toSVGTitleElement(m_titleElement)->setText(title); | |
1302 else | 1313 else |
1303 updateTitle(title); | 1314 updateTitle(title); |
1304 } | 1315 } |
1305 | 1316 |
1306 void Document::setTitleElement(Element* titleElement) | 1317 void Document::setTitleElement(Element* titleElement) |
1307 { | 1318 { |
1308 // Only allow the first title element to change the title -- others have no effect. | 1319 // If the root element is an svg element in the SVG namespace, then let valu e be the child text content |
1309 if (m_titleElement && m_titleElement != titleElement) { | 1320 // of the first title element in the SVG namespace that is a child of the ro ot element. |
1310 if (isHTMLDocument() || isXHTMLDocument()) { | 1321 if (isSVGSVGElement(documentElement())) { |
1311 m_titleElement = Traversal<HTMLTitleElement>::firstWithin(*this); | 1322 m_titleElement = Traversal<SVGTitleElement>::firstChild(*documentElement ()); |
1312 } else if (isSVGDocument()) { | 1323 if (m_titleElement && documentElement() == m_titleElement->parentNode()) { |
fs
2016/03/10 16:47:01
Traversal<SVGTitleElement>::firstChild guarantees
hyunjunekim2
2016/03/10 17:04:39
Done.
| |
1313 m_titleElement = Traversal<SVGTitleElement>::firstWithin(*this); | 1324 if (!isSVGTitleElement(m_titleElement)) { |
1325 m_titleElement = nullptr; | |
1326 return; | |
1327 } | |
1314 } | 1328 } |
1315 } else { | 1329 } else { |
1316 m_titleElement = titleElement; | 1330 if (m_titleElement && m_titleElement != titleElement) |
1331 m_titleElement = Traversal<HTMLTitleElement>::firstWithin(*this); | |
1332 else | |
1333 m_titleElement = titleElement; | |
1334 | |
1335 // If the root element isn't an svg element in the SVG namespace and the title element is | |
1336 // in the SVG namespace, it is ignored. | |
1337 if (isSVGTitleElement(m_titleElement)) { | |
1338 m_titleElement = nullptr; | |
1339 return; | |
1340 } | |
1317 } | 1341 } |
1318 | 1342 |
1319 if (isHTMLTitleElement(m_titleElement)) | 1343 if (isHTMLTitleElement(m_titleElement)) |
1320 updateTitle(toHTMLTitleElement(m_titleElement)->text()); | 1344 updateTitle(toHTMLTitleElement(m_titleElement)->text()); |
1321 else if (isSVGTitleElement(m_titleElement)) | 1345 else if (isSVGTitleElement(m_titleElement)) |
1322 updateTitle(toSVGTitleElement(m_titleElement)->textContent()); | 1346 updateTitle(toSVGTitleElement(m_titleElement)->textContent()); |
1323 } | 1347 } |
1324 | 1348 |
1325 void Document::removeTitle(Element* titleElement) | 1349 void Document::removeTitle(Element* titleElement) |
1326 { | 1350 { |
(...skipping 4663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5990 #ifndef NDEBUG | 6014 #ifndef NDEBUG |
5991 using namespace blink; | 6015 using namespace blink; |
5992 void showLiveDocumentInstances() | 6016 void showLiveDocumentInstances() |
5993 { | 6017 { |
5994 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 6018 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
5995 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6019 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5996 for (Document* document : set) | 6020 for (Document* document : set) |
5997 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); | 6021 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); |
5998 } | 6022 } |
5999 #endif | 6023 #endif |
OLD | NEW |