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/core/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/core/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 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element) | 1219 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element) |
1217 { | 1220 { |
1218 if (!m_mutableStyle || m_mutableStyle->isEmpty()) | 1221 if (!m_mutableStyle || m_mutableStyle->isEmpty()) |
1219 return; | 1222 return; |
1220 | 1223 |
1221 RefPtrWillBeRawPtr<StylePropertySet> defaultStyle = styleFromMatchedRulesFor
Element(element, StyleResolver::UAAndUserCSSRules); | 1224 RefPtrWillBeRawPtr<StylePropertySet> defaultStyle = styleFromMatchedRulesFor
Element(element, StyleResolver::UAAndUserCSSRules); |
1222 | 1225 |
1223 removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get()); | 1226 removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get()); |
1224 } | 1227 } |
1225 | 1228 |
| 1229 void EditingStyle::addAbsolutePositioningFromElement(const Element& element) |
| 1230 { |
| 1231 LayoutRect rect = element.boundingBox(); |
| 1232 RenderObject* renderer = element.renderer(); |
| 1233 |
| 1234 LayoutUnit x = rect.x(); |
| 1235 LayoutUnit y = rect.y(); |
| 1236 LayoutUnit width = rect.width(); |
| 1237 LayoutUnit height = rect.height(); |
| 1238 if (renderer && renderer->isBox()) { |
| 1239 RenderBox* renderBox = toRenderBox(renderer); |
| 1240 |
| 1241 x -= renderBox->marginLeft(); |
| 1242 y -= renderBox->marginTop(); |
| 1243 |
| 1244 m_mutableStyle->setProperty(CSSPropertyBoxSizing, CSSValueBorderBox); |
| 1245 } |
| 1246 |
| 1247 m_mutableStyle->setProperty(CSSPropertyPosition, CSSValueAbsolute); |
| 1248 m_mutableStyle->setProperty(CSSPropertyLeft, cssValuePool().createValue(x, C
SSPrimitiveValue::CSS_PX)); |
| 1249 m_mutableStyle->setProperty(CSSPropertyTop, cssValuePool().createValue(y, CS
SPrimitiveValue::CSS_PX)); |
| 1250 m_mutableStyle->setProperty(CSSPropertyWidth, cssValuePool().createValue(wid
th, CSSPrimitiveValue::CSS_PX)); |
| 1251 m_mutableStyle->setProperty(CSSPropertyHeight, cssValuePool().createValue(he
ight, CSSPrimitiveValue::CSS_PX)); |
| 1252 } |
| 1253 |
1226 void EditingStyle::forceInline() | 1254 void EditingStyle::forceInline() |
1227 { | 1255 { |
1228 if (!m_mutableStyle) | 1256 if (!m_mutableStyle) |
1229 m_mutableStyle = MutableStylePropertySet::create(); | 1257 m_mutableStyle = MutableStylePropertySet::create(); |
1230 const bool propertyIsImportant = true; | 1258 const bool propertyIsImportant = true; |
1231 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); | 1259 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm
portant); |
1232 } | 1260 } |
1233 | 1261 |
1234 int EditingStyle::legacyFontSize(Document* document) const | 1262 int EditingStyle::legacyFontSize(Document* document) const |
1235 { | 1263 { |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 { | 1673 { |
1646 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1674 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
1647 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1675 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
1648 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1676 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
1649 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1677 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
1650 } | 1678 } |
1651 return nullptr; | 1679 return nullptr; |
1652 } | 1680 } |
1653 | 1681 |
1654 } | 1682 } |
OLD | NEW |