| OLD | NEW |
| 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) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 String Document::compatMode() const | 660 String Document::compatMode() const |
| 661 { | 661 { |
| 662 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; | 662 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; |
| 663 } | 663 } |
| 664 | 664 |
| 665 void Document::setDocType(PassRefPtr<DocumentType> docType) | 665 void Document::setDocType(PassRefPtr<DocumentType> docType) |
| 666 { | 666 { |
| 667 // This should never be called more than once. | 667 // This should never be called more than once. |
| 668 ASSERT(!m_docType || !docType); | 668 ASSERT(!m_docType || !docType); |
| 669 m_docType = docType; | 669 m_docType = docType; |
| 670 if (m_docType) { | 670 if (m_docType) |
| 671 this->adoptIfNeeded(m_docType.get()); | 671 this->adoptIfNeeded(m_docType.get()); |
| 672 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.",
/* caseSensitive */ false)) | 672 |
| 673 processViewport("width=device-width, height=device-height", Viewport
Arguments::XHTMLMobileProfile); | |
| 674 } | |
| 675 // Doctype affects the interpretation of the stylesheets. | 673 // Doctype affects the interpretation of the stylesheets. |
| 676 clearStyleResolver(); | 674 clearStyleResolver(); |
| 677 } | 675 } |
| 678 | 676 |
| 679 DOMImplementation* Document::implementation() | 677 DOMImplementation* Document::implementation() |
| 680 { | 678 { |
| 681 if (!m_implementation) | 679 if (!m_implementation) |
| 682 m_implementation = DOMImplementation::create(this); | 680 m_implementation = DOMImplementation::create(this); |
| 683 return m_implementation.get(); | 681 return m_implementation.get(); |
| 684 } | 682 } |
| (...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2011 PassRefPtr<DocumentParser> Document::createParser() | 2009 PassRefPtr<DocumentParser> Document::createParser() |
| 2012 { | 2010 { |
| 2013 if (isHTMLDocument() || (RuntimeEnabledFeatures::parseSVGAsHTMLEnabled() &&
isSVGDocument())) { | 2011 if (isHTMLDocument() || (RuntimeEnabledFeatures::parseSVGAsHTMLEnabled() &&
isSVGDocument())) { |
| 2014 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors(
this->page()); | 2012 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors(
this->page()); |
| 2015 return HTMLDocumentParser::create(this, reportErrors); | 2013 return HTMLDocumentParser::create(this, reportErrors); |
| 2016 } | 2014 } |
| 2017 // FIXME: this should probably pass the frame instead | 2015 // FIXME: this should probably pass the frame instead |
| 2018 return XMLDocumentParser::create(this, view()); | 2016 return XMLDocumentParser::create(this, view()); |
| 2019 } | 2017 } |
| 2020 | 2018 |
| 2019 bool Document::isXHTMLMobileProfile() const |
| 2020 { |
| 2021 return m_docType && m_docType->publicId().startsWith("-//WAPFORUM//DTD XHTML
MOBILE 1.", /* caseSensitive */ false); |
| 2022 } |
| 2023 |
| 2021 bool Document::isFrameSet() const | 2024 bool Document::isFrameSet() const |
| 2022 { | 2025 { |
| 2023 if (!isHTMLDocument()) | 2026 if (!isHTMLDocument()) |
| 2024 return false; | 2027 return false; |
| 2025 HTMLElement* bodyElement = body(); | 2028 HTMLElement* bodyElement = body(); |
| 2026 return bodyElement && bodyElement->hasTagName(framesetTag); | 2029 return bodyElement && bodyElement->hasTagName(framesetTag); |
| 2027 } | 2030 } |
| 2028 | 2031 |
| 2029 ScriptableDocumentParser* Document::scriptableDocumentParser() const | 2032 ScriptableDocumentParser* Document::scriptableDocumentParser() const |
| 2030 { | 2033 { |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2697 String message = "Refused to display '" + url().elidedString() + "' in a
frame because it set 'X-Frame-Options' to '" + content + "'."; | 2700 String message = "Refused to display '" + url().elidedString() + "' in a
frame because it set 'X-Frame-Options' to '" + content + "'."; |
| 2698 frameLoader->stopAllLoaders(); | 2701 frameLoader->stopAllLoaders(); |
| 2699 // Stopping the loader isn't enough, as we're already parsing the docume
nt; to honor the header's | 2702 // Stopping the loader isn't enough, as we're already parsing the docume
nt; to honor the header's |
| 2700 // intent, we must navigate away from the possibly partially-rendered do
cument to a location that | 2703 // intent, we must navigate away from the possibly partially-rendered do
cument to a location that |
| 2701 // doesn't inherit the parent's SecurityOrigin. | 2704 // doesn't inherit the parent's SecurityOrigin. |
| 2702 frame->navigationScheduler()->scheduleLocationChange(securityOrigin(), S
ecurityOrigin::urlWithUniqueSecurityOrigin(), String()); | 2705 frame->navigationScheduler()->scheduleLocationChange(securityOrigin(), S
ecurityOrigin::urlWithUniqueSecurityOrigin(), String()); |
| 2703 addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, req
uestIdentifier); | 2706 addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, req
uestIdentifier); |
| 2704 } | 2707 } |
| 2705 } | 2708 } |
| 2706 | 2709 |
| 2707 // Though isspace() considers \t and \v to be whitespace, Win IE doesn't. | |
| 2708 static bool isSeparator(UChar c) | |
| 2709 { | |
| 2710 return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == '
,' || c == '\0'; | |
| 2711 } | |
| 2712 | |
| 2713 void Document::processArguments(const String& features, void* data, ArgumentsCal
lback callback) | |
| 2714 { | |
| 2715 // Tread lightly in this code -- it was specifically designed to mimic Win I
E's parsing behavior. | |
| 2716 int keyBegin, keyEnd; | |
| 2717 int valueBegin, valueEnd; | |
| 2718 | |
| 2719 int i = 0; | |
| 2720 int length = features.length(); | |
| 2721 String buffer = features.lower(); | |
| 2722 while (i < length) { | |
| 2723 // skip to first non-separator, but don't skip past the end of the strin
g | |
| 2724 while (isSeparator(buffer[i])) { | |
| 2725 if (i >= length) | |
| 2726 break; | |
| 2727 i++; | |
| 2728 } | |
| 2729 keyBegin = i; | |
| 2730 | |
| 2731 // skip to first separator | |
| 2732 while (!isSeparator(buffer[i])) | |
| 2733 i++; | |
| 2734 keyEnd = i; | |
| 2735 | |
| 2736 // skip to first '=', but don't skip past a ',' or the end of the string | |
| 2737 while (buffer[i] != '=') { | |
| 2738 if (buffer[i] == ',' || i >= length) | |
| 2739 break; | |
| 2740 i++; | |
| 2741 } | |
| 2742 | |
| 2743 // skip to first non-separator, but don't skip past a ',' or the end of
the string | |
| 2744 while (isSeparator(buffer[i])) { | |
| 2745 if (buffer[i] == ',' || i >= length) | |
| 2746 break; | |
| 2747 i++; | |
| 2748 } | |
| 2749 valueBegin = i; | |
| 2750 | |
| 2751 // skip to first separator | |
| 2752 while (!isSeparator(buffer[i])) | |
| 2753 i++; | |
| 2754 valueEnd = i; | |
| 2755 | |
| 2756 ASSERT_WITH_SECURITY_IMPLICATION(i <= length); | |
| 2757 | |
| 2758 String keyString = buffer.substring(keyBegin, keyEnd - keyBegin); | |
| 2759 String valueString = buffer.substring(valueBegin, valueEnd - valueBegin)
; | |
| 2760 callback(keyString, valueString, this, data); | |
| 2761 } | |
| 2762 } | |
| 2763 | |
| 2764 void Document::processViewport(const String& features, ViewportArguments::Type o
rigin) | |
| 2765 { | |
| 2766 ASSERT(!features.isNull()); | |
| 2767 | |
| 2768 if (origin < m_viewportArguments.type) | |
| 2769 return; | |
| 2770 | |
| 2771 m_viewportArguments = ViewportArguments(origin); | |
| 2772 processArguments(features, (void*)&m_viewportArguments, &setViewportFeature)
; | |
| 2773 | |
| 2774 updateViewportArguments(); | |
| 2775 } | |
| 2776 | |
| 2777 void Document::updateViewportArguments() | 2710 void Document::updateViewportArguments() |
| 2778 { | 2711 { |
| 2779 if (page() && page()->mainFrame() == frame()) { | 2712 if (page() && page()->mainFrame() == frame()) { |
| 2780 #ifndef NDEBUG | 2713 #ifndef NDEBUG |
| 2781 m_didDispatchViewportPropertiesChanged = true; | 2714 m_didDispatchViewportPropertiesChanged = true; |
| 2782 #endif | 2715 #endif |
| 2783 page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments
); | 2716 page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments
); |
| 2784 } | 2717 } |
| 2785 } | 2718 } |
| 2786 | 2719 |
| (...skipping 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5151 { | 5084 { |
| 5152 return DocumentLifecycleNotifier::create(this); | 5085 return DocumentLifecycleNotifier::create(this); |
| 5153 } | 5086 } |
| 5154 | 5087 |
| 5155 DocumentLifecycleNotifier* Document::lifecycleNotifier() | 5088 DocumentLifecycleNotifier* Document::lifecycleNotifier() |
| 5156 { | 5089 { |
| 5157 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); | 5090 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); |
| 5158 } | 5091 } |
| 5159 | 5092 |
| 5160 } // namespace WebCore | 5093 } // namespace WebCore |
| OLD | NEW |