Title: [150957] trunk/Source/WebCore
Revision
150957
Author
[email protected]
Date
2013-05-30 05:08:58 -0700 (Thu, 30 May 2013)

Log Message

Rename 'KURL::elidedString' and inspector's 'String.prototype.trimMiddle' for clarity.
https://bugs.webkit.org/show_bug.cgi?id=111700

Reviewed by Darin Adler.

Darin suggested that 'KURL::elidedString' is inaccurately named[1], this
patch is an attempt to do better. It additionally brings the Inspector's
'String.prototype.trimMiddle' method into line, as the two methods do
more or less the same thing.

After a bit of discussion with Maciej and Daniel Bates on IRC, I've
settled on 'KURL::stringCenterEllipsizedToLength(unsigned)' and
'String.prototype.centerEllipsizedToLength(number)' respectively.

No new tests are added, as this patch shouldn't have any visible effect
on the web. It's strictly an internal refactoring.

* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::connect):
(WebCore::WebSocket::send):
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::send):
(WebCore::WebSocketChannel::fail):
* bindings/ScriptControllerBase.cpp:
(WebCore::ScriptController::canExecuteScripts):
* dom/Document.cpp:
(WebCore::Document::processHttpEquiv):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::executeScript):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::canPlayType):
(WebCore::HTMLMediaElement::isSafeToLoadURL):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::submitForm):
(WebCore::FrameLoader::loadFrameRequest):
(WebCore::FrameLoader::commitProvisionalLoad):
(WebCore::FrameLoader::shouldInterruptLoadForXFrameOptions):
(WebCore::FrameLoader::loadProvisionalItemFromCachedPage):
(WebCore::createWindow):
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::willSendRequest):
(WebCore::MainResourceLoader::responseReceived):
* loader/MixedContentChecker.cpp:
(WebCore::MixedContentChecker::logWarning):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::didReceiveResponse):
(WebCore::ApplicationCacheGroup::didFail):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::canRequest):
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::loadResource):
(WebCore::CachedResourceLoader::printAccessDeniedMessage):
* page/ContentSecurityPolicy.cpp:
(WebCore::CSPDirectiveList::checkSourceAndReportViolation):
(WebCore::CSPDirectiveList::allowScriptNonce):
(WebCore::CSPDirectiveList::allowPluginType):
* platform/KURL.cpp:
(WebCore::KURL::stringCenterEllipsizedToLength):
* platform/KURL.h:
    Rename 'KURL::elidedString' to 'KURL::stringCenterEllipsizedToLength',
    and adjust callsites accordingly.
* inspector/front-end/CallStackSidebarPane.js:
(WebInspector.CallStackSidebarPane.Placard.prototype._update):
* inspector/front-end/ElementsTreeOutline.js:
(WebInspector.ElementsTreeElement.prototype._buildAttributeDOM):
* inspector/front-end/HeapSnapshotGridNodes.js:
(WebInspector.HeapSnapshotGenericObjectNode.prototype.shortenWindowURL):
* inspector/front-end/Linkifier.js:
(WebInspector.Linkifier.DefaultFormatter.prototype.formatLiveAnchor):
* inspector/front-end/ResourceUtils.js:
(WebInspector.linkifyURLAsNode):
* inspector/front-end/TabbedEditorContainer.js:
(WebInspector.TabbedEditorContainer.prototype._titleForFile):
* inspector/front-end/utilities.js:
    Rename 'String.prototype.trimMiddle' to 'String.prototype.centerEllipsizedToLength'
    and adjust callsites accordingly.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (150956 => 150957)


