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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 String Document::compatMode() const | 655 String Document::compatMode() const |
656 { | 656 { |
657 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; | 657 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; |
658 } | 658 } |
659 | 659 |
660 void Document::setDocType(PassRefPtr<DocumentType> docType) | 660 void Document::setDocType(PassRefPtr<DocumentType> docType) |
661 { | 661 { |
662 // This should never be called more than once. | 662 // This should never be called more than once. |
663 ASSERT(!m_docType || !docType); | 663 ASSERT(!m_docType || !docType); |
664 m_docType = docType; | 664 m_docType = docType; |
665 if (m_docType) { | 665 if (m_docType) |
666 this->adoptIfNeeded(m_docType.get()); | 666 this->adoptIfNeeded(m_docType.get()); |
667 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.",
/* caseSensitive */ false)) | 667 |
668 processViewport("width=device-width, height=device-height", Viewport
Arguments::XHTMLMobileProfile); | |
669 } | |
670 // Doctype affects the interpretation of the stylesheets. | 668 // Doctype affects the interpretation of the stylesheets. |
671 clearStyleResolver(); | 669 clearStyleResolver(); |
672 } | 670 } |
673 | 671 |
674 DOMImplementation* Document::implementation() | 672 DOMImplementation* Document::implementation() |
675 { | 673 { |
676 if (!m_implementation) | 674 if (!m_implementation) |
677 m_implementation = DOMImplementation::create(this); | 675 m_implementation = DOMImplementation::create(this); |
678 return m_implementation.get(); | 676 return m_implementation.get(); |
679 } | 677 } |
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 PassRefPtr<DocumentParser> Document::createParser() | 2030 PassRefPtr<DocumentParser> Document::createParser() |
2033 { | 2031 { |
2034 if (isHTMLDocument() || (RuntimeEnabledFeatures::parseSVGAsHTMLEnabled() &&
isSVGDocument())) { | 2032 if (isHTMLDocument() || (RuntimeEnabledFeatures::parseSVGAsHTMLEnabled() &&
isSVGDocument())) { |
2035 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors(
this->page()); | 2033 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors(
this->page()); |
2036 return HTMLDocumentParser::create(this, reportErrors); | 2034 return HTMLDocumentParser::create(this, reportErrors); |
2037 } | 2035 } |
2038 // FIXME: this should probably pass the frame instead | 2036 // FIXME: this should probably pass the frame instead |
2039 return XMLDocumentParser::create(this, view()); | 2037 return XMLDocumentParser::create(this, view()); |
2040 } | 2038 } |
2041 | 2039 |
| 2040 bool Document::isXHTMLMobileProfile() const |
| 2041 { |
| 2042 return m_docType && m_docType->publicId().startsWith("-//WAPFORUM//DTD XHTML
MOBILE 1.", /* caseSensitive */ false); |
| 2043 } |
| 2044 |
2042 bool Document::isFrameSet() const | 2045 bool Document::isFrameSet() const |
2043 { | 2046 { |
2044 if (!isHTMLDocument()) | 2047 if (!isHTMLDocument()) |
2045 return false; | 2048 return false; |
2046 HTMLElement* bodyElement = body(); | 2049 HTMLElement* bodyElement = body(); |
2047 return bodyElement && bodyElement->hasTagName(framesetTag); | 2050 return bodyElement && bodyElement->hasTagName(framesetTag); |
2048 } | 2051 } |
2049 | 2052 |
2050 ScriptableDocumentParser* Document::scriptableDocumentParser() const | 2053 ScriptableDocumentParser* Document::scriptableDocumentParser() const |
2051 { | 2054 { |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2834 String message = "Refused to display '" + url().elidedString() + "' in a
frame because it set 'X-Frame-Options' to '" + content + "'."; | 2837 String message = "Refused to display '" + url().elidedString() + "' in a
frame because it set 'X-Frame-Options' to '" + content + "'."; |
2835 frameLoader->stopAllLoaders(); | 2838 frameLoader->stopAllLoaders(); |
2836 // Stopping the loader isn't enough, as we're already parsing the docume
nt; to honor the header's | 2839 // Stopping the loader isn't enough, as we're already parsing the docume
nt; to honor the header's |
2837 // intent, we must navigate away from the possibly partially-rendered do
cument to a location that | 2840 // intent, we must navigate away from the possibly partially-rendered do
cument to a location that |
2838 // doesn't inherit the parent's SecurityOrigin. | 2841 // doesn't inherit the parent's SecurityOrigin. |
2839 frame->navigationScheduler()->scheduleLocationChange(securityOrigin(), S
ecurityOrigin::urlWithUniqueSecurityOrigin(), String()); | 2842 frame->navigationScheduler()->scheduleLocationChange(securityOrigin(), S
ecurityOrigin::urlWithUniqueSecurityOrigin(), String()); |
2840 addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, req
uestIdentifier); | 2843 addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, req
uestIdentifier); |
2841 } | 2844 } |
2842 } | 2845 } |
2843 | 2846 |
2844 // Though isspace() considers \t and \v to be whitespace, Win IE doesn't. | |
2845 static bool isSeparator(UChar c) | |
2846 { | |
2847 return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == '
,' || c == '\0'; | |
2848 } | |
2849 | |
2850 void Document::processArguments(const String& features, void* data, ArgumentsCal
lback callback) | |
2851 { | |
2852 // Tread lightly in this code -- it was specifically designed to mimic Win I
E's parsing behavior. | |
2853 int keyBegin, keyEnd; | |
2854 int valueBegin, valueEnd; | |
2855 | |
2856 int i = 0; | |
2857 int length = features.length(); | |
2858 String buffer = features.lower(); | |
2859 while (i < length) { | |
2860 // skip to first non-separator, but don't skip past the end of the strin
g | |
2861 while (isSeparator(buffer[i])) { | |
2862 if (i >= length) | |
2863 break; | |
2864 i++; | |
2865 } | |
2866 keyBegin = i; | |
2867 | |
2868 // skip to first separator | |
2869 while (!isSeparator(buffer[i])) | |
2870 i++; | |
2871 keyEnd = i; | |
2872 | |
2873 // skip to first '=', but don't skip past a ',' or the end of the string | |
2874 while (buffer[i] != '=') { | |
2875 if (buffer[i] == ',' || i >= length) | |
2876 break; | |
2877 i++; | |
2878 } | |
2879 | |
2880 // skip to first non-separator, but don't skip past a ',' or the end of
the string | |
2881 while (isSeparator(buffer[i])) { | |
2882 if (buffer[i] == ',' || i >= length) | |
2883 break; | |
2884 i++; | |
2885 } | |
2886 valueBegin = i; | |
2887 | |
2888 // skip to first separator | |
2889 while (!isSeparator(buffer[i])) | |
2890 i++; | |
2891 valueEnd = i; | |
2892 | |
2893 ASSERT_WITH_SECURITY_IMPLICATION(i <= length); | |
2894 | |
2895 String keyString = buffer.substring(keyBegin, keyEnd - keyBegin); | |
2896 String valueString = buffer.substring(valueBegin, valueEnd - valueBegin)
; | |
2897 callback(keyString, valueString, this, data); | |
2898 } | |
2899 } | |
2900 | |
2901 void Document::processViewport(const String& features, ViewportArguments::Type o
rigin) | |
2902 { | |
2903 ASSERT(!features.isNull()); | |
2904 | |
2905 if (origin < m_viewportArguments.type) | |
2906 return; | |
2907 | |
2908 m_viewportArguments = ViewportArguments(origin); | |
2909 processArguments(features, (void*)&m_viewportArguments, &setViewportFeature)
; | |
2910 | |
2911 updateViewportArguments(); | |
2912 } | |
2913 | |
2914 void Document::updateViewportArguments() | 2847 void Document::updateViewportArguments() |
2915 { | 2848 { |
2916 if (page() && page()->mainFrame() == frame()) { | 2849 if (page() && page()->mainFrame() == frame()) { |
2917 #ifndef NDEBUG | 2850 #ifndef NDEBUG |
2918 m_didDispatchViewportPropertiesChanged = true; | 2851 m_didDispatchViewportPropertiesChanged = true; |
2919 #endif | 2852 #endif |
2920 page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments
); | 2853 page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments
); |
2921 } | 2854 } |
2922 } | 2855 } |
2923 | 2856 |
(...skipping 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5204 { | 5137 { |
5205 return DocumentLifecycleNotifier::create(this); | 5138 return DocumentLifecycleNotifier::create(this); |
5206 } | 5139 } |
5207 | 5140 |
5208 DocumentLifecycleNotifier* Document::lifecycleNotifier() | 5141 DocumentLifecycleNotifier* Document::lifecycleNotifier() |
5209 { | 5142 { |
5210 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); | 5143 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); |
5211 } | 5144 } |
5212 | 5145 |
5213 } // namespace WebCore | 5146 } // namespace WebCore |
OLD | NEW |