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

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

Issue 171663005: Consistently use ElementTraversal API when looking for an Element (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/RuleFeature.cpp ('k') | Source/core/dom/Node.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2316 setReadyState(Loading); 2316 setReadyState(Loading);
2317 2317
2318 return m_parser; 2318 return m_parser;
2319 } 2319 }
2320 2320
2321 HTMLElement* Document::body() const 2321 HTMLElement* Document::body() const
2322 { 2322 {
2323 if (!documentElement()) 2323 if (!documentElement())
2324 return 0; 2324 return 0;
2325 2325
2326 for (Node* child = documentElement()->firstChild(); child; child = child->ne xtSibling()) { 2326 for (Element* child = ElementTraversal::firstWithin(*documentElement()); chi ld; child = ElementTraversal::nextSibling(*child)) {
2327 if (child->hasTagName(framesetTag) || child->hasTagName(bodyTag)) 2327 if (child->hasTagName(framesetTag) || child->hasTagName(bodyTag))
2328 return toHTMLElement(child); 2328 return toHTMLElement(child);
2329 } 2329 }
2330 2330
2331 return 0; 2331 return 0;
2332 } 2332 }
2333 2333
2334 void Document::setBody(PassRefPtr<HTMLElement> prpNewBody, ExceptionState& excep tionState) 2334 void Document::setBody(PassRefPtr<HTMLElement> prpNewBody, ExceptionState& excep tionState)
2335 { 2335 {
2336 RefPtr<HTMLElement> newBody = prpNewBody; 2336 RefPtr<HTMLElement> newBody = prpNewBody;
(...skipping 21 matching lines...) Expand all
2358 else 2358 else
2359 documentElement()->appendChild(newBody.release(), exceptionState); 2359 documentElement()->appendChild(newBody.release(), exceptionState);
2360 } 2360 }
2361 2361
2362 HTMLHeadElement* Document::head() 2362 HTMLHeadElement* Document::head()
2363 { 2363 {
2364 Node* de = documentElement(); 2364 Node* de = documentElement();
2365 if (!de) 2365 if (!de)
2366 return 0; 2366 return 0;
2367 2367
2368 for (Node* node = de->firstChild(); node; node = node->nextSibling()) { 2368 for (Element* child = ElementTraversal::firstWithin(*de); child; child = Ele mentTraversal::nextSibling(*child)) {
2369 if (node->hasTagName(headTag)) 2369 if (child->hasTagName(headTag))
2370 return toHTMLHeadElement(node); 2370 return toHTMLHeadElement(child);
2371 } 2371 }
2372 return 0; 2372 return 0;
2373 } 2373 }
2374 2374
2375 Element* Document::viewportDefiningElement(RenderStyle* rootStyle) const 2375 Element* Document::viewportDefiningElement(RenderStyle* rootStyle) const
2376 { 2376 {
2377 // If a BODY element sets non-visible overflow, it is to be propagated to th e viewport, as long 2377 // If a BODY element sets non-visible overflow, it is to be propagated to th e viewport, as long
2378 // as the following conditions are all met: 2378 // as the following conditions are all met:
2379 // (1) The root element is HTML. 2379 // (1) The root element is HTML.
2380 // (2) It is the primary BODY element (we only assert for this, expecting ca llers to behave). 2380 // (2) It is the primary BODY element (we only assert for this, expecting ca llers to behave).
(...skipping 3060 matching lines...) Expand 10 before | Expand all | Expand 10 after
5441 void Document::defaultEventHandler(Event* event) 5441 void Document::defaultEventHandler(Event* event)
5442 { 5442 {
5443 if (frame() && frame()->remotePlatformLayer()) { 5443 if (frame() && frame()->remotePlatformLayer()) {
5444 frame()->chromeClient().forwardInputEvent(this, event); 5444 frame()->chromeClient().forwardInputEvent(this, event);
5445 return; 5445 return;
5446 } 5446 }
5447 Node::defaultEventHandler(event); 5447 Node::defaultEventHandler(event);
5448 } 5448 }
5449 5449
5450 } // namespace WebCore 5450 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/RuleFeature.cpp ('k') | Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698