Document::settings() should return a const Settings&.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Feb 2017 20:32:27 +0000 (20:32 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Feb 2017 20:32:27 +0000 (20:32 +0000)
<https://webkit.org/b/168061>

Reviewed by Geoffrey Garen.

- Make Document::settings() return a const reference.
- Added Document::mutableSettings() for all your non-const needs.
- Fixed up settings generator to produce const getters.
- Simplify a few settings() call sites that exposed themselves.

* Modules/applepay/ApplePaySession.cpp:
(WebCore::shouldDiscloseApplePayCapability):
* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::canCallGetUserMedia):
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::appendSources):
* css/CSSFontSelector.cpp:
(WebCore::resolveGenericFamily):
* css/StyleResolver.h:
(WebCore::StyleResolver::settings):
* dom/Document.h:
(WebCore::Document::settings):
(WebCore::Document::mutableSettings):
* html/FTPDirectoryDocument.cpp:
(WebCore::createTemplateDocumentData):
* html/HTMLCanvasElement.cpp:
(WebCore::shouldEnableWebGL):
* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::rendererIsNeeded):
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::menuListDefaultEventHandler):
* html/ImageDocument.cpp:
(WebCore::ImageDocument::updateDuringParsing):
* page/csp/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::allowContentSecurityPolicySourceStarToMatchAnyProtocol):
* page/make_settings.pl:
(printGetterAndSetter):
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::toggleSimpleLineLayout):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211979 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/ApplePaySession.cpp
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/css/CSSFontFace.cpp
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/dom/Document.h
Source/WebCore/html/FTPDirectoryDocument.cpp
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLEmbedElement.cpp
Source/WebCore/html/HTMLSelectElement.cpp
Source/WebCore/html/ImageDocument.cpp
Source/WebCore/page/csp/ContentSecurityPolicy.cpp
Source/WebCore/page/make_settings.pl
Source/WebCore/rendering/SimpleLineLayout.cpp

index 6aa6b85..99e6b43 100644 (file)
@@ -1,3 +1,45 @@
+2017-02-09  Andreas Kling  <akling@apple.com>
+
+        Document::settings() should return a const Settings&.
+        <https://webkit.org/b/168061>
+
+        Reviewed by Geoffrey Garen.
+
+        - Make Document::settings() return a const reference.
+        - Added Document::mutableSettings() for all your non-const needs.
+        - Fixed up settings generator to produce const getters.
+        - Simplify a few settings() call sites that exposed themselves.
+
+        * Modules/applepay/ApplePaySession.cpp:
+        (WebCore::shouldDiscloseApplePayCapability):
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::canCallGetUserMedia):
+        * css/CSSFontFace.cpp:
+        (WebCore::CSSFontFace::appendSources):
+        * css/CSSFontSelector.cpp:
+        (WebCore::resolveGenericFamily):
+        * css/StyleResolver.h:
+        (WebCore::StyleResolver::settings):
+        * dom/Document.h:
+        (WebCore::Document::settings):
+        (WebCore::Document::mutableSettings):
+        * html/FTPDirectoryDocument.cpp:
+        (WebCore::createTemplateDocumentData):
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::shouldEnableWebGL):
+        * html/HTMLEmbedElement.cpp:
+        (WebCore::HTMLEmbedElement::rendererIsNeeded):
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::menuListDefaultEventHandler):
+        * html/ImageDocument.cpp:
+        (WebCore::ImageDocument::updateDuringParsing):
+        * page/csp/ContentSecurityPolicy.cpp:
+        (WebCore::ContentSecurityPolicy::allowContentSecurityPolicySourceStarToMatchAnyProtocol):
+        * page/make_settings.pl:
+        (printGetterAndSetter):
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::toggleSimpleLineLayout):
+
 2017-02-09  Jer Noble  <jer.noble@apple.com>
 
         Make passing PlatformAudioData in audioSamplesAvaliable const-correct.
index 57b8bb5..e522506 100644 (file)
@@ -466,7 +466,7 @@ static bool shouldDiscloseApplePayCapability(Document& document)
     if (!page || page->usesEphemeralSession())
         return false;
 
-    return document.frame()->settings().applePayCapabilityDisclosureAllowed();
+    return document.settings().applePayCapabilityDisclosureAllowed();
 }
 
 ExceptionOr<bool> ApplePaySession::canMakePayments(ScriptExecutionContext& scriptExecutionContext)
