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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 String Document::compatMode() const | 659 String Document::compatMode() const |
660 { | 660 { |
661 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; | 661 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; |
662 } | 662 } |
663 | 663 |
664 void Document::setDocType(PassRefPtr<DocumentType> docType) | 664 void Document::setDocType(PassRefPtr<DocumentType> docType) |
665 { | 665 { |
666 // This should never be called more than once. | 666 // This should never be called more than once. |
667 ASSERT(!m_docType || !docType); | 667 ASSERT(!m_docType || !docType); |
668 m_docType = docType; | 668 m_docType = docType; |
669 if (m_docType) { | 669 if (m_docType) |
670 this->adoptIfNeeded(m_docType.get()); | 670 this->adoptIfNeeded(m_docType.get()); |
671 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.",
/* caseSensitive */ false)) | 671 |
672 processViewport("width=device-width, height=device-height", Viewport
Arguments::XHTMLMobileProfile); | |
673 } | |
674 // Doctype affects the interpretation of the stylesheets. | 672 // Doctype affects the interpretation of the stylesheets. |
675 clearStyleResolver(); | 673 clearStyleResolver(); |
676 } | 674 } |
677 | 675 |
678 DOMImplementation* Document::implementation() | 676 DOMImplementation* Document::implementation() |
679 { | 677 { |
680 if (!m_implementation) | 678 if (!m_implementation) |
681 m_implementation = DOMImplementation::create(this); | 679 m_implementation = DOMImplementation::create(this); |
682 return m_implementation.get(); | 680 return m_implementation.get(); |
683 } | 681 } |
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 PassRefPtr<DocumentParser> Document::createParser() | 2013 PassRefPtr<DocumentParser> Document::createParser() |
2016 { | 2014 { |
2017 if (isHTMLDocument() || (RuntimeEnabledFeatures::parseSVGAsHTMLEnabled() &&
isSVGDocument())) { | 2015 if (isHTMLDocument() || (RuntimeEnabledFeatures::parseSVGAsHTMLEnabled() &&
isSVGDocument())) { |
2018 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors(
this->page()); | 2016 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors(
this->page()); |
2019 return HTMLDocumentParser::create(this, reportErrors); | 2017 return HTMLDocumentParser::create(this, reportErrors); |
2020 } | 2018 } |
2021 // FIXME: this should probably pass the frame instead | 2019 // FIXME: this should probably pass the frame instead |
2022 return XMLDocumentParser::create(this, view()); | 2020 return XMLDocumentParser::create(this, view()); |
2023 } | 2021 } |
2024 | 2022 |
| 2023 bool Document::isXHTMLMobileProfile() const |
| 2024 { |
| 2025 return m_docType && m_docType->publicId().startsWith("-//WAPFORUM//DTD XHTML
MOBILE 1.", /* caseSensitive */ false); |
| 2026 } |
| 2027 |
2025 bool Document::isFrameSet() const | 2028 bool Document::isFrameSet() const |
2026 { | 2029 { |
2027 if (!isHTMLDocument()) | 2030 if (!isHTMLDocument()) |
2028 return false; | 2031 return false; |
2029 HTMLElement* bodyElement = body(); | 2032 HTMLElement* bodyElement = body(); |
2030 return bodyElement && bodyElement->hasTagName(framesetTag); | 2033 return bodyElement && bodyElement->hasTagName(framesetTag); |
2031 } | 2034 } |
2032 | 2035 |
2033 ScriptableDocumentParser* Document::scriptableDocumentParser() const | 2036 ScriptableDocumentParser* Document::scriptableDocumentParser() const |
2034 { | 2037 { |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2709 String message = "Refused to display '" + url().elidedString() + "' in a
frame because it set 'X-Frame-Options' to '" + content + "'."; | 2712 String message = "Refused to display '" + url().elidedString() + "' in a
frame because it set 'X-Frame-Options' to '" + content + "'."; |
2710 frameLoader->stopAllLoaders(); | 2713 frameLoader->stopAllLoaders(); |
2711 // Stopping the loader isn't enough, as we're already parsing the docume
nt; to honor the header's | 2714 // Stopping the loader isn't enough, as we're already parsing the docume
nt; to honor the header's |
2712 // intent, we must navigate away from the possibly partially-rendered do
cument to a location that | 2715 // intent, we must navigate away from the possibly partially-rendered do
cument to a location that |
2713 // doesn't inherit the parent's SecurityOrigin. | 2716 // doesn't inherit the parent's SecurityOrigin. |
2714 frame->navigationScheduler()->scheduleLocationChange(securityOrigin(), S
ecurityOrigin::urlWithUniqueSecurityOrigin(), String()); | 2717 frame->navigationScheduler()->scheduleLocationChange(securityOrigin(), S
ecurityOrigin::urlWithUniqueSecurityOrigin(), String()); |
2715 addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, req
uestIdentifier); | 2718 addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, req
uestIdentifier); |
2716 } | 2719 } |
2717 } | 2720 } |
2718 | 2721 |
2719 // Though isspace() considers \t and \v to be whitespace, Win IE doesn't. | |
2720 static bool isSeparator(UChar c) | |
2721 { | |
2722 return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == '
,' || c == '\0'; | |
2723 } | |
2724 | |
2725 void Document::processArguments(const String& features, void* data, ArgumentsCal
lback callback) | |
2726 { | |
2727 // Tread lightly in this code -- it was specifically designed to mimic Win I
E's parsing behavior. | |
2728 int keyBegin, keyEnd; | |
2729 int valueBegin, valueEnd; | |
2730 | |
2731 int i = 0; | |
2732 int length = features.length(); | |
2733 String buffer = features.lower(); | |
2734 while (i < length) { | |
2735 // skip to first non-separator, but don't skip past the end of the strin
g | |
2736 while (isSeparator(buffer[i])) { | |
2737 if (i >= length) | |
2738 break; | |
2739 i++; | |
2740 } | |
2741 keyBegin = i; | |
2742 | |
2743 // skip to first separator | |
2744 while (!isSeparator(buffer[i])) | |
2745 i++; | |
2746 keyEnd = i; | |
2747 | |
2748 // skip to first '=', but don't skip past a ',' or the end of the string | |
2749 while (buffer[i] != '=') { | |
2750 if (buffer[i] == ',' || i >= length) | |
2751 break; | |
2752 i++; | |
2753 } | |
2754 | |
2755 // skip to first non-separator, but don't skip past a ',' or the end of
the string | |
2756 while (isSeparator(buffer[i])) { | |
2757 if (buffer[i] == ',' || i >= length) | |
2758 break; | |
2759 i++; | |
2760 } | |
2761 valueBegin = i; | |
2762 | |
2763 // skip to first separator | |
2764 while (!isSeparator(buffer[i])) | |
2765 i++; | |
2766 valueEnd = i; | |
2767 | |
2768 ASSERT_WITH_SECURITY_IMPLICATION(i <= length); | |
2769 | |
2770 String keyString = buffer.substring(keyBegin, keyEnd - keyBegin); | |
2771 String valueString = buffer.substring(valueBegin, valueEnd - valueBegin)
; | |
2772 callback(keyString, valueString, this, data); | |
2773 } | |
2774 } | |
2775 | |
2776 void Document::processViewport(const String& features, ViewportArguments::Type o
rigin) | |
2777 { | |
2778 ASSERT(!features.isNull()); | |
2779 | |
2780 if (origin < m_viewportArguments.type) | |
2781 return; | |
2782 | |
2783 m_viewportArguments = ViewportArguments(origin); | |
2784 processArguments(features, (void*)&m_viewportArguments, &setViewportFeature)
; | |
2785 | |
2786 updateViewportArguments(); | |
2787 } | |
2788 | |
2789 void Document::updateViewportArguments() | 2722 void Document::updateViewportArguments() |
2790 { | 2723 { |
2791 if (page() && page()->mainFrame() == frame()) { | 2724 if (page() && page()->mainFrame() == frame()) { |
2792 #ifndef NDEBUG | 2725 #ifndef NDEBUG |
2793 m_didDispatchViewportPropertiesChanged = true; | 2726 m_didDispatchViewportPropertiesChanged = true; |
2794 #endif | 2727 #endif |
2795 page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments
); | 2728 page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments
); |
2796 } | 2729 } |
2797 } | 2730 } |
2798 | 2731 |
(...skipping 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5078 { | 5011 { |
5079 return DocumentLifecycleNotifier::create(this); | 5012 return DocumentLifecycleNotifier::create(this); |
5080 } | 5013 } |
5081 | 5014 |
5082 DocumentLifecycleNotifier* Document::lifecycleNotifier() | 5015 DocumentLifecycleNotifier* Document::lifecycleNotifier() |
5083 { | 5016 { |
5084 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); | 5017 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec
ycleNotifier()); |
5085 } | 5018 } |
5086 | 5019 |
5087 } // namespace WebCore | 5020 } // namespace WebCore |
OLD | NEW |