Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: third_party/WebKit/Source/core/style/ComputedStyle.cpp

Issue 2881143004: Remove PassRefPtr on setters in ComputedStyle. (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 for (size_t i = 0; i < cached_pseudo_styles_->size(); ++i) { 407 for (size_t i = 0; i < cached_pseudo_styles_->size(); ++i) {
408 ComputedStyle* pseudo_style = cached_pseudo_styles_->at(i).Get(); 408 ComputedStyle* pseudo_style = cached_pseudo_styles_->at(i).Get();
409 if (pseudo_style->StyleType() == pid) 409 if (pseudo_style->StyleType() == pid)
410 return pseudo_style; 410 return pseudo_style;
411 } 411 }
412 412
413 return 0; 413 return 0;
414 } 414 }
415 415
416 ComputedStyle* ComputedStyle::AddCachedPseudoStyle( 416 ComputedStyle* ComputedStyle::AddCachedPseudoStyle(
417 PassRefPtr<ComputedStyle> pseudo) { 417 RefPtr<ComputedStyle> pseudo) {
418 if (!pseudo) 418 if (!pseudo)
419 return 0; 419 return 0;
420 420
421 DCHECK_GT(pseudo->StyleType(), kPseudoIdNone); 421 DCHECK_GT(pseudo->StyleType(), kPseudoIdNone);
422 422
423 ComputedStyle* result = pseudo.Get(); 423 ComputedStyle* result = pseudo.Get();
424 424
425 if (!cached_pseudo_styles_) 425 if (!cached_pseudo_styles_)
426 cached_pseudo_styles_ = WTF::WrapUnique(new PseudoStyleCache); 426 cached_pseudo_styles_ = WTF::WrapUnique(new PseudoStyleCache);
427 427
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 if (!rare_inherited_data_.Access()->cursor_data_) 1084 if (!rare_inherited_data_.Access()->cursor_data_)
1085 rare_inherited_data_.Access()->cursor_data_ = new CursorList; 1085 rare_inherited_data_.Access()->cursor_data_ = new CursorList;
1086 rare_inherited_data_.Access()->cursor_data_->push_back( 1086 rare_inherited_data_.Access()->cursor_data_->push_back(
1087 CursorData(image, hot_spot_specified, hot_spot)); 1087 CursorData(image, hot_spot_specified, hot_spot));
1088 } 1088 }
1089 1089
1090 void ComputedStyle::SetCursorList(CursorList* other) { 1090 void ComputedStyle::SetCursorList(CursorList* other) {
1091 rare_inherited_data_.Access()->cursor_data_ = other; 1091 rare_inherited_data_.Access()->cursor_data_ = other;
1092 } 1092 }
1093 1093
1094 void ComputedStyle::SetQuotes(PassRefPtr<QuotesData> q) { 1094 void ComputedStyle::SetQuotes(RefPtr<QuotesData> q) {
1095 rare_inherited_data_.Access()->quotes_ = std::move(q); 1095 rare_inherited_data_.Access()->quotes_ = std::move(q);
1096 } 1096 }
1097 1097
1098 bool ComputedStyle::QuotesDataEquivalent(const ComputedStyle& other) const { 1098 bool ComputedStyle::QuotesDataEquivalent(const ComputedStyle& other) const {
1099 return DataEquivalent(Quotes(), other.Quotes()); 1099 return DataEquivalent(Quotes(), other.Quotes());
1100 } 1100 }
1101 1101
1102 void ComputedStyle::ClearCursorList() { 1102 void ComputedStyle::ClearCursorList() {
1103 if (rare_inherited_data_->cursor_data_) 1103 if (rare_inherited_data_->cursor_data_)
1104 rare_inherited_data_.Access()->cursor_data_ = nullptr; 1104 rare_inherited_data_.Access()->cursor_data_ = nullptr;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 1364
1365 transform.Translate(point.X() - origin_x + origin_shift_x, 1365 transform.Translate(point.X() - origin_x + origin_shift_x,
1366 point.Y() - origin_y + origin_shift_y); 1366 point.Y() - origin_y + origin_shift_y);
1367 transform.Rotate(angle + motion_data.rotation_.angle); 1367 transform.Rotate(angle + motion_data.rotation_.angle);
1368 1368
1369 if (position.X() != Length(kAuto) || anchor.X() != Length(kAuto)) 1369 if (position.X() != Length(kAuto) || anchor.X() != Length(kAuto))
1370 // Shift the origin back to transform-origin. 1370 // Shift the origin back to transform-origin.
1371 transform.Translate(-origin_shift_x, -origin_shift_y); 1371 transform.Translate(-origin_shift_x, -origin_shift_y);
1372 } 1372 }
1373 1373
1374 void ComputedStyle::SetTextShadow(PassRefPtr<ShadowList> s) { 1374 void ComputedStyle::SetTextShadow(RefPtr<ShadowList> s) {
1375 rare_inherited_data_.Access()->text_shadow_ = std::move(s); 1375 rare_inherited_data_.Access()->text_shadow_ = std::move(s);
1376 } 1376 }
1377 1377
1378 bool ComputedStyle::TextShadowDataEquivalent(const ComputedStyle& other) const { 1378 bool ComputedStyle::TextShadowDataEquivalent(const ComputedStyle& other) const {
1379 return DataEquivalent(TextShadow(), other.TextShadow()); 1379 return DataEquivalent(TextShadow(), other.TextShadow());
1380 } 1380 }
1381 1381
1382 void ComputedStyle::SetBoxShadow(PassRefPtr<ShadowList> s) { 1382 void ComputedStyle::SetBoxShadow(RefPtr<ShadowList> s) {
1383 rare_non_inherited_data_.Access()->box_shadow_ = std::move(s); 1383 rare_non_inherited_data_.Access()->box_shadow_ = std::move(s);
1384 } 1384 }
1385 1385
1386 static FloatRoundedRect::Radii CalcRadiiFor(const BorderData& border, 1386 static FloatRoundedRect::Radii CalcRadiiFor(const BorderData& border,
1387 const LengthSize& top_left, 1387 const LengthSize& top_left,
1388 const LengthSize& top_right, 1388 const LengthSize& top_right,
1389 const LengthSize& bottom_left, 1389 const LengthSize& bottom_left,
1390 const LengthSize& bottom_right, 1390 const LengthSize& bottom_right,
1391 LayoutSize size) { 1391 LayoutSize size) {
1392 return FloatRoundedRect::Radii( 1392 return FloatRoundedRect::Radii(
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 StyleNonInheritedVariables& ComputedStyle::MutableNonInheritedVariables() { 1759 StyleNonInheritedVariables& ComputedStyle::MutableNonInheritedVariables() {
1760 std::unique_ptr<StyleNonInheritedVariables>& variables = 1760 std::unique_ptr<StyleNonInheritedVariables>& variables =
1761 rare_non_inherited_data_.Access()->variables_; 1761 rare_non_inherited_data_.Access()->variables_;
1762 if (!variables) 1762 if (!variables)
1763 variables = StyleNonInheritedVariables::Create(); 1763 variables = StyleNonInheritedVariables::Create();
1764 return *variables; 1764 return *variables;
1765 } 1765 }
1766 1766
1767 void ComputedStyle::SetUnresolvedInheritedVariable( 1767 void ComputedStyle::SetUnresolvedInheritedVariable(
1768 const AtomicString& name, 1768 const AtomicString& name,
1769 PassRefPtr<CSSVariableData> value) { 1769 RefPtr<CSSVariableData> value) {
1770 DCHECK(value && value->NeedsVariableResolution()); 1770 DCHECK(value && value->NeedsVariableResolution());
1771 MutableInheritedVariables().SetVariable(name, std::move(value)); 1771 MutableInheritedVariables().SetVariable(name, std::move(value));
1772 } 1772 }
1773 1773
1774 void ComputedStyle::SetUnresolvedNonInheritedVariable( 1774 void ComputedStyle::SetUnresolvedNonInheritedVariable(
1775 const AtomicString& name, 1775 const AtomicString& name,
1776 PassRefPtr<CSSVariableData> value) { 1776 RefPtr<CSSVariableData> value) {
1777 DCHECK(value && value->NeedsVariableResolution()); 1777 DCHECK(value && value->NeedsVariableResolution());
1778 MutableNonInheritedVariables().SetVariable(name, std::move(value)); 1778 MutableNonInheritedVariables().SetVariable(name, std::move(value));
1779 } 1779 }
1780 1780
1781 void ComputedStyle::SetResolvedUnregisteredVariable( 1781 void ComputedStyle::SetResolvedUnregisteredVariable(
1782 const AtomicString& name, 1782 const AtomicString& name,
1783 PassRefPtr<CSSVariableData> value) { 1783 RefPtr<CSSVariableData> value) {
1784 DCHECK(value && !value->NeedsVariableResolution()); 1784 DCHECK(value && !value->NeedsVariableResolution());
1785 MutableInheritedVariables().SetVariable(name, std::move(value)); 1785 MutableInheritedVariables().SetVariable(name, std::move(value));
1786 } 1786 }
1787 1787
1788 void ComputedStyle::SetResolvedInheritedVariable( 1788 void ComputedStyle::SetResolvedInheritedVariable(const AtomicString& name,
1789 const AtomicString& name, 1789 RefPtr<CSSVariableData> value,
1790 PassRefPtr<CSSVariableData> value, 1790 const CSSValue* parsed_value) {
1791 const CSSValue* parsed_value) {
1792 DCHECK(!!value == !!parsed_value); 1791 DCHECK(!!value == !!parsed_value);
1793 DCHECK(!(value && value->NeedsVariableResolution())); 1792 DCHECK(!(value && value->NeedsVariableResolution()));
1794 1793
1795 StyleInheritedVariables& variables = MutableInheritedVariables(); 1794 StyleInheritedVariables& variables = MutableInheritedVariables();
1796 variables.SetVariable(name, std::move(value)); 1795 variables.SetVariable(name, std::move(value));
1797 variables.SetRegisteredVariable(name, parsed_value); 1796 variables.SetRegisteredVariable(name, parsed_value);
1798 } 1797 }
1799 1798
1800 void ComputedStyle::SetResolvedNonInheritedVariable( 1799 void ComputedStyle::SetResolvedNonInheritedVariable(
1801 const AtomicString& name, 1800 const AtomicString& name,
1802 PassRefPtr<CSSVariableData> value, 1801 RefPtr<CSSVariableData> value,
1803 const CSSValue* parsed_value) { 1802 const CSSValue* parsed_value) {
1804 DCHECK(!!value == !!parsed_value); 1803 DCHECK(!!value == !!parsed_value);
1805 DCHECK(!(value && value->NeedsVariableResolution())); 1804 DCHECK(!(value && value->NeedsVariableResolution()));
1806 1805
1807 StyleNonInheritedVariables& variables = MutableNonInheritedVariables(); 1806 StyleNonInheritedVariables& variables = MutableNonInheritedVariables();
1808 variables.SetVariable(name, std::move(value)); 1807 variables.SetVariable(name, std::move(value));
1809 variables.SetRegisteredVariable(name, parsed_value); 1808 variables.SetRegisteredVariable(name, parsed_value);
1810 } 1809 }
1811 1810
1812 void ComputedStyle::RemoveVariable(const AtomicString& name, 1811 void ComputedStyle::RemoveVariable(const AtomicString& name,
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 else 2301 else
2303 SetMarginLeft(margin); 2302 SetMarginLeft(margin);
2304 } else { 2303 } else {
2305 if (IsLeftToRightDirection()) 2304 if (IsLeftToRightDirection())
2306 SetMarginBottom(margin); 2305 SetMarginBottom(margin);
2307 else 2306 else
2308 SetMarginTop(margin); 2307 SetMarginTop(margin);
2309 } 2308 }
2310 } 2309 }
2311 2310
2312 void ComputedStyle::SetOffsetPath(PassRefPtr<BasicShape> path) { 2311 void ComputedStyle::SetOffsetPath(RefPtr<BasicShape> path) {
2313 rare_non_inherited_data_.Access()->transform_.Access()->motion_.path_ = 2312 rare_non_inherited_data_.Access()->transform_.Access()->motion_.path_ =
2314 std::move(path); 2313 std::move(path);
2315 } 2314 }
2316 2315
2317 int ComputedStyle::OutlineOutsetExtent() const { 2316 int ComputedStyle::OutlineOutsetExtent() const {
2318 if (!HasOutline()) 2317 if (!HasOutline())
2319 return 0; 2318 return 0;
2320 if (OutlineStyleIsAuto()) { 2319 if (OutlineStyleIsAuto()) {
2321 return GraphicsContext::FocusRingOutsetExtent( 2320 return GraphicsContext::FocusRingOutsetExtent(
2322 OutlineOffset(), std::ceil(GetOutlineStrokeWidthForFocusRing())); 2321 OutlineOffset(), std::ceil(GetOutlineStrokeWidthForFocusRing()));
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 if (value < 0) 2493 if (value < 0)
2495 fvalue -= 0.5f; 2494 fvalue -= 0.5f;
2496 else 2495 else
2497 fvalue += 0.5f; 2496 fvalue += 0.5f;
2498 } 2497 }
2499 2498
2500 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); 2499 return RoundForImpreciseConversion<int>(fvalue / zoom_factor);
2501 } 2500 }
2502 2501
2503 } // namespace blink 2502 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698