Title: [211979] trunk/Source/WebCore
Revision
211979
Author
[email protected]
Date
2017-02-09 12:32:27 -0800 (Thu, 09 Feb 2017)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211978 => 211979)


--- trunk/Source/WebCore/ChangeLog	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/ChangeLog	2017-02-09 20:32:27 UTC (rev 211979)
@@ -1,3 +1,45 @@
+2017-02-09  Andreas Kling  <[email protected]>
+
+        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  <[email protected]>
 
         Make passing PlatformAudioData in audioSamplesAvaliable const-correct.

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp (211978 => 211979)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -466,7 +466,7 @@
     if (!page || page->usesEphemeralSession())
         return false;
 
-    return document.frame()->settings().applePayCapabilityDisclosureAllowed();
+    return document.settings().applePayCapabilityDisclosureAllowed();
 }
 
 ExceptionOr<bool> ApplePaySession::canMakePayments(ScriptExecutionContext& scriptExecutionContext)

Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp (211978 => 211979)


--- trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -101,7 +101,7 @@
 
 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;

Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (211978 => 211979)


--- trunk/Source/WebCore/css/CSSFontFace.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -73,7 +73,7 @@
         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))

Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (211978 => 211979)


--- trunk/Source/WebCore/css/CSSFontSelector.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -262,10 +262,10 @@
 
 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)

Modified: trunk/Source/WebCore/css/StyleResolver.h (211978 => 211979)


--- trunk/Source/WebCore/css/StyleResolver.h	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/css/StyleResolver.h	2017-02-09 20:32:27 UTC (rev 211979)
@@ -150,7 +150,7 @@
     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>>&);
 

Modified: trunk/Source/WebCore/dom/Document.h (211978 => 211979)


--- trunk/Source/WebCore/dom/Document.h	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/dom/Document.h	2017-02-09 20:32:27 UTC (rev 211979)
@@ -510,7 +510,8 @@
 
     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;
 

Modified: trunk/Source/WebCore/html/FTPDirectoryDocument.cpp (211978 => 211979)


--- trunk/Source/WebCore/html/FTPDirectoryDocument.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/html/FTPDirectoryDocument.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -276,7 +276,7 @@
     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)

Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (211978 => 211979)


--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -242,7 +242,7 @@
 #endif
 
 }
-static bool shouldEnableWebGL(Settings& settings)
+static bool shouldEnableWebGL(const Settings& settings)
 {
     if (!settings.webGLEnabled())
         return false;

Modified: trunk/Source/WebCore/html/HTMLEmbedElement.cpp (211978 => 211979)


--- trunk/Source/WebCore/html/HTMLEmbedElement.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/html/HTMLEmbedElement.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -208,7 +208,7 @@
 
 #if ENABLE(DASHBOARD_SUPPORT)
     // Workaround for <rdar://problem/6642221>.
-    if (document().frame()->settings().usesDashboardBackwardCompatibilityMode())
+    if (document().settings().usesDashboardBackwardCompatibilityMode())
         return true;
 #endif
 

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (211978 => 211979)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -1152,8 +1152,7 @@
 
         // 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;
         }

Modified: trunk/Source/WebCore/html/ImageDocument.cpp (211978 => 211979)


--- trunk/Source/WebCore/html/ImageDocument.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/html/ImageDocument.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -128,7 +128,7 @@
 
 void ImageDocument::updateDuringParsing()
 {
-    if (!frame()->settings().areImagesEnabled())
+    if (!settings().areImagesEnabled())
         return;
 
     if (!m_imageElement)

Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp (211978 => 211979)


--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -256,8 +256,8 @@
 
 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;
 }
 

Modified: trunk/Source/WebCore/page/make_settings.pl (211978 => 211979)


--- trunk/Source/WebCore/page/make_settings.pl	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/page/make_settings.pl	2017-02-09 20:32:27 UTC (rev 211979)
@@ -251,7 +251,7 @@
         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) {

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (211978 => 211979)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2017-02-09 20:28:44 UTC (rev 211978)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2017-02-09 20:32:27 UTC (rev 211979)
@@ -1178,8 +1178,8 @@
 
 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());
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to