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 "HTMLNames.h" | 30 #include "HTMLNames.h" |
31 #include "bindings/v8/ExceptionStatePlaceholder.h" | 31 #include "bindings/v8/ExceptionStatePlaceholder.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" |
43 #include "core/dom/ClientRect.h" | |
42 #include "core/dom/Element.h" | 44 #include "core/dom/Element.h" |
43 #include "core/dom/Node.h" | 45 #include "core/dom/Node.h" |
44 #include "core/dom/NodeTraversal.h" | 46 #include "core/dom/NodeTraversal.h" |
45 #include "core/dom/Position.h" | 47 #include "core/dom/Position.h" |
46 #include "core/dom/QualifiedName.h" | 48 #include "core/dom/QualifiedName.h" |
47 #include "core/editing/ApplyStyleCommand.h" | 49 #include "core/editing/ApplyStyleCommand.h" |
48 #include "core/editing/Editor.h" | 50 #include "core/editing/Editor.h" |
49 #include "core/editing/FrameSelection.h" | 51 #include "core/editing/FrameSelection.h" |
50 #include "core/editing/HTMLInterchange.h" | 52 #include "core/editing/HTMLInterchange.h" |
51 #include "core/editing/htmlediting.h" | 53 #include "core/editing/htmlediting.h" |
52 #include "core/frame/LocalFrame.h" | 54 #include "core/frame/LocalFrame.h" |
53 #include "core/html/HTMLFontElement.h" | 55 #include "core/html/HTMLFontElement.h" |
56 #include "core/rendering/RenderBox.h" | |
57 #include "core/rendering/RenderObject.h" | |
54 #include "core/rendering/style/RenderStyle.h" | 58 #include "core/rendering/style/RenderStyle.h" |
55 | 59 |
56 namespace WebCore { | 60 namespace WebCore { |
57 | 61 |
58 static const CSSPropertyID& textDecorationPropertyForEditing() | 62 static const CSSPropertyID& textDecorationPropertyForEditing() |
59 { | 63 { |
60 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; | 64 static const CSSPropertyID property = RuntimeEnabledFeatures::css3TextDecora tionsEnabled() ? CSSPropertyTextDecorationLine : CSSPropertyTextDecoration; |
61 return property; | 65 return property; |
62 } | 66 } |
63 | 67 |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1225 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element) | 1229 void EditingStyle::removePropertiesInElementDefaultStyle(Element* element) |
1226 { | 1230 { |
1227 if (!m_mutableStyle || m_mutableStyle->isEmpty()) | 1231 if (!m_mutableStyle || m_mutableStyle->isEmpty()) |
1228 return; | 1232 return; |
1229 | 1233 |
1230 RefPtr<StylePropertySet> defaultStyle = styleFromMatchedRulesForElement(elem ent, StyleResolver::UAAndUserCSSRules); | 1234 RefPtr<StylePropertySet> defaultStyle = styleFromMatchedRulesForElement(elem ent, StyleResolver::UAAndUserCSSRules); |
1231 | 1235 |
1232 removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get()); | 1236 removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get()); |
1233 } | 1237 } |
1234 | 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 width -= renderBox->paddingRight() + renderBox->paddingLeft() + renderBo x->borderWidth(); | |
1254 height -= renderBox->paddingTop() + renderBox->paddingBottom() + renderB ox->borderHeight(); | |
esprehn
2014/06/13 08:47:06
This doesn't work if you set box-sizing, I really
oystein (OOO til 10th of July)
2014/06/17 21:07:06
Cool, setting just border-box seems to work well (
| |
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 | |
1235 void EditingStyle::forceInline() | 1264 void EditingStyle::forceInline() |
1236 { | 1265 { |
1237 if (!m_mutableStyle) | 1266 if (!m_mutableStyle) |
1238 m_mutableStyle = MutableStylePropertySet::create(); | 1267 m_mutableStyle = MutableStylePropertySet::create(); |
1239 const bool propertyIsImportant = true; | 1268 const bool propertyIsImportant = true; |
1240 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm portant); | 1269 m_mutableStyle->setProperty(CSSPropertyDisplay, CSSValueInline, propertyIsIm portant); |
1241 } | 1270 } |
1242 | 1271 |
1243 int EditingStyle::legacyFontSize(Document* document) const | 1272 int EditingStyle::legacyFontSize(Document* document) const |
1244 { | 1273 { |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1660 { | 1689 { |
1661 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1690 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
1662 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor); | 1691 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu tedStyleDeclaration::create(ancestor); |
1663 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1692 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
1664 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); | 1693 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor ); |
1665 } | 1694 } |
1666 return nullptr; | 1695 return nullptr; |
1667 } | 1696 } |
1668 | 1697 |
1669 } | 1698 } |
OLD | NEW |