--- trunk/Source/WebCore/ChangeLog	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/ChangeLog	2013-05-30 12:08:58 UTC (rev 150957)
@@ -1,3 +1,82 @@
+2013-05-30  Mike West  <[email protected]>
+
+        Rename 'KURL::elidedString' and inspector's 'String.prototype.trimMiddle' for clarity.
+        https://bugs.webkit.org/show_bug.cgi?id=111700
+
+        Reviewed by Darin Adler.
+
+        Darin suggested that 'KURL::elidedString' is inaccurately named[1], this
+        patch is an attempt to do better. It additionally brings the Inspector's
+        'String.prototype.trimMiddle' method into line, as the two methods do
+        more or less the same thing.
+
+        After a bit of discussion with Maciej and Daniel Bates on IRC, I've
+        settled on 'KURL::stringCenterEllipsizedToLength(unsigned)' and
+        'String.prototype.centerEllipsizedToLength(number)' respectively.
+
+        No new tests are added, as this patch shouldn't have any visible effect
+        on the web. It's strictly an internal refactoring.
+
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::connect):
+        (WebCore::WebSocket::send):
+        * Modules/websockets/WebSocketChannel.cpp:
+        (WebCore::WebSocketChannel::send):
+        (WebCore::WebSocketChannel::fail):
+        * bindings/ScriptControllerBase.cpp:
+        (WebCore::ScriptController::canExecuteScripts):
+        * dom/Document.cpp:
+        (WebCore::Document::processHttpEquiv):
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::executeScript):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::canPlayType):
+        (WebCore::HTMLMediaElement::isSafeToLoadURL):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::submitForm):
+        (WebCore::FrameLoader::loadFrameRequest):
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        (WebCore::FrameLoader::shouldInterruptLoadForXFrameOptions):
+        (WebCore::FrameLoader::loadProvisionalItemFromCachedPage):
+        (WebCore::createWindow):
+        * loader/MainResourceLoader.cpp:
+        (WebCore::MainResourceLoader::willSendRequest):
+        (WebCore::MainResourceLoader::responseReceived):
+        * loader/MixedContentChecker.cpp:
+        (WebCore::MixedContentChecker::logWarning):
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::didReceiveResponse):
+        (WebCore::ApplicationCacheGroup::didFail):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::canRequest):
+        (WebCore::CachedResourceLoader::requestResource):
+        (WebCore::CachedResourceLoader::loadResource):
+        (WebCore::CachedResourceLoader::printAccessDeniedMessage):
+        * page/ContentSecurityPolicy.cpp:
+        (WebCore::CSPDirectiveList::checkSourceAndReportViolation):
+        (WebCore::CSPDirectiveList::allowScriptNonce):
+        (WebCore::CSPDirectiveList::allowPluginType):
+        * platform/KURL.cpp:
+        (WebCore::KURL::stringCenterEllipsizedToLength):
+        * platform/KURL.h:
+            Rename 'KURL::elidedString' to 'KURL::stringCenterEllipsizedToLength',
+            and adjust callsites accordingly.
+        * inspector/front-end/CallStackSidebarPane.js:
+        (WebInspector.CallStackSidebarPane.Placard.prototype._update):
+        * inspector/front-end/ElementsTreeOutline.js:
+        (WebInspector.ElementsTreeElement.prototype._buildAttributeDOM):
+        * inspector/front-end/HeapSnapshotGridNodes.js:
+        (WebInspector.HeapSnapshotGenericObjectNode.prototype.shortenWindowURL):
+        * inspector/front-end/Linkifier.js:
+        (WebInspector.Linkifier.DefaultFormatter.prototype.formatLiveAnchor):
+        * inspector/front-end/ResourceUtils.js:
+        (WebInspector.linkifyURLAsNode):
+        * inspector/front-end/TabbedEditorContainer.js:
+        (WebInspector.TabbedEditorContainer.prototype._titleForFile):
+        * inspector/front-end/utilities.js:
+            Rename 'String.prototype.trimMiddle' to 'String.prototype.centerEllipsizedToLength'
+            and adjust callsites accordingly.
+
 2013-05-30  Antti Koivisto  <[email protected]>
 
         Rename FontFallbackList.cpp/h to FontGlyphs.cpp/h

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (150956 => 150957)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -216,20 +216,20 @@
     m_url = KURL(KURL(), url);
 
     if (!m_url.isValid()) {
-        scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Invalid url for WebSocket " + m_url.elidedString());
+        scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Invalid url for WebSocket " + m_url.stringCenterEllipsizedToLength());
         m_state = CLOSED;
         ec = SYNTAX_ERR;
         return;
     }
 
     if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) {
-        scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Wrong url scheme for WebSocket " + m_url.elidedString());
+        scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Wrong url scheme for WebSocket " + m_url.stringCenterEllipsizedToLength());
         m_state = CLOSED;
         ec = SYNTAX_ERR;
         return;
     }
     if (m_url.hasFragmentIdentifier()) {
-        scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "URL has fragment component " + m_url.elidedString());
+        scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "URL has fragment component " + m_url.stringCenterEllipsizedToLength());
         m_state = CLOSED;
         ec = SYNTAX_ERR;
         return;
