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 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1279 m_title = canonicalizedTitle<UChar>(this, m_rawTitle); | 1279 m_title = canonicalizedTitle<UChar>(this, m_rawTitle); |
| 1280 | 1280 |
| 1281 if (!m_frame || oldTitle == m_title) | 1281 if (!m_frame || oldTitle == m_title) |
| 1282 return; | 1282 return; |
| 1283 m_frame->loader().client()->dispatchDidReceiveTitle(m_title); | 1283 m_frame->loader().client()->dispatchDidReceiveTitle(m_title); |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 void Document::setTitle(const String& title) | 1286 void Document::setTitle(const String& title) |
| 1287 { | 1287 { |
| 1288 // Title set by JavaScript -- overrides any title elements. | 1288 // Title set by JavaScript -- overrides any title elements. |
| 1289 if (!isHTMLDocument() && !isXHTMLDocument()) { | 1289 if (!m_titleElement) { |
| 1290 m_titleElement = nullptr; | 1290 if (isHTMLDocument() || isXHTMLDocument()) { |
| 1291 } else if (!m_titleElement) { | 1291 HTMLElement* headElement = head(); |
| 1292 HTMLElement* headElement = head(); | 1292 if (!headElement) |
| 1293 if (!headElement) | 1293 return; |
| 1294 return; | 1294 m_titleElement = HTMLTitleElement::create(*this); |
| 1295 m_titleElement = HTMLTitleElement::create(*this); | 1295 headElement->appendChild(m_titleElement.get()); |
| 1296 headElement->appendChild(m_titleElement.get()); | 1296 } else if (isSVGDocument()) { |
| 1297 if (!isSVGSVGElement(documentElement())) | |
| 1298 return; | |
| 1299 if (documentElement()) { | |
|
fs
2016/03/03 15:49:44
Here we know that documentElement() is non-null al
hyunjunekim2
2016/03/04 11:29:32
Done.
| |
| 1300 m_titleElement = SVGTitleElement::create(*this); | |
| 1301 documentElement()->insertBefore(m_titleElement.get(), documentEl ement()->firstChild()); | |
| 1302 } | |
| 1303 } | |
| 1304 } else { | |
| 1305 if (!isHTMLDocument() && !isXHTMLDocument() && !isSVGDocument()) | |
| 1306 m_titleElement = nullptr; | |
| 1297 } | 1307 } |
| 1298 | 1308 |
| 1299 if (isHTMLTitleElement(m_titleElement)) | 1309 if (isHTMLTitleElement(m_titleElement)) { |
| 1300 toHTMLTitleElement(m_titleElement)->setText(title); | 1310 toHTMLTitleElement(m_titleElement)->setText(title); |
| 1301 else | 1311 } else if (isSVGTitleElement(m_titleElement)) { |
| 1312 toSVGTitleElement(m_titleElement)->setText(title); | |
| 1313 } else { | |
| 1302 updateTitle(title); | 1314 updateTitle(title); |
| 1315 } | |
| 1303 } | 1316 } |
| 1304 | 1317 |
| 1305 void Document::setTitleElement(Element* titleElement) | 1318 void Document::setTitleElement(Element* titleElement) |
| 1306 { | 1319 { |
| 1307 // Only allow the first title element to change the title -- others have no effect. | 1320 // Only allow the first title element to change the title -- others have no effect. |
| 1308 if (m_titleElement && m_titleElement != titleElement) { | 1321 if (m_titleElement && m_titleElement != titleElement) { |
| 1309 if (isHTMLDocument() || isXHTMLDocument()) { | 1322 if (isHTMLDocument() || isXHTMLDocument()) { |
| 1310 m_titleElement = Traversal<HTMLTitleElement>::firstWithin(*this); | 1323 m_titleElement = Traversal<HTMLTitleElement>::firstWithin(*this); |
| 1311 } else if (isSVGDocument()) { | 1324 } else if (isSVGDocument()) { |
| 1312 m_titleElement = Traversal<SVGTitleElement>::firstWithin(*this); | 1325 m_titleElement = Traversal<SVGTitleElement>::firstWithin(*this); |
| 1313 } | 1326 } |
| 1314 } else { | 1327 } else { |
| 1315 m_titleElement = titleElement; | 1328 m_titleElement = titleElement; |
| 1316 } | 1329 } |
| 1317 | 1330 |
| 1318 if (isHTMLTitleElement(m_titleElement)) | 1331 if (isHTMLTitleElement(m_titleElement)) { |
| 1332 if (isSVGDocument() && isSVGSVGElement(documentElement())) { | |
|
fs
2016/03/03 15:49:44
I'd suggest that you separate the calls to updateT
hyunjunekim2
2016/03/04 11:29:32
Done.
| |
| 1333 m_titleElement = nullptr; | |
| 1334 return; | |
| 1335 } | |
| 1319 updateTitle(toHTMLTitleElement(m_titleElement)->text()); | 1336 updateTitle(toHTMLTitleElement(m_titleElement)->text()); |
| 1320 else if (isSVGTitleElement(m_titleElement)) | 1337 } else if (isSVGTitleElement(m_titleElement)) { |
| 1321 updateTitle(toSVGTitleElement(m_titleElement)->textContent()); | 1338 if (isSVGSVGElement(m_titleElement->parentNode())) |
| 1339 updateTitle(toSVGTitleElement(m_titleElement)->textContent()); | |
| 1340 else | |
| 1341 m_titleElement = nullptr; | |
| 1342 } | |
| 1322 } | 1343 } |
| 1323 | 1344 |
| 1324 void Document::removeTitle(Element* titleElement) | 1345 void Document::removeTitle(Element* titleElement) |
| 1325 { | 1346 { |
| 1326 if (m_titleElement != titleElement) | 1347 if (m_titleElement != titleElement) |
| 1327 return; | 1348 return; |
| 1328 | 1349 |
| 1329 m_titleElement = nullptr; | 1350 m_titleElement = nullptr; |
| 1330 | 1351 |
| 1331 // Update title based on first title element in the document, if one exists. | 1352 // Update title based on first title element in the document, if one exists. |
| (...skipping 4663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5995 #ifndef NDEBUG | 6016 #ifndef NDEBUG |
| 5996 using namespace blink; | 6017 using namespace blink; |
| 5997 void showLiveDocumentInstances() | 6018 void showLiveDocumentInstances() |
| 5998 { | 6019 { |
| 5999 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 6020 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 6000 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6021 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6001 for (Document* document : set) | 6022 for (Document* document : set) |
| 6002 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); | 6023 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); |
| 6003 } | 6024 } |
| 6004 #endif | 6025 #endif |
| OLD | NEW |