[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
darin at apple.com
darin at apple.com
Wed Dec 22 13:23:28 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 2f2a9804f60e94f07bc3f682d3ceb5baf9eeb303
Author: darin at apple.com <darin at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Sep 13 23:42:02 2010 +0000
2010-09-13 Darin Adler <darin at apple.com>
Reviewed by Adam Barth.
Preparation for eliminating deprecatedParseURL
https://bugs.webkit.org/show_bug.cgi?id=45695
* wtf/text/WTFString.h: Added isAllSpecialCharacters, moved here from
the HTML tree builder.
2010-09-13 Darin Adler <darin at apple.com>
Reviewed by Adam Barth.
Preparation for eliminating deprecatedParseURL
https://bugs.webkit.org/show_bug.cgi?id=45695
* DOM/WebDOMOperations.mm:
(-[DOMDocument webFrame]): Get rid of unneeded local variable.
(-[DOMDocument URLWithAttributeString:]): Remove unhelpful comment.
2010-09-13 Darin Adler <darin at apple.com>
Reviewed by Adam Barth.
Preparation for eliminating deprecatedParseURL
https://bugs.webkit.org/show_bug.cgi?id=45695
Added new HTMLParserIdioms source file, with a name inspired by the HTML
specification, which has a section defining things like "space character"
that talks about common parser idioms. These are idioms for the main HTML
parser and for parsers for various microlanguages as well.
* Android.mk:
* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
Added HTMLParserIdioms.
* css/CSSHelper.h: Fixed indentation and comments here. Point to the new
stripLeadingAndTrailingHTMLSpaces function.
* html/parser/HTMLParserIdioms.cpp: Added.
* html/parser/HTMLParserIdioms.h: Added.
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::skipLeadingWhitespace):
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeLeadingWhitespace):
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeLeadingNonWhitespace):
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeRemainingWhitespace):
Updated for name changes.
* html/parser/HTMLTreeBuilder.h: Moved functions to HTMLParserIdioms.h.
* html/HTMLInputElement.cpp:
* html/HTMLMeterElement.cpp:
* html/HTMLProgressElement.cpp:
* html/StepRange.cpp:
* rendering/RenderSlider.cpp:
Updated includes.
* svg/SVGImageLoader.cpp:
(WebCore::SVGImageLoader::sourceURI): Fixed incorrect use of deprecatedParseURL.
This is for use on the attribute value before building the URL, not on the URL
after building it. I did not add a test case; this is an obscure corner and soon
we will be moving to stripLeadingAndTrailingHTMLSpaces anyway.
* wml/WMLImageLoader.cpp:
(WebCore::WMLImageLoader::sourceURI): Ditto.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67423 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index a35cdf8..c1958db 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,13 @@
+2010-09-13 Darin Adler <darin at apple.com>
+
+ Reviewed by Adam Barth.
+
+ Preparation for eliminating deprecatedParseURL
+ https://bugs.webkit.org/show_bug.cgi?id=45695
+
+ * wtf/text/WTFString.h: Added isAllSpecialCharacters, moved here from
+ the HTML tree builder.
+
2010-09-13 Darin Fisher <darin at chromium.org>
Reviewed by David Levin.
diff --git a/JavaScriptCore/wtf/text/WTFString.h b/JavaScriptCore/wtf/text/WTFString.h
index fafef12..9ec043a 100644
--- a/JavaScriptCore/wtf/text/WTFString.h
+++ b/JavaScriptCore/wtf/text/WTFString.h
@@ -53,6 +53,7 @@ class BString;
namespace WTF {
class CString;
+struct StringHash;
// Declarations of string operations
@@ -72,6 +73,8 @@ intptr_t charactersToIntPtr(const UChar*, size_t, bool* ok = 0); // ignores trai
double charactersToDouble(const UChar*, size_t, bool* ok = 0);
float charactersToFloat(const UChar*, size_t, bool* ok = 0);
+template<bool isSpecialCharacter(UChar)> bool isAllSpecialCharacters(const UChar*, size_t);
+
class String {
public:
// Construct a null string, distinguishable from an empty string.
@@ -220,6 +223,7 @@ public:
String simplifyWhiteSpace() const;
String removeCharacters(CharacterMatchFunctionPtr) const;
+ template<bool isSpecialCharacter(UChar)> bool isAllSpecialCharacters() const;
// Return the string with case folded for case insensitive comparison.
String foldCase() const;
@@ -423,7 +427,19 @@ inline void appendNumber(Vector<UChar>& vector, unsigned char number)
}
}
-struct StringHash;
+template<bool isSpecialCharacter(UChar)> inline bool isAllSpecialCharacters(const UChar* characters, size_t length)
+{
+ for (size_t i = 0; i < length; ++i) {
+ if (!isSpecialCharacter(characters[i]))
+ return false;
+ }
+ return true;
+}
+
+template<bool isSpecialCharacter(UChar)> inline bool String::isAllSpecialCharacters() const
+{
+ return WTF::isAllSpecialCharacters<isSpecialCharacter>(characters(), length());
+}
// StringHash is the default hash for String
template<typename T> struct DefaultHash;
@@ -440,17 +456,17 @@ template <> struct VectorTraits<String> : SimpleClassVectorTraits
using WTF::CString;
using WTF::String;
-
-using WTF::isSpaceOrNewline;
-using WTF::find;
-using WTF::reverseFind;
using WTF::append;
using WTF::appendNumber;
-using WTF::equal;
-using WTF::equalIgnoringCase;
using WTF::charactersAreAllASCII;
-using WTF::charactersToInt;
-using WTF::charactersToFloat;
using WTF::charactersToDouble;
+using WTF::charactersToFloat;
+using WTF::charactersToInt;
+using WTF::equal;
+using WTF::equalIgnoringCase;
+using WTF::find;
+using WTF::isAllSpecialCharacters;
+using WTF::isSpaceOrNewline;
+using WTF::reverseFind;
#endif
diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index c0c5fba..0d60ab6 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -299,6 +299,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
html/parser/HTMLElementStack.cpp \
html/parser/HTMLEntityParser.cpp \
html/parser/HTMLFormattingElementList.cpp \
+ html/parser/HTMLParserIdioms.cpp \
html/parser/HTMLParserScheduler.cpp \
html/parser/HTMLPreloadScanner.cpp \
html/parser/HTMLScriptRunner.cpp \
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 2d870e2..e288d93 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1047,6 +1047,7 @@ SET(WebCore_SOURCES
html/parser/HTMLElementStack.cpp
html/parser/HTMLEntityParser.cpp
html/parser/HTMLEntitySearch.cpp
+ html/parser/HTMLParserIdioms.cpp
html/parser/HTMLParserScheduler.cpp
html/parser/HTMLFormattingElementList.cpp
html/parser/HTMLPreloadScanner.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7af98e8..db07543 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,54 @@
+2010-09-13 Darin Adler <darin at apple.com>
+
+ Reviewed by Adam Barth.
+
+ Preparation for eliminating deprecatedParseURL
+ https://bugs.webkit.org/show_bug.cgi?id=45695
+
+ Added new HTMLParserIdioms source file, with a name inspired by the HTML
+ specification, which has a section defining things like "space character"
+ that talks about common parser idioms. These are idioms for the main HTML
+ parser and for parsers for various microlanguages as well.
+
+ * Android.mk:
+ * CMakeLists.txt:
+ * GNUmakefile.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ Added HTMLParserIdioms.
+
+ * css/CSSHelper.h: Fixed indentation and comments here. Point to the new
+ stripLeadingAndTrailingHTMLSpaces function.
+
+ * html/parser/HTMLParserIdioms.cpp: Added.
+ * html/parser/HTMLParserIdioms.h: Added.
+
+ * html/parser/HTMLTreeBuilder.cpp:
+ (WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::skipLeadingWhitespace):
+ (WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeLeadingWhitespace):
+ (WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeLeadingNonWhitespace):
+ (WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeRemainingWhitespace):
+ Updated for name changes.
+
+ * html/parser/HTMLTreeBuilder.h: Moved functions to HTMLParserIdioms.h.
+
+ * html/HTMLInputElement.cpp:
+ * html/HTMLMeterElement.cpp:
+ * html/HTMLProgressElement.cpp:
+ * html/StepRange.cpp:
+ * rendering/RenderSlider.cpp:
+ Updated includes.
+
+ * svg/SVGImageLoader.cpp:
+ (WebCore::SVGImageLoader::sourceURI): Fixed incorrect use of deprecatedParseURL.
+ This is for use on the attribute value before building the URL, not on the URL
+ after building it. I did not add a test case; this is an obscure corner and soon
+ we will be moving to stripLeadingAndTrailingHTMLSpaces anyway.
+ * wml/WMLImageLoader.cpp:
+ (WebCore::WMLImageLoader::sourceURI): Ditto.
+
2010-09-13 Chris Fleizach <cfleizach at apple.com>
Reviewed by Darin Adler.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 47e1550..0b836c1 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1642,6 +1642,8 @@ webcore_sources += \
WebCore/html/parser/HTMLFormattingElementList.cpp \
WebCore/html/parser/HTMLFormattingElementList.h \
WebCore/html/parser/HTMLInputStream.h \
+ WebCore/html/parser/HTMLParserIdioms.cpp \
+ WebCore/html/parser/HTMLParserIdioms.h \
WebCore/html/parser/HTMLParserScheduler.cpp \
WebCore/html/parser/HTMLParserScheduler.h \
WebCore/html/parser/HTMLPreloadScanner.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index fed7ce3..7703546 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1783,6 +1783,8 @@
'html/parser/HTMLFormattingElementList.cpp',
'html/parser/HTMLFormattingElementList.h',
'html/parser/HTMLInputStream.h',
+ 'html/parser/HTMLParserIdioms.cpp',
+ 'html/parser/HTMLParserIdioms.h',
'html/parser/HTMLParserScheduler.cpp',
'html/parser/HTMLParserScheduler.h',
'html/parser/HTMLPreloadScanner.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 6c67bde..ff4454d 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -945,6 +945,7 @@ SOURCES += \
html/parser/HTMLEntityParser.cpp \
html/parser/HTMLEntitySearch.cpp \
html/parser/HTMLFormattingElementList.cpp \
+ html/parser/HTMLParserIdioms.cpp \
html/parser/HTMLParserScheduler.cpp \
html/parser/HTMLPreloadScanner.cpp \
html/parser/HTMLScriptRunner.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index e256835..083a150 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -42012,6 +42012,14 @@
>
</File>
<File
+ RelativePath="..\html\parser\HTMLParserIdioms.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\html\parser\HTMLParserIdioms.h"
+ >
+ </File>
+ <File
RelativePath="..\html\parser\HTMLParserScheduler.cpp"
>
</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 171afda..43be698 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -2662,6 +2662,8 @@
93E227E40AF589AD00D48324 /* SubresourceLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DF0AF589AD00D48324 /* SubresourceLoader.cpp */; };
93E241FF0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E241FE0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
93E2425F0B2B509500C732A1 /* HTMLFrameOwnerElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E2425E0B2B509500C732A1 /* HTMLFrameOwnerElement.cpp */; };
+ 93E2A306123E9DC0009FE12A /* HTMLParserIdioms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E2A304123E9DC0009FE12A /* HTMLParserIdioms.cpp */; };
+ 93E2A307123E9DC0009FE12A /* HTMLParserIdioms.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E2A305123E9DC0009FE12A /* HTMLParserIdioms.h */; };
93E62D9B0985F41600E1B5E3 /* SystemTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E62D990985F41600E1B5E3 /* SystemTime.h */; settings = {ATTRIBUTES = (Private, ); }; };
93EB169509F880B00091F8FF /* WebCoreSystemInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93EB169409F880B00091F8FF /* WebCoreSystemInterface.mm */; };
93EB169709F880C00091F8FF /* WebCoreSystemInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EB169609F880C00091F8FF /* WebCoreSystemInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8584,6 +8586,8 @@
93E227DF0AF589AD00D48324 /* SubresourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SubresourceLoader.cpp; sourceTree = "<group>"; };
93E241FE0B2B4E4000C732A1 /* HTMLFrameOwnerElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLFrameOwnerElement.h; sourceTree = "<group>"; };
93E2425E0B2B509500C732A1 /* HTMLFrameOwnerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLFrameOwnerElement.cpp; sourceTree = "<group>"; };
+ 93E2A304123E9DC0009FE12A /* HTMLParserIdioms.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLParserIdioms.cpp; path = parser/HTMLParserIdioms.cpp; sourceTree = "<group>"; };
+ 93E2A305123E9DC0009FE12A /* HTMLParserIdioms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLParserIdioms.h; path = parser/HTMLParserIdioms.h; sourceTree = "<group>"; };
93E62D990985F41600E1B5E3 /* SystemTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemTime.h; sourceTree = "<group>"; };
93EB169409F880B00091F8FF /* WebCoreSystemInterface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreSystemInterface.mm; sourceTree = "<group>"; };
93EB169609F880C00091F8FF /* WebCoreSystemInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreSystemInterface.h; sourceTree = "<group>"; };
@@ -14496,6 +14500,8 @@
977B3855122883E900B81FF8 /* HTMLFormattingElementList.cpp */,
977B3856122883E900B81FF8 /* HTMLFormattingElementList.h */,
97BC849A12370A4B000C6161 /* HTMLInputStream.h */,
+ 93E2A304123E9DC0009FE12A /* HTMLParserIdioms.cpp */,
+ 93E2A305123E9DC0009FE12A /* HTMLParserIdioms.h */,
977B3857122883E900B81FF8 /* HTMLParserScheduler.cpp */,
977B3858122883E900B81FF8 /* HTMLParserScheduler.h */,
977B3859122883E900B81FF8 /* HTMLPreloadScanner.cpp */,
@@ -20557,6 +20563,7 @@
893C47B81238A099002B3D86 /* JSFileCallback.h in Headers */,
893C47BC1238A0A9002B3D86 /* JSFileWriterCallback.h in Headers */,
8A309C9F123950BE00CB9204 /* NestingLevelIncrementer.h in Headers */,
+ 93E2A307123E9DC0009FE12A /* HTMLParserIdioms.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -23031,6 +23038,7 @@
A622A8FC122C44A600A785B3 /* BindingSecurityBase.cpp in Sources */,
893C47B71238A099002B3D86 /* JSFileCallback.cpp in Sources */,
893C47BB1238A0A9002B3D86 /* JSFileWriterCallback.cpp in Sources */,
+ 93E2A306123E9DC0009FE12A /* HTMLParserIdioms.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebCore/css/CSSHelper.h b/WebCore/css/CSSHelper.h
index 331815e..ffd9166 100644
--- a/WebCore/css/CSSHelper.h
+++ b/WebCore/css/CSSHelper.h
@@ -26,17 +26,14 @@
namespace WebCore {
- // Used in many inappropriate contexts throughout WebCore. We'll have to examine and test
- // each call site to find out whether it needs the various things this function does. That
- // includes trimming leading and trailing control characters (including whitespace), removing
- // url() or URL() if it surrounds the entire string, removing matching quote marks if present,
- // and stripping all characters in the range U+0000-U+000C. Probably no caller needs this.
- String deprecatedParseURL(const String&);
+// Used in many inappropriate contexts throughout WebCore. Most callers should be using
+// stripLeadingAndTrailingHTMLSpaces instead.
+String deprecatedParseURL(const String&);
- // We always assume 96 CSS pixels in a CSS inch. This is the cold hard truth of the Web.
- // At high DPI, we may scale a CSS pixel, but the ratio of the CSS pixel to the so-called
- // "absolute" CSS length units like inch and pt is always fixed and never changes.
- const float cssPixelsPerInch = 96;
+// We always assume 96 CSS pixels in a CSS inch. This is the cold hard truth of the Web.
+// At high DPI, we may scale a CSS pixel, but the ratio of the CSS pixel to the so-called
+// "absolute" CSS length units like inch and pt is always fixed and never changes.
+const float cssPixelsPerInch = 96;
} // namespace WebCore
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index e90525b..3c94e81 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -50,7 +50,7 @@
#include "HTMLImageLoader.h"
#include "HTMLNames.h"
#include "HTMLOptionElement.h"
-#include "HTMLTreeBuilder.h"
+#include "HTMLParserIdioms.h"
#include "KeyboardEvent.h"
#include "LocalizedStrings.h"
#include "MouseEvent.h"
diff --git a/WebCore/html/HTMLMeterElement.cpp b/WebCore/html/HTMLMeterElement.cpp
index aaba125..5419a22 100644
--- a/WebCore/html/HTMLMeterElement.cpp
+++ b/WebCore/html/HTMLMeterElement.cpp
@@ -28,7 +28,7 @@
#include "FormDataList.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
-#include "HTMLTreeBuilder.h"
+#include "HTMLParserIdioms.h"
#include "RenderMeter.h"
#include <wtf/StdLibExtras.h>
diff --git a/WebCore/html/HTMLProgressElement.cpp b/WebCore/html/HTMLProgressElement.cpp
index de65fcb..e707592 100644
--- a/WebCore/html/HTMLProgressElement.cpp
+++ b/WebCore/html/HTMLProgressElement.cpp
@@ -28,7 +28,7 @@
#include "FormDataList.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
-#include "HTMLTreeBuilder.h"
+#include "HTMLParserIdioms.h"
#include "RenderProgress.h"
#include <wtf/StdLibExtras.h>
diff --git a/WebCore/html/StepRange.cpp b/WebCore/html/StepRange.cpp
index aeaf62f..68b0ebd 100644
--- a/WebCore/html/StepRange.cpp
+++ b/WebCore/html/StepRange.cpp
@@ -23,9 +23,9 @@
#include "HTMLInputElement.h"
#include "HTMLNames.h"
-#include "HTMLTreeBuilder.h"
-#include "PlatformString.h"
+#include "HTMLParserIdioms.h"
#include <wtf/MathExtras.h>
+#include <wtf/text/WTFString.h>
using namespace std;
diff --git a/WebCore/html/parser/HTMLParserIdioms.cpp b/WebCore/html/parser/HTMLParserIdioms.cpp
new file mode 100644
index 0000000..7026369
--- /dev/null
+++ b/WebCore/html/parser/HTMLParserIdioms.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2010 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"
+#include "HTMLParserIdioms.h"
+
+#include <wtf/MathExtras.h>
+#include <wtf/dtoa.h>
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+String stripLeadingAndTrailingHTMLSpaces(const String& string)
+{
+ const UChar* characters = string.characters();
+ unsigned length = string.length();
+
+ unsigned numLeadingSpaces;
+ for (numLeadingSpaces = 0; numLeadingSpaces < length; ++numLeadingSpaces) {
+ if (isNotHTMLSpace(characters[numLeadingSpaces]))
+ break;
+ }
+
+ if (numLeadingSpaces == length)
+ return emptyAtom;
+
+ unsigned numTrailingSpaces;
+ for (numTrailingSpaces = 0; numTrailingSpaces < length; ++numTrailingSpaces) {
+ if (isNotHTMLSpace(characters[length - numTrailingSpaces - 1]))
+ break;
+ }
+
+ ASSERT(numLeadingSpaces + numTrailingSpaces < length);
+
+ return string.substring(numLeadingSpaces, length - numTrailingSpaces);
+}
+
+String serializeForNumberType(double number)
+{
+ // According to HTML5, "the best representation of the number n as a floating
+ // point number" is a string produced by applying ToString() to n.
+ NumberToStringBuffer buffer;
+ unsigned length = numberToString(number, buffer);
+ return String(buffer, length);
+}
+
+bool parseToDoubleForNumberType(const String& string, double* result)
+{
+ // See HTML5 2.4.4.3 `Real numbers.'
+
+ // String::toDouble() accepts leading + and whitespace characters, which are not valid here.
+ UChar firstCharacter = string[0];
+ if (firstCharacter != '-' && !isASCIIDigit(firstCharacter))
+ return false;
+
+ bool valid = false;
+ double value = string.toDouble(&valid);
+ if (!valid)
+ return false;
+
+ // NaN and infinity are considered valid by String::toDouble, but not valid here.
+ if (!isfinite(value))
+ return false;
+
+ if (result) {
+ // The following expression converts -0 to +0.
+ *result = value ? value : 0;
+ }
+
+ return true;
+}
+
+}
diff --git a/WebCore/html/parser/HTMLParserIdioms.h b/WebCore/html/parser/HTMLParserIdioms.h
new file mode 100644
index 0000000..3ae20b5
--- /dev/null
+++ b/WebCore/html/parser/HTMLParserIdioms.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef HTMLParserIdioms_h
+#define HTMLParserIdioms_h
+
+#include <wtf/Forward.h>
+#include <wtf/unicode/Unicode.h>
+
+namespace WebCore {
+
+// Space characters as defined by the HTML specification.
+bool isHTMLSpace(UChar);
+bool isNotHTMLSpace(UChar);
+
+// Strip leading and trailing whitespace as defined by the HTML specification.
+String stripLeadingAndTrailingHTMLSpaces(const String&);
+
+// An implementation of the HTML specification's algorithm to convert a number to a string for number and range types.
+String serializeForNumberType(double);
+
+// Convert the specified string to a double. If the conversion fails, the return value is false.
+// Leading or trailing illegal characters cause failure, as does passing an empty string.
+// The double* parameter may be 0 to check if the string can be parsed without getting the result.
+bool parseToDoubleForNumberType(const String&, double*);
+
+// Inline implementations of some of the functions declared above.
+
+inline bool isHTMLSpace(UChar character)
+{
+ // FIXME: Consider branch permutations as we did in isASCIISpace.
+ return character == '\t' || character == '\x0A' || character == '\x0C' || character == '\x0D' || character == ' ';
+}
+
+inline bool isNotHTMLSpace(UChar character)
+{
+ return !isHTMLSpace(character);
+}
+
+}
+
+#endif
diff --git a/WebCore/html/parser/HTMLTreeBuilder.cpp b/WebCore/html/parser/HTMLTreeBuilder.cpp
index 61a8c84..40a6651 100644
--- a/WebCore/html/parser/HTMLTreeBuilder.cpp
+++ b/WebCore/html/parser/HTMLTreeBuilder.cpp
@@ -26,16 +26,17 @@
#include "config.h"
#include "HTMLTreeBuilder.h"
+#include "CharacterNames.h"
#include "Comment.h"
#include "DocumentFragment.h"
#include "DocumentType.h"
-#include "Element.h"
#include "Frame.h"
#include "HTMLDocument.h"
#include "HTMLElementFactory.h"
#include "HTMLFormElement.h"
#include "HTMLHtmlElement.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include "HTMLScriptElement.h"
#include "HTMLToken.h"
#include "HTMLTokenizer.h"
@@ -44,15 +45,10 @@
#include "NotImplemented.h"
#include "SVGNames.h"
#include "ScriptController.h"
-#include "Settings.h"
#include "Text.h"
#include "XLinkNames.h"
#include "XMLNSNames.h"
#include "XMLNames.h"
-// FIXME: Remove this include once we find a home for the free functions that
-// are using it.
-#include <wtf/dtoa.h>
-#include <wtf/UnusedParam.h>
namespace WebCore {
@@ -62,42 +58,19 @@ static const int uninitializedLineNumberValue = -1;
namespace {
-inline bool isTreeBuilderWhitepace(UChar c)
+inline bool isHTMLSpaceOrReplacementCharacter(UChar character)
{
- // FIXME: Consider branch permutations.
- return c == '\t' || c == '\x0A' || c == '\x0C' || c == '\x0D' || c == ' ';
-}
-
-inline bool isNotTreeBuilderWhitepace(UChar c)
-{
- return !isTreeBuilderWhitepace(c);
-}
-
-inline bool isTreeBuilderWhitepaceOrReplacementCharacter(UChar c)
-{
- return isTreeBuilderWhitepace(c) || c == 0xFFFD;
-}
-
-template<bool isSpecialCharacter(UChar c)>
-inline bool isAllSpecialCharacters(const String& string)
-{
- const UChar* characters = string.characters();
- const unsigned length = string.length();
- for (unsigned i = 0; i < length; ++i) {
- if (!isSpecialCharacter(characters[i]))
- return false;
- }
- return true;
+ return isHTMLSpace(character) || character == replacementCharacter;
}
inline bool isAllWhitespace(const String& string)
{
- return isAllSpecialCharacters<isTreeBuilderWhitepace>(string);
+ return string.isAllSpecialCharacters<isHTMLSpace>();
}
inline bool isAllWhitespaceOrReplacementCharacters(const String& string)
{
- return isAllSpecialCharacters<isTreeBuilderWhitepaceOrReplacementCharacter>(string);
+ return string.isAllSpecialCharacters<isHTMLSpaceOrReplacementCharacter>();
}
bool isNumberedHeaderTag(const AtomicString& tagName)
@@ -279,17 +252,17 @@ public:
void skipLeadingWhitespace()
{
- skipLeading<isTreeBuilderWhitepace>();
+ skipLeading<isHTMLSpace>();
}
String takeLeadingWhitespace()
{
- return takeLeading<isTreeBuilderWhitepace>();
+ return takeLeading<isHTMLSpace>();
}
String takeLeadingNonWhitespace()
{
- return takeLeading<isNotTreeBuilderWhitepace>();
+ return takeLeading<isNotHTMLSpace>();
}
String takeRemaining()
@@ -312,7 +285,7 @@ public:
Vector<UChar> whitespace;
do {
UChar cc = *m_current++;
- if (isTreeBuilderWhitepace(cc))
+ if (isHTMLSpace(cc))
whitespace.append(cc);
} while (m_current < m_end);
// Returning the null string when there aren't any whitespace
@@ -2817,41 +2790,4 @@ bool HTMLTreeBuilder::pluginsEnabled(Frame* frame)
return frame->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin);
}
-// FIXME: Move this function to a more appropriate place.
-String serializeForNumberType(double number)
-{
- // According to HTML5, "the best representation of the number n as a floating
- // point number" is a string produced by applying ToString() to n.
- NumberToStringBuffer buffer;
- unsigned length = numberToString(number, buffer);
- return String(buffer, length);
-}
-
-// FIXME: Move this function to a more appropriate place.
-bool parseToDoubleForNumberType(const String& src, double* out)
-{
- // See HTML5 2.4.4.3 `Real numbers.'
-
- if (src.isEmpty())
- return false;
- // String::toDouble() accepts leading + \t \n \v \f \r and SPACE, which are invalid in HTML5.
- // So, check the first character.
- if (src[0] != '-' && (src[0] < '0' || src[0] > '9'))
- return false;
-
- bool valid = false;
- double value = src.toDouble(&valid);
- if (!valid)
- return false;
- // NaN and Infinity are not valid numbers according to the standard.
- if (!isfinite(value))
- return false;
- // -0 -> 0
- if (!value)
- value = 0;
- if (out)
- *out = value;
- return true;
-}
-
}
diff --git a/WebCore/html/parser/HTMLTreeBuilder.h b/WebCore/html/parser/HTMLTreeBuilder.h
index b483f96..894f11a 100644
--- a/WebCore/html/parser/HTMLTreeBuilder.h
+++ b/WebCore/html/parser/HTMLTreeBuilder.h
@@ -256,18 +256,6 @@ private:
int m_lastScriptElementStartLine;
};
-// FIXME: Move these functions to a more appropriate place.
-
-// Converts the specified string to a floating number.
-// If the conversion fails, the return value is false. Take care that leading
-// or trailing unnecessary characters make failures. This returns false for an
-// empty string input.
-// The double* parameter may be 0.
-bool parseToDoubleForNumberType(const String&, double*);
-// Converts the specified number to a string. This is an implementation of
-// HTML5's "algorithm to convert a number to a string" for NUMBER/RANGE types.
-String serializeForNumberType(double);
-
}
#endif
diff --git a/WebCore/rendering/RenderSlider.cpp b/WebCore/rendering/RenderSlider.cpp
index a1bc71a..e1a209a 100644
--- a/WebCore/rendering/RenderSlider.cpp
+++ b/WebCore/rendering/RenderSlider.cpp
@@ -29,7 +29,7 @@
#include "Frame.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
-#include "HTMLTreeBuilder.h"
+#include "HTMLParserIdioms.h"
#include "MediaControlElements.h"
#include "MouseEvent.h"
#include "RenderLayer.h"
diff --git a/WebCore/svg/SVGImageLoader.cpp b/WebCore/svg/SVGImageLoader.cpp
index 5ba9c81..2079f74 100644
--- a/WebCore/svg/SVGImageLoader.cpp
+++ b/WebCore/svg/SVGImageLoader.cpp
@@ -48,7 +48,7 @@ void SVGImageLoader::dispatchLoadEvent()
String SVGImageLoader::sourceURI(const AtomicString& attr) const
{
- return deprecatedParseURL(KURL(element()->baseURI(), attr).string());
+ return KURL(element()->baseURI(), deprecatedParseURL(attr)).string();
}
}
diff --git a/WebCore/wml/WMLImageLoader.cpp b/WebCore/wml/WMLImageLoader.cpp
index 3c40215..1f1054f 100644
--- a/WebCore/wml/WMLImageLoader.cpp
+++ b/WebCore/wml/WMLImageLoader.cpp
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
*
* This library is free software; you can redistribute it and/or
@@ -49,7 +49,7 @@ void WMLImageLoader::dispatchLoadEvent()
String WMLImageLoader::sourceURI(const AtomicString& attr) const
{
- return deprecatedParseURL(KURL(element()->baseURI(), attr).string());
+ return KURL(element()->baseURI(), deprecatedParseURL(attr));
}
void WMLImageLoader::notifyFinished(CachedResource* image)
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 38b3d25..8532395 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,14 @@
+2010-09-13 Darin Adler <darin at apple.com>
+
+ Reviewed by Adam Barth.
+
+ Preparation for eliminating deprecatedParseURL
+ https://bugs.webkit.org/show_bug.cgi?id=45695
+
+ * DOM/WebDOMOperations.mm:
+ (-[DOMDocument webFrame]): Get rid of unneeded local variable.
+ (-[DOMDocument URLWithAttributeString:]): Remove unhelpful comment.
+
2010-09-13 Enrica Casucci <enrica at apple.com>
Reviewed by Sam Weinig.
diff --git a/WebKit/mac/DOM/WebDOMOperations.mm b/WebKit/mac/DOM/WebDOMOperations.mm
index d21f2b0..3d69836 100644
--- a/WebKit/mac/DOM/WebDOMOperations.mm
+++ b/WebKit/mac/DOM/WebDOMOperations.mm
@@ -121,8 +121,7 @@ using namespace JSC;
- (WebFrame *)webFrame
{
- Document* document = core(self);
- Frame* frame = document->frame();
+ Frame* frame = core(self)->frame();
if (!frame)
return nil;
return kit(frame);
@@ -130,7 +129,6 @@ using namespace JSC;
- (NSURL *)URLWithAttributeString:(NSString *)string
{
- // FIXME: Is deprecatedParseURL appropriate here?
return core(self)->completeURL(deprecatedParseURL(string));
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list