@@ -353,7 +353,7 @@
 
 void WebSocket::send(Blob* binaryData, ExceptionCode& ec)
 {
-    LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->url().elidedString().utf8().data());
+    LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->url().stringCenterEllipsizedToLength().utf8().data());
     ASSERT(binaryData);
     if (m_state == CONNECTING) {
         ec = INVALID_STATE_ERR;

Modified: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (150956 => 150957)


--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -161,7 +161,7 @@
 
 ThreadableWebSocketChannel::SendResult WebSocketChannel::send(const Blob& binaryData)
 {
-    LOG(Network, "WebSocketChannel %p send() Sending Blob '%s'", this, binaryData.url().elidedString().utf8().data());
+    LOG(Network, "WebSocketChannel %p send() Sending Blob '%s'", this, binaryData.url().stringCenterEllipsizedToLength().utf8().data());
     enqueueBlobFrame(WebSocketFrame::OpCodeBinary, binaryData);
     processOutgoingFrameQueue();
     return ThreadableWebSocketChannel::SendSuccess;
@@ -200,7 +200,7 @@
     ASSERT(!m_suspended);
     if (m_document) {
         InspectorInstrumentation::didReceiveWebSocketFrameError(m_document, m_identifier, reason);
-        m_document->addConsoleMessage(NetworkMessageSource, ErrorMessageLevel, "WebSocket connection to '" + m_handshake->url().elidedString() + "' failed: " + reason);
+        m_document->addConsoleMessage(NetworkMessageSource, ErrorMessageLevel, "WebSocket connection to '" + m_handshake->url().stringCenterEllipsizedToLength() + "' failed: " + reason);
     }
 
     // Hybi-10 specification explicitly states we must not continue to handle incoming data

Modified: trunk/Source/WebCore/bindings/ScriptControllerBase.cpp (150956 => 150957)


--- trunk/Source/WebCore/bindings/ScriptControllerBase.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/bindings/ScriptControllerBase.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -42,7 +42,7 @@
     if (m_frame->document() && m_frame->document()->isSandboxed(SandboxScripts)) {
         // FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
         if (reason == AboutToExecuteScript)
-            m_frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked script execution in '" + m_frame->document()->url().elidedString() + "' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.");
+            m_frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked script execution in '" + m_frame->document()->url().stringCenterEllipsizedToLength() + "' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.");
         return false;
     }
 

Modified: trunk/Source/WebCore/dom/Document.cpp (150956 => 150957)


--- trunk/Source/WebCore/dom/Document.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/dom/Document.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -2883,7 +2883,7 @@
             if (frameLoader->activeDocumentLoader() && frameLoader->activeDocumentLoader()->mainResourceLoader())
                 requestIdentifier = frameLoader->activeDocumentLoader()->mainResourceLoader()->identifier();
             if (frameLoader->shouldInterruptLoadForXFrameOptions(content, url(), requestIdentifier)) {
-                String message = "Refused to display '" + url().elidedString() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
+                String message = "Refused to display '" + url().stringCenterEllipsizedToLength() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
                 frameLoader->stopAllLoaders();
                 // Stopping the loader isn't enough, as we're already parsing the document; to honor the header's
                 // intent, we must navigate away from the possibly partially-rendered document to a location that

Modified: trunk/Source/WebCore/dom/ScriptElement.cpp (150956 => 150957)


--- trunk/Source/WebCore/dom/ScriptElement.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -297,7 +297,7 @@
 
 #if ENABLE(NOSNIFF)
     if (m_isExternalScript && m_cachedScript && !m_cachedScript->mimeTypeAllowedByNosniff()) {
-        m_element->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Refused to execute script from '" + m_cachedScript->url().elidedString() + "' because its MIME type ('" + m_cachedScript->mimeType() + "') is not executable, and strict MIME type checking is enabled.");
+        m_element->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Refused to execute script from '" + m_cachedScript->url().stringCenterEllipsizedToLength() + "' because its MIME type ('" + m_cachedScript->mimeType() + "') is not executable, and strict MIME type checking is enabled.");
         return;
     }
 #endif

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (150956 => 150957)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -748,7 +748,7 @@
             break;
     }
     
-    LOG(Media, "HTMLMediaElement::canPlayType(%s, %s, %s) -> %s", mimeType.utf8().data(), keySystem.utf8().data(), url.elidedString().utf8().data(), canPlay.utf8().data());
+    LOG(Media, "HTMLMediaElement::canPlayType(%s, %s, %s) -> %s", mimeType.utf8().data(), keySystem.utf8().data(), url.stringCenterEllipsizedToLength().utf8().data(), canPlay.utf8().data());
 
     return canPlay;
 }
@@ -1530,7 +1530,7 @@
     Frame* frame = document()->frame();
     if (!frame || !document()->securityOrigin()->canDisplay(url)) {
         if (actionIfInvalid == Complain)
-            FrameLoader::reportLocalLoadFailed(frame, url.elidedString());
+            FrameLoader::reportLocalLoadFailed(frame, url.stringCenterEllipsizedToLength());
         LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%s) -> FALSE rejected by SecurityOrigin", urlForLoggingMedia(url).utf8().data());
         return false;
     }

