| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/CSSPaintValue.h" | 5 #include "core/css/CSSPaintValue.h" |
| 6 | 6 |
| 7 #include "core/css/CSSCustomIdentValue.h" | 7 #include "core/css/CSSCustomIdentValue.h" |
| 8 #include "core/css/CSSSyntaxDescriptor.h" | 8 #include "core/css/CSSSyntaxDescriptor.h" |
| 9 #include "core/css/cssom/StyleValueFactory.h" | 9 #include "core/css/cssom/StyleValueFactory.h" |
| 10 #include "core/layout/LayoutObject.h" | 10 #include "core/layout/LayoutObject.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 result.Append(variable_data.Get()->TokenRange().Serialize()); | 35 result.Append(variable_data.Get()->TokenRange().Serialize()); |
| 36 } | 36 } |
| 37 result.Append(')'); | 37 result.Append(')'); |
| 38 return result.ToString(); | 38 return result.ToString(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 String CSSPaintValue::GetName() const { | 41 String CSSPaintValue::GetName() const { |
| 42 return name_->Value(); | 42 return name_->Value(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 PassRefPtr<Image> CSSPaintValue::GetImage(const LayoutObject& layout_object, | 45 PassRefPtr<Image> CSSPaintValue::GetImage(const ImageResourceObserver& client, |
| 46 const Document& document, |
| 47 const ComputedStyle&, |
| 46 const IntSize& size) { | 48 const IntSize& size) { |
| 47 if (!generator_) | 49 if (!generator_) { |
| 48 generator_ = | 50 generator_ = CSSPaintImageGenerator::Create( |
| 49 CSSPaintImageGenerator::Create(GetName(), layout_object.GetDocument(), | 51 GetName(), document, paint_image_generator_observer_); |
| 50 paint_image_generator_observer_); | 52 } |
| 51 | 53 |
| 52 if (!ParseInputArguments()) | 54 if (!ParseInputArguments()) |
| 53 return nullptr; | 55 return nullptr; |
| 54 | 56 |
| 55 return generator_->Paint(layout_object, size, parsed_input_arguments_); | 57 return generator_->Paint(client, size, parsed_input_arguments_); |
| 56 } | 58 } |
| 57 | 59 |
| 58 bool CSSPaintValue::ParseInputArguments() { | 60 bool CSSPaintValue::ParseInputArguments() { |
| 59 if (input_arguments_invalid_) | 61 if (input_arguments_invalid_) |
| 60 return false; | 62 return false; |
| 61 | 63 |
| 62 if (parsed_input_arguments_ || | 64 if (parsed_input_arguments_ || |
| 63 !RuntimeEnabledFeatures::CSSPaintAPIArgumentsEnabled()) | 65 !RuntimeEnabledFeatures::CSSPaintAPIArgumentsEnabled()) |
| 64 return true; | 66 return true; |
| 65 | 67 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 87 StyleValueFactory::CssValueToStyleValueVector(*parsed_value)); | 89 StyleValueFactory::CssValueToStyleValueVector(*parsed_value)); |
| 88 } | 90 } |
| 89 return true; | 91 return true; |
| 90 } | 92 } |
| 91 | 93 |
| 92 void CSSPaintValue::Observer::PaintImageGeneratorReady() { | 94 void CSSPaintValue::Observer::PaintImageGeneratorReady() { |
| 93 owner_value_->PaintImageGeneratorReady(); | 95 owner_value_->PaintImageGeneratorReady(); |
| 94 } | 96 } |
| 95 | 97 |
| 96 void CSSPaintValue::PaintImageGeneratorReady() { | 98 void CSSPaintValue::PaintImageGeneratorReady() { |
| 97 for (const LayoutObject* client : Clients().Keys()) { | 99 for (const ImageResourceObserver* client : Clients().Keys()) { |
| 98 const_cast<LayoutObject*>(client)->ImageChanged( | 100 // TODO(ikilpatrick): We shouldn't be casting like this or mutate the layout |
| 101 // tree from a const pointer. |
| 102 const_cast<ImageResourceObserver*>(client)->ImageChanged( |
| 99 static_cast<WrappedImagePtr>(this)); | 103 static_cast<WrappedImagePtr>(this)); |
| 100 } | 104 } |
| 101 } | 105 } |
| 102 | 106 |
| 103 bool CSSPaintValue::KnownToBeOpaque(const Document&, | 107 bool CSSPaintValue::KnownToBeOpaque(const Document&, |
| 104 const ComputedStyle&) const { | 108 const ComputedStyle&) const { |
| 105 return generator_ && !generator_->HasAlpha(); | 109 return generator_ && !generator_->HasAlpha(); |
| 106 } | 110 } |
| 107 | 111 |
| 108 bool CSSPaintValue::Equals(const CSSPaintValue& other) const { | 112 bool CSSPaintValue::Equals(const CSSPaintValue& other) const { |
| 109 return GetName() == other.GetName() && | 113 return GetName() == other.GetName() && |
| 110 CustomCSSText() == other.CustomCSSText(); | 114 CustomCSSText() == other.CustomCSSText(); |
| 111 } | 115 } |
| 112 | 116 |
| 113 DEFINE_TRACE_AFTER_DISPATCH(CSSPaintValue) { | 117 DEFINE_TRACE_AFTER_DISPATCH(CSSPaintValue) { |
| 114 visitor->Trace(name_); | 118 visitor->Trace(name_); |
| 115 visitor->Trace(generator_); | 119 visitor->Trace(generator_); |
| 116 visitor->Trace(paint_image_generator_observer_); | 120 visitor->Trace(paint_image_generator_observer_); |
| 117 visitor->Trace(parsed_input_arguments_); | 121 visitor->Trace(parsed_input_arguments_); |
| 118 CSSImageGeneratorValue::TraceAfterDispatch(visitor); | 122 CSSImageGeneratorValue::TraceAfterDispatch(visitor); |
| 119 } | 123 } |
| 120 | 124 |
| 121 } // namespace blink | 125 } // namespace blink |
| OLD | NEW |