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

Side by Side Diff: Source/core/html/HTMLObjectElement.cpp

Issue 50453004: Finding an <object> element by name only works it has no children other than <param> elements (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove unnecessary include Created 7 years, 1 month 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
« no previous file with comments | « Source/core/html/HTMLObjectElement.h ('k') | no next file » | 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) 2000 Stefan Schimanski (1Stein@gmx.de) 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "core/plugins/PluginView.h" 43 #include "core/plugins/PluginView.h"
44 #include "core/rendering/RenderEmbeddedObject.h" 44 #include "core/rendering/RenderEmbeddedObject.h"
45 #include "platform/Widget.h" 45 #include "platform/Widget.h"
46 46
47 namespace WebCore { 47 namespace WebCore {
48 48
49 using namespace HTMLNames; 49 using namespace HTMLNames;
50 50
51 inline HTMLObjectElement::HTMLObjectElement(const QualifiedName& tagName, Docume nt& document, HTMLFormElement* form, bool createdByParser) 51 inline HTMLObjectElement::HTMLObjectElement(const QualifiedName& tagName, Docume nt& document, HTMLFormElement* form, bool createdByParser)
52 : HTMLPlugInElement(tagName, document, createdByParser, ShouldNotPreferPlugI nsForImages) 52 : HTMLPlugInElement(tagName, document, createdByParser, ShouldNotPreferPlugI nsForImages)
53 , m_docNamedItem(true)
54 , m_useFallbackContent(false) 53 , m_useFallbackContent(false)
55 { 54 {
56 ASSERT(hasTagName(objectTag)); 55 ASSERT(hasTagName(objectTag));
57 setForm(form ? form : findFormAncestor()); 56 setForm(form ? form : findFormAncestor());
58 ScriptWrappable::init(this); 57 ScriptWrappable::init(this);
59 } 58 }
60 59
61 inline HTMLObjectElement::~HTMLObjectElement() 60 inline HTMLObjectElement::~HTMLObjectElement()
62 { 61 {
63 setForm(0); 62 setForm(0);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 327 }
329 328
330 void HTMLObjectElement::removedFrom(ContainerNode* insertionPoint) 329 void HTMLObjectElement::removedFrom(ContainerNode* insertionPoint)
331 { 330 {
332 HTMLPlugInElement::removedFrom(insertionPoint); 331 HTMLPlugInElement::removedFrom(insertionPoint);
333 FormAssociatedElement::removedFrom(insertionPoint); 332 FormAssociatedElement::removedFrom(insertionPoint);
334 } 333 }
335 334
336 void HTMLObjectElement::childrenChanged(bool changedByParser, Node* beforeChange , Node* afterChange, int childCountDelta) 335 void HTMLObjectElement::childrenChanged(bool changedByParser, Node* beforeChange , Node* afterChange, int childCountDelta)
337 { 336 {
338 updateDocNamedItem();
339 if (inDocument() && !useFallbackContent()) { 337 if (inDocument() && !useFallbackContent()) {
340 setNeedsWidgetUpdate(true); 338 setNeedsWidgetUpdate(true);
341 setNeedsStyleRecalc(); 339 setNeedsStyleRecalc();
342 } 340 }
343 HTMLPlugInElement::childrenChanged(changedByParser, beforeChange, afterChang e, childCountDelta); 341 HTMLPlugInElement::childrenChanged(changedByParser, beforeChange, afterChang e, childCountDelta);
344 } 342 }
345 343
346 bool HTMLObjectElement::isURLAttribute(const Attribute& attribute) const 344 bool HTMLObjectElement::isURLAttribute(const Attribute& attribute) const
347 { 345 {
348 return attribute.name() == dataAttr || (attribute.name() == usemapAttr && at tribute.value().string()[0] != '#') || HTMLPlugInElement::isURLAttribute(attribu te); 346 return attribute.name() == dataAttr || (attribute.name() == usemapAttr && at tribute.value().string()[0] != '#') || HTMLPlugInElement::isURLAttribute(attribu te);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 // treat them as "recognized tags" for the purpose of parsing 405 // treat them as "recognized tags" for the purpose of parsing
408 // because that changes how we parse documents. 406 // because that changes how we parse documents.
409 continue; 407 continue;
410 } 408 }
411 tagList.add(tags[i]->localName().impl()); 409 tagList.add(tags[i]->localName().impl());
412 } 410 }
413 } 411 }
414 return tagList.contains(tagName.localName().impl()); 412 return tagList.contains(tagName.localName().impl());
415 } 413 }
416 414
417 void HTMLObjectElement::updateDocNamedItem()
418 {
419 // The rule is "<object> elements with no children other than
420 // <param> elements, unknown elements and whitespace can be
421 // found by name in a document, and other <object> elements cannot."
422 bool wasNamedItem = m_docNamedItem;
423 bool isNamedItem = true;
424 Node* child = firstChild();
425 while (child && isNamedItem) {
426 if (child->isElementNode()) {
427 Element* element = toElement(child);
428 // FIXME: Use of isRecognizedTagName is almost certainly wrong here.
429 if (isRecognizedTagName(element->tagQName()) && !element->hasTagName (paramTag))
430 isNamedItem = false;
431 } else if (child->isTextNode()) {
432 if (!toText(child)->containsOnlyWhitespace())
433 isNamedItem = false;
434 } else
435 isNamedItem = false;
436 child = child->nextSibling();
437 }
438 if (isNamedItem != wasNamedItem && document().isHTMLDocument()) {
439 HTMLDocument& document = toHTMLDocument(this->document());
440 if (isNamedItem) {
441 document.addNamedItem(getNameAttribute());
442 document.addExtraNamedItem(getIdAttribute());
443 } else {
444 document.removeNamedItem(getNameAttribute());
445 document.removeExtraNamedItem(getIdAttribute());
446 }
447 }
448 m_docNamedItem = isNamedItem;
449 }
450
451 bool HTMLObjectElement::containsJavaApplet() const 415 bool HTMLObjectElement::containsJavaApplet() const
452 { 416 {
453 if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr))) 417 if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr)))
454 return true; 418 return true;
455 419
456 for (Element* child = ElementTraversal::firstWithin(this); child; child = El ementTraversal::nextSkippingChildren(child, this)) { 420 for (Element* child = ElementTraversal::firstWithin(this); child; child = El ementTraversal::nextSkippingChildren(child, this)) {
457 if (child->hasTagName(paramTag) 421 if (child->hasTagName(paramTag)
458 && equalIgnoringCase(child->getNameAttribute(), "type") 422 && equalIgnoringCase(child->getNameAttribute(), "type")
459 && MIMETypeRegistry::isJavaAppletMIMEType(child->getAttribute(va lueAttr).string())) 423 && MIMETypeRegistry::isJavaAppletMIMEType(child->getAttribute(va lueAttr).string()))
460 return true; 424 return true;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 { 469 {
506 return FormAssociatedElement::form(); 470 return FormAssociatedElement::form();
507 } 471 }
508 472
509 bool HTMLObjectElement::isInteractiveContent() const 473 bool HTMLObjectElement::isInteractiveContent() const
510 { 474 {
511 return fastHasAttribute(usemapAttr); 475 return fastHasAttribute(usemapAttr);
512 } 476 }
513 477
514 } 478 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLObjectElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698