Modified: trunk/Source/WebCore/inspector/front-end/CallStackSidebarPane.js (150956 => 150957)


--- trunk/Source/WebCore/inspector/front-end/CallStackSidebarPane.js	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/inspector/front-end/CallStackSidebarPane.js	2013-05-30 12:08:58 UTC (rev 150957)
@@ -191,7 +191,7 @@
 WebInspector.CallStackSidebarPane.Placard.prototype = {
     _update: function(uiLocation)
     {
-        this.subtitle = WebInspector.formatLinkText(uiLocation.uiSourceCode.originURL(), uiLocation.lineNumber).trimMiddle(100);
+        this.subtitle = WebInspector.formatLinkText(uiLocation.uiSourceCode.originURL(), uiLocation.lineNumber).centerEllipsizedToLength(100);
     },
 
     _placardContextMenu: function(event)

Modified: trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js (150956 => 150957)


--- trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js	2013-05-30 12:08:58 UTC (rev 150957)
@@ -1796,7 +1796,7 @@
                 attrValueElement.textContent = value;
             } else {
                 if (value.startsWith("data:"))
-                    value = value.trimMiddle(60);
+                    value = value.centerEllipsizedToLength(60);
                 attrSpanElement.appendChild(linkify(rewrittenHref, value, "webkit-html-attribute-value", node.nodeName().toLowerCase() === "a"));
             }
         } else {

Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js (150956 => 150957)


--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js	2013-05-30 12:08:58 UTC (rev 150957)
@@ -517,7 +517,7 @@
             var fullURL = fullName.substring(startPos + 1, endPos).trimLeft();
             var url = ""
             if (url.length > 40)
-                url = ""
+                url = ""
             return fullName.substr(0, startPos + 2) + url + fullName.substr(endPos);
         } else
             return fullName;

Modified: trunk/Source/WebCore/inspector/front-end/Linkifier.js (150956 => 150957)


