diff options
Diffstat (limited to 'WebCore/rendering/style')
20 files changed, 331 insertions, 261 deletions
diff --git a/WebCore/rendering/style/BorderData.h b/WebCore/rendering/style/BorderData.h index 96caf97..03635d9 100644 --- a/WebCore/rendering/style/BorderData.h +++ b/WebCore/rendering/style/BorderData.h @@ -26,7 +26,7 @@ #define BorderData_h #include "BorderValue.h" -#include "IntSize.h" +#include "LengthSize.h" #include "NinePieceImage.h" namespace WebCore { @@ -34,6 +34,12 @@ 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(); @@ -42,13 +48,13 @@ public: bool hasBorderRadius() const { - if (m_topLeft.width() > 0) + if (m_topLeft.width().rawValue() > 0) return true; - if (m_topRight.width() > 0) + if (m_topRight.width().rawValue() > 0) return true; - if (m_bottomLeft.width() > 0) + if (m_bottomLeft.width().rawValue() > 0) return true; - if (m_bottomRight.width() > 0) + if (m_bottomRight.width().rawValue() > 0) return true; return false; } @@ -99,10 +105,10 @@ public: const NinePieceImage& image() const { return m_image; } - const IntSize& topLeft() const { return m_topLeft; } - const IntSize& topRight() const { return m_topRight; } - const IntSize& bottomLeft() const { return m_bottomLeft; } - const IntSize& bottomRight() const { return m_bottomRight; } + 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; @@ -112,10 +118,10 @@ private: NinePieceImage m_image; - IntSize m_topLeft; - IntSize m_topRight; - IntSize m_bottomLeft; - IntSize m_bottomRight; + LengthSize m_topLeft; + LengthSize m_topRight; + LengthSize m_bottomLeft; + LengthSize m_bottomRight; }; } // namespace WebCore diff --git a/WebCore/rendering/style/ContentData.cpp b/WebCore/rendering/style/ContentData.cpp index b0f9e81..d150f77 100644 --- a/WebCore/rendering/style/ContentData.cpp +++ b/WebCore/rendering/style/ContentData.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * 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 @@ -22,7 +22,6 @@ #include "config.h" #include "ContentData.h" -#include "CounterContent.h" #include "StyleImage.h" #include <wtf/text/StringImpl.h> @@ -32,42 +31,26 @@ void ContentData::clear() { deleteContent(); - ContentData* n = m_next; - m_next = 0; - - // Reverse the list so we can delete without recursing. - ContentData* last = 0; - ContentData* c; - while ((c = n)) { - n = c->m_next; - c->m_next = last; - last = c; - } - for (c = last; c; c = n) { - n = c->m_next; - c->m_next = 0; - delete c; - } + // Delete the singly-linked list without recursing. + for (OwnPtr<ContentData> 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; - break; - case CONTENT_TEXT: - return equal(text(), other.text()); - break; - case CONTENT_OBJECT: - return StyleImage::imagesEquivalent(image(), other.image()); - break; - case CONTENT_COUNTER: - return *counter() == *other.counter(); - break; + 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(); @@ -77,17 +60,17 @@ bool ContentData::dataEquivalent(const ContentData& other) const 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; + 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; diff --git a/WebCore/rendering/style/ContentData.h b/WebCore/rendering/style/ContentData.h index 5c3565e..4f964a2 100644 --- a/WebCore/rendering/style/ContentData.h +++ b/WebCore/rendering/style/ContentData.h @@ -2,7 +2,7 @@ * 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) 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 @@ -25,21 +25,18 @@ #ifndef ContentData_h #define ContentData_h -#include "RenderStyleConstants.h" -#include <wtf/Forward.h> -#include <wtf/Noncopyable.h> -#include <wtf/PassRefPtr.h> +#include "CounterContent.h" +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> namespace WebCore { -class CounterContent; class StyleImage; struct ContentData : Noncopyable { public: ContentData() : m_type(CONTENT_NONE) - , m_next(0) { } @@ -59,35 +56,44 @@ public: bool dataEquivalent(const ContentData&) const; - StyleImage* image() const { return m_content.m_image; } + StyleImage* image() const + { + ASSERT(isImage()); + return m_content.m_image; + } void setImage(PassRefPtr<StyleImage> image) { deleteContent(); m_type = CONTENT_OBJECT; - m_content.m_image = image.releaseRef(); + m_content.m_image = image.leakRef(); } - StringImpl* text() const { return m_content.m_text; } + StringImpl* text() const + { + ASSERT(isText()); + return m_content.m_text; + } void setText(PassRefPtr<StringImpl> text) { deleteContent(); m_type = CONTENT_TEXT; - m_content.m_text = text.releaseRef(); + m_content.m_text = text.leakRef(); } - CounterContent* counter() const { return m_content.m_counter; } - void setCounter(CounterContent* counter) + CounterContent* counter() const + { + ASSERT(isCounter()); + return m_content.m_counter; + } + void setCounter(PassOwnPtr<CounterContent> counter) { deleteContent(); m_type = CONTENT_COUNTER; - m_content.m_counter = counter; + m_content.m_counter = counter.leakPtr(); } - ContentData* next() const { return m_next; } - void setNext(ContentData* next) - { - m_next = next; - } + ContentData* next() const { return m_next.get(); } + void setNext(PassOwnPtr<ContentData> next) { m_next = next; } private: void deleteContent(); @@ -98,7 +104,7 @@ private: StringImpl* m_text; CounterContent* m_counter; } m_content; - ContentData* m_next; + OwnPtr<ContentData> m_next; }; } // namespace WebCore diff --git a/WebCore/rendering/style/CursorData.h b/WebCore/rendering/style/CursorData.h index 2341e71..6d0a273 100644 --- a/WebCore/rendering/style/CursorData.h +++ b/WebCore/rendering/style/CursorData.h @@ -25,15 +25,14 @@ #ifndef CursorData_h #define CursorData_h -#include "CachedImage.h" -#include "CachedResourceHandle.h" #include "IntPoint.h" +#include "StyleImage.h" namespace WebCore { class CursorData { public: - CursorData(CachedImage* image, const IntPoint& hotSpot) + CursorData(PassRefPtr<StyleImage> image, const IntPoint& hotSpot) : m_image(image) , m_hotSpot(hotSpot) { @@ -49,11 +48,13 @@ public: return !(*this == o); } - const CachedImage* image() const { return m_image.get(); } + StyleImage* image() const { return m_image.get(); } + void setImage(PassRefPtr<StyleImage> image) { m_image = image; } + const IntPoint& hotSpot() const { return m_hotSpot; } private: - CachedResourceHandle<CachedImage> m_image; + RefPtr<StyleImage> m_image; IntPoint m_hotSpot; // for CSS3 support }; diff --git a/WebCore/rendering/style/CursorList.h b/WebCore/rendering/style/CursorList.h index bdd65d4..1b82684 100644 --- a/WebCore/rendering/style/CursorList.h +++ b/WebCore/rendering/style/CursorList.h @@ -39,6 +39,7 @@ public: } const CursorData& operator[](int i) const { return m_vector[i]; } + CursorData& operator[](int i) { return m_vector[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; } diff --git a/WebCore/rendering/style/KeyframeList.cpp b/WebCore/rendering/style/KeyframeList.cpp index 41fbbe2..bafa426 100644 --- a/WebCore/rendering/style/KeyframeList.cpp +++ b/WebCore/rendering/style/KeyframeList.cpp @@ -43,10 +43,10 @@ bool KeyframeList::operator==(const KeyframeList& o) const Vector<KeyframeValue>::const_iterator it2 = o.m_keyframes.begin(); for (Vector<KeyframeValue>::const_iterator it1 = m_keyframes.begin(); it1 != m_keyframes.end(); ++it1) { - if (it1->m_key != it2->m_key) + if (it1->key() != it2->key()) return false; - const RenderStyle& style1 = *it1->m_style; - const RenderStyle& style2 = *it2->m_style; + const RenderStyle& style1 = *it1->style(); + const RenderStyle& style2 = *it2->style(); if (style1 != style2) return false; ++it2; @@ -55,34 +55,43 @@ bool KeyframeList::operator==(const KeyframeList& o) const return true; } -void KeyframeList::insert(float key, PassRefPtr<RenderStyle> style) +void KeyframeList::insert(const KeyframeValue& keyframe) { - if (key < 0 || key > 1) + if (keyframe.key() < 0 || keyframe.key() > 1) return; - int index = -1; - + bool inserted = false; + bool replaced = false; for (size_t i = 0; i < m_keyframes.size(); ++i) { - if (m_keyframes[i].m_key == key) { - index = (int) i; + if (m_keyframes[i].key() == keyframe.key()) { + m_keyframes[i] = keyframe; + replaced = true; break; } - if (m_keyframes[i].m_key > key) { + + if (m_keyframes[i].key() > keyframe.key()) { // insert before - m_keyframes.insert(i, KeyframeValue()); - index = (int) i; + m_keyframes.insert(i, keyframe); + inserted = true; break; } } - if (index < 0) { - // append - index = (int) m_keyframes.size(); - m_keyframes.append(KeyframeValue()); + if (!replaced && !inserted) + m_keyframes.append(keyframe); + + if (replaced) { + // We have to rebuild the properties list from scratch. + m_properties.clear(); + for (Vector<KeyframeValue>::const_iterator it = m_keyframes.begin(); it != m_keyframes.end(); ++it) { + const KeyframeValue& currKeyframe = *it; + for (HashSet<int>::const_iterator it = currKeyframe.properties().begin(); it != currKeyframe.properties().end(); ++it) + m_properties.add(*it); + } + } else { + for (HashSet<int>::const_iterator it = keyframe.properties().begin(); it != keyframe.properties().end(); ++it) + m_properties.add(*it); } - - m_keyframes[index].m_key = key; - m_keyframes[index].m_style = style; } } // namespace WebCore diff --git a/WebCore/rendering/style/KeyframeList.h b/WebCore/rendering/style/KeyframeList.h index bb5f180..64170ce 100644 --- a/WebCore/rendering/style/KeyframeList.h +++ b/WebCore/rendering/style/KeyframeList.h @@ -37,15 +37,25 @@ class RenderStyle; class KeyframeValue { public: - KeyframeValue() - : m_key(-1) + KeyframeValue(float key, PassRefPtr<RenderStyle> 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<int>& 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<RenderStyle> style) { m_style = style; } +private: float m_key; + HashSet<int> m_properties; // The properties specified in this keyframe. RefPtr<RenderStyle> m_style; }; @@ -55,8 +65,8 @@ public: : m_animationName(animationName) , m_renderer(renderer) { - insert(0, 0); - insert(1, 0); + insert(KeyframeValue(0, 0)); + insert(KeyframeValue(1, 0)); } ~KeyframeList(); @@ -65,7 +75,7 @@ public: const AtomicString& animationName() const { return m_animationName; } - void insert(float key, PassRefPtr<RenderStyle> style); + void insert(const KeyframeValue& keyframe); void addProperty(int prop) { m_properties.add(prop); } bool containsProperty(int prop) const { return m_properties.contains(prop); } @@ -75,13 +85,12 @@ public: void clear(); bool isEmpty() const { return m_keyframes.isEmpty(); } size_t size() const { return m_keyframes.size(); } - Vector<KeyframeValue>::const_iterator beginKeyframes() const { return m_keyframes.begin(); } - Vector<KeyframeValue>::const_iterator endKeyframes() const { return m_keyframes.end(); } + const KeyframeValue& operator[](size_t index) const { return m_keyframes[index]; } private: AtomicString m_animationName; - Vector<KeyframeValue> m_keyframes; - HashSet<int> m_properties; // the properties being animated + Vector<KeyframeValue> m_keyframes; // kept sorted by key + HashSet<int> m_properties; // the properties being animated RenderObject* m_renderer; }; diff --git a/WebCore/rendering/style/RenderStyle.cpp b/WebCore/rendering/style/RenderStyle.cpp index aaccbf7..93cd8de 100644 --- a/WebCore/rendering/style/RenderStyle.cpp +++ b/WebCore/rendering/style/RenderStyle.cpp @@ -24,8 +24,6 @@ #include "CSSPropertyNames.h" #include "CSSStyleSelector.h" -#include "CachedImage.h" -#include "CounterContent.h" #include "FontSelector.h" #include "RenderArena.h" #include "RenderObject.h" @@ -403,7 +401,6 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon 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 || - inherited_flags._htmlHacks != other->inherited_flags._htmlHacks || noninherited_flags._position != other->noninherited_flags._position || noninherited_flags._floating != other->noninherited_flags._floating || noninherited_flags._originalDisplay != other->noninherited_flags._originalDisplay) @@ -552,7 +549,7 @@ void RenderStyle::setClip(Length top, Length right, Length bottom, Length left) data->clip.m_left = left; } -void RenderStyle::addCursor(CachedImage* image, const IntPoint& hotSpot) +void RenderStyle::addCursor(PassRefPtr<StyleImage> image, const IntPoint& hotSpot) { if (!rareInheritedData.access()->cursorData) rareInheritedData.access()->cursorData = CursorList::create(); @@ -576,92 +573,59 @@ void RenderStyle::clearContent() rareNonInheritedData->m_content->clear(); } -void RenderStyle::setContent(PassRefPtr<StyleImage> image, bool add) +ContentData* RenderStyle::prepareToSetContent(StringImpl* string, bool add) { - if (!image) - return; // The object is null. Nothing to do. Just bail. - OwnPtr<ContentData>& 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; - ContentData* newContentData; + OwnPtr<ContentData> newContentData; if (reuseContent && content) { content->clear(); - newContentData = content.leakPtr(); + newContentData = content.release(); } else - newContentData = new ContentData; + newContentData = adoptPtr(new ContentData); + + ContentData* result = newContentData.get(); if (lastContent && !reuseContent) - lastContent->setNext(newContentData); + lastContent->setNext(newContentData.release()); else - content.set(newContentData); + content = newContentData.release(); - newContentData->setImage(image); + return result; } -void RenderStyle::setContent(PassRefPtr<StringImpl> s, bool add) +void RenderStyle::setContent(PassRefPtr<StyleImage> image, bool add) { - if (!s) - return; // The string is null. Nothing to do. Just bail. - - OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content; - ContentData* lastContent = content.get(); - while (lastContent && lastContent->next()) - lastContent = lastContent->next(); - - bool reuseContent = !add; - if (add && lastContent) { - if (lastContent->isText()) { - // We can augment the existing string and share this ContentData node. - String newStr = lastContent->text(); - newStr.append(s.get()); - lastContent->setText(newStr.impl()); - return; - } - } - - ContentData* newContentData = 0; - if (reuseContent && content) { - content->clear(); - newContentData = content.leakPtr(); - } else - newContentData = new ContentData; - - if (lastContent && !reuseContent) - lastContent->setNext(newContentData); - else - content.set(newContentData); - - newContentData->setText(s); + if (!image) + return; + prepareToSetContent(0, add)->setImage(image); } -void RenderStyle::setContent(CounterContent* c, bool add) +void RenderStyle::setContent(PassRefPtr<StringImpl> string, bool add) { - if (!c) + if (!string) return; + if (ContentData* data = prepareToSetContent(string.get(), add)) + data->setText(string); +} - OwnPtr<ContentData>& content = rareNonInheritedData.access()->m_content; - ContentData* lastContent = content.get(); - while (lastContent && lastContent->next()) - lastContent = lastContent->next(); - - bool reuseContent = !add; - ContentData* newContentData = 0; - if (reuseContent && content) { - content->clear(); - newContentData = content.leakPtr(); - } else - newContentData = new ContentData; - - if (lastContent && !reuseContent) - lastContent->setNext(newContentData); - else - content.set(newContentData); - - newContentData->setCounter(c); +void RenderStyle::setContent(PassOwnPtr<CounterContent> counter, bool add) +{ + if (!counter) + return; + prepareToSetContent(0, add)->setCounter(counter); } void RenderStyle::applyTransform(TransformationMatrix& transform, const IntSize& borderBoxSize, ApplyTransformOrigin applyOrigin) const @@ -774,21 +738,22 @@ static void constrainCornerRadiiForRect(const IntRect& r, IntSize& topLeft, IntS void RenderStyle::getBorderRadiiForRect(const IntRect& r, IntSize& topLeft, IntSize& topRight, IntSize& bottomLeft, IntSize& bottomRight) const { - topLeft = surround->border.topLeft(); - topRight = surround->border.topRight(); + 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 = surround->border.bottomLeft(); - bottomRight = surround->border.bottomRight(); + 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 = surround->border.topLeft(); - innerTopRight = surround->border.topRight(); - innerBottomLeft = surround->border.bottomLeft(); - innerBottomRight = surround->border.bottomRight(); + 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)); diff --git a/WebCore/rendering/style/RenderStyle.h b/WebCore/rendering/style/RenderStyle.h index 1681890..e696735 100644 --- a/WebCore/rendering/style/RenderStyle.h +++ b/WebCore/rendering/style/RenderStyle.h @@ -35,7 +35,6 @@ #include "CSSPropertyNames.h" #include "CSSReflectionDirection.h" #include "CSSValueList.h" -#include "CachedImage.h" #include "CollapsedBorderValue.h" #include "Color.h" #include "ColorSpace.h" @@ -103,7 +102,6 @@ using std::max; class CSSStyleSelector; class CSSValueList; -class CachedImage; class Pair; class StyleImage; @@ -178,7 +176,6 @@ protected: (_white_space == other._white_space) && (_box_direction == other._box_direction) && (_visuallyOrdered == other._visuallyOrdered) && - (_htmlHacks == other._htmlHacks) && (_force_backgrounds_to_white == other._force_backgrounds_to_white) && (_pointerEvents == other._pointerEvents) && (_insideLink == other._insideLink); @@ -203,7 +200,6 @@ protected: // non CSS2 inherited bool _visuallyOrdered : 1; - bool _htmlHacks : 1; bool _force_backgrounds_to_white : 1; unsigned _pointerEvents : 4; // EPointerEvents unsigned _insideLink : 2; // EInsideLink @@ -279,7 +275,6 @@ protected: inherited_flags._border_collapse = initialBorderCollapse(); inherited_flags._white_space = initialWhiteSpace(); inherited_flags._visuallyOrdered = initialVisuallyOrdered(); - inherited_flags._htmlHacks=false; inherited_flags._box_direction = initialBoxDirection(); inherited_flags._force_backgrounds_to_white = false; inherited_flags._pointerEvents = initialPointerEvents(); @@ -348,6 +343,14 @@ public: 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; } @@ -390,10 +393,10 @@ public: const NinePieceImage& borderImage() const { return surround->border.image(); } - const IntSize& borderTopLeftRadius() const { return surround->border.topLeft(); } - const IntSize& borderTopRightRadius() const { return surround->border.topRight(); } - const IntSize& borderBottomLeftRadius() const { return surround->border.bottomLeft(); } - const IntSize& borderBottomRightRadius() const { return surround->border.bottomRight(); } + 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(); } @@ -788,18 +791,23 @@ public: void setBorderImage(const NinePieceImage& b) { SET_VAR(surround, border.m_image, b) } - void setBorderTopLeftRadius(const IntSize& s) { SET_VAR(surround, border.m_topLeft, s) } - void setBorderTopRightRadius(const IntSize& s) { SET_VAR(surround, border.m_topRight, s) } - void setBorderBottomLeftRadius(const IntSize& s) { SET_VAR(surround, border.m_bottomLeft, s) } - void setBorderBottomRightRadius(const IntSize& s) { SET_VAR(surround, border.m_bottomRight, s) } + 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 IntSize& 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, @@ -914,7 +922,7 @@ public: void setCounterReset(short v) { SET_VAR(rareNonInheritedData, m_counterReset, v) } void setListStyleType(EListStyleType v) { inherited_flags._list_style_type = v; } - void setListStyleImage(StyleImage* v) { if (inherited->list_style_image != v) inherited.access()->list_style_image = v; } + void setListStyleImage(PassRefPtr<StyleImage> 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)) } @@ -931,7 +939,7 @@ public: void setPaddingRight(Length v) { SET_VAR(surround, padding.m_right, v) } void setCursor(ECursor c) { inherited_flags._cursor_style = c; } - void addCursor(CachedImage*, const IntPoint& = IntPoint()); + void addCursor(PassRefPtr<StyleImage>, const IntPoint& hotSpot = IntPoint()); void setCursorList(PassRefPtr<CursorList>); void clearCursorList(); @@ -941,9 +949,6 @@ public: bool forceBackgroundsToWhite() const { return inherited_flags._force_backgrounds_to_white; } void setForceBackgroundsToWhite(bool b=true) { inherited_flags._force_backgrounds_to_white = b; } - bool htmlHacks() const { return inherited_flags._htmlHacks; } - void setHtmlHacks(bool b=true) { inherited_flags._htmlHacks = 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(); } @@ -1091,7 +1096,7 @@ public: void clearContent(); void setContent(PassRefPtr<StringImpl>, bool add = false); void setContent(PassRefPtr<StyleImage>, bool add = false); - void setContent(CounterContent*, bool add = false); + void setContent(PassOwnPtr<CounterContent>, bool add = false); const CounterDirectiveMap* counterDirectives() const; CounterDirectiveMap& accessCounterDirectives(); @@ -1153,7 +1158,7 @@ public: static bool initialBorderCollapse() { return false; } static EBorderStyle initialBorderStyle() { return BNONE; } static NinePieceImage initialNinePieceImage() { return NinePieceImage(); } - static IntSize initialBorderRadius() { return IntSize(0, 0); } + 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; } @@ -1281,6 +1286,8 @@ private: const Color& textStrokeColor() const { return rareInheritedData->textStrokeColor; } const Color colorIncludingFallback(int colorProperty, EBorderStyle borderStyle) const; + + ContentData* prepareToSetContent(StringImpl*, bool add); }; } // namespace WebCore diff --git a/WebCore/rendering/style/RenderStyleConstants.h b/WebCore/rendering/style/RenderStyleConstants.h index 70b128b..68c8113 100644 --- a/WebCore/rendering/style/RenderStyleConstants.h +++ b/WebCore/rendering/style/RenderStyleConstants.h @@ -79,6 +79,7 @@ enum PseudoId { 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) @@ -276,6 +277,8 @@ enum EListStyleType { EthiopicAbegedeTiEt, UpperGreek, UpperNorwegian, + Asterisks, + Footnotes, Hebrew, Armenian, Georgian, diff --git a/WebCore/rendering/style/SVGRenderStyle.cpp b/WebCore/rendering/style/SVGRenderStyle.cpp index dc8a5af..7d1ad3b 100644 --- a/WebCore/rendering/style/SVGRenderStyle.cpp +++ b/WebCore/rendering/style/SVGRenderStyle.cpp @@ -162,6 +162,10 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const || 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 @@ -178,10 +182,6 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const // NOTE: All comparisions below may only return StyleDifferenceRepaint - // Shadow changes need to cause repaints. - if (shadowSVG != other->shadowSVG) - return StyleDifferenceRepaint; - // Painting related properties only need repaints. if (miscNotEqual) { if (misc->floodColor != other->misc->floodColor @@ -215,48 +215,6 @@ StyleDifference SVGRenderStyle::diff(const SVGRenderStyle* other) const return StyleDifferenceEqual; } -static void getSVGShadowExtent(ShadowData* shadow, float& top, float& right, float& bottom, float& left) -{ - top = 0.0f; - right = 0.0f; - bottom = 0.0f; - left = 0.0f; - - float 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 SVGRenderStyle::inflateForShadow(IntRect& repaintRect) const -{ - ShadowData* svgShadow = shadow(); - if (!svgShadow) - return; - - FloatRect repaintFloatRect = FloatRect(repaintRect); - inflateForShadow(repaintFloatRect); - repaintRect = enclosingIntRect(repaintFloatRect); -} - -void SVGRenderStyle::inflateForShadow(FloatRect& repaintRect) const -{ - ShadowData* svgShadow = shadow(); - if (!svgShadow) - return; - - float shadowTop; - float shadowRight; - float shadowBottom; - float shadowLeft; - getSVGShadowExtent(svgShadow, shadowTop, shadowRight, shadowBottom, shadowLeft); - - repaintRect.move(shadowLeft, shadowTop); - repaintRect.setSize(repaintRect.size() + FloatSize(shadowRight - shadowLeft, shadowBottom - shadowTop)); -} - } #endif // ENABLE(SVG) diff --git a/WebCore/rendering/style/SVGRenderStyle.h b/WebCore/rendering/style/SVGRenderStyle.h index f071755..d57e4cf 100644 --- a/WebCore/rendering/style/SVGRenderStyle.h +++ b/WebCore/rendering/style/SVGRenderStyle.h @@ -47,10 +47,6 @@ public: bool inheritedNotEqual(const SVGRenderStyle*) const; void inheritFrom(const SVGRenderStyle*); - // FIXME: These functions should move to ShadowData. - void inflateForShadow(IntRect&) const; - void inflateForShadow(FloatRect&) const; - StyleDifference diff(const SVGRenderStyle*) const; bool operator==(const SVGRenderStyle&) const; diff --git a/WebCore/rendering/style/ShadowData.cpp b/WebCore/rendering/style/ShadowData.cpp index d4569d0..3a8f81d 100644 --- a/WebCore/rendering/style/ShadowData.cpp +++ b/WebCore/rendering/style/ShadowData.cpp @@ -22,6 +22,11 @@ #include "config.h" #include "ShadowData.h" +#include "FloatRect.h" +#include "IntRect.h" + +using namespace std; + namespace WebCore { ShadowData::ShadowData(const ShadowData& o) @@ -44,4 +49,45 @@ bool ShadowData::operator==(const ShadowData& o) const 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; } +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/WebCore/rendering/style/ShadowData.h b/WebCore/rendering/style/ShadowData.h index 9252e13..ca83af0 100644 --- a/WebCore/rendering/style/ShadowData.h +++ b/WebCore/rendering/style/ShadowData.h @@ -30,6 +30,9 @@ namespace WebCore { +class FloatRect; +class IntRect; + enum ShadowStyle { Normal, Inset }; // This struct holds information about shadows for the text-shadow and box-shadow properties. @@ -76,6 +79,9 @@ public: 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; diff --git a/WebCore/rendering/style/StyleCachedImage.cpp b/WebCore/rendering/style/StyleCachedImage.cpp index b55c5b9..1d7aba8 100644 --- a/WebCore/rendering/style/StyleCachedImage.cpp +++ b/WebCore/rendering/style/StyleCachedImage.cpp @@ -29,7 +29,7 @@ namespace WebCore { -PassRefPtr<CSSValue> StyleCachedImage::cssValue() +PassRefPtr<CSSValue> StyleCachedImage::cssValue() const { return CSSPrimitiveValue::create(m_image->url(), CSSPrimitiveValue::CSS_URI); } diff --git a/WebCore/rendering/style/StyleCachedImage.h b/WebCore/rendering/style/StyleCachedImage.h index 3d22868..3d6e1a2 100644 --- a/WebCore/rendering/style/StyleCachedImage.h +++ b/WebCore/rendering/style/StyleCachedImage.h @@ -38,7 +38,7 @@ public: virtual bool isCachedImage() const { return true; } - virtual PassRefPtr<CSSValue> cssValue(); + virtual PassRefPtr<CSSValue> cssValue() const; CachedImage* cachedImage() const { return m_image.get(); } diff --git a/WebCore/rendering/style/StyleGeneratedImage.cpp b/WebCore/rendering/style/StyleGeneratedImage.cpp index 610e73d..2322f5f 100644 --- a/WebCore/rendering/style/StyleGeneratedImage.cpp +++ b/WebCore/rendering/style/StyleGeneratedImage.cpp @@ -29,7 +29,7 @@ namespace WebCore { -PassRefPtr<CSSValue> StyleGeneratedImage::cssValue() +PassRefPtr<CSSValue> StyleGeneratedImage::cssValue() const { return m_generator; } diff --git a/WebCore/rendering/style/StyleGeneratedImage.h b/WebCore/rendering/style/StyleGeneratedImage.h index 532e383..7be1f6a 100644 --- a/WebCore/rendering/style/StyleGeneratedImage.h +++ b/WebCore/rendering/style/StyleGeneratedImage.h @@ -42,7 +42,7 @@ public: virtual bool isGeneratedImage() const { return true; } - virtual PassRefPtr<CSSValue> cssValue(); + virtual PassRefPtr<CSSValue> cssValue() const; virtual IntSize imageSize(const RenderObject*, float multiplier) const; virtual bool imageHasRelativeWidth() const { return !m_fixedSize; } diff --git a/WebCore/rendering/style/StyleImage.h b/WebCore/rendering/style/StyleImage.h index cb90288..ead8d4a 100644 --- a/WebCore/rendering/style/StyleImage.h +++ b/WebCore/rendering/style/StyleImage.h @@ -24,6 +24,7 @@ #ifndef StyleImage_h #define StyleImage_h +#include "CSSValue.h" #include "IntSize.h" #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> @@ -41,12 +42,12 @@ class StyleImage : public RefCounted<StyleImage> { public: virtual ~StyleImage() { } - bool operator==(const StyleImage& other) + bool operator==(const StyleImage& other) const { return data() == other.data(); } - - virtual PassRefPtr<CSSValue> cssValue() = 0; + + virtual PassRefPtr<CSSValue> cssValue() const = 0; virtual bool canRender(float /*multiplier*/) const { return true; } virtual bool isLoaded() const { return true; } @@ -60,7 +61,9 @@ public: 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) diff --git a/WebCore/rendering/style/StylePendingImage.h b/WebCore/rendering/style/StylePendingImage.h new file mode 100644 index 0000000..b0c9b01 --- /dev/null +++ b/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<StylePendingImage> create(CSSImageValue* value) { return adoptRef(new StylePendingImage(value)); } + + virtual WrappedImagePtr data() const { return m_value; } + + virtual bool isPendingImage() const { return true; } + + virtual PassRefPtr<CSSValue> 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 |