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

Side by Side Diff: WebCore/html/HTMLElement.cpp

Issue 3400014: Merge 67292 - 2010-09-11 Mihai Parparita <mihaip@chromium.org>... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/517/
Patch Set: Created 10 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
« no previous file with comments | « WebCore/html/HTMLDocument.cpp ('k') | WebCore/html/parser/HTMLTreeBuilder.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 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 String HTMLElement::innerHTML() const 259 String HTMLElement::innerHTML() const
260 { 260 {
261 return createMarkup(this, ChildrenOnly); 261 return createMarkup(this, ChildrenOnly);
262 } 262 }
263 263
264 String HTMLElement::outerHTML() const 264 String HTMLElement::outerHTML() const
265 { 265 {
266 return createMarkup(this); 266 return createMarkup(this);
267 } 267 }
268 268
269 static bool useLegacyTreeBuilder(Document*)
270 {
271 return false;
272 }
273
274 // FIXME: This logic should move into Range::createContextualFragment 269 // FIXME: This logic should move into Range::createContextualFragment
275 PassRefPtr<DocumentFragment> HTMLElement::deprecatedCreateContextualFragment(con st String& markup, FragmentScriptingPermission scriptingPermission) 270 PassRefPtr<DocumentFragment> HTMLElement::deprecatedCreateContextualFragment(con st String& markup, FragmentScriptingPermission scriptingPermission)
276 { 271 {
277 // The following is in accordance with the definition as used by IE. 272 // The following is in accordance with the definition as used by IE.
278 if (ieForbidsInsertHTML()) 273 if (ieForbidsInsertHTML())
279 return 0; 274 return 0;
280 275
281 if (hasLocalName(colTag) || hasLocalName(colgroupTag) || hasLocalName(frames etTag) 276 if (hasLocalName(colTag) || hasLocalName(colgroupTag) || hasLocalName(frames etTag)
282 || hasLocalName(headTag) || hasLocalName(styleTag) || hasLocalName(title Tag)) 277 || hasLocalName(headTag) || hasLocalName(styleTag) || hasLocalName(title Tag))
283 return 0; 278 return 0;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 element->removeChildren(); 329 element->removeChildren();
335 element->appendChild(textNode.release(), ec); 330 element->appendChild(textNode.release(), ec);
336 } 331 }
337 332
338 // We may want to move a version of this function into DocumentFragment.h/cpp 333 // We may want to move a version of this function into DocumentFragment.h/cpp
339 static PassRefPtr<DocumentFragment> createFragmentFromSource(const String& marku p, Element* contextElement, ExceptionCode& ec) 334 static PassRefPtr<DocumentFragment> createFragmentFromSource(const String& marku p, Element* contextElement, ExceptionCode& ec)
340 { 335 {
341 Document* document = contextElement->document(); 336 Document* document = contextElement->document();
342 RefPtr<DocumentFragment> fragment; 337 RefPtr<DocumentFragment> fragment;
343 338
344 if (useLegacyTreeBuilder(document)) {
345 fragment = contextElement->deprecatedCreateContextualFragment(markup);
346 if (!fragment)
347 ec = NO_MODIFICATION_ALLOWED_ERR;
348 return fragment;
349 }
350
351 fragment = DocumentFragment::create(document); 339 fragment = DocumentFragment::create(document);
352 if (document->isHTMLDocument()) { 340 if (document->isHTMLDocument()) {
353 fragment->parseHTML(markup, contextElement); 341 fragment->parseHTML(markup, contextElement);
354 return fragment; 342 return fragment;
355 } 343 }
356 344
357 bool wasValid = fragment->parseXML(markup, contextElement); 345 bool wasValid = fragment->parseXML(markup, contextElement);
358 if (!wasValid) { 346 if (!wasValid) {
359 ec = INVALID_STATE_ERR; 347 ec = INVALID_STATE_ERR;
360 return 0; 348 return 0;
361 } 349 }
362 return fragment; 350 return fragment;
363 } 351 }
364 352
365 void HTMLElement::setInnerHTML(const String& html, ExceptionCode& ec) 353 void HTMLElement::setInnerHTML(const String& html, ExceptionCode& ec)
366 { 354 {
367 // FIXME: This code can be removed, it's handled by the HTMLDocumentParser c orrectly.
368 if (useLegacyTreeBuilder(document()) && (hasLocalName(scriptTag) || hasLocal Name(styleTag))) {
369 // Script and CSS source shouldn't be parsed as HTML.
370 removeChildren();
371 appendChild(document()->createTextNode(html), ec);
372 return;
373 }
374
375 RefPtr<DocumentFragment> fragment = createFragmentFromSource(html, this, ec) ; 355 RefPtr<DocumentFragment> fragment = createFragmentFromSource(html, this, ec) ;
376 if (fragment) 356 if (fragment)
377 replaceChildrenWithFragment(this, fragment.release(), ec); 357 replaceChildrenWithFragment(this, fragment.release(), ec);
378 } 358 }
379 359
380 void HTMLElement::setOuterHTML(const String& html, ExceptionCode& ec) 360 void HTMLElement::setOuterHTML(const String& html, ExceptionCode& ec)
381 { 361 {
382 Node* p = parent(); 362 Node* p = parent();
383 if (!p || !p->isHTMLElement()) { 363 if (!p || !p->isHTMLElement()) {
384 ec = NO_MODIFICATION_ALLOWED_ERR; 364 ec = NO_MODIFICATION_ALLOWED_ERR;
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 #ifndef NDEBUG 809 #ifndef NDEBUG
830 810
831 // For use in the debugger 811 // For use in the debugger
832 void dumpInnerHTML(WebCore::HTMLElement*); 812 void dumpInnerHTML(WebCore::HTMLElement*);
833 813
834 void dumpInnerHTML(WebCore::HTMLElement* element) 814 void dumpInnerHTML(WebCore::HTMLElement* element)
835 { 815 {
836 printf("%s\n", element->innerHTML().ascii().data()); 816 printf("%s\n", element->innerHTML().ascii().data());
837 } 817 }
838 #endif 818 #endif
OLDNEW
« no previous file with comments | « WebCore/html/HTMLDocument.cpp ('k') | WebCore/html/parser/HTMLTreeBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698