Merge pull request #9046 from IdrisKalp/master

qt5-webengine fix patch
This commit is contained in:
Idris Kalp
2021-02-26 04:03:32 +03:00
committed by GitHub
20 changed files with 36 additions and 2113 deletions
@@ -1,55 +0,0 @@
From d6e5fc10e417efdf8665d9fba57c269f0534072f Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Fri, 1 Nov 2019 11:10:31 +0100
Subject: [Backport] Fix for CVE-2019-13720
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Obtain graph/process lock when nullifying the buffer in Reverb
When the buffer is set to `null` while there is an active buffer
within a reverb object, SetBuffer() function can prematurely
nullify the `reverb_` and `shared_buffer_` while it is still
being accessed by the rendering thread.
This CL adds two locks (graph lock and process lock) when the
buffer gets nullified to ensure the synchronization between
two threads.
(cherry picked from commit 6a2e670a243b815cf043f8da4d26ecb9a64d307b)
Change-Id: I8f501b6a16b3c7e16db767e0b279a1a53d6eb290
Bug: 1019226
Reviewed-on:
https://chromium-review.googlesource.com/c/chromium/src/+/1888103
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#710627}
Reviewed-on:
https://chromium-review.googlesource.com/c/chromium/src/+/1889510
Reviewed-by: Krishna Govind <govind@chromium.org>
Cr-Commit-Position: refs/branch-heads/3953@{#8}
Cr-Branched-From:
b5ceb94d4b9a2f629c84df1be72f9e3d0a79fd2d-refs/heads/master@{#710313}
Reviewed-by: Michael Brüning <michael.bruning@qt.io>
---
chromium/third_party/blink/renderer/modules/webaudio/convolver_node.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/convolver_node.cc b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/convolver_node.cc
index a0c05beab71..066ed521d09 100644
--- a/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/convolver_node.cc
+++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/webaudio/convolver_node.cc
@@ -95,6 +95,8 @@ void ConvolverHandler::SetBuffer(AudioBuffer* buffer,
DCHECK(IsMainThread());
if (!buffer) {
+ BaseAudioContext::GraphAutoLocker context_locker(Context());
+ MutexLocker locker(process_lock_);
reverb_.reset();
buffer_ = buffer;
return;
--
cgit v1.2.1
@@ -1,55 +0,0 @@
From e70b59112104b72e794c20f7c715482809780d32 Mon Sep 17 00:00:00 2001
From: Michal Klocek <michal.klocek@theqtcompany.com>
Date: Thu, 20 Oct 2016 13:09:01 +0200
Subject: [PATCH] Add out of source builds for ninja bootstrap
Instead of coping the src ninja files to shadow dir,
do out of source build.
Change-Id: I00c577e5def66c0415681deab63b7c7947a39200
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
---
tools/qmake/mkspecs/features/functions.prf | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf
index 94aa617..3741529 100644
--- a/tools/qmake/mkspecs/features/functions.prf
+++ b/tools/qmake/mkspecs/features/functions.prf
@@ -264,28 +264,17 @@ defineReplace(findOrBuildNinja) {
!exists($$out) {
src_3rd_party_dir = $$absolute_path("$${getChromiumSrcDir()}/../", "$$QTWEBENGINE_ROOT")
- out = $$shadowed($$absolute_path("ninja/ninja", "$$src_3rd_party_dir"))
+ out = $$shadowed($$absolute_path(ninja/ninja, $$src_3rd_party_dir))
win32: out = $${out}.exe
- out = $$system_path($$out)
# If we did not find ninja, then we bootstrap it.
!exists($$out) {
- # If we are making a shadow build, copy the ninja sources to the build directory.
- !equals(PWD, $${OUT_PWD}) {
- log("Build directory is different from source directory - copying ninja sources to the build tree...")
- shadow_3rd_party_path = $$system_path($$shadowed($$src_3rd_party_dir))
-
- !exists($$dirname(out)): mkpath($$dirname(out))
- copy_dir_files {
- system("$$QMAKE_COPY_DIR $$system_quote($$system_path($$absolute_path("ninja", "$$src_3rd_party_dir"))) $$system_quote($$dirname(out))")
- } else {
- system("$$QMAKE_COPY_DIR $$system_quote($$system_path($$absolute_path("ninja", "$$src_3rd_party_dir"))) $$system_quote($$shadow_3rd_party_path)")
- }
- }
- system("cd $$system_quote($$dirname(out)) && python configure.py --bootstrap")
+ mkpath($$dirname(out))
+ ninja_configure = $$absolute_path(ninja/configure.py, $$src_3rd_party_dir)
+ system("cd $$system_quote($$system_path($$dirname(out))) && python $$system_quote($$system_path($$ninja_configure)) --bootstrap")
}
}
- return($$out)
+ return($$system_path($$out))
}
defineTest(skipBuild) {
--
2.7.4
@@ -1,40 +0,0 @@
From e3941dcdfcea6838243fa6cfdff2433867e502d6 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Thu, 1 Dec 2016 11:11:10 +0100
Subject: [PATCH] Update Chromium
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Change-Id: I1c046e16722e0e2dadb431ff0d3f5b7f69edd86f
Reviewed-by: Michael Brüning <michael.bruning@qt.io>
---
dist/changes-5.8.0 | 4 ++++
src/3rdparty | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/dist/changes-5.8.0 b/dist/changes-5.8.0
index abead3c..292e52c 100644
--- a/dist/changes-5.8.0
+++ b/dist/changes-5.8.0
@@ -29,6 +29,10 @@ information about a particular change.
- Chromium Snapshot:
* The Chromium version has been updated to 53.0.2785.148.
+ * Security fixes from Chromium up to version 54.0.2840.101
+ Including: CVE-2016-5181, CVE-2016-5182, CVE-2016-5183, CVE-2016-5185,
+ CVE-2016-5186, CVE-2016-5187, CVE-2016-5189, CVE-2016-5192,
+ CVE-2016-5199, CVE-2016-5201.
- General:
* Spellchecking support has been introduced.
diff --git a/src/3rdparty b/src/3rdparty
index 93b3786..52e8806 160000
--- a/src/3rdparty
+++ b/src/3rdparty
@@ -1 +1 @@
-Subproject commit 93b3786290ac16c95f15c95e2c2f3d8254171ab6
+Subproject commit 52e8806fb0b4e441603dd5885ab80447cfc66a63
--
2.7.4
@@ -1,51 +0,0 @@
From 4e8ca195e4a58a35b015ec55f32fb35403acb5ad Mon Sep 17 00:00:00 2001
From: Kirill Burtsev <kirill.burtsev@qt.io>
Date: Fri, 12 Jun 2020 16:30:23 +0200
Subject: Fix crash on run with blink setting DarkModeImagePolicy=kFilterSmart
Activating Dark Mode with with smart image filter policy
'--blink-settings=darkModeEnabled=true,darkModeImagePolicy=2'
lead to crash due stack-use-after-scope. Don't use use local references.
Issue was fixed after refatoring here:
https://chromium-review.googlesource.com/c/chromium/src/+/2169489
Won't be needed after chromium 85.0.4166.0
Change-Id: I6a36a394be41602c10b4c4bca3aa197c99d3be0c
Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
---
.../blink/renderer/platform/graphics/dark_mode_filter.cc | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/graphics/dark_mode_filter.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/graphics/dark_mode_filter.cc
index 0c2a478ca67..6f76ef45588 100644
--- a/src/3rdparty/chromium/third_party/blink/renderer/platform/graphics/dark_mode_filter.cc
+++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/graphics/dark_mode_filter.cc
@@ -49,21 +49,17 @@ bool ShouldApplyToImage(const DarkModeSettings& settings,
Image* image) {
switch (settings.image_policy) {
case DarkModeImagePolicy::kFilterSmart: {
- DarkModeImageClassifier* classifier;
+ DarkModeClassification result = DarkModeClassification::kNotClassified;
switch (settings.classifier_type) {
case DarkModeClassifierType::kIcon: {
- DarkModeIconClassifier icon_classifier;
- classifier = &icon_classifier;
+ result = DarkModeIconClassifier().Classify(image, src_rect, dest_rect);
break;
}
case DarkModeClassifierType::kGeneric: {
- DarkModeGenericClassifier generic_classifier;
- classifier = &generic_classifier;
+ result = DarkModeGenericClassifier().Classify(image, src_rect, dest_rect);
break;
}
}
- DarkModeClassification result =
- classifier->Classify(image, src_rect, dest_rect);
return result == DarkModeClassification::kApplyFilter;
}
case DarkModeImagePolicy::kFilterNone:
--
cgit v1.2.1
@@ -1,55 +0,0 @@
From c845b8438b65e6735c8beb0927ad0527cb1b0611 Mon Sep 17 00:00:00 2001
From: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Date: Fri, 7 Mar 2014 14:44:03 +0100
Subject: [PATCH] Do not use the system ninja
Always bootstrap and use the bundled ninja to avoid incompatibilities
between our bundled gyp and the system ninja, which might be quite
old.
This patch also removes the ninja location caching, as updating the
cache would trigger a re-run of qmake and gyp on all the project,
while the benefit of using the cache in this case are low.
Change-Id: I843cbe20e1153caecbda00ab3d45a34d560b2423
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu>
---
tools/qmake/mkspecs/features/functions.prf | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf
index 0814e8b..4dcd8ed 100644
--- a/tools/qmake/mkspecs/features/functions.prf
+++ b/tools/qmake/mkspecs/features/functions.prf
@@ -84,23 +84,16 @@ defineReplace(which) {
}
defineReplace(findOrBuildNinja) {
- !isEmpty(CACHED_NINJA_EXECUTABLE):exists($$CACHED_NINJA_EXECUTABLE): return($$CACHED_NINJA_EXECUTABLE)
- out = $$which(ninja)
- # Try to be smart about it if we know where the chromium sources are located
- !exists($$out) {
git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir")
# Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used)
isEmpty(git_chromium_src_dir): git_chromium_src_dir = "src/3rdparty/chromium"
- win32: out = $$system_path($$absolute_path("$$git_chromium_src_dir/../ninja/ninja.exe", "$$QTWEBENGINE_ROOT"))
- else: out = $$absolute_path("$$git_chromium_src_dir/../ninja/ninja", "$$QTWEBENGINE_ROOT")
- # If we still did not find ninja, then we bootstrap it.
+
+ out = $$absolute_path("$$git_chromium_src_dir/../ninja/ninja", "$$QTWEBENGINE_ROOT")
+ win32: out = $$system_path($${out}.exe)
+
+ # If we did not find ninja, then we bootstrap it.
!exists($$out) {
- message("bootstrapping ninja...")
- ninjadir = $$dirname(out)
- system("python $$ninjadir/bootstrap.py")
+ system("python $$dirname(out)/bootstrap.py")
}
- }
- message("using $$out")
- cache(CACHED_NINJA_EXECUTABLE, set, out)
- return($$out)
+ return($$out)
}
@@ -1,69 +0,0 @@
diff -u -r qtwebengine-everywhere-src-5.9.1/src/3rdparty/chromium/third_party/skia/src/ports/SkFontHost_FreeType.cpp qtwebengine-everywhere-src-5.9.1-ftfixes/src/3rdparty/chromium/third_party/skia/src/ports/SkFontHost_FreeType.cpp
--- qtwebengine-everywhere-src-5.9.1/src/3rdparty/chromium/third_party/skia/src/ports/SkFontHost_FreeType.cpp 2017-09-19 17:38:43.659642835 +0200
+++ qtwebengine-everywhere-src-5.9.1-ftfixes/src/3rdparty/chromium/third_party/skia/src/ports/SkFontHost_FreeType.cpp 2017-09-19 17:38:50.492991631 +0200
@@ -80,7 +80,7 @@
class FreeTypeLibrary : SkNoncopyable {
public:
- FreeTypeLibrary() : fLibrary(nullptr), fIsLCDSupported(false), fLCDExtra(0) {
+ FreeTypeLibrary() : fLibrary(nullptr) {
if (FT_New_Library(&gFTMemory, &fLibrary)) {
return;
}
@@ -90,8 +90,6 @@
// Default { 0x10, 0x40, 0x70, 0x40, 0x10 } adds up to 0x110, simulating ink spread.
// SetLcdFilter must be called before SetLcdFilterWeights.
if (FT_Library_SetLcdFilter(fLibrary, FT_LCD_FILTER_DEFAULT) == 0) {
- fIsLCDSupported = true;
- fLCDExtra = 2; //Using a filter adds one full pixel to each side.
#ifdef SK_FONTHOST_FREETYPE_USE_NORMAL_LCD_FILTER
// Adds to 0x110 simulating ink spread, but provides better results than default.
@@ -124,13 +122,9 @@
}
FT_Library library() { return fLibrary; }
- bool isLCDSupported() { return fIsLCDSupported; }
- int lcdExtra() { return fLCDExtra; }
private:
FT_Library fLibrary;
- bool fIsLCDSupported;
- int fLCDExtra;
// FT_Library_SetLcdFilterWeights was introduced in FreeType 2.4.0.
// The following platforms provide FreeType of at least 2.4.0.
@@ -633,17 +627,6 @@
rec->fTextSize = SkIntToScalar(1 << 14);
}
- if (isLCD(*rec)) {
- // TODO: re-work so that FreeType is set-up and selected by the SkFontMgr.
- SkAutoMutexAcquire ama(gFTMutex);
- ref_ft_library();
- if (!gFTLibrary->isLCDSupported()) {
- // If the runtime Freetype library doesn't support LCD, disable it here.
- rec->fMaskFormat = SkMask::kA8_Format;
- }
- unref_ft_library();
- }
-
SkPaint::Hinting h = rec->getHinting();
if (SkPaint::kFull_Hinting == h && !isLCD(*rec)) {
// collapse full->normal hinting if we're not doing LCD
@@ -1046,11 +1029,11 @@
void SkScalerContext_FreeType::updateGlyphIfLCD(SkGlyph* glyph) {
if (isLCD(fRec)) {
if (fLCDIsVert) {
- glyph->fHeight += gFTLibrary->lcdExtra();
- glyph->fTop -= gFTLibrary->lcdExtra() >> 1;
+ glyph->fHeight += 2;
+ glyph->fTop -= 1;
} else {
- glyph->fWidth += gFTLibrary->lcdExtra();
- glyph->fLeft -= gFTLibrary->lcdExtra() >> 1;
+ glyph->fWidth += 2;
+ glyph->fLeft -= 1;
}
}
}
@@ -1,49 +0,0 @@
From 5f69ea6f29371f0d03c23ff0ec81b63b7e5dca23 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Date: Thu, 9 Jun 2016 13:18:36 +0200
Subject: [PATCH] Use -fno-delete-null-pointer-checks with gcc 6
V8 is not safe for removing null pointer checks. Until it is, we need
to disable optimizations in GCC that assume it is not doing something
wrong.
Task-number: QTBUG-53956
Change-Id: Ieae1a44a36ddd481656497414275b134bbbc9da3
---
chromium/build/common.gypi | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/chromium/build/common.gypi b/chromium/build/common.gypi
index 272a42f..209ffe0 100644
--- a/chromium/build/common.gypi
+++ src/3rdparty/chromium/build/common.gypi
@@ -4729,6 +4729,26 @@
}],
],
}],
+ ['gcc_version>=60 and clang==0', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags_cc': [
+ # V8 needs this, see https://bugs.chromium.org/p/v8/issues/detail?id=3782
+ '-fno-delete-null-pointer-checks',
+ ],
+ }],
+ ],
+ }],
+ ['host_gcc_version>=60 and clang==0 and host_clang==0', {
+ 'target_conditions': [
+ ['_toolset=="host"', {
+ 'cflags_cc': [
+ # V8 needs this, see https://bugs.chromium.org/p/v8/issues/detail?id=3782
+ '-fno-delete-null-pointer-checks',
+ ],
+ }],
+ ],
+ }],
],
},
}],
--
2.8.3
@@ -24,10 +24,10 @@ Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
chromium/ui/base/l10n/formatter.cc | 6 +++---
12 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/chromium/base/i18n/string_compare.cc b/chromium/base/i18n/string_compare.cc
diff --git a/src/3rdparty/chromium/base/i18n/string_compare.cc b/src/3rdparty/chromium/base/i18n/string_compare.cc
index 6cd59b98f49..a5fa502b53f 100644
--- a/chromium/base/i18n/string_compare.cc
+++ b/chromium/base/i18n/string_compare.cc
--- a/src/3rdparty/chromium/base/i18n/string_compare.cc
+++ b/src/3rdparty/chromium/base/i18n/string_compare.cc
@@ -18,8 +18,8 @@ UCollationResult CompareString16WithCollator(const icu::Collator& collator,
StringPiece16 rhs) {
UErrorCode error = U_ZERO_ERROR;
@@ -39,10 +39,10 @@ index 6cd59b98f49..a5fa502b53f 100644
error);
DCHECK(U_SUCCESS(error));
return result;
diff --git a/chromium/base/i18n/time_formatting.cc b/chromium/base/i18n/time_formatting.cc
diff --git a/src/3rdparty/chromium/base/i18n/time_formatting.cc b/src/3rdparty/chromium/base/i18n/time_formatting.cc
index 1a6c1389ba0..106dd0e5b47 100644
--- a/chromium/base/i18n/time_formatting.cc
+++ b/chromium/base/i18n/time_formatting.cc
--- a/src/3rdparty/chromium/base/i18n/time_formatting.cc
+++ b/src/3rdparty/chromium/base/i18n/time_formatting.cc
@@ -236,7 +236,7 @@ bool TimeDurationFormatWithSeconds(const TimeDelta time,
icu::FieldPosition ignore(icu::FieldPosition::DONT_CARE);
measure_format.formatMeasures(measures, 3, formatted, ignore, status);
@@ -52,10 +52,10 @@ index 1a6c1389ba0..106dd0e5b47 100644
}
string16 DateIntervalFormat(const Time& begin_time,
diff --git a/chromium/components/autofill/core/common/autofill_regexes.cc b/chromium/components/autofill/core/common/autofill_regexes.cc
diff --git a/src/3rdparty/chromium/components/autofill/core/common/autofill_regexes.cc b/src/3rdparty/chromium/components/autofill/core/common/autofill_regexes.cc
index b141cb2d0f6..a8a688d50c7 100644
--- a/chromium/components/autofill/core/common/autofill_regexes.cc
+++ b/chromium/components/autofill/core/common/autofill_regexes.cc
--- a/src/3rdparty/chromium/components/autofill/core/common/autofill_regexes.cc
+++ b/src/3rdparty/chromium/components/autofill/core/common/autofill_regexes.cc
@@ -43,7 +43,7 @@ class AutofillRegexes {
icu::RegexMatcher* AutofillRegexes::GetMatcher(const base::string16& pattern) {
auto it = matchers_.find(pattern);
@@ -89,10 +89,10 @@ index b141cb2d0f6..a8a688d50c7 100644
}
} // namespace autofill
diff --git a/chromium/components/spellcheck/renderer/spellcheck_worditerator.cc b/chromium/components/spellcheck/renderer/spellcheck_worditerator.cc
diff --git a/src/3rdparty/chromium/components/spellcheck/renderer/spellcheck_worditerator.cc b/src/3rdparty/chromium/components/spellcheck/renderer/spellcheck_worditerator.cc
index 8fe8a6df381..e3a65580c08 100644
--- a/chromium/components/spellcheck/renderer/spellcheck_worditerator.cc
+++ b/chromium/components/spellcheck/renderer/spellcheck_worditerator.cc
--- a/src/3rdparty/chromium/components/spellcheck/renderer/spellcheck_worditerator.cc
+++ b/src/3rdparty/chromium/components/spellcheck/renderer/spellcheck_worditerator.cc
@@ -424,7 +424,7 @@ bool SpellcheckWordIterator::Normalize(size_t input_start,
// spellchecker and we need manual normalization as well. The normalized
// text does not have to be NUL-terminated since its characters are copied to
@@ -102,10 +102,10 @@ index 8fe8a6df381..e3a65580c08 100644
base::checked_cast<int32_t>(input_length));
UErrorCode status = U_ZERO_ERROR;
icu::UnicodeString output;
diff --git a/chromium/components/url_formatter/spoof_checks/idn_spoof_checker.cc b/chromium/components/url_formatter/spoof_checks/idn_spoof_checker.cc
diff --git a/src/3rdparty/chromium/components/url_formatter/spoof_checks/idn_spoof_checker.cc b/src/3rdparty/chromium/components/url_formatter/spoof_checks/idn_spoof_checker.cc
index 1964793fd3e..c4e01026c38 100644
--- a/chromium/components/url_formatter/spoof_checks/idn_spoof_checker.cc
+++ b/chromium/components/url_formatter/spoof_checks/idn_spoof_checker.cc
--- a/src/3rdparty/chromium/components/url_formatter/spoof_checks/idn_spoof_checker.cc
+++ b/src/3rdparty/chromium/components/url_formatter/spoof_checks/idn_spoof_checker.cc
@@ -347,7 +347,7 @@ bool IDNSpoofChecker::SafeToDisplayAsUnicode(
if (U_FAILURE(status) || (result & USPOOF_ALL_CHECKS))
return false;
@@ -124,10 +124,10 @@ index 1964793fd3e..c4e01026c38 100644
base::checked_cast<int32_t>(tld_unicode.size()));
// Allow if the TLD contains any letter from the script, in which case it's
// likely to be a TLD in that script.
diff --git a/chromium/components/url_formatter/spoof_checks/skeleton_generator.cc b/chromium/components/url_formatter/spoof_checks/skeleton_generator.cc
diff --git a/src/3rdparty/chromium/components/url_formatter/spoof_checks/skeleton_generator.cc b/src/3rdparty/chromium/components/url_formatter/spoof_checks/skeleton_generator.cc
index 41485914007..b8c1c2f547a 100644
--- a/chromium/components/url_formatter/spoof_checks/skeleton_generator.cc
+++ b/chromium/components/url_formatter/spoof_checks/skeleton_generator.cc
--- a/src/3rdparty/chromium/components/url_formatter/spoof_checks/skeleton_generator.cc
+++ b/src/3rdparty/chromium/components/url_formatter/spoof_checks/skeleton_generator.cc
@@ -117,7 +117,7 @@ SkeletonGenerator::~SkeletonGenerator() = default;
Skeletons SkeletonGenerator::GetSkeletons(base::StringPiece16 hostname) {
Skeletons skeletons;
@@ -137,10 +137,10 @@ index 41485914007..b8c1c2f547a 100644
// If input has any characters outside Latin-Greek-Cyrillic and [0-9._-],
// there is no point in getting rid of diacritics because combining marks
// attached to non-LGC characters are already blocked.
diff --git a/chromium/services/service_manager/zygote/zygote_linux.cc b/chromium/services/service_manager/zygote/zygote_linux.cc
diff --git a/src/3rdparty/chromium/services/service_manager/zygote/zygote_linux.cc b/src/3rdparty/chromium/services/service_manager/zygote/zygote_linux.cc
index aa601ab28d7..920438e5b50 100644
--- a/chromium/services/service_manager/zygote/zygote_linux.cc
+++ b/chromium/services/service_manager/zygote/zygote_linux.cc
--- a/src/3rdparty/chromium/services/service_manager/zygote/zygote_linux.cc
+++ b/src/3rdparty/chromium/services/service_manager/zygote/zygote_linux.cc
@@ -564,7 +564,7 @@ base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter,
if (!iter.ReadString16(&timezone_id))
return -1;
@@ -150,10 +150,10 @@ index aa601ab28d7..920438e5b50 100644
if (!iter.ReadInt(&numfds))
return -1;
diff --git a/chromium/third_party/blink/renderer/platform/text/locale_icu.cc b/chromium/third_party/blink/renderer/platform/text/locale_icu.cc
diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/text/locale_icu.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/text/locale_icu.cc
index abff1b1d809..57f1286d4e4 100644
--- a/chromium/third_party/blink/renderer/platform/text/locale_icu.cc
+++ b/chromium/third_party/blink/renderer/platform/text/locale_icu.cc
--- a/src/3rdparty/chromium/third_party/blink/renderer/platform/text/locale_icu.cc
+++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/text/locale_icu.cc
@@ -169,12 +169,12 @@ static String GetDateFormatPattern(const UDateFormat* date_format) {
return g_empty_string;
@@ -169,10 +169,10 @@ index abff1b1d809..57f1286d4e4 100644
if (U_FAILURE(status))
return g_empty_string;
return String::Adopt(buffer);
diff --git a/chromium/third_party/blink/renderer/platform/text/text_break_iterator_icu.cc b/chromium/third_party/blink/renderer/platform/text/text_break_iterator_icu.cc
diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/text/text_break_iterator_icu.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/text/text_break_iterator_icu.cc
index a257cd75ccf..898d0c47bb1 100644
--- a/chromium/third_party/blink/renderer/platform/text/text_break_iterator_icu.cc
+++ b/chromium/third_party/blink/renderer/platform/text/text_break_iterator_icu.cc
--- a/src/3rdparty/chromium/third_party/blink/renderer/platform/text/text_break_iterator_icu.cc
+++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/text/text_break_iterator_icu.cc
@@ -311,13 +311,13 @@ static inline bool TextInChunkOrOutOfRange(UText* text,
text->chunkOffset = offset <= std::numeric_limits<int32_t>::max()
? static_cast<int32_t>(offset)
@@ -240,10 +240,10 @@ index a257cd75ccf..898d0c47bb1 100644
}
static const struct UTextFuncs kTextUTF16Funcs = {
diff --git a/chromium/third_party/blink/renderer/platform/text/unicode_utilities.cc b/chromium/third_party/blink/renderer/platform/text/unicode_utilities.cc
diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/text/unicode_utilities.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/text/unicode_utilities.cc
index 2cefd5390b6..b8c4515dc13 100644
--- a/chromium/third_party/blink/renderer/platform/text/unicode_utilities.cc
+++ b/chromium/third_party/blink/renderer/platform/text/unicode_utilities.cc
--- a/src/3rdparty/chromium/third_party/blink/renderer/platform/text/unicode_utilities.cc
+++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/text/unicode_utilities.cc
@@ -300,7 +300,7 @@ void NormalizeCharactersIntoNFCForm(const UChar* characters,
DCHECK(U_SUCCESS(status));
int32_t input_length = static_cast<int32_t>(length);
@@ -253,10 +253,10 @@ index 2cefd5390b6..b8c4515dc13 100644
// In the vast majority of cases, input is already NFC. Run a quick check
// to avoid normalizing the entire input unnecessarily.
int32_t normalized_prefix_length =
diff --git a/chromium/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc b/chromium/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
diff --git a/src/3rdparty/chromium/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc b/src/3rdparty/chromium/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
index 810d1cd9181..9074b640fff 100644
--- a/chromium/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
+++ b/chromium/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
--- a/src/3rdparty/chromium/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
+++ b/src/3rdparty/chromium/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
@@ -326,7 +326,7 @@ void TextCodecICU::CreateICUConverter() const {
DLOG_IF(ERROR, err == U_AMBIGUOUS_ALIAS_WARNING)
<< "ICU ambiguous alias warning for encoding: " << encoding_.GetName();
@@ -266,10 +266,10 @@ index 810d1cd9181..9074b640fff 100644
}
int TextCodecICU::DecodeToBuffer(UChar* target,
diff --git a/chromium/ui/base/l10n/formatter.cc b/chromium/ui/base/l10n/formatter.cc
diff --git a/src/3rdparty/chromium/ui/base/l10n/formatter.cc b/src/3rdparty/chromium/ui/base/l10n/formatter.cc
index 486a3a029cb..d7a41724628 100644
--- a/chromium/ui/base/l10n/formatter.cc
+++ b/chromium/ui/base/l10n/formatter.cc
--- a/src/3rdparty/chromium/ui/base/l10n/formatter.cc
+++ b/src/3rdparty/chromium/ui/base/l10n/formatter.cc
@@ -232,7 +232,7 @@ void Formatter::Format(Unit unit,
int value,
icu::UnicodeString* formatted_string) const {
@@ -1,31 +0,0 @@
diff -ur qtwebengine-everywhere-src-5.6.0-beta/src/3rdparty/chromium/net/socket/ssl_client_socket_openssl.cc
qtwebengine-everywhere-src-5.6.0-beta-chimera-nss-init/src/3rdparty/chromium/net/socket/ssl_client_socket_openssl.cc
--- qtwebengine-everywhere-src-5.6.0-beta/src/3rdparty/chromium/net/socket/ssl_client_socket_openssl.cc 2015-12-10 18:17:21.000000000 +0100
+++ qtwebengine-everywhere-src-5.6.0-beta-chimera-nss-init/src/3rdparty/chromium/net/socket/ssl_client_socket_openssl.cc 2016-01-14
17:11:38.432633534 +0100
@@ -57,6 +57,10 @@
#include "net/ssl/ssl_platform_key.h"
#endif
+#if defined(USE_NSS_CERTS) || defined(OS_IOS)
+#include "net/cert_net/nss_ocsp.h"
+#endif
+
namespace net {
namespace {
@@ -795,6 +799,14 @@
DCHECK(!ssl_);
DCHECK(!transport_bio_);
+#if defined(USE_NSS_CERTS) || defined(OS_IOS)
+ if (ssl_config_.cert_io_enabled) {
+ // TODO(davidben): Move this out of SSLClientSocket. See
+ // https://crbug.com/539520.
+ EnsureNSSHttpIOInit();
+ }
+#endif
+
SSLContext* context = SSLContext::GetInstance();
crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
@@ -1,101 +0,0 @@
From 721cd2d24995df8f7960cc5e8a96be1d2cd05f29 Mon Sep 17 00:00:00 2001
From: Michal Klocek <michal.klocek@qt.io>
Date: Tue, 27 Nov 2018 12:07:00 +0100
Subject: Fix missing TransportSecurityPersister
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit d603b7055 introduced TrasnsportSecurityPersister,
however it did not survive merge form 5.11 to 5.12.
Task-number: QTBUG-69605
Change-Id: I6357af25afcfd5c08aae77695bd2131f1cef6b71
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
---
src/core/profile_io_data_qt.cpp | 19 +++++++++++++++++--
src/core/profile_io_data_qt.h | 3 +++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index 7aaddc35..0a0d242a 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -59,6 +59,7 @@
#include "net/http/http_cache.h"
#include "net/http/http_server_properties_impl.h"
#include "net/http/http_network_session.h"
+#include "net/http/transport_security_persister.h"
#include "net/proxy_resolution/dhcp_pac_file_fetcher_factory.h"
#include "net/proxy_resolution/pac_file_fetcher_impl.h"
#include "net/proxy_resolution/proxy_config_service.h"
@@ -267,6 +268,7 @@ void ProfileIODataQt::generateStorage()
// we need to get rid of dangling pointer due to coming storage deletion
m_urlRequestContext->set_http_transaction_factory(0);
m_httpNetworkSession.reset();
+ m_transportSecurityPersister.reset();
}
m_storage.reset(new net::URLRequestContextStorage(m_urlRequestContext.get()));
@@ -299,8 +301,20 @@ void ProfileIODataQt::generateStorage()
m_networkDelegate.get()));
m_storage->set_ssl_config_service(std::make_unique<net::SSLConfigServiceDefaults>());
- m_storage->set_transport_security_state(std::unique_ptr<net::TransportSecurityState>(
- new net::TransportSecurityState()));
+ m_storage->set_transport_security_state(std::make_unique<net::TransportSecurityState>());
+
+ if (!m_dataPath.isEmpty()) {
+ scoped_refptr<base::SequencedTaskRunner> background_task_runner(
+ base::CreateSequencedTaskRunnerWithTraits(
+ {base::MayBlock(),
+ base::TaskPriority::BACKGROUND,
+ base::TaskShutdownBehavior::BLOCK_SHUTDOWN}));
+ m_transportSecurityPersister =
+ std::make_unique<net::TransportSecurityPersister>(
+ m_urlRequestContext->transport_security_state(),
+ toFilePath(m_dataPath),
+ background_task_runner);
+ };
if (!m_httpAuthPreferences)
m_httpAuthPreferences.reset(new net::HttpAuthPreferences());
@@ -566,6 +580,7 @@ void ProfileIODataQt::setFullConfiguration()
m_httpCachePath = m_profileAdapter->httpCachePath();
m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize();
m_customUrlSchemes = m_profileAdapter->customUrlSchemes();
+ m_dataPath = m_profileAdapter->dataPath();
}
void ProfileIODataQt::updateStorageSettings()
diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h
index 60f4d2d1..6961e2ad 100644
--- a/src/core/profile_io_data_qt.h
+++ b/src/core/profile_io_data_qt.h
@@ -58,6 +58,7 @@ class ProxyConfigService;
class URLRequestContext;
class URLRequestContextStorage;
class URLRequestJobFactoryImpl;
+class TransportSecurityPersister;
}
namespace QtWebEngineCore {
@@ -113,6 +114,7 @@ private:
std::unique_ptr<net::DhcpPacFileFetcherFactory> m_dhcpPacFileFetcherFactory;
std::unique_ptr<net::HttpAuthPreferences> m_httpAuthPreferences;
std::unique_ptr<net::URLRequestJobFactory> m_jobFactory;
+ std::unique_ptr<net::TransportSecurityPersister> m_transportSecurityPersister;
base::WeakPtr<ProfileIODataQt> m_weakPtr;
scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
content::URLRequestInterceptorScopedVector m_requestInterceptors;
@@ -141,6 +143,7 @@ private:
bool m_updateUserAgent = false;
bool m_ignoreCertificateErrors = false;
base::WeakPtrFactory<ProfileIODataQt> m_weakPtrFactory; // this should be always the last member
+ QString m_dataPath;
DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt);
};
} // namespace QtWebEngineCore
--
cgit v1.2.1
@@ -1,121 +0,0 @@
From 20238f2c472af7b94d48a837d7723a209a87fd9e Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Wed, 14 Nov 2018 16:29:35 +0100
Subject: Fix autoscrolling
We were missing the connection between on begin frame and progressing
auto-scroll.
Change-Id: I651b35c031afedc9aeef1dc6a16547757b869633
Fixes: QTBUG-71370
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
---
src/core/compositor.cpp | 11 +++++++----
src/core/compositor.h | 4 +++-
src/core/render_widget_host_view_qt.cpp | 7 ++++++-
src/core/render_widget_host_view_qt.h | 1 +
4 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/core/compositor.cpp b/src/core/compositor.cpp
index 5dd05371..f7a5e651 100644
--- a/src/core/compositor.cpp
+++ b/src/core/compositor.cpp
@@ -40,15 +40,17 @@
#include "compositor.h"
#include "delegated_frame_node.h"
+#include "render_widget_host_view_qt.h"
-#include <components/viz/common/resources/returned_resource.h>
-#include <content/public/browser/browser_thread.h>
-#include <services/viz/public/interfaces/compositing/compositor_frame_sink.mojom.h>
+#include "components/viz/common/resources/returned_resource.h"
+#include "content/public/browser/browser_thread.h"
+#include "services/viz/public/interfaces/compositing/compositor_frame_sink.mojom.h"
namespace QtWebEngineCore {
-Compositor::Compositor()
+Compositor::Compositor(RenderWidgetHostViewQt *hostView)
: m_chromiumCompositorData(new ChromiumCompositorData)
+ , m_view(hostView)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -163,6 +165,7 @@ bool Compositor::OnBeginFrameDerivedImpl(const viz::BeginFrameArgs &args)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ m_view->OnBeginFrame(args.frame_time);
m_beginFrameSource->OnUpdateVSyncParameters(args.frame_time, args.interval);
if (m_frameSinkClient)
m_frameSinkClient->OnBeginFrame(args);
diff --git a/src/core/compositor.h b/src/core/compositor.h
index 4852d059..7d7db5d0 100644
--- a/src/core/compositor.h
+++ b/src/core/compositor.h
@@ -60,6 +60,7 @@ class CompositorFrameSinkClient;
namespace QtWebEngineCore {
+class RenderWidgetHostViewQt;
class RenderWidgetHostViewQtDelegate;
class ChromiumCompositorData;
@@ -84,7 +85,7 @@ class ChromiumCompositorData;
class Compositor final : private viz::BeginFrameObserverBase
{
public:
- explicit Compositor();
+ explicit Compositor(RenderWidgetHostViewQt *hostView);
~Compositor() override;
void setViewDelegate(RenderWidgetHostViewQtDelegate *viewDelegate);
@@ -105,6 +106,7 @@ private:
std::vector<viz::ReturnedResource> m_resourcesToRelease;
QExplicitlySharedDataPointer<ChromiumCompositorData> m_chromiumCompositorData;
+ RenderWidgetHostViewQt *m_view;
RenderWidgetHostViewQtDelegate *m_viewDelegate = nullptr;
std::unique_ptr<viz::SyntheticBeginFrameSource> m_beginFrameSource;
viz::mojom::CompositorFrameSinkClient *m_frameSinkClient = nullptr;
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 9706ac07..4ed62504 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -260,7 +260,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
, m_gestureProvider(QtGestureProviderConfig(), this)
, m_sendMotionActionDown(false)
, m_touchMotionStarted(false)
- , m_compositor(new Compositor)
+ , m_compositor(new Compositor(this))
, m_loadVisuallyCommittedState(NotCommitted)
, m_adapterClient(0)
, m_imeInProgress(false)
@@ -1637,6 +1637,11 @@ void RenderWidgetHostViewQt::SetNeedsBeginFrames(bool needs_begin_frames)
m_compositor->setNeedsBeginFrames(needs_begin_frames);
}
+void RenderWidgetHostViewQt::OnBeginFrame(base::TimeTicks frame_time)
+{
+ host()->ProgressFlingIfNeeded(frame_time);
+}
+
content::RenderFrameHost *RenderWidgetHostViewQt::getFocusedFrameHost()
{
content::RenderViewHostImpl *viewHost = content::RenderViewHostImpl::From(host());
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 8db3351f..6dd4d57e 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -112,6 +112,7 @@ public:
RenderWidgetHostViewQtDelegate *delegate() { return m_delegate.get(); }
void setDelegate(RenderWidgetHostViewQtDelegate *delegate);
void setAdapterClient(WebContentsAdapterClient *adapterClient);
+ void OnBeginFrame(base::TimeTicks frame_time);
void InitAsChild(gfx::NativeView) override;
void InitAsPopup(content::RenderWidgetHostView*, const gfx::Rect&) override;
--
cgit v1.2.1
@@ -1,29 +0,0 @@
From 4746bb904bf6841137d5b50357bf79c852bf5d06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=BCri=20Valdmann?= <juri.valdmann@qt.io>
Date: Thu, 4 Jul 2019 15:38:05 +0200
Subject: Null check result of consuming mailbox texture
Fixes: QTBUG-76913
Change-Id: Ib036121f366d037d507f59bf31c3ab9c79bfea5e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
---
src/core/compositor/compositor_resource_tracker.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/core/compositor/compositor_resource_tracker.cpp b/src/core/compositor/compositor_resource_tracker.cpp
index 73242c69..741c2717 100644
--- a/src/core/compositor/compositor_resource_tracker.cpp
+++ b/src/core/compositor/compositor_resource_tracker.cpp
@@ -174,7 +174,8 @@ quint32 CompositorResourceTracker::consumeMailbox(const gpu::MailboxHolder &mail
DCHECK(mailboxManager);
if (mailboxHolder.sync_token.HasData())
mailboxManager->PullTextureUpdates(mailboxHolder.sync_token);
- return service_id(mailboxManager->ConsumeTexture(mailboxHolder.mailbox));
+ gpu::TextureBase *tex = mailboxManager->ConsumeTexture(mailboxHolder.mailbox);
+ return tex ? service_id(tex) : 0;
#else
NOTREACHED();
#endif // QT_CONFIG(OPENGL)
--
cgit v1.2.1
@@ -1,11 +0,0 @@
--- qtwebengine-everywhere-src-5.13.0/src/core/config/linux.pri.orig 2019-08-06 08:23:45.385072740 +0300
+++ qtwebengine-everywhere-src-5.13.0/src/core/config/linux.pri 2019-08-06 08:23:51.085237082 +0300
@@ -162,7 +162,7 @@ host_build {
qtConfig(webengine-system-harfbuzz): gn_args += use_system_harfbuzz=true
!qtConfig(webengine-system-glib): gn_args += use_glib=false
qtConfig(webengine-pulseaudio) {
- gn_args += use_pulseaudio=true
+ gn_args += use_pulseaudio=true link_pulseaudio=true
} else {
gn_args += use_pulseaudio=false
}
@@ -1,44 +0,0 @@
From 4e828b3bd2d410151dc2574d084bed631dac42ca Mon Sep 17 00:00:00 2001
From: Daniel McArdle <dmcardle@chromium.org>
Date: Thu, 16 Apr 2020 20:18:47 +0000
Subject: [Backport] Fix for bug 1071327
Manual backport of patch originally reviewed on
https://chromium-review.googlesource.com/c/chromium/src/+/2153325:
Avoid nullptr dereference in RTCPeerConnectionHandler
Bug: 1071327
Fixes: QTBUG-86752
Change-Id: Icf4189905dc5c95854b5af4b3e5e25e0607dd39e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
---
.../renderer/modules/peerconnection/rtc_peer_connection_handler.cc | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/3rdparty/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc b/src/3rdparty/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc
index 5a68327ee08..371f25c781e 100644
--- a/src/3rdparty/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc
+++ b/src/3rdparty/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_handler.cc
@@ -2319,7 +2319,8 @@ void RTCPeerConnectionHandler::OnRemoveReceiverPlanB(uintptr_t receiver_id) {
void RTCPeerConnectionHandler::OnModifySctpTransport(
blink::WebRTCSctpTransportSnapshot state) {
- client_->DidModifySctpTransport(state);
+ if (client_)
+ client_->DidModifySctpTransport(state);
}
void RTCPeerConnectionHandler::OnModifyTransceivers(
@@ -2446,7 +2447,8 @@ void RTCPeerConnectionHandler::OnIceCandidateError(const String& host_candidate,
}
void RTCPeerConnectionHandler::OnInterestingUsage(int usage_pattern) {
- client_->DidNoteInterestingUsage(usage_pattern);
+ if (client_)
+ client_->DidNoteInterestingUsage(usage_pattern);
}
webrtc::SessionDescriptionInterface*
--
cgit v1.2.1
@@ -1,105 +0,0 @@
From 424584b4984bde7c831f42e9fb47f1ad583a1c46 Mon Sep 17 00:00:00 2001
From: jshin <jshin@chromium.org>
Date: Fri, 21 Oct 2016 01:15:50 -0700
Subject: [PATCH] Update aspirational_scripts per Unicode 9
This is a preparation to update ICU to 58.1.
Without this change, ICU update CL cannot be tested on
trybots because a compile will fail due to '#error' checking
if ICU version is less than 58.
BUG=637001
TEST=None
TBR=pkasting@chromium.org
Review-Url: https://chromiumcodereview.appspot.com/2436113003
Cr-Commit-Position: refs/heads/master@{#426749}
---
components/url_formatter/url_formatter.cc | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/components/url_formatter/url_formatter.cc b/components/url_formatter/url_formatter.cc
index 4455db3..2b82c0c 100644
--- qtwebengine-everywhere-src-5.7.0.orig/src/3rdparty/chromium/components/url_formatter/url_formatter.cc
+++ qtwebengine-everywhere-src-5.7.0/src/3rdparty/chromium/components/url_formatter/url_formatter.cc
@@ -428,9 +428,9 @@ void IDNSpoofChecker::SetAllowedUnicodeSet(UErrorCode* status) {
// section at
// http://www.unicode.org/Public/security/latest/xidmodifications.txt) are
// are added to the allowed set. The list has to be updated when a new
- // version of Unicode is released. The current version is 8.0.0 and ICU 58
- // will have Unicode 9.0 data.
-#if U_ICU_VERSION_MAJOR_NUM < 58
+ // version of Unicode is released. The current version is 9.0.0 and ICU 60
+ // will have Unicode 10.0 data.
+#if U_ICU_VERSION_MAJOR_NUM < 60
const icu::UnicodeSet aspirational_scripts(
icu::UnicodeString(
// Unified Canadian Syllabics
@@ -444,13 +444,13 @@ void IDNSpoofChecker::SetAllowedUnicodeSet(UErrorCode* status) {
// Yi
"\\uA000-\\uA48C"
// Miao
- "\\U00016F00-\\U00016F44\\U00016F50-\\U00016F7F"
+ "\\U00016F00-\\U00016F44\\U00016F50-\\U00016F7E"
"\\U00016F8F-\\U00016F9F]",
-1, US_INV),
*status);
allowed_set.addAll(aspirational_scripts);
#else
-#error "Update aspirational_scripts per Unicode 9.0"
+#error "Update aspirational_scripts per Unicode 10.0"
#endif
// U+0338 is included in the recommended set, while U+05F4 and U+2027 are in
diff -Naur qtwebengine-everywhere-src-5.7.0.orig/src/3rdparty/chromium/third_party/WebKit/Source/platform/text/TextBreakIterator.cpp
qtwebengine-everywhere-src-5.7.0/src/3rdparty/chromium/third_party/WebKit/Source/platform/text/TextBreakIterator.cpp
--- qtwebengine-everywhere-src-5.7.0.orig/src/3rdparty/chromium/third_party/WebKit/Source/platform/text/TextBreakIterator.cpp 2016-11-15 17:07:38.680665385 -0800
+++ qtwebengine-everywhere-src-5.7.0/src/3rdparty/chromium/third_party/WebKit/Source/platform/text/TextBreakIterator.cpp 2016-11-15 17:12:17.564001354 -0800
@@ -26,6 +26,9 @@
#include "wtf/StdLibExtras.h"
#include "wtf/text/CharacterNames.h"
+#include <unicode/uchar.h>
+#include <unicode/uvernum.h>
+
namespace blink {
unsigned numGraphemeClusters(const String& string)
@@ -122,13 +125,18 @@
{ B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0), 0, 0, 0, B(0, 0, 0, 0, 0, 0, 0, 0) }, // DEL
};
+#if U_ICU_VERSION_MAJOR_NUM >= 58
+#define BA_LB_COUNT (U_LB_COUNT - 3)
+#else
+#define BA_LB_COUNT U_LB_COUNT
+#endif
// Line breaking table for CSS word-break: break-all. This table differs from
// asciiLineBreakTable in:
// - Indices are Line Breaking Classes defined in UAX#14 Unicode Line Breaking
// Algorithm: http://unicode.org/reports/tr14/#DescriptionOfProperties
// - 1 indicates additional break opportunities. 0 indicates to fallback to
// normal line break, not "prohibit break."
-static const unsigned char breakAllLineBreakClassTable[][U_LB_COUNT / 8 + 1] = {
+static const unsigned char breakAllLineBreakClassTable[][BA_LB_COUNT / 8 + 1] = {
// XX AI AL B2 BA BB BK CB CL CM CR EX GL HY ID IN IS LF NS NU OP PO PR QU SA SG SP SY ZW NL WJ H2 H3 JL JT JV CP CJ HL RI
{ B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 0, 0) }, // XX
{ B(0, 1, 1, 0, 1, 0, 0, 0), B(0, 0, 0, 0, 0, 1, 0, 0), B(0, 0, 0, 1, 1, 0, 1, 0), B(1, 0, 0, 0, 0, 0, 0, 0), B(0, 0, 0, 0, 0, 0, 1, 0) }, // AI
@@ -178,7 +186,7 @@
#undef AL
static_assert(WTF_ARRAY_LENGTH(asciiLineBreakTable) == asciiLineBreakTableLastChar - asciiLineBreakTableFirstChar + 1, "asciiLineBreakTable should be consistent");
-static_assert(WTF_ARRAY_LENGTH(breakAllLineBreakClassTable) == U_LB_COUNT, "breakAllLineBreakClassTable should be consistent");
+static_assert(WTF_ARRAY_LENGTH(breakAllLineBreakClassTable) == BA_LB_COUNT, "breakAllLineBreakClassTable should be consistent");
static inline bool shouldBreakAfter(UChar lastCh, UChar ch, UChar nextCh)
{
@@ -209,7 +217,7 @@
static inline bool shouldBreakAfterBreakAll(ULineBreak lastLineBreak, ULineBreak lineBreak)
{
- if (lineBreak >= 0 && lineBreak < U_LB_COUNT && lastLineBreak >= 0 && lastLineBreak < U_LB_COUNT) {
+ if (lineBreak >= 0 && lineBreak < BA_LB_COUNT && lastLineBreak >= 0 && lastLineBreak < BA_LB_COUNT) {
const unsigned char* tableRow = breakAllLineBreakClassTable[lastLineBreak];
return tableRow[lineBreak / 8] & (1 << (lineBreak % 8));
}
@@ -1,11 +0,0 @@
--- a/src/3rdparty/chromium/components/url_formatter/url_formatter.cc 2017-11-08 21:13:31.000000000 +0200
+++ b/src/3rdparty/chromium/components/url_formatter/url_formatter.cc 2017-11-30 16:37:00.116153976 +0200
@@ -488,7 +488,7 @@
// are added to the allowed set. The list has to be updated when a new
// version of Unicode is released. The current version is 9.0.0 and ICU 60
// will have Unicode 10.0 data.
-#if U_ICU_VERSION_MAJOR_NUM < 60
+#if U_ICU_VERSION_MAJOR_NUM < 60 || defined(TOOLKIT_QT)
const icu::UnicodeSet aspirational_scripts(
icu::UnicodeString(
// Unified Canadian Syllabics
@@ -1,89 +0,0 @@
diff --git a/src/3rdparty/chromium/media/base/decoder_buffer.h b/src/3rdparty/chromium/media/base/decoder_buffer.h
index 0341e5784f..60ffba708b 100644
--- a/src/3rdparty/chromium/media/base/decoder_buffer.h
+++ b/src/3rdparty/chromium/media/base/decoder_buffer.h
@@ -37,7 +37,7 @@ class MEDIA_EXPORT DecoderBuffer
: public base::RefCountedThreadSafe<DecoderBuffer> {
public:
enum {
- kPaddingSize = 32,
+ kPaddingSize = 64,
#if defined(ARCH_CPU_ARM_FAMILY)
kAlignmentSize = 16
#else
diff --git a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc
index 61d0bc341c..d79c694555 100644
--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc
+++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.cc
@@ -30,10 +30,10 @@ EncryptionScheme GetEncryptionScheme(const AVStream* stream) {
} // namespace
-// Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are
+// Why AV_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are
// padded. Check here to ensure FFmpeg only receives data padded to its
// specifications.
-static_assert(DecoderBuffer::kPaddingSize >= FF_INPUT_BUFFER_PADDING_SIZE,
+static_assert(DecoderBuffer::kPaddingSize >= AV_INPUT_BUFFER_PADDING_SIZE,
"DecoderBuffer padding size does not fit ffmpeg requirement");
// Alignment requirement by FFmpeg for input and output buffers. This need to
@@ -444,11 +444,11 @@ void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config,
} else {
codec_context->extradata_size = config.extra_data().size();
codec_context->extradata = reinterpret_cast<uint8_t*>(
- av_malloc(config.extra_data().size() + FF_INPUT_BUFFER_PADDING_SIZE));
+ av_malloc(config.extra_data().size() + AV_INPUT_BUFFER_PADDING_SIZE));
memcpy(codec_context->extradata, &config.extra_data()[0],
config.extra_data().size());
memset(codec_context->extradata + config.extra_data().size(), '\0',
- FF_INPUT_BUFFER_PADDING_SIZE);
+ AV_INPUT_BUFFER_PADDING_SIZE);
}
}
@@ -585,11 +585,11 @@ void VideoDecoderConfigToAVCodecContext(
} else {
codec_context->extradata_size = config.extra_data().size();
codec_context->extradata = reinterpret_cast<uint8_t*>(
- av_malloc(config.extra_data().size() + FF_INPUT_BUFFER_PADDING_SIZE));
+ av_malloc(config.extra_data().size() + AV_INPUT_BUFFER_PADDING_SIZE));
memcpy(codec_context->extradata, &config.extra_data()[0],
config.extra_data().size());
memset(codec_context->extradata + config.extra_data().size(), '\0',
- FF_INPUT_BUFFER_PADDING_SIZE);
+ AV_INPUT_BUFFER_PADDING_SIZE);
}
}
diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
index b4020b001d..41da2d3939 100644
--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
@@ -368,7 +368,7 @@ void FFmpegAudioDecoder::ResetTimestampState(const AudioDecoderConfig& config) {
int FFmpegAudioDecoder::GetAudioBuffer(struct AVCodecContext* s,
AVFrame* frame,
int flags) {
- DCHECK(s->codec->capabilities & CODEC_CAP_DR1);
+ DCHECK(s->codec->capabilities & AV_CODEC_CAP_DR1);
DCHECK_EQ(s->codec_type, AVMEDIA_TYPE_AUDIO);
// Since this routine is called by FFmpeg when a buffer is required for audio
diff --git a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
index 42d044dd69..32f5c7b79d 100644
--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
@@ -427,12 +427,11 @@ bool FFmpegVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config,
codec_context_->thread_type =
FF_THREAD_SLICE | (low_delay ? 0 : FF_THREAD_FRAME);
codec_context_->opaque = this;
- codec_context_->flags |= CODEC_FLAG_EMU_EDGE;
codec_context_->get_buffer2 = GetVideoBufferImpl;
codec_context_->refcounted_frames = 1;
if (decode_nalus_)
- codec_context_->flags2 |= CODEC_FLAG2_CHUNKS;
+ codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
@@ -1,77 +0,0 @@
--- qtwebengine-opensource-src-5.9.1/src/3rdparty/chromium/third_party/skia/src/ports/SkFontHost_FreeType.cpp.orig 2017-10-10 17:42:06.956950985 +0200
+++ qtwebengine-opensource-src-5.9.1/src/3rdparty/chromium/third_party/skia/src/ports/SkFontHost_FreeType.cpp 2017-10-10 17:46:05.824187787 +0200
@@ -99,8 +99,6 @@
FreeTypeLibrary()
: fGetVarDesignCoordinates(nullptr)
, fLibrary(nullptr)
- , fIsLCDSupported(false)
- , fLCDExtra(0)
{
if (FT_New_Library(&gFTMemory, &fLibrary)) {
return;
@@ -147,12 +145,7 @@
}
#endif
- // Setup LCD filtering. This reduces color fringes for LCD smoothed glyphs.
- // The default has changed over time, so this doesn't mean the same thing to all users.
- if (FT_Library_SetLcdFilter(fLibrary, FT_LCD_FILTER_DEFAULT) == 0) {
- fIsLCDSupported = true;
- fLCDExtra = 2; //Using a filter adds one full pixel to each side.
- }
+ FT_Library_SetLcdFilter(fLibrary, FT_LCD_FILTER_DEFAULT);
}
~FreeTypeLibrary() {
if (fLibrary) {
@@ -161,8 +153,6 @@
}
FT_Library library() { return fLibrary; }
- bool isLCDSupported() { return fIsLCDSupported; }
- int lcdExtra() { return fLCDExtra; }
// FT_Get_{MM,Var}_{Blend,Design}_Coordinates were added in FreeType 2.7.1.
// Prior to this there was no way to get the coordinates out of the FT_Face.
@@ -173,8 +163,6 @@
private:
FT_Library fLibrary;
- bool fIsLCDSupported;
- int fLCDExtra;
// FT_Library_SetLcdFilterWeights was introduced in FreeType 2.4.0.
// The following platforms provide FreeType of at least 2.4.0.
@@ -704,17 +692,6 @@
rec->fTextSize = SkIntToScalar(1 << 14);
}
- if (isLCD(*rec)) {
- // TODO: re-work so that FreeType is set-up and selected by the SkFontMgr.
- SkAutoMutexAcquire ama(gFTMutex);
- ref_ft_library();
- if (!gFTLibrary->isLCDSupported()) {
- // If the runtime Freetype library doesn't support LCD, disable it here.
- rec->fMaskFormat = SkMask::kA8_Format;
- }
- unref_ft_library();
- }
-
SkPaint::Hinting h = rec->getHinting();
if (SkPaint::kFull_Hinting == h && !isLCD(*rec)) {
// collapse full->normal hinting if we're not doing LCD
@@ -1115,11 +1092,11 @@
void SkScalerContext_FreeType::updateGlyphIfLCD(SkGlyph* glyph) {
if (isLCD(fRec)) {
if (fLCDIsVert) {
- glyph->fHeight += gFTLibrary->lcdExtra();
- glyph->fTop -= gFTLibrary->lcdExtra() >> 1;
+ glyph->fHeight += 2;
+ glyph->fTop -= 1;
} else {
- glyph->fWidth += gFTLibrary->lcdExtra();
- glyph->fLeft -= gFTLibrary->lcdExtra() >> 1;
+ glyph->fWidth += 2;
+ glyph->fLeft -= 1;
}
}
}
@@ -1,99 +0,0 @@
From: Antonio Larrosa <alarrosa@suse.com>
Subject: Disable GPU when using nouveau or running on wayland
References: boo#1005323, boo#1060990
Qt WebEngine uses multi-threaded OpenGL, which nouveau does not support.
It also crashes when running on wayland, the cause is not yet known.
Work around these issues by not doing GPU-accelerated rendering in such
cases.
Index: qtwebengine-everywhere-src-5.10.0/src/core/web_engine_context.cpp
===================================================================
--- qtwebengine-everywhere-src-5.10.0.orig/src/core/web_engine_context.cpp
+++ qtwebengine-everywhere-src-5.10.0/src/core/web_engine_context.cpp
@@ -93,6 +93,7 @@
#include <QOffscreenSurface>
#ifndef QT_NO_OPENGL
# include <QOpenGLContext>
+# include <QOpenGLFunctions>
#endif
#include <QQuickWindow>
#include <QStringList>
@@ -167,6 +168,39 @@ void dummyGetPluginCallback(const std::v
}
#endif
+#ifndef QT_NO_OPENGL
+QString openGLVendor()
+{
+ QString vendor;
+
+ QOpenGLContext *oldContext = QOpenGLContext::currentContext();
+ QSurface *oldSurface = 0;
+ if (oldContext)
+ oldSurface = oldContext->surface();
+
+ QScopedPointer<QOffscreenSurface> surface( new QOffscreenSurface );
+ surface->create();
+ QOpenGLContext context;
+ if (!context.create()) {
+ qDebug() << "Error creating openGL context";
+ }
+ else if (!context.makeCurrent(surface.data())) {
+ qDebug() << "Error making openGL context current context";
+ } else {
+ const GLubyte *p;
+ QOpenGLFunctions *f = context.functions();
+ if ((p = f->glGetString(GL_VENDOR)))
+ vendor = QString::fromLatin1(reinterpret_cast<const char *>(p));
+ }
+
+ context.doneCurrent();
+ if (oldContext && oldSurface)
+ oldContext->makeCurrent(oldSurface);
+
+ return vendor;
+}
+#endif
+
} // namespace
namespace QtWebEngineCore {
@@ -379,6 +413,27 @@ WebEngineContext::WebEngineContext()
const char *glType = 0;
#ifndef QT_NO_OPENGL
+ bool disableGpu = qEnvironmentVariableIsSet("QT_WEBENGINE_DISABLE_GPU");
+
+ if (!qEnvironmentVariableIsSet("QT_WEBENGINE_DISABLE_WAYLAND_WORKAROUND") && platform.startsWith("wayland", Qt::CaseInsensitive))
+ {
+ qWarning() << "Running on wayland. Qt WebEngine will disable usage of the GPU.\n"
+ "Note: you can set the QT_WEBENGINE_DISABLE_WAYLAND_WORKAROUND\n"
+ "environment variable before running this application, but this is \n"
+ "not recommended since this usually causes applications to crash.";
+ disableGpu = true;
+ }
+
+ if (!qEnvironmentVariableIsSet("QT_WEBENGINE_DISABLE_NOUVEAU_WORKAROUND") && openGLVendor() == QStringLiteral("nouveau"))
+ {
+ qWarning() << "Nouveau openGL driver detected. Qt WebEngine will disable usage of the GPU.\n"
+ "Note: you can set the QT_WEBENGINE_DISABLE_NOUVEAU_WORKAROUND\n"
+ "environment variable before running this application, but this is \n"
+ "not recommended since this usually causes applications to crash as\n"
+ "Nouveau openGL drivers don't support multithreaded rendering";
+ disableGpu = true;
+ }
+
bool tryGL =
!usingANGLE()
&& (!usingSoftwareDynamicGL()
@@ -389,7 +444,7 @@ WebEngineContext::WebEngineContext()
|| enableWebGLSoftwareRendering
#endif
)
- && !usingQtQuick2DRenderer();
+ && !usingQtQuick2DRenderer() && !disableGpu;
if (tryGL) {
if (qt_gl_global_share_context() && qt_gl_global_share_context()->isValid()) {
@@ -1,985 +0,0 @@
--- a/src/3rdparty/chromium/third_party/re2/src/re2/re2.h
+++ b/src/3rdparty/chromium/third_party/re2/src/re2/re2.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#ifndef RE2_RE2_H
-#define RE2_RE2_H
+#ifndef RE2_RE2_H_
+#define RE2_RE2_H_
// C++ interface to the re2 regular-expression library.
// RE2 supports Perl-style regular expressions (with extensions like
@@ -179,38 +179,25 @@
// RE2::Octal(&a), RE2::Hex(&b), RE2::CRadix(&c), RE2::CRadix(&d));
// will leave 64 in a, b, c, and d.
+#include <stddef.h>
#include <stdint.h>
+#include <sys/types.h>
+#include <algorithm>
#include <map>
+#include <mutex>
#include <string>
-#include "re2/stringpiece.h"
-#include "re2/variadic_function.h"
-#ifndef RE2_HAVE_LONGLONG
-#define RE2_HAVE_LONGLONG 1
-#endif
+#include "re2/stringpiece.h"
namespace re2 {
-
-using std::string;
-using std::map;
-class Mutex;
class Prog;
class Regexp;
+} // namespace re2
+
+namespace re2 {
-// The following enum should be used only as a constructor argument to indicate
-// that the variable has static storage class, and that the constructor should
-// do nothing to its state. It indicates to the reader that it is legal to
-// declare a static instance of the class, provided the constructor is given
-// the LINKER_INITIALIZED argument. Normally, it is unsafe to declare a
-// static variable that has a constructor or a destructor because invocation
-// order is undefined. However, IF the type can be initialized by filling with
-// zeroes (which the loader does for static variables), AND the type's
-// destructor does nothing to the storage, then a constructor for static
-// initialization can be declared as
-// explicit MyClass(LinkerInitialized x) {}
-// and invoked as
-// static MyClass my_variable_name(LINKER_INITIALIZED);
-enum LinkerInitialized { LINKER_INITIALIZED };
+// TODO(junyer): Get rid of this.
+using std::string;
// Interface for regular expression matching. Also corresponds to a
// pre-compiled regular expression. An "RE2" object is safe for
@@ -266,7 +253,7 @@ class RE2 {
RE2(const string& pattern);
#endif
RE2(const StringPiece& pattern);
- RE2(const StringPiece& pattern, const Options& option);
+ RE2(const StringPiece& pattern, const Options& options);
~RE2();
// Returns whether RE2 was created properly.
@@ -296,7 +283,7 @@ class RE2 {
// EXPERIMENTAL! SUBJECT TO CHANGE!
// Outputs the program fanout as a histogram bucketed by powers of 2.
// Returns the number of the largest non-empty bucket.
- int ProgramFanout(map<int, int>* histogram) const;
+ int ProgramFanout(std::map<int, int>* histogram) const;
// Returns the underlying Regexp; not for general use.
// Returns entire_regexp_ so that callers don't need
@@ -305,21 +292,21 @@ class RE2 {
/***** The useful part: the matching interface *****/
- // Matches "text" against "pattern". If pointer arguments are
+ // Matches "text" against "re". If pointer arguments are
// supplied, copies matched sub-patterns into them.
//
// You can pass in a "const char*" or a "string" for "text".
- // You can pass in a "const char*" or a "string" or a "RE2" for "pattern".
+ // You can pass in a "const char*" or a "string" or a "RE2" for "re".
//
// The provided pointer arguments can be pointers to any scalar numeric
// type, or one of:
// string (matched piece is copied to string)
// StringPiece (StringPiece is mutated to point to matched piece)
- // T (where "bool T::ParseFrom(const char*, int)" exists)
+ // T (where "bool T::ParseFrom(const char*, size_t)" exists)
// (void*)NULL (the corresponding matched sub-pattern is not copied)
//
// Returns true iff all of the following conditions are satisfied:
- // a. "text" matches "pattern" exactly
+ // a. "text" matches "re" exactly
// b. The number of matched sub-patterns is >= number of supplied pointers
// c. The "i"th argument has a suitable type for holding the
// string captured as the "i"th sub-pattern. If you pass in
@@ -335,32 +322,65 @@ class RE2 {
// RE2::FullMatch("abc", "[a-z]+(\\d+)?", &number);
static bool FullMatchN(const StringPiece& text, const RE2& re,
const Arg* const args[], int argc);
- static const VariadicFunction2<
- bool, const StringPiece&, const RE2&, Arg, RE2::FullMatchN> FullMatch;
- // Exactly like FullMatch(), except that "pattern" is allowed to match
+ // Exactly like FullMatch(), except that "re" is allowed to match
// a substring of "text".
- static bool PartialMatchN(const StringPiece& text, const RE2& re, // 3..16 args
+ static bool PartialMatchN(const StringPiece& text, const RE2& re,
const Arg* const args[], int argc);
- static const VariadicFunction2<
- bool, const StringPiece&, const RE2&, Arg, RE2::PartialMatchN> PartialMatch;
- // Like FullMatch() and PartialMatch(), except that pattern has to
- // match a prefix of "text", and "input" is advanced past the matched
+ // Like FullMatch() and PartialMatch(), except that "re" has to match
+ // a prefix of the text, and "input" is advanced past the matched
// text. Note: "input" is modified iff this routine returns true.
- static bool ConsumeN(StringPiece* input, const RE2& pattern, // 3..16 args
+ static bool ConsumeN(StringPiece* input, const RE2& re,
const Arg* const args[], int argc);
- static const VariadicFunction2<
- bool, StringPiece*, const RE2&, Arg, RE2::ConsumeN> Consume;
- // Like Consume(..), but does not anchor the match at the beginning of the
- // string. That is, "pattern" need not start its match at the beginning of
- // "input". For example, "FindAndConsume(s, "(\\w+)", &word)" finds the next
- // word in "s" and stores it in "word".
- static bool FindAndConsumeN(StringPiece* input, const RE2& pattern,
- const Arg* const args[], int argc);
- static const VariadicFunction2<
- bool, StringPiece*, const RE2&, Arg, RE2::FindAndConsumeN> FindAndConsume;
+ // Like Consume(), but does not anchor the match at the beginning of
+ // the text. That is, "re" need not start its match at the beginning
+ // of "input". For example, "FindAndConsume(s, "(\\w+)", &word)" finds
+ // the next word in "s" and stores it in "word".
+ static bool FindAndConsumeN(StringPiece* input, const RE2& re,
+ const Arg* const args[], int argc);
+
+#ifndef SWIG
+ private:
+ template <typename F, typename SP>
+ static inline bool Apply(F f, SP sp, const RE2& re) {
+ return f(sp, re, NULL, 0);
+ }
+
+ template <typename F, typename SP, typename... A>
+ static inline bool Apply(F f, SP sp, const RE2& re, const A&... a) {
+ const Arg* const args[] = {&a...};
+ const int argc = sizeof...(a);
+ return f(sp, re, args, argc);
+ }
+
+ public:
+ // In order to allow FullMatch() et al. to be called with a varying number
+ // of arguments of varying types, we use two layers of variadic templates.
+ // The first layer constructs the temporary Arg objects. The second layer
+ // (above) constructs the array of pointers to the temporary Arg objects.
+
+ template <typename... A>
+ static bool FullMatch(const StringPiece& text, const RE2& re, A&&... a) {
+ return Apply(FullMatchN, text, re, Arg(std::forward<A>(a))...);
+ }
+
+ template <typename... A>
+ static bool PartialMatch(const StringPiece& text, const RE2& re, A&&... a) {
+ return Apply(PartialMatchN, text, re, Arg(std::forward<A>(a))...);
+ }
+
+ template <typename... A>
+ static bool Consume(StringPiece* input, const RE2& re, A&&... a) {
+ return Apply(ConsumeN, input, re, Arg(std::forward<A>(a))...);
+ }
+
+ template <typename... A>
+ static bool FindAndConsume(StringPiece* input, const RE2& re, A&&... a) {
+ return Apply(FindAndConsumeN, input, re, Arg(std::forward<A>(a))...);
+ }
+#endif
// Replace the first match of "pattern" in "str" with "rewrite".
// Within "rewrite", backslash-escaped digits (\1 to \9) can be
@@ -451,12 +471,12 @@ class RE2 {
// The map records the index of the leftmost group
// with the given name.
// Only valid until the re is deleted.
- const map<string, int>& NamedCapturingGroups() const;
+ const std::map<string, int>& NamedCapturingGroups() const;
// Return a map from capturing indices to names.
// The map has no entries for unnamed groups.
// Only valid until the re is deleted.
- const map<int, string>& CapturingGroupNames() const;
+ const std::map<int, string>& CapturingGroupNames() const;
// General matching routine.
// Match against text starting at offset startpos
@@ -465,8 +485,8 @@ class RE2 {
// On a successful match, fills in match[] (up to nmatch entries)
// with information about submatches.
// I.e. matching RE2("(foo)|(bar)baz") on "barbazbla" will return true,
- // setting match[0] = "barbaz", match[1] = NULL, match[2] = "bar",
- // match[3] = NULL, ..., up to match[nmatch-1] = NULL.
+ // setting match[0] = "barbaz", match[1].data() = NULL, match[2] = "bar",
+ // match[3].data() = NULL, ..., up to match[nmatch-1].data() = NULL.
//
// Don't ask for more match information than you will use:
// runs much faster with nmatch == 1 than nmatch > 1, and
@@ -477,10 +497,10 @@ class RE2 {
// Passing text == StringPiece(NULL, 0) will be handled like any other
// empty string, but note that on return, it will not be possible to tell
// whether submatch i matched the empty string or did not match:
- // either way, match[i] == NULL.
+ // either way, match[i].data() == NULL.
bool Match(const StringPiece& text,
- int startpos,
- int endpos,
+ size_t startpos,
+ size_t endpos,
Anchor anchor,
StringPiece *match,
int nmatch) const;
@@ -638,19 +658,7 @@ class RE2 {
void set_one_line(bool b) { one_line_ = b; }
void Copy(const Options& src) {
- encoding_ = src.encoding_;
- posix_syntax_ = src.posix_syntax_;
- longest_match_ = src.longest_match_;
- log_errors_ = src.log_errors_;
- max_mem_ = src.max_mem_;
- literal_ = src.literal_;
- never_nl_ = src.never_nl_;
- dot_nl_ = src.dot_nl_;
- never_capture_ = src.never_capture_;
- case_sensitive_ = src.case_sensitive_;
- perl_classes_ = src.perl_classes_;
- word_boundary_ = src.word_boundary_;
- one_line_ = src.one_line_;
+ *this = src;
}
int ParseFlags() const;
@@ -669,10 +677,6 @@ class RE2 {
bool perl_classes_;
bool word_boundary_;
bool one_line_;
-
- //DISALLOW_COPY_AND_ASSIGN(Options);
- Options(const Options&);
- void operator=(const Options&);
};
// Returns the options set in the constructor.
@@ -685,10 +689,8 @@ class RE2 {
static inline Arg CRadix(unsigned int* x);
static inline Arg CRadix(long* x);
static inline Arg CRadix(unsigned long* x);
- #if RE2_HAVE_LONGLONG
static inline Arg CRadix(long long* x);
static inline Arg CRadix(unsigned long long* x);
- #endif
static inline Arg Hex(short* x);
static inline Arg Hex(unsigned short* x);
@@ -696,10 +698,8 @@ class RE2 {
static inline Arg Hex(unsigned int* x);
static inline Arg Hex(long* x);
static inline Arg Hex(unsigned long* x);
- #if RE2_HAVE_LONGLONG
static inline Arg Hex(long long* x);
static inline Arg Hex(unsigned long long* x);
- #endif
static inline Arg Octal(short* x);
static inline Arg Octal(unsigned short* x);
@@ -707,47 +707,50 @@ class RE2 {
static inline Arg Octal(unsigned int* x);
static inline Arg Octal(long* x);
static inline Arg Octal(unsigned long* x);
- #if RE2_HAVE_LONGLONG
static inline Arg Octal(long long* x);
static inline Arg Octal(unsigned long long* x);
- #endif
private:
void Init(const StringPiece& pattern, const Options& options);
bool DoMatch(const StringPiece& text,
- Anchor anchor,
- int* consumed,
- const Arg* const args[],
- int n) const;
+ Anchor anchor,
+ size_t* consumed,
+ const Arg* const args[],
+ int n) const;
re2::Prog* ReverseProg() const;
- mutable Mutex* mutex_;
- string pattern_; // string regular expression
- Options options_; // option flags
+ string pattern_; // string regular expression
+ Options options_; // option flags
string prefix_; // required prefix (before regexp_)
bool prefix_foldcase_; // prefix is ASCII case-insensitive
re2::Regexp* entire_regexp_; // parsed regular expression
re2::Regexp* suffix_regexp_; // parsed regular expression, prefix removed
re2::Prog* prog_; // compiled program for regexp
- mutable re2::Prog* rprog_; // reverse program for regexp
- bool is_one_pass_; // can use prog_->SearchOnePass?
- mutable const string* error_; // Error indicator
- // (or points to empty string)
- mutable ErrorCode error_code_; // Error code
- mutable string error_arg_; // Fragment of regexp showing error
- mutable int num_captures_; // Number of capturing groups
+ bool is_one_pass_; // can use prog_->SearchOnePass?
+
+ mutable re2::Prog* rprog_; // reverse program for regexp
+ mutable const string* error_; // Error indicator
+ // (or points to empty string)
+ mutable ErrorCode error_code_; // Error code
+ mutable string error_arg_; // Fragment of regexp showing error
+ mutable int num_captures_; // Number of capturing groups
// Map from capture names to indices
- mutable const map<string, int>* named_groups_;
+ mutable const std::map<string, int>* named_groups_;
// Map from capture indices to names
- mutable const map<int, string>* group_names_;
+ mutable const std::map<int, string>* group_names_;
+
+ // Onces for lazy computations.
+ mutable std::once_flag rprog_once_;
+ mutable std::once_flag num_captures_once_;
+ mutable std::once_flag named_groups_once_;
+ mutable std::once_flag group_names_once_;
- //DISALLOW_COPY_AND_ASSIGN(RE2);
- RE2(const RE2&);
- void operator=(const RE2&);
+ RE2(const RE2&) = delete;
+ RE2& operator=(const RE2&) = delete;
};
/***** Implementation details *****/
@@ -758,7 +761,7 @@ class RE2 {
template <class T>
class _RE2_MatchObject {
public:
- static inline bool Parse(const char* str, int n, void* dest) {
+ static inline bool Parse(const char* str, size_t n, void* dest) {
if (dest == NULL) return true;
T* object = reinterpret_cast<T*>(dest);
return object->ParseFrom(str, n);
@@ -773,31 +776,29 @@ class RE2::Arg {
// Constructor specially designed for NULL arguments
Arg(void*);
- typedef bool (*Parser)(const char* str, int n, void* dest);
+ typedef bool (*Parser)(const char* str, size_t n, void* dest);
// Type-specific parsers
-#define MAKE_PARSER(type,name) \
- Arg(type* p) : arg_(p), parser_(name) { } \
- Arg(type* p, Parser parser) : arg_(p), parser_(parser) { } \
-
+#define MAKE_PARSER(type, name) \
+ Arg(type* p) : arg_(p), parser_(name) {} \
+ Arg(type* p, Parser parser) : arg_(p), parser_(parser) {}
MAKE_PARSER(char, parse_char);
- MAKE_PARSER(signed char, parse_char);
+ MAKE_PARSER(signed char, parse_schar);
MAKE_PARSER(unsigned char, parse_uchar);
+ MAKE_PARSER(float, parse_float);
+ MAKE_PARSER(double, parse_double);
+ MAKE_PARSER(string, parse_string);
+ MAKE_PARSER(StringPiece, parse_stringpiece);
+
MAKE_PARSER(short, parse_short);
MAKE_PARSER(unsigned short, parse_ushort);
MAKE_PARSER(int, parse_int);
MAKE_PARSER(unsigned int, parse_uint);
MAKE_PARSER(long, parse_long);
MAKE_PARSER(unsigned long, parse_ulong);
- #if RE2_HAVE_LONGLONG
MAKE_PARSER(long long, parse_longlong);
MAKE_PARSER(unsigned long long, parse_ulonglong);
- #endif
- MAKE_PARSER(float, parse_float);
- MAKE_PARSER(double, parse_double);
- MAKE_PARSER(string, parse_string);
- MAKE_PARSER(StringPiece, parse_stringpiece);
#undef MAKE_PARSER
@@ -808,29 +809,31 @@ class RE2::Arg {
: arg_(p), parser_(parser) { }
// Parse the data
- bool Parse(const char* str, int n) const;
+ bool Parse(const char* str, size_t n) const;
private:
void* arg_;
Parser parser_;
- static bool parse_null (const char* str, int n, void* dest);
- static bool parse_char (const char* str, int n, void* dest);
- static bool parse_uchar (const char* str, int n, void* dest);
- static bool parse_float (const char* str, int n, void* dest);
- static bool parse_double (const char* str, int n, void* dest);
- static bool parse_string (const char* str, int n, void* dest);
- static bool parse_stringpiece (const char* str, int n, void* dest);
-
-#define DECLARE_INTEGER_PARSER(name) \
- private: \
- static bool parse_ ## name(const char* str, int n, void* dest); \
- static bool parse_ ## name ## _radix( \
- const char* str, int n, void* dest, int radix); \
- public: \
- static bool parse_ ## name ## _hex(const char* str, int n, void* dest); \
- static bool parse_ ## name ## _octal(const char* str, int n, void* dest); \
- static bool parse_ ## name ## _cradix(const char* str, int n, void* dest)
+ static bool parse_null (const char* str, size_t n, void* dest);
+ static bool parse_char (const char* str, size_t n, void* dest);
+ static bool parse_schar (const char* str, size_t n, void* dest);
+ static bool parse_uchar (const char* str, size_t n, void* dest);
+ static bool parse_float (const char* str, size_t n, void* dest);
+ static bool parse_double (const char* str, size_t n, void* dest);
+ static bool parse_string (const char* str, size_t n, void* dest);
+ static bool parse_stringpiece (const char* str, size_t n, void* dest);
+
+#define DECLARE_INTEGER_PARSER(name) \
+ private: \
+ static bool parse_##name(const char* str, size_t n, void* dest); \
+ static bool parse_##name##_radix(const char* str, size_t n, void* dest, \
+ int radix); \
+ \
+ public: \
+ static bool parse_##name##_hex(const char* str, size_t n, void* dest); \
+ static bool parse_##name##_octal(const char* str, size_t n, void* dest); \
+ static bool parse_##name##_cradix(const char* str, size_t n, void* dest)
DECLARE_INTEGER_PARSER(short);
DECLARE_INTEGER_PARSER(ushort);
@@ -838,29 +841,31 @@ class RE2::Arg {
DECLARE_INTEGER_PARSER(uint);
DECLARE_INTEGER_PARSER(long);
DECLARE_INTEGER_PARSER(ulong);
- #if RE2_HAVE_LONGLONG
DECLARE_INTEGER_PARSER(longlong);
DECLARE_INTEGER_PARSER(ulonglong);
- #endif
#undef DECLARE_INTEGER_PARSER
+
};
inline RE2::Arg::Arg() : arg_(NULL), parser_(parse_null) { }
inline RE2::Arg::Arg(void* p) : arg_(p), parser_(parse_null) { }
-inline bool RE2::Arg::Parse(const char* str, int n) const {
+inline bool RE2::Arg::Parse(const char* str, size_t n) const {
return (*parser_)(str, n, arg_);
}
// This part of the parser, appropriate only for ints, deals with bases
-#define MAKE_INTEGER_PARSER(type, name) \
- inline RE2::Arg RE2::Hex(type* ptr) { \
- return RE2::Arg(ptr, RE2::Arg::parse_ ## name ## _hex); } \
- inline RE2::Arg RE2::Octal(type* ptr) { \
- return RE2::Arg(ptr, RE2::Arg::parse_ ## name ## _octal); } \
- inline RE2::Arg RE2::CRadix(type* ptr) { \
- return RE2::Arg(ptr, RE2::Arg::parse_ ## name ## _cradix); }
+#define MAKE_INTEGER_PARSER(type, name) \
+ inline RE2::Arg RE2::Hex(type* ptr) { \
+ return RE2::Arg(ptr, RE2::Arg::parse_##name##_hex); \
+ } \
+ inline RE2::Arg RE2::Octal(type* ptr) { \
+ return RE2::Arg(ptr, RE2::Arg::parse_##name##_octal); \
+ } \
+ inline RE2::Arg RE2::CRadix(type* ptr) { \
+ return RE2::Arg(ptr, RE2::Arg::parse_##name##_cradix); \
+ }
MAKE_INTEGER_PARSER(short, short)
MAKE_INTEGER_PARSER(unsigned short, ushort)
@@ -868,15 +873,62 @@ MAKE_INTEGER_PARSER(int,
MAKE_INTEGER_PARSER(unsigned int, uint)
MAKE_INTEGER_PARSER(long, long)
MAKE_INTEGER_PARSER(unsigned long, ulong)
-#if RE2_HAVE_LONGLONG
MAKE_INTEGER_PARSER(long long, longlong)
MAKE_INTEGER_PARSER(unsigned long long, ulonglong)
-#endif
#undef MAKE_INTEGER_PARSER
+#ifndef SWIG
+// Helper for writing global or static RE2s safely.
+// Write
+// static LazyRE2 re = {".*"};
+// and then use *re instead of writing
+// static RE2 re(".*");
+// The former is more careful about multithreaded
+// situations than the latter.
+//
+// N.B. This class never deletes the RE2 object that
+// it constructs: that's a feature, so that it can be used
+// for global and function static variables.
+class LazyRE2 {
+ private:
+ struct NoArg {};
+
+ public:
+ typedef RE2 element_type; // support std::pointer_traits
+
+ // Constructor omitted to preserve braced initialization in C++98.
+
+ // Pretend to be a pointer to Type (never NULL due to on-demand creation):
+ RE2& operator*() const { return *get(); }
+ RE2* operator->() const { return get(); }
+
+ // Named accessor/initializer:
+ RE2* get() const {
+ std::call_once(once_, &LazyRE2::Init, this);
+ return ptr_;
+ }
+
+ // All data fields must be public to support {"foo"} initialization.
+ const char* pattern_;
+ RE2::CannedOptions options_;
+ NoArg barrier_against_excess_initializers_;
+
+ mutable RE2* ptr_;
+ mutable std::once_flag once_;
+
+ private:
+ static void Init(const LazyRE2* lazy_re2) {
+ lazy_re2->ptr_ = new RE2(lazy_re2->pattern_, lazy_re2->options_);
+ }
+
+ void operator=(const LazyRE2&); // disallowed
+};
+#endif // SWIG
+
} // namespace re2
using re2::RE2;
+using re2::LazyRE2;
-#endif /* RE2_RE2_H */
+#endif // RE2_RE2_H_
--- a/src/3rdparty/chromium/third_party/re2/src/re2/filtered_re2.h
+++ b/src/3rdparty/chromium/third_party/re2/src/re2/filtered_re2.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#ifndef RE2_FILTERED_RE2_H_
+#define RE2_FILTERED_RE2_H_
+
// The class FilteredRE2 is used as a wrapper to multiple RE2 regexps.
// It provides a prefilter mechanism that helps in cutting down the
// number of regexps that need to be actually searched.
@@ -18,20 +21,19 @@
// indices of strings that were found in the text to get the actual
// regexp matches.
-#ifndef RE2_FILTERED_RE2_H_
-#define RE2_FILTERED_RE2_H_
-
+#include <string>
#include <vector>
+
#include "re2/re2.h"
namespace re2 {
-using std::vector;
class PrefilterTree;
class FilteredRE2 {
public:
FilteredRE2();
+ explicit FilteredRE2(int min_atom_len);
~FilteredRE2();
// Uses RE2 constructor to create a RE2 object (re). Returns
@@ -47,7 +49,7 @@ class FilteredRE2 {
// the search text should be lowercased first to find matching
// strings from the set of strings returned by Compile. Call after
// all Add calls are done.
- void Compile(vector<string>* strings_to_match);
+ void Compile(std::vector<string>* strings_to_match);
// Returns the index of the first matching regexp.
// Returns -1 on no match. Can be called prior to Compile.
@@ -59,21 +61,21 @@ class FilteredRE2 {
// Returns -1 on no match. Compile has to be called before
// calling this.
int FirstMatch(const StringPiece& text,
- const vector<int>& atoms) const;
+ const std::vector<int>& atoms) const;
// Returns the indices of all matching regexps, after first clearing
// matched_regexps.
bool AllMatches(const StringPiece& text,
- const vector<int>& atoms,
- vector<int>* matching_regexps) const;
+ const std::vector<int>& atoms,
+ std::vector<int>* matching_regexps) const;
// Returns the indices of all potentially matching regexps after first
// clearing potential_regexps.
// A regexp is potentially matching if it passes the filter.
// If a regexp passes the filter it may still not match.
// A regexp that does not pass the filter is guaranteed to not match.
- void AllPotentials(const vector<int>& atoms,
- vector<int>* potential_regexps) const;
+ void AllPotentials(const std::vector<int>& atoms,
+ std::vector<int>* potential_regexps) const;
// The number of regexps added.
int NumRegexps() const { return static_cast<int>(re2_vec_.size()); }
@@ -87,11 +89,11 @@ class FilteredRE2 {
void PrintPrefilter(int regexpid);
// Useful for testing and debugging.
- void RegexpsGivenStrings(const vector<int>& matched_atoms,
- vector<int>* passed_regexps);
+ void RegexpsGivenStrings(const std::vector<int>& matched_atoms,
+ std::vector<int>* passed_regexps);
// All the regexps in the FilteredRE2.
- vector<RE2*> re2_vec_;
+ std::vector<RE2*> re2_vec_;
// Has the FilteredRE2 been compiled using Compile()
bool compiled_;
@@ -99,9 +101,8 @@ class FilteredRE2 {
// An AND-OR tree of string atoms used for filtering regexps.
PrefilterTree* prefilter_tree_;
- //DISALLOW_COPY_AND_ASSIGN(FilteredRE2);
- FilteredRE2(const FilteredRE2&);
- void operator=(const FilteredRE2&);
+ FilteredRE2(const FilteredRE2&) = delete;
+ FilteredRE2& operator=(const FilteredRE2&) = delete;
};
} // namespace re2
--- a/src/3rdparty/chromium/third_party/re2/src/re2/set.h
+++ b/src/3rdparty/chromium/third_party/re2/src/re2/set.h
@@ -2,16 +2,20 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#ifndef RE2_SET_H
-#define RE2_SET_H
+#ifndef RE2_SET_H_
+#define RE2_SET_H_
-#include <utility>
+#include <string>
#include <vector>
#include "re2/re2.h"
namespace re2 {
-using std::vector;
+class Prog;
+class Regexp;
+} // namespace re2
+
+namespace re2 {
// An RE2::Set represents a collection of regexps that can
// be searched for simultaneously.
@@ -31,25 +35,25 @@ class RE2::Set {
// Compile prepares the Set for matching.
// Add must not be called again after Compile.
- // Compile must be called before FullMatch or PartialMatch.
+ // Compile must be called before Match.
// Compile may return false if it runs out of memory.
bool Compile();
// Match returns true if text matches any of the regexps in the set.
- // If so, it fills v with the indices of the matching regexps.
- bool Match(const StringPiece& text, vector<int>* v) const;
+ // If so, it fills v (if not NULL) with the indices of the matching regexps.
+ bool Match(const StringPiece& text, std::vector<int>* v) const;
private:
RE2::Options options_;
RE2::Anchor anchor_;
- vector<re2::Regexp*> re_;
+ std::vector<re2::Regexp*> re_;
re2::Prog* prog_;
bool compiled_;
- //DISALLOW_COPY_AND_ASSIGN(Set);
- Set(const Set&);
- void operator=(const Set&);
+
+ Set(const Set&) = delete;
+ Set& operator=(const Set&) = delete;
};
} // namespace re2
-#endif // RE2_SET_H
+#endif // RE2_SET_H_
--- a/src/3rdparty/chromium/third_party/re2/src/re2/stringpiece.h
+++ b/src/3rdparty/chromium/third_party/re2/src/re2/stringpiece.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#ifndef RE2_STRINGPIECE_H_
+#define RE2_STRINGPIECE_H_
+
// A string-like object that points to a sized piece of memory.
//
// Functions or methods may use const StringPiece& parameters to accept either
@@ -16,143 +19,139 @@
//
// Arghh! I wish C++ literals were "string".
-#ifndef STRINGS_STRINGPIECE_H__
-#define STRINGS_STRINGPIECE_H__
-
+#include <stddef.h>
#include <string.h>
#include <algorithm>
-#include <cstddef>
#include <iosfwd>
+#include <iterator>
#include <string>
namespace re2 {
class StringPiece {
- private:
- const char* ptr_;
- int length_;
-
public:
+ typedef char value_type;
+ typedef char* pointer;
+ typedef const char* const_pointer;
+ typedef char& reference;
+ typedef const char& const_reference;
+ typedef const char* const_iterator;
+ typedef const_iterator iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef const_reverse_iterator reverse_iterator;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ static const size_type npos = static_cast<size_type>(-1);
+
// We provide non-explicit singleton constructors so users can pass
// in a "const char*" or a "string" wherever a "StringPiece" is
// expected.
- StringPiece() : ptr_(NULL), length_(0) { }
- StringPiece(const char* str)
- : ptr_(str), length_((str == NULL) ? 0 : static_cast<int>(strlen(str))) { }
+ StringPiece()
+ : data_(NULL), size_(0) {}
StringPiece(const std::string& str)
- : ptr_(str.data()), length_(static_cast<int>(str.size())) { }
- StringPiece(const char* offset, int len) : ptr_(offset), length_(len) { }
-
- // data() may return a pointer to a buffer with embedded NULs, and the
- // returned buffer may or may not be null terminated. Therefore it is
- // typically a mistake to pass data() to a routine that expects a NUL
- // terminated string.
- const char* data() const { return ptr_; }
- int size() const { return length_; }
- int length() const { return length_; }
- bool empty() const { return length_ == 0; }
+ : data_(str.data()), size_(str.size()) {}
+ StringPiece(const char* str)
+ : data_(str), size_(str == NULL ? 0 : strlen(str)) {}
+ StringPiece(const char* str, size_type len)
+ : data_(str), size_(len) {}
- void clear() { ptr_ = NULL; length_ = 0; }
- void set(const char* data, int len) { ptr_ = data; length_ = len; }
- void set(const char* str) {
- ptr_ = str;
- if (str != NULL)
- length_ = static_cast<int>(strlen(str));
- else
- length_ = 0;
+ const_iterator begin() const { return data_; }
+ const_iterator end() const { return data_ + size_; }
+ const_reverse_iterator rbegin() const {
+ return const_reverse_iterator(data_ + size_);
}
- void set(const void* data, int len) {
- ptr_ = reinterpret_cast<const char*>(data);
- length_ = len;
+ const_reverse_iterator rend() const {
+ return const_reverse_iterator(data_);
}
- char operator[](int i) const { return ptr_[i]; }
+ size_type size() const { return size_; }
+ size_type length() const { return size_; }
+ bool empty() const { return size_ == 0; }
- void remove_prefix(int n) {
- ptr_ += n;
- length_ -= n;
+ const_reference operator[](size_type i) const { return data_[i]; }
+ const_pointer data() const { return data_; }
+
+ void remove_prefix(size_type n) {
+ data_ += n;
+ size_ -= n;
}
- void remove_suffix(int n) {
- length_ -= n;
+ void remove_suffix(size_type n) {
+ size_ -= n;
}
- int compare(const StringPiece& x) const {
- int r = memcmp(ptr_, x.ptr_, std::min(length_, x.length_));
- if (r == 0) {
- if (length_ < x.length_) r = -1;
- else if (length_ > x.length_) r = +1;
- }
- return r;
+ void set(const char* str) {
+ data_ = str;
+ size_ = str == NULL ? 0 : strlen(str);
+ }
+
+ void set(const char* str, size_type len) {
+ data_ = str;
+ size_ = len;
}
std::string as_string() const {
- return std::string(data(), size());
+ return std::string(data_, size_);
}
+
// We also define ToString() here, since many other string-like
// interfaces name the routine that converts to a C++ string
// "ToString", and it's confusing to have the method that does that
// for a StringPiece be called "as_string()". We also leave the
// "as_string()" method defined here for existing code.
std::string ToString() const {
- return std::string(data(), size());
+ return std::string(data_, size_);
}
- void CopyToString(std::string* target) const;
- void AppendToString(std::string* target) const;
-
- // Does "this" start with "x"
- bool starts_with(const StringPiece& x) const {
- return ((length_ >= x.length_) &&
- (memcmp(ptr_, x.ptr_, x.length_) == 0));
+ void CopyToString(std::string* target) const {
+ target->assign(data_, size_);
}
- // Does "this" end with "x"
- bool ends_with(const StringPiece& x) const {
- return ((length_ >= x.length_) &&
- (memcmp(ptr_ + (length_-x.length_), x.ptr_, x.length_) == 0));
+ void AppendToString(std::string* target) const {
+ target->append(data_, size_);
}
- // standard STL container boilerplate
- typedef char value_type;
- typedef const char* pointer;
- typedef const char& reference;
- typedef const char& const_reference;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- static const size_type npos;
- typedef const char* const_iterator;
- typedef const char* iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- iterator begin() const { return ptr_; }
- iterator end() const { return ptr_ + length_; }
- const_reverse_iterator rbegin() const {
- return const_reverse_iterator(ptr_ + length_);
+ size_type copy(char* buf, size_type n, size_type pos = 0) const;
+ StringPiece substr(size_type pos = 0, size_type n = npos) const;
+
+ int compare(const StringPiece& x) const {
+ int r = memcmp(data_, x.data_, std::min(size_, x.size_));
+ if (r == 0) {
+ if (size_ < x.size_) r = -1;
+ else if (size_ > x.size_) r = +1;
+ }
+ return r;
}
- const_reverse_iterator rend() const {
- return const_reverse_iterator(ptr_);
+
+ // Does "this" start with "x"?
+ bool starts_with(const StringPiece& x) const {
+ return size_ >= x.size_ &&
+ memcmp(data_, x.data_, x.size_) == 0;
}
- // STLS says return size_type, but Google says return int
- int max_size() const { return length_; }
- int capacity() const { return length_; }
- size_type copy(char* buf, size_type n, size_type pos = 0) const;
+ // Does "this" end with "x"?
+ bool ends_with(const StringPiece& x) const {
+ return size_ >= x.size_ &&
+ memcmp(data_ + size_ - x.size_, x.data_, x.size_) == 0;
+ }
- bool contains(StringPiece s) const;
+ bool contains(const StringPiece& s) const {
+ return find(s) != npos;
+ }
size_type find(const StringPiece& s, size_type pos = 0) const;
size_type find(char c, size_type pos = 0) const;
size_type rfind(const StringPiece& s, size_type pos = npos) const;
size_type rfind(char c, size_type pos = npos) const;
- StringPiece substr(size_type pos, size_type n = npos) const;
-
- static bool _equal(const StringPiece&, const StringPiece&);
+ private:
+ const_pointer data_;
+ size_type size_;
};
inline bool operator==(const StringPiece& x, const StringPiece& y) {
- return StringPiece::_equal(x, y);
+ return x.size() == y.size() &&
+ memcmp(x.data(), y.data(), x.size()) == 0;
}
inline bool operator!=(const StringPiece& x, const StringPiece& y) {
@@ -160,8 +159,7 @@ inline bool operator!=(const StringPiece
}
inline bool operator<(const StringPiece& x, const StringPiece& y) {
- const int r = memcmp(x.data(), y.data(),
- std::min(x.size(), y.size()));
+ int r = memcmp(x.data(), y.data(), std::min(x.size(), y.size()));
return ((r < 0) || ((r == 0) && (x.size() < y.size())));
}
@@ -179,7 +177,7 @@ inline bool operator>=(const StringPiece
} // namespace re2
-// allow StringPiece to be logged
-extern std::ostream& operator<<(std::ostream& o, const re2::StringPiece& piece);
+// Allow StringPiece to be logged.
+std::ostream& operator<<(std::ostream& o, const re2::StringPiece& p);
-#endif // STRINGS_STRINGPIECE_H__
+#endif // RE2_STRINGPIECE_H_