Index: Source/core/editing/EditingStyle.cpp |
diff --git a/Source/core/editing/EditingStyle.cpp b/Source/core/editing/EditingStyle.cpp |
index cb4eb97c45778337f7fc521bb38ef7d2c541c205..34e03a2b1f9431540e59d98a39f8b7f8f203d9e0 100644 |
--- a/Source/core/editing/EditingStyle.cpp |
+++ b/Source/core/editing/EditingStyle.cpp |
@@ -34,11 +34,13 @@ |
#include "core/css/CSSRuleList.h" |
#include "core/css/CSSStyleRule.h" |
#include "core/css/CSSValueList.h" |
+#include "core/css/CSSValuePool.h" |
#include "core/css/FontSize.h" |
#include "core/css/RuntimeCSSEnabled.h" |
#include "core/css/StylePropertySet.h" |
#include "core/css/StyleRule.h" |
#include "core/css/resolver/StyleResolver.h" |
+#include "core/dom/ClientRect.h" |
#include "core/dom/Element.h" |
#include "core/dom/Node.h" |
#include "core/dom/NodeTraversal.h" |
@@ -51,6 +53,8 @@ |
#include "core/editing/htmlediting.h" |
#include "core/frame/LocalFrame.h" |
#include "core/html/HTMLFontElement.h" |
+#include "core/rendering/RenderBox.h" |
+#include "core/rendering/RenderObject.h" |
#include "core/rendering/style/RenderStyle.h" |
namespace WebCore { |
@@ -1232,6 +1236,31 @@ void EditingStyle::removePropertiesInElementDefaultStyle(Element* element) |
removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get()); |
} |
+void EditingStyle::addAbsolutePositioningFromElement(const Element& element) |
+{ |
+ LayoutRect rect = element.boundingBox(); |
+ RenderObject* renderer = element.renderer(); |
+ |
+ LayoutUnit x = rect.x(); |
+ LayoutUnit y = rect.y(); |
+ LayoutUnit width = rect.width(); |
+ LayoutUnit height = rect.height(); |
+ if (renderer && renderer->isBox()) { |
+ RenderBox* renderBox = toRenderBox(renderer); |
+ |
+ x -= renderBox->marginLeft(); |
+ y -= renderBox->marginTop(); |
+ width -= renderBox->paddingRight() + renderBox->paddingLeft() + renderBox->borderWidth(); |
+ height -= renderBox->paddingTop() + renderBox->paddingBottom() + renderBox->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 (
|
+ } |
+ |
+ m_mutableStyle->setProperty(CSSPropertyPosition, CSSValueAbsolute); |
+ m_mutableStyle->setProperty(CSSPropertyLeft, cssValuePool().createValue(x, CSSPrimitiveValue::CSS_PX)); |
+ m_mutableStyle->setProperty(CSSPropertyTop, cssValuePool().createValue(y, CSSPrimitiveValue::CSS_PX)); |
+ m_mutableStyle->setProperty(CSSPropertyWidth, cssValuePool().createValue(width, CSSPrimitiveValue::CSS_PX)); |
+ m_mutableStyle->setProperty(CSSPropertyHeight, cssValuePool().createValue(height, CSSPrimitiveValue::CSS_PX)); |
+} |
+ |
void EditingStyle::forceInline() |
{ |
if (!m_mutableStyle) |