Source/WebCore: Implement the CSS3 line-box-contain property. This property provides authors with more control over spacing between lines. For example,
you can fix the height of lines and cause all line contents to be ignored. You can make lines fit to glyphs. You can ignore leading and
fit to the font size. You can ignore replaced elements, etc.
Reviewed by Simon Fraser.
Refactor the code in computeLogicalBoxHeights into helper methods on RootInlineBox. verticalPositionForBox moved over to RootInlineBox
so that it could be called from RenderBlockLineLayout. ascentAndDescentForBox is the new method that computes the appropriate box
height based off the block's line-box-contain value.
GlyphOverflow can now have a computeBounds parameter set, in which case glyph bounds will be computed and stored in the overflow struct.
RenderInline no longer returns 0 margins in the block direction, since line-box-contain can size around the margin box.
Added new tests in fast/block/lineboxcontain
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::createLineBoxContainValue):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSLineBoxContainValue.cpp: Added.
(WebCore::CSSLineBoxContainValue::CSSLineBoxContainValue):
(WebCore::CSSLineBoxContainValue::cssText):
* css/CSSLineBoxContainValue.h: Added.
(WebCore::CSSLineBoxContainValue::create):
(WebCore::CSSLineBoxContainValue::value):
(WebCore::CSSLineBoxContainValue::isCSSLineBoxContainValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseLineBoxContain):
* css/CSSParser.h:
* css/CSSPropertyNames.in:
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* css/CSSValue.h:
(WebCore::CSSValue::isCSSLineBoxContainValue):
* css/CSSValueKeywords.in:
* platform/graphics/Font.cpp:
(WebCore::Font::width):
* platform/graphics/Font.h:
(WebCore::GlyphOverflow::GlyphOverflow):
* platform/graphics/FontFastPath.cpp:
(WebCore::Font::floatWidthForSimpleText):
* platform/graphics/mac/FontComplexTextMac.cpp:
(WebCore::Font::floatWidthForComplexText):
* platform/graphics/win/FontWin.cpp:
(WebCore::Font::floatWidthForComplexText):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::computeLogicalBoxHeights):
* rendering/InlineFlowBox.h:
* rendering/RenderBlock.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::computeInlineDirectionPositionsForLine):
(WebCore::RenderBlock::layoutInlineChildren):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::marginLeft):
(WebCore::RenderInline::marginRight):
(WebCore::RenderInline::marginTop):
(WebCore::RenderInline::marginBottom):
(WebCore::RenderInline::marginBefore):
(WebCore::RenderInline::marginAfter):
* rendering/RenderInline.h:
* rendering/RenderText.cpp:
(WebCore::RenderText::widthFromCache):
(WebCore::RenderText::width):
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::alignBoxesInBlockDirection):
(WebCore::setAscentAndDescent):
(WebCore::RootInlineBox::ascentAndDescentForBox):
(WebCore::RootInlineBox::verticalPositionForBox):
(WebCore::RootInlineBox::includeLeadingForBox):
(WebCore::RootInlineBox::includeFontForBox):
(WebCore::RootInlineBox::includeGlyphsForBox):
(WebCore::RootInlineBox::includeMarginForBox):
(WebCore::RootInlineBox::fitsToGlyphs):
(WebCore::RootInlineBox::includesRootLineBoxFontOrLeading):
* rendering/RootInlineBox.h:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::diff):
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::lineBoxContain):
(WebCore::InheritedFlags::setLineBoxContain):
(WebCore::InheritedFlags::initialLineBoxContain):
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):
* rendering/style/StyleRareInheritedData.h:
LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=56388
Reviewed by Simon Fraser.
Implement the CSS3 line-box-contain property. This property provides authors with more control over spacing between lines. For example,
you can fix the height of lines and cause all line contents to be ignored. You can make lines fit to glyphs. You can ignore leading and
fit to the font size. You can ignore replaced elements, etc.
Refactor the code in computeLogicalBoxHeights into helper methods on RootInlineBox. verticalPositionForBox moved over to RootInlineBox
so that it could be called from RenderBlockLineLayout. ascentAndDescentForBox is the new method that computes the appropriate box
height based off the block's line-box-contain value.
GlyphOverflow can now have a computeBounds parameter set, in which case glyph bounds will be computed and stored in the overflow struct.
RenderInline no longer returns 0 margins in the block direction, since line-box-contain can size around the margin box.
* fast/block/lineboxcontain: Added.
* fast/block/lineboxcontain/block-font.html: Added.
* fast/block/lineboxcontain/block-glyphs-replaced.html: Added.
* fast/block/lineboxcontain/block-glyphs.html: Added.
* fast/block/lineboxcontain/block-replaced.html: Added.
* fast/block/lineboxcontain/block.html: Added.
* fast/block/lineboxcontain/font-replaced.html: Added.
* fast/block/lineboxcontain/font.html: Added.
* fast/block/lineboxcontain/glyphs.html: Added.
* fast/block/lineboxcontain/inline-box-replaced.html: Added.
* fast/block/lineboxcontain/inline-box-vertical.html: Added.
* fast/block/lineboxcontain/inline-box.html: Added.
* fast/block/lineboxcontain/inline-replaced.html: Added.
* fast/block/lineboxcontain/inline.html: Added.
* fast/block/lineboxcontain/none.html: Added.
* fast/block/lineboxcontain/replaced.html: Added.
* platform/mac/fast/block/lineboxcontain: Added.
* platform/mac/fast/block/lineboxcontain/block-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/block-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/block-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/block-font-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/block-font-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/block-font-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-replaced-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/block-replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/block-replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/block-replaced-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/font-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/font-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/font-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/font-replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/font-replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/font-replaced-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/glyphs-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/glyphs-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/glyphs-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-replaced-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-vertical-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-vertical-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-vertical-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/inline-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/inline-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/inline-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/inline-replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/inline-replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/inline-replaced-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/none-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/none-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/none-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/replaced-expected.txt: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@81684 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/css/CSSLineBoxContainValue.cpp b/Source/WebCore/css/CSSLineBoxContainValue.cpp
new file mode 100644
index 0000000..b029285
--- /dev/null
+++ b/Source/WebCore/css/CSSLineBoxContainValue.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CSSLineBoxContainValue.h"
+
+#include "CSSPrimitiveValue.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+CSSLineBoxContainValue::CSSLineBoxContainValue(unsigned value)
+ : m_value(value)
+{
+}
+
+String CSSLineBoxContainValue::cssText() const
+{
+ String text("");
+
+ if (m_value & LineBoxContainBlock)
+ text += "block";
+ if (m_value & LineBoxContainInline) {
+ if (!text.isEmpty())
+ text += " ";
+ text += "inline";
+ }
+ if (m_value & LineBoxContainFont) {
+ if (!text.isEmpty())
+ text += " ";
+ text += "font";
+ }
+ if (m_value & LineBoxContainGlyphs) {
+ if (!text.isEmpty())
+ text += " ";
+ text += "glyphs";
+ }
+ if (m_value & LineBoxContainReplaced) {
+ if (!text.isEmpty())
+ text += " ";
+ text += "replaced";
+ }
+ if (m_value & LineBoxContainInlineBox) {
+ if (!text.isEmpty())
+ text += " ";
+ text += "inline-box";
+ }
+
+ return text;
+}
+
+}