提交 6553eb43 编写于 作者: E Eric Seidel

Merge pull request #71 from eseidelGoogle/rect

Remove CSS Rect
......@@ -102,113 +102,8 @@ namespace blink {
{{convert_and_set_value(property)}}
}
{% endmacro %}
{{apply_auto('CSSPropertyClip')}}
{{apply_auto('CSSPropertyZIndex')}}
static bool lengthTypeAndValueMatch(const Length& length, LengthType type, float value)
{
return length.type() == type && length.value() == value;
}
static bool lengthTypeAndValueMatch(const LengthBox& lengthBox, LengthType type, float value)
{
return (lengthTypeAndValueMatch(lengthBox.left(), type, value)
&& lengthTypeAndValueMatch(lengthBox.right(), type, value)
&& lengthTypeAndValueMatch(lengthBox.top(), type, value)
&& lengthTypeAndValueMatch(lengthBox.bottom(), type, value));
}
static bool lengthTypeAndValueMatch(const BorderImageLength& borderImageLength, LengthType type, float value)
{
return borderImageLength.isLength() && lengthTypeAndValueMatch(borderImageLength.length(), type, value);
}
static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengthBox, LengthType type, float value)
{
return (lengthTypeAndValueMatch(borderImageLengthBox.left(), type, value)
&& lengthTypeAndValueMatch(borderImageLengthBox.right(), type, value)
&& lengthTypeAndValueMatch(borderImageLengthBox.top(), type, value)
&& lengthTypeAndValueMatch(borderImageLengthBox.bottom(), type, value));
}
{% macro apply_border_image_modifier(property_id, modifier_type) %}
{{ declare_initial_function(property_id) }}
{
const NinePieceImage& currentImage = state.style()->borderImage();
{# Check for equality in case we can bail out before creating a new NinePieceImage. #}
{% if modifier_type == 'Outset' %}
if (lengthTypeAndValueMatch(currentImage.outset(), Fixed, 0))
return;
{% elif modifier_type == 'Repeat' %}
if (currentImage.horizontalRule() == StretchImageRule && currentImage.verticalRule() == StretchImageRule)
return;
{% elif modifier_type == 'Slice' %}
if (currentImage.fill() == false && lengthTypeAndValueMatch(currentImage.imageSlices(), Percent, 100))
return;
{% elif modifier_type == 'Width' %}
if (lengthTypeAndValueMatch(currentImage.borderSlices(), Fixed, 1))
return;
{% endif %}
NinePieceImage image(currentImage);
{% if modifier_type == 'Outset' %}
image.setOutset(Length(0, Fixed));
{% elif modifier_type == 'Repeat' %}
image.setHorizontalRule(StretchImageRule);
image.setVerticalRule(StretchImageRule);
{% elif modifier_type == 'Slice' %}
image.setImageSlices(LengthBox({{ (['Length(100, Percent)']*4) | join(', ') }}));
image.setFill(false);
{% elif modifier_type == 'Width' %}
image.setBorderSlices(1.0);
{% endif %}
state.style()->setBorderImage(image);
}
{{declare_inherit_function(property_id)}}
{
NinePieceImage image(state.style()->borderImage());
{% if modifier_type == 'Outset' %}
image.copyOutsetFrom(state.parentStyle()->borderImage());
{% elif modifier_type == 'Repeat' %}
image.copyRepeatFrom(state.parentStyle()->borderImage());
{% elif modifier_type == 'Slice' %}
image.copyImageSlicesFrom(state.parentStyle()->borderImage());
{% elif modifier_type == 'Width' %}
image.copyBorderSlicesFrom(state.parentStyle()->borderImage());
{% endif %}
state.style()->setBorderImage(image);
}
{{declare_value_function(property_id)}}
{
NinePieceImage image(state.style()->borderImage());
{% if modifier_type == 'Outset' %}
image.setOutset(state.styleMap().mapNinePieceImageQuad(value));
{% elif modifier_type == 'Repeat' %}
state.styleMap().mapNinePieceImageRepeat(value, image);
{% elif modifier_type == 'Slice' %}
state.styleMap().mapNinePieceImageSlice(value, image);
{% elif modifier_type == 'Width' %}
image.setBorderSlices(state.styleMap().mapNinePieceImageQuad(value));
{% endif %}
state.style()->setBorderImage(image);
}
{% endmacro %}
{{apply_border_image_modifier('CSSPropertyBorderImageOutset', 'Outset')}}
{{apply_border_image_modifier('CSSPropertyBorderImageRepeat', 'Repeat')}}
{{apply_border_image_modifier('CSSPropertyBorderImageSlice', 'Slice')}}
{{apply_border_image_modifier('CSSPropertyBorderImageWidth', 'Width')}}
{% macro apply_value_border_image_source(property_id) %}
{{declare_value_function(property_id)}}
{
{% set property = properties[property_id] %}
{{set_value(property)}}(state.styleImage({{property_id}}, value));
}
{% endmacro %}
{{apply_value_border_image_source('CSSPropertyBorderImageSource')}}
{% macro apply_color(property_id, initial_color='StyleColor::currentColor') %}
{% set property = properties[property_id] %}
{{declare_initial_function(property_id)}}
......
......@@ -15,10 +15,6 @@ sky_core_files = [
"css/CSSAspectRatioValue.h",
"css/CSSBasicShapes.cpp",
"css/CSSBasicShapes.h",
"css/CSSBorderImage.cpp",
"css/CSSBorderImage.h",
"css/CSSBorderImageSliceValue.cpp",
"css/CSSBorderImageSliceValue.h",
"css/CSSCalculationValue.cpp",
"css/CSSCalculationValue.h",
"css/CSSComputedStyleDeclaration.cpp",
......@@ -126,8 +122,6 @@ sky_core_files = [
"css/PropertySetCSSStyleDeclaration.h",
"css/RGBColor.cpp",
"css/RGBColor.h",
"css/Rect.cpp",
"css/Rect.h",
"css/RuleFeature.cpp",
"css/RuleFeature.h",
"css/RuleSet.cpp",
......@@ -682,8 +676,6 @@ sky_core_files = [
"rendering/style/BasicShapes.cpp",
"rendering/style/BasicShapes.h",
"rendering/style/BorderData.h",
"rendering/style/BorderImageLength.h",
"rendering/style/BorderImageLengthBox.h",
"rendering/style/BorderValue.h",
"rendering/style/CollapsedBorderValue.h",
"rendering/style/CounterDirectives.cpp",
......@@ -692,8 +684,6 @@ sky_core_files = [
"rendering/style/DataRef.h",
"rendering/style/FillLayer.cpp",
"rendering/style/FillLayer.h",
"rendering/style/NinePieceImage.cpp",
"rendering/style/NinePieceImage.h",
"rendering/style/OutlineValue.h",
"rendering/style/RenderStyle.cpp",
"rendering/style/RenderStyle.h",
......
/*
* Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "sky/engine/core/css/CSSBorderImage.h"
namespace blink {
PassRefPtr<CSSValueList> createBorderImageValue(PassRefPtr<CSSValue> image, PassRefPtr<CSSValue> imageSlice,
PassRefPtr<CSSValue> borderSlice, PassRefPtr<CSSValue> outset, PassRefPtr<CSSValue> repeat)
{
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
if (image)
list->append(image);
if (borderSlice || outset) {
RefPtr<CSSValueList> listSlash = CSSValueList::createSlashSeparated();
if (imageSlice)
listSlash->append(imageSlice);
if (borderSlice)
listSlash->append(borderSlice);
if (outset)
listSlash->append(outset);
list->append(listSlash);
} else if (imageSlice)
list->append(imageSlice);
if (repeat)
list->append(repeat);
return list.release();
}
} // namespace blink
/*
* Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef SKY_ENGINE_CORE_CSS_CSSBORDERIMAGE_H_
#define SKY_ENGINE_CORE_CSS_CSSBORDERIMAGE_H_
#include "sky/engine/core/css/CSSBorderImageSliceValue.h"
#include "sky/engine/core/css/CSSValueList.h"
#include "sky/engine/wtf/PassRefPtr.h"
namespace blink {
PassRefPtr<CSSValueList> createBorderImageValue(PassRefPtr<CSSValue> image, PassRefPtr<CSSValue> imageSlice, PassRefPtr<CSSValue> borderSlice,
PassRefPtr<CSSValue> outset, PassRefPtr<CSSValue> repeat);
} // namespace blink
#endif // SKY_ENGINE_CORE_CSS_CSSBORDERIMAGE_H_
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "sky/engine/core/css/CSSBorderImageSliceValue.h"
#include "sky/engine/wtf/text/WTFString.h"
namespace blink {
CSSBorderImageSliceValue::CSSBorderImageSliceValue(PassRefPtr<CSSPrimitiveValue> slices, bool fill)
: CSSValue(BorderImageSliceClass)
, m_slices(slices)
, m_fill(fill)
{
}
String CSSBorderImageSliceValue::customCSSText() const
{
// Dump the slices first.
String text = m_slices->cssText();
// Now the fill keywords if it is present.
if (m_fill)
return text + " fill";
return text;
}
bool CSSBorderImageSliceValue::equals(const CSSBorderImageSliceValue& other) const
{
return m_fill == other.m_fill && compareCSSValuePtr(m_slices, other.m_slices);
}
} // namespace blink
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SKY_ENGINE_CORE_CSS_CSSBORDERIMAGESLICEVALUE_H_
#define SKY_ENGINE_CORE_CSS_CSSBORDERIMAGESLICEVALUE_H_
#include "sky/engine/core/css/CSSPrimitiveValue.h"
#include "sky/engine/wtf/PassRefPtr.h"
#include "sky/engine/wtf/RefPtr.h"
namespace blink {
class Rect;
class CSSBorderImageSliceValue : public CSSValue {
public:
static PassRefPtr<CSSBorderImageSliceValue> create(PassRefPtr<CSSPrimitiveValue> slices, bool fill)
{
return adoptRef(new CSSBorderImageSliceValue(slices, fill));
}
String customCSSText() const;
Quad* slices() { return m_slices ? m_slices->getQuadValue() : 0; }
bool equals(const CSSBorderImageSliceValue&) const;
// These four values are used to make "cuts" in the border image. They can be numbers
// or percentages.
RefPtr<CSSPrimitiveValue> m_slices;
bool m_fill;
private:
CSSBorderImageSliceValue(PassRefPtr<CSSPrimitiveValue> slices, bool fill);
};
DEFINE_CSS_VALUE_TYPE_CASTS(CSSBorderImageSliceValue, isBorderImageSliceValue());
} // namespace blink
#endif // SKY_ENGINE_CORE_CSS_CSSBORDERIMAGESLICEVALUE_H_
......@@ -120,13 +120,11 @@ static bool hasDoubleValue(CSSPrimitiveValue::UnitType type)
case CSSPrimitiveValue::CSS_URI:
case CSSPrimitiveValue::CSS_IDENT:
case CSSPrimitiveValue::CSS_ATTR:
case CSSPrimitiveValue::CSS_RECT:
case CSSPrimitiveValue::CSS_RGBCOLOR:
case CSSPrimitiveValue::CSS_PAIR:
case CSSPrimitiveValue::CSS_UNICODE_RANGE:
case CSSPrimitiveValue::CSS_PARSER_HEXCOLOR:
case CSSPrimitiveValue::CSS_SHAPE:
case CSSPrimitiveValue::CSS_QUAD:
case CSSPrimitiveValue::CSS_CALC:
case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_NUMBER:
case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_LENGTH:
......
......@@ -30,7 +30,6 @@
#include "sky/engine/bindings/exception_state.h"
#include "sky/engine/core/css/BasicShapeFunctions.h"
#include "sky/engine/core/css/CSSAspectRatioValue.h"
#include "sky/engine/core/css/CSSBorderImage.h"
#include "sky/engine/core/css/CSSFilterValue.h"
#include "sky/engine/core/css/CSSFontFeatureValue.h"
#include "sky/engine/core/css/CSSFontValue.h"
......@@ -45,7 +44,6 @@
#include "sky/engine/core/css/CSSValueList.h"
#include "sky/engine/core/css/CSSValuePool.h"
#include "sky/engine/core/css/Pair.h"
#include "sky/engine/core/css/Rect.h"
#include "sky/engine/core/css/StylePropertySet.h"
#include "sky/engine/core/css/parser/BisonCSSParser.h"
#include "sky/engine/core/css/resolver/StyleResolver.h"
......@@ -77,11 +75,6 @@ static const CSSPropertyID staticComputableProperties[] = {
CSSPropertyBorderBottomRightRadius,
CSSPropertyBorderBottomStyle,
CSSPropertyBorderBottomWidth,
CSSPropertyBorderImageOutset,
CSSPropertyBorderImageRepeat,
CSSPropertyBorderImageSlice,
CSSPropertyBorderImageSource,
CSSPropertyBorderImageWidth,
CSSPropertyBorderLeftColor,
CSSPropertyBorderLeftStyle,
CSSPropertyBorderLeftWidth,
......@@ -96,7 +89,6 @@ static const CSSPropertyID staticComputableProperties[] = {
CSSPropertyBottom,
CSSPropertyBoxShadow,
CSSPropertyBoxSizing,
CSSPropertyClip,
CSSPropertyColor,
CSSPropertyDirection,
CSSPropertyDisplay,
......@@ -168,7 +160,6 @@ static const CSSPropertyID staticComputableProperties[] = {
CSSPropertyWebkitBackgroundOrigin,
CSSPropertyWebkitBackgroundSize,
CSSPropertyWebkitBorderHorizontalSpacing,
CSSPropertyWebkitBorderImage,
CSSPropertyWebkitBorderVerticalSpacing,
CSSPropertyWebkitBoxDecorationBreak,
CSSPropertyWebkitBoxShadow,
......@@ -222,163 +213,6 @@ static const Vector<CSSPropertyID>& computableProperties()
return properties;
}
static CSSValueID valueForRepeatRule(int rule)
{
switch (rule) {
case RepeatImageRule:
return CSSValueRepeat;
case RoundImageRule:
return CSSValueRound;
case SpaceImageRule:
return CSSValueSpace;
default:
return CSSValueStretch;
}
}
static PassRefPtr<CSSBorderImageSliceValue> valueForNinePieceImageSlice(const NinePieceImage& image)
{
// Create the slices.
RefPtr<CSSPrimitiveValue> top = nullptr;
RefPtr<CSSPrimitiveValue> right = nullptr;
RefPtr<CSSPrimitiveValue> bottom = nullptr;
RefPtr<CSSPrimitiveValue> left = nullptr;
if (image.imageSlices().top().isPercent())
top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
else
top = cssValuePool().createValue(image.imageSlices().top().value(), CSSPrimitiveValue::CSS_NUMBER);
if (image.imageSlices().right() == image.imageSlices().top() && image.imageSlices().bottom() == image.imageSlices().top()
&& image.imageSlices().left() == image.imageSlices().top()) {
right = top;
bottom = top;
left = top;
} else {
if (image.imageSlices().right().isPercent())
right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
else
right = cssValuePool().createValue(image.imageSlices().right().value(), CSSPrimitiveValue::CSS_NUMBER);
if (image.imageSlices().bottom() == image.imageSlices().top() && image.imageSlices().right() == image.imageSlices().left()) {
bottom = top;
left = right;
} else {
if (image.imageSlices().bottom().isPercent())
bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
else
bottom = cssValuePool().createValue(image.imageSlices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER);
if (image.imageSlices().left() == image.imageSlices().right())
left = right;
else {
if (image.imageSlices().left().isPercent())
left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE);
else
left = cssValuePool().createValue(image.imageSlices().left().value(), CSSPrimitiveValue::CSS_NUMBER);
}
}
}
RefPtr<Quad> quad = Quad::create();
quad->setTop(top);
quad->setRight(right);
quad->setBottom(bottom);
quad->setLeft(left);
return CSSBorderImageSliceValue::create(cssValuePool().createValue(quad.release()), image.fill());
}
static PassRefPtr<CSSPrimitiveValue> valueForNinePieceImageQuad(const BorderImageLengthBox& box, const RenderStyle& style)
{
// Create the slices.
RefPtr<CSSPrimitiveValue> top = nullptr;
RefPtr<CSSPrimitiveValue> right = nullptr;
RefPtr<CSSPrimitiveValue> bottom = nullptr;
RefPtr<CSSPrimitiveValue> left = nullptr;
if (box.top().isNumber())
top = cssValuePool().createValue(box.top().number(), CSSPrimitiveValue::CSS_NUMBER);
else
top = cssValuePool().createValue(box.top().length(), style);
if (box.right() == box.top() && box.bottom() == box.top() && box.left() == box.top()) {
right = top;
bottom = top;
left = top;
} else {
if (box.right().isNumber())
right = cssValuePool().createValue(box.right().number(), CSSPrimitiveValue::CSS_NUMBER);
else
right = cssValuePool().createValue(box.right().length(), style);
if (box.bottom() == box.top() && box.right() == box.left()) {
bottom = top;
left = right;
} else {
if (box.bottom().isNumber())
bottom = cssValuePool().createValue(box.bottom().number(), CSSPrimitiveValue::CSS_NUMBER);
else
bottom = cssValuePool().createValue(box.bottom().length(), style);
if (box.left() == box.right())
left = right;
else {
if (box.left().isNumber())
left = cssValuePool().createValue(box.left().number(), CSSPrimitiveValue::CSS_NUMBER);
else
left = cssValuePool().createValue(box.left().length(), style);
}
}
}
RefPtr<Quad> quad = Quad::create();
quad->setTop(top);
quad->setRight(right);
quad->setBottom(bottom);
quad->setLeft(left);
return cssValuePool().createValue(quad.release());
}
static PassRefPtr<CSSValue> valueForNinePieceImageRepeat(const NinePieceImage& image)
{
RefPtr<CSSPrimitiveValue> horizontalRepeat = nullptr;
RefPtr<CSSPrimitiveValue> verticalRepeat = nullptr;
horizontalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.horizontalRule()));
if (image.horizontalRule() == image.verticalRule())
verticalRepeat = horizontalRepeat;
else
verticalRepeat = cssValuePool().createIdentifierValue(valueForRepeatRule(image.verticalRule()));
return cssValuePool().createValue(Pair::create(horizontalRepeat.release(), verticalRepeat.release(), Pair::DropIdenticalValues));
}
static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image, const RenderStyle& style)
{
if (!image.hasImage())
return cssValuePool().createIdentifierValue(CSSValueNone);
// Image first.
RefPtr<CSSValue> imageValue = nullptr;
if (image.image())
imageValue = image.image()->cssValue();
// Create the image slice.
RefPtr<CSSBorderImageSliceValue> imageSlices = valueForNinePieceImageSlice(image);
// Create the border area slices.
RefPtr<CSSValue> borderSlices = valueForNinePieceImageQuad(image.borderSlices(), style);
// Create the border outset.
RefPtr<CSSValue> outset = valueForNinePieceImageQuad(image.outset(), style);
// Create the repeat rules.
RefPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image);
return createBorderImageValue(imageValue.release(), imageSlices.release(), borderSlices.release(), outset.release(), repeat.release());
}
inline static PassRefPtr<CSSPrimitiveValue> pixelValue(double value, const RenderStyle&)
{
return cssValuePool().createValue(value, CSSPrimitiveValue::CSS_PX);
......@@ -1122,10 +956,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return pixelValue(style->horizontalBorderSpacing(), *style);
case CSSPropertyWebkitBorderVerticalSpacing:
return pixelValue(style->verticalBorderSpacing(), *style);
case CSSPropertyBorderImageSource:
if (style->borderImageSource())
return style->borderImageSource()->cssValue();
return cssValuePool().createIdentifierValue(CSSValueNone);
case CSSPropertyBorderTopColor:
return m_allowVisitedStyle ? cssValuePool().createColorValue(style->colorIncludingFallback(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(*style, style->borderTopColor());
case CSSPropertyBorderRightColor:
......@@ -1540,16 +1370,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
if (!style->hasAspectRatio())
return cssValuePool().createIdentifierValue(CSSValueNone);
return CSSAspectRatioValue::create(style->aspectRatioNumerator(), style->aspectRatioDenominator());
case CSSPropertyWebkitBorderImage:
return valueForNinePieceImage(style->borderImage(), *style);
case CSSPropertyBorderImageOutset:
return valueForNinePieceImageQuad(style->borderImage().outset(), *style);
case CSSPropertyBorderImageRepeat:
return valueForNinePieceImageRepeat(style->borderImage());
case CSSPropertyBorderImageSlice:
return valueForNinePieceImageSlice(style->borderImage());
case CSSPropertyBorderImageWidth:
return valueForNinePieceImageQuad(style->borderImage().borderSlices(), *style);
case CSSPropertyWebkitFontSizeDelta:
// Not a real style property -- used by the editing engine -- so has no computed value.
break;
......@@ -1590,16 +1410,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return valueForBorderRadiusCorner(style->borderTopLeftRadius(), *style);
case CSSPropertyBorderTopRightRadius:
return valueForBorderRadiusCorner(style->borderTopRightRadius(), *style);
case CSSPropertyClip: {
if (style->hasAutoClip())
return cssValuePool().createIdentifierValue(CSSValueAuto);
RefPtr<Rect> rect = Rect::create();
rect->setTop(pixelValue(style->clip().top().value(), *style));
rect->setRight(pixelValue(style->clip().right().value(), *style));
rect->setBottom(pixelValue(style->clip().bottom().value(), *style));
rect->setLeft(pixelValue(style->clip().left().value(), *style));
return cssValuePool().createValue(rect.release());
}
case CSSPropertyTransform:
case CSSPropertyWebkitTransform:
return computedTransform(renderer, *style);
......@@ -1659,8 +1469,6 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropert
return valuesForSidesShorthand(borderColorShorthand());
case CSSPropertyBorderLeft:
return valuesForShorthandProperty(borderLeftShorthand());
case CSSPropertyBorderImage:
return valueForNinePieceImage(style->borderImage(), *style);
case CSSPropertyBorderRadius:
return valueForBorderRadiusShorthand(*style);
case CSSPropertyBorderRight:
......
......@@ -28,7 +28,6 @@
#include "sky/engine/core/css/CSSToLengthConversionData.h"
#include "sky/engine/core/css/Pair.h"
#include "sky/engine/core/css/RGBColor.h"
#include "sky/engine/core/css/Rect.h"
#include "sky/engine/core/css/StyleSheetContents.h"
#include "sky/engine/core/dom/ExceptionCode.h"
#include "sky/engine/core/dom/Node.h"
......@@ -90,8 +89,6 @@ static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::Unit
case CSSPrimitiveValue::CSS_VALUE_ID:
case CSSPrimitiveValue::CSS_PAIR:
case CSSPrimitiveValue::CSS_PARSER_HEXCOLOR:
case CSSPrimitiveValue::CSS_RECT:
case CSSPrimitiveValue::CSS_QUAD:
case CSSPrimitiveValue::CSS_RGBCOLOR:
case CSSPrimitiveValue::CSS_SHAPE:
case CSSPrimitiveValue::CSS_STRING:
......@@ -369,20 +366,6 @@ void CSSPrimitiveValue::init(const LengthSize& lengthSize, const RenderStyle& st
m_value.pair = Pair::create(create(lengthSize.width()), create(lengthSize.height()), Pair::KeepIdenticalValues).leakRef();
}
void CSSPrimitiveValue::init(PassRefPtr<Rect> r)
{
m_primitiveUnitType = CSS_RECT;
m_hasCachedCSSText = false;
m_value.rect = r.leakRef();
}
void CSSPrimitiveValue::init(PassRefPtr<Quad> quad)
{
m_primitiveUnitType = CSS_QUAD;
m_hasCachedCSSText = false;
m_value.quad = quad.leakRef();
}
void CSSPrimitiveValue::init(PassRefPtr<Pair> p)
{
m_primitiveUnitType = CSS_PAIR;
......@@ -419,18 +402,6 @@ void CSSPrimitiveValue::cleanup()
if (m_value.string)
m_value.string->deref();
break;
case CSS_RECT:
// We must not call deref() when oilpan is enabled because m_value.rect is traced.
#if !ENABLE(OILPAN)
m_value.rect->deref();
#endif
break;
case CSS_QUAD:
// We must not call deref() when oilpan is enabled because m_value.quad is traced.
#if !ENABLE(OILPAN)
m_value.quad->deref();
#endif
break;
case CSS_PAIR:
// We must not call deref() when oilpan is enabled because m_value.pair is traced.
#if !ENABLE(OILPAN)
......@@ -925,26 +896,6 @@ String CSSPrimitiveValue::getStringValue() const
return String();
}
Rect* CSSPrimitiveValue::getRectValue(ExceptionState& exceptionState) const
{
if (m_primitiveUnitType != CSS_RECT) {
exceptionState.ThrowDOMException(InvalidAccessError, "This object is not a rect value.");
return 0;
}
return m_value.rect;
}
Quad* CSSPrimitiveValue::getQuadValue(ExceptionState& exceptionState) const
{
if (m_primitiveUnitType != CSS_QUAD) {
exceptionState.ThrowDOMException(InvalidAccessError, "This object is not a quad value.");
return 0;
}
return m_value.quad;
}
PassRefPtr<RGBColor> CSSPrimitiveValue::getRGBColorValue(ExceptionState& exceptionState) const
{
if (m_primitiveUnitType != CSS_RGBCOLOR) {
......@@ -1049,8 +1000,6 @@ const char* CSSPrimitiveValue::unitTypeToString(UnitType type)
case CSS_VALUE_ID:
case CSS_PROPERTY_ID:
case CSS_ATTR:
case CSS_RECT:
case CSS_QUAD:
case CSS_RGBCOLOR:
case CSS_PARSER_HEXCOLOR:
case CSS_PAIR:
......@@ -1135,12 +1084,6 @@ String CSSPrimitiveValue::customCSSText(CSSTextFormattingFlags formattingFlag) c
text = result.toString();
break;
}
case CSS_RECT:
text = getRectValue()->cssText();
break;
case CSS_QUAD:
text = getQuadValue()->cssText();
break;
case CSS_RGBCOLOR:
case CSS_PARSER_HEXCOLOR: {
RGBA32 rgbColor = m_value.rgbcolor;
......@@ -1177,12 +1120,6 @@ PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const
case CSS_ATTR:
result = CSSPrimitiveValue::create(m_value.string, static_cast<UnitType>(m_primitiveUnitType));
break;
case CSS_RECT:
result = CSSPrimitiveValue::create(m_value.rect->cloneForCSSOM());
break;
case CSS_QUAD:
result = CSSPrimitiveValue::create(m_value.quad->cloneForCSSOM());
break;
case CSS_PAIR:
// Pair is not exposed to the CSSOM, no need for a deep clone.
result = CSSPrimitiveValue::create(m_value.pair);
......@@ -1290,10 +1227,6 @@ bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const
case CSS_ATTR:
case CSS_PARSER_HEXCOLOR:
return equal(m_value.string, other.m_value.string);
case CSS_RECT:
return m_value.rect && other.m_value.rect && m_value.rect->equals(*other.m_value.rect);
case CSS_QUAD:
return m_value.quad && other.m_value.quad && m_value.quad->equals(*other.m_value.quad);
case CSS_RGBCOLOR:
return m_value.rgbcolor == other.m_value.rgbcolor;
case CSS_PAIR:
......
......@@ -39,9 +39,7 @@ class ExceptionState;
class Length;
class LengthSize;
class Pair;
class Quad;
class RGBColor;
class Rect;
class RenderStyle;
// Dimension calculations are imprecise, often resulting in values of e.g.
......@@ -94,7 +92,6 @@ public:
CSS_URI = 20,
CSS_IDENT = 21,
CSS_ATTR = 22,
CSS_RECT = 24,
CSS_RGBCOLOR = 25,
// From CSS Values and Units. Viewport-percentage Lengths (vw/vh/vmin/vmax).
CSS_VW = 26,
......@@ -119,9 +116,6 @@ public:
// This is used by the CSS Shapes draft
CSS_SHAPE = 111,
// Used by border images.
CSS_QUAD = 112,
CSS_CALC = 113,
CSS_CALC_PERCENTAGE_WITH_NUMBER = 114,
CSS_CALC_PERCENTAGE_WITH_LENGTH = 115,
......@@ -188,7 +182,6 @@ public:
bool isNumber() const { return primitiveType() == CSS_NUMBER; }
bool isPercentage() const { return primitiveType() == CSS_PERCENTAGE; }
bool isPx() const { return primitiveType() == CSS_PX; }
bool isRect() const { return m_primitiveUnitType == CSS_RECT; }
bool isRGBColor() const { return m_primitiveUnitType == CSS_RGBCOLOR; }
bool isShape() const { return m_primitiveUnitType == CSS_SHAPE; }
bool isString() const { return m_primitiveUnitType == CSS_STRING; }
......@@ -294,12 +287,6 @@ public:
String getStringValue(ExceptionState&) const;
String getStringValue() const;
Rect* getRectValue(ExceptionState&) const;
Rect* getRectValue() const { return m_primitiveUnitType != CSS_RECT ? 0 : m_value.rect; }
Quad* getQuadValue(ExceptionState&) const;
Quad* getQuadValue() const { return m_primitiveUnitType != CSS_QUAD ? 0 : m_value.quad; }
PassRefPtr<RGBColor> getRGBColorValue(ExceptionState&) const;
RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ? 0 : m_value.rgbcolor; }
......@@ -362,9 +349,7 @@ private:
void init(const Length&);
void init(const LengthSize&, const RenderStyle&);
void init(PassRefPtr<Rect>);
void init(PassRefPtr<Pair>);
void init(PassRefPtr<Quad>);
void init(PassRefPtr<CSSBasicShape>);
void init(PassRefPtr<CSSCalcValue>);
bool getDoubleValueInternal(UnitType targetUnitType, double* result) const;
......@@ -382,8 +367,6 @@ private:
CSSBasicShape* shape;
CSSCalcValue* calc;
Pair* pair;
Rect* rect;
Quad* quad;
} m_value;
};
......
......@@ -120,11 +120,6 @@ border-bottom-left-radius initial=initialBorderRadius, converter=convertRadius
border-bottom-right-radius initial=initialBorderRadius, converter=convertRadius
border-bottom-style type_name=EBorderStyle, initial=initialBorderStyle
border-bottom-width initial=initialBorderWidth, converter=convertLineWidth<unsigned>
border-image-outset custom_all
border-image-repeat custom_all
border-image-slice custom_all
border-image-source custom_value
border-image-width custom_all
border-left-color custom_all
border-left-style type_name=EBorderStyle, initial=initialBorderStyle
border-left-width initial=initialBorderWidth, converter=convertLineWidth<unsigned>
......@@ -145,8 +140,6 @@ box-shadow converter=convertShadow
// LAYOUT
box-sizing
clip converter=convertClip, custom_all
// LAYOUT
display
......@@ -288,8 +281,6 @@ filter custom_value
// LAYOUT
-webkit-border-horizontal-spacing inherited, name_for_methods=HorizontalBorderSpacing, converter=convertComputedLength<short>
-webkit-border-image initial=initialNinePieceImage, custom_value
// LAYOUT
-webkit-border-vertical-spacing inherited, name_for_methods=VerticalBorderSpacing, converter=convertComputedLength<short>
......@@ -419,7 +410,6 @@ background-repeat longhands=background-repeat-x;background-repeat-y
border longhands=border-top-color;border-top-style;border-top-width;border-right-color;border-right-style;border-right-width;border-bottom-color;border-bottom-style;border-bottom-width;border-left-color;border-left-style;border-left-width
border-bottom longhands=border-bottom-width;border-bottom-style;border-bottom-color
border-color longhands=border-top-color;border-right-color;border-bottom-color;border-left-color
border-image longhands=border-image-source;border-image-slice;border-image-width;border-image-outset;border-image-repeat
border-left longhands=border-left-width;border-left-style;border-left-color
border-radius longhands=border-top-left-radius;border-top-right-radius;border-bottom-right-radius;border-bottom-left-radius
border-right longhands=border-right-width;border-right-style;border-right-color
......
......@@ -27,7 +27,6 @@
#include "sky/engine/core/css/CSSValue.h"
#include "sky/engine/core/css/CSSAspectRatioValue.h"
#include "sky/engine/core/css/CSSBorderImageSliceValue.h"
#include "sky/engine/core/css/CSSCalculationValue.h"
#include "sky/engine/core/css/CSSFilterValue.h"
#include "sky/engine/core/css/CSSFontFeatureValue.h"
......@@ -109,8 +108,6 @@ bool CSSValue::equals(const CSSValue& other) const
switch (m_classType) {
case AspectRatioClass:
return compareCSSValues<CSSAspectRatioValue>(*this, other);
case BorderImageSliceClass:
return compareCSSValues<CSSBorderImageSliceValue>(*this, other);
case FontClass:
return compareCSSValues<CSSFontValue>(*this, other);
case FontFeatureClass:
......@@ -163,8 +160,6 @@ String CSSValue::cssText() const
switch (classType()) {
case AspectRatioClass:
return toCSSAspectRatioValue(this)->customCSSText();
case BorderImageSliceClass:
return toCSSBorderImageSliceValue(this)->customCSSText();
case FontClass:
return toCSSFontValue(this)->customCSSText();
case FontFeatureClass:
......@@ -213,9 +208,6 @@ void CSSValue::destroy()
case AspectRatioClass:
delete toCSSAspectRatioValue(this);
return;
case BorderImageSliceClass:
delete toCSSBorderImageSliceValue(this);
return;
case FontClass:
delete toCSSFontValue(this);
return;
......
......@@ -76,7 +76,6 @@ public:
bool isBaseValueList() const { return m_classType == ValueListClass; }
bool isAspectRatioValue() const { return m_classType == AspectRatioClass; }
bool isBorderImageSliceValue() const { return m_classType == BorderImageSliceClass; }
bool isFontFeatureValue() const { return m_classType == FontFeatureClass; }
bool isFontValue() const { return m_classType == FontClass; }
bool isFunctionValue() const { return m_classType == FunctionClass; }
......@@ -117,7 +116,6 @@ protected:
// Other class types.
AspectRatioClass,
BorderImageSliceClass,
FontFeatureClass,
FontClass,
FunctionClass,
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/engine/core/css/Rect.h"
namespace blink {
DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(RectBase)
}
/*
* Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef SKY_ENGINE_CORE_CSS_RECT_H_
#define SKY_ENGINE_CORE_CSS_RECT_H_
#include "sky/engine/tonic/dart_wrappable.h"
#include "sky/engine/core/css/CSSPrimitiveValue.h"
#include "sky/engine/wtf/RefPtr.h"
#include "sky/engine/wtf/text/StringBuilder.h"
namespace blink {
class RectBase : public RefCounted<RectBase> {
DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(RectBase);
public:
CSSPrimitiveValue* top() const { return m_top.get(); }
CSSPrimitiveValue* right() const { return m_right.get(); }
CSSPrimitiveValue* bottom() const { return m_bottom.get(); }
CSSPrimitiveValue* left() const { return m_left.get(); }
void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
void setRight(PassRefPtr<CSSPrimitiveValue> right) { m_right = right; }
void setBottom(PassRefPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; }
void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
bool equals(const RectBase& other) const
{
return compareCSSValuePtr(m_top, other.m_top)
&& compareCSSValuePtr(m_right, other.m_right)
&& compareCSSValuePtr(m_left, other.m_left)
&& compareCSSValuePtr(m_bottom, other.m_bottom);
}
protected:
RectBase() { }
RectBase(const RectBase& cloneFrom)
: m_top(cloneFrom.m_top ? cloneFrom.m_top->cloneForCSSOM() : nullptr)
, m_right(cloneFrom.m_right ? cloneFrom.m_right->cloneForCSSOM() : nullptr)
, m_bottom(cloneFrom.m_bottom ? cloneFrom.m_bottom->cloneForCSSOM() : nullptr)
, m_left(cloneFrom.m_left ? cloneFrom.m_left->cloneForCSSOM() : nullptr)
{
}
private:
RefPtr<CSSPrimitiveValue> m_top;
RefPtr<CSSPrimitiveValue> m_right;
RefPtr<CSSPrimitiveValue> m_bottom;
RefPtr<CSSPrimitiveValue> m_left;
};
class Rect : public RectBase {
public:
static PassRefPtr<Rect> create() { return adoptRef(new Rect); }
PassRefPtr<Rect> cloneForCSSOM() const { return adoptRef(new Rect(*this)); }
String cssText() const
{
return generateCSSString(top()->cssText(), right()->cssText(), bottom()->cssText(), left()->cssText());
}
private:
Rect() { }
Rect(const Rect& cloneFrom) : RectBase(cloneFrom) { }
static String generateCSSString(const String& top, const String& right, const String& bottom, const String& left)
{
return "rect(" + top + ' ' + right + ' ' + bottom + ' ' + left + ')';
}
// NOTE: If adding fields to this class please make the RectBase trace
// method virtual and add a trace method in this subclass tracing the new
// fields.
};
class Quad : public RectBase {
public:
static PassRefPtr<Quad> create() { return adoptRef(new Quad); }
PassRefPtr<Quad> cloneForCSSOM() const { return adoptRef(new Quad(*this)); }
String cssText() const
{
return generateCSSString(top()->cssText(), right()->cssText(), bottom()->cssText(), left()->cssText());
}
private:
Quad() { }
Quad(const Quad& cloneFrom) : RectBase(cloneFrom) { }
static String generateCSSString(const String& top, const String& right, const String& bottom, const String& left)
{
StringBuilder result;
// reserve space for the four strings, plus three space separator characters.
result.reserveCapacity(top.length() + right.length() + bottom.length() + left.length() + 3);
result.append(top);
if (right != top || bottom != top || left != top) {
result.append(' ');
result.append(right);
if (bottom != top || right != left) {
result.append(' ');
result.append(bottom);
if (left != right) {
result.append(' ');
result.append(left);
}
}
}
return result.toString();
}
// NOTE: If adding fields to this class please make the RectBase trace
// method virtual and add a trace method in this subclass tracing the new
// fields.
};
} // namespace blink
#endif // SKY_ENGINE_CORE_CSS_RECT_H_
......@@ -32,7 +32,6 @@
#include "gen/sky/platform/RuntimeEnabledFeatures.h"
#include "sky/engine/core/css/CSSAspectRatioValue.h"
#include "sky/engine/core/css/CSSBasicShapes.h"
#include "sky/engine/core/css/CSSBorderImage.h"
#include "sky/engine/core/css/CSSFontFeatureValue.h"
#include "sky/engine/core/css/CSSFunctionValue.h"
#include "sky/engine/core/css/CSSGradientValue.h"
......@@ -50,7 +49,6 @@
#include "sky/engine/core/css/CSSValuePool.h"
#include "sky/engine/core/css/HashTools.h"
#include "sky/engine/core/css/Pair.h"
#include "sky/engine/core/css/Rect.h"
#include "sky/engine/core/css/StylePropertySet.h"
#include "sky/engine/core/css/StyleRule.h"
#include "sky/engine/core/css/StyleSheetContents.h"
......
......@@ -48,7 +48,6 @@ namespace blink {
class CSSBasicShape;
class CSSBasicShapeInset;
class CSSBorderImageSliceValue;
class CSSPrimitiveValue;
class CSSSelectorList;
class CSSValue;
......
......@@ -40,7 +40,6 @@
namespace blink {
class CSSBorderImageSliceValue;
class CSSPrimitiveValue;
class CSSValue;
class CSSValueList;
......@@ -116,8 +115,6 @@ private:
bool parseWebkitTransformOriginShorthand();
bool parseClipShape(CSSPropertyID);
bool parseItemPositionOverflowPosition(CSSPropertyID);
PassRefPtr<CSSValue> parseShapeProperty(CSSPropertyID propId);
......@@ -146,12 +143,6 @@ private:
// CSS3 Parsing Routines (for properties specific to CSS3)
PassRefPtr<CSSValueList> parseShadow(CSSParserValueList*, CSSPropertyID);
bool parseBorderImageShorthand(CSSPropertyID);
PassRefPtr<CSSValue> parseBorderImage(CSSPropertyID);
bool parseBorderImageRepeat(RefPtr<CSSValue>&);
bool parseBorderImageSlice(CSSPropertyID, RefPtr<CSSBorderImageSliceValue>&);
bool parseBorderImageWidth(RefPtr<CSSPrimitiveValue>&);
bool parseBorderImageOutset(RefPtr<CSSPrimitiveValue>&);
bool parseBorderRadius(CSSPropertyID);
PassRefPtr<CSSValue> parseAspectRatio();
......@@ -267,7 +258,6 @@ private:
inline bool validUnit(CSSParserValue* value, Units unitflags, ReleaseParsedCalcValueCondition releaseCalc = DoNotReleaseParsedCalcValue) { return validUnit(value, unitflags, m_context.mode(), releaseCalc); }
bool validUnit(CSSParserValue*, Units, CSSParserMode, ReleaseParsedCalcValueCondition releaseCalc = DoNotReleaseParsedCalcValue);
bool parseBorderImageQuad(Units, RefPtr<CSSPrimitiveValue>&);
int colorIntFromValue(CSSParserValue*);
bool isCalculation(CSSParserValue*);
......@@ -290,9 +280,6 @@ private:
// FIXME: There is probably a small set of APIs we could expose for these
// classes w/o needing to make them friends.
friend class ShadowParseContext;
friend class BorderImageParseContext;
friend class BorderImageSliceParseContext;
friend class BorderImageQuadParseContext;
friend class TransformOperationInfo;
friend PassRefPtr<CSSPrimitiveValue> parseGradientColorOrKeyword(CSSPropertyParser*, CSSParserValue*);
};
......
......@@ -28,13 +28,10 @@
#include "sky/engine/core/css/resolver/CSSToStyleMap.h"
#include "gen/sky/core/CSSValueKeywords.h"
#include "sky/engine/core/css/CSSBorderImageSliceValue.h"
#include "sky/engine/core/css/CSSPrimitiveValue.h"
#include "sky/engine/core/css/CSSPrimitiveValueMappings.h"
#include "sky/engine/core/css/Pair.h"
#include "sky/engine/core/css/Rect.h"
#include "sky/engine/core/css/resolver/StyleResolverState.h"
#include "sky/engine/core/rendering/style/BorderImageLengthBox.h"
#include "sky/engine/core/rendering/style/FillLayer.h"
namespace blink {
......@@ -253,169 +250,4 @@ void CSSToStyleMap::mapFillYPosition(FillLayer* layer, CSSValue* value) const
layer->setBackgroundYOrigin(*(pair->first()));
}
void CSSToStyleMap::mapNinePieceImage(RenderStyle* mutableStyle, CSSPropertyID property, CSSValue* value, NinePieceImage& image)
{
// If we're not a value list, then we are "none" and don't need to alter the empty image at all.
if (!value || !value->isValueList())
return;
// Retrieve the border image value.
CSSValueList* borderImage = toCSSValueList(value);
// Set the image (this kicks off the load).
CSSPropertyID imageProperty;
if (property == CSSPropertyWebkitBorderImage)
imageProperty = CSSPropertyBorderImageSource;
else
imageProperty = property;
for (unsigned i = 0 ; i < borderImage->length() ; ++i) {
CSSValue* current = borderImage->item(i);
if (current->isImageGeneratorValue())
image.setImage(styleImage(imageProperty, current));
else if (current->isBorderImageSliceValue())
mapNinePieceImageSlice(current, image);
else if (current->isValueList()) {
CSSValueList* slashList = toCSSValueList(current);
size_t length = slashList->length();
// Map in the image slices.
if (length && slashList->item(0)->isBorderImageSliceValue())
mapNinePieceImageSlice(slashList->item(0), image);
// Map in the border slices.
if (length > 1)
image.setBorderSlices(mapNinePieceImageQuad(slashList->item(1)));
// Map in the outset.
if (length > 2)
image.setOutset(mapNinePieceImageQuad(slashList->item(2)));
} else if (current->isPrimitiveValue()) {
// Set the appropriate rules for stretch/round/repeat of the slices.
mapNinePieceImageRepeat(current, image);
}
}
if (property == CSSPropertyWebkitBorderImage) {
// We have to preserve the legacy behavior of -webkit-border-image and make the border slices
// also set the border widths. We don't need to worry about percentages, since we don't even support
// those on real borders yet.
if (image.borderSlices().top().isLength() && image.borderSlices().top().length().isFixed())
mutableStyle->setBorderTopWidth(image.borderSlices().top().length().value());
if (image.borderSlices().right().isLength() && image.borderSlices().right().length().isFixed())
mutableStyle->setBorderRightWidth(image.borderSlices().right().length().value());
if (image.borderSlices().bottom().isLength() && image.borderSlices().bottom().length().isFixed())
mutableStyle->setBorderBottomWidth(image.borderSlices().bottom().length().value());
if (image.borderSlices().left().isLength() && image.borderSlices().left().length().isFixed())
mutableStyle->setBorderLeftWidth(image.borderSlices().left().length().value());
}
}
void CSSToStyleMap::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& image) const
{
if (!value || !value->isBorderImageSliceValue())
return;
// Retrieve the border image value.
CSSBorderImageSliceValue* borderImageSlice = toCSSBorderImageSliceValue(value);
// Set up a length box to represent our image slices.
LengthBox box;
Quad* slices = borderImageSlice->slices();
if (slices->top()->isPercentage())
box.m_top = Length(slices->top()->getDoubleValue(), Percent);
else
box.m_top = Length(slices->top()->getIntValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
if (slices->bottom()->isPercentage())
box.m_bottom = Length(slices->bottom()->getDoubleValue(), Percent);
else
box.m_bottom = Length((int)slices->bottom()->getFloatValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
if (slices->left()->isPercentage())
box.m_left = Length(slices->left()->getDoubleValue(), Percent);
else
box.m_left = Length(slices->left()->getIntValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
if (slices->right()->isPercentage())
box.m_right = Length(slices->right()->getDoubleValue(), Percent);
else
box.m_right = Length(slices->right()->getIntValue(CSSPrimitiveValue::CSS_NUMBER), Fixed);
image.setImageSlices(box);
// Set our fill mode.
image.setFill(borderImageSlice->m_fill);
}
static BorderImageLength toBorderImageLength(CSSPrimitiveValue& value, const CSSToLengthConversionData& conversionData)
{
if (value.isNumber())
return value.getDoubleValue();
if (value.isPercentage())
return Length(value.getDoubleValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
if (value.getValueID() != CSSValueAuto)
return value.computeLength<Length>(conversionData);
return Length(Auto);
}
BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const
{
if (!value || !value->isPrimitiveValue())
return BorderImageLengthBox(Length(Auto));
Quad* slices = toCSSPrimitiveValue(value)->getQuadValue();
// Set up a border image length box to represent our image slices.
return BorderImageLengthBox(
toBorderImageLength(*slices->top(), cssToLengthConversionData()),
toBorderImageLength(*slices->right(), cssToLengthConversionData()),
toBorderImageLength(*slices->bottom(), cssToLengthConversionData()),
toBorderImageLength(*slices->left(), cssToLengthConversionData()));
}
void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& image) const
{
if (!value || !value->isPrimitiveValue())
return;
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
Pair* pair = primitiveValue->getPairValue();
if (!pair || !pair->first() || !pair->second())
return;
CSSValueID firstIdentifier = pair->first()->getValueID();
CSSValueID secondIdentifier = pair->second()->getValueID();
ENinePieceImageRule horizontalRule;
switch (firstIdentifier) {
case CSSValueStretch:
horizontalRule = StretchImageRule;
break;
case CSSValueRound:
horizontalRule = RoundImageRule;
break;
case CSSValueSpace:
horizontalRule = SpaceImageRule;
break;
default: // CSSValueRepeat
horizontalRule = RepeatImageRule;
break;
}
image.setHorizontalRule(horizontalRule);
ENinePieceImageRule verticalRule;
switch (secondIdentifier) {
case CSSValueStretch:
verticalRule = StretchImageRule;
break;
case CSSValueRound:
verticalRule = RoundImageRule;
break;
case CSSValueSpace:
verticalRule = SpaceImageRule;
break;
default: // CSSValueRepeat
verticalRule = RepeatImageRule;
break;
}
image.setVerticalRule(verticalRule);
}
};
......@@ -35,8 +35,6 @@ class CSSValue;
class RenderStyle;
class StyleImage;
class StyleResolverState;
class NinePieceImage;
class BorderImageLengthBox;
// CSSToStyleMap is a short-lived helper object which
// given the current StyleResolverState can map
......@@ -65,11 +63,6 @@ public:
static AtomicString mapAnimationName(CSSValue*);
static EAnimPlayState mapAnimationPlayState(CSSValue*);
void mapNinePieceImage(RenderStyle* mutableStyle, CSSPropertyID, CSSValue*, NinePieceImage&);
void mapNinePieceImageSlice(CSSValue*, NinePieceImage&) const;
BorderImageLengthBox mapNinePieceImageQuad(CSSValue*) const;
void mapNinePieceImageRepeat(CSSValue*, NinePieceImage&) const;
private:
const CSSToLengthConversionData& cssToLengthConversionData() const;
......
......@@ -31,7 +31,6 @@
#include "sky/engine/core/css/CSSPrimitiveValueMappings.h"
#include "sky/engine/core/css/CSSShadowValue.h"
#include "sky/engine/core/css/Pair.h"
#include "sky/engine/core/css/Rect.h"
namespace blink {
......@@ -46,16 +45,6 @@ AtomicString StyleBuilderConverter::convertFragmentIdentifier(StyleResolverState
return nullAtom;
}
LengthBox StyleBuilderConverter::convertClip(StyleResolverState& state, CSSValue* value)
{
Rect* rect = toCSSPrimitiveValue(value)->getRectValue();
return LengthBox(convertLengthOrAuto(state, rect->top()),
convertLengthOrAuto(state, rect->right()),
convertLengthOrAuto(state, rect->bottom()),
convertLengthOrAuto(state, rect->left()));
}
PassRefPtr<FontFeatureSettings> StyleBuilderConverter::convertFontFeatureSettings(StyleResolverState& state, CSSValue* value)
{
if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueNormal)
......
......@@ -44,7 +44,6 @@ public:
static AtomicString convertFragmentIdentifier(StyleResolverState&, CSSValue*);
static Color convertColor(StyleResolverState&, CSSValue*);
template <typename T> static T convertComputedLength(StyleResolverState&, CSSValue*);
static LengthBox convertClip(StyleResolverState&, CSSValue*);
template <typename T> static T convertFlags(StyleResolverState&, CSSValue*);
static PassRefPtr<FontFeatureSettings> convertFontFeatureSettings(StyleResolverState&, CSSValue*);
static FontWeight convertFontWeight(StyleResolverState&, CSSValue*);
......
......@@ -424,13 +424,6 @@ void StyleBuilderFunctions::applyValueCSSPropertyWebkitAspectRatio(StyleResolver
state.style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue());
}
void StyleBuilderFunctions::applyValueCSSPropertyWebkitBorderImage(StyleResolverState& state, CSSValue* value)
{
NinePieceImage image;
state.styleMap().mapNinePieceImage(state.style(), CSSPropertyWebkitBorderImage, value, image);
state.style()->setBorderImage(image);
}
void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverState& state, CSSValue* value)
{
if (value->isPrimitiveValue()) {
......
......@@ -160,7 +160,6 @@ void InlineFlowBox::addToLine(InlineBox* child)
if (box.hasRenderOverflow() || box.hasSelfPaintingLayer())
child->clearKnownToHaveNoOverflow();
} else if (child->renderer().style(isFirstLineStyle())->boxShadow() || hasSelfPaintingLayer(child)
|| child->renderer().style(isFirstLineStyle())->hasBorderImageOutsets()
|| child->renderer().style(isFirstLineStyle())->hasOutline()) {
child->clearKnownToHaveNoOverflow();
}
......@@ -738,37 +737,7 @@ inline void InlineFlowBox::addBoxShadowVisualOverflow(LayoutRect& logicalVisualO
inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisualOverflow)
{
// border-image-outset on root line boxes is applying to the block and not to the lines.
if (!parent())
return;
RenderStyle* style = renderer().style(isFirstLineStyle());
if (!style->hasBorderImageOutsets())
return;
LayoutBoxExtent borderOutsets = style->borderImageOutsets();
LayoutUnit borderOutsetLogicalTop = borderOutsets.logicalTop();
LayoutUnit borderOutsetLogicalBottom = borderOutsets.logicalBottom();
LayoutUnit borderOutsetLogicalLeft = borderOutsets.logicalLeft();
LayoutUnit borderOutsetLogicalRight = borderOutsets.logicalRight();
// Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite border that applies, since
// the line is "upside down" in terms of block coordinates. vertical-rl and horizontal-bt are the flipped line modes.
LayoutUnit outsetLogicalTop = borderOutsetLogicalTop;
LayoutUnit outsetLogicalBottom = borderOutsetLogicalBottom;
LayoutUnit logicalTopVisualOverflow = std::min(pixelSnappedLogicalTop() - outsetLogicalTop, logicalVisualOverflow.y());
LayoutUnit logicalBottomVisualOverflow = std::max(pixelSnappedLogicalBottom() + outsetLogicalBottom, logicalVisualOverflow.maxY());
LayoutUnit outsetLogicalLeft = includeLogicalLeftEdge() ? borderOutsetLogicalLeft : LayoutUnit();
LayoutUnit outsetLogicalRight = includeLogicalRightEdge() ? borderOutsetLogicalRight : LayoutUnit();
LayoutUnit logicalLeftVisualOverflow = std::min(pixelSnappedLogicalLeft() - outsetLogicalLeft, logicalVisualOverflow.x());
LayoutUnit logicalRightVisualOverflow = std::max(pixelSnappedLogicalRight() + outsetLogicalRight, logicalVisualOverflow.maxX());
logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisualOverflow,
logicalRightVisualOverflow - logicalLeftVisualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow);
return;
}
inline void InlineFlowBox::addOutlineVisualOverflow(LayoutRect& logicalVisualOverflow)
......@@ -1083,22 +1052,6 @@ void InlineFlowBox::paintBoxShadow(const PaintInfo& info, RenderStyle* s, Shadow
}
}
static LayoutRect clipRectForNinePieceImageStrip(InlineFlowBox* box, const NinePieceImage& image, const LayoutRect& paintRect)
{
LayoutRect clipRect(paintRect);
RenderStyle* style = box->renderer().style();
LayoutBoxExtent outsets = style->imageOutsets(image);
clipRect.setY(paintRect.y() - outsets.top());
clipRect.setHeight(paintRect.height() + outsets.top() + outsets.bottom());
if (box->includeLogicalLeftEdge()) {
clipRect.setX(paintRect.x() - outsets.left());
clipRect.setWidth(paintRect.width() + outsets.left());
}
if (box->includeLogicalRightEdge())
clipRect.setWidth(clipRect.width() + outsets.right());
return clipRect;
}
void InlineFlowBox::paintBoxDecorationBackground(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
// You can use p::first-line to specify a background. If so, the root line boxes for
......@@ -1133,41 +1086,7 @@ void InlineFlowBox::paintBoxDecorationBackground(PaintInfo& paintInfo, const Lay
// :first-line cannot be used to put borders on a line. Always paint borders with our
// non-first-line style.
if (parent() && renderer().style()->hasBorder()) {
const NinePieceImage& borderImage = renderer().style()->borderImage();
StyleImage* borderImageSource = borderImage.image();
bool hasBorderImage = borderImageSource && borderImageSource->canRender(renderer());
if (hasBorderImage && !borderImageSource->isLoaded())
return; // Don't paint anything while we wait for the image to load.
// The simple case is where we either have no border image or we are the only box for this object.
// In those cases only a single call to draw is required.
if (!hasBorderImage || (!prevLineBox() && !nextLineBox())) {
boxModelObject()->paintBorder(paintInfo, paintRect, renderer().style(isFirstLineStyle()), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
} else {
// We have a border image that spans multiple lines.
// We need to adjust tx and ty by the width of all previous lines.
// Think of border image painting on inlines as though you had one long line, a single continuous
// strip. Even though that strip has been broken up across multiple lines, you still paint it
// as though you had one single line. This means each line has to pick up the image where
// the previous line left off.
// FIXME: What the heck do we do with RTL here? The math we're using is obviously not right,
// but it isn't even clear how this should work at all.
LayoutUnit logicalOffsetOnLine = 0;
for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox())
logicalOffsetOnLine += curr->logicalWidth();
LayoutUnit totalLogicalWidth = logicalOffsetOnLine;
for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox())
totalLogicalWidth += curr->logicalWidth();
LayoutUnit stripX = adjustedPaintOffset.x() - logicalOffsetOnLine;
LayoutUnit stripY = adjustedPaintOffset.y();
LayoutUnit stripWidth = totalLogicalWidth;
LayoutUnit stripHeight = frameRect.height();
LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borderImage, paintRect);
GraphicsContextStateSaver stateSaver(*paintInfo.context);
paintInfo.context->clip(clipRect);
boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer().style(isFirstLineStyle()));
}
boxModelObject()->paintBorder(paintInfo, paintRect, renderer().style(isFirstLineStyle()), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
}
}
......
......@@ -954,7 +954,7 @@ void RenderBox::paintRootBoxFillLayers(const PaintInfo& paintInfo)
BackgroundBleedAvoidance RenderBox::determineBackgroundBleedAvoidance(GraphicsContext* context, const BoxDecorationData& boxDecorationData) const
{
if (!boxDecorationData.hasBackground || !boxDecorationData.hasBorder || !style()->hasBorderRadius() || canRenderBorderImage())
if (!boxDecorationData.hasBackground || !boxDecorationData.hasBorder || !style()->hasBorderRadius())
return BackgroundBleedNone;
// FIXME: See crbug.com/382491. getCTM does not accurately reflect the scale at the time content is
......@@ -2842,14 +2842,6 @@ LayoutBoxExtent RenderBox::computeVisualEffectOverflowExtent() const
left = -left;
}
if (style()->hasBorderImageOutsets()) {
LayoutBoxExtent borderOutsets = style()->borderImageOutsets();
top = std::max(top, borderOutsets.top());
right = std::max(right, borderOutsets.right());
bottom = std::max(bottom, borderOutsets.bottom());
left = std::max(left, borderOutsets.left());
}
if (style()->hasOutline()) {
if (style()->outlineStyleIsAuto()) {
// The result focus ring rects are in coordinates of this object's border box.
......
......@@ -766,179 +766,6 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderBox* pai
geometry.setDestOrigin(geometry.destRect().location());
}
static LayoutUnit computeBorderImageSide(const BorderImageLength& borderSlice, LayoutUnit borderSide, LayoutUnit imageSide, LayoutUnit boxExtent)
{
if (borderSlice.isNumber())
return borderSlice.number() * borderSide;
if (borderSlice.length().isAuto())
return imageSide;
return valueForLength(borderSlice.length(), boxExtent);
}
bool RenderBoxModelObject::paintNinePieceImage(GraphicsContext* graphicsContext, const LayoutRect& rect, const RenderStyle* style,
const NinePieceImage& ninePieceImage)
{
StyleImage* styleImage = ninePieceImage.image();
if (!styleImage)
return false;
if (!styleImage->isLoaded())
return true; // Never paint a nine-piece image incrementally, but don't paint the fallback borders either.
if (!styleImage->canRender(*this))
return false;
LayoutRect rectWithOutsets = rect;
rectWithOutsets.expand(style->imageOutsets(ninePieceImage));
IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets);
IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size());
// If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
styleImage->setContainerSizeForRenderer(this, imageSize);
int imageWidth = imageSize.width();
int imageHeight = imageSize.height();
float imageScaleFactor = styleImage->imageScaleFactor();
int topSlice = std::min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().top(), imageHeight)) * imageScaleFactor;
int rightSlice = std::min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().right(), imageWidth)) * imageScaleFactor;
int bottomSlice = std::min<int>(imageHeight, valueForLength(ninePieceImage.imageSlices().bottom(), imageHeight)) * imageScaleFactor;
int leftSlice = std::min<int>(imageWidth, valueForLength(ninePieceImage.imageSlices().left(), imageWidth)) * imageScaleFactor;
ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
ENinePieceImageRule vRule = ninePieceImage.verticalRule();
int topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), style->borderTopWidth(), topSlice, borderImageRect.height());
int rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(), style->borderRightWidth(), rightSlice, borderImageRect.width());
int bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().bottom(), style->borderBottomWidth(), bottomSlice, borderImageRect.height());
int leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(), style->borderLeftWidth(), leftSlice, borderImageRect.width());
// Reduce the widths if they're too large.
// The spec says: Given Lwidth as the width of the border image area, Lheight as its height, and Wside as the border image width
// offset for the side, let f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbottom)). If f < 1, then all W are reduced by
// multiplying them by f.
int borderSideWidth = std::max(1, leftWidth + rightWidth);
int borderSideHeight = std::max(1, topWidth + bottomWidth);
float borderSideScaleFactor = std::min((float)borderImageRect.width() / borderSideWidth, (float)borderImageRect.height() / borderSideHeight);
if (borderSideScaleFactor < 1) {
topWidth *= borderSideScaleFactor;
rightWidth *= borderSideScaleFactor;
bottomWidth *= borderSideScaleFactor;
leftWidth *= borderSideScaleFactor;
}
bool drawLeft = leftSlice > 0 && leftWidth > 0;
bool drawTop = topSlice > 0 && topWidth > 0;
bool drawRight = rightSlice > 0 && rightWidth > 0;
bool drawBottom = bottomSlice > 0 && bottomWidth > 0;
bool drawMiddle = ninePieceImage.fill() && (imageWidth - leftSlice - rightSlice) > 0 && (borderImageRect.width() - leftWidth - rightWidth) > 0
&& (imageHeight - topSlice - bottomSlice) > 0 && (borderImageRect.height() - topWidth - bottomWidth) > 0;
RefPtr<Image> image = styleImage->image(this, imageSize);
float destinationWidth = borderImageRect.width() - leftWidth - rightWidth;
float destinationHeight = borderImageRect.height() - topWidth - bottomWidth;
float sourceWidth = imageWidth - leftSlice - rightSlice;
float sourceHeight = imageHeight - topSlice - bottomSlice;
float leftSideScale = drawLeft ? (float)leftWidth / leftSlice : 1;
float rightSideScale = drawRight ? (float)rightWidth / rightSlice : 1;
float topSideScale = drawTop ? (float)topWidth / topSlice : 1;
float bottomSideScale = drawBottom ? (float)bottomWidth / bottomSlice : 1;
if (drawLeft) {
// Paint the top and bottom left corners.
// The top left corner rect is (tx, ty, leftWidth, topWidth)
// The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
if (drawTop)
graphicsContext->drawImage(image.get(), IntRect(borderImageRect.location(), IntSize(leftWidth, topWidth)),
LayoutRect(0, 0, leftSlice, topSlice), CompositeSourceOver);
// The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth)
// The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
if (drawBottom)
graphicsContext->drawImage(image.get(), IntRect(borderImageRect.x(), borderImageRect.maxY() - bottomWidth, leftWidth, bottomWidth),
LayoutRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), CompositeSourceOver);
// Paint the left edge.
// Have to scale and tile into the border rect.
if (sourceHeight > 0)
graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth, destinationHeight),
IntRect(0, topSlice, leftSlice, sourceHeight),
FloatSize(leftSideScale, leftSideScale), Image::StretchTile, (Image::TileRule)vRule, CompositeSourceOver);
}
if (drawRight) {
// Paint the top and bottom right corners
// The top right corner rect is (tx + w - rightWidth, ty, rightWidth, topWidth)
// The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
if (drawTop)
graphicsContext->drawImage(image.get(), IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.y(), rightWidth, topWidth),
LayoutRect(imageWidth - rightSlice, 0, rightSlice, topSlice), CompositeSourceOver);
// The bottom right corner rect is (tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)
// The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice)
if (drawBottom)
graphicsContext->drawImage(image.get(), IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.maxY() - bottomWidth, rightWidth, bottomWidth),
LayoutRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), CompositeSourceOver);
// Paint the right edge.
if (sourceHeight > 0)
graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth,
destinationHeight),
IntRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight),
FloatSize(rightSideScale, rightSideScale),
Image::StretchTile, (Image::TileRule)vRule, CompositeSourceOver);
}
// Paint the top edge.
if (drawTop && sourceWidth > 0)
graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth),
IntRect(leftSlice, 0, sourceWidth, topSlice),
FloatSize(topSideScale, topSideScale), (Image::TileRule)hRule, Image::StretchTile, CompositeSourceOver);
// Paint the bottom edge.
if (drawBottom && sourceWidth > 0)
graphicsContext->drawTiledImage(image.get(), IntRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth,
destinationWidth, bottomWidth),
IntRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice),
FloatSize(bottomSideScale, bottomSideScale),
(Image::TileRule)hRule, Image::StretchTile, CompositeSourceOver);
// Paint the middle.
if (drawMiddle) {
FloatSize middleScaleFactor(1, 1);
if (drawTop)
middleScaleFactor.setWidth(topSideScale);
else if (drawBottom)
middleScaleFactor.setWidth(bottomSideScale);
if (drawLeft)
middleScaleFactor.setHeight(leftSideScale);
else if (drawRight)
middleScaleFactor.setHeight(rightSideScale);
// For "stretch" rules, just override the scale factor and replace. We only had to do this for the
// center tile, since sides don't even use the scale factor unless they have a rule other than "stretch".
// The middle however can have "stretch" specified in one axis but not the other, so we have to
// correct the scale here.
if (hRule == StretchImageRule)
middleScaleFactor.setWidth(destinationWidth / sourceWidth);
if (vRule == StretchImageRule)
middleScaleFactor.setHeight(destinationHeight / sourceHeight);
graphicsContext->drawTiledImage(image.get(),
IntRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight),
IntRect(leftSlice, topSlice, sourceWidth, sourceHeight),
middleScaleFactor, (Image::TileRule)hRule, (Image::TileRule)vRule, CompositeSourceOver);
}
return true;
}
class BorderEdge {
public:
BorderEdge(int edgeWidth, const Color& edgeColor, EBorderStyle edgeStyle, bool edgeIsTransparent, bool edgeIsPresent = true)
......@@ -1353,9 +1180,6 @@ void RenderBoxModelObject::paintBorder(const PaintInfo& info, const LayoutRect&
BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
{
GraphicsContext* graphicsContext = info.context;
// border-image is not affected by border-radius.
if (paintNinePieceImage(graphicsContext, rect, style, style->borderImage()))
return;
BorderEdge edges[4];
getBorderEdgeInfo(edges, style, includeLogicalLeftEdge, includeLogicalRightEdge);
......@@ -2029,10 +1853,6 @@ bool RenderBoxModelObject::borderObscuresBackground() const
if (!style()->hasBorder())
return false;
// Bail if we have any border-image for now. We could look at the image alpha to improve this.
if (style()->borderImage().image())
return false;
BorderEdge edges[4];
getBorderEdgeInfo(edges, style());
......
......@@ -147,7 +147,6 @@ public:
LayoutUnit containingBlockLogicalWidthForContent() const;
void paintBorder(const PaintInfo&, const LayoutRect&, const RenderStyle*, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
bool paintNinePieceImage(GraphicsContext*, const LayoutRect&, const RenderStyle*, const NinePieceImage&);
void paintBoxShadow(const PaintInfo&, const LayoutRect&, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance, InlineFlowBox* = 0, const LayoutSize& = LayoutSize(), RenderObject* backgroundObject = 0, bool skipBaseColor = false);
......
......@@ -598,14 +598,6 @@ RenderBlock* RenderObject::containingBlock() const
return toRenderBlock(o);
}
bool RenderObject::canRenderBorderImage() const
{
ASSERT(style()->hasBorder());
StyleImage* borderImage = style()->borderImage().image();
return borderImage && borderImage->canRender(*this) && borderImage->isLoaded();
}
void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, int x1, int y1, int x2, int y2,
BoxSide side, Color color, EBorderStyle style,
int adjacentWidth1, int adjacentWidth2, bool antialias)
......@@ -1188,7 +1180,6 @@ void RenderObject::setStyle(PassRefPtr<RenderStyle> style)
setStyleInternal(style);
updateFillImages(oldStyle ? &oldStyle->backgroundLayers() : 0, m_style->backgroundLayers());
updateImage(oldStyle ? oldStyle->borderImage().image() : 0, m_style->borderImage().image());
bool doesNotNeedLayout = !m_parent || isText();
......@@ -1596,9 +1587,6 @@ void RenderObject::postDestroy()
if (StyleImage* backgroundImage = bgLayer->image())
backgroundImage->removeClient(this);
}
if (StyleImage* borderImage = m_style->borderImage().image())
borderImage->removeClient(this);
}
delete this;
}
......
......@@ -297,7 +297,6 @@ public:
bool hasLayer() const { return m_bitfields.hasLayer(); }
bool hasBoxDecorationBackground() const { return m_bitfields.hasBoxDecorationBackground(); }
bool canRenderBorderImage() const;
bool hasBackground() const { return style()->hasBackground(); }
bool hasEntirelyFixedBackground() const;
......
......@@ -26,7 +26,6 @@
#define SKY_ENGINE_CORE_RENDERING_STYLE_BORDERDATA_H_
#include "sky/engine/core/rendering/style/BorderValue.h"
#include "sky/engine/core/rendering/style/NinePieceImage.h"
#include "sky/engine/platform/LengthSize.h"
#include "sky/engine/platform/geometry/IntRect.h"
......@@ -43,8 +42,7 @@ public:
}
bool hasBorder() const
{
bool haveImage = m_image.hasImage();
return m_left.nonZero(!haveImage) || m_right.nonZero(!haveImage) || m_top.nonZero(!haveImage) || m_bottom.nonZero(!haveImage);
return m_left.nonZero() || m_right.nonZero() || m_top.nonZero() || m_bottom.nonZero();
}
bool hasBorderRadius() const
......@@ -62,35 +60,35 @@ public:
unsigned borderLeftWidth() const
{
if (!m_image.hasImage() && (m_left.style() == BNONE || m_left.style() == BHIDDEN))
if ((m_left.style() == BNONE || m_left.style() == BHIDDEN))
return 0;
return m_left.width();
}
unsigned borderRightWidth() const
{
if (!m_image.hasImage() && (m_right.style() == BNONE || m_right.style() == BHIDDEN))
if ((m_right.style() == BNONE || m_right.style() == BHIDDEN))
return 0;
return m_right.width();
}
unsigned borderTopWidth() const
{
if (!m_image.hasImage() && (m_top.style() == BNONE || m_top.style() == BHIDDEN))
if ((m_top.style() == BNONE || m_top.style() == BHIDDEN))
return 0;
return m_top.width();
}
unsigned borderBottomWidth() const
{
if (!m_image.hasImage() && (m_bottom.style() == BNONE || m_bottom.style() == BHIDDEN))
if ((m_bottom.style() == BNONE || m_bottom.style() == BHIDDEN))
return 0;
return m_bottom.width();
}
bool operator==(const BorderData& o) const
{
return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top && m_bottom == o.m_bottom && m_image == o.m_image
return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top && m_bottom == o.m_bottom
&& m_topLeft == o.m_topLeft && m_topRight == o.m_topRight && m_bottomLeft == o.m_bottomLeft && m_bottomRight == o.m_bottomRight;
}
......@@ -100,7 +98,6 @@ public:
&& m_right.visuallyEqual(o.m_right)
&& m_top.visuallyEqual(o.m_top)
&& m_bottom.visuallyEqual(o.m_bottom)
&& m_image == o.m_image
&& m_topLeft == o.m_topLeft
&& m_topRight == o.m_topRight
&& m_bottomLeft == o.m_bottomLeft
......@@ -117,8 +114,6 @@ public:
const BorderValue& top() const { return m_top; }
const BorderValue& bottom() const { return m_bottom; }
const NinePieceImage& image() const { return m_image; }
const LengthSize& topLeft() const { return m_topLeft; }
const LengthSize& topRight() const { return m_topRight; }
const LengthSize& bottomLeft() const { return m_bottomLeft; }
......@@ -130,8 +125,6 @@ private:
BorderValue m_top;
BorderValue m_bottom;
NinePieceImage m_image;
LengthSize m_topLeft;
LengthSize m_topRight;
LengthSize m_bottomLeft;
......
/*
* Copyright (c) 2013, Opera Software ASA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Opera Software ASA nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SKY_ENGINE_CORE_RENDERING_STYLE_BORDERIMAGELENGTH_H_
#define SKY_ENGINE_CORE_RENDERING_STYLE_BORDERIMAGELENGTH_H_
#include "sky/engine/platform/Length.h"
namespace blink {
// Represents an individual computed border image width or outset.
//
// http://www.w3.org/TR/css3-background/#border-image-width
// http://www.w3.org/TR/css3-background/#border-image-outset
class BorderImageLength {
public:
BorderImageLength(double number)
: m_number(number)
, m_type(NumberType)
{
}
BorderImageLength(const Length& length)
: m_length(length)
, m_number(0)
, m_type(LengthType)
{
}
bool isNumber() const { return m_type == NumberType; }
bool isLength() const { return m_type == LengthType; }
const Length& length() const { ASSERT(isLength()); return m_length; }
Length& length() { ASSERT(isLength()); return m_length; }
double number() const { ASSERT(isNumber()); return m_number; }
bool operator==(const BorderImageLength& other) const
{
return m_type == other.m_type && m_length == other.m_length && m_number == other.m_number;
}
bool isZero() const
{
return (isLength() && m_length.isZero()) || (isNumber() && m_number);
}
private:
// Ideally we would put the 2 following fields in a union, but Length has a constructor,
// a destructor and a copy assignment which isn't allowed.
Length m_length;
double m_number;
enum {
LengthType,
NumberType
} m_type;
};
} // namespace blink
#endif // SKY_ENGINE_CORE_RENDERING_STYLE_BORDERIMAGELENGTH_H_
/*
* Copyright (c) 2013, Opera Software ASA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Opera Software ASA nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SKY_ENGINE_CORE_RENDERING_STYLE_BORDERIMAGELENGTHBOX_H_
#define SKY_ENGINE_CORE_RENDERING_STYLE_BORDERIMAGELENGTHBOX_H_
#include "sky/engine/core/rendering/style/BorderImageLength.h"
namespace blink {
// Represents a computed border image width or outset.
//
// http://www.w3.org/TR/css3-background/#border-image-width
// http://www.w3.org/TR/css3-background/#border-image-outset
class BorderImageLengthBox {
public:
BorderImageLengthBox(Length length)
: m_left(length)
, m_right(length)
, m_top(length)
, m_bottom(length)
{
}
BorderImageLengthBox(double number)
: m_left(number)
, m_right(number)
, m_top(number)
, m_bottom(number)
{
}
BorderImageLengthBox(const BorderImageLength& top, const BorderImageLength& right,
const BorderImageLength& bottom, const BorderImageLength& left)
: m_left(left)
, m_right(right)
, m_top(top)
, m_bottom(bottom)
{
}
const BorderImageLength& left() const { return m_left; }
const BorderImageLength& right() const { return m_right; }
const BorderImageLength& top() const { return m_top; }
const BorderImageLength& bottom() const { return m_bottom; }
bool operator==(const BorderImageLengthBox& other) const
{
return m_left == other.m_left && m_right == other.m_right
&& m_top == other.m_top && m_bottom == other.m_bottom;
}
bool operator!=(const BorderImageLengthBox& other) const
{
return !(*this == other);
}
bool nonZero() const
{
return !(m_left.isZero() && m_right.isZero() && m_top.isZero() && m_bottom.isZero());
}
private:
BorderImageLength m_left;
BorderImageLength m_right;
BorderImageLength m_top;
BorderImageLength m_bottom;
};
} // namespace blink
#endif // SKY_ENGINE_CORE_RENDERING_STYLE_BORDERIMAGELENGTHBOX_H_
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "sky/engine/core/rendering/style/NinePieceImage.h"
#include "sky/engine/core/rendering/style/DataEquivalency.h"
namespace blink {
static DataRef<NinePieceImageData>& defaultData()
{
static DataRef<NinePieceImageData>* data = new DataRef<NinePieceImageData>;
if (!data->get())
data->init();
return *data;
}
NinePieceImage::NinePieceImage()
: m_data(defaultData())
{
}
NinePieceImage::NinePieceImage(PassRefPtr<StyleImage> image, LengthBox imageSlices, bool fill, const BorderImageLengthBox& borderSlices, const BorderImageLengthBox& outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule)
{
m_data.init();
m_data.access()->image = image;
m_data.access()->imageSlices = imageSlices;
m_data.access()->borderSlices = borderSlices;
m_data.access()->outset = outset;
m_data.access()->fill = fill;
m_data.access()->horizontalRule = horizontalRule;
m_data.access()->verticalRule = verticalRule;
}
NinePieceImageData::NinePieceImageData()
: fill(false)
, horizontalRule(StretchImageRule)
, verticalRule(StretchImageRule)
, image(nullptr)
, imageSlices(Length(100, Percent), Length(100, Percent), Length(100, Percent), Length(100, Percent))
, borderSlices(1.0, 1.0, 1.0, 1.0)
, outset(Length(0, Fixed), Length(0, Fixed), Length(0, Fixed), Length(0, Fixed))
{
}
NinePieceImageData::NinePieceImageData(const NinePieceImageData& other)
: RefCounted<NinePieceImageData>()
, fill(other.fill)
, horizontalRule(other.horizontalRule)
, verticalRule(other.verticalRule)
, image(other.image)
, imageSlices(other.imageSlices)
, borderSlices(other.borderSlices)
, outset(other.outset)
{
}
bool NinePieceImageData::operator==(const NinePieceImageData& other) const
{
return dataEquivalent(image, other.image)
&& imageSlices == other.imageSlices
&& fill == other.fill
&& borderSlices == other.borderSlices
&& outset == other.outset
&& horizontalRule == other.horizontalRule
&& verticalRule == other.verticalRule;
}
}
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef SKY_ENGINE_CORE_RENDERING_STYLE_NINEPIECEIMAGE_H_
#define SKY_ENGINE_CORE_RENDERING_STYLE_NINEPIECEIMAGE_H_
#include "sky/engine/core/rendering/style/BorderImageLengthBox.h"
#include "sky/engine/core/rendering/style/DataRef.h"
#include "sky/engine/core/rendering/style/StyleImage.h"
#include "sky/engine/platform/LayoutUnit.h"
#include "sky/engine/platform/LengthBox.h"
namespace blink {
enum ENinePieceImageRule {
StretchImageRule, RoundImageRule, SpaceImageRule, RepeatImageRule
};
class NinePieceImageData : public RefCounted<NinePieceImageData> {
public:
static PassRefPtr<NinePieceImageData> create() { return adoptRef(new NinePieceImageData); }
PassRefPtr<NinePieceImageData> copy() const { return adoptRef(new NinePieceImageData(*this)); }
bool operator==(const NinePieceImageData&) const;
bool operator!=(const NinePieceImageData& o) const { return !(*this == o); }
bool fill : 1;
unsigned horizontalRule : 2; // ENinePieceImageRule
unsigned verticalRule : 2; // ENinePieceImageRule
RefPtr<StyleImage> image;
LengthBox imageSlices;
BorderImageLengthBox borderSlices;
BorderImageLengthBox outset;
private:
NinePieceImageData();
NinePieceImageData(const NinePieceImageData&);
};
class NinePieceImage {
public:
NinePieceImage();
NinePieceImage(PassRefPtr<StyleImage>, LengthBox imageSlices, bool fill, const BorderImageLengthBox& borderSlices,
const BorderImageLengthBox& outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule);
bool operator==(const NinePieceImage& other) const { return m_data == other.m_data; }
bool operator!=(const NinePieceImage& other) const { return m_data != other.m_data; }
bool hasImage() const { return m_data->image; }
StyleImage* image() const { return m_data->image.get(); }
void setImage(PassRefPtr<StyleImage> image) { m_data.access()->image = image; }
const LengthBox& imageSlices() const { return m_data->imageSlices; }
void setImageSlices(const LengthBox& slices) { m_data.access()->imageSlices = slices; }
bool fill() const { return m_data->fill; }
void setFill(bool fill) { m_data.access()->fill = fill; }
const BorderImageLengthBox& borderSlices() const { return m_data->borderSlices; }
void setBorderSlices(const BorderImageLengthBox& slices) { m_data.access()->borderSlices = slices; }
const BorderImageLengthBox& outset() const { return m_data->outset; }
void setOutset(const BorderImageLengthBox& outset) { m_data.access()->outset = outset; }
ENinePieceImageRule horizontalRule() const { return static_cast<ENinePieceImageRule>(m_data->horizontalRule); }
void setHorizontalRule(ENinePieceImageRule rule) { m_data.access()->horizontalRule = rule; }
ENinePieceImageRule verticalRule() const { return static_cast<ENinePieceImageRule>(m_data->verticalRule); }
void setVerticalRule(ENinePieceImageRule rule) { m_data.access()->verticalRule = rule; }
void copyImageSlicesFrom(const NinePieceImage& other)
{
m_data.access()->imageSlices = other.m_data->imageSlices;
m_data.access()->fill = other.m_data->fill;
}
void copyBorderSlicesFrom(const NinePieceImage& other)
{
m_data.access()->borderSlices = other.m_data->borderSlices;
}
void copyOutsetFrom(const NinePieceImage& other)
{
m_data.access()->outset = other.m_data->outset;
}
void copyRepeatFrom(const NinePieceImage& other)
{
m_data.access()->horizontalRule = other.m_data->horizontalRule;
m_data.access()->verticalRule = other.m_data->verticalRule;
}
static LayoutUnit computeOutset(const BorderImageLength& outsetSide, LayoutUnit borderSide)
{
if (outsetSide.isNumber())
return outsetSide.number() * borderSide;
return outsetSide.length().value();
}
private:
DataRef<NinePieceImageData> m_data;
};
} // namespace blink
#endif // SKY_ENGINE_CORE_RENDERING_STYLE_NINEPIECEIMAGE_H_
......@@ -1057,42 +1057,6 @@ Color RenderStyle::initialTapHighlightColor()
return RenderTheme::tapHighlightColor();
}
LayoutBoxExtent RenderStyle::imageOutsets(const NinePieceImage& image) const
{
return LayoutBoxExtent(NinePieceImage::computeOutset(image.outset().top(), borderTopWidth()),
NinePieceImage::computeOutset(image.outset().right(), borderRightWidth()),
NinePieceImage::computeOutset(image.outset().bottom(), borderBottomWidth()),
NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth()));
}
void RenderStyle::setBorderImageSource(PassRefPtr<StyleImage> image)
{
if (surround->border.m_image.image() == image.get())
return;
surround.access()->border.m_image.setImage(image);
}
void RenderStyle::setBorderImageSlices(const LengthBox& slices)
{
if (surround->border.m_image.imageSlices() == slices)
return;
surround.access()->border.m_image.setImageSlices(slices);
}
void RenderStyle::setBorderImageWidth(const BorderImageLengthBox& slices)
{
if (surround->border.m_image.borderSlices() == slices)
return;
surround.access()->border.m_image.setBorderSlices(slices);
}
void RenderStyle::setBorderImageOutset(const BorderImageLengthBox& outset)
{
if (surround->border.m_image.outset() == outset)
return;
surround.access()->border.m_image.setOutset(outset);
}
float calcBorderRadiiConstraintScaleFor(const FloatRect& rect, const FloatRoundedRect::Radii& radii)
{
// Constrain corner radii using CSS3 rules:
......
......@@ -31,7 +31,6 @@
#include "sky/engine/core/rendering/style/BorderValue.h"
#include "sky/engine/core/rendering/style/CounterDirectives.h"
#include "sky/engine/core/rendering/style/DataRef.h"
#include "sky/engine/core/rendering/style/NinePieceImage.h"
#include "sky/engine/core/rendering/style/OutlineValue.h"
#include "sky/engine/core/rendering/style/RenderStyleConstants.h"
#include "sky/engine/core/rendering/style/ShapeValue.h"
......@@ -299,16 +298,6 @@ public:
return hasBackgroundImage();
}
LayoutBoxExtent imageOutsets(const NinePieceImage&) const;
bool hasBorderImageOutsets() const
{
return borderImage().hasImage() && borderImage().outset().nonZero();
}
LayoutBoxExtent borderImageOutsets() const
{
return imageOutsets(borderImage());
}
FilterOutsets filterOutsets() const { return hasFilter() ? filter().outsets() : FilterOutsets(); }
Order rtlOrdering() const { return static_cast<Order>(inherited_flags.m_rtlOrdering); }
......@@ -365,12 +354,6 @@ public:
const BorderValue& borderStart() const;
const BorderValue& borderEnd() const;
const NinePieceImage& borderImage() const { return surround->border.image(); }
StyleImage* borderImageSource() const { return surround->border.image().image(); }
const LengthBox& borderImageSlices() const { return surround->border.image().imageSlices(); }
const BorderImageLengthBox& borderImageWidth() const { return surround->border.image().borderSlices(); }
const BorderImageLengthBox& borderImageOutset() const { return surround->border.image().outset(); }
const LengthSize& borderTopLeftRadius() const { return surround->border.topLeft(); }
const LengthSize& borderTopRightRadius() const { return surround->border.topRight(); }
const LengthSize& borderBottomLeftRadius() const { return surround->border.bottomLeft(); }
......@@ -608,7 +591,7 @@ public:
// FIXME: reflections should belong to this helper function but they are currently handled
// through their self-painting layers. So the rendering code doesn't account for them.
bool hasVisualOverflowingEffect() const { return boxShadow() || hasBorderImageOutsets() || hasOutline(); }
bool hasVisualOverflowingEffect() const { return boxShadow() || hasOutline(); }
EBoxSizing boxSizing() const { return m_box->boxSizing(); }
EUserModify userModify() const { return static_cast<EUserModify>(rareInheritedData->userModify); }
......@@ -709,7 +692,6 @@ public:
void resetBorder()
{
resetBorderImage();
resetBorderTop();
resetBorderRight();
resetBorderBottom();
......@@ -723,7 +705,6 @@ public:
void resetBorderRight() { SET_VAR(surround, border.m_right, BorderValue()); }
void resetBorderBottom() { SET_VAR(surround, border.m_bottom, BorderValue()); }
void resetBorderLeft() { SET_VAR(surround, border.m_left, BorderValue()); }
void resetBorderImage() { SET_VAR(surround, border.m_image, NinePieceImage()); }
void resetBorderTopLeftRadius() { SET_VAR(surround, border.m_topLeft, initialBorderRadius()); }
void resetBorderTopRightRadius() { SET_VAR(surround, border.m_topRight, initialBorderRadius()); }
void resetBorderBottomLeftRadius() { SET_VAR(surround, border.m_bottomLeft, initialBorderRadius()); }
......@@ -736,12 +717,6 @@ public:
void setBackgroundSize(EFillSizeType b) { SET_VAR(m_background, m_background.m_sizeType, b); }
void setBackgroundSizeLength(const LengthSize& s) { SET_VAR(m_background, m_background.m_sizeLength, s); }
void setBorderImage(const NinePieceImage& b) { SET_VAR(surround, border.m_image, b); }
void setBorderImageSource(PassRefPtr<StyleImage>);
void setBorderImageSlices(const LengthBox&);
void setBorderImageWidth(const BorderImageLengthBox&);
void setBorderImageOutset(const BorderImageLengthBox&);
void setBorderTopLeftRadius(const LengthSize& s) { SET_VAR(surround, border.m_topLeft, s); }
void setBorderTopRightRadius(const LengthSize& s) { SET_VAR(surround, border.m_topRight, s); }
void setBorderBottomLeftRadius(const LengthSize& s) { SET_VAR(surround, border.m_bottomLeft, s); }
......@@ -987,7 +962,6 @@ public:
// Initial values for all the properties
static EBorderStyle initialBorderStyle() { return BNONE; }
static OutlineIsAuto initialOutlineStyleIsAuto() { return AUTO_OFF; }
static NinePieceImage initialNinePieceImage() { return NinePieceImage(); }
static LengthSize initialBorderRadius() { return LengthSize(Length(0, Fixed), Length(0, Fixed)); }
static LengthBox initialClip() { return LengthBox(); }
static TextDirection initialDirection() { return LTR; }
......@@ -1090,7 +1064,6 @@ public:
static ImageResolutionSource initialImageResolutionSource() { return ImageResolutionSpecified; }
static ImageResolutionSnap initialImageResolutionSnap() { return ImageResolutionNoSnap; }
static float initialImageResolution() { return 1; }
static StyleImage* initialBorderImageSource() { return 0; }
static TouchAction initialTouchAction() { return TouchActionAuto; }
static TouchActionDelay initialTouchActionDelay() { return TouchActionDelayScript; }
static ShadowList* initialBoxShadow() { return 0; }
......
......@@ -31,7 +31,6 @@
#include "sky/engine/core/rendering/style/CounterDirectives.h"
#include "sky/engine/core/rendering/style/DataRef.h"
#include "sky/engine/core/rendering/style/FillLayer.h"
#include "sky/engine/core/rendering/style/NinePieceImage.h"
#include "sky/engine/core/rendering/style/RenderStyleConstants.h"
#include "sky/engine/core/rendering/style/ShapeValue.h"
#include "sky/engine/platform/LengthPoint.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册