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

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

Issue 61213008: Revert "Finding an <object> element by name only works it has no children other than <param> elemen… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/rendering/RenderEmbeddedObject.h" 43 #include "core/rendering/RenderEmbeddedObject.h"
44 #include "platform/MIMETypeRegistry.h" 44 #include "platform/MIMETypeRegistry.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(Document& document, HTMLFormElement* form, bool createdByParser) 51 inline HTMLObjectElement::HTMLObjectElement(Document& document, HTMLFormElement* form, bool createdByParser)
52 : HTMLPlugInElement(objectTag, document, createdByParser, ShouldNotPreferPlu gInsForImages) 52 : HTMLPlugInElement(objectTag, document, createdByParser, ShouldNotPreferPlu gInsForImages)
53 , m_docNamedItem(true)
53 , m_useFallbackContent(false) 54 , m_useFallbackContent(false)
54 { 55 {
55 setForm(form ? form : findFormAncestor()); 56 setForm(form ? form : findFormAncestor());
56 ScriptWrappable::init(this); 57 ScriptWrappable::init(this);
57 } 58 }
58 59
59 inline HTMLObjectElement::~HTMLObjectElement() 60 inline HTMLObjectElement::~HTMLObjectElement()
60 { 61 {
61 setForm(0); 62 setForm(0);
62 } 63 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 327 }
327 328
328 void HTMLObjectElement::removedFrom(ContainerNode* insertionPoint) 329 void HTMLObjectElement::removedFrom(ContainerNode* insertionPoint)
329 { 330 {
330 HTMLPlugInElement::removedFrom(insertionPoint); 331 HTMLPlugInElement::removedFrom(insertionPoint);
331 FormAssociatedElement::removedFrom(insertionPoint); 332 FormAssociatedElement::removedFrom(insertionPoint);
332 } 333 }
333 334
334 void HTMLObjectElement::childrenChanged(bool changedByParser, Node* beforeChange , Node* afterChange, int childCountDelta) 335 void HTMLObjectElement::childrenChanged(bool changedByParser, Node* beforeChange , Node* afterChange, int childCountDelta)
335 { 336 {
337 updateDocNamedItem();
336 if (inDocument() && !useFallbackContent()) { 338 if (inDocument() && !useFallbackContent()) {
337 setNeedsWidgetUpdate(true); 339 setNeedsWidgetUpdate(true);
338 setNeedsStyleRecalc(); 340 setNeedsStyleRecalc();
339 } 341 }
340 HTMLPlugInElement::childrenChanged(changedByParser, beforeChange, afterChang e, childCountDelta); 342 HTMLPlugInElement::childrenChanged(changedByParser, beforeChange, afterChang e, childCountDelta);
341 } 343 }
342 344
343 bool HTMLObjectElement::isURLAttribute(const Attribute& attribute) const 345 bool HTMLObjectElement::isURLAttribute(const Attribute& attribute) const
344 { 346 {
345 return attribute.name() == dataAttr || (attribute.name() == usemapAttr && at tribute.value().string()[0] != '#') || HTMLPlugInElement::isURLAttribute(attribu te); 347 return attribute.name() == dataAttr || (attribute.name() == usemapAttr && at tribute.value().string()[0] != '#') || HTMLPlugInElement::isURLAttribute(attribu te);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 return; 381 return;
380 } 382 }
381 } 383 }
382 384
383 m_useFallbackContent = true; 385 m_useFallbackContent = true;
384 386
385 // FIXME: Style gets recalculated which is suboptimal. 387 // FIXME: Style gets recalculated which is suboptimal.
386 reattachFallbackContent(); 388 reattachFallbackContent();
387 } 389 }
388 390
391 // FIXME: This should be removed, all callers are almost certainly wrong.
392 static bool isRecognizedTagName(const QualifiedName& tagName)
393 {
394 DEFINE_STATIC_LOCAL(HashSet<StringImpl*>, tagList, ());
395 if (tagList.isEmpty()) {
396 const QualifiedName* const* tags = HTMLNames::getHTMLTags();
397 for (size_t i = 0; i < HTMLNames::HTMLTagsCount; i++) {
398 if (*tags[i] == bgsoundTag
399 || *tags[i] == commandTag
400 || *tags[i] == detailsTag
401 || *tags[i] == figcaptionTag
402 || *tags[i] == figureTag
403 || *tags[i] == summaryTag
404 || *tags[i] == trackTag) {
405 // Even though we have atoms for these tags, we don't want to
406 // treat them as "recognized tags" for the purpose of parsing
407 // because that changes how we parse documents.
408 continue;
409 }
410 tagList.add(tags[i]->localName().impl());
411 }
412 }
413 return tagList.contains(tagName.localName().impl());
414 }
415
416 void HTMLObjectElement::updateDocNamedItem()
417 {
418 // The rule is "<object> elements with no children other than
419 // <param> elements, unknown elements and whitespace can be
420 // found by name in a document, and other <object> elements cannot."
421 bool wasNamedItem = m_docNamedItem;
422 bool isNamedItem = true;
423 Node* child = firstChild();
424 while (child && isNamedItem) {
425 if (child->isElementNode()) {
426 Element* element = toElement(child);
427 // FIXME: Use of isRecognizedTagName is almost certainly wrong here.
428 if (isRecognizedTagName(element->tagQName()) && !element->hasTagName (paramTag))
429 isNamedItem = false;
430 } else if (child->isTextNode()) {
431 if (!toText(child)->containsOnlyWhitespace())
432 isNamedItem = false;
433 } else {
434 isNamedItem = false;
435 }
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
389 bool HTMLObjectElement::containsJavaApplet() const 451 bool HTMLObjectElement::containsJavaApplet() const
390 { 452 {
391 if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr))) 453 if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr)))
392 return true; 454 return true;
393 455
394 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSkippingChildren(*child, this)) { 456 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSkippingChildren(*child, this)) {
395 if (child->hasTagName(paramTag) 457 if (child->hasTagName(paramTag)
396 && equalIgnoringCase(child->getNameAttribute(), "type") 458 && equalIgnoringCase(child->getNameAttribute(), "type")
397 && MIMETypeRegistry::isJavaAppletMIMEType(child->getAttribute(va lueAttr).string())) 459 && MIMETypeRegistry::isJavaAppletMIMEType(child->getAttribute(va lueAttr).string()))
398 return true; 460 return true;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 { 505 {
444 return FormAssociatedElement::form(); 506 return FormAssociatedElement::form();
445 } 507 }
446 508
447 bool HTMLObjectElement::isInteractiveContent() const 509 bool HTMLObjectElement::isInteractiveContent() const
448 { 510 {
449 return fastHasAttribute(usemapAttr); 511 return fastHasAttribute(usemapAttr);
450 } 512 }
451 513
452 } 514 }
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