1926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)/*
2926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
3926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
4926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without
5926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * modification, are permitted provided that the following conditions
6926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * are met:
7926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
8926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 1. Redistributions of source code must retain the above
9926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    copyright notice, this list of conditions and the following
10926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    disclaimer.
11926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 2. Redistributions in binary form must reproduce the above
12926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    copyright notice, this list of conditions and the following
13926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    disclaimer in the documentation and/or other materials
14926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *    provided with the distribution.
15926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) *
16926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
17926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
20926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * SUCH DAMAGE.
28926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) */
29926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
30926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#include "config.h"
31591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "core/rendering/shapes/ShapeOutsideInfo.h"
32926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/rendering/RenderBox.h"
34926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
35926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)namespace WebCore {
36591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochbool ShapeOutsideInfo::isEnabledFor(const RenderBox* box)
37926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
38591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    ShapeValue* value = box->style()->shapeOutside();
39e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    return box->isFloatingWithShapeOutside() && value->type() == ShapeValue::Shape && value->shape();
40926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
41926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
4202772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdochbool ShapeOutsideInfo::computeSegmentsForContainingBlockLine(LayoutUnit lineTop, LayoutUnit floatTop, LayoutUnit lineHeight)
4302772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch{
4402772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch    LayoutUnit lineTopInShapeCoordinates = lineTop - floatTop + logicalTopOffset();
4502772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch    return computeSegmentsForLine(lineTopInShapeCoordinates, lineHeight);
4602772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch}
4702772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch
48591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochbool ShapeOutsideInfo::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight)
49926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
50926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (shapeSizeDirty() || m_lineTop != lineTop || m_lineHeight != lineHeight) {
51591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch        if (ShapeInfo<RenderBox, &RenderStyle::shapeOutside, &Shape::getExcludedIntervals>::computeSegmentsForLine(lineTop, lineHeight)) {
52e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch            m_leftSegmentMarginBoxDelta = m_segments[0].logicalLeft + m_renderer->marginStart();
53e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch            m_rightSegmentMarginBoxDelta = m_segments[m_segments.size()-1].logicalRight - m_renderer->logicalWidth() - m_renderer->marginEnd();
54926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        } else {
55e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch            m_leftSegmentMarginBoxDelta = m_renderer->logicalWidth() + m_renderer->marginStart();
56e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch            m_rightSegmentMarginBoxDelta = -m_renderer->logicalWidth() - m_renderer->marginEnd();
57926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        }
58926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        m_lineTop = lineTop;
59926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    }
60926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
61926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return m_segments.size();
62926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
63926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
64926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
65