diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/ui/base/x/selection_utils.cc | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/base/x/selection_utils.cc')
-rw-r--r-- | chromium/ui/base/x/selection_utils.cc | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/chromium/ui/base/x/selection_utils.cc b/chromium/ui/base/x/selection_utils.cc index a5eaa7443e0..34533b97d69 100644 --- a/chromium/ui/base/x/selection_utils.cc +++ b/chromium/ui/base/x/selection_utils.cc @@ -25,8 +25,8 @@ const char kTextPlain[] = "text/plain"; const char kTextPlainUtf8[] = "text/plain;charset=utf-8"; const char kUtf8String[] = "UTF8_STRING"; -std::vector<::Atom> GetTextAtomsFrom() { - std::vector< ::Atom> atoms; +std::vector<x11::Atom> GetTextAtomsFrom() { + std::vector<x11::Atom> atoms; atoms.push_back(gfx::GetAtom(kUtf8String)); atoms.push_back(gfx::GetAtom(kString)); atoms.push_back(gfx::GetAtom(kText)); @@ -35,22 +35,22 @@ std::vector<::Atom> GetTextAtomsFrom() { return atoms; } -std::vector<::Atom> GetURLAtomsFrom() { - std::vector< ::Atom> atoms; +std::vector<x11::Atom> GetURLAtomsFrom() { + std::vector<x11::Atom> atoms; atoms.push_back(gfx::GetAtom(kMimeTypeURIList)); atoms.push_back(gfx::GetAtom(kMimeTypeMozillaURL)); return atoms; } -std::vector<::Atom> GetURIListAtomsFrom() { - std::vector< ::Atom> atoms; +std::vector<x11::Atom> GetURIListAtomsFrom() { + std::vector<x11::Atom> atoms; atoms.push_back(gfx::GetAtom(kMimeTypeURIList)); return atoms; } -void GetAtomIntersection(const std::vector< ::Atom>& desired, - const std::vector< ::Atom>& offered, - std::vector< ::Atom>* output) { +void GetAtomIntersection(const std::vector<x11::Atom>& desired, + const std::vector<x11::Atom>& offered, + std::vector<x11::Atom>* output) { for (const auto& desired_atom : desired) { if (base::Contains(offered, desired_atom)) output->push_back(desired_atom); @@ -68,8 +68,8 @@ std::vector<std::string> ParseURIList(const SelectionData& data) { // uri-lists are newline separated file lists in URL encoding. std::string unparsed; data.AssignTo(&unparsed); - return base::SplitString( - unparsed, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + return base::SplitString(unparsed, "\n", base::KEEP_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); } std::string RefCountedMemoryToString( @@ -104,22 +104,22 @@ base::string16 RefCountedMemoryToString16( /////////////////////////////////////////////////////////////////////////////// -SelectionFormatMap::SelectionFormatMap() {} +SelectionFormatMap::SelectionFormatMap() = default; SelectionFormatMap::SelectionFormatMap(const SelectionFormatMap& other) = default; -SelectionFormatMap::~SelectionFormatMap() {} +SelectionFormatMap::~SelectionFormatMap() = default; void SelectionFormatMap::Insert( - ::Atom atom, + x11::Atom atom, const scoped_refptr<base::RefCountedMemory>& item) { data_.erase(atom); data_.emplace(atom, item); } ui::SelectionData SelectionFormatMap::GetFirstOf( - const std::vector< ::Atom>& requested_types) const { + const std::vector<x11::Atom>& requested_types) const { for (const auto& requested_type : requested_types) { auto data_it = data_.find(requested_type); if (data_it != data_.end()) { @@ -130,8 +130,8 @@ ui::SelectionData SelectionFormatMap::GetFirstOf( return SelectionData(); } -std::vector< ::Atom> SelectionFormatMap::GetTypes() const { - std::vector< ::Atom> atoms; +std::vector<x11::Atom> SelectionFormatMap::GetTypes() const { + std::vector<x11::Atom> atoms; for (const auto& datum : data_) atoms.push_back(datum.first); @@ -140,17 +140,16 @@ std::vector< ::Atom> SelectionFormatMap::GetTypes() const { /////////////////////////////////////////////////////////////////////////////// -SelectionData::SelectionData() : type_(x11::None) {} +SelectionData::SelectionData() : type_(x11::Atom::None) {} SelectionData::SelectionData( - ::Atom type, + x11::Atom type, const scoped_refptr<base::RefCountedMemory>& memory) : type_(type), memory_(memory) {} -SelectionData::SelectionData(const SelectionData& rhs) - : type_(rhs.type_), memory_(rhs.memory_) {} +SelectionData::SelectionData(const SelectionData& rhs) = default; -SelectionData::~SelectionData() {} +SelectionData::~SelectionData() = default; SelectionData& SelectionData::operator=(const SelectionData& rhs) { type_ = rhs.type_; @@ -161,10 +160,10 @@ SelectionData& SelectionData::operator=(const SelectionData& rhs) { } bool SelectionData::IsValid() const { - return type_ != x11::None; + return type_ != x11::Atom::None; } -::Atom SelectionData::GetType() const { +x11::Atom SelectionData::GetType() const { return type_; } @@ -184,8 +183,7 @@ std::string SelectionData::GetText() const { type_ == gfx::GetAtom(kTextPlain)) { std::string result; base::ConvertToUtf8AndNormalize(RefCountedMemoryToString(memory_), - base::kCodepageLatin1, - &result); + base::kCodepageLatin1, &result); return result; } else { // BTW, I looked at COMPOUND_TEXT, and there's no way we're going to @@ -204,8 +202,7 @@ base::string16 SelectionData::GetHtml() const { // If the data starts with 0xFEFF, i.e., Byte Order Mark, assume it is // UTF-16, otherwise assume UTF-8. - if (size >= 2 && - reinterpret_cast<const uint16_t*>(data)[0] == 0xFEFF) { + if (size >= 2 && reinterpret_cast<const uint16_t*>(data)[0] == 0xFEFF) { markup.assign(reinterpret_cast<const uint16_t*>(data) + 1, (size / 2) - 1); } else { |