index 720b001..5df3e98 100644 (file)
@@ -101,7 +101,7 @@ static bool isSecure(DocumentLoader& documentLoader)
 
 static bool canCallGetUserMedia(Document& document, String& errorMessage)
 {
-    bool requiresSecureConnection = document.frame()->settings().mediaCaptureRequiresSecureConnection();
+    bool requiresSecureConnection = document.settings().mediaCaptureRequiresSecureConnection();
     if (requiresSecureConnection && !isSecure(*document.loader())) {
         errorMessage = "Trying to call getUserMedia from an insecure document.";
         return false;
index 63e57e5..4d9dc2a 100644 (file)
@@ -73,7 +73,7 @@ void CSSFontFace::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, Do
         fontFaceElement = item.svgFontFaceElement();
 #endif
         if (!item.isLocal()) {
-            Settings* settings = document ? &document->settings() : nullptr;
+            const Settings* settings = document ? &document->settings() : nullptr;
             bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled());
             if (allowDownloading && item.isSupportedFormat() && document) {
                 if (CachedFont* cachedFont = item.cachedFont(document, foundSVGFont, isInitiatingElementInUserAgentShadowTree))
index 45caf19..06b9df9 100644 (file)
@@ -262,10 +262,10 @@ void CSSFontSelector::fontCacheInvalidated()
 
 static const AtomicString& resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName)
 {
-    if (!document || !document->frame())
+    if (!document)
         return familyName;
 
-    const Settings& settings = document->frame()->settings();
+    const Settings& settings = document->settings();
 
     UScriptCode script = fontDescription.script();
     if (familyName == serifFamily)
index 619aba8..6f45adf 100644 (file)
@@ -150,7 +150,7 @@ public:
     const Element* element() { return m_state.element(); }
     Document& document() { return m_document; }
     const Document& document() const { return m_document; }
-    Settings& settings() { return m_document.settings(); }
+    const Settings& settings() const { return m_document.settings(); }
 
     void appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet>>&);
 
index 2e5ad5e..07304ea 100644 (file)
@@ -510,7 +510,8 @@ public:
 
     WEBCORE_EXPORT FrameView* view() const; // can be NULL
     WEBCORE_EXPORT Page* page() const; // can be NULL
-    Settings& settings() const { return m_settings.get(); }
+    const Settings& settings() const { return m_settings.get(); }
+    Settings& mutableSettings() { return m_settings.get(); }
 
     float deviceScaleFactor() const;
 
index 28e3287..86cb302 100644 (file)
@@ -276,7 +276,7 @@ void FTPDirectoryDocumentParser::parseAndAppendOneLine(const String& inputLine)
     appendEntry(filename, processFilesizeString(result.fileSize, result.type == FTPDirectoryEntry), processFileDateString(result.modifiedTime), result.type == FTPDirectoryEntry);
 }
 
-static inline RefPtr<SharedBuffer> createTemplateDocumentData(Settings& settings)
+static inline RefPtr<SharedBuffer> createTemplateDocumentData(const Settings& settings)
 {
     RefPtr<SharedBuffer> buffer = SharedBuffer::createWithContentsOfFile(settings.ftpDirectoryTemplatePath());
     if (buffer)
index d92bddd..e1aad2e 100644 (file)
@@ -242,7 +242,7 @@ static bool requiresAcceleratedCompositingForWebGL()
 #endif
 
 }
-static bool shouldEnableWebGL(Settings& settings)
+static bool shouldEnableWebGL(const Settings& settings)
 {
     if (!settings.webGLEnabled())
         return false;
index f750450..f4ccb36 100644 (file)
@@ -208,7 +208,7 @@ bool HTMLEmbedElement::rendererIsNeeded(const RenderStyle& style)
 
 #if ENABLE(DASHBOARD_SUPPORT)
     // Workaround for <rdar://problem/6642221>.
-    if (document().frame()->settings().usesDashboardBackwardCompatibilityMode())
+    if (document().settings().usesDashboardBackwardCompatibilityMode())
         return true;
 #endif
 
index ea09e55..a28e4c0 100644 (file)
@@ -1152,8 +1152,7 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event& event)
 
         // When using caret browsing, we want to be able to move the focus
         // out of the select element when user hits a left or right arrow key.
-        const Frame* frame = document().frame();
-        if (frame && frame->settings().caretBrowsingEnabled()) {
+        if (document().settings().caretBrowsingEnabled()) {
             if (keyIdentifier == "Left" || keyIdentifier == "Right")
                 return;
         }
index 4ab51fb..f1a26d2 100644 (file)
@@ -128,7 +128,7 @@ LayoutSize ImageDocument::imageSize()
 
 void ImageDocument::updateDuringParsing()
 {
-    if (!frame()->settings().areImagesEnabled())
+    if (!settings().areImagesEnabled())
         return;
 
     if (!m_imageElement)
index c3fbf6e..475087f 100644 (file)
@@ -256,8 +256,8 @@ bool ContentSecurityPolicy::urlMatchesSelf(const URL& url) const
 
 bool ContentSecurityPolicy::allowContentSecurityPolicySourceStarToMatchAnyProtocol() const
 {
-    if (Settings* settings = is<Document>(m_scriptExecutionContext) ? &downcast<Document>(*m_scriptExecutionContext).settings() : nullptr)
-        return settings->allowContentSecurityPolicySourceStarToMatchAnyProtocol();
+    if (is<Document>(m_scriptExecutionContext))
+        return downcast<Document>(*m_scriptExecutionContext).settings().allowContentSecurityPolicySourceStarToMatchAnyProtocol();
     return false;
 }
 
index da3234e..34c279f 100755 (executable)
@@ -251,7 +251,7 @@ sub printGetterAndSetter($$$$)
         print $file "    $type $settingName() const { return m_$settingName; } \\\n";
         print $file "    $webcoreExport void $setterFunctionName($type $settingName)";
     } else {
-        print $file "    const $type& $settingName() { return m_$settingName; } \\\n";
+        print $file "    const $type& $settingName() const { return m_$settingName; } \\\n";
         print $file "    $webcoreExport void $setterFunctionName(const $type& $settingName)";
     }
     if ($setNeedsStyleRecalcInAllFrames) {
index d31bca5..e7f1640 100644 (file)
@@ -1178,8 +1178,8 @@ static void collectNonEmptyLeafRenderBlockFlowsForCurrentPage(HashSet<const Rend
 
 void toggleSimpleLineLayout()
 {
-    for (const auto* document : Document::allDocuments()) {
-        auto& settings = document->settings();
+    for (auto* document : Document::allDocuments()) {
+        auto& settings = document->mutableSettings();
         settings.setSimpleLineLayoutEnabled(!settings.simpleLineLayoutEnabled());
     }
 }