OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. |
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
6 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com) | 6 * Copyright (C) 2010 Daniel Bates (dbates@intudata.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
12 * | 12 * |
13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
17 * | 17 * |
18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "core/layout/LayoutListMarker.h" | 26 #include "core/layout/LayoutListMarker.h" |
27 | 27 |
| 28 #include "core/dom/MarkerPseudoElement.h" |
28 #include "core/fetch/ImageResource.h" | 29 #include "core/fetch/ImageResource.h" |
29 #include "core/layout/LayoutAnalyzer.h" | 30 #include "core/layout/LayoutAnalyzer.h" |
30 #include "core/layout/LayoutListItem.h" | 31 #include "core/layout/LayoutListItem.h" |
31 #include "core/layout/TextRunConstructor.h" | 32 #include "core/layout/TextRunConstructor.h" |
32 #include "core/paint/DeprecatedPaintLayer.h" | 33 #include "core/paint/DeprecatedPaintLayer.h" |
33 #include "core/paint/ListMarkerPainter.h" | 34 #include "core/paint/ListMarkerPainter.h" |
34 #include "platform/fonts/Font.h" | 35 #include "platform/fonts/Font.h" |
35 #include "wtf/text/StringBuilder.h" | 36 #include "wtf/text/StringBuilder.h" |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 case Georgian: | 1042 case Georgian: |
1042 return toGeorgian(value); | 1043 return toGeorgian(value); |
1043 case Hebrew: | 1044 case Hebrew: |
1044 return toHebrew(value); | 1045 return toHebrew(value); |
1045 } | 1046 } |
1046 | 1047 |
1047 ASSERT_NOT_REACHED(); | 1048 ASSERT_NOT_REACHED(); |
1048 return ""; | 1049 return ""; |
1049 } | 1050 } |
1050 | 1051 |
| 1052 LayoutListMarker::LayoutListMarker(Element* node, LayoutListItem* item) |
| 1053 : LayoutBox(node) |
| 1054 , m_listItem(item) |
| 1055 { |
| 1056 // init LayoutObject attributes |
| 1057 setInline(true); // our object is Inline |
| 1058 setReplaced(true); // pretend to be replaced |
| 1059 } |
| 1060 |
1051 LayoutListMarker::LayoutListMarker(LayoutListItem* item) | 1061 LayoutListMarker::LayoutListMarker(LayoutListItem* item) |
1052 : LayoutBox(0) | 1062 : LayoutBox(0) |
1053 , m_listItem(item) | 1063 , m_listItem(item) |
1054 { | 1064 { |
1055 // init LayoutObject attributes | 1065 // init LayoutObject attributes |
1056 setInline(true); // our object is Inline | 1066 setInline(true); // our object is Inline |
1057 setReplaced(true); // pretend to be replaced | 1067 setReplaced(true); // pretend to be replaced |
1058 } | 1068 } |
1059 | 1069 |
1060 LayoutListMarker::~LayoutListMarker() | 1070 LayoutListMarker::~LayoutListMarker() |
1061 { | 1071 { |
1062 } | 1072 } |
1063 | 1073 |
1064 void LayoutListMarker::destroy() | 1074 void LayoutListMarker::destroy() |
1065 { | 1075 { |
1066 if (m_image) | 1076 if (m_image) |
1067 m_image->removeClient(this); | 1077 m_image->removeClient(this); |
1068 LayoutBox::destroy(); | 1078 LayoutBox::destroy(); |
1069 } | 1079 } |
1070 | 1080 |
1071 LayoutListMarker* LayoutListMarker::createAnonymous(LayoutListItem* item) | 1081 LayoutListMarker* LayoutListMarker::createAnonymous(LayoutListItem* item) |
1072 { | 1082 { |
1073 Document& document = item->document(); | 1083 Document& document = item->document(); |
1074 LayoutListMarker* renderer = new LayoutListMarker(item); | 1084 LayoutListMarker* layoutObject = new LayoutListMarker(item); |
1075 renderer->setDocumentForAnonymous(&document); | 1085 layoutObject->setDocumentForAnonymous(&document); |
1076 return renderer; | 1086 return layoutObject; |
1077 } | 1087 } |
1078 | 1088 |
1079 void LayoutListMarker::styleWillChange(StyleDifference diff, const ComputedStyle
& newStyle) | 1089 void LayoutListMarker::styleWillChange(StyleDifference diff, const ComputedStyle
& newStyle) |
1080 { | 1090 { |
1081 if (style() && (newStyle.listStylePosition() != style()->listStylePosition()
|| newStyle.listStyleType() != style()->listStyleType())) | 1091 if (style() && (newStyle.listStylePosition() != style()->listStylePosition()
|| newStyle.listStyleType() != style()->listStyleType())) |
1082 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalida
tionReason::StyleChange); | 1092 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalida
tionReason::StyleChange); |
1083 | 1093 |
1084 LayoutBox::styleWillChange(diff, newStyle); | 1094 LayoutBox::styleWillChange(diff, newStyle); |
1085 } | 1095 } |
1086 | 1096 |
1087 void LayoutListMarker::styleDidChange(StyleDifference diff, const ComputedStyle*
oldStyle) | 1097 void LayoutListMarker::styleDidChange(StyleDifference diff, const ComputedStyle*
oldStyle) |
1088 { | 1098 { |
1089 LayoutBox::styleDidChange(diff, oldStyle); | 1099 LayoutBox::styleDidChange(diff, oldStyle); |
1090 | 1100 |
| 1101 if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) |
| 1102 updateMarginsAndContent(); |
| 1103 |
1091 if (m_image != style()->listStyleImage()) { | 1104 if (m_image != style()->listStyleImage()) { |
1092 if (m_image) | 1105 if (m_image) |
1093 m_image->removeClient(this); | 1106 m_image->removeClient(this); |
1094 m_image = style()->listStyleImage(); | 1107 m_image = style()->listStyleImage(); |
1095 if (m_image) | 1108 if (m_image) |
1096 m_image->addClient(this); | 1109 m_image->addClient(this); |
1097 } | 1110 } |
1098 } | 1111 } |
1099 | 1112 |
1100 InlineBox* LayoutListMarker::createInlineBox() | 1113 InlineBox* LayoutListMarker::createInlineBox() |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 LayoutRect rect(0, root.selectionTop() - location().y(), size().width(), roo
t.selectionHeight()); | 1642 LayoutRect rect(0, root.selectionTop() - location().y(), size().width(), roo
t.selectionHeight()); |
1630 mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, 0); | 1643 mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, 0); |
1631 // FIXME: groupedMapping() leaks the squashing abstraction. | 1644 // FIXME: groupedMapping() leaks the squashing abstraction. |
1632 if (paintInvalidationContainer->layer()->groupedMapping()) | 1645 if (paintInvalidationContainer->layer()->groupedMapping()) |
1633 DeprecatedPaintLayer::mapRectToPaintBackingCoordinates(paintInvalidation
Container, rect); | 1646 DeprecatedPaintLayer::mapRectToPaintBackingCoordinates(paintInvalidation
Container, rect); |
1634 return rect; | 1647 return rect; |
1635 } | 1648 } |
1636 | 1649 |
1637 void LayoutListMarker::listItemStyleDidChange() | 1650 void LayoutListMarker::listItemStyleDidChange() |
1638 { | 1651 { |
1639 RefPtr<ComputedStyle> newStyle = ComputedStyle::create(); | 1652 ASSERT(!RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()); |
1640 // The marker always inherits from the list item, regardless of where it mig
ht end | 1653 RefPtr<ComputedStyle> newStyle = MarkerPseudoElement::styleForListMarkerLayo
utObject(*m_listItem, style()); |
1641 // up (e.g., in some deeply nested line box). See CSS3 spec. | |
1642 newStyle->inheritFrom(m_listItem->styleRef()); | |
1643 if (style()) { | |
1644 // Reuse the current margins. Otherwise resetting the margins to initial
values | |
1645 // would trigger unnecessary layout. | |
1646 newStyle->setMarginStart(style()->marginStart()); | |
1647 newStyle->setMarginEnd(style()->marginRight()); | |
1648 } | |
1649 setStyle(newStyle.release()); | 1654 setStyle(newStyle.release()); |
1650 } | 1655 } |
1651 | 1656 |
1652 } // namespace blink | 1657 } // namespace blink |
OLD | NEW |