From cad810f21b803229eb11403f9209855525a25d57 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Fri, 6 May 2011 11:45:16 +0100 Subject: Merge WebKit at r75315: Initial merge by git. Change-Id: I570314b346ce101c935ed22a626b48c2af266b84 --- Source/WebCore/rendering/style/BorderData.h | 129 ++ Source/WebCore/rendering/style/BorderValue.h | 79 ++ .../WebCore/rendering/style/CollapsedBorderValue.h | 72 + Source/WebCore/rendering/style/ContentData.cpp | 79 ++ Source/WebCore/rendering/style/ContentData.h | 112 ++ Source/WebCore/rendering/style/CounterContent.h | 62 + .../WebCore/rendering/style/CounterDirectives.cpp | 38 + Source/WebCore/rendering/style/CounterDirectives.h | 54 + Source/WebCore/rendering/style/CursorData.h | 63 + Source/WebCore/rendering/style/CursorList.h | 62 + Source/WebCore/rendering/style/DataRef.h | 71 + Source/WebCore/rendering/style/FillLayer.cpp | 284 ++++ Source/WebCore/rendering/style/FillLayer.h | 201 +++ Source/WebCore/rendering/style/KeyframeList.cpp | 97 ++ Source/WebCore/rendering/style/KeyframeList.h | 99 ++ Source/WebCore/rendering/style/LineClampValue.h | 69 + Source/WebCore/rendering/style/NinePieceImage.cpp | 35 + Source/WebCore/rendering/style/NinePieceImage.h | 78 ++ Source/WebCore/rendering/style/OutlineValue.h | 61 + Source/WebCore/rendering/style/RenderStyle.cpp | 1473 ++++++++++++++++++++ Source/WebCore/rendering/style/RenderStyle.h | 1409 +++++++++++++++++++ .../WebCore/rendering/style/RenderStyleConstants.h | 434 ++++++ Source/WebCore/rendering/style/SVGRenderStyle.cpp | 220 +++ Source/WebCore/rendering/style/SVGRenderStyle.h | 431 ++++++ .../WebCore/rendering/style/SVGRenderStyleDefs.cpp | 227 +++ .../WebCore/rendering/style/SVGRenderStyleDefs.h | 266 ++++ Source/WebCore/rendering/style/ShadowData.cpp | 100 ++ Source/WebCore/rendering/style/ShadowData.h | 101 ++ Source/WebCore/rendering/style/StyleAllInOne.cpp | 49 + .../rendering/style/StyleBackgroundData.cpp | 49 + .../WebCore/rendering/style/StyleBackgroundData.h | 65 + Source/WebCore/rendering/style/StyleBoxData.cpp | 68 + Source/WebCore/rendering/style/StyleBoxData.h | 86 ++ .../WebCore/rendering/style/StyleCachedImage.cpp | 92 ++ Source/WebCore/rendering/style/StyleCachedImage.h | 67 + .../WebCore/rendering/style/StyleDashboardRegion.h | 61 + .../rendering/style/StyleFlexibleBoxData.cpp | 59 + .../WebCore/rendering/style/StyleFlexibleBoxData.h | 60 + .../rendering/style/StyleGeneratedImage.cpp | 80 ++ .../WebCore/rendering/style/StyleGeneratedImage.h | 69 + Source/WebCore/rendering/style/StyleImage.h | 84 ++ .../WebCore/rendering/style/StyleInheritedData.cpp | 65 + .../WebCore/rendering/style/StyleInheritedData.h | 69 + .../WebCore/rendering/style/StyleMarqueeData.cpp | 54 + Source/WebCore/rendering/style/StyleMarqueeData.h | 61 + .../WebCore/rendering/style/StyleMultiColData.cpp | 67 + Source/WebCore/rendering/style/StyleMultiColData.h | 76 + Source/WebCore/rendering/style/StylePendingImage.h | 71 + .../rendering/style/StyleRareInheritedData.cpp | 187 +++ .../rendering/style/StyleRareInheritedData.h | 114 ++ .../rendering/style/StyleRareNonInheritedData.cpp | 203 +++ .../rendering/style/StyleRareNonInheritedData.h | 140 ++ Source/WebCore/rendering/style/StyleReflection.h | 70 + .../WebCore/rendering/style/StyleSurroundData.cpp | 47 + Source/WebCore/rendering/style/StyleSurroundData.h | 58 + .../WebCore/rendering/style/StyleTransformData.cpp | 51 + .../WebCore/rendering/style/StyleTransformData.h | 58 + Source/WebCore/rendering/style/StyleVisualData.cpp | 49 + Source/WebCore/rendering/style/StyleVisualData.h | 62 + 59 files changed, 8797 insertions(+) create mode 100644 Source/WebCore/rendering/style/BorderData.h create mode 100644 Source/WebCore/rendering/style/BorderValue.h create mode 100644 Source/WebCore/rendering/style/CollapsedBorderValue.h create mode 100644 Source/WebCore/rendering/style/ContentData.cpp create mode 100644 Source/WebCore/rendering/style/ContentData.h create mode 100644 Source/WebCore/rendering/style/CounterContent.h create mode 100644 Source/WebCore/rendering/style/CounterDirectives.cpp create mode 100644 Source/WebCore/rendering/style/CounterDirectives.h create mode 100644 Source/WebCore/rendering/style/CursorData.h create mode 100644 Source/WebCore/rendering/style/CursorList.h create mode 100644 Source/WebCore/rendering/style/DataRef.h create mode 100644 Source/WebCore/rendering/style/FillLayer.cpp create mode 100644 Source/WebCore/rendering/style/FillLayer.h create mode 100644 Source/WebCore/rendering/style/KeyframeList.cpp create mode 100644 Source/WebCore/rendering/style/KeyframeList.h create mode 100644 Source/WebCore/rendering/style/LineClampValue.h create mode 100644 Source/WebCore/rendering/style/NinePieceImage.cpp create mode 100644 Source/WebCore/rendering/style/NinePieceImage.h create mode 100644 Source/WebCore/rendering/style/OutlineValue.h create mode 100644 Source/WebCore/rendering/style/RenderStyle.cpp create mode 100644 Source/WebCore/rendering/style/RenderStyle.h create mode 100644 Source/WebCore/rendering/style/RenderStyleConstants.h create mode 100644 Source/WebCore/rendering/style/SVGRenderStyle.cpp create mode 100644 Source/WebCore/rendering/style/SVGRenderStyle.h create mode 100644 Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp create mode 100644 Source/WebCore/rendering/style/SVGRenderStyleDefs.h create mode 100644 Source/WebCore/rendering/style/ShadowData.cpp create mode 100644 Source/WebCore/rendering/style/ShadowData.h create mode 100644 Source/WebCore/rendering/style/StyleAllInOne.cpp create mode 100644 Source/WebCore/rendering/style/StyleBackgroundData.cpp create mode 100644 Source/WebCore/rendering/style/StyleBackgroundData.h create mode 100644 Source/WebCore/rendering/style/StyleBoxData.cpp create mode 100644 Source/WebCore/rendering/style/StyleBoxData.h create mode 100644 Source/WebCore/rendering/style/StyleCachedImage.cpp create mode 100644 Source/WebCore/rendering/style/StyleCachedImage.h create mode 100644 Source/WebCore/rendering/style/StyleDashboardRegion.h create mode 100644 Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp create mode 100644 Source/WebCore/rendering/style/StyleFlexibleBoxData.h create mode 100644 Source/WebCore/rendering/style/StyleGeneratedImage.cpp create mode 100644 Source/WebCore/rendering/style/StyleGeneratedImage.h create mode 100644 Source/WebCore/rendering/style/StyleImage.h create mode 100644 Source/WebCore/rendering/style/StyleInheritedData.cpp create mode 100644 Source/WebCore/rendering/style/StyleInheritedData.h create mode 100644 Source/WebCore/rendering/style/StyleMarqueeData.cpp create mode 100644 Source/WebCore/rendering/style/StyleMarqueeData.h create mode 100644 Source/WebCore/rendering/style/StyleMultiColData.cpp create mode 100644 Source/WebCore/rendering/style/StyleMultiColData.h create mode 100644 Source/WebCore/rendering/style/StylePendingImage.h create mode 100644 Source/WebCore/rendering/style/StyleRareInheritedData.cpp create mode 100644 Source/WebCore/rendering/style/StyleRareInheritedData.h create mode 100644 Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp create mode 100644 Source/WebCore/rendering/style/StyleRareNonInheritedData.h create mode 100644 Source/WebCore/rendering/style/StyleReflection.h create mode 100644 Source/WebCore/rendering/style/StyleSurroundData.cpp create mode 100644 Source/WebCore/rendering/style/StyleSurroundData.h create mode 100644 Source/WebCore/rendering/style/StyleTransformData.cpp create mode 100644 Source/WebCore/rendering/style/StyleTransformData.h create mode 100644 Source/WebCore/rendering/style/StyleVisualData.cpp create mode 100644 Source/WebCore/rendering/style/StyleVisualData.h (limited to 'Source/WebCore/rendering/style') diff --git a/Source/WebCore/rendering/style/BorderData.h b/Source/WebCore/rendering/style/BorderData.h new file mode 100644 index 0000000..03635d9 --- /dev/null +++ b/Source/WebCore/rendering/style/BorderData.h @@ -0,0 +1,129 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 BorderData_h +#define BorderData_h + +#include "BorderValue.h" +#include "LengthSize.h" +#include "NinePieceImage.h" + +namespace WebCore { + +class BorderData { +friend class RenderStyle; +public: + BorderData() : m_topLeft(Length(0, Fixed), Length(0, Fixed)) + , m_topRight(Length(0, Fixed), Length(0, Fixed)) + , m_bottomLeft(Length(0, Fixed), Length(0, Fixed)) + , m_bottomRight(Length(0, Fixed), Length(0, Fixed)) + { + } + 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); + } + + bool hasBorderRadius() const + { + if (m_topLeft.width().rawValue() > 0) + return true; + if (m_topRight.width().rawValue() > 0) + return true; + if (m_bottomLeft.width().rawValue() > 0) + return true; + if (m_bottomRight.width().rawValue() > 0) + return true; + return false; + } + + unsigned short borderLeftWidth() const + { + if (!m_image.hasImage() && (m_left.style() == BNONE || m_left.style() == BHIDDEN)) + return 0; + return m_left.width(); + } + + unsigned short borderRightWidth() const + { + if (!m_image.hasImage() && (m_right.style() == BNONE || m_right.style() == BHIDDEN)) + return 0; + return m_right.width(); + } + + unsigned short borderTopWidth() const + { + if (!m_image.hasImage() && (m_top.style() == BNONE || m_top.style() == BHIDDEN)) + return 0; + return m_top.width(); + } + + unsigned short borderBottomWidth() const + { + if (!m_image.hasImage() && (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 + && m_topLeft == o.m_topLeft && m_topRight == o.m_topRight && m_bottomLeft == o.m_bottomLeft && m_bottomRight == o.m_bottomRight; + } + + bool operator!=(const BorderData& o) const + { + return !(*this == o); + } + + const BorderValue& left() const { return m_left; } + const BorderValue& right() const { return m_right; } + 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; } + const LengthSize& bottomRight() const { return m_bottomRight; } + +private: + BorderValue m_left; + BorderValue m_right; + BorderValue m_top; + BorderValue m_bottom; + + NinePieceImage m_image; + + LengthSize m_topLeft; + LengthSize m_topRight; + LengthSize m_bottomLeft; + LengthSize m_bottomRight; +}; + +} // namespace WebCore + +#endif // BorderData_h diff --git a/Source/WebCore/rendering/style/BorderValue.h b/Source/WebCore/rendering/style/BorderValue.h new file mode 100644 index 0000000..3e6fd5d --- /dev/null +++ b/Source/WebCore/rendering/style/BorderValue.h @@ -0,0 +1,79 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 BorderValue_h +#define BorderValue_h + +#include "Color.h" +#include "RenderStyleConstants.h" + +namespace WebCore { + +class BorderValue { +friend class RenderStyle; +public: + BorderValue() + : m_width(3) + , m_style(BNONE) + { + } + + bool nonZero(bool checkStyle = true) const + { + return width() && (!checkStyle || m_style != BNONE); + } + + bool isTransparent() const + { + return m_color.isValid() && !m_color.alpha(); + } + + bool isVisible(bool checkStyle = true) const + { + return nonZero(checkStyle) && !isTransparent() && (!checkStyle || m_style != BHIDDEN); + } + + bool operator==(const BorderValue& o) const + { + return m_width == o.m_width && m_style == o.m_style && m_color == o.m_color; + } + + bool operator!=(const BorderValue& o) const + { + return !(*this == o); + } + + const Color& color() const { return m_color; } + unsigned short width() const { return m_width; } + EBorderStyle style() const { return static_cast(m_style); } + +protected: + Color m_color; + unsigned m_width : 12; + unsigned m_style : 4; // EBorderStyle +}; + +} // namespace WebCore + +#endif // BorderValue_h diff --git a/Source/WebCore/rendering/style/CollapsedBorderValue.h b/Source/WebCore/rendering/style/CollapsedBorderValue.h new file mode 100644 index 0000000..6207231 --- /dev/null +++ b/Source/WebCore/rendering/style/CollapsedBorderValue.h @@ -0,0 +1,72 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 CollapsedBorderValue_h +#define CollapsedBorderValue_h + +#include "BorderValue.h" + +namespace WebCore { + +class CollapsedBorderValue { +friend class RenderStyle; +public: + CollapsedBorderValue() + : m_border(0) + , m_precedence(BOFF) + { + } + + CollapsedBorderValue(const BorderValue* b, Color c, EBorderPrecedence p) + : m_border(b) + , m_borderColor(c) + , m_precedence(p) + { + } + + int width() const { return m_border && m_border->nonZero() ? m_border->width() : 0; } + EBorderStyle style() const { return m_border ? m_border->style() : BHIDDEN; } + bool exists() const { return m_border; } + const Color& color() const { return m_borderColor; } + bool isTransparent() const { return m_border ? m_border->isTransparent() : true; } + EBorderPrecedence precedence() const { return m_precedence; } + + bool operator==(const CollapsedBorderValue& o) const + { + if (!m_border) + return !o.m_border; + if (!o.m_border) + return false; + return *m_border == *o.m_border && m_borderColor == o.m_borderColor && m_precedence == o.m_precedence; + } + +private: + const BorderValue* m_border; + Color m_borderColor; + EBorderPrecedence m_precedence; +}; + +} // namespace WebCore + +#endif // CollapsedBorderValue_h diff --git a/Source/WebCore/rendering/style/ContentData.cpp b/Source/WebCore/rendering/style/ContentData.cpp new file mode 100644 index 0000000..d150f77 --- /dev/null +++ b/Source/WebCore/rendering/style/ContentData.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 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 "config.h" +#include "ContentData.h" + +#include "StyleImage.h" +#include + +namespace WebCore { + +void ContentData::clear() +{ + deleteContent(); + + // Delete the singly-linked list without recursing. + for (OwnPtr next = m_next.release(); next; next = next->m_next.release()) { } +} + +// FIXME: Why isn't this just operator==? +// FIXME: This is not a good name for a boolean-returning function. +bool ContentData::dataEquivalent(const ContentData& other) const +{ + if (type() != other.type()) + return false; + + switch (type()) { + case CONTENT_NONE: + return true; + case CONTENT_TEXT: + return equal(text(), other.text()); + case CONTENT_OBJECT: + return StyleImage::imagesEquivalent(image(), other.image()); + case CONTENT_COUNTER: + return *counter() == *other.counter(); + } + + ASSERT_NOT_REACHED(); + return false; +} + +void ContentData::deleteContent() +{ + switch (m_type) { + case CONTENT_NONE: + break; + case CONTENT_OBJECT: + m_content.m_image->deref(); + break; + case CONTENT_TEXT: + m_content.m_text->deref(); + break; + case CONTENT_COUNTER: + delete m_content.m_counter; + break; + } + + m_type = CONTENT_NONE; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/ContentData.h b/Source/WebCore/rendering/style/ContentData.h new file mode 100644 index 0000000..4f964a2 --- /dev/null +++ b/Source/WebCore/rendering/style/ContentData.h @@ -0,0 +1,112 @@ +/* + * 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, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 ContentData_h +#define ContentData_h + +#include "CounterContent.h" +#include +#include + +namespace WebCore { + +class StyleImage; + +struct ContentData : Noncopyable { +public: + ContentData() + : m_type(CONTENT_NONE) + { + } + + ~ContentData() + { + clear(); + } + + void clear(); + + bool isCounter() const { return m_type == CONTENT_COUNTER; } + bool isImage() const { return m_type == CONTENT_OBJECT; } + bool isNone() const { return m_type == CONTENT_NONE; } + bool isText() const { return m_type == CONTENT_TEXT; } + + StyleContentType type() const { return m_type; } + + bool dataEquivalent(const ContentData&) const; + + StyleImage* image() const + { + ASSERT(isImage()); + return m_content.m_image; + } + void setImage(PassRefPtr image) + { + deleteContent(); + m_type = CONTENT_OBJECT; + m_content.m_image = image.leakRef(); + } + + StringImpl* text() const + { + ASSERT(isText()); + return m_content.m_text; + } + void setText(PassRefPtr text) + { + deleteContent(); + m_type = CONTENT_TEXT; + m_content.m_text = text.leakRef(); + } + + CounterContent* counter() const + { + ASSERT(isCounter()); + return m_content.m_counter; + } + void setCounter(PassOwnPtr counter) + { + deleteContent(); + m_type = CONTENT_COUNTER; + m_content.m_counter = counter.leakPtr(); + } + + ContentData* next() const { return m_next.get(); } + void setNext(PassOwnPtr next) { m_next = next; } + +private: + void deleteContent(); + + StyleContentType m_type; + union { + StyleImage* m_image; + StringImpl* m_text; + CounterContent* m_counter; + } m_content; + OwnPtr m_next; +}; + +} // namespace WebCore + +#endif // ContentData_h diff --git a/Source/WebCore/rendering/style/CounterContent.h b/Source/WebCore/rendering/style/CounterContent.h new file mode 100644 index 0000000..52757ad --- /dev/null +++ b/Source/WebCore/rendering/style/CounterContent.h @@ -0,0 +1,62 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 CounterContent_h +#define CounterContent_h + +#include "RenderStyleConstants.h" +#include + +namespace WebCore { + +class CounterContent : public FastAllocBase { +public: + CounterContent(const AtomicString& identifier, EListStyleType style, const AtomicString& separator) + : m_identifier(identifier) + , m_listStyle(style) + , m_separator(separator) + { + } + + const AtomicString& identifier() const { return m_identifier; } + EListStyleType listStyle() const { return m_listStyle; } + const AtomicString& separator() const { return m_separator; } + +private: + AtomicString m_identifier; + EListStyleType m_listStyle; + AtomicString m_separator; +}; + +static inline bool operator==(const CounterContent& a, const CounterContent& b) +{ + return a.identifier() == b.identifier() + && a.listStyle() == b.listStyle() + && a.separator() == b.separator(); +} + + +} // namespace WebCore + +#endif // CounterContent_h diff --git a/Source/WebCore/rendering/style/CounterDirectives.cpp b/Source/WebCore/rendering/style/CounterDirectives.cpp new file mode 100644 index 0000000..a0ff52f --- /dev/null +++ b/Source/WebCore/rendering/style/CounterDirectives.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "CounterDirectives.h" + +namespace WebCore { + +bool operator==(const CounterDirectives& a, const CounterDirectives& b) +{ + if (a.m_reset != b.m_reset || a.m_increment != b.m_increment) + return false; + if (a.m_reset && a.m_resetValue != b.m_resetValue) + return false; + if (a.m_increment && a.m_incrementValue != b.m_incrementValue) + return false; + return true; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/CounterDirectives.h b/Source/WebCore/rendering/style/CounterDirectives.h new file mode 100644 index 0000000..e54028e --- /dev/null +++ b/Source/WebCore/rendering/style/CounterDirectives.h @@ -0,0 +1,54 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 CounterDirectives_h +#define CounterDirectives_h + +#include +#include +#include + +namespace WebCore { + +struct CounterDirectives { + CounterDirectives() + : m_reset(false) + , m_increment(false) + { + } + + bool m_reset; + int m_resetValue; + bool m_increment; + int m_incrementValue; +}; + +bool operator==(const CounterDirectives&, const CounterDirectives&); +inline bool operator!=(const CounterDirectives& a, const CounterDirectives& b) { return !(a == b); } + +typedef HashMap, CounterDirectives> CounterDirectiveMap; + +} // namespace WebCore + +#endif // CounterDirectives_h diff --git a/Source/WebCore/rendering/style/CursorData.h b/Source/WebCore/rendering/style/CursorData.h new file mode 100644 index 0000000..6d0a273 --- /dev/null +++ b/Source/WebCore/rendering/style/CursorData.h @@ -0,0 +1,63 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 CursorData_h +#define CursorData_h + +#include "IntPoint.h" +#include "StyleImage.h" + +namespace WebCore { + +class CursorData { +public: + CursorData(PassRefPtr image, const IntPoint& hotSpot) + : m_image(image) + , m_hotSpot(hotSpot) + { + } + + bool operator==(const CursorData& o) const + { + return m_hotSpot == o.m_hotSpot && m_image == o.m_image; + } + + bool operator!=(const CursorData& o) const + { + return !(*this == o); + } + + StyleImage* image() const { return m_image.get(); } + void setImage(PassRefPtr image) { m_image = image; } + + const IntPoint& hotSpot() const { return m_hotSpot; } + +private: + RefPtr m_image; + IntPoint m_hotSpot; // for CSS3 support +}; + +} // namespace WebCore + +#endif // CursorData_h diff --git a/Source/WebCore/rendering/style/CursorList.h b/Source/WebCore/rendering/style/CursorList.h new file mode 100644 index 0000000..a1d1fe7 --- /dev/null +++ b/Source/WebCore/rendering/style/CursorList.h @@ -0,0 +1,62 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 CursorList_h +#define CursorList_h + +#include "CursorData.h" +#include +#include + +namespace WebCore { + +class CursorList : public RefCounted { +public: + static PassRefPtr create() + { + return adoptRef(new CursorList); + } + + const CursorData& operator[](int i) const { return m_vector[i]; } + CursorData& operator[](int i) { return m_vector[i]; } + const CursorData& at(size_t i) const { return m_vector.at(i); } + CursorData& at(size_t i) { return m_vector.at(i); } + + bool operator==(const CursorList& o) const { return m_vector == o.m_vector; } + bool operator!=(const CursorList& o) const { return m_vector != o.m_vector; } + + size_t size() const { return m_vector.size(); } + void append(const CursorData& cursorData) { m_vector.append(cursorData); } + +private: + CursorList() + { + } + + Vector m_vector; +}; + +} // namespace WebCore + +#endif // CursorList_h diff --git a/Source/WebCore/rendering/style/DataRef.h b/Source/WebCore/rendering/style/DataRef.h new file mode 100644 index 0000000..c8d8072 --- /dev/null +++ b/Source/WebCore/rendering/style/DataRef.h @@ -0,0 +1,71 @@ +/* + * 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, 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 DataRef_h +#define DataRef_h + +#include + +namespace WebCore { + +template class DataRef { +public: + const T* get() const { return m_data.get(); } + + const T& operator*() const { return *get(); } + const T* operator->() const { return get(); } + + T* access() + { + if (!m_data->hasOneRef()) + m_data = m_data->copy(); + return m_data.get(); + } + + void init() + { + ASSERT(!m_data); + m_data = T::create(); + } + + bool operator==(const DataRef& o) const + { + ASSERT(m_data); + ASSERT(o.m_data); + return m_data == o.m_data || *m_data == *o.m_data; + } + + bool operator!=(const DataRef& o) const + { + ASSERT(m_data); + ASSERT(o.m_data); + return m_data != o.m_data && *m_data != *o.m_data; + } + +private: + RefPtr m_data; +}; + +} // namespace WebCore + +#endif // DataRef_h diff --git a/Source/WebCore/rendering/style/FillLayer.cpp b/Source/WebCore/rendering/style/FillLayer.cpp new file mode 100644 index 0000000..59f3bb2 --- /dev/null +++ b/Source/WebCore/rendering/style/FillLayer.cpp @@ -0,0 +1,284 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "FillLayer.h" + +namespace WebCore { + +FillLayer::FillLayer(EFillLayerType type) + : m_next(0) + , m_image(FillLayer::initialFillImage(type)) + , m_xPosition(FillLayer::initialFillXPosition(type)) + , m_yPosition(FillLayer::initialFillYPosition(type)) + , m_attachment(FillLayer::initialFillAttachment(type)) + , m_clip(FillLayer::initialFillClip(type)) + , m_origin(FillLayer::initialFillOrigin(type)) + , m_repeatX(FillLayer::initialFillRepeatX(type)) + , m_repeatY(FillLayer::initialFillRepeatY(type)) + , m_composite(FillLayer::initialFillComposite(type)) + , m_sizeType(SizeNone) + , m_sizeLength(FillLayer::initialFillSizeLength(type)) + , m_imageSet(false) + , m_attachmentSet(false) + , m_clipSet(false) + , m_originSet(false) + , m_repeatXSet(false) + , m_repeatYSet(false) + , m_xPosSet(false) + , m_yPosSet(false) + , m_compositeSet(type == MaskFillLayer) + , m_type(type) +{ +} + +FillLayer::FillLayer(const FillLayer& o) + : m_next(o.m_next ? new FillLayer(*o.m_next) : 0) + , m_image(o.m_image) + , m_xPosition(o.m_xPosition) + , m_yPosition(o.m_yPosition) + , m_attachment(o.m_attachment) + , m_clip(o.m_clip) + , m_origin(o.m_origin) + , m_repeatX(o.m_repeatX) + , m_repeatY(o.m_repeatY) + , m_composite(o.m_composite) + , m_sizeType(o.m_sizeType) + , m_sizeLength(o.m_sizeLength) + , m_imageSet(o.m_imageSet) + , m_attachmentSet(o.m_attachmentSet) + , m_clipSet(o.m_clipSet) + , m_originSet(o.m_originSet) + , m_repeatXSet(o.m_repeatXSet) + , m_repeatYSet(o.m_repeatYSet) + , m_xPosSet(o.m_xPosSet) + , m_yPosSet(o.m_yPosSet) + , m_compositeSet(o.m_compositeSet) + , m_type(o.m_type) +{ +} + +FillLayer::~FillLayer() +{ + delete m_next; +} + +FillLayer& FillLayer::operator=(const FillLayer& o) +{ + if (m_next != o.m_next) { + delete m_next; + m_next = o.m_next ? new FillLayer(*o.m_next) : 0; + } + + m_image = o.m_image; + m_xPosition = o.m_xPosition; + m_yPosition = o.m_yPosition; + m_attachment = o.m_attachment; + m_clip = o.m_clip; + m_composite = o.m_composite; + m_origin = o.m_origin; + m_repeatX = o.m_repeatX; + m_repeatY = o.m_repeatY; + m_sizeType = o.m_sizeType; + m_sizeLength = o.m_sizeLength; + + m_imageSet = o.m_imageSet; + m_attachmentSet = o.m_attachmentSet; + m_clipSet = o.m_clipSet; + m_compositeSet = o.m_compositeSet; + m_originSet = o.m_originSet; + m_repeatXSet = o.m_repeatXSet; + m_repeatYSet = o.m_repeatYSet; + m_xPosSet = o.m_xPosSet; + m_yPosSet = o.m_yPosSet; + + m_type = o.m_type; + + return *this; +} + +bool FillLayer::operator==(const FillLayer& o) const +{ + // We do not check the "isSet" booleans for each property, since those are only used during initial construction + // to propagate patterns into layers. All layer comparisons happen after values have all been filled in anyway. + return StyleImage::imagesEquivalent(m_image.get(), o.m_image.get()) && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition && + m_attachment == o.m_attachment && m_clip == o.m_clip && + m_composite == o.m_composite && m_origin == o.m_origin && m_repeatX == o.m_repeatX && + m_repeatY == o.m_repeatY && m_sizeType == o.m_sizeType && m_sizeLength == o.m_sizeLength && + m_type == o.m_type && ((m_next && o.m_next) ? *m_next == *o.m_next : m_next == o.m_next); +} + +void FillLayer::fillUnsetProperties() +{ + FillLayer* curr; + for (curr = this; curr && curr->isImageSet(); curr = curr->next()) { } + if (curr && curr != this) { + // We need to fill in the remaining values with the pattern specified. + for (FillLayer* pattern = this; curr; curr = curr->next()) { + curr->m_image = pattern->m_image; + pattern = pattern->next(); + if (pattern == curr || !pattern) + pattern = this; + } + } + + for (curr = this; curr && curr->isXPositionSet(); curr = curr->next()) { } + if (curr && curr != this) { + // We need to fill in the remaining values with the pattern specified. + for (FillLayer* pattern = this; curr; curr = curr->next()) { + curr->m_xPosition = pattern->m_xPosition; + pattern = pattern->next(); + if (pattern == curr || !pattern) + pattern = this; + } + } + + for (curr = this; curr && curr->isYPositionSet(); curr = curr->next()) { } + if (curr && curr != this) { + // We need to fill in the remaining values with the pattern specified. + for (FillLayer* pattern = this; curr; curr = curr->next()) { + curr->m_yPosition = pattern->m_yPosition; + pattern = pattern->next(); + if (pattern == curr || !pattern) + pattern = this; + } + } + + for (curr = this; curr && curr->isAttachmentSet(); curr = curr->next()) { } + if (curr && curr != this) { + // We need to fill in the remaining values with the pattern specified. + for (FillLayer* pattern = this; curr; curr = curr->next()) { + curr->m_attachment = pattern->m_attachment; + pattern = pattern->next(); + if (pattern == curr || !pattern) + pattern = this; + } + } + + for (curr = this; curr && curr->isClipSet(); curr = curr->next()) { } + if (curr && curr != this) { + // We need to fill in the remaining values with the pattern specified. + for (FillLayer* pattern = this; curr; curr = curr->next()) { + curr->m_clip = pattern->m_clip; + pattern = pattern->next(); + if (pattern == curr || !pattern) + pattern = this; + } + } + + for (curr = this; curr && curr->isCompositeSet(); curr = curr->next()) { } + if (curr && curr != this) { + // We need to fill in the remaining values with the pattern specified. + for (FillLayer* pattern = this; curr; curr = curr->next()) { + curr->m_composite = pattern->m_composite; + pattern = pattern->next(); + if (pattern == curr || !pattern) + pattern = this; + } + } + + for (curr = this; curr && curr->isOriginSet(); curr = curr->next()) { } + if (curr && curr != this) { + // We need to fill in the remaining values with the pattern specified. + for (FillLayer* pattern = this; curr; curr = curr->next()) { + curr->m_origin = pattern->m_origin; + pattern = pattern->next(); + if (pattern == curr || !pattern) + pattern = this; + } + } + + for (curr = this; curr && curr->isRepeatXSet(); curr = curr->next()) { } + if (curr && curr != this) { + // We need to fill in the remaining values with the pattern specified. + for (FillLayer* pattern = this; curr; curr = curr->next()) { + curr->m_repeatX = pattern->m_repeatX; + pattern = pattern->next(); + if (pattern == curr || !pattern) + pattern = this; + } + } + + for (curr = this; curr && curr->isRepeatYSet(); curr = curr->next()) { } + if (curr && curr != this) { + // We need to fill in the remaining values with the pattern specified. + for (FillLayer* pattern = this; curr; curr = curr->next()) { + curr->m_repeatY = pattern->m_repeatY; + pattern = pattern->next(); + if (pattern == curr || !pattern) + pattern = this; + } + } + + for (curr = this; curr && curr->isSizeSet(); curr = curr->next()) { } + if (curr && curr != this) { + // We need to fill in the remaining values with the pattern specified. + for (FillLayer* pattern = this; curr; curr = curr->next()) { + curr->m_sizeType = pattern->m_sizeType; + curr->m_sizeLength = pattern->m_sizeLength; + pattern = pattern->next(); + if (pattern == curr || !pattern) + pattern = this; + } + } +} + +void FillLayer::cullEmptyLayers() +{ + FillLayer* next; + for (FillLayer* p = this; p; p = next) { + next = p->m_next; + if (next && !next->isImageSet() && + !next->isXPositionSet() && !next->isYPositionSet() && + !next->isAttachmentSet() && !next->isClipSet() && + !next->isCompositeSet() && !next->isOriginSet() && + !next->isRepeatXSet() && !next->isRepeatYSet() + && !next->isSizeSet()) { + delete next; + p->m_next = 0; + break; + } + } +} + +bool FillLayer::containsImage(StyleImage* s) const +{ + if (!s) + return false; + if (m_image && *s == *m_image) + return true; + if (m_next) + return m_next->containsImage(s); + return false; +} + +bool FillLayer::imagesAreLoaded() const +{ + const FillLayer* curr; + for (curr = this; curr; curr = curr->next()) { + if (curr->m_image && !curr->m_image->isLoaded()) + return false; + } + + return true; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/FillLayer.h b/Source/WebCore/rendering/style/FillLayer.h new file mode 100644 index 0000000..49fb294 --- /dev/null +++ b/Source/WebCore/rendering/style/FillLayer.h @@ -0,0 +1,201 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 FillLayer_h +#define FillLayer_h + +#include "GraphicsTypes.h" +#include "Length.h" +#include "LengthSize.h" +#include "RenderStyleConstants.h" +#include "StyleImage.h" +#include + +namespace WebCore { + +struct FillSize { + FillSize() + : type(SizeLength) + { + } + + FillSize(EFillSizeType t, LengthSize l) + : type(t) + , size(l) + { + } + + bool operator==(const FillSize& o) const + { + return type == o.type && size == o.size; + } + bool operator!=(const FillSize& o) const + { + return !(*this == o); + } + + EFillSizeType type; + LengthSize size; +}; + +class FillLayer : public FastAllocBase { +public: + FillLayer(EFillLayerType); + ~FillLayer(); + + StyleImage* image() const { return m_image.get(); } + Length xPosition() const { return m_xPosition; } + Length yPosition() const { return m_yPosition; } + EFillAttachment attachment() const { return static_cast(m_attachment); } + EFillBox clip() const { return static_cast(m_clip); } + EFillBox origin() const { return static_cast(m_origin); } + EFillRepeat repeatX() const { return static_cast(m_repeatX); } + EFillRepeat repeatY() const { return static_cast(m_repeatY); } + CompositeOperator composite() const { return static_cast(m_composite); } + LengthSize sizeLength() const { return m_sizeLength; } + EFillSizeType sizeType() const { return static_cast(m_sizeType); } + FillSize size() const { return FillSize(static_cast(m_sizeType), m_sizeLength); } + + const FillLayer* next() const { return m_next; } + FillLayer* next() { return m_next; } + + bool isImageSet() const { return m_imageSet; } + bool isXPositionSet() const { return m_xPosSet; } + bool isYPositionSet() const { return m_yPosSet; } + bool isAttachmentSet() const { return m_attachmentSet; } + bool isClipSet() const { return m_clipSet; } + bool isOriginSet() const { return m_originSet; } + bool isRepeatXSet() const { return m_repeatXSet; } + bool isRepeatYSet() const { return m_repeatYSet; } + bool isCompositeSet() const { return m_compositeSet; } + bool isSizeSet() const { return m_sizeType != SizeNone; } + + void setImage(StyleImage* i) { m_image = i; m_imageSet = true; } + void setXPosition(Length l) { m_xPosition = l; m_xPosSet = true; } + void setYPosition(Length l) { m_yPosition = l; m_yPosSet = true; } + void setAttachment(EFillAttachment attachment) { m_attachment = attachment; m_attachmentSet = true; } + void setClip(EFillBox b) { m_clip = b; m_clipSet = true; } + void setOrigin(EFillBox b) { m_origin = b; m_originSet = true; } + void setRepeatX(EFillRepeat r) { m_repeatX = r; m_repeatXSet = true; } + void setRepeatY(EFillRepeat r) { m_repeatY = r; m_repeatYSet = true; } + void setComposite(CompositeOperator c) { m_composite = c; m_compositeSet = true; } + void setSizeType(EFillSizeType b) { m_sizeType = b; } + void setSizeLength(LengthSize l) { m_sizeLength = l; } + void setSize(FillSize f) { m_sizeType = f.type; m_sizeLength = f.size; } + + void clearImage() { m_imageSet = false; } + void clearXPosition() { m_xPosSet = false; } + void clearYPosition() { m_yPosSet = false; } + void clearAttachment() { m_attachmentSet = false; } + void clearClip() { m_clipSet = false; } + void clearOrigin() { m_originSet = false; } + void clearRepeatX() { m_repeatXSet = false; } + void clearRepeatY() { m_repeatYSet = false; } + void clearComposite() { m_compositeSet = false; } + void clearSize() { m_sizeType = SizeNone; } + + void setNext(FillLayer* n) { if (m_next != n) { delete m_next; m_next = n; } } + + FillLayer& operator=(const FillLayer& o); + FillLayer(const FillLayer& o); + + bool operator==(const FillLayer& o) const; + bool operator!=(const FillLayer& o) const + { + return !(*this == o); + } + + bool containsImage(StyleImage*) const; + bool imagesAreLoaded() const; + + bool hasImage() const + { + if (m_image) + return true; + return m_next ? m_next->hasImage() : false; + } + + bool hasFixedImage() const + { + if (m_image && m_attachment == FixedBackgroundAttachment) + return true; + return m_next ? m_next->hasFixedImage() : false; + } + + EFillLayerType type() const { return static_cast(m_type); } + + void fillUnsetProperties(); + void cullEmptyLayers(); + + static EFillAttachment initialFillAttachment(EFillLayerType) { return ScrollBackgroundAttachment; } + static EFillBox initialFillClip(EFillLayerType) { return BorderFillBox; } + static EFillBox initialFillOrigin(EFillLayerType type) { return type == BackgroundFillLayer ? PaddingFillBox : BorderFillBox; } + static EFillRepeat initialFillRepeatX(EFillLayerType) { return RepeatFill; } + static EFillRepeat initialFillRepeatY(EFillLayerType) { return RepeatFill; } + static CompositeOperator initialFillComposite(EFillLayerType) { return CompositeSourceOver; } + static EFillSizeType initialFillSizeType(EFillLayerType) { return SizeLength; } + static LengthSize initialFillSizeLength(EFillLayerType) { return LengthSize(); } + static FillSize initialFillSize(EFillLayerType) { return FillSize(); } + static Length initialFillXPosition(EFillLayerType) { return Length(0.0, Percent); } + static Length initialFillYPosition(EFillLayerType) { return Length(0.0, Percent); } + static StyleImage* initialFillImage(EFillLayerType) { return 0; } + +private: + friend class RenderStyle; + + FillLayer() { } + + FillLayer* m_next; + + RefPtr m_image; + + Length m_xPosition; + Length m_yPosition; + + unsigned m_attachment : 2; // EFillAttachment + unsigned m_clip : 2; // EFillBox + unsigned m_origin : 2; // EFillBox + unsigned m_repeatX : 3; // EFillRepeat + unsigned m_repeatY : 3; // EFillRepeat + unsigned m_composite : 4; // CompositeOperator + unsigned m_sizeType : 2; // EFillSizeType + + LengthSize m_sizeLength; + + bool m_imageSet : 1; + bool m_attachmentSet : 1; + bool m_clipSet : 1; + bool m_originSet : 1; + bool m_repeatXSet : 1; + bool m_repeatYSet : 1; + bool m_xPosSet : 1; + bool m_yPosSet : 1; + bool m_compositeSet : 1; + + unsigned m_type : 1; // EFillLayerType +}; + +} // namespace WebCore + +#endif // FillLayer_h diff --git a/Source/WebCore/rendering/style/KeyframeList.cpp b/Source/WebCore/rendering/style/KeyframeList.cpp new file mode 100644 index 0000000..bafa426 --- /dev/null +++ b/Source/WebCore/rendering/style/KeyframeList.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "KeyframeList.h" +#include "RenderObject.h" + +namespace WebCore { + +KeyframeList::~KeyframeList() +{ + clear(); +} + +void KeyframeList::clear() +{ + m_keyframes.clear(); + m_properties.clear(); +} + +bool KeyframeList::operator==(const KeyframeList& o) const +{ + if (m_keyframes.size() != o.m_keyframes.size()) + return false; + + Vector::const_iterator it2 = o.m_keyframes.begin(); + for (Vector::const_iterator it1 = m_keyframes.begin(); it1 != m_keyframes.end(); ++it1) { + if (it1->key() != it2->key()) + return false; + const RenderStyle& style1 = *it1->style(); + const RenderStyle& style2 = *it2->style(); + if (style1 != style2) + return false; + ++it2; + } + + return true; +} + +void KeyframeList::insert(const KeyframeValue& keyframe) +{ + if (keyframe.key() < 0 || keyframe.key() > 1) + return; + + bool inserted = false; + bool replaced = false; + for (size_t i = 0; i < m_keyframes.size(); ++i) { + if (m_keyframes[i].key() == keyframe.key()) { + m_keyframes[i] = keyframe; + replaced = true; + break; + } + + if (m_keyframes[i].key() > keyframe.key()) { + // insert before + m_keyframes.insert(i, keyframe); + inserted = true; + break; + } + } + + if (!replaced && !inserted) + m_keyframes.append(keyframe); + + if (replaced) { + // We have to rebuild the properties list from scratch. + m_properties.clear(); + for (Vector::const_iterator it = m_keyframes.begin(); it != m_keyframes.end(); ++it) { + const KeyframeValue& currKeyframe = *it; + for (HashSet::const_iterator it = currKeyframe.properties().begin(); it != currKeyframe.properties().end(); ++it) + m_properties.add(*it); + } + } else { + for (HashSet::const_iterator it = keyframe.properties().begin(); it != keyframe.properties().end(); ++it) + m_properties.add(*it); + } +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/KeyframeList.h b/Source/WebCore/rendering/style/KeyframeList.h new file mode 100644 index 0000000..64170ce --- /dev/null +++ b/Source/WebCore/rendering/style/KeyframeList.h @@ -0,0 +1,99 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 KeyframeList_h +#define KeyframeList_h + +#include +#include +#include +#include + +namespace WebCore { + +class RenderObject; +class RenderStyle; + +class KeyframeValue { +public: + KeyframeValue(float key, PassRefPtr style) + : m_key(key) + , m_style(style) + { + } + + void addProperty(int prop) { m_properties.add(prop); } + bool containsProperty(int prop) const { return m_properties.contains(prop); } + const HashSet& properties() const { return m_properties; } + + float key() const { return m_key; } + void setKey(float key) { m_key = key; } + + const RenderStyle* style() const { return m_style.get(); } + void setStyle(PassRefPtr style) { m_style = style; } + +private: + float m_key; + HashSet m_properties; // The properties specified in this keyframe. + RefPtr m_style; +}; + +class KeyframeList { +public: + KeyframeList(RenderObject* renderer, const AtomicString& animationName) + : m_animationName(animationName) + , m_renderer(renderer) + { + insert(KeyframeValue(0, 0)); + insert(KeyframeValue(1, 0)); + } + ~KeyframeList(); + + bool operator==(const KeyframeList& o) const; + bool operator!=(const KeyframeList& o) const { return !(*this == o); } + + const AtomicString& animationName() const { return m_animationName; } + + void insert(const KeyframeValue& keyframe); + + void addProperty(int prop) { m_properties.add(prop); } + bool containsProperty(int prop) const { return m_properties.contains(prop); } + HashSet::const_iterator beginProperties() const { return m_properties.begin(); } + HashSet::const_iterator endProperties() const { return m_properties.end(); } + + void clear(); + bool isEmpty() const { return m_keyframes.isEmpty(); } + size_t size() const { return m_keyframes.size(); } + const KeyframeValue& operator[](size_t index) const { return m_keyframes[index]; } + +private: + AtomicString m_animationName; + Vector m_keyframes; // kept sorted by key + HashSet m_properties; // the properties being animated + RenderObject* m_renderer; +}; + +} // namespace WebCore + +#endif // KeyframeList_h diff --git a/Source/WebCore/rendering/style/LineClampValue.h b/Source/WebCore/rendering/style/LineClampValue.h new file mode 100644 index 0000000..2119ca2 --- /dev/null +++ b/Source/WebCore/rendering/style/LineClampValue.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 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 INC. AND ITS 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 APPLE INC. OR ITS 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 LineClampValue_h +#define LineClampValue_h + +#include "RenderStyleConstants.h" + +namespace WebCore { + +class LineClampValue { +public: + LineClampValue() + : m_type(LineClampLineCount) + , m_value(-1) + { + } + + LineClampValue(int value, ELineClampType type) + : m_type(type) + , m_value(value) + { + } + + int value() const { return m_value; } + + bool isPercentage() const { return m_type == LineClampPercentage; } + + bool isNone() const { return m_value == -1; } + + bool operator==(const LineClampValue& o) const + { + return value() == o.value() && isPercentage() == o.isPercentage(); + } + + bool operator!=(const LineClampValue& o) const + { + return !(*this == o); + } + +private: + ELineClampType m_type; + int m_value; +}; + +} // namespace WebCore + +#endif // LineClampValue_h diff --git a/Source/WebCore/rendering/style/NinePieceImage.cpp b/Source/WebCore/rendering/style/NinePieceImage.cpp new file mode 100644 index 0000000..d585e8f --- /dev/null +++ b/Source/WebCore/rendering/style/NinePieceImage.cpp @@ -0,0 +1,35 @@ +/* + * 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 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 "config.h" +#include "NinePieceImage.h" + +namespace WebCore { + +bool NinePieceImage::operator==(const NinePieceImage& o) const +{ + return StyleImage::imagesEquivalent(m_image.get(), o.m_image.get()) && m_slices == o.m_slices && m_horizontalRule == o.m_horizontalRule && + m_verticalRule == o.m_verticalRule; +} + +} diff --git a/Source/WebCore/rendering/style/NinePieceImage.h b/Source/WebCore/rendering/style/NinePieceImage.h new file mode 100644 index 0000000..c400551 --- /dev/null +++ b/Source/WebCore/rendering/style/NinePieceImage.h @@ -0,0 +1,78 @@ +/* + * 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 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 NinePieceImage_h +#define NinePieceImage_h + +#include "LengthBox.h" +#include "StyleImage.h" + +namespace WebCore { + +enum ENinePieceImageRule { + StretchImageRule, RoundImageRule, RepeatImageRule +}; + +class NinePieceImage { +public: + NinePieceImage() + : m_image(0) + , m_horizontalRule(StretchImageRule) + , m_verticalRule(StretchImageRule) + { + } + + NinePieceImage(StyleImage* image, LengthBox slices, ENinePieceImageRule h, ENinePieceImageRule v) + : m_image(image) + , m_slices(slices) + , m_horizontalRule(h) + , m_verticalRule(v) + { + } + + bool operator==(const NinePieceImage& o) const; + bool operator!=(const NinePieceImage& o) const { return !(*this == o); } + + bool hasImage() const { return m_image != 0; } + StyleImage* image() const { return m_image.get(); } + void setImage(StyleImage* image) { m_image = image; } + + const LengthBox& slices() const { return m_slices; } + void setSlices(const LengthBox& l) { m_slices = l; } + + ENinePieceImageRule horizontalRule() const { return static_cast(m_horizontalRule); } + void setHorizontalRule(ENinePieceImageRule rule) { m_horizontalRule = rule; } + + ENinePieceImageRule verticalRule() const { return static_cast(m_verticalRule); } + void setVerticalRule(ENinePieceImageRule rule) { m_verticalRule = rule; } + +private: + RefPtr m_image; + LengthBox m_slices; + unsigned m_horizontalRule : 2; // ENinePieceImageRule + unsigned m_verticalRule : 2; // ENinePieceImageRule +}; + +} // namespace WebCore + +#endif // NinePieceImage_h diff --git a/Source/WebCore/rendering/style/OutlineValue.h b/Source/WebCore/rendering/style/OutlineValue.h new file mode 100644 index 0000000..19c17a7 --- /dev/null +++ b/Source/WebCore/rendering/style/OutlineValue.h @@ -0,0 +1,61 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 OutlineValue_h +#define OutlineValue_h + +#include "BorderValue.h" + +namespace WebCore { + +class OutlineValue : public BorderValue { +friend class RenderStyle; +public: + OutlineValue() + : m_offset(0) + , m_isAuto(false) + { + } + + bool operator==(const OutlineValue& o) const + { + return m_width == o.m_width && m_style == o.m_style && m_color == o.m_color && m_offset == o.m_offset && m_isAuto == o.m_isAuto; + } + + bool operator!=(const OutlineValue& o) const + { + return !(*this == o); + } + + int offset() const { return m_offset; } + bool isAuto() const { return m_isAuto; } + +private: + int m_offset; + bool m_isAuto; +}; + +} // namespace WebCore + +#endif // OutlineValue_h diff --git a/Source/WebCore/rendering/style/RenderStyle.cpp b/Source/WebCore/rendering/style/RenderStyle.cpp new file mode 100644 index 0000000..881818c --- /dev/null +++ b/Source/WebCore/rendering/style/RenderStyle.cpp @@ -0,0 +1,1473 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 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 "config.h" +#include "RenderStyle.h" + +#include "CSSPropertyNames.h" +#include "CSSStyleSelector.h" +#include "FontSelector.h" +#include "RenderArena.h" +#include "RenderObject.h" +#include "ScaleTransformOperation.h" +#include "StyleImage.h" +#include +#include + +using namespace std; + +namespace WebCore { + +inline RenderStyle* defaultStyle() +{ + static RenderStyle* s_defaultStyle = RenderStyle::createDefaultStyle().releaseRef(); + return s_defaultStyle; +} + +PassRefPtr RenderStyle::create() +{ + return adoptRef(new RenderStyle()); +} + +PassRefPtr RenderStyle::createDefaultStyle() +{ + return adoptRef(new RenderStyle(true)); +} + +PassRefPtr RenderStyle::clone(const RenderStyle* other) +{ + return adoptRef(new RenderStyle(*other)); +} + +ALWAYS_INLINE RenderStyle::RenderStyle() + : m_affectedByAttributeSelectors(false) + , m_unique(false) + , m_affectedByEmpty(false) + , m_emptyState(false) + , m_childrenAffectedByFirstChildRules(false) + , m_childrenAffectedByLastChildRules(false) + , m_childrenAffectedByDirectAdjacentRules(false) + , m_childrenAffectedByForwardPositionalRules(false) + , m_childrenAffectedByBackwardPositionalRules(false) + , m_firstChildState(false) + , m_lastChildState(false) + , m_childIndex(0) + , m_box(defaultStyle()->m_box) + , visual(defaultStyle()->visual) + , m_background(defaultStyle()->m_background) + , surround(defaultStyle()->surround) + , rareNonInheritedData(defaultStyle()->rareNonInheritedData) + , rareInheritedData(defaultStyle()->rareInheritedData) + , inherited(defaultStyle()->inherited) +#if ENABLE(SVG) + , m_svgStyle(defaultStyle()->m_svgStyle) +#endif +{ + setBitDefaults(); // Would it be faster to copy this from the default style? +} + +ALWAYS_INLINE RenderStyle::RenderStyle(bool) + : m_affectedByAttributeSelectors(false) + , m_unique(false) + , m_affectedByEmpty(false) + , m_emptyState(false) + , m_childrenAffectedByFirstChildRules(false) + , m_childrenAffectedByLastChildRules(false) + , m_childrenAffectedByDirectAdjacentRules(false) + , m_childrenAffectedByForwardPositionalRules(false) + , m_childrenAffectedByBackwardPositionalRules(false) + , m_firstChildState(false) + , m_lastChildState(false) + , m_childIndex(0) +{ + setBitDefaults(); + + m_box.init(); + visual.init(); + m_background.init(); + surround.init(); + rareNonInheritedData.init(); + rareNonInheritedData.access()->flexibleBox.init(); + rareNonInheritedData.access()->marquee.init(); + rareNonInheritedData.access()->m_multiCol.init(); + rareNonInheritedData.access()->m_transform.init(); + rareInheritedData.init(); + inherited.init(); + +#if ENABLE(SVG) + m_svgStyle.init(); +#endif +} + +ALWAYS_INLINE RenderStyle::RenderStyle(const RenderStyle& o) + : RefCounted() + , m_affectedByAttributeSelectors(false) + , m_unique(false) + , m_affectedByEmpty(false) + , m_emptyState(false) + , m_childrenAffectedByFirstChildRules(false) + , m_childrenAffectedByLastChildRules(false) + , m_childrenAffectedByDirectAdjacentRules(false) + , m_childrenAffectedByForwardPositionalRules(false) + , m_childrenAffectedByBackwardPositionalRules(false) + , m_firstChildState(false) + , m_lastChildState(false) + , m_childIndex(0) + , m_box(o.m_box) + , visual(o.visual) + , m_background(o.m_background) + , surround(o.surround) + , rareNonInheritedData(o.rareNonInheritedData) + , rareInheritedData(o.rareInheritedData) + , inherited(o.inherited) +#if ENABLE(SVG) + , m_svgStyle(o.m_svgStyle) +#endif + , inherited_flags(o.inherited_flags) + , noninherited_flags(o.noninherited_flags) +{ +} + +void RenderStyle::inheritFrom(const RenderStyle* inheritParent) +{ + rareInheritedData = inheritParent->rareInheritedData; + inherited = inheritParent->inherited; + inherited_flags = inheritParent->inherited_flags; +#if ENABLE(SVG) + if (m_svgStyle != inheritParent->m_svgStyle) + m_svgStyle.access()->inheritFrom(inheritParent->m_svgStyle.get()); +#endif +} + +RenderStyle::~RenderStyle() +{ +} + +bool RenderStyle::operator==(const RenderStyle& o) const +{ + // compare everything except the pseudoStyle pointer + return inherited_flags == o.inherited_flags && + noninherited_flags == o.noninherited_flags && + m_box == o.m_box && + visual == o.visual && + m_background == o.m_background && + surround == o.surround && + rareNonInheritedData == o.rareNonInheritedData && + rareInheritedData == o.rareInheritedData && + inherited == o.inherited +#if ENABLE(SVG) + && m_svgStyle == o.m_svgStyle +#endif + ; +} + +bool RenderStyle::isStyleAvailable() const +{ + return this != CSSStyleSelector::styleNotYetAvailable(); +} + +static inline int pseudoBit(PseudoId pseudo) +{ + return 1 << (pseudo - 1); +} + +bool RenderStyle::hasAnyPublicPseudoStyles() const +{ + return PUBLIC_PSEUDOID_MASK & noninherited_flags._pseudoBits; +} + +bool RenderStyle::hasPseudoStyle(PseudoId pseudo) const +{ + ASSERT(pseudo > NOPSEUDO); + ASSERT(pseudo < FIRST_INTERNAL_PSEUDOID); + return pseudoBit(pseudo) & noninherited_flags._pseudoBits; +} + +void RenderStyle::setHasPseudoStyle(PseudoId pseudo) +{ + ASSERT(pseudo > NOPSEUDO); + ASSERT(pseudo < FIRST_INTERNAL_PSEUDOID); + noninherited_flags._pseudoBits |= pseudoBit(pseudo); +} + +RenderStyle* RenderStyle::getCachedPseudoStyle(PseudoId pid) const +{ + ASSERT(styleType() != VISITED_LINK); + + if (!m_cachedPseudoStyles || !m_cachedPseudoStyles->size()) + return 0; + + if (styleType() != NOPSEUDO) { + if (pid == VISITED_LINK) + return m_cachedPseudoStyles->at(0)->styleType() == VISITED_LINK ? m_cachedPseudoStyles->at(0).get() : 0; + return 0; + } + + for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) { + RenderStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); + if (pseudoStyle->styleType() == pid) + return pseudoStyle; + } + + return 0; +} + +RenderStyle* RenderStyle::addCachedPseudoStyle(PassRefPtr pseudo) +{ + if (!pseudo) + return 0; + + RenderStyle* result = pseudo.get(); + + if (!m_cachedPseudoStyles) + m_cachedPseudoStyles.set(new PseudoStyleCache); + + m_cachedPseudoStyles->append(pseudo); + + return result; +} + +void RenderStyle::removeCachedPseudoStyle(PseudoId pid) +{ + if (!m_cachedPseudoStyles) + return; + for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) { + RenderStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get(); + if (pseudoStyle->styleType() == pid) { + m_cachedPseudoStyles->remove(i); + return; + } + } +} + +bool RenderStyle::inheritedNotEqual(const RenderStyle* other) const +{ + return inherited_flags != other->inherited_flags || + inherited != other->inherited || +#if ENABLE(SVG) + m_svgStyle->inheritedNotEqual(other->m_svgStyle.get()) || +#endif + rareInheritedData != other->rareInheritedData; +} + +static bool positionedObjectMoved(const LengthBox& a, const LengthBox& b) +{ + // If any unit types are different, then we can't guarantee + // that this was just a movement. + if (a.left().type() != b.left().type() || + a.right().type() != b.right().type() || + a.top().type() != b.top().type() || + a.bottom().type() != b.bottom().type()) + return false; + + // Only one unit can be non-auto in the horizontal direction and + // in the vertical direction. Otherwise the adjustment of values + // is changing the size of the box. + if (!a.left().isIntrinsicOrAuto() && !a.right().isIntrinsicOrAuto()) + return false; + if (!a.top().isIntrinsicOrAuto() && !a.bottom().isIntrinsicOrAuto()) + return false; + + // One of the units is fixed or percent in both directions and stayed + // that way in the new style. Therefore all we are doing is moving. + return true; +} + +/* + compares two styles. The result gives an idea of the action that + needs to be taken when replacing the old style with a new one. + + CbLayout: The containing block of the object needs a relayout. + Layout: the RenderObject needs a relayout after the style change + Visible: The change is visible, but no relayout is needed + NonVisible: The object does need neither repaint nor relayout after + the change. + + ### TODO: + A lot can be optimised here based on the display type, lots of + optimisations are unimplemented, and currently result in the + worst case result causing a relayout of the containing block. +*/ +StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedContextSensitiveProperties) const +{ + changedContextSensitiveProperties = ContextSensitivePropertyNone; + +#if ENABLE(SVG) + StyleDifference svgChange = StyleDifferenceEqual; + if (m_svgStyle != other->m_svgStyle) { + svgChange = m_svgStyle->diff(other->m_svgStyle.get()); + if (svgChange == StyleDifferenceLayout) + return svgChange; + } +#endif + + if (m_box->width() != other->m_box->width() || + m_box->minWidth() != other->m_box->minWidth() || + m_box->maxWidth() != other->m_box->maxWidth() || + m_box->height() != other->m_box->height() || + m_box->minHeight() != other->m_box->minHeight() || + m_box->maxHeight() != other->m_box->maxHeight()) + return StyleDifferenceLayout; + + if (m_box->verticalAlign() != other->m_box->verticalAlign() || noninherited_flags._vertical_align != other->noninherited_flags._vertical_align) + return StyleDifferenceLayout; + + if (m_box->boxSizing() != other->m_box->boxSizing()) + return StyleDifferenceLayout; + + if (surround->margin != other->surround->margin) + return StyleDifferenceLayout; + + if (surround->padding != other->surround->padding) + return StyleDifferenceLayout; + + if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) { + if (rareNonInheritedData->m_appearance != other->rareNonInheritedData->m_appearance || + rareNonInheritedData->marginBeforeCollapse != other->rareNonInheritedData->marginBeforeCollapse || + rareNonInheritedData->marginAfterCollapse != other->rareNonInheritedData->marginAfterCollapse || + rareNonInheritedData->lineClamp != other->rareNonInheritedData->lineClamp || + rareNonInheritedData->textOverflow != other->rareNonInheritedData->textOverflow) + return StyleDifferenceLayout; + + if (rareNonInheritedData->flexibleBox.get() != other->rareNonInheritedData->flexibleBox.get() && + *rareNonInheritedData->flexibleBox.get() != *other->rareNonInheritedData->flexibleBox.get()) + return StyleDifferenceLayout; + + // FIXME: We should add an optimized form of layout that just recomputes visual overflow. + if (!rareNonInheritedData->shadowDataEquivalent(*other->rareNonInheritedData.get())) + return StyleDifferenceLayout; + + if (!rareNonInheritedData->reflectionDataEquivalent(*other->rareNonInheritedData.get())) + return StyleDifferenceLayout; + + if (rareNonInheritedData->m_multiCol.get() != other->rareNonInheritedData->m_multiCol.get() && + *rareNonInheritedData->m_multiCol.get() != *other->rareNonInheritedData->m_multiCol.get()) + return StyleDifferenceLayout; + + if (rareNonInheritedData->m_transform.get() != other->rareNonInheritedData->m_transform.get() && + *rareNonInheritedData->m_transform.get() != *other->rareNonInheritedData->m_transform.get()) { +#if USE(ACCELERATED_COMPOSITING) + changedContextSensitiveProperties |= ContextSensitivePropertyTransform; + // Don't return; keep looking for another change +#else + return StyleDifferenceLayout; +#endif + } + +#if !USE(ACCELERATED_COMPOSITING) + if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) { + if (rareNonInheritedData->m_transformStyle3D != other->rareNonInheritedData->m_transformStyle3D || + rareNonInheritedData->m_backfaceVisibility != other->rareNonInheritedData->m_backfaceVisibility || + rareNonInheritedData->m_perspective != other->rareNonInheritedData->m_perspective || + rareNonInheritedData->m_perspectiveOriginX != other->rareNonInheritedData->m_perspectiveOriginX || + rareNonInheritedData->m_perspectiveOriginY != other->rareNonInheritedData->m_perspectiveOriginY) + return StyleDifferenceLayout; + } +#endif + +#if ENABLE(DASHBOARD_SUPPORT) + // If regions change, trigger a relayout to re-calc regions. + if (rareNonInheritedData->m_dashboardRegions != other->rareNonInheritedData->m_dashboardRegions) + return StyleDifferenceLayout; +#endif + } + + if (rareInheritedData.get() != other->rareInheritedData.get()) { + if (rareInheritedData->highlight != other->rareInheritedData->highlight || + rareInheritedData->indent != other->rareInheritedData->indent || + rareInheritedData->m_effectiveZoom != other->rareInheritedData->m_effectiveZoom || + rareInheritedData->textSizeAdjust != other->rareInheritedData->textSizeAdjust || + rareInheritedData->wordBreak != other->rareInheritedData->wordBreak || + rareInheritedData->wordWrap != other->rareInheritedData->wordWrap || + rareInheritedData->nbspMode != other->rareInheritedData->nbspMode || + rareInheritedData->khtmlLineBreak != other->rareInheritedData->khtmlLineBreak || + rareInheritedData->textSecurity != other->rareInheritedData->textSecurity || + rareInheritedData->hyphens != other->rareInheritedData->hyphens || + rareInheritedData->hyphenationString != other->rareInheritedData->hyphenationString || + rareInheritedData->hyphenationLocale != other->rareInheritedData->hyphenationLocale || + rareInheritedData->textEmphasisMark != other->rareInheritedData->textEmphasisMark || + rareInheritedData->textEmphasisPosition != other->rareInheritedData->textEmphasisPosition || + rareInheritedData->textEmphasisCustomMark != other->rareInheritedData->textEmphasisCustomMark) + return StyleDifferenceLayout; + + if (!rareInheritedData->shadowDataEquivalent(*other->rareInheritedData.get())) + return StyleDifferenceLayout; + + if (textStrokeWidth() != other->textStrokeWidth()) + return StyleDifferenceLayout; + } + + if (inherited->line_height != other->inherited->line_height || + inherited->list_style_image != other->inherited->list_style_image || + inherited->font != other->inherited->font || + inherited->horizontal_border_spacing != other->inherited->horizontal_border_spacing || + inherited->vertical_border_spacing != other->inherited->vertical_border_spacing || + inherited_flags._box_direction != other->inherited_flags._box_direction || + inherited_flags._visuallyOrdered != other->inherited_flags._visuallyOrdered || + noninherited_flags._position != other->noninherited_flags._position || + noninherited_flags._floating != other->noninherited_flags._floating || + noninherited_flags._originalDisplay != other->noninherited_flags._originalDisplay) + return StyleDifferenceLayout; + + + if (((int)noninherited_flags._effectiveDisplay) >= TABLE) { + if (inherited_flags._border_collapse != other->inherited_flags._border_collapse || + inherited_flags._empty_cells != other->inherited_flags._empty_cells || + inherited_flags._caption_side != other->inherited_flags._caption_side || + noninherited_flags._table_layout != other->noninherited_flags._table_layout) + return StyleDifferenceLayout; + + // In the collapsing border model, 'hidden' suppresses other borders, while 'none' + // does not, so these style differences can be width differences. + if (inherited_flags._border_collapse && + ((borderTopStyle() == BHIDDEN && other->borderTopStyle() == BNONE) || + (borderTopStyle() == BNONE && other->borderTopStyle() == BHIDDEN) || + (borderBottomStyle() == BHIDDEN && other->borderBottomStyle() == BNONE) || + (borderBottomStyle() == BNONE && other->borderBottomStyle() == BHIDDEN) || + (borderLeftStyle() == BHIDDEN && other->borderLeftStyle() == BNONE) || + (borderLeftStyle() == BNONE && other->borderLeftStyle() == BHIDDEN) || + (borderRightStyle() == BHIDDEN && other->borderRightStyle() == BNONE) || + (borderRightStyle() == BNONE && other->borderRightStyle() == BHIDDEN))) + return StyleDifferenceLayout; + } + + if (noninherited_flags._effectiveDisplay == LIST_ITEM) { + if (inherited_flags._list_style_type != other->inherited_flags._list_style_type || + inherited_flags._list_style_position != other->inherited_flags._list_style_position) + return StyleDifferenceLayout; + } + + if (inherited_flags._text_align != other->inherited_flags._text_align || + inherited_flags._text_transform != other->inherited_flags._text_transform || + inherited_flags._direction != other->inherited_flags._direction || + inherited_flags._white_space != other->inherited_flags._white_space || + noninherited_flags._clear != other->noninherited_flags._clear) + return StyleDifferenceLayout; + + // Check block flow direction. + if (inherited_flags.m_writingMode != other->inherited_flags.m_writingMode) + return StyleDifferenceLayout; + + // Check text combine mode. + if (rareNonInheritedData->m_textCombine != other->rareNonInheritedData->m_textCombine) + return StyleDifferenceLayout; + + // Overflow returns a layout hint. + if (noninherited_flags._overflowX != other->noninherited_flags._overflowX || + noninherited_flags._overflowY != other->noninherited_flags._overflowY) + return StyleDifferenceLayout; + + // If our border widths change, then we need to layout. Other changes to borders + // only necessitate a repaint. + if (borderLeftWidth() != other->borderLeftWidth() || + borderTopWidth() != other->borderTopWidth() || + borderBottomWidth() != other->borderBottomWidth() || + borderRightWidth() != other->borderRightWidth()) + return StyleDifferenceLayout; + + // If the counter directives change, trigger a relayout to re-calculate counter values and rebuild the counter node tree. + const CounterDirectiveMap* mapA = rareNonInheritedData->m_counterDirectives.get(); + const CounterDirectiveMap* mapB = other->rareNonInheritedData->m_counterDirectives.get(); + if (!(mapA == mapB || (mapA && mapB && *mapA == *mapB))) + return StyleDifferenceLayout; + if (rareNonInheritedData->m_counterIncrement != other->rareNonInheritedData->m_counterIncrement || + rareNonInheritedData->m_counterReset != other->rareNonInheritedData->m_counterReset) + return StyleDifferenceLayout; + + if ((rareNonInheritedData->opacity == 1 && other->rareNonInheritedData->opacity < 1) || + (rareNonInheritedData->opacity < 1 && other->rareNonInheritedData->opacity == 1)) { + // FIXME: We should add an optimized form of layout that just recomputes visual overflow. + return StyleDifferenceLayout; + } + + if ((visibility() == COLLAPSE) != (other->visibility() == COLLAPSE)) + return StyleDifferenceLayout; + +#if ENABLE(SVG) + // SVGRenderStyle::diff() might have returned StyleDifferenceRepaint, eg. if fill changes. + // If eg. the font-size changed at the same time, we're not allowed to return StyleDifferenceRepaint, + // but have to return StyleDifferenceLayout, that's why this if branch comes after all branches + // that are relevant for SVG and might return StyleDifferenceLayout. + if (svgChange != StyleDifferenceEqual) + return svgChange; +#endif + + // Make sure these left/top/right/bottom checks stay below all layout checks and above + // all visible checks. + if (position() != StaticPosition) { + if (surround->offset != other->surround->offset) { + // Optimize for the case where a positioned layer is moving but not changing size. + if (position() == AbsolutePosition && positionedObjectMoved(surround->offset, other->surround->offset)) + return StyleDifferenceLayoutPositionedMovementOnly; + + // FIXME: We will need to do a bit of work in RenderObject/Box::setStyle before we + // can stop doing a layout when relative positioned objects move. In particular, we'll need + // to update scrolling positions and figure out how to do a repaint properly of the updated layer. + //if (other->position() == RelativePosition) + // return RepaintLayer; + //else + return StyleDifferenceLayout; + } else if (m_box->zIndex() != other->m_box->zIndex() || m_box->hasAutoZIndex() != other->m_box->hasAutoZIndex() || + visual->clip != other->visual->clip || visual->hasClip != other->visual->hasClip) + return StyleDifferenceRepaintLayer; + } + + if (rareNonInheritedData->opacity != other->rareNonInheritedData->opacity) { +#if USE(ACCELERATED_COMPOSITING) + changedContextSensitiveProperties |= ContextSensitivePropertyOpacity; + // Don't return; keep looking for another change. +#else + return StyleDifferenceRepaintLayer; +#endif + } + + if (rareNonInheritedData->m_mask != other->rareNonInheritedData->m_mask || + rareNonInheritedData->m_maskBoxImage != other->rareNonInheritedData->m_maskBoxImage) + return StyleDifferenceRepaintLayer; + + if (inherited->color != other->inherited->color || + inherited_flags._visibility != other->inherited_flags._visibility || + inherited_flags._text_decorations != other->inherited_flags._text_decorations || + inherited_flags._force_backgrounds_to_white != other->inherited_flags._force_backgrounds_to_white || + inherited_flags._insideLink != other->inherited_flags._insideLink || + surround->border != other->surround->border || + *m_background.get() != *other->m_background.get() || + visual->textDecoration != other->visual->textDecoration || + rareInheritedData->userModify != other->rareInheritedData->userModify || + rareInheritedData->userSelect != other->rareInheritedData->userSelect || + rareNonInheritedData->userDrag != other->rareNonInheritedData->userDrag || + rareNonInheritedData->m_borderFit != other->rareNonInheritedData->m_borderFit || + rareInheritedData->textFillColor != other->rareInheritedData->textFillColor || + rareInheritedData->textStrokeColor != other->rareInheritedData->textStrokeColor || + rareInheritedData->textEmphasisColor != other->rareInheritedData->textEmphasisColor || + rareInheritedData->textEmphasisFill != other->rareInheritedData->textEmphasisFill) + return StyleDifferenceRepaint; + +#if USE(ACCELERATED_COMPOSITING) + if (rareNonInheritedData.get() != other->rareNonInheritedData.get()) { + if (rareNonInheritedData->m_transformStyle3D != other->rareNonInheritedData->m_transformStyle3D || + rareNonInheritedData->m_backfaceVisibility != other->rareNonInheritedData->m_backfaceVisibility || + rareNonInheritedData->m_perspective != other->rareNonInheritedData->m_perspective || + rareNonInheritedData->m_perspectiveOriginX != other->rareNonInheritedData->m_perspectiveOriginX || + rareNonInheritedData->m_perspectiveOriginY != other->rareNonInheritedData->m_perspectiveOriginY) + return StyleDifferenceRecompositeLayer; + } +#endif + + // Cursors are not checked, since they will be set appropriately in response to mouse events, + // so they don't need to cause any repaint or layout. + + // Animations don't need to be checked either. We always set the new style on the RenderObject, so we will get a chance to fire off + // the resulting transition properly. + return StyleDifferenceEqual; +} + +void RenderStyle::setClip(Length top, Length right, Length bottom, Length left) +{ + StyleVisualData* data = visual.access(); + data->clip.m_top = top; + data->clip.m_right = right; + data->clip.m_bottom = bottom; + data->clip.m_left = left; +} + +void RenderStyle::addCursor(PassRefPtr image, const IntPoint& hotSpot) +{ + if (!rareInheritedData.access()->cursorData) + rareInheritedData.access()->cursorData = CursorList::create(); + rareInheritedData.access()->cursorData->append(CursorData(image, hotSpot)); +} + +void RenderStyle::setCursorList(PassRefPtr other) +{ + rareInheritedData.access()->cursorData = other; +} + +void RenderStyle::clearCursorList() +{ + if (rareInheritedData->cursorData) + rareInheritedData.access()->cursorData = 0; +} + +void RenderStyle::clearContent() +{ + if (rareNonInheritedData->m_content) + rareNonInheritedData->m_content->clear(); +} + +ContentData* RenderStyle::prepareToSetContent(StringImpl* string, bool add) +{ + OwnPtr& content = rareNonInheritedData.access()->m_content; + ContentData* lastContent = content.get(); + while (lastContent && lastContent->next()) + lastContent = lastContent->next(); + + if (string && add && lastContent && lastContent->isText()) { + // Augment the existing string and share the existing ContentData node. + String newText = lastContent->text(); + newText.append(string); + lastContent->setText(newText.impl()); + return 0; + } + + bool reuseContent = !add; + OwnPtr newContentData; + if (reuseContent && content) { + content->clear(); + newContentData = content.release(); + } else + newContentData = adoptPtr(new ContentData); + + ContentData* result = newContentData.get(); + + if (lastContent && !reuseContent) + lastContent->setNext(newContentData.release()); + else + content = newContentData.release(); + + return result; +} + +void RenderStyle::setContent(PassRefPtr image, bool add) +{ + if (!image) + return; + prepareToSetContent(0, add)->setImage(image); +} + +void RenderStyle::setContent(PassRefPtr string, bool add) +{ + if (!string) + return; + if (ContentData* data = prepareToSetContent(string.get(), add)) + data->setText(string); +} + +void RenderStyle::setContent(PassOwnPtr counter, bool add) +{ + if (!counter) + return; + prepareToSetContent(0, add)->setCounter(counter); +} + +void RenderStyle::applyTransform(TransformationMatrix& transform, const IntSize& borderBoxSize, ApplyTransformOrigin applyOrigin) const +{ + // transform-origin brackets the transform with translate operations. + // Optimize for the case where the only transform is a translation, since the transform-origin is irrelevant + // in that case. + bool applyTransformOrigin = false; + unsigned s = rareNonInheritedData->m_transform->m_operations.operations().size(); + unsigned i; + if (applyOrigin == IncludeTransformOrigin) { + for (i = 0; i < s; i++) { + TransformOperation::OperationType type = rareNonInheritedData->m_transform->m_operations.operations()[i]->getOperationType(); + if (type != TransformOperation::TRANSLATE_X && + type != TransformOperation::TRANSLATE_Y && + type != TransformOperation::TRANSLATE && + type != TransformOperation::TRANSLATE_Z && + type != TransformOperation::TRANSLATE_3D + ) { + applyTransformOrigin = true; + break; + } + } + } + + if (applyTransformOrigin) { + transform.translate3d(transformOriginX().calcFloatValue(borderBoxSize.width()), transformOriginY().calcFloatValue(borderBoxSize.height()), transformOriginZ()); + } + + for (i = 0; i < s; i++) + rareNonInheritedData->m_transform->m_operations.operations()[i]->apply(transform, borderBoxSize); + + if (applyTransformOrigin) { + transform.translate3d(-transformOriginX().calcFloatValue(borderBoxSize.width()), -transformOriginY().calcFloatValue(borderBoxSize.height()), -transformOriginZ()); + } +} + +void RenderStyle::setPageScaleTransform(float scale) +{ + if (scale == 1) + return; + TransformOperations transform; + transform.operations().append(ScaleTransformOperation::create(scale, scale, ScaleTransformOperation::SCALE)); + setTransform(transform); + setTransformOriginX(Length(0, Fixed)); + setTransformOriginY(Length(0, Fixed)); +} + +void RenderStyle::setTextShadow(ShadowData* val, bool add) +{ + ASSERT(!val || (!val->spread() && val->style() == Normal)); + + StyleRareInheritedData* rareData = rareInheritedData.access(); + if (!add) { + delete rareData->textShadow; + rareData->textShadow = val; + return; + } + + val->setNext(rareData->textShadow); + rareData->textShadow = val; +} + +void RenderStyle::setBoxShadow(ShadowData* shadowData, bool add) +{ + StyleRareNonInheritedData* rareData = rareNonInheritedData.access(); + if (!add) { + rareData->m_boxShadow.set(shadowData); + return; + } + + shadowData->setNext(rareData->m_boxShadow.leakPtr()); + rareData->m_boxShadow.set(shadowData); +} + +static void constrainCornerRadiiForRect(const IntRect& r, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) +{ + // Constrain corner radii using CSS3 rules: + // http://www.w3.org/TR/css3-background/#the-border-radius + + float factor = 1; + unsigned radiiSum; + + // top + radiiSum = static_cast(topLeft.width()) + static_cast(topRight.width()); // Casts to avoid integer overflow. + if (radiiSum > static_cast(r.width())) + factor = min(static_cast(r.width()) / radiiSum, factor); + + // bottom + radiiSum = static_cast(bottomLeft.width()) + static_cast(bottomRight.width()); + if (radiiSum > static_cast(r.width())) + factor = min(static_cast(r.width()) / radiiSum, factor); + + // left + radiiSum = static_cast(topLeft.height()) + static_cast(bottomLeft.height()); + if (radiiSum > static_cast(r.height())) + factor = min(static_cast(r.height()) / radiiSum, factor); + + // right + radiiSum = static_cast(topRight.height()) + static_cast(bottomRight.height()); + if (radiiSum > static_cast(r.height())) + factor = min(static_cast(r.height()) / radiiSum, factor); + + // Scale all radii by f if necessary. + if (factor < 1) { + // If either radius on a corner becomes zero, reset both radii on that corner. + topLeft.scale(factor); + if (!topLeft.width() || !topLeft.height()) + topLeft = IntSize(); + topRight.scale(factor); + if (!topRight.width() || !topRight.height()) + topRight = IntSize(); + bottomLeft.scale(factor); + if (!bottomLeft.width() || !bottomLeft.height()) + bottomLeft = IntSize(); + bottomRight.scale(factor); + if (!bottomRight.width() || !bottomRight.height()) + bottomRight = IntSize(); + } +} + +void RenderStyle::getBorderRadiiForRect(const IntRect& r, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const +{ + topLeft = IntSize(surround->border.topLeft().width().calcValue(r.width()), surround->border.topLeft().height().calcValue(r.height())); + topRight = IntSize(surround->border.topRight().width().calcValue(r.width()), surround->border.topRight().height().calcValue(r.height())); + + bottomLeft = IntSize(surround->border.bottomLeft().width().calcValue(r.width()), surround->border.bottomLeft().height().calcValue(r.height())); + bottomRight = IntSize(surround->border.bottomRight().width().calcValue(r.width()), surround->border.bottomRight().height().calcValue(r.height())); + + constrainCornerRadiiForRect(r, topLeft, topRight, bottomLeft, bottomRight); +} + +void RenderStyle::getInnerBorderRadiiForRectWithBorderWidths(const IntRect& innerRect, unsigned short topWidth, unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth, IntSize& innerTopLeft, IntSize& innerTopRight, IntSize& innerBottomLeft, IntSize& innerBottomRight) const +{ + innerTopLeft = IntSize(surround->border.topLeft().width().calcValue(innerRect.width()), surround->border.topLeft().height().calcValue(innerRect.height())); + innerTopRight = IntSize(surround->border.topRight().width().calcValue(innerRect.width()), surround->border.topRight().height().calcValue(innerRect.height())); + innerBottomLeft = IntSize(surround->border.bottomLeft().width().calcValue(innerRect.width()), surround->border.bottomLeft().height().calcValue(innerRect.height())); + innerBottomRight = IntSize(surround->border.bottomRight().width().calcValue(innerRect.width()), surround->border.bottomRight().height().calcValue(innerRect.height())); + + + innerTopLeft.setWidth(max(0, innerTopLeft.width() - leftWidth)); + innerTopLeft.setHeight(max(0, innerTopLeft.height() - topWidth)); + + innerTopRight.setWidth(max(0, innerTopRight.width() - rightWidth)); + innerTopRight.setHeight(max(0, innerTopRight.height() - topWidth)); + + innerBottomLeft.setWidth(max(0, innerBottomLeft.width() - leftWidth)); + innerBottomLeft.setHeight(max(0, innerBottomLeft.height() - bottomWidth)); + + innerBottomRight.setWidth(max(0, innerBottomRight.width() - rightWidth)); + innerBottomRight.setHeight(max(0, innerBottomRight.height() - bottomWidth)); + + constrainCornerRadiiForRect(innerRect, innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight); +} + +const CounterDirectiveMap* RenderStyle::counterDirectives() const +{ + return rareNonInheritedData->m_counterDirectives.get(); +} + +CounterDirectiveMap& RenderStyle::accessCounterDirectives() +{ + OwnPtr& map = rareNonInheritedData.access()->m_counterDirectives; + if (!map) + map.set(new CounterDirectiveMap); + return *map.get(); +} + +const AtomicString& RenderStyle::hyphenString() const +{ + ASSERT(hyphens() != HyphensNone); + + const AtomicString& hyphenationString = rareInheritedData.get()->hyphenationString; + if (!hyphenationString.isNull()) + return hyphenationString; + + // FIXME: This should depend on locale. + DEFINE_STATIC_LOCAL(AtomicString, hyphenMinusString, (&hyphenMinus, 1)); + DEFINE_STATIC_LOCAL(AtomicString, hyphenString, (&hyphen, 1)); + return font().primaryFontHasGlyphForCharacter(hyphen) ? hyphenString : hyphenMinusString; +} + +const AtomicString& RenderStyle::textEmphasisMarkString() const +{ + switch (textEmphasisMark()) { + case TextEmphasisMarkNone: + return nullAtom; + case TextEmphasisMarkCustom: + return textEmphasisCustomMark(); + case TextEmphasisMarkDot: { + DEFINE_STATIC_LOCAL(AtomicString, filledDotString, (&bullet, 1)); + DEFINE_STATIC_LOCAL(AtomicString, openDotString, (&whiteBullet, 1)); + return textEmphasisFill() == TextEmphasisFillFilled ? filledDotString : openDotString; + } + case TextEmphasisMarkCircle: { + DEFINE_STATIC_LOCAL(AtomicString, filledCircleString, (&blackCircle, 1)); + DEFINE_STATIC_LOCAL(AtomicString, openCircleString, (&whiteCircle, 1)); + return textEmphasisFill() == TextEmphasisFillFilled ? filledCircleString : openCircleString; + } + case TextEmphasisMarkDoubleCircle: { + DEFINE_STATIC_LOCAL(AtomicString, filledDoubleCircleString, (&fisheye, 1)); + DEFINE_STATIC_LOCAL(AtomicString, openDoubleCircleString, (&bullseye, 1)); + return textEmphasisFill() == TextEmphasisFillFilled ? filledDoubleCircleString : openDoubleCircleString; + } + case TextEmphasisMarkTriangle: { + DEFINE_STATIC_LOCAL(AtomicString, filledTriangleString, (&blackUpPointingTriangle, 1)); + DEFINE_STATIC_LOCAL(AtomicString, openTriangleString, (&whiteUpPointingTriangle, 1)); + return textEmphasisFill() == TextEmphasisFillFilled ? filledTriangleString : openTriangleString; + } + case TextEmphasisMarkSesame: { + DEFINE_STATIC_LOCAL(AtomicString, filledSesameString, (&sesameDot, 1)); + DEFINE_STATIC_LOCAL(AtomicString, openSesameString, (&whiteSesameDot, 1)); + return textEmphasisFill() == TextEmphasisFillFilled ? filledSesameString : openSesameString; + } + case TextEmphasisMarkAuto: + ASSERT_NOT_REACHED(); + return nullAtom; + } + + ASSERT_NOT_REACHED(); + return nullAtom; +} + +#if ENABLE(DASHBOARD_SUPPORT) +const Vector& RenderStyle::initialDashboardRegions() +{ + DEFINE_STATIC_LOCAL(Vector, emptyList, ()); + return emptyList; +} + +const Vector& RenderStyle::noneDashboardRegions() +{ + DEFINE_STATIC_LOCAL(Vector, noneList, ()); + static bool noneListInitialized = false; + + if (!noneListInitialized) { + StyleDashboardRegion region; + region.label = ""; + region.offset.m_top = Length(); + region.offset.m_right = Length(); + region.offset.m_bottom = Length(); + region.offset.m_left = Length(); + region.type = StyleDashboardRegion::None; + noneList.append(region); + noneListInitialized = true; + } + return noneList; +} +#endif + +void RenderStyle::adjustAnimations() +{ + AnimationList* animationList = rareNonInheritedData->m_animations.get(); + if (!animationList) + return; + + // Get rid of empty animations and anything beyond them + for (size_t i = 0; i < animationList->size(); ++i) { + if (animationList->animation(i)->isEmpty()) { + animationList->resize(i); + break; + } + } + + if (animationList->isEmpty()) { + clearAnimations(); + return; + } + + // Repeat patterns into layers that don't have some properties set. + animationList->fillUnsetProperties(); +} + +void RenderStyle::adjustTransitions() +{ + AnimationList* transitionList = rareNonInheritedData->m_transitions.get(); + if (!transitionList) + return; + + // Get rid of empty transitions and anything beyond them + for (size_t i = 0; i < transitionList->size(); ++i) { + if (transitionList->animation(i)->isEmpty()) { + transitionList->resize(i); + break; + } + } + + if (transitionList->isEmpty()) { + clearTransitions(); + return; + } + + // Repeat patterns into layers that don't have some properties set. + transitionList->fillUnsetProperties(); + + // Make sure there are no duplicate properties. This is an O(n^2) algorithm + // but the lists tend to be very short, so it is probably ok + for (size_t i = 0; i < transitionList->size(); ++i) { + for (size_t j = i+1; j < transitionList->size(); ++j) { + if (transitionList->animation(i)->property() == transitionList->animation(j)->property()) { + // toss i + transitionList->remove(i); + j = i; + } + } + } +} + +AnimationList* RenderStyle::accessAnimations() +{ + if (!rareNonInheritedData.access()->m_animations) + rareNonInheritedData.access()->m_animations.set(new AnimationList()); + return rareNonInheritedData->m_animations.get(); +} + +AnimationList* RenderStyle::accessTransitions() +{ + if (!rareNonInheritedData.access()->m_transitions) + rareNonInheritedData.access()->m_transitions.set(new AnimationList()); + return rareNonInheritedData->m_transitions.get(); +} + +const Animation* RenderStyle::transitionForProperty(int property) const +{ + if (transitions()) { + for (size_t i = 0; i < transitions()->size(); ++i) { + const Animation* p = transitions()->animation(i); + if (p->property() == cAnimateAll || p->property() == property) { + return p; + } + } + } + return 0; +} + +void RenderStyle::setBlendedFontSize(int size) +{ + FontSelector* currentFontSelector = font().fontSelector(); + FontDescription desc(fontDescription()); + desc.setSpecifiedSize(size); + desc.setComputedSize(size); + setFontDescription(desc); + font().update(currentFontSelector); +} + +void RenderStyle::getShadowExtent(const ShadowData* shadow, int &top, int &right, int &bottom, int &left) const +{ + top = 0; + right = 0; + bottom = 0; + left = 0; + + for ( ; shadow; shadow = shadow->next()) { + if (shadow->style() == Inset) + continue; + int blurAndSpread = shadow->blur() + shadow->spread(); + + top = min(top, shadow->y() - blurAndSpread); + right = max(right, shadow->x() + blurAndSpread); + bottom = max(bottom, shadow->y() + blurAndSpread); + left = min(left, shadow->x() - blurAndSpread); + } +} + +void RenderStyle::getShadowHorizontalExtent(const ShadowData* shadow, int &left, int &right) const +{ + left = 0; + right = 0; + + for ( ; shadow; shadow = shadow->next()) { + if (shadow->style() == Inset) + continue; + int blurAndSpread = shadow->blur() + shadow->spread(); + + left = min(left, shadow->x() - blurAndSpread); + right = max(right, shadow->x() + blurAndSpread); + } +} + +void RenderStyle::getShadowVerticalExtent(const ShadowData* shadow, int &top, int &bottom) const +{ + top = 0; + bottom = 0; + + for ( ; shadow; shadow = shadow->next()) { + if (shadow->style() == Inset) + continue; + int blurAndSpread = shadow->blur() + shadow->spread(); + + top = min(top, shadow->y() - blurAndSpread); + bottom = max(bottom, shadow->y() + blurAndSpread); + } +} + +static EBorderStyle borderStyleForColorProperty(const RenderStyle* style, int colorProperty) +{ + EBorderStyle borderStyle; + switch (colorProperty) { + case CSSPropertyBorderLeftColor: + borderStyle = style->borderLeftStyle(); + break; + case CSSPropertyBorderRightColor: + borderStyle = style->borderRightStyle(); + break; + case CSSPropertyBorderTopColor: + borderStyle = style->borderTopStyle(); + break; + case CSSPropertyBorderBottomColor: + borderStyle = style->borderBottomStyle(); + break; + default: + borderStyle = BNONE; + break; + } + return borderStyle; +} + +const Color RenderStyle::colorIncludingFallback(int colorProperty, EBorderStyle borderStyle) const +{ + Color result; + switch (colorProperty) { + case CSSPropertyBackgroundColor: + return backgroundColor(); // Background color doesn't fall back. + case CSSPropertyBorderLeftColor: + result = borderLeftColor(); + borderStyle = borderLeftStyle(); + break; + case CSSPropertyBorderRightColor: + result = borderRightColor(); + borderStyle = borderRightStyle(); + break; + case CSSPropertyBorderTopColor: + result = borderTopColor(); + borderStyle = borderTopStyle(); + break; + case CSSPropertyBorderBottomColor: + result = borderBottomColor(); + borderStyle = borderBottomStyle(); + break; + case CSSPropertyColor: + result = color(); + break; + case CSSPropertyOutlineColor: + result = outlineColor(); + break; + case CSSPropertyWebkitColumnRuleColor: + result = columnRuleColor(); + break; + case CSSPropertyWebkitTextEmphasisColor: + result = textEmphasisColor(); + break; + case CSSPropertyWebkitTextFillColor: + result = textFillColor(); + break; + case CSSPropertyWebkitTextStrokeColor: + result = textStrokeColor(); + break; + default: + ASSERT_NOT_REACHED(); + break; + } + + if (!result.isValid()) { + if ((colorProperty == CSSPropertyBorderLeftColor || colorProperty == CSSPropertyBorderRightColor + || colorProperty == CSSPropertyBorderTopColor || colorProperty == CSSPropertyBorderBottomColor) + && (borderStyle == INSET || borderStyle == OUTSET || borderStyle == RIDGE || borderStyle == GROOVE)) + result.setRGB(238, 238, 238); + else + result = color(); + } + + return result; +} + +const Color RenderStyle::visitedDependentColor(int colorProperty) const +{ + EBorderStyle borderStyle = borderStyleForColorProperty(this, colorProperty); + Color unvisitedColor = colorIncludingFallback(colorProperty, borderStyle); + if (insideLink() != InsideVisitedLink) + return unvisitedColor; + + RenderStyle* visitedStyle = getCachedPseudoStyle(VISITED_LINK); + if (!visitedStyle) + return unvisitedColor; + Color visitedColor = visitedStyle->colorIncludingFallback(colorProperty, borderStyle); + + // Take the alpha from the unvisited color, but get the RGB values from the visited color. + return Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), unvisitedColor.alpha()); +} + +Length RenderStyle::logicalWidth() const +{ + if (isHorizontalWritingMode()) + return width(); + return height(); +} + +Length RenderStyle::logicalHeight() const +{ + if (isHorizontalWritingMode()) + return height(); + return width(); +} + +Length RenderStyle::logicalMinWidth() const +{ + if (isHorizontalWritingMode()) + return minWidth(); + return minHeight(); +} + +Length RenderStyle::logicalMaxWidth() const +{ + if (isHorizontalWritingMode()) + return maxWidth(); + return maxHeight(); +} + +Length RenderStyle::logicalMinHeight() const +{ + if (isHorizontalWritingMode()) + return minHeight(); + return minWidth(); +} + +Length RenderStyle::logicalMaxHeight() const +{ + if (isHorizontalWritingMode()) + return maxHeight(); + return maxWidth(); +} + +const BorderValue& RenderStyle::borderBefore() const +{ + switch (writingMode()) { + case TopToBottomWritingMode: + return borderTop(); + case BottomToTopWritingMode: + return borderBottom(); + case LeftToRightWritingMode: + return borderLeft(); + case RightToLeftWritingMode: + return borderRight(); + } + ASSERT_NOT_REACHED(); + return borderTop(); +} + +const BorderValue& RenderStyle::borderAfter() const +{ + switch (writingMode()) { + case TopToBottomWritingMode: + return borderBottom(); + case BottomToTopWritingMode: + return borderTop(); + case LeftToRightWritingMode: + return borderRight(); + case RightToLeftWritingMode: + return borderLeft(); + } + ASSERT_NOT_REACHED(); + return borderBottom(); +} + +const BorderValue& RenderStyle::borderStart() const +{ + if (isHorizontalWritingMode()) + return isLeftToRightDirection() ? borderLeft() : borderRight(); + return isLeftToRightDirection() ? borderTop() : borderBottom(); +} + +const BorderValue& RenderStyle::borderEnd() const +{ + if (isHorizontalWritingMode()) + return isLeftToRightDirection() ? borderRight() : borderLeft(); + return isLeftToRightDirection() ? borderBottom() : borderTop(); +} + +unsigned short RenderStyle::borderBeforeWidth() const +{ + switch (writingMode()) { + case TopToBottomWritingMode: + return borderTopWidth(); + case BottomToTopWritingMode: + return borderBottomWidth(); + case LeftToRightWritingMode: + return borderLeftWidth(); + case RightToLeftWritingMode: + return borderRightWidth(); + } + ASSERT_NOT_REACHED(); + return borderTopWidth(); +} + +unsigned short RenderStyle::borderAfterWidth() const +{ + switch (writingMode()) { + case TopToBottomWritingMode: + return borderBottomWidth(); + case BottomToTopWritingMode: + return borderTopWidth(); + case LeftToRightWritingMode: + return borderRightWidth(); + case RightToLeftWritingMode: + return borderLeftWidth(); + } + ASSERT_NOT_REACHED(); + return borderBottomWidth(); +} + +unsigned short RenderStyle::borderStartWidth() const +{ + if (isHorizontalWritingMode()) + return isLeftToRightDirection() ? borderLeftWidth() : borderRightWidth(); + return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth(); +} + +unsigned short RenderStyle::borderEndWidth() const +{ + if (isHorizontalWritingMode()) + return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth(); + return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth(); +} + +Length RenderStyle::marginBefore() const +{ + switch (writingMode()) { + case TopToBottomWritingMode: + return marginTop(); + case BottomToTopWritingMode: + return marginBottom(); + case LeftToRightWritingMode: + return marginLeft(); + case RightToLeftWritingMode: + return marginRight(); + } + ASSERT_NOT_REACHED(); + return marginTop(); +} + +Length RenderStyle::marginAfter() const +{ + switch (writingMode()) { + case TopToBottomWritingMode: + return marginBottom(); + case BottomToTopWritingMode: + return marginTop(); + case LeftToRightWritingMode: + return marginRight(); + case RightToLeftWritingMode: + return marginLeft(); + } + ASSERT_NOT_REACHED(); + return marginBottom(); +} + +Length RenderStyle::marginBeforeUsing(const RenderStyle* otherStyle) const +{ + switch (otherStyle->writingMode()) { + case TopToBottomWritingMode: + return marginTop(); + case BottomToTopWritingMode: + return marginBottom(); + case LeftToRightWritingMode: + return marginLeft(); + case RightToLeftWritingMode: + return marginRight(); + } + ASSERT_NOT_REACHED(); + return marginTop(); +} + +Length RenderStyle::marginAfterUsing(const RenderStyle* otherStyle) const +{ + switch (otherStyle->writingMode()) { + case TopToBottomWritingMode: + return marginBottom(); + case BottomToTopWritingMode: + return marginTop(); + case LeftToRightWritingMode: + return marginRight(); + case RightToLeftWritingMode: + return marginLeft(); + } + ASSERT_NOT_REACHED(); + return marginBottom(); +} + +Length RenderStyle::marginStart() const +{ + if (isHorizontalWritingMode()) + return isLeftToRightDirection() ? marginLeft() : marginRight(); + return isLeftToRightDirection() ? marginTop() : marginBottom(); +} + +Length RenderStyle::marginEnd() const +{ + if (isHorizontalWritingMode()) + return isLeftToRightDirection() ? marginRight() : marginLeft(); + return isLeftToRightDirection() ? marginBottom() : marginTop(); +} + +Length RenderStyle::marginStartUsing(const RenderStyle* otherStyle) const +{ + if (otherStyle->isHorizontalWritingMode()) + return otherStyle->isLeftToRightDirection() ? marginLeft() : marginRight(); + return otherStyle->isLeftToRightDirection() ? marginTop() : marginBottom(); +} + +Length RenderStyle::marginEndUsing(const RenderStyle* otherStyle) const +{ + if (otherStyle->isHorizontalWritingMode()) + return otherStyle->isLeftToRightDirection() ? marginRight() : marginLeft(); + return otherStyle->isLeftToRightDirection() ? marginBottom() : marginTop(); +} + +void RenderStyle::setMarginStart(Length margin) +{ + if (isHorizontalWritingMode()) { + if (isLeftToRightDirection()) + setMarginLeft(margin); + else + setMarginRight(margin); + } else { + if (isLeftToRightDirection()) + setMarginTop(margin); + else + setMarginBottom(margin); + } +} + +void RenderStyle::setMarginEnd(Length margin) +{ + if (isHorizontalWritingMode()) { + if (isLeftToRightDirection()) + setMarginRight(margin); + else + setMarginLeft(margin); + } else { + if (isLeftToRightDirection()) + setMarginBottom(margin); + else + setMarginTop(margin); + } +} + +Length RenderStyle::paddingBefore() const +{ + switch (writingMode()) { + case TopToBottomWritingMode: + return paddingTop(); + case BottomToTopWritingMode: + return paddingBottom(); + case LeftToRightWritingMode: + return paddingLeft(); + case RightToLeftWritingMode: + return paddingRight(); + } + ASSERT_NOT_REACHED(); + return paddingTop(); +} + +Length RenderStyle::paddingAfter() const +{ + switch (writingMode()) { + case TopToBottomWritingMode: + return paddingBottom(); + case BottomToTopWritingMode: + return paddingTop(); + case LeftToRightWritingMode: + return paddingRight(); + case RightToLeftWritingMode: + return paddingLeft(); + } + ASSERT_NOT_REACHED(); + return paddingBottom(); +} + +Length RenderStyle::paddingStart() const +{ + if (isHorizontalWritingMode()) + return isLeftToRightDirection() ? paddingLeft() : paddingRight(); + return isLeftToRightDirection() ? paddingTop() : paddingBottom(); +} + +Length RenderStyle::paddingEnd() const +{ + if (isHorizontalWritingMode()) + return isLeftToRightDirection() ? paddingRight() : paddingLeft(); + return isLeftToRightDirection() ? paddingBottom() : paddingTop(); +} + +TextEmphasisMark RenderStyle::textEmphasisMark() const +{ + TextEmphasisMark mark = static_cast(rareInheritedData->textEmphasisMark); + if (mark != TextEmphasisMarkAuto) + return mark; + + if (isHorizontalWritingMode()) + return TextEmphasisMarkDot; + + return TextEmphasisMarkSesame; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h new file mode 100644 index 0000000..7e61e46 --- /dev/null +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -0,0 +1,1409 @@ +/* + * 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, 2009, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 RenderStyle_h +#define RenderStyle_h + +#include "TransformationMatrix.h" +#include "AnimationList.h" +#include "BorderData.h" +#include "BorderValue.h" +#include "CSSImageGeneratorValue.h" +#include "CSSPrimitiveValue.h" +#include "CSSPropertyNames.h" +#include "CSSReflectionDirection.h" +#include "CSSValueList.h" +#include "CollapsedBorderValue.h" +#include "Color.h" +#include "ColorSpace.h" +#include "ContentData.h" +#include "CounterDirectives.h" +#include "CursorList.h" +#include "DataRef.h" +#include "FillLayer.h" +#include "FloatPoint.h" +#include "Font.h" +#include "GraphicsTypes.h" +#include "IntRect.h" +#include "Length.h" +#include "LengthBox.h" +#include "LengthSize.h" +#include "LineClampValue.h" +#include "NinePieceImage.h" +#include "OutlineValue.h" +#include "Pair.h" +#include "RenderStyleConstants.h" +#include "ShadowData.h" +#include "StyleBackgroundData.h" +#include "StyleBoxData.h" +#include "StyleFlexibleBoxData.h" +#include "StyleInheritedData.h" +#include "StyleMarqueeData.h" +#include "StyleMultiColData.h" +#include "StyleRareInheritedData.h" +#include "StyleRareNonInheritedData.h" +#include "StyleReflection.h" +#include "StyleSurroundData.h" +#include "StyleTransformData.h" +#include "StyleVisualData.h" +#include "TextDirection.h" +#include "ThemeTypes.h" +#include "TimingFunction.h" +#include "TransformOperations.h" +#include +#include +#include +#include +#include + +#if ENABLE(DASHBOARD_SUPPORT) +#include "StyleDashboardRegion.h" +#endif + +#if ENABLE(SVG) +#include "SVGRenderStyle.h" +#endif + +#if COMPILER(WINSCW) +#define compareEqual(t, u) ((t) == (u)) +#else +template inline bool compareEqual(const T& t, const U& u) { return t == static_cast(u); } +#endif + +#define SET_VAR(group, variable, value) \ + if (!compareEqual(group->variable, value)) \ + group.access()->variable = value; + +namespace WebCore { + +using std::max; + +class CSSStyleSelector; +class CSSValueList; +class Pair; +class StyleImage; + +typedef Vector, 4> PseudoStyleCache; + +class RenderStyle: public RefCounted { + friend class AnimationBase; // Used by CSS animations. We can't allow them to animate based off visited colors. + friend class ApplyStyleCommand; // Editing has to only reveal unvisited info. + friend class EditingStyle; // Editing has to only reveal unvisited info. + friend class CSSStyleSelector; // Sets members directly. + friend class CSSComputedStyleDeclaration; // Ignores visited styles, so needs to be able to see unvisited info. + friend class PropertyWrapperMaybeInvalidColor; // Used by CSS animations. We can't allow them to animate based off visited colors. + friend class RenderSVGResource; // FIXME: Needs to alter the visited state by hand. Should clean the SVG code up and move it into RenderStyle perhaps. + friend class RenderTreeAsText; // FIXME: Only needed so the render tree can keep lying and dump the wrong colors. Rebaselining would allow this to be yanked. +protected: + + // The following bitfield is 32-bits long, which optimizes padding with the + // int refCount in the base class. Beware when adding more bits. + bool m_affectedByAttributeSelectors : 1; + bool m_unique : 1; + + // Bits for dynamic child matching. + bool m_affectedByEmpty : 1; + bool m_emptyState : 1; + + // We optimize for :first-child and :last-child. The other positional child selectors like nth-child or + // *-child-of-type, we will just give up and re-evaluate whenever children change at all. + bool m_childrenAffectedByFirstChildRules : 1; + bool m_childrenAffectedByLastChildRules : 1; + bool m_childrenAffectedByDirectAdjacentRules : 1; + bool m_childrenAffectedByForwardPositionalRules : 1; + bool m_childrenAffectedByBackwardPositionalRules : 1; + bool m_firstChildState : 1; + bool m_lastChildState : 1; + unsigned m_childIndex : 21; // Plenty of bits to cache an index. + + // non-inherited attributes + DataRef m_box; + DataRef visual; + DataRef m_background; + DataRef surround; + DataRef rareNonInheritedData; + + // inherited attributes + DataRef rareInheritedData; + DataRef inherited; + + // list of associated pseudo styles + OwnPtr m_cachedPseudoStyles; + +#if ENABLE(SVG) + DataRef m_svgStyle; +#endif + +// !START SYNC!: Keep this in sync with the copy constructor in RenderStyle.cpp + + // inherit + struct InheritedFlags { + bool operator==(const InheritedFlags& other) const + { + return (_empty_cells == other._empty_cells) && + (_caption_side == other._caption_side) && + (_list_style_type == other._list_style_type) && + (_list_style_position == other._list_style_position) && + (_visibility == other._visibility) && + (_text_align == other._text_align) && + (_text_transform == other._text_transform) && + (_text_decorations == other._text_decorations) && + (_text_transform == other._text_transform) && + (_cursor_style == other._cursor_style) && + (_direction == other._direction) && + (_border_collapse == other._border_collapse) && + (_white_space == other._white_space) && + (_box_direction == other._box_direction) && + (_visuallyOrdered == other._visuallyOrdered) && + (_force_backgrounds_to_white == other._force_backgrounds_to_white) && + (_pointerEvents == other._pointerEvents) && + (_insideLink == other._insideLink) && + (m_writingMode == other.m_writingMode); + } + + bool operator!=(const InheritedFlags& other) const { return !(*this == other); } + + unsigned _empty_cells : 1; // EEmptyCell + unsigned _caption_side : 2; // ECaptionSide + unsigned _list_style_type : 7; // EListStyleType + unsigned _list_style_position : 1; // EListStylePosition + unsigned _visibility : 2; // EVisibility + unsigned _text_align : 3; // ETextAlign + unsigned _text_transform : 2; // ETextTransform + unsigned _text_decorations : 4; + unsigned _cursor_style : 6; // ECursor + unsigned _direction : 1; // TextDirection + bool _border_collapse : 1 ; + unsigned _white_space : 3; // EWhiteSpace + unsigned _box_direction : 1; // EBoxDirection (CSS3 box_direction property, flexible box layout module) + // 34 bits + + // non CSS2 inherited + bool _visuallyOrdered : 1; + bool _force_backgrounds_to_white : 1; + unsigned _pointerEvents : 4; // EPointerEvents + unsigned _insideLink : 2; // EInsideLink + // 43 bits + + // CSS Text Layout Module Level 3: Vertical writing support + unsigned m_writingMode : 2; // WritingMode + // 45 bits + } inherited_flags; + +// don't inherit + struct NonInheritedFlags { + bool operator==(const NonInheritedFlags& other) const + { + return _effectiveDisplay == other._effectiveDisplay + && _originalDisplay == other._originalDisplay + && _overflowX == other._overflowX + && _overflowY == other._overflowY + && _vertical_align == other._vertical_align + && _clear == other._clear + && _position == other._position + && _floating == other._floating + && _table_layout == other._table_layout + && _page_break_before == other._page_break_before + && _page_break_after == other._page_break_after + && _page_break_inside == other._page_break_inside + && _styleType == other._styleType + && _affectedByHover == other._affectedByHover + && _affectedByActive == other._affectedByActive + && _affectedByDrag == other._affectedByDrag + && _pseudoBits == other._pseudoBits + && _unicodeBidi == other._unicodeBidi + && _isLink == other._isLink; + } + + bool operator!=(const NonInheritedFlags& other) const { return !(*this == other); } + + unsigned _effectiveDisplay : 5; // EDisplay + unsigned _originalDisplay : 5; // EDisplay + unsigned _overflowX : 3; // EOverflow + unsigned _overflowY : 3; // EOverflow + unsigned _vertical_align : 4; // EVerticalAlign + unsigned _clear : 2; // EClear + unsigned _position : 2; // EPosition + unsigned _floating : 2; // EFloat + unsigned _table_layout : 1; // ETableLayout + + unsigned _page_break_before : 2; // EPageBreak + unsigned _page_break_after : 2; // EPageBreak + unsigned _page_break_inside : 2; // EPageBreak + + unsigned _styleType : 6; // PseudoId + bool _affectedByHover : 1; + bool _affectedByActive : 1; + bool _affectedByDrag : 1; + unsigned _pseudoBits : 7; + unsigned _unicodeBidi : 2; // EUnicodeBidi + bool _isLink : 1; + // 50 bits + } noninherited_flags; + +// !END SYNC! + +protected: + void setBitDefaults() + { + inherited_flags._empty_cells = initialEmptyCells(); + inherited_flags._caption_side = initialCaptionSide(); + inherited_flags._list_style_type = initialListStyleType(); + inherited_flags._list_style_position = initialListStylePosition(); + inherited_flags._visibility = initialVisibility(); + inherited_flags._text_align = initialTextAlign(); + inherited_flags._text_transform = initialTextTransform(); + inherited_flags._text_decorations = initialTextDecoration(); + inherited_flags._cursor_style = initialCursor(); + inherited_flags._direction = initialDirection(); + inherited_flags._border_collapse = initialBorderCollapse(); + inherited_flags._white_space = initialWhiteSpace(); + inherited_flags._visuallyOrdered = initialVisuallyOrdered(); + inherited_flags._box_direction = initialBoxDirection(); + inherited_flags._force_backgrounds_to_white = false; + inherited_flags._pointerEvents = initialPointerEvents(); + inherited_flags._insideLink = NotInsideLink; + inherited_flags.m_writingMode = initialWritingMode(); + + noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = initialDisplay(); + noninherited_flags._overflowX = initialOverflowX(); + noninherited_flags._overflowY = initialOverflowY(); + noninherited_flags._vertical_align = initialVerticalAlign(); + noninherited_flags._clear = initialClear(); + noninherited_flags._position = initialPosition(); + noninherited_flags._floating = initialFloating(); + noninherited_flags._table_layout = initialTableLayout(); + noninherited_flags._page_break_before = initialPageBreak(); + noninherited_flags._page_break_after = initialPageBreak(); + noninherited_flags._page_break_inside = initialPageBreak(); + noninherited_flags._styleType = NOPSEUDO; + noninherited_flags._affectedByHover = false; + noninherited_flags._affectedByActive = false; + noninherited_flags._affectedByDrag = false; + noninherited_flags._pseudoBits = 0; + noninherited_flags._unicodeBidi = initialUnicodeBidi(); + noninherited_flags._isLink = false; + } + +private: + ALWAYS_INLINE RenderStyle(); + // used to create the default style. + ALWAYS_INLINE RenderStyle(bool); + ALWAYS_INLINE RenderStyle(const RenderStyle&); + +public: + static PassRefPtr create(); + static PassRefPtr createDefaultStyle(); + static PassRefPtr clone(const RenderStyle*); + + ~RenderStyle(); + + void inheritFrom(const RenderStyle* inheritParent); + + PseudoId styleType() const { return static_cast(noninherited_flags._styleType); } + void setStyleType(PseudoId styleType) { noninherited_flags._styleType = styleType; } + + RenderStyle* getCachedPseudoStyle(PseudoId) const; + RenderStyle* addCachedPseudoStyle(PassRefPtr); + void removeCachedPseudoStyle(PseudoId); + + const PseudoStyleCache* cachedPseudoStyles() const { return m_cachedPseudoStyles.get(); } + + bool affectedByHoverRules() const { return noninherited_flags._affectedByHover; } + bool affectedByActiveRules() const { return noninherited_flags._affectedByActive; } + bool affectedByDragRules() const { return noninherited_flags._affectedByDrag; } + + void setAffectedByHoverRules(bool b) { noninherited_flags._affectedByHover = b; } + void setAffectedByActiveRules(bool b) { noninherited_flags._affectedByActive = b; } + void setAffectedByDragRules(bool b) { noninherited_flags._affectedByDrag = b; } + + bool operator==(const RenderStyle& other) const; + bool operator!=(const RenderStyle& other) const { return !(*this == other); } + bool isFloating() const { return !(noninherited_flags._floating == FNONE); } + bool hasMargin() const { return surround->margin.nonZero(); } + bool hasBorder() const { return surround->border.hasBorder(); } + bool hasPadding() const { return surround->padding.nonZero(); } + bool hasOffset() const { return surround->offset.nonZero(); } + + bool hasBackgroundImage() const { return m_background->background().hasImage(); } + bool hasFixedBackgroundImage() const { return m_background->background().hasFixedImage(); } + bool hasAppearance() const { return appearance() != NoControlPart; } + + bool hasBackground() const + { + Color color = visitedDependentColor(CSSPropertyBackgroundColor); + if (color.isValid() && color.alpha() > 0) + return true; + return hasBackgroundImage(); + } + + bool visuallyOrdered() const { return inherited_flags._visuallyOrdered; } + void setVisuallyOrdered(bool b) { inherited_flags._visuallyOrdered = b; } + + bool isStyleAvailable() const; + + bool hasAnyPublicPseudoStyles() const; + bool hasPseudoStyle(PseudoId pseudo) const; + void setHasPseudoStyle(PseudoId pseudo); + + // attribute getter methods + + EDisplay display() const { return static_cast(noninherited_flags._effectiveDisplay); } + EDisplay originalDisplay() const { return static_cast(noninherited_flags._originalDisplay); } + + Length left() const { return surround->offset.left(); } + Length right() const { return surround->offset.right(); } + Length top() const { return surround->offset.top(); } + Length bottom() const { return surround->offset.bottom(); } + + // Whether or not a positioned element requires normal flow x/y to be computed + // to determine its position. + bool hasStaticX() const { return (left().isAuto() && right().isAuto()) || left().isStatic() || right().isStatic(); } + bool hasStaticY() const { return (top().isAuto() && bottom().isAuto()) || top().isStatic(); } + + EPosition position() const { return static_cast(noninherited_flags._position); } + EFloat floating() const { return static_cast(noninherited_flags._floating); } + + Length width() const { return m_box->width(); } + Length height() const { return m_box->height(); } + Length minWidth() const { return m_box->minWidth(); } + Length maxWidth() const { return m_box->maxWidth(); } + Length minHeight() const { return m_box->minHeight(); } + Length maxHeight() const { return m_box->maxHeight(); } + + Length logicalWidth() const; + Length logicalHeight() const; + Length logicalMinWidth() const; + Length logicalMaxWidth() const; + Length logicalMinHeight() const; + Length logicalMaxHeight() const; + + const BorderData& border() const { return surround->border; } + const BorderValue& borderLeft() const { return surround->border.left(); } + const BorderValue& borderRight() const { return surround->border.right(); } + const BorderValue& borderTop() const { return surround->border.top(); } + const BorderValue& borderBottom() const { return surround->border.bottom(); } + + const BorderValue& borderBefore() const; + const BorderValue& borderAfter() const; + const BorderValue& borderStart() const; + const BorderValue& borderEnd() const; + + const NinePieceImage& borderImage() const { return surround->border.image(); } + + const LengthSize& borderTopLeftRadius() const { return surround->border.topLeft(); } + const LengthSize& borderTopRightRadius() const { return surround->border.topRight(); } + const LengthSize& borderBottomLeftRadius() const { return surround->border.bottomLeft(); } + const LengthSize& borderBottomRightRadius() const { return surround->border.bottomRight(); } + bool hasBorderRadius() const { return surround->border.hasBorderRadius(); } + + unsigned short borderLeftWidth() const { return surround->border.borderLeftWidth(); } + EBorderStyle borderLeftStyle() const { return surround->border.left().style(); } + bool borderLeftIsTransparent() const { return surround->border.left().isTransparent(); } + unsigned short borderRightWidth() const { return surround->border.borderRightWidth(); } + EBorderStyle borderRightStyle() const { return surround->border.right().style(); } + bool borderRightIsTransparent() const { return surround->border.right().isTransparent(); } + unsigned short borderTopWidth() const { return surround->border.borderTopWidth(); } + EBorderStyle borderTopStyle() const { return surround->border.top().style(); } + bool borderTopIsTransparent() const { return surround->border.top().isTransparent(); } + unsigned short borderBottomWidth() const { return surround->border.borderBottomWidth(); } + EBorderStyle borderBottomStyle() const { return surround->border.bottom().style(); } + bool borderBottomIsTransparent() const { return surround->border.bottom().isTransparent(); } + + unsigned short borderBeforeWidth() const; + unsigned short borderAfterWidth() const; + unsigned short borderStartWidth() const; + unsigned short borderEndWidth() const; + + unsigned short outlineSize() const { return max(0, outlineWidth() + outlineOffset()); } + unsigned short outlineWidth() const + { + if (m_background->outline().style() == BNONE) + return 0; + return m_background->outline().width(); + } + bool hasOutline() const { return outlineWidth() > 0 && outlineStyle() > BHIDDEN; } + EBorderStyle outlineStyle() const { return m_background->outline().style(); } + bool outlineStyleIsAuto() const { return m_background->outline().isAuto(); } + + EOverflow overflowX() const { return static_cast(noninherited_flags._overflowX); } + EOverflow overflowY() const { return static_cast(noninherited_flags._overflowY); } + + EVisibility visibility() const { return static_cast(inherited_flags._visibility); } + EVerticalAlign verticalAlign() const { return static_cast(noninherited_flags._vertical_align); } + Length verticalAlignLength() const { return m_box->verticalAlign(); } + + Length clipLeft() const { return visual->clip.left(); } + Length clipRight() const { return visual->clip.right(); } + Length clipTop() const { return visual->clip.top(); } + Length clipBottom() const { return visual->clip.bottom(); } + LengthBox clip() const { return visual->clip; } + bool hasClip() const { return visual->hasClip; } + + EUnicodeBidi unicodeBidi() const { return static_cast(noninherited_flags._unicodeBidi); } + + EClear clear() const { return static_cast(noninherited_flags._clear); } + ETableLayout tableLayout() const { return static_cast(noninherited_flags._table_layout); } + + const Font& font() const { return inherited->font; } + const FontDescription& fontDescription() const { return inherited->font.fontDescription(); } + int fontSize() const { return inherited->font.pixelSize(); } + + Length textIndent() const { return rareInheritedData->indent; } + ETextAlign textAlign() const { return static_cast(inherited_flags._text_align); } + ETextTransform textTransform() const { return static_cast(inherited_flags._text_transform); } + int textDecorationsInEffect() const { return inherited_flags._text_decorations; } + int textDecoration() const { return visual->textDecoration; } + int wordSpacing() const { return inherited->font.wordSpacing(); } + int letterSpacing() const { return inherited->font.letterSpacing(); } + + float zoom() const { return visual->m_zoom; } + float effectiveZoom() const { return rareInheritedData->m_effectiveZoom; } + + TextDirection direction() const { return static_cast(inherited_flags._direction); } + bool isLeftToRightDirection() const { return direction() == LTR; } + + Length lineHeight() const { return inherited->line_height; } + int computedLineHeight() const + { + Length lh = lineHeight(); + + // Negative value means the line height is not set. Use the font's built-in spacing. + if (lh.isNegative()) + return font().lineSpacing(); + + if (lh.isPercent()) + return lh.calcMinValue(fontSize()); + + return lh.value(); + } + + EWhiteSpace whiteSpace() const { return static_cast(inherited_flags._white_space); } + static bool autoWrap(EWhiteSpace ws) + { + // Nowrap and pre don't automatically wrap. + return ws != NOWRAP && ws != PRE; + } + + bool autoWrap() const + { + return autoWrap(whiteSpace()); + } + + static bool preserveNewline(EWhiteSpace ws) + { + // Normal and nowrap do not preserve newlines. + return ws != NORMAL && ws != NOWRAP; + } + + bool preserveNewline() const + { + return preserveNewline(whiteSpace()); + } + + static bool collapseWhiteSpace(EWhiteSpace ws) + { + // Pre and prewrap do not collapse whitespace. + return ws != PRE && ws != PRE_WRAP; + } + + bool collapseWhiteSpace() const + { + return collapseWhiteSpace(whiteSpace()); + } + + bool isCollapsibleWhiteSpace(UChar c) const + { + switch (c) { + case ' ': + case '\t': + return collapseWhiteSpace(); + case '\n': + return !preserveNewline(); + } + return false; + } + + bool breakOnlyAfterWhiteSpace() const + { + return whiteSpace() == PRE_WRAP || khtmlLineBreak() == AFTER_WHITE_SPACE; + } + + bool breakWords() const + { + return wordBreak() == BreakWordBreak || wordWrap() == BreakWordWrap; + } + + StyleImage* backgroundImage() const { return m_background->background().image(); } + EFillRepeat backgroundRepeatX() const { return static_cast(m_background->background().repeatX()); } + EFillRepeat backgroundRepeatY() const { return static_cast(m_background->background().repeatY()); } + CompositeOperator backgroundComposite() const { return static_cast(m_background->background().composite()); } + EFillAttachment backgroundAttachment() const { return static_cast(m_background->background().attachment()); } + EFillBox backgroundClip() const { return static_cast(m_background->background().clip()); } + EFillBox backgroundOrigin() const { return static_cast(m_background->background().origin()); } + Length backgroundXPosition() const { return m_background->background().xPosition(); } + Length backgroundYPosition() const { return m_background->background().yPosition(); } + EFillSizeType backgroundSizeType() const { return m_background->background().sizeType(); } + LengthSize backgroundSizeLength() const { return m_background->background().sizeLength(); } + FillLayer* accessBackgroundLayers() { return &(m_background.access()->m_background); } + const FillLayer* backgroundLayers() const { return &(m_background->background()); } + + StyleImage* maskImage() const { return rareNonInheritedData->m_mask.image(); } + EFillRepeat maskRepeatX() const { return static_cast(rareNonInheritedData->m_mask.repeatX()); } + EFillRepeat maskRepeatY() const { return static_cast(rareNonInheritedData->m_mask.repeatY()); } + CompositeOperator maskComposite() const { return static_cast(rareNonInheritedData->m_mask.composite()); } + EFillAttachment maskAttachment() const { return static_cast(rareNonInheritedData->m_mask.attachment()); } + EFillBox maskClip() const { return static_cast(rareNonInheritedData->m_mask.clip()); } + EFillBox maskOrigin() const { return static_cast(rareNonInheritedData->m_mask.origin()); } + Length maskXPosition() const { return rareNonInheritedData->m_mask.xPosition(); } + Length maskYPosition() const { return rareNonInheritedData->m_mask.yPosition(); } + EFillSizeType maskSizeType() const { return rareNonInheritedData->m_mask.sizeType(); } + LengthSize maskSizeLength() const { return rareNonInheritedData->m_mask.sizeLength(); } + FillLayer* accessMaskLayers() { return &(rareNonInheritedData.access()->m_mask); } + const FillLayer* maskLayers() const { return &(rareNonInheritedData->m_mask); } + const NinePieceImage& maskBoxImage() const { return rareNonInheritedData->m_maskBoxImage; } + + // returns true for collapsing borders, false for separate borders + bool borderCollapse() const { return inherited_flags._border_collapse; } + short horizontalBorderSpacing() const { return inherited->horizontal_border_spacing; } + short verticalBorderSpacing() const { return inherited->vertical_border_spacing; } + EEmptyCell emptyCells() const { return static_cast(inherited_flags._empty_cells); } + ECaptionSide captionSide() const { return static_cast(inherited_flags._caption_side); } + + short counterIncrement() const { return rareNonInheritedData->m_counterIncrement; } + short counterReset() const { return rareNonInheritedData->m_counterReset; } + + EListStyleType listStyleType() const { return static_cast(inherited_flags._list_style_type); } + StyleImage* listStyleImage() const { return inherited->list_style_image.get(); } + EListStylePosition listStylePosition() const { return static_cast(inherited_flags._list_style_position); } + + Length marginTop() const { return surround->margin.top(); } + Length marginBottom() const { return surround->margin.bottom(); } + Length marginLeft() const { return surround->margin.left(); } + Length marginRight() const { return surround->margin.right(); } + Length marginBefore() const; + Length marginAfter() const; + Length marginStart() const; + Length marginEnd() const; + Length marginStartUsing(const RenderStyle* otherStyle) const; + Length marginEndUsing(const RenderStyle* otherStyle) const; + Length marginBeforeUsing(const RenderStyle* otherStyle) const; + Length marginAfterUsing(const RenderStyle* otherStyle) const; + + LengthBox paddingBox() const { return surround->padding; } + Length paddingTop() const { return surround->padding.top(); } + Length paddingBottom() const { return surround->padding.bottom(); } + Length paddingLeft() const { return surround->padding.left(); } + Length paddingRight() const { return surround->padding.right(); } + Length paddingBefore() const; + Length paddingAfter() const; + Length paddingStart() const; + Length paddingEnd() const; + + ECursor cursor() const { return static_cast(inherited_flags._cursor_style); } + + CursorList* cursors() const { return rareInheritedData->cursorData.get(); } + + EInsideLink insideLink() const { return static_cast(inherited_flags._insideLink); } + bool isLink() const { return noninherited_flags._isLink; } + + short widows() const { return rareInheritedData->widows; } + short orphans() const { return rareInheritedData->orphans; } + EPageBreak pageBreakInside() const { return static_cast(noninherited_flags._page_break_inside); } + EPageBreak pageBreakBefore() const { return static_cast(noninherited_flags._page_break_before); } + EPageBreak pageBreakAfter() const { return static_cast(noninherited_flags._page_break_after); } + + // CSS3 Getter Methods + + int outlineOffset() const + { + if (m_background->outline().style() == BNONE) + return 0; + return m_background->outline().offset(); + } + + const ShadowData* textShadow() const { return rareInheritedData->textShadow; } + void getTextShadowExtent(int& top, int& right, int& bottom, int& left) const { getShadowExtent(textShadow(), top, right, bottom, left); } + void getTextShadowHorizontalExtent(int& left, int& right) const { getShadowHorizontalExtent(textShadow(), left, right); } + void getTextShadowVerticalExtent(int& top, int& bottom) const { getShadowVerticalExtent(textShadow(), top, bottom); } + void getTextShadowInlineDirectionExtent(int& logicalLeft, int& logicalRight) { getShadowInlineDirectionExtent(textShadow(), logicalLeft, logicalRight); } + void getTextShadowBlockDirectionExtent(int& logicalTop, int& logicalBottom) { getShadowBlockDirectionExtent(textShadow(), logicalTop, logicalBottom); } + + float textStrokeWidth() const { return rareInheritedData->textStrokeWidth; } + ColorSpace colorSpace() const { return static_cast(rareInheritedData->colorSpace); } + float opacity() const { return rareNonInheritedData->opacity; } + ControlPart appearance() const { return static_cast(rareNonInheritedData->m_appearance); } + EBoxAlignment boxAlign() const { return static_cast(rareNonInheritedData->flexibleBox->align); } + EBoxDirection boxDirection() const { return static_cast(inherited_flags._box_direction); } + float boxFlex() { return rareNonInheritedData->flexibleBox->flex; } + unsigned int boxFlexGroup() const { return rareNonInheritedData->flexibleBox->flex_group; } + EBoxLines boxLines() { return static_cast(rareNonInheritedData->flexibleBox->lines); } + unsigned int boxOrdinalGroup() const { return rareNonInheritedData->flexibleBox->ordinal_group; } + EBoxOrient boxOrient() const { return static_cast(rareNonInheritedData->flexibleBox->orient); } + EBoxAlignment boxPack() const { return static_cast(rareNonInheritedData->flexibleBox->pack); } + + const ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); } + void getBoxShadowExtent(int& top, int& right, int& bottom, int& left) const { getShadowExtent(boxShadow(), top, right, bottom, left); } + void getBoxShadowHorizontalExtent(int& left, int& right) const { getShadowHorizontalExtent(boxShadow(), left, right); } + void getBoxShadowVerticalExtent(int& top, int& bottom) const { getShadowVerticalExtent(boxShadow(), top, bottom); } + void getBoxShadowInlineDirectionExtent(int& logicalLeft, int& logicalRight) { getShadowInlineDirectionExtent(boxShadow(), logicalLeft, logicalRight); } + void getBoxShadowBlockDirectionExtent(int& logicalTop, int& logicalBottom) { getShadowBlockDirectionExtent(boxShadow(), logicalTop, logicalBottom); } + + StyleReflection* boxReflect() const { return rareNonInheritedData->m_boxReflect.get(); } + EBoxSizing boxSizing() const { return m_box->boxSizing(); } + Length marqueeIncrement() const { return rareNonInheritedData->marquee->increment; } + int marqueeSpeed() const { return rareNonInheritedData->marquee->speed; } + int marqueeLoopCount() const { return rareNonInheritedData->marquee->loops; } + EMarqueeBehavior marqueeBehavior() const { return static_cast(rareNonInheritedData->marquee->behavior); } + EMarqueeDirection marqueeDirection() const { return static_cast(rareNonInheritedData->marquee->direction); } + EUserModify userModify() const { return static_cast(rareInheritedData->userModify); } + EUserDrag userDrag() const { return static_cast(rareNonInheritedData->userDrag); } + EUserSelect userSelect() const { return static_cast(rareInheritedData->userSelect); } + bool textOverflow() const { return rareNonInheritedData->textOverflow; } + EMarginCollapse marginBeforeCollapse() const { return static_cast(rareNonInheritedData->marginBeforeCollapse); } + EMarginCollapse marginAfterCollapse() const { return static_cast(rareNonInheritedData->marginAfterCollapse); } + EWordBreak wordBreak() const { return static_cast(rareInheritedData->wordBreak); } + EWordWrap wordWrap() const { return static_cast(rareInheritedData->wordWrap); } + ENBSPMode nbspMode() const { return static_cast(rareInheritedData->nbspMode); } + EKHTMLLineBreak khtmlLineBreak() const { return static_cast(rareInheritedData->khtmlLineBreak); } + EMatchNearestMailBlockquoteColor matchNearestMailBlockquoteColor() const { return static_cast(rareNonInheritedData->matchNearestMailBlockquoteColor); } + const AtomicString& highlight() const { return rareInheritedData->highlight; } + Hyphens hyphens() const { return static_cast(rareInheritedData->hyphens); } + const AtomicString& hyphenationString() const { return rareInheritedData->hyphenationString; } + const AtomicString& hyphenationLocale() const { return rareInheritedData->hyphenationLocale; } + EBorderFit borderFit() const { return static_cast(rareNonInheritedData->m_borderFit); } + EResize resize() const { return static_cast(rareInheritedData->resize); } + float columnWidth() const { return rareNonInheritedData->m_multiCol->m_width; } + bool hasAutoColumnWidth() const { return rareNonInheritedData->m_multiCol->m_autoWidth; } + unsigned short columnCount() const { return rareNonInheritedData->m_multiCol->m_count; } + bool hasAutoColumnCount() const { return rareNonInheritedData->m_multiCol->m_autoCount; } + bool specifiesColumns() const { return !hasAutoColumnCount() || !hasAutoColumnWidth(); } + float columnGap() const { return rareNonInheritedData->m_multiCol->m_gap; } + bool hasNormalColumnGap() const { return rareNonInheritedData->m_multiCol->m_normalGap; } + EBorderStyle columnRuleStyle() const { return rareNonInheritedData->m_multiCol->m_rule.style(); } + unsigned short columnRuleWidth() const { return rareNonInheritedData->m_multiCol->ruleWidth(); } + bool columnRuleIsTransparent() const { return rareNonInheritedData->m_multiCol->m_rule.isTransparent(); } + bool columnSpan() const { return rareNonInheritedData->m_multiCol->m_columnSpan; } + EPageBreak columnBreakBefore() const { return static_cast(rareNonInheritedData->m_multiCol->m_breakBefore); } + EPageBreak columnBreakInside() const { return static_cast(rareNonInheritedData->m_multiCol->m_breakInside); } + EPageBreak columnBreakAfter() const { return static_cast(rareNonInheritedData->m_multiCol->m_breakAfter); } + const TransformOperations& transform() const { return rareNonInheritedData->m_transform->m_operations; } + Length transformOriginX() const { return rareNonInheritedData->m_transform->m_x; } + Length transformOriginY() const { return rareNonInheritedData->m_transform->m_y; } + float transformOriginZ() const { return rareNonInheritedData->m_transform->m_z; } + bool hasTransform() const { return !rareNonInheritedData->m_transform->m_operations.operations().isEmpty(); } + + TextEmphasisFill textEmphasisFill() const { return static_cast(rareInheritedData->textEmphasisFill); } + TextEmphasisMark textEmphasisMark() const; + const AtomicString& textEmphasisCustomMark() const { return rareInheritedData->textEmphasisCustomMark; } + TextEmphasisPosition textEmphasisPosition() const { return static_cast(rareInheritedData->textEmphasisPosition); } + const AtomicString& textEmphasisMarkString() const; + + // Return true if any transform related property (currently transform, transformStyle3D or perspective) + // indicates that we are transforming + bool hasTransformRelatedProperty() const { return hasTransform() || preserves3D() || hasPerspective(); } + + enum ApplyTransformOrigin { IncludeTransformOrigin, ExcludeTransformOrigin }; + void applyTransform(TransformationMatrix&, const IntSize& borderBoxSize, ApplyTransformOrigin = IncludeTransformOrigin) const; + void setPageScaleTransform(float); + + bool hasMask() const { return rareNonInheritedData->m_mask.hasImage() || rareNonInheritedData->m_maskBoxImage.hasImage(); } + + TextCombine textCombine() const { return static_cast(rareNonInheritedData->m_textCombine); } + // End CSS3 Getters + + // Apple-specific property getter methods + EPointerEvents pointerEvents() const { return static_cast(inherited_flags._pointerEvents); } + const AnimationList* animations() const { return rareNonInheritedData->m_animations.get(); } + const AnimationList* transitions() const { return rareNonInheritedData->m_transitions.get(); } + + AnimationList* accessAnimations(); + AnimationList* accessTransitions(); + + bool hasAnimations() const { return rareNonInheritedData->m_animations && rareNonInheritedData->m_animations->size() > 0; } + bool hasTransitions() const { return rareNonInheritedData->m_transitions && rareNonInheritedData->m_transitions->size() > 0; } + + // return the first found Animation (including 'all' transitions) + const Animation* transitionForProperty(int property) const; + + ETransformStyle3D transformStyle3D() const { return rareNonInheritedData->m_transformStyle3D; } + bool preserves3D() const { return rareNonInheritedData->m_transformStyle3D == TransformStyle3DPreserve3D; } + + EBackfaceVisibility backfaceVisibility() const { return rareNonInheritedData->m_backfaceVisibility; } + float perspective() const { return rareNonInheritedData->m_perspective; } + bool hasPerspective() const { return rareNonInheritedData->m_perspective > 0; } + Length perspectiveOriginX() const { return rareNonInheritedData->m_perspectiveOriginX; } + Length perspectiveOriginY() const { return rareNonInheritedData->m_perspectiveOriginY; } + LengthSize pageSize() const { return rareNonInheritedData->m_pageSize; } + PageSizeType pageSizeType() const { return rareNonInheritedData->m_pageSizeType; } + +#if USE(ACCELERATED_COMPOSITING) + // When set, this ensures that styles compare as different. Used during accelerated animations. + bool isRunningAcceleratedAnimation() const { return rareNonInheritedData->m_runningAcceleratedAnimation; } +#endif + + const LineClampValue& lineClamp() const { return rareNonInheritedData->lineClamp; } + bool textSizeAdjust() const { return rareInheritedData->textSizeAdjust; } + ETextSecurity textSecurity() const { return static_cast(rareInheritedData->textSecurity); } + + WritingMode writingMode() const { return static_cast(inherited_flags.m_writingMode); } + bool isHorizontalWritingMode() const { return writingMode() == TopToBottomWritingMode || writingMode() == BottomToTopWritingMode; } + bool isFlippedLinesWritingMode() const { return writingMode() == LeftToRightWritingMode || writingMode() == BottomToTopWritingMode; } + bool isFlippedBlocksWritingMode() const { return writingMode() == RightToLeftWritingMode || writingMode() == BottomToTopWritingMode; } + + ESpeak speak() { return static_cast(rareInheritedData->speak); } + +#ifdef ANDROID_CSS_RING + // called when building nav cache to determine if the ring data is unchanged + const void* ringData() const { return reinterpret_cast(rareInheritedData.get()); } + Color ringFillColor() const { return rareInheritedData->ringFillColor; } + Length ringInnerWidth() const { return rareInheritedData->ringInnerWidth; } + Length ringOuterWidth() const { return rareInheritedData->ringOuterWidth; } + Length ringOutset() const { return rareInheritedData->ringOutset; } + Color ringPressedInnerColor() const { return rareInheritedData->ringPressedInnerColor; } + Color ringPressedOuterColor() const { return rareInheritedData->ringPressedOuterColor; } + Length ringRadius() const { return rareInheritedData->ringRadius; } + Color ringSelectedInnerColor() const { return rareInheritedData->ringSelectedInnerColor; } + Color ringSelectedOuterColor() const { return rareInheritedData->ringSelectedOuterColor; } +#endif +#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR + Color tapHighlightColor() const { return rareInheritedData->tapHighlightColor; } +#endif +// attribute setter methods + + void setDisplay(EDisplay v) { noninherited_flags._effectiveDisplay = v; } + void setOriginalDisplay(EDisplay v) { noninherited_flags._originalDisplay = v; } + void setPosition(EPosition v) { noninherited_flags._position = v; } + void setFloating(EFloat v) { noninherited_flags._floating = v; } + + void setLeft(Length v) { SET_VAR(surround, offset.m_left, v) } + void setRight(Length v) { SET_VAR(surround, offset.m_right, v) } + void setTop(Length v) { SET_VAR(surround, offset.m_top, v) } + void setBottom(Length v) { SET_VAR(surround, offset.m_bottom, v) } + + void setWidth(Length v) { SET_VAR(m_box, m_width, v) } + void setHeight(Length v) { SET_VAR(m_box, m_height, v) } + + void setMinWidth(Length v) { SET_VAR(m_box, m_minWidth, v) } + void setMaxWidth(Length v) { SET_VAR(m_box, m_maxWidth, v) } + void setMinHeight(Length v) { SET_VAR(m_box, m_minHeight, v) } + void setMaxHeight(Length v) { SET_VAR(m_box, m_maxHeight, v) } + +#if ENABLE(DASHBOARD_SUPPORT) + Vector dashboardRegions() const { return rareNonInheritedData->m_dashboardRegions; } + void setDashboardRegions(Vector regions) { SET_VAR(rareNonInheritedData, m_dashboardRegions, regions); } + + void setDashboardRegion(int type, const String& label, Length t, Length r, Length b, Length l, bool append) + { + StyleDashboardRegion region; + region.label = label; + region.offset.m_top = t; + region.offset.m_right = r; + region.offset.m_bottom = b; + region.offset.m_left = l; + region.type = type; + if (!append) + rareNonInheritedData.access()->m_dashboardRegions.clear(); + rareNonInheritedData.access()->m_dashboardRegions.append(region); + } +#endif + + void resetBorder() { resetBorderImage(); resetBorderTop(); resetBorderRight(); resetBorderBottom(); resetBorderLeft(); resetBorderRadius(); } + void resetBorderTop() { SET_VAR(surround, border.m_top, BorderValue()) } + 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 resetBorderRadius() { resetBorderTopLeftRadius(); resetBorderTopRightRadius(); resetBorderBottomLeftRadius(); resetBorderBottomRightRadius(); } + 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()) } + void resetBorderBottomRightRadius() { SET_VAR(surround, border.m_bottomRight, initialBorderRadius()) } + + void resetOutline() { SET_VAR(m_background, m_outline, OutlineValue()) } + + void setBackgroundColor(const Color& v) { SET_VAR(m_background, m_color, v) } + + void setBackgroundXPosition(Length l) { SET_VAR(m_background, m_background.m_xPosition, l) } + void setBackgroundYPosition(Length l) { SET_VAR(m_background, m_background.m_yPosition, l) } + void setBackgroundSize(EFillSizeType b) { SET_VAR(m_background, m_background.m_sizeType, b) } + void setBackgroundSizeLength(LengthSize l) { SET_VAR(m_background, m_background.m_sizeLength, l) } + + void setBorderImage(const NinePieceImage& b) { SET_VAR(surround, border.m_image, b) } + + 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) } + void setBorderBottomRightRadius(const LengthSize& s) { SET_VAR(surround, border.m_bottomRight, s) } + + void setBorderRadius(const LengthSize& s) + { + setBorderTopLeftRadius(s); + setBorderTopRightRadius(s); + setBorderBottomLeftRadius(s); + setBorderBottomRightRadius(s); + } + void setBorderRadius(const IntSize& s) + { + setBorderRadius(LengthSize(Length(s.width(), Fixed), Length(s.height(), Fixed))); + } + + + void getBorderRadiiForRect(const IntRect&, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const; + void getInnerBorderRadiiForRectWithBorderWidths(const IntRect&, unsigned short topWidth, + unsigned short bottomWidth, unsigned short leftWidth, unsigned short rightWidth, + IntSize& innerTopLeft, IntSize& innerTopRight, IntSize& innerBottomLeft, + IntSize& innerBottomRight) const; + + void setBorderLeftWidth(unsigned short v) { SET_VAR(surround, border.m_left.m_width, v) } + void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround, border.m_left.m_style, v) } + void setBorderLeftColor(const Color& v) { SET_VAR(surround, border.m_left.m_color, v) } + void setBorderRightWidth(unsigned short v) { SET_VAR(surround, border.m_right.m_width, v) } + void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround, border.m_right.m_style, v) } + void setBorderRightColor(const Color& v) { SET_VAR(surround, border.m_right.m_color, v) } + void setBorderTopWidth(unsigned short v) { SET_VAR(surround, border.m_top.m_width, v) } + void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround, border.m_top.m_style, v) } + void setBorderTopColor(const Color& v) { SET_VAR(surround, border.m_top.m_color, v) } + void setBorderBottomWidth(unsigned short v) { SET_VAR(surround, border.m_bottom.m_width, v) } + void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround, border.m_bottom.m_style, v) } + void setBorderBottomColor(const Color& v) { SET_VAR(surround, border.m_bottom.m_color, v) } + void setOutlineWidth(unsigned short v) { SET_VAR(m_background, m_outline.m_width, v) } + + void setOutlineStyle(EBorderStyle v, bool isAuto = false) + { + SET_VAR(m_background, m_outline.m_style, v) + SET_VAR(m_background, m_outline.m_isAuto, isAuto) + } + + void setOutlineColor(const Color& v) { SET_VAR(m_background, m_outline.m_color, v) } + + void setOverflowX(EOverflow v) { noninherited_flags._overflowX = v; } + void setOverflowY(EOverflow v) { noninherited_flags._overflowY = v; } + void setVisibility(EVisibility v) { inherited_flags._visibility = v; } + void setVerticalAlign(EVerticalAlign v) { noninherited_flags._vertical_align = v; } + void setVerticalAlignLength(Length l) { SET_VAR(m_box, m_verticalAlign, l) } + + void setHasClip(bool b = true) { SET_VAR(visual, hasClip, b) } + void setClipLeft(Length v) { SET_VAR(visual, clip.m_left, v) } + void setClipRight(Length v) { SET_VAR(visual, clip.m_right, v) } + void setClipTop(Length v) { SET_VAR(visual, clip.m_top, v) } + void setClipBottom(Length v) { SET_VAR(visual, clip.m_bottom, v) } + void setClip(Length top, Length right, Length bottom, Length left); + void setClip(LengthBox box) { SET_VAR(visual, clip, box) } + + void setUnicodeBidi(EUnicodeBidi b) { noninherited_flags._unicodeBidi = b; } + + void setClear(EClear v) { noninherited_flags._clear = v; } + void setTableLayout(ETableLayout v) { noninherited_flags._table_layout = v; } + + bool setFontDescription(const FontDescription& v) + { + if (inherited->font.fontDescription() != v) { + inherited.access()->font = Font(v, inherited->font.letterSpacing(), inherited->font.wordSpacing()); + return true; + } + return false; + } + + // Only used for blending font sizes when animating. + void setBlendedFontSize(int); + + void setColor(const Color& v) { SET_VAR(inherited, color, v) } + void setTextIndent(Length v) { SET_VAR(rareInheritedData, indent, v) } + void setTextAlign(ETextAlign v) { inherited_flags._text_align = v; } + void setTextTransform(ETextTransform v) { inherited_flags._text_transform = v; } + void addToTextDecorationsInEffect(int v) { inherited_flags._text_decorations |= v; } + void setTextDecorationsInEffect(int v) { inherited_flags._text_decorations = v; } + void setTextDecoration(int v) { SET_VAR(visual, textDecoration, v); } + void setDirection(TextDirection v) { inherited_flags._direction = v; } + void setLineHeight(Length v) { SET_VAR(inherited, line_height, v) } + void setZoom(float f) { SET_VAR(visual, m_zoom, f); setEffectiveZoom(effectiveZoom() * zoom()); } + void setEffectiveZoom(float f) { SET_VAR(rareInheritedData, m_effectiveZoom, f) } + + void setWhiteSpace(EWhiteSpace v) { inherited_flags._white_space = v; } + + void setWordSpacing(int v) { inherited.access()->font.setWordSpacing(v); } + void setLetterSpacing(int v) { inherited.access()->font.setLetterSpacing(v); } + + void clearBackgroundLayers() { m_background.access()->m_background = FillLayer(BackgroundFillLayer); } + void inheritBackgroundLayers(const FillLayer& parent) { m_background.access()->m_background = parent; } + + void adjustBackgroundLayers() + { + if (backgroundLayers()->next()) { + accessBackgroundLayers()->cullEmptyLayers(); + accessBackgroundLayers()->fillUnsetProperties(); + } + } + + void clearMaskLayers() { rareNonInheritedData.access()->m_mask = FillLayer(MaskFillLayer); } + void inheritMaskLayers(const FillLayer& parent) { rareNonInheritedData.access()->m_mask = parent; } + + void adjustMaskLayers() + { + if (maskLayers()->next()) { + accessMaskLayers()->cullEmptyLayers(); + accessMaskLayers()->fillUnsetProperties(); + } + } + + void setMaskBoxImage(const NinePieceImage& b) { SET_VAR(rareNonInheritedData, m_maskBoxImage, b) } + void setMaskXPosition(Length l) { SET_VAR(rareNonInheritedData, m_mask.m_xPosition, l) } + void setMaskYPosition(Length l) { SET_VAR(rareNonInheritedData, m_mask.m_yPosition, l) } + void setMaskSize(LengthSize l) { SET_VAR(rareNonInheritedData, m_mask.m_sizeLength, l) } + + void setBorderCollapse(bool collapse) { inherited_flags._border_collapse = collapse; } + void setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horizontal_border_spacing, v) } + void setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertical_border_spacing, v) } + void setEmptyCells(EEmptyCell v) { inherited_flags._empty_cells = v; } + void setCaptionSide(ECaptionSide v) { inherited_flags._caption_side = v; } + + void setCounterIncrement(short v) { SET_VAR(rareNonInheritedData, m_counterIncrement, v) } + void setCounterReset(short v) { SET_VAR(rareNonInheritedData, m_counterReset, v) } + + void setListStyleType(EListStyleType v) { inherited_flags._list_style_type = v; } + void setListStyleImage(PassRefPtr v) { if (inherited->list_style_image != v) inherited.access()->list_style_image = v; } + void setListStylePosition(EListStylePosition v) { inherited_flags._list_style_position = v; } + + void resetMargin() { SET_VAR(surround, margin, LengthBox(Fixed)) } + void setMarginTop(Length v) { SET_VAR(surround, margin.m_top, v) } + void setMarginBottom(Length v) { SET_VAR(surround, margin.m_bottom, v) } + void setMarginLeft(Length v) { SET_VAR(surround, margin.m_left, v) } + void setMarginRight(Length v) { SET_VAR(surround, margin.m_right, v) } + void setMarginStart(Length); + void setMarginEnd(Length); + + void resetPadding() { SET_VAR(surround, padding, LengthBox(Auto)) } + void setPaddingBox(const LengthBox& b) { SET_VAR(surround, padding, b) } + void setPaddingTop(Length v) { SET_VAR(surround, padding.m_top, v) } + void setPaddingBottom(Length v) { SET_VAR(surround, padding.m_bottom, v) } + void setPaddingLeft(Length v) { SET_VAR(surround, padding.m_left, v) } + void setPaddingRight(Length v) { SET_VAR(surround, padding.m_right, v) } + + void setCursor(ECursor c) { inherited_flags._cursor_style = c; } + void addCursor(PassRefPtr, const IntPoint& hotSpot = IntPoint()); + void setCursorList(PassRefPtr); + void clearCursorList(); + + void setInsideLink(EInsideLink insideLink) { inherited_flags._insideLink = insideLink; } + void setIsLink(bool b) { noninherited_flags._isLink = b; } + + bool forceBackgroundsToWhite() const { return inherited_flags._force_backgrounds_to_white; } + void setForceBackgroundsToWhite(bool b=true) { inherited_flags._force_backgrounds_to_white = b; } + + bool hasAutoZIndex() const { return m_box->hasAutoZIndex(); } + void setHasAutoZIndex() { SET_VAR(m_box, m_hasAutoZIndex, true); SET_VAR(m_box, m_zIndex, 0) } + int zIndex() const { return m_box->zIndex(); } + void setZIndex(int v) { SET_VAR(m_box, m_hasAutoZIndex, false); SET_VAR(m_box, m_zIndex, v) } + + void setWidows(short w) { SET_VAR(rareInheritedData, widows, w); } + void setOrphans(short o) { SET_VAR(rareInheritedData, orphans, o); } + void setPageBreakInside(EPageBreak b) { noninherited_flags._page_break_inside = b; } + void setPageBreakBefore(EPageBreak b) { noninherited_flags._page_break_before = b; } + void setPageBreakAfter(EPageBreak b) { noninherited_flags._page_break_after = b; } + + // CSS3 Setters + void setOutlineOffset(int v) { SET_VAR(m_background, m_outline.m_offset, v) } + void setTextShadow(ShadowData* val, bool add=false); + void setTextStrokeColor(const Color& c) { SET_VAR(rareInheritedData, textStrokeColor, c) } + void setTextStrokeWidth(float w) { SET_VAR(rareInheritedData, textStrokeWidth, w) } + void setTextFillColor(const Color& c) { SET_VAR(rareInheritedData, textFillColor, c) } + void setColorSpace(ColorSpace space) { SET_VAR(rareInheritedData, colorSpace, space) } + void setOpacity(float f) { SET_VAR(rareNonInheritedData, opacity, f); } + void setAppearance(ControlPart a) { SET_VAR(rareNonInheritedData, m_appearance, a); } + void setBoxAlign(EBoxAlignment a) { SET_VAR(rareNonInheritedData.access()->flexibleBox, align, a); } + void setBoxDirection(EBoxDirection d) { inherited_flags._box_direction = d; } + void setBoxFlex(float f) { SET_VAR(rareNonInheritedData.access()->flexibleBox, flex, f); } + void setBoxFlexGroup(unsigned int fg) { SET_VAR(rareNonInheritedData.access()->flexibleBox, flex_group, fg); } + void setBoxLines(EBoxLines l) { SET_VAR(rareNonInheritedData.access()->flexibleBox, lines, l); } + void setBoxOrdinalGroup(unsigned int og) { SET_VAR(rareNonInheritedData.access()->flexibleBox, ordinal_group, og); } + void setBoxOrient(EBoxOrient o) { SET_VAR(rareNonInheritedData.access()->flexibleBox, orient, o); } + void setBoxPack(EBoxAlignment p) { SET_VAR(rareNonInheritedData.access()->flexibleBox, pack, p); } + void setBoxShadow(ShadowData* val, bool add=false); + void setBoxReflect(PassRefPtr reflect) { if (rareNonInheritedData->m_boxReflect != reflect) rareNonInheritedData.access()->m_boxReflect = reflect; } + void setBoxSizing(EBoxSizing s) { SET_VAR(m_box, m_boxSizing, s); } + void setMarqueeIncrement(const Length& f) { SET_VAR(rareNonInheritedData.access()->marquee, increment, f); } + void setMarqueeSpeed(int f) { SET_VAR(rareNonInheritedData.access()->marquee, speed, f); } + void setMarqueeDirection(EMarqueeDirection d) { SET_VAR(rareNonInheritedData.access()->marquee, direction, d); } + void setMarqueeBehavior(EMarqueeBehavior b) { SET_VAR(rareNonInheritedData.access()->marquee, behavior, b); } + void setMarqueeLoopCount(int i) { SET_VAR(rareNonInheritedData.access()->marquee, loops, i); } + void setUserModify(EUserModify u) { SET_VAR(rareInheritedData, userModify, u); } + void setUserDrag(EUserDrag d) { SET_VAR(rareNonInheritedData, userDrag, d); } + void setUserSelect(EUserSelect s) { SET_VAR(rareInheritedData, userSelect, s); } + void setTextOverflow(bool b) { SET_VAR(rareNonInheritedData, textOverflow, b); } + void setMarginBeforeCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginBeforeCollapse, c); } + void setMarginAfterCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginAfterCollapse, c); } + void setWordBreak(EWordBreak b) { SET_VAR(rareInheritedData, wordBreak, b); } + void setWordWrap(EWordWrap b) { SET_VAR(rareInheritedData, wordWrap, b); } + void setNBSPMode(ENBSPMode b) { SET_VAR(rareInheritedData, nbspMode, b); } + void setKHTMLLineBreak(EKHTMLLineBreak b) { SET_VAR(rareInheritedData, khtmlLineBreak, b); } + void setMatchNearestMailBlockquoteColor(EMatchNearestMailBlockquoteColor c) { SET_VAR(rareNonInheritedData, matchNearestMailBlockquoteColor, c); } + void setHighlight(const AtomicString& h) { SET_VAR(rareInheritedData, highlight, h); } + void setHyphens(Hyphens h) { SET_VAR(rareInheritedData, hyphens, h); } + void setHyphenationString(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenationString, h); } + void setHyphenationLocale(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenationLocale, h); } + void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); } + void setResize(EResize r) { SET_VAR(rareInheritedData, resize, r); } + void setColumnWidth(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, f); } + void setHasAutoColumnWidth() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoWidth, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_width, 0); } + void setColumnCount(unsigned short c) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, c); } + void setHasAutoColumnCount() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_autoCount, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_count, 0); } + void setColumnGap(float f) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, false); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, f); } + void setHasNormalColumnGap() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_normalGap, true); SET_VAR(rareNonInheritedData.access()->m_multiCol, m_gap, 0); } + void setColumnRuleColor(const Color& c) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_color, c); } + void setColumnRuleStyle(EBorderStyle b) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_style, b); } + void setColumnRuleWidth(unsigned short w) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule.m_width, w); } + void resetColumnRule() { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_rule, BorderValue()) } + void setColumnSpan(bool b) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_columnSpan, b); } + void setColumnBreakBefore(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakBefore, p); } + void setColumnBreakInside(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakInside, p); } + void setColumnBreakAfter(EPageBreak p) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_breakAfter, p); } + void inheritColumnPropertiesFrom(RenderStyle* parent) { rareNonInheritedData.access()->m_multiCol = parent->rareNonInheritedData->m_multiCol; } + void setTransform(const TransformOperations& ops) { SET_VAR(rareNonInheritedData.access()->m_transform, m_operations, ops); } + void setTransformOriginX(Length l) { SET_VAR(rareNonInheritedData.access()->m_transform, m_x, l); } + void setTransformOriginY(Length l) { SET_VAR(rareNonInheritedData.access()->m_transform, m_y, l); } + void setTransformOriginZ(float f) { SET_VAR(rareNonInheritedData.access()->m_transform, m_z, f); } + void setSpeak(ESpeak s) { SET_VAR(rareInheritedData, speak, s); } + void setTextCombine(TextCombine v) { SET_VAR(rareNonInheritedData, m_textCombine, v); } + void setTextEmphasisColor(const Color& c) { SET_VAR(rareInheritedData, textEmphasisColor, c) } + void setTextEmphasisFill(TextEmphasisFill fill) { SET_VAR(rareInheritedData, textEmphasisFill, fill); } + void setTextEmphasisMark(TextEmphasisMark mark) { SET_VAR(rareInheritedData, textEmphasisMark, mark); } + void setTextEmphasisCustomMark(const AtomicString& mark) { SET_VAR(rareInheritedData, textEmphasisCustomMark, mark); } + void setTextEmphasisPosition(TextEmphasisPosition position) { SET_VAR(rareInheritedData, textEmphasisPosition, position); } + // End CSS3 Setters + + // Apple-specific property setters + void setPointerEvents(EPointerEvents p) { inherited_flags._pointerEvents = p; } + + void clearAnimations() + { + rareNonInheritedData.access()->m_animations.clear(); + } + + void clearTransitions() + { + rareNonInheritedData.access()->m_transitions.clear(); + } + + void inheritAnimations(const AnimationList* parent) { rareNonInheritedData.access()->m_animations = parent ? adoptPtr(new AnimationList(*parent)) : PassOwnPtr(); } + void inheritTransitions(const AnimationList* parent) { rareNonInheritedData.access()->m_transitions = parent ? adoptPtr(new AnimationList(*parent)) : PassOwnPtr(); } + void adjustAnimations(); + void adjustTransitions(); + + void setTransformStyle3D(ETransformStyle3D b) { SET_VAR(rareNonInheritedData, m_transformStyle3D, b); } + void setBackfaceVisibility(EBackfaceVisibility b) { SET_VAR(rareNonInheritedData, m_backfaceVisibility, b); } + void setPerspective(float p) { SET_VAR(rareNonInheritedData, m_perspective, p); } + void setPerspectiveOriginX(Length l) { SET_VAR(rareNonInheritedData, m_perspectiveOriginX, l); } + void setPerspectiveOriginY(Length l) { SET_VAR(rareNonInheritedData, m_perspectiveOriginY, l); } + void setPageSize(LengthSize s) { SET_VAR(rareNonInheritedData, m_pageSize, s); } + void setPageSizeType(PageSizeType t) { SET_VAR(rareNonInheritedData, m_pageSizeType, t); } + void resetPageSizeType() { SET_VAR(rareNonInheritedData, m_pageSizeType, PAGE_SIZE_AUTO); } + +#if USE(ACCELERATED_COMPOSITING) + void setIsRunningAcceleratedAnimation(bool b = true) { SET_VAR(rareNonInheritedData, m_runningAcceleratedAnimation, b); } +#endif + + void setLineClamp(LineClampValue c) { SET_VAR(rareNonInheritedData, lineClamp, c); } + void setTextSizeAdjust(bool b) { SET_VAR(rareInheritedData, textSizeAdjust, b); } + void setTextSecurity(ETextSecurity aTextSecurity) { SET_VAR(rareInheritedData, textSecurity, aTextSecurity); } + +#ifdef ANDROID_CSS_RING + void setRingFillColor(const Color& v) { SET_VAR(rareInheritedData, ringFillColor, v); } + void setRingInnerWidth(Length v) { SET_VAR(rareInheritedData, ringInnerWidth, v); } + void setRingOuterWidth(Length v) { SET_VAR(rareInheritedData, ringOuterWidth, v); } + void setRingOutset(Length v) { SET_VAR(rareInheritedData, ringOutset, v); } + void setRingPressedInnerColor(const Color& v) { + SET_VAR(rareInheritedData, ringPressedInnerColor, v); } + void setRingPressedOuterColor(const Color& v) { + SET_VAR(rareInheritedData, ringPressedOuterColor, v); } + void setRingRadius(Length v) { SET_VAR(rareInheritedData, ringRadius, v); } + void setRingSelectedInnerColor(const Color& v) { + SET_VAR(rareInheritedData, ringSelectedInnerColor, v); } + void setRingSelectedOuterColor(const Color& v) { + SET_VAR(rareInheritedData, ringSelectedOuterColor, v); } +#endif +#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR + void setTapHighlightColor(const Color& v) { SET_VAR(rareInheritedData, tapHighlightColor, v); } +#endif + +#if ENABLE(SVG) + const SVGRenderStyle* svgStyle() const { return m_svgStyle.get(); } + SVGRenderStyle* accessSVGStyle() { return m_svgStyle.access(); } + + float fillOpacity() const { return svgStyle()->fillOpacity(); } + void setFillOpacity(float f) { accessSVGStyle()->setFillOpacity(f); } + + float strokeOpacity() const { return svgStyle()->strokeOpacity(); } + void setStrokeOpacity(float f) { accessSVGStyle()->setStrokeOpacity(f); } + + float floodOpacity() const { return svgStyle()->floodOpacity(); } + void setFloodOpacity(float f) { accessSVGStyle()->setFloodOpacity(f); } +#endif + + const ContentData* contentData() const { return rareNonInheritedData->m_content.get(); } + bool contentDataEquivalent(const RenderStyle* otherStyle) const { return const_cast(this)->rareNonInheritedData->contentDataEquivalent(*const_cast(otherStyle)->rareNonInheritedData); } + void clearContent(); + void setContent(PassRefPtr, bool add = false); + void setContent(PassRefPtr, bool add = false); + void setContent(PassOwnPtr, bool add = false); + + const CounterDirectiveMap* counterDirectives() const; + CounterDirectiveMap& accessCounterDirectives(); + + const AtomicString& hyphenString() const; + + bool inheritedNotEqual(const RenderStyle*) const; + + StyleDifference diff(const RenderStyle*, unsigned& changedContextSensitiveProperties) const; + + bool isDisplayReplacedType() const + { + return display() == INLINE_BLOCK || display() == INLINE_BOX || display() == INLINE_TABLE; + } + + bool isDisplayInlineType() const + { + return display() == INLINE || isDisplayReplacedType(); + } + + bool isOriginalDisplayInlineType() const + { + return originalDisplay() == INLINE || originalDisplay() == INLINE_BLOCK || + originalDisplay() == INLINE_BOX || originalDisplay() == INLINE_TABLE; + } + + void setWritingMode(WritingMode v) { inherited_flags.m_writingMode = v; } + + // To tell if this style matched attribute selectors. This makes it impossible to share. + bool affectedByAttributeSelectors() const { return m_affectedByAttributeSelectors; } + void setAffectedByAttributeSelectors() { m_affectedByAttributeSelectors = true; } + + bool unique() const { return m_unique; } + void setUnique() { m_unique = true; } + + // Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.) + bool affectedByEmpty() const { return m_affectedByEmpty; } + bool emptyState() const { return m_emptyState; } + void setEmptyState(bool b) { m_affectedByEmpty = true; m_unique = true; m_emptyState = b; } + bool childrenAffectedByPositionalRules() const { return childrenAffectedByForwardPositionalRules() || childrenAffectedByBackwardPositionalRules(); } + bool childrenAffectedByFirstChildRules() const { return m_childrenAffectedByFirstChildRules; } + void setChildrenAffectedByFirstChildRules() { m_childrenAffectedByFirstChildRules = true; } + bool childrenAffectedByLastChildRules() const { return m_childrenAffectedByLastChildRules; } + void setChildrenAffectedByLastChildRules() { m_childrenAffectedByLastChildRules = true; } + bool childrenAffectedByDirectAdjacentRules() const { return m_childrenAffectedByDirectAdjacentRules; } + void setChildrenAffectedByDirectAdjacentRules() { m_childrenAffectedByDirectAdjacentRules = true; } + bool childrenAffectedByForwardPositionalRules() const { return m_childrenAffectedByForwardPositionalRules; } + void setChildrenAffectedByForwardPositionalRules() { m_childrenAffectedByForwardPositionalRules = true; } + bool childrenAffectedByBackwardPositionalRules() const { return m_childrenAffectedByBackwardPositionalRules; } + void setChildrenAffectedByBackwardPositionalRules() { m_childrenAffectedByBackwardPositionalRules = true; } + bool firstChildState() const { return m_firstChildState; } + void setFirstChildState() { m_firstChildState = true; } + bool lastChildState() const { return m_lastChildState; } + void setLastChildState() { m_lastChildState = true; } + unsigned childIndex() const { return m_childIndex; } + void setChildIndex(unsigned index) { m_childIndex = index; } + + const Color visitedDependentColor(int colorProperty) const; + + // Initial values for all the properties + static bool initialBorderCollapse() { return false; } + static EBorderStyle initialBorderStyle() { return BNONE; } + static NinePieceImage initialNinePieceImage() { return NinePieceImage(); } + static LengthSize initialBorderRadius() { return LengthSize(Length(0, Fixed), Length(0, Fixed)); } + static ECaptionSide initialCaptionSide() { return CAPTOP; } + static EClear initialClear() { return CNONE; } + static TextDirection initialDirection() { return LTR; } + static WritingMode initialWritingMode() { return TopToBottomWritingMode; } + static TextCombine initialTextCombine() { return TextCombineNone; } + static EDisplay initialDisplay() { return INLINE; } + static EEmptyCell initialEmptyCells() { return SHOW; } + static EFloat initialFloating() { return FNONE; } + static EListStylePosition initialListStylePosition() { return OUTSIDE; } + static EListStyleType initialListStyleType() { return Disc; } + static EOverflow initialOverflowX() { return OVISIBLE; } + static EOverflow initialOverflowY() { return OVISIBLE; } + static EPageBreak initialPageBreak() { return PBAUTO; } + static EPosition initialPosition() { return StaticPosition; } + static ETableLayout initialTableLayout() { return TAUTO; } + static EUnicodeBidi initialUnicodeBidi() { return UBNormal; } + static ETextTransform initialTextTransform() { return TTNONE; } + static EVisibility initialVisibility() { return VISIBLE; } + static EWhiteSpace initialWhiteSpace() { return NORMAL; } + static short initialHorizontalBorderSpacing() { return 0; } + static short initialVerticalBorderSpacing() { return 0; } + static ECursor initialCursor() { return CURSOR_AUTO; } + static Color initialColor() { return Color::black; } + static StyleImage* initialListStyleImage() { return 0; } + static unsigned short initialBorderWidth() { return 3; } + static int initialLetterWordSpacing() { return 0; } + static Length initialSize() { return Length(); } + static Length initialMinSize() { return Length(0, Fixed); } + static Length initialMaxSize() { return Length(undefinedLength, Fixed); } + static Length initialOffset() { return Length(); } + static Length initialMargin() { return Length(Fixed); } + static Length initialPadding() { return Length(Fixed); } + static Length initialTextIndent() { return Length(Fixed); } + static EVerticalAlign initialVerticalAlign() { return BASELINE; } + static int initialWidows() { return 2; } + static int initialOrphans() { return 2; } + static Length initialLineHeight() { return Length(-100.0, Percent); } + static ETextAlign initialTextAlign() { return TAAUTO; } + static ETextDecoration initialTextDecoration() { return TDNONE; } + static float initialZoom() { return 1.0f; } + static int initialOutlineOffset() { return 0; } + static float initialOpacity() { return 1.0f; } + static EBoxAlignment initialBoxAlign() { return BSTRETCH; } + static EBoxDirection initialBoxDirection() { return BNORMAL; } + static EBoxLines initialBoxLines() { return SINGLE; } + static EBoxOrient initialBoxOrient() { return HORIZONTAL; } + static EBoxAlignment initialBoxPack() { return BSTART; } + static float initialBoxFlex() { return 0.0f; } + static int initialBoxFlexGroup() { return 1; } + static int initialBoxOrdinalGroup() { return 1; } + static EBoxSizing initialBoxSizing() { return CONTENT_BOX; } + static StyleReflection* initialBoxReflect() { return 0; } + static int initialMarqueeLoopCount() { return -1; } + static int initialMarqueeSpeed() { return 85; } + static Length initialMarqueeIncrement() { return Length(6, Fixed); } + static EMarqueeBehavior initialMarqueeBehavior() { return MSCROLL; } + static EMarqueeDirection initialMarqueeDirection() { return MAUTO; } + static EUserModify initialUserModify() { return READ_ONLY; } + static EUserDrag initialUserDrag() { return DRAG_AUTO; } + static EUserSelect initialUserSelect() { return SELECT_TEXT; } + static bool initialTextOverflow() { return false; } + static EMarginCollapse initialMarginBeforeCollapse() { return MCOLLAPSE; } + static EMarginCollapse initialMarginAfterCollapse() { return MCOLLAPSE; } + static EWordBreak initialWordBreak() { return NormalWordBreak; } + static EWordWrap initialWordWrap() { return NormalWordWrap; } + static ENBSPMode initialNBSPMode() { return NBNORMAL; } + static EKHTMLLineBreak initialKHTMLLineBreak() { return LBNORMAL; } + static EMatchNearestMailBlockquoteColor initialMatchNearestMailBlockquoteColor() { return BCNORMAL; } + static const AtomicString& initialHighlight() { return nullAtom; } + static ESpeak initialSpeak() { return SpeakNormal; } + static Hyphens initialHyphens() { return HyphensManual; } + static const AtomicString& initialHyphenationString() { return nullAtom; } + static const AtomicString& initialHyphenationLocale() { return nullAtom; } + static EBorderFit initialBorderFit() { return BorderFitBorder; } + static EResize initialResize() { return RESIZE_NONE; } + static ControlPart initialAppearance() { return NoControlPart; } + static bool initialVisuallyOrdered() { return false; } + static float initialTextStrokeWidth() { return 0; } + static unsigned short initialColumnCount() { return 1; } + static bool initialColumnSpan() { return false; } + static const TransformOperations& initialTransform() { DEFINE_STATIC_LOCAL(TransformOperations, ops, ()); return ops; } + static Length initialTransformOriginX() { return Length(50.0, Percent); } + static Length initialTransformOriginY() { return Length(50.0, Percent); } + static EPointerEvents initialPointerEvents() { return PE_AUTO; } + static float initialTransformOriginZ() { return 0; } + static ETransformStyle3D initialTransformStyle3D() { return TransformStyle3DFlat; } + static EBackfaceVisibility initialBackfaceVisibility() { return BackfaceVisibilityVisible; } + static float initialPerspective() { return 0; } + static Length initialPerspectiveOriginX() { return Length(50.0, Percent); } + static Length initialPerspectiveOriginY() { return Length(50.0, Percent); } + static Color initialBackgroundColor() { return Color::transparent; } + static Color initialTextEmphasisColor() { return TextEmphasisFillFilled; } + static TextEmphasisFill initialTextEmphasisFill() { return TextEmphasisFillFilled; } + static TextEmphasisMark initialTextEmphasisMark() { return TextEmphasisMarkNone; } + static const AtomicString& initialTextEmphasisCustomMark() { return nullAtom; } + static TextEmphasisPosition initialTextEmphasisPosition() { return TextEmphasisPositionOver; } + + // Keep these at the end. + static LineClampValue initialLineClamp() { return LineClampValue(); } + static bool initialTextSizeAdjust() { return true; } + static ETextSecurity initialTextSecurity() { return TSNONE; } +#if ENABLE(DASHBOARD_SUPPORT) + static const Vector& initialDashboardRegions(); + static const Vector& noneDashboardRegions(); +#endif + +#ifdef ANDROID_CSS_RING + static Color initialRingFillColor() { return Color::ringFill; } + static Length initialRingInnerWidth() { return Length(16, Fixed); } // 1.0 + static Length initialRingOuterWidth() { return Length(40, Fixed); } // 2.5 + static Length initialRingOutset() { return Length(3, Fixed); } + static Color initialRingSelectedInnerColor() { return Color::ringSelectedInner; } + static Color initialRingSelectedOuterColor() { return Color::ringSelectedOuter; } + static Color initialRingPressedInnerColor() { return Color::ringPressedInner; } + static Color initialRingPressedOuterColor() { return Color::ringPressedOuter; } + static Length initialRingRadius() { return Length(1, Fixed); } +#endif +#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR + static Color initialTapHighlightColor() { return Color::tap; } +#endif + +private: + void getShadowExtent(const ShadowData*, int& top, int& right, int& bottom, int& left) const; + void getShadowHorizontalExtent(const ShadowData*, int& left, int& right) const; + void getShadowVerticalExtent(const ShadowData*, int& top, int& bottom) const; + void getShadowInlineDirectionExtent(const ShadowData* shadow, int& logicalLeft, int& logicalRight) const + { + return isHorizontalWritingMode() ? getShadowHorizontalExtent(shadow, logicalLeft, logicalRight) : getShadowVerticalExtent(shadow, logicalLeft, logicalRight); + } + void getShadowBlockDirectionExtent(const ShadowData* shadow, int& logicalTop, int& logicalBottom) const + { + return isHorizontalWritingMode() ? getShadowVerticalExtent(shadow, logicalTop, logicalBottom) : getShadowHorizontalExtent(shadow, logicalTop, logicalBottom); + } + + // Color accessors are all private to make sure callers use visitedDependentColor instead to access them. + const Color& borderLeftColor() const { return surround->border.left().color(); } + const Color& borderRightColor() const { return surround->border.right().color(); } + const Color& borderTopColor() const { return surround->border.top().color(); } + const Color& borderBottomColor() const { return surround->border.bottom().color(); } + const Color& backgroundColor() const { return m_background->color(); } + const Color& color() const { return inherited->color; } + const Color& columnRuleColor() const { return rareNonInheritedData->m_multiCol->m_rule.color(); } + const Color& outlineColor() const { return m_background->outline().color(); } + const Color& textEmphasisColor() const { return rareInheritedData->textEmphasisColor; } + const Color& textFillColor() const { return rareInheritedData->textFillColor; } + const Color& textStrokeColor() const { return rareInheritedData->textStrokeColor; } + + const Color colorIncludingFallback(int colorProperty, EBorderStyle borderStyle) const; + + ContentData* prepareToSetContent(StringImpl*, bool add); +}; + +inline int adjustForAbsoluteZoom(int value, const RenderStyle* style) +{ + double zoomFactor = style->effectiveZoom(); + if (zoomFactor == 1) + return value; + // Needed because computeLengthInt truncates (rather than rounds) when scaling up. + if (zoomFactor > 1) { + if (value < 0) + value--; + else + value++; + } + + return roundForImpreciseConversion(value / zoomFactor); +} + +inline float adjustFloatForAbsoluteZoom(float value, const RenderStyle* style) +{ + return value / style->effectiveZoom(); +} + +} // namespace WebCore + +#endif // RenderStyle_h diff --git a/Source/WebCore/rendering/style/RenderStyleConstants.h b/Source/WebCore/rendering/style/RenderStyleConstants.h new file mode 100644 index 0000000..0839864 --- /dev/null +++ b/Source/WebCore/rendering/style/RenderStyleConstants.h @@ -0,0 +1,434 @@ +/* + * 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, 2009, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) + * + * 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 RenderStyleConstants_h +#define RenderStyleConstants_h + +namespace WebCore { + +/* + * WARNING: + * -------- + * + * The order of the values in the enums have to agree with the order specified + * in CSSValueKeywords.in, otherwise some optimizations in the parser will fail, + * and produce invalid results. + */ + +// The difference between two styles. The following values are used: +// (1) StyleDifferenceEqual - The two styles are identical +// (2) StyleDifferenceRecompositeLayer - The layer needs its position and transform updated, but no repaint +// (3) StyleDifferenceRepaint - The object just needs to be repainted. +// (4) StyleDifferenceRepaintLayer - The layer and its descendant layers needs to be repainted. +// (5) StyleDifferenceLayout - A layout is required. +enum StyleDifference { + StyleDifferenceEqual, +#if USE(ACCELERATED_COMPOSITING) + StyleDifferenceRecompositeLayer, +#endif + StyleDifferenceRepaint, + StyleDifferenceRepaintLayer, + StyleDifferenceLayoutPositionedMovementOnly, + StyleDifferenceLayout +}; + +// When some style properties change, different amounts of work have to be done depending on +// context (e.g. whether the property is changing on an element which has a compositing layer). +// A simple StyleDifference does not provide enough information so we return a bit mask of +// StyleDifferenceContextSensitiveProperties from RenderStyle::diff() too. +enum StyleDifferenceContextSensitiveProperty { + ContextSensitivePropertyNone = 0, + ContextSensitivePropertyTransform = (1 << 0), + ContextSensitivePropertyOpacity = (1 << 1) +}; + +// Static pseudo styles. Dynamic ones are produced on the fly. +enum PseudoId { + // The order must be NOP ID, public IDs, and then internal IDs. + NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED, SCROLLBAR, FILE_UPLOAD_BUTTON, INPUT_PLACEHOLDER, + SLIDER_THUMB, SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON, MEDIA_CONTROLS_PANEL, + MEDIA_CONTROLS_PLAY_BUTTON, MEDIA_CONTROLS_MUTE_BUTTON, MEDIA_CONTROLS_TIMELINE, MEDIA_CONTROLS_TIMELINE_CONTAINER, + MEDIA_CONTROLS_VOLUME_SLIDER, MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER, MEDIA_CONTROLS_VOLUME_SLIDER_MUTE_BUTTON, + MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, + MEDIA_CONTROLS_SEEK_BACK_BUTTON, MEDIA_CONTROLS_SEEK_FORWARD_BUTTON, MEDIA_CONTROLS_FULLSCREEN_BUTTON, MEDIA_CONTROLS_REWIND_BUTTON, + MEDIA_CONTROLS_RETURN_TO_REALTIME_BUTTON, MEDIA_CONTROLS_TOGGLE_CLOSED_CAPTIONS_BUTTON, + MEDIA_CONTROLS_STATUS_DISPLAY, SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER, RESIZER, + INPUT_LIST_BUTTON, INPUT_SPEECH_BUTTON, INNER_SPIN_BUTTON, OUTER_SPIN_BUTTON, VISITED_LINK, PROGRESS_BAR_VALUE, + METER_HORIZONTAL_BAR, METER_HORIZONTAL_OPTIMUM, METER_HORIZONTAL_SUBOPTIMAL, METER_HORIZONTAL_EVEN_LESS_GOOD, + METER_VERTICAL_BAR, METER_VERTICAL_OPTIMUM, METER_VERTICAL_SUBOPTIMAL, METER_VERTICAL_EVEN_LESS_GOOD, + AFTER_LAST_INTERNAL_PSEUDOID, + FULL_SCREEN, FULL_SCREEN_DOCUMENT, + FIRST_PUBLIC_PSEUDOID = FIRST_LINE, + FIRST_INTERNAL_PSEUDOID = FILE_UPLOAD_BUTTON, + PUBLIC_PSEUDOID_MASK = ((1 << FIRST_INTERNAL_PSEUDOID) - 1) & ~((1 << FIRST_PUBLIC_PSEUDOID) - 1) +}; + +// These have been defined in the order of their precedence for border-collapsing. Do +// not change this order! +enum EBorderStyle { BNONE, BHIDDEN, INSET, GROOVE, RIDGE, OUTSET, DOTTED, DASHED, SOLID, DOUBLE }; + +enum EBorderPrecedence { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL }; + +enum EPosition { + StaticPosition, RelativePosition, AbsolutePosition, FixedPosition +}; + +enum EFloat { + FNONE = 0, FLEFT, FRIGHT +}; + +enum EMarginCollapse { MCOLLAPSE, MSEPARATE, MDISCARD }; + +// Box attributes. Not inherited. + +enum EBoxSizing { CONTENT_BOX, BORDER_BOX }; + +// Random visual rendering model attributes. Not inherited. + +enum EOverflow { + OVISIBLE, OHIDDEN, OSCROLL, OAUTO, OOVERLAY, OMARQUEE +}; + +enum EVerticalAlign { + BASELINE, MIDDLE, SUB, SUPER, TEXT_TOP, + TEXT_BOTTOM, TOP, BOTTOM, BASELINE_MIDDLE, LENGTH +}; + +enum EClear { + CNONE = 0, CLEFT = 1, CRIGHT = 2, CBOTH = 3 +}; + +enum ETableLayout { + TAUTO, TFIXED +}; + +enum EUnicodeBidi { + UBNormal, Embed, Override +}; + +// CSS Text Layout Module Level 3: Vertical writing support +enum WritingMode { + TopToBottomWritingMode, RightToLeftWritingMode, LeftToRightWritingMode, BottomToTopWritingMode +}; + +enum TextCombine { + TextCombineNone, TextCombineHorizontal +}; + +enum EFillAttachment { + ScrollBackgroundAttachment, LocalBackgroundAttachment, FixedBackgroundAttachment +}; + +enum EFillBox { + BorderFillBox, PaddingFillBox, ContentFillBox, TextFillBox +}; + +enum EFillRepeat { + RepeatFill, NoRepeatFill, RoundFill, SpaceFill +}; + +enum EFillLayerType { + BackgroundFillLayer, MaskFillLayer +}; + +// CSS3 Background Values +enum EFillSizeType { Contain, Cover, SizeLength, SizeNone }; + +// CSS3 Marquee Properties + +enum EMarqueeBehavior { MNONE, MSCROLL, MSLIDE, MALTERNATE }; +enum EMarqueeDirection { MAUTO = 0, MLEFT = 1, MRIGHT = -1, MUP = 2, MDOWN = -2, MFORWARD = 3, MBACKWARD = -3 }; + +// CSS3 Flexible Box Properties + +enum EBoxAlignment { BSTRETCH, BSTART, BCENTER, BEND, BJUSTIFY, BBASELINE }; +enum EBoxOrient { HORIZONTAL, VERTICAL }; +enum EBoxLines { SINGLE, MULTIPLE }; +enum EBoxDirection { BNORMAL, BREVERSE }; + +enum ETextSecurity { + TSNONE, TSDISC, TSCIRCLE, TSSQUARE +}; + +// CSS3 User Modify Properties + +enum EUserModify { + READ_ONLY, READ_WRITE, READ_WRITE_PLAINTEXT_ONLY +}; + +// CSS3 User Drag Values + +enum EUserDrag { + DRAG_AUTO, DRAG_NONE, DRAG_ELEMENT +}; + +// CSS3 User Select Values + +enum EUserSelect { + SELECT_NONE, SELECT_TEXT +}; + +// Word Break Values. Matches WinIE, rather than CSS3 + +enum EWordBreak { + NormalWordBreak, BreakAllWordBreak, BreakWordBreak +}; + +enum EWordWrap { + NormalWordWrap, BreakWordWrap +}; + +enum ENBSPMode { + NBNORMAL, SPACE +}; + +enum EKHTMLLineBreak { + LBNORMAL, AFTER_WHITE_SPACE +}; + +enum EMatchNearestMailBlockquoteColor { + BCNORMAL, MATCH +}; + +enum EResize { + RESIZE_NONE, RESIZE_BOTH, RESIZE_HORIZONTAL, RESIZE_VERTICAL +}; + +// The order of this enum must match the order of the list style types in CSSValueKeywords.in. +enum EListStyleType { + Disc, + Circle, + Square, + DecimalListStyle, + DecimalLeadingZero, + ArabicIndic, + BinaryListStyle, + Bengali, + Cambodian, + Khmer, + Devanagari, + Gujarati, + Gurmukhi, + Kannada, + LowerHexadecimal, + Lao, + Malayalam, + Mongolian, + Myanmar, + Octal, + Oriya, + Persian, + Urdu, + Telugu, + Tibetan, + Thai, + UpperHexadecimal, + LowerRoman, + UpperRoman, + LowerGreek, + LowerAlpha, + LowerLatin, + UpperAlpha, + UpperLatin, + Afar, + EthiopicHalehameAaEt, + EthiopicHalehameAaEr, + Amharic, + EthiopicHalehameAmEt, + AmharicAbegede, + EthiopicAbegedeAmEt, + CjkEarthlyBranch, + CjkHeavenlyStem, + Ethiopic, + EthiopicHalehameGez, + EthiopicAbegede, + EthiopicAbegedeGez, + HangulConsonant, + Hangul, + LowerNorwegian, + Oromo, + EthiopicHalehameOmEt, + Sidama, + EthiopicHalehameSidEt, + Somali, + EthiopicHalehameSoEt, + Tigre, + EthiopicHalehameTig, + TigrinyaEr, + EthiopicHalehameTiEr, + TigrinyaErAbegede, + EthiopicAbegedeTiEr, + TigrinyaEt, + EthiopicHalehameTiEt, + TigrinyaEtAbegede, + EthiopicAbegedeTiEt, + UpperGreek, + UpperNorwegian, + Asterisks, + Footnotes, + Hebrew, + Armenian, + LowerArmenian, + UpperArmenian, + Georgian, + CJKIdeographic, + Hiragana, + Katakana, + HiraganaIroha, + KatakanaIroha, + NoneListStyle +}; + +enum StyleContentType { + CONTENT_NONE, CONTENT_OBJECT, CONTENT_TEXT, CONTENT_COUNTER +}; + +enum EBorderFit { BorderFitBorder, BorderFitLines }; + +enum EAnimationFillMode { AnimationFillModeNone, AnimationFillModeForwards, AnimationFillModeBackwards, AnimationFillModeBoth }; + +enum EAnimPlayState { + AnimPlayStatePlaying = 0x0, + AnimPlayStatePaused = 0x1 +}; + +enum EWhiteSpace { + NORMAL, PRE, PRE_WRAP, PRE_LINE, NOWRAP, KHTML_NOWRAP +}; + +enum ETextAlign { + TAAUTO, LEFT, RIGHT, CENTER, JUSTIFY, WEBKIT_LEFT, WEBKIT_RIGHT, WEBKIT_CENTER +}; + +enum ETextTransform { + CAPITALIZE, UPPERCASE, LOWERCASE, TTNONE +}; + +enum ETextDecoration { + TDNONE = 0x0 , UNDERLINE = 0x1, OVERLINE = 0x2, LINE_THROUGH= 0x4, BLINK = 0x8 +}; + +enum EPageBreak { + PBAUTO, PBALWAYS, PBAVOID +}; + +enum EEmptyCell { + SHOW, HIDE +}; + +enum ECaptionSide { + CAPTOP, CAPBOTTOM, CAPLEFT, CAPRIGHT +}; + +enum EListStylePosition { OUTSIDE, INSIDE }; + +enum EVisibility { VISIBLE, HIDDEN, COLLAPSE }; + +enum ECursor { + // The following must match the order in CSSValueKeywords.in. + CURSOR_AUTO, + CURSOR_CROSS, + CURSOR_DEFAULT, + CURSOR_POINTER, + CURSOR_MOVE, + CURSOR_VERTICAL_TEXT, + CURSOR_CELL, + CURSOR_CONTEXT_MENU, + CURSOR_ALIAS, + CURSOR_PROGRESS, + CURSOR_NO_DROP, + CURSOR_NOT_ALLOWED, + CURSOR_WEBKIT_ZOOM_IN, + CURSOR_WEBKIT_ZOOM_OUT, + CURSOR_E_RESIZE, + CURSOR_NE_RESIZE, + CURSOR_NW_RESIZE, + CURSOR_N_RESIZE, + CURSOR_SE_RESIZE, + CURSOR_SW_RESIZE, + CURSOR_S_RESIZE, + CURSOR_W_RESIZE, + CURSOR_EW_RESIZE, + CURSOR_NS_RESIZE, + CURSOR_NESW_RESIZE, + CURSOR_NWSE_RESIZE, + CURSOR_COL_RESIZE, + CURSOR_ROW_RESIZE, + CURSOR_TEXT, + CURSOR_WAIT, + CURSOR_HELP, + CURSOR_ALL_SCROLL, + CURSOR_WEBKIT_GRAB, + CURSOR_WEBKIT_GRABBING, + + // The following are handled as exceptions so don't need to match. + CURSOR_COPY, + CURSOR_NONE +}; + +enum EDisplay { + INLINE, BLOCK, LIST_ITEM, RUN_IN, COMPACT, INLINE_BLOCK, + TABLE, INLINE_TABLE, TABLE_ROW_GROUP, + TABLE_HEADER_GROUP, TABLE_FOOTER_GROUP, TABLE_ROW, + TABLE_COLUMN_GROUP, TABLE_COLUMN, TABLE_CELL, + TABLE_CAPTION, BOX, INLINE_BOX, +#if ENABLE(WCSS) + WAP_MARQUEE, +#endif + NONE +}; + +enum EInsideLink { + NotInsideLink, InsideUnvisitedLink, InsideVisitedLink +}; + +enum EPointerEvents { + PE_NONE, PE_AUTO, PE_STROKE, PE_FILL, PE_PAINTED, PE_VISIBLE, + PE_VISIBLE_STROKE, PE_VISIBLE_FILL, PE_VISIBLE_PAINTED, PE_ALL +}; + +enum ETransformStyle3D { + TransformStyle3DFlat, TransformStyle3DPreserve3D +}; + +enum EBackfaceVisibility { + BackfaceVisibilityVisible, BackfaceVisibilityHidden +}; + +enum ELineClampType { LineClampLineCount, LineClampPercentage }; + +enum Hyphens { HyphensNone, HyphensManual, HyphensAuto }; + +enum ESpeak { SpeakNone, SpeakNormal, SpeakSpellOut, SpeakDigits, SpeakLiteralPunctuation, SpeakNoPunctuation }; + +enum TextEmphasisFill { TextEmphasisFillFilled, TextEmphasisFillOpen }; + +enum TextEmphasisMark { TextEmphasisMarkNone, TextEmphasisMarkAuto, TextEmphasisMarkDot, TextEmphasisMarkCircle, TextEmphasisMarkDoubleCircle, TextEmphasisMarkTriangle, TextEmphasisMarkSesame, TextEmphasisMarkCustom }; + +enum TextEmphasisPosition { TextEmphasisPositionOver, TextEmphasisPositionUnder }; + +} // namespace WebCore + +#endif // RenderStyleConstants_h diff --git a/Source/WebCore/rendering/style/SVGRenderStyle.cpp b/Source/WebCore/rendering/style/SVGRenderStyle.cpp new file mode 100644 index 0000000..28f80f2 --- /dev/null +++ b/Source/WebCore/rendering/style/SVGRenderStyle.cpp @@ -0,0 +1,220 @@ +/* + Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann + 2004, 2005, 2010 Rob Buis + Copyright (C) Research In Motion Limited 2010. All rights reserved. + + Based on khtml code by: + Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) + Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) + Copyright (C) 2002-2003 Dirk Mueller (mueller@kde.org) + Copyright (C) 2002 Apple Computer, Inc. + + 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 "config.h" + +#if ENABLE(SVG) +#include "SVGRenderStyle.h" + +#include "CSSPrimitiveValue.h" +#include "CSSValueList.h" +#include "IntRect.h" +#include "NodeRenderStyle.h" +#include "SVGStyledElement.h" + +using namespace std; + +namespace WebCore { + +SVGRenderStyle::SVGRenderStyle() +{ + static SVGRenderStyle* defaultStyle = new SVGRenderStyle(CreateDefault); + + fill = defaultStyle->fill; + stroke = defaultStyle->stroke; + text = defaultStyle->text; + stops = defaultStyle->stops; + misc = defaultStyle->misc; + shadowSVG = defaultStyle->shadowSVG; + inheritedResources = defaultStyle->inheritedResources; + resources = defaultStyle->resources; + + setBitDefaults(); +} + +SVGRenderStyle::SVGRenderStyle(CreateDefaultType) +{ + setBitDefaults(); + + fill.init(); + stroke.init(); + text.init(); + stops.init(); + misc.init(); + shadowSVG.init(); + inheritedResources.init(); + resources.init(); +} + +SVGRenderStyle::SVGRenderStyle(const SVGRenderStyle& other) + : RefCounted() +{ + fill = other.fill; + stroke = other.stroke; + text = other.text; + stops = other.stops; + misc = other.misc; + shadowSVG = other.shadowSVG; + inheritedResources = other.inheritedResources; + resources = other.resources; + + svg_inherited_flags = other.svg_inherited_flags; + svg_noninherited_flags = other.svg_noninherited_flags; +} + +SVGRenderStyle::~SVGRenderStyle() +{ +} + +bool SVGRenderStyle::operator==(const SVGRenderStyle& other) const +{ + return fill == other.fill + && stroke == other.stroke + && text == other.text + && stops == other.stops + && misc == other.misc + && shadowSVG == other.shadowSVG + && inheritedResources == other.inheritedResources + && resources == other.resources + && svg_inherited_flags == other.svg_inherited_flags + && svg_noninherited_flags == other.svg_noninherited_flags; +} + +bool SVGRenderStyle::inheritedNotEqual(const SVGRenderStyle* other) const +{ + return fill != other->fill + || stroke != other->stroke + || text != other->text + || inheritedResources != other->inheritedResources + || svg_inherited_flags != other->svg_inherited_flags; +} + +void SVGRenderStyle::inheritFrom(const SVGRenderStyle* svgInheritParent) +{ + if (!svgInheritParent) + return; + + fill = svgInheritParent->fill; + stroke = svgInheritParent->stroke; + text = svgInheritParent->text; + inheritedResources = svgInheritParent->inheritedResources; + + svg_inherited_flags = svgInheritParent->svg_inherited_flags; +} + +StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const +{ + // NOTE: All comparisions that may return StyleDifferenceLayout have to go before those who return StyleDifferenceRepaint + + // If kerning changes, we need a relayout, to force SVGCharacterData to be recalculated in the SVGRootInlineBox. + if (text != other->text) + return StyleDifferenceLayout; + + // If resources change, we need a relayout, as the presence of resources influences the repaint rect. + if (resources != other->resources) + return StyleDifferenceLayout; + + // If markers change, we need a relayout, as marker boundaries are cached in RenderSVGPath. + if (inheritedResources != other->inheritedResources) + return StyleDifferenceLayout; + + // All text related properties influence layout. + if (svg_inherited_flags._textAnchor != other->svg_inherited_flags._textAnchor + || svg_inherited_flags._writingMode != other->svg_inherited_flags._writingMode + || svg_inherited_flags._glyphOrientationHorizontal != other->svg_inherited_flags._glyphOrientationHorizontal + || svg_inherited_flags._glyphOrientationVertical != other->svg_inherited_flags._glyphOrientationVertical + || svg_noninherited_flags.f._alignmentBaseline != other->svg_noninherited_flags.f._alignmentBaseline + || svg_noninherited_flags.f._dominantBaseline != other->svg_noninherited_flags.f._dominantBaseline + || svg_noninherited_flags.f._baselineShift != other->svg_noninherited_flags.f._baselineShift) + return StyleDifferenceLayout; + + // Text related properties influence layout. + bool miscNotEqual = misc != other->misc; + if (miscNotEqual && misc->baselineShiftValue != other->misc->baselineShiftValue) + return StyleDifferenceLayout; + + // These properties affect the cached stroke bounding box rects. + if (svg_inherited_flags._capStyle != other->svg_inherited_flags._capStyle + || svg_inherited_flags._joinStyle != other->svg_inherited_flags._joinStyle) + return StyleDifferenceLayout; + + // Shadow changes require relayouts, as they affect the repaint rects. + if (shadowSVG != other->shadowSVG) + return StyleDifferenceLayout; + + // Some stroke properties, requires relayouts, as the cached stroke boundaries need to be recalculated. + if (stroke != other->stroke) { + if (stroke->width != other->stroke->width + || stroke->paint != other->stroke->paint + || stroke->miterLimit != other->stroke->miterLimit + || stroke->dashArray != other->stroke->dashArray + || stroke->dashOffset != other->stroke->dashOffset) + return StyleDifferenceLayout; + + // Only the stroke-opacity case remains, where we only need a repaint. + ASSERT(stroke->opacity != other->stroke->opacity); + return StyleDifferenceRepaint; + } + + // NOTE: All comparisions below may only return StyleDifferenceRepaint + + // Painting related properties only need repaints. + if (miscNotEqual) { + if (misc->floodColor != other->misc->floodColor + || misc->floodOpacity != other->misc->floodOpacity + || misc->lightingColor != other->misc->lightingColor) + return StyleDifferenceRepaint; + } + + // If fill changes, we just need to repaint. Fill boundaries are not influenced by this, only by the Path, that RenderSVGPath contains. + if (fill != other->fill) + return StyleDifferenceRepaint; + + // If gradient stops change, we just need to repaint. Style updates are already handled through RenderSVGGradientSTop. + if (stops != other->stops) + return StyleDifferenceRepaint; + + // Changes of these flags only cause repaints. + if (svg_inherited_flags._colorRendering != other->svg_inherited_flags._colorRendering + || svg_inherited_flags._imageRendering != other->svg_inherited_flags._imageRendering + || svg_inherited_flags._shapeRendering != other->svg_inherited_flags._shapeRendering + || svg_inherited_flags._clipRule != other->svg_inherited_flags._clipRule + || svg_inherited_flags._fillRule != other->svg_inherited_flags._fillRule + || svg_inherited_flags._colorInterpolation != other->svg_inherited_flags._colorInterpolation + || svg_inherited_flags._colorInterpolationFilters != other->svg_inherited_flags._colorInterpolationFilters) + return StyleDifferenceRepaint; + + // FIXME: vector-effect is not taken into account in the layout-phase. Once this is fixed, we should relayout here. + if (svg_noninherited_flags.f._vectorEffect != other->svg_noninherited_flags.f._vectorEffect) + return StyleDifferenceRepaint; + + return StyleDifferenceEqual; +} + +} + +#endif // ENABLE(SVG) diff --git a/Source/WebCore/rendering/style/SVGRenderStyle.h b/Source/WebCore/rendering/style/SVGRenderStyle.h new file mode 100644 index 0000000..7f032e7 --- /dev/null +++ b/Source/WebCore/rendering/style/SVGRenderStyle.h @@ -0,0 +1,431 @@ +/* + Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann + 2004, 2005 Rob Buis + Copyright (C) 2005, 2006 Apple Computer, Inc. + Copyright (C) Research In Motion Limited 2010. 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 SVGRenderStyle_h +#define SVGRenderStyle_h + +#if ENABLE(SVG) +#include "CSSValueList.h" +#include "DataRef.h" +#include "GraphicsTypes.h" +#include "Path.h" +#include "RenderStyleConstants.h" +#include "SVGPaint.h" +#include "SVGRenderStyleDefs.h" + +namespace WebCore { + +class FloatRect; +class IntRect; +class RenderObject; + +class SVGRenderStyle : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new SVGRenderStyle); } + PassRefPtr copy() const { return adoptRef(new SVGRenderStyle(*this));} + ~SVGRenderStyle(); + + bool inheritedNotEqual(const SVGRenderStyle*) const; + void inheritFrom(const SVGRenderStyle*); + + StyleDifference diff(const SVGRenderStyle*) const; + + bool operator==(const SVGRenderStyle&) const; + bool operator!=(const SVGRenderStyle& o) const { return !(*this == o); } + + // Initial values for all the properties + static EAlignmentBaseline initialAlignmentBaseline() { return AB_AUTO; } + static EDominantBaseline initialDominantBaseline() { return DB_AUTO; } + static EBaselineShift initialBaselineShift() { return BS_BASELINE; } + static EVectorEffect initialVectorEffect() { return VE_NONE; } + static LineCap initialCapStyle() { return ButtCap; } + static WindRule initialClipRule() { return RULE_NONZERO; } + static EColorInterpolation initialColorInterpolation() { return CI_SRGB; } + static EColorInterpolation initialColorInterpolationFilters() { return CI_LINEARRGB; } + static EColorRendering initialColorRendering() { return CR_AUTO; } + static WindRule initialFillRule() { return RULE_NONZERO; } + static EImageRendering initialImageRendering() { return IR_AUTO; } + static LineJoin initialJoinStyle() { return MiterJoin; } + static EShapeRendering initialShapeRendering() { return SR_AUTO; } + static ETextAnchor initialTextAnchor() { return TA_START; } + static SVGWritingMode initialWritingMode() { return WM_LRTB; } + static EGlyphOrientation initialGlyphOrientationHorizontal() { return GO_0DEG; } + static EGlyphOrientation initialGlyphOrientationVertical() { return GO_AUTO; } + static float initialFillOpacity() { return 1.0f; } + static SVGPaint* initialFillPaint() { return SVGPaint::defaultFill(); } + static float initialStrokeOpacity() { return 1.0f; } + static SVGPaint* initialStrokePaint() { return SVGPaint::defaultStroke(); } + static Vector initialStrokeDashArray() { return Vector(); } + static float initialStrokeMiterLimit() { return 4.0f; } + static float initialStopOpacity() { return 1.0f; } + static Color initialStopColor() { return Color(0, 0, 0); } + static float initialFloodOpacity() { return 1.0f; } + static Color initialFloodColor() { return Color(0, 0, 0); } + static Color initialLightingColor() { return Color(255, 255, 255); } + static ShadowData* initialShadow() { return 0; } + static String initialClipperResource() { return String(); } + static String initialFilterResource() { return String(); } + static String initialMaskerResource() { return String(); } + static String initialMarkerStartResource() { return String(); } + static String initialMarkerMidResource() { return String(); } + static String initialMarkerEndResource() { return String(); } + + static SVGLength initialBaselineShiftValue() + { + SVGLength length; + ExceptionCode ec = 0; + length.newValueSpecifiedUnits(LengthTypeNumber, 0, ec); + ASSERT(!ec); + return length; + } + + static SVGLength initialKerning() + { + SVGLength length; + ExceptionCode ec = 0; + length.newValueSpecifiedUnits(LengthTypeNumber, 0, ec); + ASSERT(!ec); + return length; + } + + static SVGLength initialStrokeDashOffset() + { + SVGLength length; + ExceptionCode ec = 0; + length.newValueSpecifiedUnits(LengthTypeNumber, 0, ec); + ASSERT(!ec); + return length; + } + + static SVGLength initialStrokeWidth() + { + SVGLength length; + ExceptionCode ec = 0; + length.newValueSpecifiedUnits(LengthTypeNumber, 1, ec); + ASSERT(!ec); + return length; + } + + // SVG CSS Property setters + void setAlignmentBaseline(EAlignmentBaseline val) { svg_noninherited_flags.f._alignmentBaseline = val; } + void setDominantBaseline(EDominantBaseline val) { svg_noninherited_flags.f._dominantBaseline = val; } + void setBaselineShift(EBaselineShift val) { svg_noninherited_flags.f._baselineShift = val; } + void setVectorEffect(EVectorEffect val) { svg_noninherited_flags.f._vectorEffect = val; } + void setCapStyle(LineCap val) { svg_inherited_flags._capStyle = val; } + void setClipRule(WindRule val) { svg_inherited_flags._clipRule = val; } + void setColorInterpolation(EColorInterpolation val) { svg_inherited_flags._colorInterpolation = val; } + void setColorInterpolationFilters(EColorInterpolation val) { svg_inherited_flags._colorInterpolationFilters = val; } + void setColorRendering(EColorRendering val) { svg_inherited_flags._colorRendering = val; } + void setFillRule(WindRule val) { svg_inherited_flags._fillRule = val; } + void setImageRendering(EImageRendering val) { svg_inherited_flags._imageRendering = val; } + void setJoinStyle(LineJoin val) { svg_inherited_flags._joinStyle = val; } + void setShapeRendering(EShapeRendering val) { svg_inherited_flags._shapeRendering = val; } + void setTextAnchor(ETextAnchor val) { svg_inherited_flags._textAnchor = val; } + void setWritingMode(SVGWritingMode val) { svg_inherited_flags._writingMode = val; } + void setGlyphOrientationHorizontal(EGlyphOrientation val) { svg_inherited_flags._glyphOrientationHorizontal = val; } + void setGlyphOrientationVertical(EGlyphOrientation val) { svg_inherited_flags._glyphOrientationVertical = val; } + + void setFillOpacity(float obj) + { + if (!(fill->opacity == obj)) + fill.access()->opacity = obj; + } + + void setFillPaint(PassRefPtr obj) + { + if (!(fill->paint == obj)) + fill.access()->paint = obj; + } + + void setStrokeOpacity(float obj) + { + if (!(stroke->opacity == obj)) + stroke.access()->opacity = obj; + } + + void setStrokePaint(PassRefPtr obj) + { + if (!(stroke->paint == obj)) + stroke.access()->paint = obj; + } + + void setStrokeDashArray(const Vector& obj) + { + if (!(stroke->dashArray == obj)) + stroke.access()->dashArray = obj; + } + + void setStrokeMiterLimit(float obj) + { + if (!(stroke->miterLimit == obj)) + stroke.access()->miterLimit = obj; + } + + void setStrokeWidth(const SVGLength& obj) + { + if (!(stroke->width == obj)) + stroke.access()->width = obj; + } + + void setStrokeDashOffset(const SVGLength& obj) + { + if (!(stroke->dashOffset == obj)) + stroke.access()->dashOffset = obj; + } + + void setKerning(const SVGLength& obj) + { + if (!(text->kerning == obj)) + text.access()->kerning = obj; + } + + void setStopOpacity(float obj) + { + if (!(stops->opacity == obj)) + stops.access()->opacity = obj; + } + + void setStopColor(const Color& obj) + { + if (!(stops->color == obj)) + stops.access()->color = obj; + } + + void setFloodOpacity(float obj) + { + if (!(misc->floodOpacity == obj)) + misc.access()->floodOpacity = obj; + } + + void setFloodColor(const Color& obj) + { + if (!(misc->floodColor == obj)) + misc.access()->floodColor = obj; + } + + void setLightingColor(const Color& obj) + { + if (!(misc->lightingColor == obj)) + misc.access()->lightingColor = obj; + } + + void setBaselineShiftValue(const SVGLength& obj) + { + if (!(misc->baselineShiftValue == obj)) + misc.access()->baselineShiftValue = obj; + } + + void setShadow(PassOwnPtr obj) { shadowSVG.access()->shadow = obj; } + + // Setters for non-inherited resources + void setClipperResource(const String& obj) + { + if (!(resources->clipper == obj)) + resources.access()->clipper = obj; + } + + void setFilterResource(const String& obj) + { + if (!(resources->filter == obj)) + resources.access()->filter = obj; + } + + void setMaskerResource(const String& obj) + { + if (!(resources->masker == obj)) + resources.access()->masker = obj; + } + + // Setters for inherited resources + void setMarkerStartResource(const String& obj) + { + if (!(inheritedResources->markerStart == obj)) + inheritedResources.access()->markerStart = obj; + } + + void setMarkerMidResource(const String& obj) + { + if (!(inheritedResources->markerMid == obj)) + inheritedResources.access()->markerMid = obj; + } + + void setMarkerEndResource(const String& obj) + { + if (!(inheritedResources->markerEnd == obj)) + inheritedResources.access()->markerEnd = obj; + } + + // Read accessors for all the properties + EAlignmentBaseline alignmentBaseline() const { return (EAlignmentBaseline) svg_noninherited_flags.f._alignmentBaseline; } + EDominantBaseline dominantBaseline() const { return (EDominantBaseline) svg_noninherited_flags.f._dominantBaseline; } + EBaselineShift baselineShift() const { return (EBaselineShift) svg_noninherited_flags.f._baselineShift; } + EVectorEffect vectorEffect() const { return (EVectorEffect) svg_noninherited_flags.f._vectorEffect; } + LineCap capStyle() const { return (LineCap) svg_inherited_flags._capStyle; } + WindRule clipRule() const { return (WindRule) svg_inherited_flags._clipRule; } + EColorInterpolation colorInterpolation() const { return (EColorInterpolation) svg_inherited_flags._colorInterpolation; } + EColorInterpolation colorInterpolationFilters() const { return (EColorInterpolation) svg_inherited_flags._colorInterpolationFilters; } + EColorRendering colorRendering() const { return (EColorRendering) svg_inherited_flags._colorRendering; } + WindRule fillRule() const { return (WindRule) svg_inherited_flags._fillRule; } + EImageRendering imageRendering() const { return (EImageRendering) svg_inherited_flags._imageRendering; } + LineJoin joinStyle() const { return (LineJoin) svg_inherited_flags._joinStyle; } + EShapeRendering shapeRendering() const { return (EShapeRendering) svg_inherited_flags._shapeRendering; } + ETextAnchor textAnchor() const { return (ETextAnchor) svg_inherited_flags._textAnchor; } + SVGWritingMode writingMode() const { return (SVGWritingMode) svg_inherited_flags._writingMode; } + EGlyphOrientation glyphOrientationHorizontal() const { return (EGlyphOrientation) svg_inherited_flags._glyphOrientationHorizontal; } + EGlyphOrientation glyphOrientationVertical() const { return (EGlyphOrientation) svg_inherited_flags._glyphOrientationVertical; } + float fillOpacity() const { return fill->opacity; } + SVGPaint* fillPaint() const { return fill->paint.get(); } + float strokeOpacity() const { return stroke->opacity; } + SVGPaint* strokePaint() const { return stroke->paint.get(); } + Vector strokeDashArray() const { return stroke->dashArray; } + float strokeMiterLimit() const { return stroke->miterLimit; } + SVGLength strokeWidth() const { return stroke->width; } + SVGLength strokeDashOffset() const { return stroke->dashOffset; } + SVGLength kerning() const { return text->kerning; } + float stopOpacity() const { return stops->opacity; } + Color stopColor() const { return stops->color; } + float floodOpacity() const { return misc->floodOpacity; } + Color floodColor() const { return misc->floodColor; } + Color lightingColor() const { return misc->lightingColor; } + SVGLength baselineShiftValue() const { return misc->baselineShiftValue; } + ShadowData* shadow() const { return shadowSVG->shadow.get(); } + String clipperResource() const { return resources->clipper; } + String filterResource() const { return resources->filter; } + String maskerResource() const { return resources->masker; } + String markerStartResource() const { return inheritedResources->markerStart; } + String markerMidResource() const { return inheritedResources->markerMid; } + String markerEndResource() const { return inheritedResources->markerEnd; } + + // convenience + bool hasClipper() const { return !clipperResource().isEmpty(); } + bool hasMasker() const { return !maskerResource().isEmpty(); } + bool hasFilter() const { return !filterResource().isEmpty(); } + bool hasMarkers() const { return !markerStartResource().isEmpty() || !markerMidResource().isEmpty() || !markerEndResource().isEmpty(); } + bool hasStroke() const { return strokePaint()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE; } + bool hasFill() const { return fillPaint()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE; } + bool isVerticalWritingMode() const { return writingMode() == WM_TBRL || writingMode() == WM_TB; } + +protected: + // inherit + struct InheritedFlags { + bool operator==(const InheritedFlags& other) const + { + return (_colorRendering == other._colorRendering) + && (_imageRendering == other._imageRendering) + && (_shapeRendering == other._shapeRendering) + && (_clipRule == other._clipRule) + && (_fillRule == other._fillRule) + && (_capStyle == other._capStyle) + && (_joinStyle == other._joinStyle) + && (_textAnchor == other._textAnchor) + && (_colorInterpolation == other._colorInterpolation) + && (_colorInterpolationFilters == other._colorInterpolationFilters) + && (_writingMode == other._writingMode) + && (_glyphOrientationHorizontal == other._glyphOrientationHorizontal) + && (_glyphOrientationVertical == other._glyphOrientationVertical); + } + + bool operator!=(const InheritedFlags& other) const + { + return !(*this == other); + } + + unsigned _colorRendering : 2; // EColorRendering + unsigned _imageRendering : 2; // EImageRendering + unsigned _shapeRendering : 2; // EShapeRendering + unsigned _clipRule : 1; // WindRule + unsigned _fillRule : 1; // WindRule + unsigned _capStyle : 2; // LineCap + unsigned _joinStyle : 2; // LineJoin + unsigned _textAnchor : 2; // ETextAnchor + unsigned _colorInterpolation : 2; // EColorInterpolation + unsigned _colorInterpolationFilters : 2; // EColorInterpolation + unsigned _writingMode : 3; // SVGWritingMode + unsigned _glyphOrientationHorizontal : 3; // EGlyphOrientation + unsigned _glyphOrientationVertical : 3; // EGlyphOrientation + } svg_inherited_flags; + + // don't inherit + struct NonInheritedFlags { + // 32 bit non-inherited, don't add to the struct, or the operator will break. + bool operator==(const NonInheritedFlags &other) const { return _niflags == other._niflags; } + bool operator!=(const NonInheritedFlags &other) const { return _niflags != other._niflags; } + + union { + struct { + unsigned _alignmentBaseline : 4; // EAlignmentBaseline + unsigned _dominantBaseline : 4; // EDominantBaseline + unsigned _baselineShift : 2; // EBaselineShift + unsigned _vectorEffect: 1; // EVectorEffect + // 21 bits unused + } f; + uint32_t _niflags; + }; + } svg_noninherited_flags; + + // inherited attributes + DataRef fill; + DataRef stroke; + DataRef text; + DataRef inheritedResources; + + // non-inherited attributes + DataRef stops; + DataRef misc; + DataRef shadowSVG; + DataRef resources; + +private: + enum CreateDefaultType { CreateDefault }; + + SVGRenderStyle(); + SVGRenderStyle(const SVGRenderStyle&); + SVGRenderStyle(CreateDefaultType); // Used to create the default style. + + void setBitDefaults() + { + svg_inherited_flags._clipRule = initialClipRule(); + svg_inherited_flags._colorRendering = initialColorRendering(); + svg_inherited_flags._fillRule = initialFillRule(); + svg_inherited_flags._imageRendering = initialImageRendering(); + svg_inherited_flags._shapeRendering = initialShapeRendering(); + svg_inherited_flags._textAnchor = initialTextAnchor(); + svg_inherited_flags._capStyle = initialCapStyle(); + svg_inherited_flags._joinStyle = initialJoinStyle(); + svg_inherited_flags._colorInterpolation = initialColorInterpolation(); + svg_inherited_flags._colorInterpolationFilters = initialColorInterpolationFilters(); + svg_inherited_flags._writingMode = initialWritingMode(); + svg_inherited_flags._glyphOrientationHorizontal = initialGlyphOrientationHorizontal(); + svg_inherited_flags._glyphOrientationVertical = initialGlyphOrientationVertical(); + + svg_noninherited_flags._niflags = 0; + svg_noninherited_flags.f._alignmentBaseline = initialAlignmentBaseline(); + svg_noninherited_flags.f._dominantBaseline = initialDominantBaseline(); + svg_noninherited_flags.f._baselineShift = initialBaselineShift(); + svg_noninherited_flags.f._vectorEffect = initialVectorEffect(); + } +}; + +} // namespace WebCore + +#endif // ENABLE(SVG) +#endif // SVGRenderStyle_h diff --git a/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp b/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp new file mode 100644 index 0000000..c30ae6d --- /dev/null +++ b/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp @@ -0,0 +1,227 @@ +/* + Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann + 2004, 2005, 2007 Rob Buis + Copyright (C) Research In Motion Limited 2010. All rights reserved. + + Based on khtml code by: + Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) + Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) + Copyright (C) 2002-2003 Dirk Mueller (mueller@kde.org) + Copyright (C) 2002 Apple Computer, Inc. + + 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 "config.h" + +#if ENABLE(SVG) +#include "SVGRenderStyleDefs.h" + +#include "RenderStyle.h" +#include "SVGRenderStyle.h" + +namespace WebCore { + +StyleFillData::StyleFillData() + : opacity(SVGRenderStyle::initialFillOpacity()) + , paint(SVGRenderStyle::initialFillPaint()) +{ +} + +StyleFillData::StyleFillData(const StyleFillData& other) + : RefCounted() + , opacity(other.opacity) + , paint(other.paint) +{ +} + +bool StyleFillData::operator==(const StyleFillData& other) const +{ + if (opacity != other.opacity) + return false; + + if (!paint || !other.paint) + return paint == other.paint; + + if (paint->paintType() != other.paint->paintType()) + return false; + + if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_URI) + return paint->uri() == other.paint->uri(); + + if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR) + return paint->color() == other.paint->color(); + + return paint == other.paint; +} + +StyleStrokeData::StyleStrokeData() + : opacity(SVGRenderStyle::initialStrokeOpacity()) + , miterLimit(SVGRenderStyle::initialStrokeMiterLimit()) + , width(SVGRenderStyle::initialStrokeWidth()) + , dashOffset(SVGRenderStyle::initialStrokeDashOffset()) + , dashArray(SVGRenderStyle::initialStrokeDashArray()) + , paint(SVGRenderStyle::initialStrokePaint()) +{ +} + +StyleStrokeData::StyleStrokeData(const StyleStrokeData& other) + : RefCounted() + , opacity(other.opacity) + , miterLimit(other.miterLimit) + , width(other.width) + , dashOffset(other.dashOffset) + , dashArray(other.dashArray) + , paint(other.paint) +{ +} + +bool StyleStrokeData::operator==(const StyleStrokeData& other) const +{ + return paint == other.paint + && width == other.width + && opacity == other.opacity + && miterLimit == other.miterLimit + && dashOffset == other.dashOffset + && dashArray == other.dashArray; +} + +StyleStopData::StyleStopData() + : opacity(SVGRenderStyle::initialStopOpacity()) + , color(SVGRenderStyle::initialStopColor()) +{ +} + +StyleStopData::StyleStopData(const StyleStopData& other) + : RefCounted() + , opacity(other.opacity) + , color(other.color) +{ +} + +bool StyleStopData::operator==(const StyleStopData& other) const +{ + return color == other.color + && opacity == other.opacity; +} + +StyleTextData::StyleTextData() + : kerning(SVGRenderStyle::initialKerning()) +{ +} + +StyleTextData::StyleTextData(const StyleTextData& other) + : RefCounted() + , kerning(other.kerning) +{ +} + +bool StyleTextData::operator==(const StyleTextData& other) const +{ + return kerning == other.kerning; +} + +StyleMiscData::StyleMiscData() + : floodColor(SVGRenderStyle::initialFloodColor()) + , floodOpacity(SVGRenderStyle::initialFloodOpacity()) + , lightingColor(SVGRenderStyle::initialLightingColor()) + , baselineShiftValue(SVGRenderStyle::initialBaselineShiftValue()) +{ +} + +StyleMiscData::StyleMiscData(const StyleMiscData& other) + : RefCounted() + , floodColor(other.floodColor) + , floodOpacity(other.floodOpacity) + , lightingColor(other.lightingColor) + , baselineShiftValue(other.baselineShiftValue) +{ +} + +bool StyleMiscData::operator==(const StyleMiscData& other) const +{ + return floodOpacity == other.floodOpacity + && floodColor == other.floodColor + && lightingColor == other.lightingColor + && baselineShiftValue == other.baselineShiftValue; +} + +StyleShadowSVGData::StyleShadowSVGData() +{ +} + +StyleShadowSVGData::StyleShadowSVGData(const StyleShadowSVGData& other) + : RefCounted() + , shadow(other.shadow ? new ShadowData(*other.shadow) : 0) +{ +} + +bool StyleShadowSVGData::operator==(const StyleShadowSVGData& other) const +{ + if ((!shadow && other.shadow) || (shadow && !other.shadow)) + return false; + if (shadow && other.shadow && (*shadow != *other.shadow)) + return false; + return true; +} + +StyleResourceData::StyleResourceData() + : clipper(SVGRenderStyle::initialClipperResource()) + , filter(SVGRenderStyle::initialFilterResource()) + , masker(SVGRenderStyle::initialMaskerResource()) +{ +} + +StyleResourceData::StyleResourceData(const StyleResourceData& other) + : RefCounted() + , clipper(other.clipper) + , filter(other.filter) + , masker(other.masker) +{ +} + +bool StyleResourceData::operator==(const StyleResourceData& other) const +{ + return clipper == other.clipper + && filter == other.filter + && masker == other.masker; +} + +StyleInheritedResourceData::StyleInheritedResourceData() + : markerStart(SVGRenderStyle::initialMarkerStartResource()) + , markerMid(SVGRenderStyle::initialMarkerMidResource()) + , markerEnd(SVGRenderStyle::initialMarkerEndResource()) +{ +} + +StyleInheritedResourceData::StyleInheritedResourceData(const StyleInheritedResourceData& other) + : RefCounted() + , markerStart(other.markerStart) + , markerMid(other.markerMid) + , markerEnd(other.markerEnd) +{ +} + +bool StyleInheritedResourceData::operator==(const StyleInheritedResourceData& other) const +{ + return markerStart == other.markerStart + && markerMid == other.markerMid + && markerEnd == other.markerEnd; +} + +} + +#endif // ENABLE(SVG) diff --git a/Source/WebCore/rendering/style/SVGRenderStyleDefs.h b/Source/WebCore/rendering/style/SVGRenderStyleDefs.h new file mode 100644 index 0000000..de058a2 --- /dev/null +++ b/Source/WebCore/rendering/style/SVGRenderStyleDefs.h @@ -0,0 +1,266 @@ +/* + Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann + 2004, 2005 Rob Buis + Copyright (C) Research In Motion Limited 2010. All rights reserved. + + Based on khtml code by: + Copyright (C) 2000-2003 Lars Knoll (knoll@kde.org) + (C) 2000 Antti Koivisto (koivisto@kde.org) + (C) 2000-2003 Dirk Mueller (mueller@kde.org) + (C) 2002-2003 Apple Computer, Inc. + + 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 SVGRenderStyleDefs_h +#define SVGRenderStyleDefs_h + +#if ENABLE(SVG) +#include "Color.h" +#include "PlatformString.h" +#include "SVGLength.h" +#include "ShadowData.h" +#include +#include +#include +#include + +namespace WebCore { + + enum EBaselineShift { + BS_BASELINE, BS_SUB, BS_SUPER, BS_LENGTH + }; + + enum ETextAnchor { + TA_START, TA_MIDDLE, TA_END + }; + + enum EColorInterpolation { + CI_AUTO, CI_SRGB, CI_LINEARRGB + }; + + enum EColorRendering { + CR_AUTO, CR_OPTIMIZESPEED, CR_OPTIMIZEQUALITY + }; + + enum EImageRendering { + IR_AUTO, IR_OPTIMIZESPEED, IR_OPTIMIZEQUALITY + }; + + enum EShapeRendering { + SR_AUTO, SR_OPTIMIZESPEED, SR_CRISPEDGES, SR_GEOMETRICPRECISION + }; + + enum SVGWritingMode { + WM_LRTB, WM_LR, WM_RLTB, WM_RL, WM_TBRL, WM_TB + }; + + enum EGlyphOrientation { + GO_0DEG, GO_90DEG, GO_180DEG, GO_270DEG, GO_AUTO + }; + + enum EAlignmentBaseline { + AB_AUTO, AB_BASELINE, AB_BEFORE_EDGE, AB_TEXT_BEFORE_EDGE, + AB_MIDDLE, AB_CENTRAL, AB_AFTER_EDGE, AB_TEXT_AFTER_EDGE, + AB_IDEOGRAPHIC, AB_ALPHABETIC, AB_HANGING, AB_MATHEMATICAL + }; + + enum EDominantBaseline { + DB_AUTO, DB_USE_SCRIPT, DB_NO_CHANGE, DB_RESET_SIZE, + DB_IDEOGRAPHIC, DB_ALPHABETIC, DB_HANGING, DB_MATHEMATICAL, + DB_CENTRAL, DB_MIDDLE, DB_TEXT_AFTER_EDGE, DB_TEXT_BEFORE_EDGE + }; + + enum EVectorEffect { + VE_NONE, + VE_NON_SCALING_STROKE + }; + + class CSSValue; + class CSSValueList; + class SVGPaint; + + // Inherited/Non-Inherited Style Datastructures + class StyleFillData : public RefCounted { + public: + static PassRefPtr create() { return adoptRef(new StyleFillData); } + PassRefPtr copy() const { return adoptRef(new StyleFillData(*this)); } + + bool operator==(const StyleFillData&) const; + bool operator!=(const StyleFillData& other) const + { + return !(*this == other); + } + + float opacity; + RefPtr paint; + + private: + StyleFillData(); + StyleFillData(const StyleFillData&); + }; + + class StyleStrokeData : public RefCounted { + public: + static PassRefPtr create() { return adoptRef(new StyleStrokeData); } + PassRefPtr copy() const { return adoptRef(new StyleStrokeData(*this)); } + + bool operator==(const StyleStrokeData&) const; + bool operator!=(const StyleStrokeData& other) const + { + return !(*this == other); + } + + float opacity; + float miterLimit; + + SVGLength width; + SVGLength dashOffset; + Vector dashArray; + + RefPtr paint; + + private: + StyleStrokeData(); + StyleStrokeData(const StyleStrokeData&); + }; + + class StyleStopData : public RefCounted { + public: + static PassRefPtr create() { return adoptRef(new StyleStopData); } + PassRefPtr copy() const { return adoptRef(new StyleStopData(*this)); } + + bool operator==(const StyleStopData&) const; + bool operator!=(const StyleStopData& other) const + { + return !(*this == other); + } + + float opacity; + Color color; + + private: + StyleStopData(); + StyleStopData(const StyleStopData&); + }; + + class StyleTextData : public RefCounted { + public: + static PassRefPtr create() { return adoptRef(new StyleTextData); } + PassRefPtr copy() const { return adoptRef(new StyleTextData(*this)); } + + bool operator==(const StyleTextData& other) const; + bool operator!=(const StyleTextData& other) const + { + return !(*this == other); + } + + SVGLength kerning; + + private: + StyleTextData(); + StyleTextData(const StyleTextData&); + }; + + // Note: the rule for this class is, *no inheritance* of these props + class StyleMiscData : public RefCounted { + public: + static PassRefPtr create() { return adoptRef(new StyleMiscData); } + PassRefPtr copy() const { return adoptRef(new StyleMiscData(*this)); } + + bool operator==(const StyleMiscData&) const; + bool operator!=(const StyleMiscData& other) const + { + return !(*this == other); + } + + Color floodColor; + float floodOpacity; + Color lightingColor; + + // non-inherited text stuff lives here not in StyleTextData. + SVGLength baselineShiftValue; + + private: + StyleMiscData(); + StyleMiscData(const StyleMiscData&); + }; + + class StyleShadowSVGData : public RefCounted { + public: + static PassRefPtr create() { return adoptRef(new StyleShadowSVGData); } + PassRefPtr copy() const { return adoptRef(new StyleShadowSVGData(*this)); } + + bool operator==(const StyleShadowSVGData&) const; + bool operator!=(const StyleShadowSVGData& other) const + { + return !(*this == other); + } + + OwnPtr shadow; + + private: + StyleShadowSVGData(); + StyleShadowSVGData(const StyleShadowSVGData&); + }; + + // Non-inherited resources + class StyleResourceData : public RefCounted { + public: + static PassRefPtr create() { return adoptRef(new StyleResourceData); } + PassRefPtr copy() const { return adoptRef(new StyleResourceData(*this)); } + + bool operator==(const StyleResourceData&) const; + bool operator!=(const StyleResourceData& other) const + { + return !(*this == other); + } + + String clipper; + String filter; + String masker; + + private: + StyleResourceData(); + StyleResourceData(const StyleResourceData&); + }; + + // Inherited resources + class StyleInheritedResourceData : public RefCounted { + public: + static PassRefPtr create() { return adoptRef(new StyleInheritedResourceData); } + PassRefPtr copy() const { return adoptRef(new StyleInheritedResourceData(*this)); } + + bool operator==(const StyleInheritedResourceData&) const; + bool operator!=(const StyleInheritedResourceData& other) const + { + return !(*this == other); + } + + String markerStart; + String markerMid; + String markerEnd; + + private: + StyleInheritedResourceData(); + StyleInheritedResourceData(const StyleInheritedResourceData&); + }; + +} // namespace WebCore + +#endif // ENABLE(SVG) + +#endif // SVGRenderStyleDefs_h diff --git a/Source/WebCore/rendering/style/ShadowData.cpp b/Source/WebCore/rendering/style/ShadowData.cpp new file mode 100644 index 0000000..e8d381c --- /dev/null +++ b/Source/WebCore/rendering/style/ShadowData.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 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 "config.h" +#include "ShadowData.h" + +#include "FloatRect.h" +#include "IntRect.h" + +using namespace std; + +namespace WebCore { + +ShadowData::ShadowData(const ShadowData& o) + : m_x(o.m_x) + , m_y(o.m_y) + , m_blur(o.m_blur) + , m_spread(o.m_spread) + , m_color(o.m_color) + , m_style(o.m_style) + , m_isWebkitBoxShadow(o.m_isWebkitBoxShadow) +{ + m_next = o.m_next ? new ShadowData(*o.m_next) : 0; +} + +bool ShadowData::operator==(const ShadowData& o) const +{ + if ((m_next && !o.m_next) || (!m_next && o.m_next) + || (m_next && o.m_next && *m_next != *o.m_next)) + return false; + + return m_x == o.m_x + && m_y == o.m_y + && m_blur == o.m_blur + && m_spread == o.m_spread + && m_style == o.m_style + && m_color == o.m_color + && m_isWebkitBoxShadow == o.m_isWebkitBoxShadow; +} + +static inline void calculateShadowExtent(const ShadowData* shadow, int additionalOutlineSize, int& shadowLeft, int& shadowRight, int& shadowTop, int& shadowBottom) +{ + do { + int blurAndSpread = shadow->blur() + shadow->spread() + additionalOutlineSize; + if (shadow->style() == Normal) { + shadowLeft = min(shadow->x() - blurAndSpread, shadowLeft); + shadowRight = max(shadow->x() + blurAndSpread, shadowRight); + shadowTop = min(shadow->y() - blurAndSpread, shadowTop); + shadowBottom = max(shadow->y() + blurAndSpread, shadowBottom); + } + + shadow = shadow->next(); + } while (shadow); +} + +void ShadowData::adjustRectForShadow(IntRect& rect, int additionalOutlineSize) const +{ + int shadowLeft = 0; + int shadowRight = 0; + int shadowTop = 0; + int shadowBottom = 0; + calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom); + + rect.move(shadowLeft, shadowTop); + rect.setWidth(rect.width() - shadowLeft + shadowRight); + rect.setHeight(rect.height() - shadowTop + shadowBottom); +} + +void ShadowData::adjustRectForShadow(FloatRect& rect, int additionalOutlineSize) const +{ + int shadowLeft = 0; + int shadowRight = 0; + int shadowTop = 0; + int shadowBottom = 0; + calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom); + + rect.move(shadowLeft, shadowTop); + rect.setWidth(rect.width() - shadowLeft + shadowRight); + rect.setHeight(rect.height() - shadowTop + shadowBottom); +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/ShadowData.h b/Source/WebCore/rendering/style/ShadowData.h new file mode 100644 index 0000000..fb5926d --- /dev/null +++ b/Source/WebCore/rendering/style/ShadowData.h @@ -0,0 +1,101 @@ +/* + * 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, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 ShadowData_h +#define ShadowData_h + +#include "Color.h" +#include + +namespace WebCore { + +class FloatRect; +class IntRect; + +enum ShadowStyle { Normal, Inset }; + +// This struct holds information about shadows for the text-shadow and box-shadow properties. + +class ShadowData : public FastAllocBase { +public: + ShadowData() + : m_x(0) + , m_y(0) + , m_blur(0) + , m_spread(0) + , m_style(Normal) + , m_isWebkitBoxShadow(false) + , m_next(0) + { + } + + ShadowData(int x, int y, int blur, int spread, ShadowStyle style, bool isWebkitBoxShadow, const Color& color) + : m_x(x) + , m_y(y) + , m_blur(blur) + , m_spread(spread) + , m_color(color) + , m_style(style) + , m_isWebkitBoxShadow(isWebkitBoxShadow) + , m_next(0) + { + } + + ShadowData(const ShadowData& o); + ~ShadowData() { delete m_next; } + + bool operator==(const ShadowData& o) const; + bool operator!=(const ShadowData& o) const + { + return !(*this == o); + } + + int x() const { return m_x; } + int y() const { return m_y; } + int blur() const { return m_blur; } + int spread() const { return m_spread; } + ShadowStyle style() const { return m_style; } + const Color& color() const { return m_color; } + bool isWebkitBoxShadow() const { return m_isWebkitBoxShadow; } + + const ShadowData* next() const { return m_next; } + void setNext(ShadowData* shadow) { m_next = shadow; } + + void adjustRectForShadow(IntRect&, int additionalOutlineSize = 0) const; + void adjustRectForShadow(FloatRect&, int additionalOutlineSize = 0) const; + +private: + int m_x; + int m_y; + int m_blur; + int m_spread; + Color m_color; + ShadowStyle m_style; + bool m_isWebkitBoxShadow; + ShadowData* m_next; +}; + +} // namespace WebCore + +#endif // ShadowData_h diff --git a/Source/WebCore/rendering/style/StyleAllInOne.cpp b/Source/WebCore/rendering/style/StyleAllInOne.cpp new file mode 100644 index 0000000..25b539f --- /dev/null +++ b/Source/WebCore/rendering/style/StyleAllInOne.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2010 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 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 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. + */ + +// This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build. + +#include "ContentData.cpp" +#include "CounterDirectives.cpp" +#include "FillLayer.cpp" +#include "KeyframeList.cpp" +#include "NinePieceImage.cpp" +#include "RenderStyle.cpp" +#include "SVGRenderStyle.cpp" +#include "SVGRenderStyleDefs.cpp" +#include "ShadowData.cpp" +#include "StyleBackgroundData.cpp" +#include "StyleBoxData.cpp" +#include "StyleCachedImage.cpp" +#include "StyleFlexibleBoxData.cpp" +#include "StyleGeneratedImage.cpp" +#include "StyleInheritedData.cpp" +#include "StyleMarqueeData.cpp" +#include "StyleMultiColData.cpp" +#include "StyleRareInheritedData.cpp" +#include "StyleRareNonInheritedData.cpp" +#include "StyleSurroundData.cpp" +#include "StyleTransformData.cpp" +#include "StyleVisualData.cpp" diff --git a/Source/WebCore/rendering/style/StyleBackgroundData.cpp b/Source/WebCore/rendering/style/StyleBackgroundData.cpp new file mode 100644 index 0000000..08f5527 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleBackgroundData.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "StyleBackgroundData.h" + +#include "RenderStyle.h" +#include "RenderStyleConstants.h" + +namespace WebCore { + +StyleBackgroundData::StyleBackgroundData() + : m_background(BackgroundFillLayer) + , m_color(RenderStyle::initialBackgroundColor()) +{ +} + +StyleBackgroundData::StyleBackgroundData(const StyleBackgroundData& o) + : RefCounted() + , m_background(o.m_background) + , m_color(o.m_color) + , m_outline(o.m_outline) +{ +} + +bool StyleBackgroundData::operator==(const StyleBackgroundData& o) const +{ + return m_background == o.m_background && m_color == o.m_color && m_outline == o.m_outline; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleBackgroundData.h b/Source/WebCore/rendering/style/StyleBackgroundData.h new file mode 100644 index 0000000..48a700e --- /dev/null +++ b/Source/WebCore/rendering/style/StyleBackgroundData.h @@ -0,0 +1,65 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleBackgroundData_h +#define StyleBackgroundData_h + +#include "Color.h" +#include "FillLayer.h" +#include "OutlineValue.h" +#include +#include + +namespace WebCore { + +class StyleBackgroundData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleBackgroundData); } + PassRefPtr copy() const { return adoptRef(new StyleBackgroundData(*this)); } + ~StyleBackgroundData() { } + + bool operator==(const StyleBackgroundData& o) const; + bool operator!=(const StyleBackgroundData& o) const + { + return !(*this == o); + } + + const FillLayer& background() const { return m_background; } + const Color& color() const { return m_color; } + const OutlineValue& outline() const { return m_outline; } + +private: + friend class RenderStyle; + + StyleBackgroundData(); + StyleBackgroundData(const StyleBackgroundData&); + + FillLayer m_background; + Color m_color; + OutlineValue m_outline; +}; + +} // namespace WebCore + +#endif // StyleBackgroundData_h diff --git a/Source/WebCore/rendering/style/StyleBoxData.cpp b/Source/WebCore/rendering/style/StyleBoxData.cpp new file mode 100644 index 0000000..2c523da --- /dev/null +++ b/Source/WebCore/rendering/style/StyleBoxData.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "StyleBoxData.h" + +#include "RenderStyle.h" +#include "RenderStyleConstants.h" + +namespace WebCore { + +StyleBoxData::StyleBoxData() + : m_minWidth(RenderStyle::initialMinSize()) + , m_maxWidth(RenderStyle::initialMaxSize()) + , m_minHeight(RenderStyle::initialMinSize()) + , m_maxHeight(RenderStyle::initialMaxSize()) + , m_zIndex(0) + , m_hasAutoZIndex(true) + , m_boxSizing(CONTENT_BOX) +{ +} + +StyleBoxData::StyleBoxData(const StyleBoxData& o) + : RefCounted() + , m_width(o.m_width) + , m_height(o.m_height) + , m_minWidth(o.m_minWidth) + , m_maxWidth(o.m_maxWidth) + , m_minHeight(o.m_minHeight) + , m_maxHeight(o.m_maxHeight) + , m_zIndex(o.m_zIndex) + , m_hasAutoZIndex(o.m_hasAutoZIndex) + , m_boxSizing(o.m_boxSizing) +{ +} + +bool StyleBoxData::operator==(const StyleBoxData& o) const +{ + return m_width == o.m_width + && m_height == o.m_height + && m_minWidth == o.m_minWidth + && m_maxWidth == o.m_maxWidth + && m_minHeight == o.m_minHeight + && m_maxHeight == o.m_maxHeight + && m_zIndex == o.m_zIndex + && m_hasAutoZIndex == o.m_hasAutoZIndex + && m_boxSizing == o.m_boxSizing; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleBoxData.h b/Source/WebCore/rendering/style/StyleBoxData.h new file mode 100644 index 0000000..00bce4e --- /dev/null +++ b/Source/WebCore/rendering/style/StyleBoxData.h @@ -0,0 +1,86 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleBoxData_h +#define StyleBoxData_h + +#include "Length.h" +#include "RenderStyleConstants.h" +#include +#include + +namespace WebCore { + +class StyleBoxData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleBoxData); } + PassRefPtr copy() const { return adoptRef(new StyleBoxData(*this)); } + + bool operator==(const StyleBoxData& o) const; + bool operator!=(const StyleBoxData& o) const + { + return !(*this == o); + } + + Length width() const { return m_width; } + Length height() const { return m_height; } + + Length minWidth() const { return m_minWidth; } + Length minHeight() const { return m_minHeight; } + + Length maxWidth() const { return m_maxWidth; } + Length maxHeight() const { return m_maxHeight; } + + Length verticalAlign() const { return m_verticalAlign; } + + int zIndex() const { return m_zIndex; } + bool hasAutoZIndex() const { return m_hasAutoZIndex; } + + EBoxSizing boxSizing() const { return static_cast(m_boxSizing); } + +private: + friend class RenderStyle; + + StyleBoxData(); + StyleBoxData(const StyleBoxData&); + + Length m_width; + Length m_height; + + Length m_minWidth; + Length m_maxWidth; + + Length m_minHeight; + Length m_maxHeight; + + Length m_verticalAlign; + + int m_zIndex; + bool m_hasAutoZIndex : 1; + unsigned m_boxSizing : 1; // EBoxSizing +}; + +} // namespace WebCore + +#endif // StyleBoxData_h diff --git a/Source/WebCore/rendering/style/StyleCachedImage.cpp b/Source/WebCore/rendering/style/StyleCachedImage.cpp new file mode 100644 index 0000000..1d7aba8 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleCachedImage.cpp @@ -0,0 +1,92 @@ +/* + * 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 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 "config.h" +#include "StyleCachedImage.h" + +#include "CachedImage.h" +#include "RenderObject.h" + +namespace WebCore { + +PassRefPtr StyleCachedImage::cssValue() const +{ + return CSSPrimitiveValue::create(m_image->url(), CSSPrimitiveValue::CSS_URI); +} + +bool StyleCachedImage::canRender(float multiplier) const +{ + return m_image->canRender(multiplier); +} + +bool StyleCachedImage::isLoaded() const +{ + return m_image->isLoaded(); +} + +bool StyleCachedImage::errorOccurred() const +{ + return m_image->errorOccurred(); +} + +IntSize StyleCachedImage::imageSize(const RenderObject* /*renderer*/, float multiplier) const +{ + return m_image->imageSize(multiplier); +} + +bool StyleCachedImage::imageHasRelativeWidth() const +{ + return m_image->imageHasRelativeWidth(); +} + +bool StyleCachedImage::imageHasRelativeHeight() const +{ + return m_image->imageHasRelativeHeight(); +} + +bool StyleCachedImage::usesImageContainerSize() const +{ + return m_image->usesImageContainerSize(); +} + +void StyleCachedImage::setImageContainerSize(const IntSize& size) +{ + return m_image->setImageContainerSize(size); +} + +void StyleCachedImage::addClient(RenderObject* renderer) +{ + return m_image->addClient(renderer); +} + +void StyleCachedImage::removeClient(RenderObject* renderer) +{ + return m_image->removeClient(renderer); +} + +Image* StyleCachedImage::image(RenderObject*, const IntSize&) const +{ + return m_image->image(); +} + +} diff --git a/Source/WebCore/rendering/style/StyleCachedImage.h b/Source/WebCore/rendering/style/StyleCachedImage.h new file mode 100644 index 0000000..3d6e1a2 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleCachedImage.h @@ -0,0 +1,67 @@ +/* + * 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 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 StyleCachedImage_h +#define StyleCachedImage_h + +#include "CachedResourceHandle.h" +#include "StyleImage.h" + +namespace WebCore { + +class CachedImage; + +class StyleCachedImage : public StyleImage { +public: + static PassRefPtr create(CachedImage* image) { return adoptRef(new StyleCachedImage(image)); } + virtual WrappedImagePtr data() const { return m_image.get(); } + + virtual bool isCachedImage() const { return true; } + + virtual PassRefPtr cssValue() const; + + CachedImage* cachedImage() const { return m_image.get(); } + + virtual bool canRender(float multiplier) const; + virtual bool isLoaded() const; + virtual bool errorOccurred() const; + virtual IntSize imageSize(const RenderObject*, float multiplier) const; + virtual bool imageHasRelativeWidth() const; + virtual bool imageHasRelativeHeight() const; + virtual bool usesImageContainerSize() const; + virtual void setImageContainerSize(const IntSize&); + virtual void addClient(RenderObject*); + virtual void removeClient(RenderObject*); + virtual Image* image(RenderObject*, const IntSize&) const; + +private: + StyleCachedImage(CachedImage* image) + : m_image(image) + { + } + + CachedResourceHandle m_image; +}; + +} +#endif diff --git a/Source/WebCore/rendering/style/StyleDashboardRegion.h b/Source/WebCore/rendering/style/StyleDashboardRegion.h new file mode 100644 index 0000000..bbb0cda --- /dev/null +++ b/Source/WebCore/rendering/style/StyleDashboardRegion.h @@ -0,0 +1,61 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleDashboardRegion_h +#define StyleDashboardRegion_h +#if ENABLE(DASHBOARD_SUPPORT) + +#include "LengthBox.h" +#include "PlatformString.h" + +namespace WebCore { + +// Dashboard region attributes. Not inherited. + +struct StyleDashboardRegion { + String label; + LengthBox offset; + int type; + + enum { + None, + Circle, + Rectangle + }; + + bool operator==(const StyleDashboardRegion& o) const + { + return type == o.type && offset == o.offset && label == o.label; + } + + bool operator!=(const StyleDashboardRegion& o) const + { + return !(*this == o); + } +}; + +} // namespace WebCore + +#endif // ENABLE(DASHBOARD_SUPPORT) +#endif // StyleDashboardRegion_h diff --git a/Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp b/Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp new file mode 100644 index 0000000..7c00080 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "StyleFlexibleBoxData.h" + +#include "RenderStyle.h" + +namespace WebCore { + +StyleFlexibleBoxData::StyleFlexibleBoxData() + : flex(RenderStyle::initialBoxFlex()) + , flex_group(RenderStyle::initialBoxFlexGroup()) + , ordinal_group(RenderStyle::initialBoxOrdinalGroup()) + , align(RenderStyle::initialBoxAlign()) + , pack(RenderStyle::initialBoxPack()) + , orient(RenderStyle::initialBoxOrient()) + , lines(RenderStyle::initialBoxLines()) +{ +} + +StyleFlexibleBoxData::StyleFlexibleBoxData(const StyleFlexibleBoxData& o) + : RefCounted() + , flex(o.flex) + , flex_group(o.flex_group) + , ordinal_group(o.ordinal_group) + , align(o.align) + , pack(o.pack) + , orient(o.orient) + , lines(o.lines) +{ +} + +bool StyleFlexibleBoxData::operator==(const StyleFlexibleBoxData& o) const +{ + return flex == o.flex && flex_group == o.flex_group && + ordinal_group == o.ordinal_group && align == o.align && + pack == o.pack && orient == o.orient && lines == o.lines; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleFlexibleBoxData.h b/Source/WebCore/rendering/style/StyleFlexibleBoxData.h new file mode 100644 index 0000000..f5d5e74 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleFlexibleBoxData.h @@ -0,0 +1,60 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleFlexibleBoxData_h +#define StyleFlexibleBoxData_h + +#include +#include + +namespace WebCore { + +class StyleFlexibleBoxData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleFlexibleBoxData); } + PassRefPtr copy() const { return adoptRef(new StyleFlexibleBoxData(*this)); } + + bool operator==(const StyleFlexibleBoxData& o) const; + bool operator!=(const StyleFlexibleBoxData& o) const + { + return !(*this == o); + } + + float flex; + unsigned int flex_group; + unsigned int ordinal_group; + + unsigned align : 3; // EBoxAlignment + unsigned pack: 3; // EBoxAlignment + unsigned orient: 1; // EBoxOrient + unsigned lines : 1; // EBoxLines + +private: + StyleFlexibleBoxData(); + StyleFlexibleBoxData(const StyleFlexibleBoxData&); +}; + +} // namespace WebCore + +#endif // StyleFlexibleBoxData_h diff --git a/Source/WebCore/rendering/style/StyleGeneratedImage.cpp b/Source/WebCore/rendering/style/StyleGeneratedImage.cpp new file mode 100644 index 0000000..2322f5f --- /dev/null +++ b/Source/WebCore/rendering/style/StyleGeneratedImage.cpp @@ -0,0 +1,80 @@ +/* + * 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 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 "config.h" +#include "StyleGeneratedImage.h" + +#include "CSSImageGeneratorValue.h" +#include "RenderObject.h" + +namespace WebCore { + +PassRefPtr StyleGeneratedImage::cssValue() const +{ + return m_generator; +} + +IntSize StyleGeneratedImage::imageSize(const RenderObject* renderer, float multiplier) const +{ + if (m_fixedSize) { + IntSize fixedSize = m_generator->fixedSize(renderer); + if (multiplier == 1.0f) + return fixedSize; + + int width = fixedSize.width() * multiplier; + int height = fixedSize.height() * multiplier; + + // Don't let images that have a width/height >= 1 shrink below 1 when zoomed. + if (fixedSize.width() > 0) + width = max(1, width); + + if (fixedSize.height() > 0) + height = max(1, height); + + return IntSize(width, height); + } + + return m_containerSize; +} + +void StyleGeneratedImage::setImageContainerSize(const IntSize& size) +{ + m_containerSize = size; +} + +void StyleGeneratedImage::addClient(RenderObject* renderer) +{ + m_generator->addClient(renderer, IntSize()); +} + +void StyleGeneratedImage::removeClient(RenderObject* renderer) +{ + m_generator->removeClient(renderer); +} + +Image* StyleGeneratedImage::image(RenderObject* renderer, const IntSize& size) const +{ + return m_generator->image(renderer, size); +} + +} diff --git a/Source/WebCore/rendering/style/StyleGeneratedImage.h b/Source/WebCore/rendering/style/StyleGeneratedImage.h new file mode 100644 index 0000000..7be1f6a --- /dev/null +++ b/Source/WebCore/rendering/style/StyleGeneratedImage.h @@ -0,0 +1,69 @@ +/* + * 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 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 StyleGeneratedImage_h +#define StyleGeneratedImage_h + +#include "StyleImage.h" + +namespace WebCore { + +class CSSValue; +class CSSImageGeneratorValue; + +class StyleGeneratedImage : public StyleImage { +public: + static PassRefPtr create(CSSImageGeneratorValue* val, bool fixedSize) + { + return adoptRef(new StyleGeneratedImage(val, fixedSize)); + } + + virtual WrappedImagePtr data() const { return m_generator; } + + virtual bool isGeneratedImage() const { return true; } + + virtual PassRefPtr cssValue() const; + + virtual IntSize imageSize(const RenderObject*, float multiplier) const; + virtual bool imageHasRelativeWidth() const { return !m_fixedSize; } + virtual bool imageHasRelativeHeight() const { return !m_fixedSize; } + virtual bool usesImageContainerSize() const { return !m_fixedSize; } + virtual void setImageContainerSize(const IntSize&); + virtual void addClient(RenderObject*); + virtual void removeClient(RenderObject*); + virtual Image* image(RenderObject*, const IntSize&) const; + +private: + StyleGeneratedImage(CSSImageGeneratorValue* val, bool fixedSize) + : m_generator(val) + , m_fixedSize(fixedSize) + { + } + + CSSImageGeneratorValue* m_generator; // The generator holds a reference to us. + IntSize m_containerSize; + bool m_fixedSize; +}; + +} +#endif diff --git a/Source/WebCore/rendering/style/StyleImage.h b/Source/WebCore/rendering/style/StyleImage.h new file mode 100644 index 0000000..ead8d4a --- /dev/null +++ b/Source/WebCore/rendering/style/StyleImage.h @@ -0,0 +1,84 @@ +/* + * 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 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 StyleImage_h +#define StyleImage_h + +#include "CSSValue.h" +#include "IntSize.h" +#include +#include +#include + +namespace WebCore { + +class CSSValue; +class Image; +class RenderObject; + +typedef void* WrappedImagePtr; + +class StyleImage : public RefCounted { +public: + virtual ~StyleImage() { } + + bool operator==(const StyleImage& other) const + { + return data() == other.data(); + } + + virtual PassRefPtr cssValue() const = 0; + + virtual bool canRender(float /*multiplier*/) const { return true; } + virtual bool isLoaded() const { return true; } + virtual bool errorOccurred() const { return false; } + virtual IntSize imageSize(const RenderObject*, float multiplier) const = 0; + virtual bool imageHasRelativeWidth() const = 0; + virtual bool imageHasRelativeHeight() const = 0; + virtual bool usesImageContainerSize() const = 0; + virtual void setImageContainerSize(const IntSize&) = 0; + virtual void addClient(RenderObject*) = 0; + virtual void removeClient(RenderObject*) = 0; + virtual Image* image(RenderObject*, const IntSize&) const = 0; + virtual WrappedImagePtr data() const = 0; + + virtual bool isCachedImage() const { return false; } + virtual bool isPendingImage() const { return false; } + virtual bool isGeneratedImage() const { return false; } + + static bool imagesEquivalent(StyleImage* image1, StyleImage* image2) + { + if (image1 != image2) { + if (!image1 || !image2) + return false; + return *image1 == *image2; + } + return true; + } + +protected: + StyleImage() { } +}; + +} +#endif diff --git a/Source/WebCore/rendering/style/StyleInheritedData.cpp b/Source/WebCore/rendering/style/StyleInheritedData.cpp new file mode 100644 index 0000000..874d053 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleInheritedData.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "StyleRareInheritedData.h" + +#include "RenderStyle.h" +#include "StyleImage.h" + +namespace WebCore { + +StyleInheritedData::StyleInheritedData() + : line_height(RenderStyle::initialLineHeight()) + , list_style_image(RenderStyle::initialListStyleImage()) + , color(RenderStyle::initialColor()) + , horizontal_border_spacing(RenderStyle::initialHorizontalBorderSpacing()) + , vertical_border_spacing(RenderStyle::initialVerticalBorderSpacing()) +{ +} + +StyleInheritedData::~StyleInheritedData() +{ +} + +StyleInheritedData::StyleInheritedData(const StyleInheritedData& o) + : RefCounted() + , line_height(o.line_height) + , list_style_image(o.list_style_image) + , font(o.font) + , color(o.color) + , horizontal_border_spacing(o.horizontal_border_spacing) + , vertical_border_spacing(o.vertical_border_spacing) +{ +} + +bool StyleInheritedData::operator==(const StyleInheritedData& o) const +{ + return + line_height == o.line_height && + StyleImage::imagesEquivalent(list_style_image.get(), o.list_style_image.get()) && + font == o.font && + color == o.color && + horizontal_border_spacing == o.horizontal_border_spacing && + vertical_border_spacing == o.vertical_border_spacing; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleInheritedData.h b/Source/WebCore/rendering/style/StyleInheritedData.h new file mode 100644 index 0000000..ea398db --- /dev/null +++ b/Source/WebCore/rendering/style/StyleInheritedData.h @@ -0,0 +1,69 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleInheritedData_h +#define StyleInheritedData_h + +#include "Color.h" +#include "Font.h" +#include "Length.h" +#include +#include +#include + +namespace WebCore { + +class StyleImage; + +class StyleInheritedData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleInheritedData); } + PassRefPtr copy() const { return adoptRef(new StyleInheritedData(*this)); } + ~StyleInheritedData(); + + bool operator==(const StyleInheritedData& o) const; + bool operator!=(const StyleInheritedData& o) const + { + return !(*this == o); + } + + // could be packed in a short but doesn't + // make a difference currently because of padding + Length line_height; + + RefPtr list_style_image; + + Font font; + Color color; + + short horizontal_border_spacing; + short vertical_border_spacing; +private: + StyleInheritedData(); + StyleInheritedData(const StyleInheritedData&); +}; + +} // namespace WebCore + +#endif // StyleInheritedData_h diff --git a/Source/WebCore/rendering/style/StyleMarqueeData.cpp b/Source/WebCore/rendering/style/StyleMarqueeData.cpp new file mode 100644 index 0000000..f0e824d --- /dev/null +++ b/Source/WebCore/rendering/style/StyleMarqueeData.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "StyleBackgroundData.h" + +#include "RenderStyle.h" + +namespace WebCore { + +StyleMarqueeData::StyleMarqueeData() + : increment(RenderStyle::initialMarqueeIncrement()) + , speed(RenderStyle::initialMarqueeSpeed()) + , loops(RenderStyle::initialMarqueeLoopCount()) + , behavior(RenderStyle::initialMarqueeBehavior()) + , direction(RenderStyle::initialMarqueeDirection()) +{ +} + +StyleMarqueeData::StyleMarqueeData(const StyleMarqueeData& o) + : RefCounted() + , increment(o.increment) + , speed(o.speed) + , loops(o.loops) + , behavior(o.behavior) + , direction(o.direction) +{ +} + +bool StyleMarqueeData::operator==(const StyleMarqueeData& o) const +{ + return increment == o.increment && speed == o.speed && direction == o.direction && + behavior == o.behavior && loops == o.loops; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleMarqueeData.h b/Source/WebCore/rendering/style/StyleMarqueeData.h new file mode 100644 index 0000000..5765f5d --- /dev/null +++ b/Source/WebCore/rendering/style/StyleMarqueeData.h @@ -0,0 +1,61 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleMarqueeData_h +#define StyleMarqueeData_h + +#include "Length.h" +#include "RenderStyleConstants.h" +#include +#include + +namespace WebCore { + +class StyleMarqueeData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleMarqueeData); } + PassRefPtr copy() const { return adoptRef(new StyleMarqueeData(*this)); } + + bool operator==(const StyleMarqueeData& o) const; + bool operator!=(const StyleMarqueeData& o) const + { + return !(*this == o); + } + + Length increment; + int speed; + + int loops; // -1 means infinite. + + unsigned behavior : 2; // EMarqueeBehavior + EMarqueeDirection direction : 3; // not unsigned because EMarqueeDirection has negative values + +private: + StyleMarqueeData(); + StyleMarqueeData(const StyleMarqueeData&); +}; + +} // namespace WebCore + +#endif // StyleMarqueeData_h diff --git a/Source/WebCore/rendering/style/StyleMultiColData.cpp b/Source/WebCore/rendering/style/StyleMultiColData.cpp new file mode 100644 index 0000000..3366e9f --- /dev/null +++ b/Source/WebCore/rendering/style/StyleMultiColData.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "StyleMultiColData.h" + +#include "RenderStyle.h" + +namespace WebCore { + +StyleMultiColData::StyleMultiColData() + : m_width(0) + , m_count(RenderStyle::initialColumnCount()) + , m_gap(0) + , m_autoWidth(true) + , m_autoCount(true) + , m_normalGap(true) + , m_columnSpan(false) + , m_breakBefore(RenderStyle::initialPageBreak()) + , m_breakAfter(RenderStyle::initialPageBreak()) + , m_breakInside(RenderStyle::initialPageBreak()) +{ +} + +StyleMultiColData::StyleMultiColData(const StyleMultiColData& o) + : RefCounted() + , m_width(o.m_width) + , m_count(o.m_count) + , m_gap(o.m_gap) + , m_rule(o.m_rule) + , m_autoWidth(o.m_autoWidth) + , m_autoCount(o.m_autoCount) + , m_normalGap(o.m_normalGap) + , m_columnSpan(o.m_columnSpan) + , m_breakBefore(o.m_breakBefore) + , m_breakAfter(o.m_breakAfter) + , m_breakInside(o.m_breakInside) +{ +} + +bool StyleMultiColData::operator==(const StyleMultiColData& o) const +{ + return m_width == o.m_width && m_count == o.m_count && m_gap == o.m_gap + && m_rule == o.m_rule && m_breakBefore == o.m_breakBefore + && m_autoWidth == o.m_autoWidth && m_autoCount == o.m_autoCount && m_normalGap == o.m_normalGap + && m_columnSpan == o.m_columnSpan && m_breakAfter == o.m_breakAfter && m_breakInside == o.m_breakInside; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleMultiColData.h b/Source/WebCore/rendering/style/StyleMultiColData.h new file mode 100644 index 0000000..9948846 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleMultiColData.h @@ -0,0 +1,76 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleMultiColData_h +#define StyleMultiColData_h + +#include "BorderValue.h" +#include "Length.h" +#include "RenderStyleConstants.h" +#include +#include + +namespace WebCore { + +// CSS3 Multi Column Layout + +class StyleMultiColData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleMultiColData); } + PassRefPtr copy() const { return adoptRef(new StyleMultiColData(*this)); } + + bool operator==(const StyleMultiColData& o) const; + bool operator!=(const StyleMultiColData &o) const + { + return !(*this == o); + } + + unsigned short ruleWidth() const + { + if (m_rule.style() == BNONE || m_rule.style() == BHIDDEN) + return 0; + return m_rule.width(); + } + + float m_width; + unsigned short m_count; + float m_gap; + BorderValue m_rule; + + bool m_autoWidth : 1; + bool m_autoCount : 1; + bool m_normalGap : 1; + bool m_columnSpan : 1; + unsigned m_breakBefore : 2; // EPageBreak + unsigned m_breakAfter : 2; // EPageBreak + unsigned m_breakInside : 2; // EPageBreak + +private: + StyleMultiColData(); + StyleMultiColData(const StyleMultiColData&); +}; + +} // namespace WebCore + +#endif // StyleMultiColData_h diff --git a/Source/WebCore/rendering/style/StylePendingImage.h b/Source/WebCore/rendering/style/StylePendingImage.h new file mode 100644 index 0000000..b0c9b01 --- /dev/null +++ b/Source/WebCore/rendering/style/StylePendingImage.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2010 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 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 StylePendingImage_h +#define StylePendingImage_h + +#include "StyleImage.h" + +namespace WebCore { + +// StylePendingImage is a placeholder StyleImage that is entered into the RenderStyle during +// style resolution, in order to avoid loading images that are not referenced by the final style. +// They should never exist in a RenderStyle after it has been returned from the style selector. + +class StylePendingImage : public StyleImage { +public: + static PassRefPtr create(CSSImageValue* value) { return adoptRef(new StylePendingImage(value)); } + + virtual WrappedImagePtr data() const { return m_value; } + + virtual bool isPendingImage() const { return true; } + + virtual PassRefPtr cssValue() const { return m_value; } + CSSImageValue* cssImageValue() const { return m_value; } + + virtual IntSize imageSize(const RenderObject*, float /*multiplier*/) const { return IntSize(); } + virtual bool imageHasRelativeWidth() const { return false; } + virtual bool imageHasRelativeHeight() const { return false; } + virtual bool usesImageContainerSize() const { return false; } + virtual void setImageContainerSize(const IntSize&) { } + virtual void addClient(RenderObject*) { } + virtual void removeClient(RenderObject*) { } + virtual Image* image(RenderObject*, const IntSize&) const + { + ASSERT_NOT_REACHED(); + return 0; + } + +private: + StylePendingImage(CSSImageValue* value) + : m_value(value) + { + } + + CSSImageValue* m_value; // Not retained; it owns us. +}; + +} +#endif diff --git a/Source/WebCore/rendering/style/StyleRareInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareInheritedData.cpp new file mode 100644 index 0000000..6138df2 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleRareInheritedData.cpp @@ -0,0 +1,187 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 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 "config.h" +#include "StyleRareInheritedData.h" + +#include "RenderStyle.h" +#include "RenderStyleConstants.h" + +namespace WebCore { + +StyleRareInheritedData::StyleRareInheritedData() + : textStrokeWidth(RenderStyle::initialTextStrokeWidth()) +#ifdef ANDROID_CSS_RING + , ringFillColor(RenderStyle::initialRingFillColor()) + , ringInnerWidth(RenderStyle::initialRingInnerWidth()) + , ringOuterWidth(RenderStyle::initialRingOuterWidth()) + , ringOutset(RenderStyle::initialRingOutset()) + , ringPressedInnerColor(RenderStyle::initialRingPressedInnerColor()) + , ringPressedOuterColor(RenderStyle::initialRingPressedOuterColor()) + , ringRadius(RenderStyle::initialRingRadius()) + , ringSelectedInnerColor(RenderStyle::initialRingSelectedInnerColor()) + , ringSelectedOuterColor(RenderStyle::initialRingSelectedOuterColor()) +#endif +#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR + , tapHighlightColor(RenderStyle::initialTapHighlightColor()) +#endif + , textShadow(0) + , indent(RenderStyle::initialTextIndent()) + , m_effectiveZoom(RenderStyle::initialZoom()) + , widows(RenderStyle::initialWidows()) + , orphans(RenderStyle::initialOrphans()) + , textSecurity(RenderStyle::initialTextSecurity()) + , userModify(READ_ONLY) + , wordBreak(RenderStyle::initialWordBreak()) + , wordWrap(RenderStyle::initialWordWrap()) + , nbspMode(NBNORMAL) + , khtmlLineBreak(LBNORMAL) + , textSizeAdjust(RenderStyle::initialTextSizeAdjust()) + , resize(RenderStyle::initialResize()) + , userSelect(RenderStyle::initialUserSelect()) + , colorSpace(ColorSpaceDeviceRGB) + , speak(SpeakNormal) + , hyphens(HyphensManual) + , textEmphasisFill(TextEmphasisFillFilled) + , textEmphasisMark(TextEmphasisMarkNone) + , textEmphasisPosition(TextEmphasisPositionOver) +{ +} + +StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o) + : RefCounted() + , textStrokeColor(o.textStrokeColor) + , textStrokeWidth(o.textStrokeWidth) + , textFillColor(o.textFillColor) + , textEmphasisColor(o.textEmphasisColor) +#ifdef ANDROID_CSS_RING + , ringFillColor(o.ringFillColor) + , ringInnerWidth(o.ringInnerWidth) + , ringOuterWidth(o.ringOuterWidth) + , ringOutset(o.ringOutset) + , ringPressedInnerColor(o.ringPressedInnerColor) + , ringPressedOuterColor(o.ringPressedOuterColor) + , ringRadius(o.ringRadius) + , ringSelectedInnerColor(o.ringSelectedInnerColor) + , ringSelectedOuterColor(o.ringSelectedOuterColor) +#endif +#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR + , tapHighlightColor(o.tapHighlightColor) +#endif + , textShadow(o.textShadow ? new ShadowData(*o.textShadow) : 0) + , highlight(o.highlight) + , cursorData(o.cursorData) + , indent(o.indent) + , m_effectiveZoom(o.m_effectiveZoom) + , widows(o.widows) + , orphans(o.orphans) + , textSecurity(o.textSecurity) + , userModify(o.userModify) + , wordBreak(o.wordBreak) + , wordWrap(o.wordWrap) + , nbspMode(o.nbspMode) + , khtmlLineBreak(o.khtmlLineBreak) + , textSizeAdjust(o.textSizeAdjust) + , resize(o.resize) + , userSelect(o.userSelect) + , colorSpace(o.colorSpace) + , speak(o.speak) + , hyphens(o.hyphens) + , textEmphasisFill(o.textEmphasisFill) + , textEmphasisMark(o.textEmphasisMark) + , textEmphasisPosition(o.textEmphasisPosition) + , hyphenationString(o.hyphenationString) + , hyphenationLocale(o.hyphenationLocale) + , textEmphasisCustomMark(o.textEmphasisCustomMark) +{ +} + +StyleRareInheritedData::~StyleRareInheritedData() +{ + delete textShadow; +} + +static bool cursorDataEquivalent(const CursorList* c1, const CursorList* c2) +{ + if (c1 == c2) + return true; + if ((!c1 && c2) || (c1 && !c2)) + return false; + return (*c1 == *c2); +} + +bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const +{ + return textStrokeColor == o.textStrokeColor + && textStrokeWidth == o.textStrokeWidth + && textFillColor == o.textFillColor + && textEmphasisColor == o.textEmphasisColor + && shadowDataEquivalent(o) + && highlight == o.highlight + && cursorDataEquivalent(cursorData.get(), o.cursorData.get()) + && indent == o.indent + && m_effectiveZoom == o.m_effectiveZoom + && widows == o.widows + && orphans == o.orphans + && textSecurity == o.textSecurity + && userModify == o.userModify + && wordBreak == o.wordBreak + && wordWrap == o.wordWrap + && nbspMode == o.nbspMode + && khtmlLineBreak == o.khtmlLineBreak + && textSizeAdjust == o.textSizeAdjust +#ifdef ANDROID_CSS_RING + && ringFillColor == o.ringFillColor + && ringInnerWidth == o.ringInnerWidth + && ringOuterWidth == o.ringOuterWidth + && ringOutset == o.ringOutset + && ringPressedInnerColor == o.ringPressedInnerColor + && ringPressedOuterColor == o.ringPressedOuterColor + && ringRadius == o.ringRadius + && ringSelectedInnerColor == o.ringSelectedInnerColor + && ringSelectedOuterColor == o.ringSelectedOuterColor +#endif +#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR + && tapHighlightColor == o.tapHighlightColor +#endif + && resize == o.resize + && userSelect == o.userSelect + && colorSpace == o.colorSpace + && speak == o.speak + && hyphens == o.hyphens + && textEmphasisFill == o.textEmphasisFill + && textEmphasisMark == o.textEmphasisMark + && textEmphasisPosition == o.textEmphasisPosition + && hyphenationString == o.hyphenationString + && hyphenationLocale == o.hyphenationLocale + && textEmphasisCustomMark == o.textEmphasisCustomMark; +} + +bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const +{ + if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow)) + return false; + if (textShadow && o.textShadow && (*textShadow != *o.textShadow)) + return false; + return true; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleRareInheritedData.h b/Source/WebCore/rendering/style/StyleRareInheritedData.h new file mode 100644 index 0000000..a370934 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleRareInheritedData.h @@ -0,0 +1,114 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleRareInheritedData_h +#define StyleRareInheritedData_h + +#include "Color.h" +#include "Length.h" +#include +#include +#include + +namespace WebCore { + +class CursorList; +class ShadowData; + +// This struct is for rarely used inherited CSS3, CSS2, and WebKit-specific properties. +// By grouping them together, we save space, and only allocate this object when someone +// actually uses one of these properties. +class StyleRareInheritedData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleRareInheritedData); } + PassRefPtr copy() const { return adoptRef(new StyleRareInheritedData(*this)); } + ~StyleRareInheritedData(); + + bool operator==(const StyleRareInheritedData& o) const; + bool operator!=(const StyleRareInheritedData& o) const + { + return !(*this == o); + } + bool shadowDataEquivalent(const StyleRareInheritedData&) const; + + Color textStrokeColor; + float textStrokeWidth; + Color textFillColor; + Color textEmphasisColor; + +#ifdef ANDROID_CSS_RING + Color ringFillColor; + Length ringInnerWidth; + Length ringOuterWidth; + Length ringOutset; + Color ringPressedInnerColor; + Color ringPressedOuterColor; + Length ringRadius; + Color ringSelectedInnerColor; + Color ringSelectedOuterColor; +#endif +#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR + Color tapHighlightColor; +#endif + + ShadowData* textShadow; // Our text shadow information for shadowed text drawing. + AtomicString highlight; // Apple-specific extension for custom highlight rendering. + + RefPtr cursorData; + Length indent; + float m_effectiveZoom; + + // Paged media properties. + short widows; + short orphans; + + unsigned textSecurity : 2; // ETextSecurity + unsigned userModify : 2; // EUserModify (editing) + unsigned wordBreak : 2; // EWordBreak + unsigned wordWrap : 1; // EWordWrap + unsigned nbspMode : 1; // ENBSPMode + unsigned khtmlLineBreak : 1; // EKHTMLLineBreak + bool textSizeAdjust : 1; // An Apple extension. + unsigned resize : 2; // EResize + unsigned userSelect : 1; // EUserSelect + unsigned colorSpace : 1; // ColorSpace + unsigned speak : 3; // ESpeak + unsigned hyphens : 2; // Hyphens + unsigned textEmphasisFill : 1; // TextEmphasisFill + unsigned textEmphasisMark : 3; // TextEmphasisMark + unsigned textEmphasisPosition : 1; // TextEmphasisPosition + + AtomicString hyphenationString; + AtomicString hyphenationLocale; + + AtomicString textEmphasisCustomMark; + +private: + StyleRareInheritedData(); + StyleRareInheritedData(const StyleRareInheritedData&); +}; + +} // namespace WebCore + +#endif // StyleRareInheritedData_h diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp new file mode 100644 index 0000000..42cf966 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp @@ -0,0 +1,203 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "StyleRareNonInheritedData.h" + +#include "CSSStyleSelector.h" +#include "ContentData.h" +#include "RenderCounter.h" +#include "RenderStyle.h" +#include "StyleImage.h" + +namespace WebCore { + +StyleRareNonInheritedData::StyleRareNonInheritedData() + : lineClamp(RenderStyle::initialLineClamp()) + , opacity(RenderStyle::initialOpacity()) + , m_content(0) + , m_counterDirectives(0) + , userDrag(RenderStyle::initialUserDrag()) + , textOverflow(RenderStyle::initialTextOverflow()) + , marginBeforeCollapse(MCOLLAPSE) + , marginAfterCollapse(MCOLLAPSE) + , matchNearestMailBlockquoteColor(RenderStyle::initialMatchNearestMailBlockquoteColor()) + , m_appearance(RenderStyle::initialAppearance()) + , m_borderFit(RenderStyle::initialBorderFit()) + , m_textCombine(RenderStyle::initialTextCombine()) + , m_counterIncrement(0) + , m_counterReset(0) +#if USE(ACCELERATED_COMPOSITING) + , m_runningAcceleratedAnimation(false) +#endif + , m_boxShadow(0) + , m_animations(0) + , m_transitions(0) + , m_mask(FillLayer(MaskFillLayer)) + , m_transformStyle3D(RenderStyle::initialTransformStyle3D()) + , m_backfaceVisibility(RenderStyle::initialBackfaceVisibility()) + , m_perspective(RenderStyle::initialPerspective()) + , m_perspectiveOriginX(RenderStyle::initialPerspectiveOriginX()) + , m_perspectiveOriginY(RenderStyle::initialPerspectiveOriginY()) + , m_pageSize() + , m_pageSizeType(PAGE_SIZE_AUTO) +{ +} + +StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o) + : RefCounted() + , lineClamp(o.lineClamp) + , opacity(o.opacity) + , flexibleBox(o.flexibleBox) + , marquee(o.marquee) + , m_multiCol(o.m_multiCol) + , m_transform(o.m_transform) + , m_content(0) + , m_counterDirectives(0) + , userDrag(o.userDrag) + , textOverflow(o.textOverflow) + , marginBeforeCollapse(o.marginBeforeCollapse) + , marginAfterCollapse(o.marginAfterCollapse) + , matchNearestMailBlockquoteColor(o.matchNearestMailBlockquoteColor) + , m_appearance(o.m_appearance) + , m_borderFit(o.m_borderFit) + , m_textCombine(o.m_textCombine) + , m_counterIncrement(o.m_counterIncrement) + , m_counterReset(o.m_counterReset) +#if USE(ACCELERATED_COMPOSITING) + , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation) +#endif + , m_boxShadow(o.m_boxShadow ? new ShadowData(*o.m_boxShadow) : 0) + , m_boxReflect(o.m_boxReflect) + , m_animations(o.m_animations ? new AnimationList(*o.m_animations) : 0) + , m_transitions(o.m_transitions ? new AnimationList(*o.m_transitions) : 0) + , m_mask(o.m_mask) + , m_maskBoxImage(o.m_maskBoxImage) + , m_transformStyle3D(o.m_transformStyle3D) + , m_backfaceVisibility(o.m_backfaceVisibility) + , m_perspective(o.m_perspective) + , m_perspectiveOriginX(o.m_perspectiveOriginX) + , m_perspectiveOriginY(o.m_perspectiveOriginY) + , m_pageSize(o.m_pageSize) + , m_pageSizeType(o.m_pageSizeType) +{ +} + +StyleRareNonInheritedData::~StyleRareNonInheritedData() +{ +} + +bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const +{ + return lineClamp == o.lineClamp +#if ENABLE(DASHBOARD_SUPPORT) + && m_dashboardRegions == o.m_dashboardRegions +#endif + && opacity == o.opacity + && flexibleBox == o.flexibleBox + && marquee == o.marquee + && m_multiCol == o.m_multiCol + && m_transform == o.m_transform + && contentDataEquivalent(o) + && m_counterDirectives == o.m_counterDirectives + && userDrag == o.userDrag + && textOverflow == o.textOverflow + && marginBeforeCollapse == o.marginBeforeCollapse + && marginAfterCollapse == o.marginAfterCollapse + && matchNearestMailBlockquoteColor == o.matchNearestMailBlockquoteColor + && m_appearance == o.m_appearance + && m_borderFit == o.m_borderFit + && m_textCombine == o.m_textCombine + && m_counterIncrement == o.m_counterIncrement + && m_counterReset == o.m_counterReset +#if USE(ACCELERATED_COMPOSITING) + && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation +#endif + && shadowDataEquivalent(o) + && reflectionDataEquivalent(o) + && animationDataEquivalent(o) + && transitionDataEquivalent(o) + && m_mask == o.m_mask + && m_maskBoxImage == o.m_maskBoxImage + && (m_transformStyle3D == o.m_transformStyle3D) + && (m_backfaceVisibility == o.m_backfaceVisibility) + && (m_perspective == o.m_perspective) + && (m_perspectiveOriginX == o.m_perspectiveOriginX) + && (m_perspectiveOriginY == o.m_perspectiveOriginY) + && (m_pageSize == o.m_pageSize) + && (m_pageSizeType == o.m_pageSizeType) + ; +} + +bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& o) const +{ + ContentData* c1 = m_content.get(); + ContentData* c2 = o.m_content.get(); + + while (c1 && c2) { + if (!c1->dataEquivalent(*c2)) + return false; + c1 = c1->next(); + c2 = c2->next(); + } + + return !c1 && !c2; +} + +bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const +{ + if ((!m_boxShadow && o.m_boxShadow) || (m_boxShadow && !o.m_boxShadow)) + return false; + if (m_boxShadow && o.m_boxShadow && (*m_boxShadow != *o.m_boxShadow)) + return false; + return true; +} + +bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const +{ + if (m_boxReflect != o.m_boxReflect) { + if (!m_boxReflect || !o.m_boxReflect) + return false; + return *m_boxReflect == *o.m_boxReflect; + } + return true; + +} + +bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const +{ + if ((!m_animations && o.m_animations) || (m_animations && !o.m_animations)) + return false; + if (m_animations && o.m_animations && (*m_animations != *o.m_animations)) + return false; + return true; +} + +bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const +{ + if ((!m_transitions && o.m_transitions) || (m_transitions && !o.m_transitions)) + return false; + if (m_transitions && o.m_transitions && (*m_transitions != *o.m_transitions)) + return false; + return true; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleRareNonInheritedData.h b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h new file mode 100644 index 0000000..89437f6 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleRareNonInheritedData.h @@ -0,0 +1,140 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleRareNonInheritedData_h +#define StyleRareNonInheritedData_h + +#include "CounterDirectives.h" +#include "CursorData.h" +#include "DataRef.h" +#include "FillLayer.h" +#include "LineClampValue.h" +#include "NinePieceImage.h" +#include "StyleTransformData.h" +#include +#include +#include + +namespace WebCore { + +class AnimationList; +class CSSStyleSelector; +class ShadowData; +class StyleFlexibleBoxData; +class StyleMarqueeData; +class StyleMultiColData; +class StyleReflection; +class StyleTransformData; + +struct ContentData; +struct LengthSize; + +#if ENABLE(DASHBOARD_SUPPORT) +struct StyleDashboardRegion; +#endif + +// Page size type. +// StyleRareNonInheritedData::m_pageSize is meaningful only when +// StyleRareNonInheritedData::m_pageSizeType is PAGE_SIZE_RESOLVED. +enum PageSizeType { + PAGE_SIZE_AUTO, // size: auto + PAGE_SIZE_AUTO_LANDSCAPE, // size: landscape + PAGE_SIZE_AUTO_PORTRAIT, // size: portrait + PAGE_SIZE_RESOLVED // Size is fully resolved. +}; + +// This struct is for rarely used non-inherited CSS3, CSS2, and WebKit-specific properties. +// By grouping them together, we save space, and only allocate this object when someone +// actually uses one of these properties. +class StyleRareNonInheritedData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleRareNonInheritedData); } + PassRefPtr copy() const { return adoptRef(new StyleRareNonInheritedData(*this)); } + ~StyleRareNonInheritedData(); + + bool operator==(const StyleRareNonInheritedData&) const; + bool operator!=(const StyleRareNonInheritedData& o) const { return !(*this == o); } + + bool contentDataEquivalent(const StyleRareNonInheritedData& o) const; + bool shadowDataEquivalent(const StyleRareNonInheritedData& o) const; + bool reflectionDataEquivalent(const StyleRareNonInheritedData& o) const; + bool animationDataEquivalent(const StyleRareNonInheritedData&) const; + bool transitionDataEquivalent(const StyleRareNonInheritedData&) const; + + LineClampValue lineClamp; // An Apple extension. +#if ENABLE(DASHBOARD_SUPPORT) + Vector m_dashboardRegions; +#endif + float opacity; // Whether or not we're transparent. + + DataRef flexibleBox; // Flexible box properties + DataRef marquee; // Marquee properties + DataRef m_multiCol; // CSS3 multicol properties + DataRef m_transform; // Transform properties (rotate, scale, skew, etc.) + + OwnPtr m_content; + OwnPtr m_counterDirectives; + + unsigned userDrag : 2; // EUserDrag + bool textOverflow : 1; // Whether or not lines that spill out should be truncated with "..." + unsigned marginBeforeCollapse : 2; // EMarginCollapse + unsigned marginAfterCollapse : 2; // EMarginCollapse + unsigned matchNearestMailBlockquoteColor : 1; // EMatchNearestMailBlockquoteColor, FIXME: This property needs to be eliminated. It should never have been added. + unsigned m_appearance : 6; // EAppearance + unsigned m_borderFit : 1; // EBorderFit + unsigned m_textCombine : 1; // CSS3 text-combine properties + + short m_counterIncrement; + short m_counterReset; + +#if USE(ACCELERATED_COMPOSITING) + bool m_runningAcceleratedAnimation : 1; +#endif + OwnPtr m_boxShadow; // For box-shadow decorations. + + RefPtr m_boxReflect; + + OwnPtr m_animations; + OwnPtr m_transitions; + + FillLayer m_mask; + NinePieceImage m_maskBoxImage; + + ETransformStyle3D m_transformStyle3D; + EBackfaceVisibility m_backfaceVisibility; + float m_perspective; + Length m_perspectiveOriginX; + Length m_perspectiveOriginY; + + LengthSize m_pageSize; + PageSizeType m_pageSizeType; + +private: + StyleRareNonInheritedData(); + StyleRareNonInheritedData(const StyleRareNonInheritedData&); +}; + +} // namespace WebCore + +#endif // StyleRareNonInheritedData_h diff --git a/Source/WebCore/rendering/style/StyleReflection.h b/Source/WebCore/rendering/style/StyleReflection.h new file mode 100644 index 0000000..455d1b7 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleReflection.h @@ -0,0 +1,70 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleReflection_h +#define StyleReflection_h + +#include "CSSReflectionDirection.h" +#include "Length.h" +#include "NinePieceImage.h" +#include + +namespace WebCore { + +class StyleReflection : public RefCounted { +public: + static PassRefPtr create() + { + return adoptRef(new StyleReflection); + } + + bool operator==(const StyleReflection& o) const + { + return m_direction == o.m_direction && m_offset == o.m_offset && m_mask == o.m_mask; + } + bool operator!=(const StyleReflection& o) const { return !(*this == o); } + + CSSReflectionDirection direction() const { return m_direction; } + Length offset() const { return m_offset; } + const NinePieceImage& mask() const { return m_mask; } + + void setDirection(CSSReflectionDirection dir) { m_direction = dir; } + void setOffset(const Length& l) { m_offset = l; } + void setMask(const NinePieceImage& image) { m_mask = image; } + +private: + StyleReflection() + : m_direction(ReflectionBelow) + , m_offset(0, Fixed) + { + } + + CSSReflectionDirection m_direction; + Length m_offset; + NinePieceImage m_mask; +}; + +} // namespace WebCore + +#endif // StyleReflection_h diff --git a/Source/WebCore/rendering/style/StyleSurroundData.cpp b/Source/WebCore/rendering/style/StyleSurroundData.cpp new file mode 100644 index 0000000..8d5e79c --- /dev/null +++ b/Source/WebCore/rendering/style/StyleSurroundData.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "StyleSurroundData.h" + +namespace WebCore { + +StyleSurroundData::StyleSurroundData() + : margin(Fixed) + , padding(Fixed) +{ +} + +StyleSurroundData::StyleSurroundData(const StyleSurroundData& o) + : RefCounted() + , offset(o.offset) + , margin(o.margin) + , padding(o.padding) + , border(o.border) +{ +} + +bool StyleSurroundData::operator==(const StyleSurroundData& o) const +{ + return offset == o.offset && margin == o.margin && padding == o.padding && border == o.border; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleSurroundData.h b/Source/WebCore/rendering/style/StyleSurroundData.h new file mode 100644 index 0000000..b8f21e4 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleSurroundData.h @@ -0,0 +1,58 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleSurroundData_h +#define StyleSurroundData_h + +#include "BorderData.h" +#include "LengthBox.h" +#include +#include + +namespace WebCore { + +class StyleSurroundData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleSurroundData); } + PassRefPtr copy() const { return adoptRef(new StyleSurroundData(*this)); } + + bool operator==(const StyleSurroundData& o) const; + bool operator!=(const StyleSurroundData& o) const + { + return !(*this == o); + } + + LengthBox offset; + LengthBox margin; + LengthBox padding; + BorderData border; + +private: + StyleSurroundData(); + StyleSurroundData(const StyleSurroundData&); +}; + +} // namespace WebCore + +#endif // StyleSurroundData_h diff --git a/Source/WebCore/rendering/style/StyleTransformData.cpp b/Source/WebCore/rendering/style/StyleTransformData.cpp new file mode 100644 index 0000000..2baebf9 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleTransformData.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "StyleTransformData.h" + +#include "RenderStyle.h" + +namespace WebCore { + +StyleTransformData::StyleTransformData() + : m_operations(RenderStyle::initialTransform()) + , m_x(RenderStyle::initialTransformOriginX()) + , m_y(RenderStyle::initialTransformOriginY()) + , m_z(RenderStyle::initialTransformOriginZ()) +{ +} + +StyleTransformData::StyleTransformData(const StyleTransformData& o) + : RefCounted() + , m_operations(o.m_operations) + , m_x(o.m_x) + , m_y(o.m_y) + , m_z(o.m_z) +{ +} + +bool StyleTransformData::operator==(const StyleTransformData& o) const +{ + return m_x == o.m_x && m_y == o.m_y && m_z == o.m_z && m_operations == o.m_operations; +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleTransformData.h b/Source/WebCore/rendering/style/StyleTransformData.h new file mode 100644 index 0000000..6039824 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleTransformData.h @@ -0,0 +1,58 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleTransformData_h +#define StyleTransformData_h + +#include "Length.h" +#include "TransformOperations.h" +#include +#include + +namespace WebCore { + +class StyleTransformData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleTransformData); } + PassRefPtr copy() const { return adoptRef(new StyleTransformData(*this)); } + + bool operator==(const StyleTransformData& o) const; + bool operator!=(const StyleTransformData& o) const + { + return !(*this == o); + } + + TransformOperations m_operations; + Length m_x; + Length m_y; + float m_z; + +private: + StyleTransformData(); + StyleTransformData(const StyleTransformData&); +}; + +} // namespace WebCore + +#endif // StyleTransformData_h diff --git a/Source/WebCore/rendering/style/StyleVisualData.cpp b/Source/WebCore/rendering/style/StyleVisualData.cpp new file mode 100644 index 0000000..14996c9 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleVisualData.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 1999 Antti Koivisto (koivisto@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. + * + */ + +#include "config.h" +#include "StyleVisualData.h" + +#include "RenderStyle.h" + +namespace WebCore { + +StyleVisualData::StyleVisualData() + : hasClip(false) + , textDecoration(RenderStyle::initialTextDecoration()) + , m_zoom(RenderStyle::initialZoom()) +{ +} + +StyleVisualData::~StyleVisualData() +{ +} + +StyleVisualData::StyleVisualData(const StyleVisualData& o) + : RefCounted() + , clip(o.clip) + , hasClip(o.hasClip) + , textDecoration(o.textDecoration) + , m_zoom(RenderStyle::initialZoom()) +{ +} + +} // namespace WebCore diff --git a/Source/WebCore/rendering/style/StyleVisualData.h b/Source/WebCore/rendering/style/StyleVisualData.h new file mode 100644 index 0000000..d1f0f83 --- /dev/null +++ b/Source/WebCore/rendering/style/StyleVisualData.h @@ -0,0 +1,62 @@ +/* + * 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 Apple Inc. All rights reserved. + * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) + * + * 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 StyleVisualData_h +#define StyleVisualData_h + +#include "LengthBox.h" +#include +#include + +namespace WebCore { + +class StyleVisualData : public RefCounted { +public: + static PassRefPtr create() { return adoptRef(new StyleVisualData); } + PassRefPtr copy() const { return adoptRef(new StyleVisualData(*this)); } + ~StyleVisualData(); + + bool operator==(const StyleVisualData& o) const + { + return ( clip == o.clip && + hasClip == o.hasClip && + textDecoration == o.textDecoration && + m_zoom == o.m_zoom); + } + bool operator!=(const StyleVisualData& o) const { return !(*this == o); } + + LengthBox clip; + bool hasClip : 1; + unsigned textDecoration : 4; // Text decorations defined *only* by this element. + + float m_zoom; + +private: + StyleVisualData(); + StyleVisualData(const StyleVisualData&); +}; + +} // namespace WebCore + +#endif // StyleVisualData_h -- cgit v1.1