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

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

Issue 75273004: Add 'exposed' objects and embeds to a document's named properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove extraneous empty line in expected output Created 7 years 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "core/rendering/RenderEmbeddedObject.h" 44 #include "core/rendering/RenderEmbeddedObject.h"
45 #include "platform/MIMETypeRegistry.h" 45 #include "platform/MIMETypeRegistry.h"
46 #include "platform/Widget.h" 46 #include "platform/Widget.h"
47 47
48 namespace WebCore { 48 namespace WebCore {
49 49
50 using namespace HTMLNames; 50 using namespace HTMLNames;
51 51
52 inline HTMLObjectElement::HTMLObjectElement(Document& document, HTMLFormElement* form, bool createdByParser) 52 inline HTMLObjectElement::HTMLObjectElement(Document& document, HTMLFormElement* form, bool createdByParser)
53 : HTMLPlugInElement(objectTag, document, createdByParser, ShouldNotPreferPlu gInsForImages) 53 : HTMLPlugInElement(objectTag, document, createdByParser, ShouldNotPreferPlu gInsForImages)
54 , m_docNamedItem(true)
55 , m_useFallbackContent(false) 54 , m_useFallbackContent(false)
56 { 55 {
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);
64 } 63 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 329 }
331 330
332 void HTMLObjectElement::removedFrom(ContainerNode* insertionPoint) 331 void HTMLObjectElement::removedFrom(ContainerNode* insertionPoint)
333 { 332 {
334 HTMLPlugInElement::removedFrom(insertionPoint); 333 HTMLPlugInElement::removedFrom(insertionPoint);
335 FormAssociatedElement::removedFrom(insertionPoint); 334 FormAssociatedElement::removedFrom(insertionPoint);
336 } 335 }
337 336
338 void HTMLObjectElement::childrenChanged(bool changedByParser, Node* beforeChange , Node* afterChange, int childCountDelta) 337 void HTMLObjectElement::childrenChanged(bool changedByParser, Node* beforeChange , Node* afterChange, int childCountDelta)
339 { 338 {
340 updateDocNamedItem();
341 if (inDocument() && !useFallbackContent()) { 339 if (inDocument() && !useFallbackContent()) {
342 setNeedsWidgetUpdate(true); 340 setNeedsWidgetUpdate(true);
343 setNeedsStyleRecalc(); 341 setNeedsStyleRecalc();
344 } 342 }
345 HTMLPlugInElement::childrenChanged(changedByParser, beforeChange, afterChang e, childCountDelta); 343 HTMLPlugInElement::childrenChanged(changedByParser, beforeChange, afterChang e, childCountDelta);
346 } 344 }
347 345
348 bool HTMLObjectElement::isURLAttribute(const Attribute& attribute) const 346 bool HTMLObjectElement::isURLAttribute(const Attribute& attribute) const
349 { 347 {
350 return attribute.name() == codebaseAttr || attribute.name() == dataAttr 348 return attribute.name() == codebaseAttr || attribute.name() == dataAttr
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 return; 384 return;
387 } 385 }
388 } 386 }
389 387
390 m_useFallbackContent = true; 388 m_useFallbackContent = true;
391 389
392 // FIXME: Style gets recalculated which is suboptimal. 390 // FIXME: Style gets recalculated which is suboptimal.
393 reattachFallbackContent(); 391 reattachFallbackContent();
394 } 392 }
395 393
396 // FIXME: This should be removed, all callers are almost certainly wrong. 394 bool HTMLObjectElement::isExposed() const
397 static bool isRecognizedTagName(const QualifiedName& tagName)
398 { 395 {
399 DEFINE_STATIC_LOCAL(HashSet<StringImpl*>, tagList, ()); 396 // http://www.whatwg.org/specs/web-apps/current-work/#exposed
400 if (tagList.isEmpty()) { 397 for (Node* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNod e()) {
401 const QualifiedName* const* tags = HTMLNames::getHTMLTags(); 398 if (ancestor->hasTagName(objectTag) && toHTMLObjectElement(ancestor)->is Exposed())
402 for (size_t i = 0; i < HTMLNames::HTMLTagsCount; i++) { 399 return false;
403 if (*tags[i] == bgsoundTag
404 || *tags[i] == commandTag
405 || *tags[i] == detailsTag
406 || *tags[i] == figcaptionTag
407 || *tags[i] == figureTag
408 || *tags[i] == summaryTag
409 || *tags[i] == trackTag) {
410 // Even though we have atoms for these tags, we don't want to
411 // treat them as "recognized tags" for the purpose of parsing
412 // because that changes how we parse documents.
413 continue;
414 }
415 tagList.add(tags[i]->localName().impl());
416 }
417 } 400 }
418 return tagList.contains(tagName.localName().impl()); 401 for (Node* node = firstChild(); node; node = NodeTraversal::next(*node, this )) {
419 } 402 if (node->hasTagName(objectTag) || node->hasTagName(embedTag))
420 403 return false;
421 void HTMLObjectElement::updateDocNamedItem()
422 {
423 // The rule is "<object> elements with no children other than
424 // <param> elements, unknown elements and whitespace can be
425 // found by name in a document, and other <object> elements cannot."
426 bool wasNamedItem = m_docNamedItem;
427 bool isNamedItem = true;
428 Node* child = firstChild();
429 while (child && isNamedItem) {
430 if (child->isElementNode()) {
431 Element* element = toElement(child);
432 // FIXME: Use of isRecognizedTagName is almost certainly wrong here.
433 if (isRecognizedTagName(element->tagQName()) && !element->hasTagName (paramTag))
434 isNamedItem = false;
435 } else if (child->isTextNode()) {
436 if (!toText(child)->containsOnlyWhitespace())
437 isNamedItem = false;
438 } else {
439 isNamedItem = false;
440 }
441 child = child->nextSibling();
442 } 404 }
443 if (isNamedItem != wasNamedItem && document().isHTMLDocument()) { 405 return true;
444 HTMLDocument& document = toHTMLDocument(this->document());
445 if (isNamedItem) {
446 document.addNamedItem(getNameAttribute());
447 document.addExtraNamedItem(getIdAttribute());
448 } else {
449 document.removeNamedItem(getNameAttribute());
450 document.removeExtraNamedItem(getIdAttribute());
451 }
452 }
453 m_docNamedItem = isNamedItem;
454 } 406 }
455 407
456 bool HTMLObjectElement::containsJavaApplet() const 408 bool HTMLObjectElement::containsJavaApplet() const
457 { 409 {
458 if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr))) 410 if (MIMETypeRegistry::isJavaAppletMIMEType(getAttribute(typeAttr)))
459 return true; 411 return true;
460 412
461 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSkippingChildren(*child, this)) { 413 for (Element* child = ElementTraversal::firstWithin(*this); child; child = E lementTraversal::nextSkippingChildren(*child, this)) {
462 if (child->hasTagName(paramTag) 414 if (child->hasTagName(paramTag)
463 && equalIgnoringCase(child->getNameAttribute(), "type") 415 && equalIgnoringCase(child->getNameAttribute(), "type")
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 { 467 {
516 return fastHasAttribute(usemapAttr); 468 return fastHasAttribute(usemapAttr);
517 } 469 }
518 470
519 bool HTMLObjectElement::useFallbackContent() const 471 bool HTMLObjectElement::useFallbackContent() const
520 { 472 {
521 return HTMLPlugInElement::useFallbackContent() || m_useFallbackContent; 473 return HTMLPlugInElement::useFallbackContent() || m_useFallbackContent;
522 } 474 }
523 475
524 } 476 }
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