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

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

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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/html/HTMLMeterElement.cpp ('k') | Source/core/html/HTMLOptGroupElement.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) 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 } 195 }
196 196
197 mapDataParamToSrc(&paramNames, &paramValues); 197 mapDataParamToSrc(&paramNames, &paramValues);
198 198
199 // HTML5 says that an object resource's URL is specified by the object's dat a 199 // HTML5 says that an object resource's URL is specified by the object's dat a
200 // attribute, not by a param element. However, for compatibility, allow the 200 // attribute, not by a param element. However, for compatibility, allow the
201 // resource's URL to be given by a param named "src", "movie", "code" or "ur l" 201 // resource's URL to be given by a param named "src", "movie", "code" or "ur l"
202 // if we know that resource points to a plug-in. 202 // if we know that resource points to a plug-in.
203 if (url.isEmpty() && !urlParameter.isEmpty()) { 203 if (url.isEmpty() && !urlParameter.isEmpty()) {
204 KURL completedURL = document()->completeURL(urlParameter); 204 KURL completedURL = document().completeURL(urlParameter);
205 bool useFallback; 205 bool useFallback;
206 if (shouldUsePlugin(completedURL, serviceType, false, useFallback)) 206 if (shouldUsePlugin(completedURL, serviceType, false, useFallback))
207 url = urlParameter; 207 url = urlParameter;
208 } 208 }
209 } 209 }
210 210
211 211
212 bool HTMLObjectElement::hasFallbackContent() const 212 bool HTMLObjectElement::hasFallbackContent() const
213 { 213 {
214 for (Node* child = firstChild(); child; child = child->nextSibling()) { 214 for (Node* child = firstChild(); child; child = child->nextSibling()) {
215 // Ignore whitespace-only text, and <param> tags, any other content is f allback content. 215 // Ignore whitespace-only text, and <param> tags, any other content is f allback content.
216 if (child->isTextNode()) { 216 if (child->isTextNode()) {
217 if (!toText(child)->containsOnlyWhitespace()) 217 if (!toText(child)->containsOnlyWhitespace())
218 return true; 218 return true;
219 } else if (!child->hasTagName(paramTag)) 219 } else if (!child->hasTagName(paramTag))
220 return true; 220 return true;
221 } 221 }
222 return false; 222 return false;
223 } 223 }
224 224
225 bool HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk() 225 bool HTMLObjectElement::shouldAllowQuickTimeClassIdQuirk()
226 { 226 {
227 // This site-specific hack maintains compatibility with Mac OS X Wiki Server , 227 // This site-specific hack maintains compatibility with Mac OS X Wiki Server ,
228 // which embeds QuickTime movies using an object tag containing QuickTime's 228 // which embeds QuickTime movies using an object tag containing QuickTime's
229 // ActiveX classid. Treat this classid as valid only if OS X Server's unique 229 // ActiveX classid. Treat this classid as valid only if OS X Server's unique
230 // 'generator' meta tag is present. Only apply this quirk if there is no 230 // 'generator' meta tag is present. Only apply this quirk if there is no
231 // fallback content, which ensures the quirk will disable itself if Wiki 231 // fallback content, which ensures the quirk will disable itself if Wiki
232 // Server is updated to generate an alternate embed tag as fallback content. 232 // Server is updated to generate an alternate embed tag as fallback content.
233 if (!document()->page() 233 if (!document().page()
234 || !document()->page()->settings().needsSiteSpecificQuirks() 234 || !document().page()->settings().needsSiteSpecificQuirks()
235 || hasFallbackContent() 235 || hasFallbackContent()
236 || !equalIgnoringCase(classId(), "clsid:02BF25D5-8C17-4B23-BC80-D3488ABD DC6B")) 236 || !equalIgnoringCase(classId(), "clsid:02BF25D5-8C17-4B23-BC80-D3488ABD DC6B"))
237 return false; 237 return false;
238 238
239 RefPtr<NodeList> metaElements = document()->getElementsByTagName(HTMLNames:: metaTag.localName()); 239 RefPtr<NodeList> metaElements = document().getElementsByTagName(HTMLNames::m etaTag.localName());
240 unsigned length = metaElements->length(); 240 unsigned length = metaElements->length();
241 for (unsigned i = 0; i < length; ++i) { 241 for (unsigned i = 0; i < length; ++i) {
242 ASSERT(metaElements->item(i)->isHTMLElement()); 242 ASSERT(metaElements->item(i)->isHTMLElement());
243 HTMLMetaElement* metaElement = static_cast<HTMLMetaElement*>(metaElement s->item(i)); 243 HTMLMetaElement* metaElement = static_cast<HTMLMetaElement*>(metaElement s->item(i));
244 if (equalIgnoringCase(metaElement->name(), "generator") && metaElement-> content().startsWith("Mac OS X Server Web Services Server", false)) 244 if (equalIgnoringCase(metaElement->name(), "generator") && metaElement-> content().startsWith("Mac OS X Server Web Services Server", false))
245 return true; 245 return true;
246 } 246 }
247 247
248 return false; 248 return false;
249 } 249 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return; 308 return;
309 309
310 bool success = beforeLoadAllowedLoad && hasValidClassId() && requestObject(u rl, serviceType, paramNames, paramValues); 310 bool success = beforeLoadAllowedLoad && hasValidClassId() && requestObject(u rl, serviceType, paramNames, paramValues);
311 if (!success && fallbackContent) 311 if (!success && fallbackContent)
312 renderFallbackContent(); 312 renderFallbackContent();
313 } 313 }
314 314
315 bool HTMLObjectElement::rendererIsNeeded(const NodeRenderingContext& context) 315 bool HTMLObjectElement::rendererIsNeeded(const NodeRenderingContext& context)
316 { 316 {
317 // FIXME: This check should not be needed, detached documents never render! 317 // FIXME: This check should not be needed, detached documents never render!
318 Frame* frame = document()->frame(); 318 Frame* frame = document().frame();
319 if (!frame) 319 if (!frame)
320 return false; 320 return false;
321 321
322 return HTMLPlugInImageElement::rendererIsNeeded(context); 322 return HTMLPlugInImageElement::rendererIsNeeded(context);
323 } 323 }
324 324
325 Node::InsertionNotificationRequest HTMLObjectElement::insertedInto(ContainerNode * insertionPoint) 325 Node::InsertionNotificationRequest HTMLObjectElement::insertedInto(ContainerNode * insertionPoint)
326 { 326 {
327 HTMLPlugInImageElement::insertedInto(insertionPoint); 327 HTMLPlugInImageElement::insertedInto(insertionPoint);
328 FormAssociatedElement::insertedInto(insertionPoint); 328 FormAssociatedElement::insertedInto(insertionPoint);
(...skipping 24 matching lines...) Expand all
353 const AtomicString& HTMLObjectElement::imageSourceURL() const 353 const AtomicString& HTMLObjectElement::imageSourceURL() const
354 { 354 {
355 return getAttribute(dataAttr); 355 return getAttribute(dataAttr);
356 } 356 }
357 357
358 // FIXME: Remove this hack. 358 // FIXME: Remove this hack.
359 void HTMLObjectElement::reattachFallbackContent() 359 void HTMLObjectElement::reattachFallbackContent()
360 { 360 {
361 // This can happen inside of attach() in the middle of a recalcStyle so we n eed to 361 // This can happen inside of attach() in the middle of a recalcStyle so we n eed to
362 // reattach synchronously here. 362 // reattach synchronously here.
363 if (document()->inStyleRecalc()) 363 if (document().inStyleRecalc())
364 reattach(); 364 reattach();
365 else 365 else
366 lazyReattach(); 366 lazyReattach();
367 } 367 }
368 368
369 void HTMLObjectElement::renderFallbackContent() 369 void HTMLObjectElement::renderFallbackContent()
370 { 370 {
371 if (useFallbackContent()) 371 if (useFallbackContent())
372 return; 372 return;
373 373
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // FIXME: Use of isRecognizedTagName is almost certainly wrong here. 430 // FIXME: Use of isRecognizedTagName is almost certainly wrong here.
431 if (isRecognizedTagName(element->tagQName()) && !element->hasTagName (paramTag)) 431 if (isRecognizedTagName(element->tagQName()) && !element->hasTagName (paramTag))
432 isNamedItem = false; 432 isNamedItem = false;
433 } else if (child->isTextNode()) { 433 } else if (child->isTextNode()) {
434 if (!toText(child)->containsOnlyWhitespace()) 434 if (!toText(child)->containsOnlyWhitespace())
435 isNamedItem = false; 435 isNamedItem = false;
436 } else 436 } else
437 isNamedItem = false; 437 isNamedItem = false;
438 child = child->nextSibling(); 438 child = child->nextSibling();
439 } 439 }
440 if (isNamedItem != wasNamedItem && document()->isHTMLDocument()) { 440 if (isNamedItem != wasNamedItem && document().isHTMLDocument()) {
441 HTMLDocument* document = toHTMLDocument(this->document()); 441 HTMLDocument* document = toHTMLDocument(&this->document());
442 if (isNamedItem) { 442 if (isNamedItem) {
443 document->addNamedItem(getNameAttribute()); 443 document->addNamedItem(getNameAttribute());
444 document->addExtraNamedItem(getIdAttribute()); 444 document->addExtraNamedItem(getIdAttribute());
445 } else { 445 } else {
446 document->removeNamedItem(getNameAttribute()); 446 document->removeNamedItem(getNameAttribute());
447 document->removeExtraNamedItem(getIdAttribute()); 447 document->removeExtraNamedItem(getIdAttribute());
448 } 448 }
449 } 449 }
450 m_docNamedItem = isNamedItem; 450 m_docNamedItem = isNamedItem;
451 } 451 }
(...skipping 14 matching lines...) Expand all
466 return true; 466 return true;
467 } 467 }
468 468
469 return false; 469 return false;
470 } 470 }
471 471
472 void HTMLObjectElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) con st 472 void HTMLObjectElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) con st
473 { 473 {
474 HTMLPlugInImageElement::addSubresourceAttributeURLs(urls); 474 HTMLPlugInImageElement::addSubresourceAttributeURLs(urls);
475 475
476 addSubresourceURL(urls, document()->completeURL(getAttribute(dataAttr))); 476 addSubresourceURL(urls, document().completeURL(getAttribute(dataAttr)));
477 477
478 // FIXME: Passing a string that starts with "#" to the completeURL function does 478 // FIXME: Passing a string that starts with "#" to the completeURL function does
479 // not seem like it would work. The image element has similar but not identi cal code. 479 // not seem like it would work. The image element has similar but not identi cal code.
480 const AtomicString& useMap = getAttribute(usemapAttr); 480 const AtomicString& useMap = getAttribute(usemapAttr);
481 if (useMap.startsWith('#')) 481 if (useMap.startsWith('#'))
482 addSubresourceURL(urls, document()->completeURL(useMap)); 482 addSubresourceURL(urls, document().completeURL(useMap));
483 } 483 }
484 484
485 void HTMLObjectElement::didMoveToNewDocument(Document* oldDocument) 485 void HTMLObjectElement::didMoveToNewDocument(Document* oldDocument)
486 { 486 {
487 FormAssociatedElement::didMoveToNewDocument(oldDocument); 487 FormAssociatedElement::didMoveToNewDocument(oldDocument);
488 HTMLPlugInImageElement::didMoveToNewDocument(oldDocument); 488 HTMLPlugInImageElement::didMoveToNewDocument(oldDocument);
489 } 489 }
490 490
491 bool HTMLObjectElement::appendFormData(FormDataList& encoding, bool) 491 bool HTMLObjectElement::appendFormData(FormDataList& encoding, bool)
492 { 492 {
493 if (name().isEmpty()) 493 if (name().isEmpty())
494 return false; 494 return false;
495 495
496 Widget* widget = pluginWidget(); 496 Widget* widget = pluginWidget();
497 if (!widget || !widget->isPluginView()) 497 if (!widget || !widget->isPluginView())
498 return false; 498 return false;
499 String value; 499 String value;
500 if (!toPluginView(widget)->getFormValue(value)) 500 if (!toPluginView(widget)->getFormValue(value))
501 return false; 501 return false;
502 encoding.appendData(name(), value); 502 encoding.appendData(name(), value);
503 return true; 503 return true;
504 } 504 }
505 505
506 HTMLFormElement* HTMLObjectElement::virtualForm() const 506 HTMLFormElement* HTMLObjectElement::virtualForm() const
507 { 507 {
508 return FormAssociatedElement::form(); 508 return FormAssociatedElement::form();
509 } 509 }
510 510
511 } 511 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMeterElement.cpp ('k') | Source/core/html/HTMLOptGroupElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698