--- trunk/Source/WebCore/inspector/front-end/Linkifier.js	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/inspector/front-end/Linkifier.js	2013-05-30 12:08:58 UTC (rev 150957)
@@ -139,7 +139,7 @@
     {
         var text = WebInspector.formatLinkText(uiLocation.uiSourceCode.originURL(), uiLocation.lineNumber);
         if (this._maxLength)
-            text = text.trimMiddle(this._maxLength);
+            text = text.centerEllipsizedToLength(this._maxLength);
         anchor.textContent = text;
 
         var titleText = uiLocation.uiSourceCode.originURL();

Modified: trunk/Source/WebCore/inspector/front-end/ResourceUtils.js (150956 => 150957)


--- trunk/Source/WebCore/inspector/front-end/ResourceUtils.js	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/inspector/front-end/ResourceUtils.js	2013-05-30 12:08:58 UTC (rev 150957)
@@ -172,7 +172,7 @@
         a.title = url;
     else if (typeof tooltipText !== "string" || tooltipText.length)
         a.title = tooltipText;
-    a.textContent = linkText.trimMiddle(WebInspector.Linkifier.MaxLengthForDisplayedURLs);
+    a.textContent = linkText.centerEllipsizedToLength(WebInspector.Linkifier.MaxLengthForDisplayedURLs);
     if (isExternal)
         a.setAttribute("target", "_blank");
 

Modified: trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js (150956 => 150957)


--- trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2013-05-30 12:08:58 UTC (rev 150957)
@@ -173,7 +173,7 @@
         const minDisplayQueryParamLength = 5;
 
         var title = uiSourceCode.name();
-        title = title ? title.trimMiddle(maxDisplayNameLength) : WebInspector.UIString("(program)");
+        title = title ? title.centerEllipsizedToLength(maxDisplayNameLength) : WebInspector.UIString("(program)");
         if (uiSourceCode.isDirty())
             title += "*";
         return title;

Modified: trunk/Source/WebCore/inspector/front-end/utilities.js (150956 => 150957)


--- trunk/Source/WebCore/inspector/front-end/utilities.js	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/inspector/front-end/utilities.js	2013-05-30 12:08:58 UTC (rev 150957)
@@ -114,7 +114,7 @@
     return this.replace(/[\s\xA0]+/g, " ");
 }
 
-String.prototype.trimMiddle = function(maxLength)
+String.prototype.centerEllipsizedToLength = function(maxLength)
 {
     if (this.length <= maxLength)
         return String(this);

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (150956 => 150957)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -572,7 +572,7 @@
         ASSERT(identifier);
         if (frameLoader()->shouldInterruptLoadForXFrameOptions(content, response.url(), identifier)) {
             InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_frame, this, identifier, response);
-            String message = "Refused to display '" + response.url().elidedString() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
+            String message = "Refused to display '" + response.url().stringCenterEllipsizedToLength() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
             frame()->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message, identifier);
             frame()->document()->enforceSandboxFlags(SandboxOrigin);
             if (HTMLFrameOwnerElement* ownerElement = frame()->ownerElement())

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (150956 => 150957)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -336,7 +336,7 @@
 
     if (isDocumentSandboxed(m_frame, SandboxForms)) {
         // FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
-        m_frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked form submission to '" + submission->action().elidedString() + "' because the form's frame is sandboxed and the 'allow-forms' permission is not set.");
+        m_frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked form submission to '" + submission->action().stringCenterEllipsizedToLength() + "' because the form's frame is sandboxed and the 'allow-forms' permission is not set.");
         return;
     }
 
@@ -1150,7 +1150,7 @@
 
     ASSERT(m_frame->document());
     if (!request.requester()->canDisplay(url)) {
-        reportLocalLoadFailed(m_frame, url.elidedString());
+        reportLocalLoadFailed(m_frame, url.stringCenterEllipsizedToLength());
         return;
     }
 
