Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: Source/core/dom/Document.cpp

Issue 19028005: Introduce isHTMLTitleElement and toHTMLTitleElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 if (HTMLElement* headElement = head()) { 1316 if (HTMLElement* headElement = head()) {
1317 m_titleElement = createElement(titleTag, false); 1317 m_titleElement = createElement(titleTag, false);
1318 headElement->appendChild(m_titleElement, ASSERT_NO_EXCEPTION); 1318 headElement->appendChild(m_titleElement, ASSERT_NO_EXCEPTION);
1319 } 1319 }
1320 } 1320 }
1321 1321
1322 // The DOM API has no method of specifying direction, so assume LTR. 1322 // The DOM API has no method of specifying direction, so assume LTR.
1323 updateTitle(StringWithDirection(title, LTR)); 1323 updateTitle(StringWithDirection(title, LTR));
1324 1324
1325 if (m_titleElement) { 1325 if (m_titleElement) {
1326 ASSERT(m_titleElement->hasTagName(titleTag)); 1326 ASSERT(isHTMLTitleElement(m_titleElement.get()));
1327 if (m_titleElement->hasTagName(titleTag)) 1327 if (isHTMLTitleElement(m_titleElement.get()))
1328 static_cast<HTMLTitleElement*>(m_titleElement.get())->setText(title) ; 1328 toHTMLTitleElement(m_titleElement.get())->setText(title);
1329 } 1329 }
1330 } 1330 }
1331 1331
1332 void Document::setTitleElement(const StringWithDirection& title, Element* titleE lement) 1332 void Document::setTitleElement(const StringWithDirection& title, Element* titleE lement)
1333 { 1333 {
1334 if (titleElement != m_titleElement) { 1334 if (titleElement != m_titleElement) {
1335 if (m_titleElement || m_titleSetExplicitly) 1335 if (m_titleElement || m_titleSetExplicitly)
1336 // Only allow the first title element to change the title -- others have no effect. 1336 // Only allow the first title element to change the title -- others have no effect.
1337 return; 1337 return;
1338 m_titleElement = titleElement; 1338 m_titleElement = titleElement;
1339 } 1339 }
1340 1340
1341 updateTitle(title); 1341 updateTitle(title);
1342 } 1342 }
1343 1343
1344 void Document::removeTitle(Element* titleElement) 1344 void Document::removeTitle(Element* titleElement)
1345 { 1345 {
1346 if (m_titleElement != titleElement) 1346 if (m_titleElement != titleElement)
1347 return; 1347 return;
1348 1348
1349 m_titleElement = 0; 1349 m_titleElement = 0;
1350 m_titleSetExplicitly = false; 1350 m_titleSetExplicitly = false;
1351 1351
1352 // Update title based on first title element in the head, if one exists. 1352 // Update title based on first title element in the head, if one exists.
1353 if (HTMLElement* headElement = head()) { 1353 if (HTMLElement* headElement = head()) {
1354 for (Node* e = headElement->firstChild(); e; e = e->nextSibling()) 1354 for (Node* e = headElement->firstChild(); e; e = e->nextSibling()) {
1355 if (e->hasTagName(titleTag)) { 1355 if (isHTMLTitleElement(e)) {
1356 HTMLTitleElement* titleElement = static_cast<HTMLTitleElement*>( e); 1356 HTMLTitleElement* titleElement = toHTMLTitleElement(e);
1357 setTitleElement(titleElement->textWithDirection(), titleElement) ; 1357 setTitleElement(titleElement->textWithDirection(), titleElement) ;
1358 break; 1358 break;
1359 } 1359 }
1360 }
1360 } 1361 }
1361 1362
1362 if (!m_titleElement) 1363 if (!m_titleElement)
1363 updateTitle(StringWithDirection()); 1364 updateTitle(StringWithDirection());
1364 } 1365 }
1365 1366
1366 PageVisibilityState Document::visibilityState() const 1367 PageVisibilityState Document::visibilityState() const
1367 { 1368 {
1368 // The visibility of the document is inherited from the visibility of the 1369 // The visibility of the document is inherited from the visibility of the
1369 // page. If there is no page associated with the document, we will assume 1370 // page. If there is no page associated with the document, we will assume
(...skipping 3771 matching lines...) Expand 10 before | Expand all | Expand 10 after
5141 { 5142 {
5142 return DocumentLifecycleNotifier::create(this); 5143 return DocumentLifecycleNotifier::create(this);
5143 } 5144 }
5144 5145
5145 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5146 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5146 { 5147 {
5147 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5148 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5148 } 5149 }
5149 5150
5150 } // namespace WebCore 5151 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/editing/ReplaceSelectionCommand.cpp » ('j') | Source/core/html/HTMLTitleElement.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698