| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) | 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) |
| 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) | 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) |
| 5 * (C) 2001 Peter Kelly (pmk@post.com) | 5 * (C) 2001 Peter Kelly (pmk@post.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. | 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 element = nullptr; | 877 element = nullptr; |
| 878 else if (node->isElementNode()) | 878 else if (node->isElementNode()) |
| 879 element = toElement(node); | 879 element = toElement(node); |
| 880 else | 880 else |
| 881 element = node->parentElement(); | 881 element = node->parentElement(); |
| 882 | 882 |
| 883 // Step 2. | 883 // Step 2. |
| 884 if (!element || isHTMLHtmlElement(element)) { | 884 if (!element || isHTMLHtmlElement(element)) { |
| 885 Document& document = node->document(); | 885 Document& document = node->document(); |
| 886 | 886 |
| 887 if (document.isHTMLDocument() || document.isXHTMLDocument()) { | 887 if (document.isSVGDocument()) { |
| 888 element = document.documentElement(); |
| 889 if (!element) |
| 890 element = SVGSVGElement::create(document); |
| 891 } else { |
| 888 // Optimization over spec: try to reuse the existing <body> element,
if it is available. | 892 // Optimization over spec: try to reuse the existing <body> element,
if it is available. |
| 889 element = document.body(); | 893 element = document.body(); |
| 890 if (!element) | 894 if (!element) |
| 891 element = HTMLBodyElement::create(document); | 895 element = HTMLBodyElement::create(document); |
| 892 } else if (document.isSVGDocument()) { | |
| 893 element = document.documentElement(); | |
| 894 if (!element) | |
| 895 element = SVGSVGElement::create(document); | |
| 896 } | 896 } |
| 897 } | 897 } |
| 898 | 898 |
| 899 if (!element || (!element->isHTMLElement() && !element->isSVGElement())) { | |
| 900 exceptionState.throwDOMException(NotSupportedError, "The range's contain
er must be an HTML or SVG Element, Document, or DocumentFragment."); | |
| 901 return nullptr; | |
| 902 } | |
| 903 | |
| 904 // Steps 3, 4, 5. | 899 // Steps 3, 4, 5. |
| 905 DocumentFragment* fragment = blink::createContextualFragment(markup, element
, AllowScriptingContentAndDoNotMarkAlreadyStarted, exceptionState); | 900 return blink::createContextualFragment(markup, element, AllowScriptingConten
tAndDoNotMarkAlreadyStarted, exceptionState); |
| 906 if (!fragment) | |
| 907 return nullptr; | |
| 908 | |
| 909 return fragment; | |
| 910 } | 901 } |
| 911 | 902 |
| 912 | 903 |
| 913 void Range::detach() | 904 void Range::detach() |
| 914 { | 905 { |
| 915 // This is now a no-op as per the DOM specification. | 906 // This is now a no-op as per the DOM specification. |
| 916 } | 907 } |
| 917 | 908 |
| 918 Node* Range::checkNodeWOffset(Node* n, int offset, ExceptionState& exceptionStat
e) | 909 Node* Range::checkNodeWOffset(Node* n, int offset, ExceptionState& exceptionStat
e) |
| 919 { | 910 { |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 if (range && range->boundaryPointsValid()) { | 1565 if (range && range->boundaryPointsValid()) { |
| 1575 LOG(INFO) << "\n" | 1566 LOG(INFO) << "\n" |
| 1576 << range->startContainer()->toMarkedTreeString(range->startContainer
(), "S", range->endContainer(), "E").utf8().data() | 1567 << range->startContainer()->toMarkedTreeString(range->startContainer
(), "S", range->endContainer(), "E").utf8().data() |
| 1577 << "start offset: " << range->startOffset() << ", end offset: " << r
ange->endOffset(); | 1568 << "start offset: " << range->startOffset() << ", end offset: " << r
ange->endOffset(); |
| 1578 } else { | 1569 } else { |
| 1579 LOG(INFO) << "Cannot show tree if range is null, or if boundary points a
re invalid."; | 1570 LOG(INFO) << "Cannot show tree if range is null, or if boundary points a
re invalid."; |
| 1580 } | 1571 } |
| 1581 } | 1572 } |
| 1582 | 1573 |
| 1583 #endif | 1574 #endif |
| OLD | NEW |