OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. | 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. |
3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/editing/EditingStyle.h" | 28 #include "core/editing/EditingStyle.h" |
29 | 29 |
30 #include "bindings/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/v8/ExceptionStatePlaceholder.h" |
31 #include "core/HTMLNames.h" | 31 #include "core/HTMLNames.h" |
32 #include "core/css/CSSComputedStyleDeclaration.h" | 32 #include "core/css/CSSComputedStyleDeclaration.h" |
33 #include "core/css/parser/BisonCSSParser.h" | 33 #include "core/css/parser/BisonCSSParser.h" |
34 #include "core/css/CSSRuleList.h" | 34 #include "core/css/CSSRuleList.h" |
35 #include "core/css/CSSStyleRule.h" | 35 #include "core/css/CSSStyleRule.h" |
36 #include "core/css/CSSValueList.h" | 36 #include "core/css/CSSValueList.h" |
| 37 #include "core/css/CSSValuePool.h" |
37 #include "core/css/FontSize.h" | 38 #include "core/css/FontSize.h" |
38 #include "core/css/RuntimeCSSEnabled.h" | 39 #include "core/css/RuntimeCSSEnabled.h" |
39 #include "core/css/StylePropertySet.h" | 40 #include "core/css/StylePropertySet.h" |
40 #include "core/css/StyleRule.h" | 41 #include "core/css/StyleRule.h" |
41 #include "core/css/resolver/StyleResolver.h" | 42 #include "core/css/resolver/StyleResolver.h" |
42 #include "core/dom/Document.h" | 43 #include "core/dom/Document.h" |
43 #include "core/dom/Element.h" | 44 #include "core/dom/Element.h" |
44 #include "core/dom/Node.h" | 45 #include "core/dom/Node.h" |
45 #include "core/dom/NodeTraversal.h" | 46 #include "core/dom/NodeTraversal.h" |
46 #include "core/dom/Position.h" | 47 #include "core/dom/Position.h" |
47 #include "core/dom/QualifiedName.h" | 48 #include "core/dom/QualifiedName.h" |
48 #include "core/editing/ApplyStyleCommand.h" | 49 #include "core/editing/ApplyStyleCommand.h" |
49 #include "core/editing/Editor.h" | 50 #include "core/editing/Editor.h" |
50 #include "core/editing/FrameSelection.h" | 51 #include "core/editing/FrameSelection.h" |
51 #include "core/editing/HTMLInterchange.h" | 52 #include "core/editing/HTMLInterchange.h" |
52 #include "core/editing/htmlediting.h" | 53 #include "core/editing/htmlediting.h" |
53 #include "core/frame/LocalFrame.h" | 54 #include "core/frame/LocalFrame.h" |
54 #include "core/html/HTMLFontElement.h" | 55 #include "core/html/HTMLFontElement.h" |
| 56 #include "core/rendering/RenderBox.h" |
| 57 #include "core/rendering/RenderObject.h" |
55 #include "core/rendering/style/RenderStyle.h" | 58 #include "core/rendering/style/RenderStyle.h" |
56 | 59 |
57 namespace WebCore { | 60 namespace WebCore { |
58 | 61 |
59 static const CSSPropertyID& textDecorationPropertyForEditing() | 62 static const CSSPropertyID& textDecorationPropertyForEditing() |
60 { | 63 { |
61 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora
tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; | 64 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora
tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; |
62 return property; | 65 return property; |
63 } | 66 } |
64 | 67 |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element) | 1229 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element) |
1227 { | 1230 { |
1228 if (!m_mutableStyle || m_mutableStyle->isEmpty()) | 1231 if (!m_mutableStyle || m_mutableStyle->isEmpty()) |
1229 return; | 1232 return; |
1230 | 1233 |
1231 RefPtrWillBeRawPtr<StylePropertySet> defaultStyle = styleFromMatchedRulesFor
Element(element, StyleResolver::UAAndUserCSSRules); | 1234 RefPtrWillBeRawPtr<StylePropertySet> defaultStyle = styleFromMatchedRulesFor
Element(element, StyleResolver::UAAndUserCSSRules); |
1232 | 1235 |
1233 removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get()); | 1236 removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get()); |
1234 } | 1237 } |
1235 | 1238 |
| 1239 void EditingStyle::addAbsolutePositioningFromElement(const Element& element) |
| 1240 { |
| 1241 LayoutRect rect = element.boundingBox(); |
| 1242 RenderObject* renderer = element.renderer(); |
| 1243 |
| 1244 LayoutUnit x = rect.x(); |
| 1245 LayoutUnit y = rect.y(); |
| 1246 LayoutUnit width = rect.width(); |
| 1247 LayoutUnit height = rect.height(); |
| 1248 if (renderer && renderer->isBox()) { |
| 1249 RenderBox* renderBox = toRenderBox(renderer); |
| 1250 |
| 1251 x -= renderBox->marginLeft(); |
| 1252 y -= renderBox->marginTop(); |
| 1253 |
| 1254 m_mutableStyle->setProperty(CSSPropertyBoxSizing, CSSValueBorderBox); |
| 1255 } |
| 1256 |
| 1257 m_mutableStyle->setProperty(CSSPropertyPosition, CSSValueAbsolute); |
| 1258 m_mutableStyle->setProperty(CSSPropertyLeft, cssValuePool().createValue(x, C
SSPrimitiveValue::CSS_PX)); |
| 1259 m_mutableStyle->setProperty(CSSPropertyTop, cssValuePool().createValue(y, CS
SPrimitiveValue::CSS_PX)); |
| 1260 m_mutableStyle->setProperty(CSSPropertyWidth, cssValuePool().createValue(wid
th, CSSPrimitiveValue::CSS_PX)); |
| 1261 m_mutableStyle->setProperty(CSSPropertyHeight, cssValuePool().createValue(he
ight, CSSPrimitiveValue::CSS_PX)); |
| 1262 } |
| 1263 |
1236 void EditingStyle::forceInline() | 1264 void EditingStyle::forceInline() |
1237 { | 1265 { |
1238 if (!m_mutableStyle) | 1266 if (!m_mutableStyle) |
1239 m_mutableStyle = MutableStylePropertySet::create(); | 1267 m_mutableStyle = MutableStylePropertySet::create(); |
1240 const bool propertyIsImportant = true; | 1268 const bool propertyIsImportant = true; |
1241 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); | 1269 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); |
1242 } | 1270 } |
1243 | 1271 |
1244 int EditingStyle::legacyFontSize(Document* document) const | 1272 int EditingStyle::legacyFontSize(Document* document) const |
1245 { | 1273 { |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 { | 1689 { |
1662 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1690 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
1663 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1691 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
1664 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1692 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
1665 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1693 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
1666 } | 1694 } |
1667 return nullptr; | 1695 return nullptr; |
1668 } | 1696 } |
1669 | 1697 |
1670 } | 1698 } |
OLD | NEW |