Chromium Code Reviews| 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 // Only allow the first title element to change the title -- others have no effect. |
| 1309 if (m_titleElement && m_titleElement != titleElement) { | 1320 if (m_titleElement && m_titleElement != titleElement) { |
| 1310 if (isHTMLDocument() || isXHTMLDocument()) { | 1321 if (isHTMLDocument() || isXHTMLDocument()) { |
| 1311 m_titleElement = Traversal<HTMLTitleElement>::firstWithin(*this); | 1322 m_titleElement = Traversal<HTMLTitleElement>::firstWithin(*this); |
| 1312 } else if (isSVGDocument()) { | 1323 } else if (isSVGDocument()) { |
| 1313 m_titleElement = Traversal<SVGTitleElement>::firstWithin(*this); | 1324 m_titleElement = Traversal<SVGTitleElement>::firstWithin(*this); |
| 1325 if (!m_titleElement) | |
| 1326 m_titleElement = titleElement; | |
| 1314 } | 1327 } |
| 1315 } else { | 1328 } else { |
| 1316 m_titleElement = titleElement; | 1329 m_titleElement = titleElement; |
| 1317 } | 1330 } |
| 1318 | 1331 |
| 1332 if (!m_titleElement) | |
|
hyunjunekim2
2016/03/10 15:00:44
Moved it.
| |
| 1333 return; | |
| 1334 | |
| 1335 if (isSVGSVGElement(documentElement()) && documentElement() == m_titleElemen t->parentNode()) { | |
| 1336 // If the root element is an svg element in the SVG namespace, then let value be the child | |
|
fs
2016/03/10 14:41:47
Maybe you'd be better served to just fold this log
hyunjunekim2
2016/03/10 15:00:44
Done.
| |
| 1337 // text content of the first title element in the SVG namespace that is a child of the root | |
| 1338 // element. | |
| 1339 if (!isSVGTitleElement(m_titleElement)) { | |
| 1340 m_titleElement = nullptr; | |
| 1341 return; | |
| 1342 } | |
| 1343 } else { | |
| 1344 // Otherwise, let value be the child text content of the title element. | |
|
fs
2016/03/10 14:41:47
This comment is very confusing together with the c
hyunjunekim2
2016/03/10 15:00:44
Done.
| |
| 1345 if (isSVGTitleElement(m_titleElement)) { | |
| 1346 m_titleElement = nullptr; | |
| 1347 return; | |
| 1348 } | |
| 1349 } | |
| 1350 | |
| 1319 if (isHTMLTitleElement(m_titleElement)) | 1351 if (isHTMLTitleElement(m_titleElement)) |
| 1320 updateTitle(toHTMLTitleElement(m_titleElement)->text()); | 1352 updateTitle(toHTMLTitleElement(m_titleElement)->text()); |
| 1321 else if (isSVGTitleElement(m_titleElement)) | 1353 else if (isSVGTitleElement(m_titleElement)) |
| 1322 updateTitle(toSVGTitleElement(m_titleElement)->textContent()); | 1354 updateTitle(toSVGTitleElement(m_titleElement)->textContent()); |
| 1323 } | 1355 } |
| 1324 | 1356 |
| 1325 void Document::removeTitle(Element* titleElement) | 1357 void Document::removeTitle(Element* titleElement) |
| 1326 { | 1358 { |
| 1327 if (m_titleElement != titleElement) | 1359 if (m_titleElement != titleElement) |
| 1328 return; | 1360 return; |
| (...skipping 4661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5990 #ifndef NDEBUG | 6022 #ifndef NDEBUG |
| 5991 using namespace blink; | 6023 using namespace blink; |
| 5992 void showLiveDocumentInstances() | 6024 void showLiveDocumentInstances() |
| 5993 { | 6025 { |
| 5994 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 6026 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 5995 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6027 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5996 for (Document* document : set) | 6028 for (Document* document : set) |
| 5997 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); | 6029 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); |
| 5998 } | 6030 } |
| 5999 #endif | 6031 #endif |
| OLD | NEW |