<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[161785] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/161785">161785</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2014-01-11 17:54:22 -0800 (Sat, 11 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add support for null StringViews
https://bugs.webkit.org/show_bug.cgi?id=126827
Reviewed by Anders Carlsson.
Source/WTF:
- Do some style cleanup while in the neighborhood.
* wtf/text/StringView.h:
(WTF::StringView::StringView):
Add default constructor to create a null StringView.
(WTF::StringView::isNull):
Add isNull(), matching the semantics of String.
(WTF::StringView::operator bool):
Add an explicit operator bool() to allow use in if-statements.
Tools:
Add new test for StringView.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/StringView.cpp: Added.
(TestWebKitAPI::TEST):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtftextStringViewh">trunk/Source/WTF/wtf/text/StringView.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWTFStringViewcpp">trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (161784 => 161785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-01-12 00:54:27 UTC (rev 161784)
+++ trunk/Source/WTF/ChangeLog        2014-01-12 01:54:22 UTC (rev 161785)
</span><span class="lines">@@ -1,5 +1,24 @@
</span><span class="cx"> 2014-01-11 Sam Weinig <sam@webkit.org>
</span><span class="cx">
</span><ins>+ Add support for null StringViews
+ https://bugs.webkit.org/show_bug.cgi?id=126827
+
+ Reviewed by Anders Carlsson.
+
+ - Do some style cleanup while in the neighborhood.
+
+ * wtf/text/StringView.h:
+ (WTF::StringView::StringView):
+ Add default constructor to create a null StringView.
+
+ (WTF::StringView::isNull):
+ Add isNull(), matching the semantics of String.
+
+ (WTF::StringView::operator bool):
+ Add an explicit operator bool() to allow use in if-statements.
+
+2014-01-11 Sam Weinig <sam@webkit.org>
+
</ins><span class="cx"> Clean up iterator filter / iterator range code
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=126817
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringView.h (161784 => 161785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringView.h        2014-01-12 00:54:27 UTC (rev 161784)
+++ trunk/Source/WTF/wtf/text/StringView.h        2014-01-12 01:54:22 UTC (rev 161785)
</span><span class="lines">@@ -37,12 +37,18 @@
</span><span class="cx">
</span><span class="cx"> class StringView {
</span><span class="cx"> public:
</span><del>- StringView(const LChar *characters, unsigned length)
</del><ins>+ StringView()
+ : m_characters(nullptr)
+ , m_length(0)
</ins><span class="cx"> {
</span><ins>+ }
+
+ StringView(const LChar* characters, unsigned length)
+ {
</ins><span class="cx"> initialize(characters, length);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- StringView(const UChar *characters, unsigned length)
</del><ins>+ StringView(const UChar* characters, unsigned length)
</ins><span class="cx"> {
</span><span class="cx"> initialize(characters, length);
</span><span class="cx"> }
</span><span class="lines">@@ -79,9 +85,12 @@
</span><span class="cx"> return static_cast<const UChar*>(m_characters);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ bool isNull() const { return !m_characters; }
</ins><span class="cx"> bool isEmpty() const { return !length(); }
</span><span class="cx"> unsigned length() const { return m_length & ~is16BitStringFlag; }
</span><span class="cx">
</span><ins>+ explicit operator bool() const { return !isNull(); }
+
</ins><span class="cx"> bool is8Bit() const { return !(m_length & is16BitStringFlag); }
</span><span class="cx">
</span><span class="cx"> StringView substring(unsigned start, unsigned length = std::numeric_limits<unsigned>::max()) const
</span><span class="lines">@@ -119,7 +128,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- void initialize(const LChar *characters, unsigned length)
</del><ins>+ void initialize(const LChar* characters, unsigned length)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!(length & is16BitStringFlag));
</span><span class="cx">
</span><span class="lines">@@ -127,7 +136,7 @@
</span><span class="cx"> m_length = length;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- void initialize(const UChar *characters, unsigned length)
</del><ins>+ void initialize(const UChar* characters, unsigned length)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(!(length & is16BitStringFlag));
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (161784 => 161785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-01-12 00:54:27 UTC (rev 161784)
+++ trunk/Tools/ChangeLog        2014-01-12 01:54:22 UTC (rev 161785)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-01-11 Sam Weinig <sam@webkit.org>
+
+ Add support for null StringViews
+ https://bugs.webkit.org/show_bug.cgi?id=126827
+
+ Reviewed by Anders Carlsson.
+
+ Add new test for StringView.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WTF/StringView.cpp: Added.
+ (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2014-01-10 Benjamin Poulain <bpoulain@apple.com>
</span><span class="cx">
</span><span class="cx"> Remove the BlackBerry port from trunk
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (161784 => 161785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2014-01-12 00:54:27 UTC (rev 161784)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2014-01-12 01:54:22 UTC (rev 161785)
</span><span class="lines">@@ -109,6 +109,7 @@
</span><span class="cx">                 76E182DA1547550100F1FADD /* WillSendSubmitEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76E182D91547550100F1FADD /* WillSendSubmitEvent.cpp */; };
</span><span class="cx">                 76E182DD1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */; };
</span><span class="cx">                 76E182DF154767E600F1FADD /* auto-submitting-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 76E182DE15475A8300F1FADD /* auto-submitting-form.html */; };
</span><ins>+                7C74D42F188228F300E5ED57 /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C74D42D188228F300E5ED57 /* StringView.cpp */; };
</ins><span class="cx">                 7C8DDAAB1735DEEE00EA5AC0 /* CloseThenTerminate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C8DDAA91735DE1D00EA5AC0 /* CloseThenTerminate.cpp */; };
</span><span class="cx">                 7C9ED98B17A19F4B00E4DC33 /* attributedStringStrikethrough.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7C9ED98A17A19D0600E4DC33 /* attributedStringStrikethrough.html */; };
</span><span class="cx">                 7CFBCADF1743234F00B2BFCF /* WillLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */; };
</span><span class="lines">@@ -432,6 +433,7 @@
</span><span class="cx">                 76E182D91547550100F1FADD /* WillSendSubmitEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillSendSubmitEvent.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 76E182DC1547569100F1FADD /* WillSendSubmitEvent_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillSendSubmitEvent_Bundle.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 76E182DE15475A8300F1FADD /* auto-submitting-form.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "auto-submitting-form.html"; sourceTree = "<group>"; };
</span><ins>+                7C74D42D188228F300E5ED57 /* StringView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringView.cpp; sourceTree = "<group>"; };
</ins><span class="cx">                 7C8DDAA91735DE1D00EA5AC0 /* CloseThenTerminate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CloseThenTerminate.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C9ED98A17A19D0600E4DC33 /* attributedStringStrikethrough.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = attributedStringStrikethrough.html; sourceTree = "<group>"; };
</span><span class="cx">                 7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -848,6 +850,7 @@
</span><span class="cx">                                 93ABA80816DDAB91002DB2FA /* StringHasher.cpp */,
</span><span class="cx">                                 26F1B44315CA434F00D1E4BF /* StringImpl.cpp */,
</span><span class="cx">                                 C01363C713C3997300EF3964 /* StringOperators.cpp */,
</span><ins>+                                7C74D42D188228F300E5ED57 /* StringView.cpp */,
</ins><span class="cx">                                 0BCD85691485C98B00EA2003 /* TemporaryChange.cpp */,
</span><span class="cx">                                 BC55F5F814AD78EE00484BE1 /* Vector.cpp */,
</span><span class="cx">                                 265AF54F15D1E48A00B0CB4A /* WTFString.cpp */,
</span><span class="lines">@@ -1162,6 +1165,7 @@
</span><span class="cx">                                 1A02C84F125D4A8400E3F4BD /* Find.cpp in Sources */,
</span><span class="cx">                                 C51AFB99169F49FF009CCF66 /* FindMatches.mm in Sources */,
</span><span class="cx">                                 1ADBEFAE130C689C00D61D19 /* ForceRepaint.cpp in Sources */,
</span><ins>+                                7C74D42F188228F300E5ED57 /* StringView.cpp in Sources */,
</ins><span class="cx">                                 BCBD3710125AA2EB00D2C29F /* FrameMIMETypeHTML.cpp in Sources */,
</span><span class="cx">                                 BCBD3761125ABCFE00D2C29F /* FrameMIMETypePNG.cpp in Sources */,
</span><span class="cx">                                 CE32C7C818184C4900CD8C28 /* WillPerformClientRedirectToURLCrash.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFStringViewcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp (0 => 161785)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp        2014-01-12 01:54:22 UTC (rev 161785)
</span><span class="lines">@@ -0,0 +1,80 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#import <wtf/text/StringView.h>
+
+namespace TestWebKitAPI {
+
+TEST(WTF, StringViewEmptyVsNull)
+{
+ StringView nullView;
+ EXPECT_TRUE(nullView.isNull());
+ EXPECT_TRUE(nullView.isEmpty());
+
+ // Test in a boolean context to test operator bool().
+ if (nullView)
+ FAIL();
+ else
+ SUCCEED();
+
+ if (!nullView)
+ SUCCEED();
+ else
+ FAIL();
+
+ StringView emptyView = StringView::empty();
+ EXPECT_FALSE(emptyView.isNull());
+ EXPECT_TRUE(emptyView.isEmpty());
+
+ // Test in a boolean context to test operator bool().
+ if (emptyView)
+ SUCCEED();
+ else
+ FAIL();
+
+ if (!emptyView)
+ FAIL();
+ else
+ SUCCEED();
+
+ StringView viewWithCharacters(String("hello"));
+ EXPECT_FALSE(viewWithCharacters.isNull());
+ EXPECT_FALSE(viewWithCharacters.isEmpty());
+
+ // Test in a boolean context to test operator bool().
+ if (viewWithCharacters)
+ SUCCEED();
+ else
+ FAIL();
+
+ if (!viewWithCharacters)
+ FAIL();
+ else
+ SUCCEED();
+}
+
+} // namespace TestWebKitAPI
</ins></span></pre>
</div>
</div>
</body>
</html>