@@ -1694,8 +1694,8 @@
     RefPtr<Frame> protect(m_frame);
 
     LOG(PageCache, "WebCoreLoading %s: About to commit provisional load from previous URL '%s' to new URL '%s'", m_frame->tree()->uniqueName().string().utf8().data(),
-        m_frame->document() ? m_frame->document()->url().elidedString().utf8().data() : "",
-        pdl ? pdl->url().elidedString().utf8().data() : "<no provisional DocumentLoader>");
+        m_frame->document() ? m_frame->document()->url().stringCenterEllipsizedToLength().utf8().data() : "",
+        pdl ? pdl->url().stringCenterEllipsizedToLength().utf8().data() : "<no provisional DocumentLoader>");
 
     willTransitionToCommitted();
 
@@ -1748,7 +1748,7 @@
     }
 
     LOG(Loading, "WebCoreLoading %s: Finished committing provisional load to URL %s", m_frame->tree()->uniqueName().string().utf8().data(),
-        m_frame->document() ? m_frame->document()->url().elidedString().utf8().data() : "");
+        m_frame->document() ? m_frame->document()->url().stringCenterEllipsizedToLength().utf8().data() : "");
 
     if (m_loadType == FrameLoadTypeStandard && m_documentLoader->isClientRedirect())
         history()->updateForClientRedirect();
@@ -2964,10 +2964,10 @@
     case XFrameOptionsAllowAll:
         return false;
     case XFrameOptionsConflict:
-        m_frame->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Multiple 'X-Frame-Options' headers with conflicting values ('" + content + "') encountered when loading '" + url.elidedString() + "'. Falling back to 'DENY'.", requestIdentifier);
+        m_frame->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Multiple 'X-Frame-Options' headers with conflicting values ('" + content + "') encountered when loading '" + url.stringCenterEllipsizedToLength() + "'. Falling back to 'DENY'.", requestIdentifier);
         return true;
     case XFrameOptionsInvalid:
-        m_frame->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Invalid 'X-Frame-Options' header encountered when loading '" + url.elidedString() + "': '" + content + "' is not a recognized directive. The header will be ignored.", requestIdentifier);
+        m_frame->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Invalid 'X-Frame-Options' header encountered when loading '" + url.stringCenterEllipsizedToLength() + "': '" + content + "' is not a recognized directive. The header will be ignored.", requestIdentifier);
         return false;
     default:
         ASSERT_NOT_REACHED();
@@ -2978,7 +2978,7 @@
 void FrameLoader::loadProvisionalItemFromCachedPage()
 {
     DocumentLoader* provisionalLoader = provisionalDocumentLoader();
-    LOG(PageCache, "WebCorePageCache: Loading provisional DocumentLoader %p with URL '%s' from CachedPage", provisionalDocumentLoader(), provisionalDocumentLoader()->url().elidedString().utf8().data());
+    LOG(PageCache, "WebCorePageCache: Loading provisional DocumentLoader %p with URL '%s' from CachedPage", provisionalDocumentLoader(), provisionalDocumentLoader()->url().stringCenterEllipsizedToLength().utf8().data());
 
     prepareForLoadStart();
 
@@ -3367,7 +3367,7 @@
     // Sandboxed frames cannot open new auxiliary browsing contexts.
     if (isDocumentSandboxed(openerFrame, SandboxPopups)) {
         // FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
-        openerFrame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked opening '" + request.resourceRequest().url().elidedString() + "' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.");
+        openerFrame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, "Blocked opening '" + request.resourceRequest().url().stringCenterEllipsizedToLength() + "' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.");
         return 0;
     }
 

Modified: trunk/Source/WebCore/loader/MixedContentChecker.cpp (150956 => 150957)


--- trunk/Source/WebCore/loader/MixedContentChecker.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/loader/MixedContentChecker.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -95,7 +95,7 @@
 
 void MixedContentChecker::logWarning(bool allowed, const String& action, const KURL& target) const
 {
-    String message = makeString((allowed ? "" : "[blocked] "), "The page at ", m_frame->document()->url().elidedString(), " ", action, " insecure content from ", target.elidedString(), ".\n");
+    String message = makeString((allowed ? "" : "[blocked] "), "The page at ", m_frame->document()->url().stringCenterEllipsizedToLength(), " ", action, " insecure content from ", target.stringCenterEllipsizedToLength(), ".\n");
     m_frame->document()->addConsoleMessage(SecurityMessageSource, WarningMessageLevel, message);
 }
 

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp (150956 => 150957)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -573,7 +573,7 @@
 
     if (response.httpStatusCode() / 100 != 2 || response.url() != m_currentHandle->firstRequest().url()) {
         if ((type & ApplicationCacheResource::Explicit) || (type & ApplicationCacheResource::Fallback)) {
-            m_frame->document()->addConsoleMessage(AppCacheMessageSource, ErrorMessageLevel, "Application Cache update failed, because " + m_currentHandle->firstRequest().url().elidedString() +
+            m_frame->document()->addConsoleMessage(AppCacheMessageSource, ErrorMessageLevel, "Application Cache update failed, because " + m_currentHandle->firstRequest().url().stringCenterEllipsizedToLength() +
                 ((response.httpStatusCode() / 100 != 2) ? " could not be fetched." : " was redirected."));
             // Note that cacheUpdateFailed() can cause the cache group to be deleted.
             cacheUpdateFailed();
@@ -687,7 +687,7 @@
     m_pendingEntries.remove(url);
 
     if ((type & ApplicationCacheResource::Explicit) || (type & ApplicationCacheResource::Fallback)) {
-        m_frame->document()->addConsoleMessage(AppCacheMessageSource, ErrorMessageLevel, "Application Cache update failed, because " + url.elidedString() + " could not be fetched.");
+        m_frame->document()->addConsoleMessage(AppCacheMessageSource, ErrorMessageLevel, "Application Cache update failed, because " + url.stringCenterEllipsizedToLength() + " could not be fetched.");
         // Note that cacheUpdateFailed() can cause the cache group to be deleted.
         cacheUpdateFailed();
     } else {

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (150956 => 150957)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -307,7 +307,7 @@
 {
     if (document() && !document()->securityOrigin()->canDisplay(url)) {
         if (!forPreload)
-            FrameLoader::reportLocalLoadFailed(frame(), url.elidedString());
+            FrameLoader::reportLocalLoadFailed(frame(), url.stringCenterEllipsizedToLength());
         LOG(ResourceLoading, "CachedResourceLoader::requestResource URL was not allowed by SecurityOrigin::canDisplay");
         return 0;
     }
@@ -435,7 +435,7 @@
 {
     KURL url = ""
     
-    LOG(ResourceLoading, "CachedResourceLoader::requestResource '%s', charset '%s', priority=%d, forPreload=%u", url.elidedString().latin1().data(), request.charset().latin1().data(), request.priority(), request.forPreload());
+    LOG(ResourceLoading, "CachedResourceLoader::requestResource '%s', charset '%s', priority=%d, forPreload=%u", url.stringCenterEllipsizedToLength().latin1().data(), request.charset().latin1().data(), request.priority(), request.forPreload());
     
     // If only the fragment identifiers differ, it is the same resource.
     url = ""
@@ -538,7 +538,7 @@
 {
     ASSERT(!memoryCache()->resourceForRequest(request.resourceRequest()));
 
-    LOG(ResourceLoading, "Loading CachedResource for '%s'.", request.resourceRequest().url().elidedString().latin1().data());
+    LOG(ResourceLoading, "Loading CachedResource for '%s'.", request.resourceRequest().url().stringCenterEllipsizedToLength().latin1().data());
 
     CachedResourceHandle<CachedResource> resource = createResource(type, request.mutableResourceRequest(), charset);
 
@@ -668,9 +668,9 @@
 
     String message;
     if (!m_document || m_document->url().isNull())
-        message = "Unsafe attempt to load URL " + url.elidedString() + '.';
+        message = "Unsafe attempt to load URL " + url.stringCenterEllipsizedToLength() + '.';
     else
-        message = "Unsafe attempt to load URL " + url.elidedString() + " from frame with URL " + m_document->url().elidedString() + ". Domains, protocols and ports must match.\n";
+        message = "Unsafe attempt to load URL " + url.stringCenterEllipsizedToLength() + " from frame with URL " + m_document->url().stringCenterEllipsizedToLength() + ". Domains, protocols and ports must match.\n";
 
     frame()->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLevel, message);
 }

Modified: trunk/Source/WebCore/page/ContentSecurityPolicy.cpp (150956 => 150957)


--- trunk/Source/WebCore/page/ContentSecurityPolicy.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/page/ContentSecurityPolicy.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -1076,7 +1076,7 @@
     if (directive == m_defaultSrc)
         suffix = " Note that '" + effectiveDirective + "' was not explicitly set, so 'default-src' is used as a fallback.";
 
-    reportViolation(directive->text(), effectiveDirective, prefix + url.elidedString() + "' because it violates the following Content Security Policy directive: \"" + directive->text() + "\"." + suffix + "\n", url);
+    reportViolation(directive->text(), effectiveDirective, prefix + url.stringCenterEllipsizedToLength() + "' because it violates the following Content Security Policy directive: \"" + directive->text() + "\"." + suffix + "\n", url);
     return denyIfEnforcingPolicy();
 }
 
@@ -1133,13 +1133,13 @@
     DEFINE_STATIC_LOCAL(String, consoleMessage, (ASCIILiteral("Refused to execute script because it violates the following Content Security Policy directive: ")));
     if (url.isEmpty())
         return checkNonceAndReportViolation(m_scriptNonce.get(), nonce, consoleMessage, contextURL, contextLine);
-    return checkNonceAndReportViolation(m_scriptNonce.get(), nonce, "Refused to load '" + url.elidedString() + "' because it violates the following Content Security Policy directive: ", contextURL, contextLine);
+    return checkNonceAndReportViolation(m_scriptNonce.get(), nonce, "Refused to load '" + url.stringCenterEllipsizedToLength() + "' because it violates the following Content Security Policy directive: ", contextURL, contextLine);
 }
 
 bool CSPDirectiveList::allowPluginType(const String& type, const String& typeAttribute, const KURL& url, ContentSecurityPolicy::ReportingStatus reportingStatus) const
 {
     return reportingStatus == ContentSecurityPolicy::SendReport ?
-        checkMediaTypeAndReportViolation(m_pluginTypes.get(), type, typeAttribute, "Refused to load '" + url.elidedString() + "' (MIME type '" + typeAttribute + "') because it violates the following Content Security Policy Directive: ") :
+        checkMediaTypeAndReportViolation(m_pluginTypes.get(), type, typeAttribute, "Refused to load '" + url.stringCenterEllipsizedToLength() + "' (MIME type '" + typeAttribute + "') because it violates the following Content Security Policy Directive: ") :
         checkMediaType(m_pluginTypes.get(), type, typeAttribute);
 }
 

Modified: trunk/Source/WebCore/platform/KURL.cpp (150956 => 150957)


--- trunk/Source/WebCore/platform/KURL.cpp	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/platform/KURL.cpp	2013-05-30 12:08:58 UTC (rev 150957)
@@ -1924,12 +1924,12 @@
     return m_string.isSafeToSendToAnotherThread();
 }
 
-String KURL::elidedString() const
+String KURL::stringCenterEllipsizedToLength(unsigned length) const
 {
-    if (string().length() <= 1024)
+    if (string().length() <= length)
         return string();
 
-    return string().left(511) + "..." + string().right(510);
+    return string().left(length / 2 - 1) + "..." + string().right(length / 2 - 2);
 }
 
 }

Modified: trunk/Source/WebCore/platform/KURL.h (150956 => 150957)


--- trunk/Source/WebCore/platform/KURL.h	2013-05-30 10:44:22 UTC (rev 150956)
+++ trunk/Source/WebCore/platform/KURL.h	2013-05-30 12:08:58 UTC (rev 150957)
@@ -103,7 +103,7 @@
 
     const String& string() const { return m_string; }
 
-    String elidedString() const;
+    String stringCenterEllipsizedToLength(unsigned length = 1024) const;
 
     String protocol() const;
     String host() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to