darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 1 | /* |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 2 | * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 | * (C) 1999 Antti Koivisto (koivisto@kde.org) |
darin@apple.com | b6cb256 | 2009-08-05 21:25:09 +0000 | [diff] [blame] | 4 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Library General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Library General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Library General Public License |
| 17 | * along with this library; see the file COPYING.LIB. If not, write to |
ddkilzer | c8eccec | 2007-09-26 02:29:57 +0000 | [diff] [blame] | 18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 | * Boston, MA 02110-1301, USA. |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include "config.h" |
| 24 | #include "RenderInline.h" |
| 25 | |
aroben@apple.com | a7c639a | 2009-12-18 17:38:45 +0000 | [diff] [blame] | 26 | #include "Chrome.h" |
darin@apple.com | 36744d6 | 2009-01-25 20:23:04 +0000 | [diff] [blame] | 27 | #include "FloatQuad.h" |
zalan@apple.com | e36543a | 2014-07-29 01:45:54 +0000 | [diff] [blame] | 28 | #include "FrameSelection.h" |
hyatt@apple.com | 9bfe16c | 2009-01-28 23:44:41 +0000 | [diff] [blame] | 29 | #include "GraphicsContext.h" |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 30 | #include "HitTestResult.h" |
akling@apple.com | 27e7d14 | 2013-11-07 12:04:02 +0000 | [diff] [blame] | 31 | #include "InlineElementBox.h" |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 32 | #include "InlineTextBox.h" |
bdakin@apple.com | e3d43bb | 2009-02-05 00:19:31 +0000 | [diff] [blame] | 33 | #include "Page.h" |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 34 | #include "RenderBlock.h" |
rniwa@webkit.org | 39c8c1b | 2013-05-22 19:21:52 +0000 | [diff] [blame] | 35 | #include "RenderFullScreen.h" |
simon.fraser@apple.com | ca41ec6 | 2012-05-25 21:42:32 +0000 | [diff] [blame] | 36 | #include "RenderGeometryMap.h" |
akling@apple.com | 1626ee0 | 2013-11-04 12:55:48 +0000 | [diff] [blame] | 37 | #include "RenderIterator.h" |
eric@webkit.org | b35848a | 2010-06-10 08:33:22 +0000 | [diff] [blame] | 38 | #include "RenderLayer.h" |
antti@apple.com | 8d8ae71 | 2013-09-18 18:04:32 +0000 | [diff] [blame] | 39 | #include "RenderLineBreak.h" |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 40 | #include "RenderListMarker.h" |
abucur@adobe.com | 7f2c82d | 2013-11-20 08:47:35 +0000 | [diff] [blame] | 41 | #include "RenderNamedFlowThread.h" |
dbates@webkit.org | e825c2a | 2010-10-14 16:00:52 +0000 | [diff] [blame] | 42 | #include "RenderTheme.h" |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 43 | #include "RenderView.h" |
commit-queue@webkit.org | d0c076d | 2012-08-22 22:25:59 +0000 | [diff] [blame] | 44 | #include "StyleInheritedData.h" |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 45 | #include "TransformState.h" |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 46 | #include "VisiblePosition.h" |
| 47 | |
commit-queue@webkit.org | 85192c5 | 2014-01-26 06:25:55 +0000 | [diff] [blame] | 48 | #if ENABLE(DASHBOARD_SUPPORT) |
mrowe@apple.com | fc8aa69 | 2009-03-09 03:44:38 +0000 | [diff] [blame] | 49 | #include "Frame.h" |
| 50 | #endif |
| 51 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 52 | namespace WebCore { |
| 53 | |
akling@apple.com | 8f40c5b | 2013-10-27 22:54:07 +0000 | [diff] [blame] | 54 | RenderInline::RenderInline(Element& element, PassRef<RenderStyle> style) |
dbates@webkit.org | 0cefe4f | 2014-07-03 22:13:54 +0000 | [diff] [blame] | 55 | : RenderBoxModelObject(element, WTF::move(style), RenderInlineFlag) |
weinig | c24ab18 | 2006-10-30 22:41:29 +0000 | [diff] [blame] | 56 | { |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 57 | setChildrenInline(true); |
weinig | c24ab18 | 2006-10-30 22:41:29 +0000 | [diff] [blame] | 58 | } |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 59 | |
akling@apple.com | 8f40c5b | 2013-10-27 22:54:07 +0000 | [diff] [blame] | 60 | RenderInline::RenderInline(Document& document, PassRef<RenderStyle> style) |
dbates@webkit.org | 0cefe4f | 2014-07-03 22:13:54 +0000 | [diff] [blame] | 61 | : RenderBoxModelObject(document, WTF::move(style), RenderInlineFlag) |
antti@apple.com | 6310f61 | 2013-01-19 14:34:36 +0000 | [diff] [blame] | 62 | { |
akling@apple.com | 42e1063 | 2013-10-14 17:55:52 +0000 | [diff] [blame] | 63 | setChildrenInline(true); |
antti@apple.com | 6310f61 | 2013-01-19 14:34:36 +0000 | [diff] [blame] | 64 | } |
| 65 | |
simon.fraser@apple.com | 73cb0b3 | 2011-07-09 00:43:14 +0000 | [diff] [blame] | 66 | void RenderInline::willBeDestroyed() |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 67 | { |
mitz@apple.com | 9e0c4ef | 2011-11-11 07:08:46 +0000 | [diff] [blame] | 68 | #if !ASSERT_DISABLED |
inferno@chromium.org | 576aa55 | 2011-02-25 23:18:18 +0000 | [diff] [blame] | 69 | // Make sure we do not retain "this" in the continuation outline table map of our containing blocks. |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 70 | if (parent() && style().visibility() == VISIBLE && hasOutline()) { |
inferno@chromium.org | 576aa55 | 2011-02-25 23:18:18 +0000 | [diff] [blame] | 71 | bool containingBlockPaintsContinuationOutline = continuation() || isInlineElementContinuation(); |
| 72 | if (containingBlockPaintsContinuationOutline) { |
| 73 | if (RenderBlock* cb = containingBlock()) { |
| 74 | if (RenderBlock* cbCb = cb->containingBlock()) |
| 75 | ASSERT(!cbCb->paintsContinuationOutline(this)); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | #endif |
| 80 | |
hyatt@apple.com | 4db38f5 | 2009-01-29 18:00:39 +0000 | [diff] [blame] | 81 | // Make sure to destroy anonymous children first while they are still connected to the rest of the tree, so that they will |
| 82 | // properly dirty line boxes that they are removed from. Effects that do :before/:after only on hover could crash otherwise. |
antti@apple.com | da4d316 | 2013-09-23 17:43:04 +0000 | [diff] [blame] | 83 | destroyLeftoverChildren(); |
hyatt@apple.com | 4db38f5 | 2009-01-29 18:00:39 +0000 | [diff] [blame] | 84 | |
darin@apple.com | ecb5332 | 2009-11-03 18:23:53 +0000 | [diff] [blame] | 85 | // Destroy our continuation before anything other than anonymous children. |
| 86 | // The reason we don't destroy it before anonymous children is that they may |
| 87 | // have continuations of their own that are anonymous children of our continuation. |
commit-queue@webkit.org | 4750953 | 2010-12-30 03:16:05 +0000 | [diff] [blame] | 88 | RenderBoxModelObject* continuation = this->continuation(); |
| 89 | if (continuation) { |
| 90 | continuation->destroy(); |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 91 | setContinuation(nullptr); |
darin@apple.com | ecb5332 | 2009-11-03 18:23:53 +0000 | [diff] [blame] | 92 | } |
| 93 | |
hyatt@apple.com | 4db38f5 | 2009-01-29 18:00:39 +0000 | [diff] [blame] | 94 | if (!documentBeingDestroyed()) { |
| 95 | if (firstLineBox()) { |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 96 | // We can't wait for RenderBoxModelObject::destroy to clear the selection, |
hyatt@apple.com | 4db38f5 | 2009-01-29 18:00:39 +0000 | [diff] [blame] | 97 | // because by then we will have nuked the line boxes. |
hyatt@apple.com | 4db38f5 | 2009-01-29 18:00:39 +0000 | [diff] [blame] | 98 | if (isSelectionBorder()) |
zalan@apple.com | e36543a | 2014-07-29 01:45:54 +0000 | [diff] [blame] | 99 | frame().selection().setNeedsSelectionUpdate(); |
hyatt@apple.com | 4db38f5 | 2009-01-29 18:00:39 +0000 | [diff] [blame] | 100 | |
| 101 | // If line boxes are contained inside a root, that means we're an inline. |
| 102 | // In that case, we need to remove all the line boxes so that the parent |
| 103 | // lines aren't pointing to deleted children. If the first line box does |
| 104 | // not have a parent that means they are either already disconnected or |
| 105 | // root lines that can just be destroyed without disconnecting. |
| 106 | if (firstLineBox()->parent()) { |
antti@apple.com | 48e1064 | 2013-10-13 11:39:33 +0000 | [diff] [blame] | 107 | for (auto box = firstLineBox(); box; box = box->nextLineBox()) |
| 108 | box->removeFromParent(); |
hyatt@apple.com | 4db38f5 | 2009-01-29 18:00:39 +0000 | [diff] [blame] | 109 | } |
inferno@chromium.org | 3bdb04c | 2011-05-09 16:29:36 +0000 | [diff] [blame] | 110 | } else if (parent()) |
cdumez@apple.com | f802215 | 2014-10-15 00:29:51 +0000 | [diff] [blame] | 111 | parent()->dirtyLinesFromChangedChild(*this); |
hyatt@apple.com | 4db38f5 | 2009-01-29 18:00:39 +0000 | [diff] [blame] | 112 | } |
| 113 | |
akling@apple.com | 31dd4f4 | 2013-10-30 22:27:59 +0000 | [diff] [blame] | 114 | m_lineBoxes.deleteLineBoxes(); |
hyatt@apple.com | 4db38f5 | 2009-01-29 18:00:39 +0000 | [diff] [blame] | 115 | |
simon.fraser@apple.com | 73cb0b3 | 2011-07-09 00:43:14 +0000 | [diff] [blame] | 116 | RenderBoxModelObject::willBeDestroyed(); |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 117 | } |
| 118 | |
hyatt@apple.com | ca8ce86 | 2010-05-22 04:23:04 +0000 | [diff] [blame] | 119 | RenderInline* RenderInline::inlineElementContinuation() const |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 120 | { |
commit-queue@webkit.org | 4750953 | 2010-12-30 03:16:05 +0000 | [diff] [blame] | 121 | RenderBoxModelObject* continuation = this->continuation(); |
jhoneycutt@apple.com | d4c71aa | 2014-04-19 00:49:07 +0000 | [diff] [blame] | 122 | if (!continuation) |
| 123 | return nullptr; |
| 124 | |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 125 | if (is<RenderInline>(*continuation)) |
| 126 | return downcast<RenderInline>(continuation); |
jhoneycutt@apple.com | d4c71aa | 2014-04-19 00:49:07 +0000 | [diff] [blame] | 127 | |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 128 | return is<RenderBlock>(*continuation) ? downcast<RenderBlock>(*continuation).inlineElementContinuation() : nullptr; |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 129 | } |
| 130 | |
fmalita@chromium.org | 49d26f2 | 2012-10-01 22:04:56 +0000 | [diff] [blame] | 131 | void RenderInline::updateFromStyle() |
hyatt@apple.com | 0de4d64 | 2009-02-05 22:26:53 +0000 | [diff] [blame] | 132 | { |
fmalita@chromium.org | 49d26f2 | 2012-10-01 22:04:56 +0000 | [diff] [blame] | 133 | RenderBoxModelObject::updateFromStyle(); |
hyatt@apple.com | 0de4d64 | 2009-02-05 22:26:53 +0000 | [diff] [blame] | 134 | |
hyatt@apple.com | 0de4d64 | 2009-02-05 22:26:53 +0000 | [diff] [blame] | 135 | // FIXME: Support transforms and reflections on inline flows someday. |
| 136 | setHasTransform(false); |
| 137 | setHasReflection(false); |
| 138 | } |
| 139 | |
akling@apple.com | 1414155 | 2013-10-14 07:58:09 +0000 | [diff] [blame] | 140 | static RenderElement* inFlowPositionedInlineAncestor(RenderElement* p) |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 141 | { |
| 142 | while (p && p->isRenderInline()) { |
simon.fraser@apple.com | ea93fa0 | 2012-08-24 00:52:53 +0000 | [diff] [blame] | 143 | if (p->isInFlowPositioned()) |
| 144 | return p; |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 145 | p = p->parent(); |
| 146 | } |
simon.fraser@apple.com | ea93fa0 | 2012-08-24 00:52:53 +0000 | [diff] [blame] | 147 | return 0; |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 148 | } |
| 149 | |
hyatt@apple.com | ac92875 | 2014-04-03 19:22:48 +0000 | [diff] [blame] | 150 | static void updateStyleOfAnonymousBlockContinuations(RenderBox* box, const RenderStyle* newStyle, const RenderStyle* oldStyle) |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 151 | { |
hyatt@apple.com | ac92875 | 2014-04-03 19:22:48 +0000 | [diff] [blame] | 152 | for (;box && box->isAnonymousBlock(); box = box->nextSiblingBox()) { |
| 153 | if (box->style().position() == newStyle->position()) |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 154 | continue; |
hyatt@apple.com | ac92875 | 2014-04-03 19:22:48 +0000 | [diff] [blame] | 155 | |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 156 | if (!is<RenderBlock>(*box)) |
hyatt@apple.com | d696549 | 2014-04-03 21:40:49 +0000 | [diff] [blame] | 157 | continue; |
hyatt@apple.com | ac92875 | 2014-04-03 19:22:48 +0000 | [diff] [blame] | 158 | |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 159 | RenderBlock& block = downcast<RenderBlock>(*box); |
| 160 | if (!block.isAnonymousBlockContinuation()) |
hyatt@apple.com | d696549 | 2014-04-03 21:40:49 +0000 | [diff] [blame] | 161 | continue; |
hyatt@apple.com | ac92875 | 2014-04-03 19:22:48 +0000 | [diff] [blame] | 162 | |
simon.fraser@apple.com | ea93fa0 | 2012-08-24 00:52:53 +0000 | [diff] [blame] | 163 | // If we are no longer in-flow positioned but our descendant block(s) still have an in-flow positioned ancestor then |
| 164 | // their containing anonymous block should keep its in-flow positioning. |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 165 | RenderInline* continuation = block.inlineElementContinuation(); |
| 166 | if (oldStyle->hasInFlowPosition() && inFlowPositionedInlineAncestor(continuation)) |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 167 | continue; |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 168 | auto blockStyle = RenderStyle::createAnonymousStyleWithDisplay(&block.style(), BLOCK); |
akling@apple.com | e8eb70e | 2013-10-19 13:58:49 +0000 | [diff] [blame] | 169 | blockStyle.get().setPosition(newStyle->position()); |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 170 | block.setStyle(WTF::move(blockStyle)); |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 171 | } |
| 172 | } |
| 173 | |
weinig@apple.com | 1a57c82 | 2009-02-04 22:27:50 +0000 | [diff] [blame] | 174 | void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) |
weinig | c24ab18 | 2006-10-30 22:41:29 +0000 | [diff] [blame] | 175 | { |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 176 | RenderBoxModelObject::styleDidChange(diff, oldStyle); |
simon.fraser@apple.com | a89b8cd | 2008-10-10 03:15:31 +0000 | [diff] [blame] | 177 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 178 | // Ensure that all of the split inlines pick up the new style. We |
| 179 | // only do this if we're an inline, since we don't want to propagate |
| 180 | // a block's style to the other inlines. |
| 181 | // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before |
| 182 | // and after the block share the same style, but the block doesn't |
| 183 | // need to pass its style on to anyone else. |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 184 | RenderStyle& newStyle = style(); |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 185 | RenderInline* continuation = inlineElementContinuation(); |
dpranke@chromium.org | cecd9c0 | 2012-12-11 18:53:19 +0000 | [diff] [blame] | 186 | for (RenderInline* currCont = continuation; currCont; currCont = currCont->inlineElementContinuation()) { |
| 187 | RenderBoxModelObject* nextCont = currCont->continuation(); |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 188 | currCont->setContinuation(nullptr); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 189 | currCont->setStyle(newStyle); |
dpranke@chromium.org | cecd9c0 | 2012-12-11 18:53:19 +0000 | [diff] [blame] | 190 | currCont->setContinuation(nextCont); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 191 | } |
| 192 | |
simon.fraser@apple.com | ea93fa0 | 2012-08-24 00:52:53 +0000 | [diff] [blame] | 193 | // If an inline's in-flow positioning has changed then any descendant blocks will need to change their in-flow positioning accordingly. |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 194 | // Do this by updating the position of the descendant blocks' containing anonymous blocks - there may be more than one. |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 195 | if (continuation && oldStyle && newStyle.position() != oldStyle->position() |
| 196 | && (newStyle.hasInFlowPosition() || oldStyle->hasInFlowPosition())) { |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 197 | // If any descendant blocks exist then they will be in the next anonymous block and its siblings. |
| 198 | RenderObject* block = containingBlock()->nextSibling(); |
| 199 | ASSERT(block && block->isAnonymousBlock()); |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 200 | updateStyleOfAnonymousBlockContinuations(downcast<RenderBlock>(block), &newStyle, oldStyle); |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 201 | } |
| 202 | |
akling@apple.com | 4ea8c6b | 2013-11-11 06:20:36 +0000 | [diff] [blame] | 203 | if (!alwaysCreateLineBoxes()) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 204 | bool alwaysCreateLineBoxes = hasSelfPaintingLayer() || hasBoxDecorations() || newStyle.hasPadding() || newStyle.hasMargin() || hasOutline(); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 205 | if (oldStyle && alwaysCreateLineBoxes) { |
| 206 | dirtyLineBoxes(false); |
antti@apple.com | ca2a8ff | 2013-10-04 04:04:35 +0000 | [diff] [blame] | 207 | setNeedsLayout(); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 208 | } |
akling@apple.com | 4ea8c6b | 2013-11-11 06:20:36 +0000 | [diff] [blame] | 209 | setRenderInlineAlwaysCreatesLineBoxes(alwaysCreateLineBoxes); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 210 | } |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 211 | } |
| 212 | |
inferno@chromium.org | 88a424d | 2011-08-09 18:18:36 +0000 | [diff] [blame] | 213 | void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout) |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 214 | { |
| 215 | // Once we have been tainted once, just assume it will happen again. This way effects like hover highlighting that change the |
| 216 | // background color will only cause a layout on the first rollover. |
akling@apple.com | 4ea8c6b | 2013-11-11 06:20:36 +0000 | [diff] [blame] | 217 | if (alwaysCreateLineBoxes()) |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 218 | return; |
| 219 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 220 | RenderStyle* parentStyle = &parent()->style(); |
cdumez@apple.com | f802215 | 2014-10-15 00:29:51 +0000 | [diff] [blame] | 221 | RenderInline* parentRenderInline = is<RenderInline>(*parent()) ? downcast<RenderInline>(parent()) : nullptr; |
akling@apple.com | 836b22b | 2013-08-25 21:22:06 +0000 | [diff] [blame] | 222 | bool checkFonts = document().inNoQuirksMode(); |
hyatt@apple.com | fd6f22e | 2013-03-01 21:44:06 +0000 | [diff] [blame] | 223 | RenderFlowThread* flowThread = flowThreadContainingBlock(); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 224 | bool alwaysCreateLineBoxes = (parentRenderInline && parentRenderInline->alwaysCreateLineBoxes()) |
| 225 | || (parentRenderInline && parentStyle->verticalAlign() != BASELINE) |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 226 | || style().verticalAlign() != BASELINE |
| 227 | || style().textEmphasisMark() != TextEmphasisMarkNone |
| 228 | || (checkFonts && (!parentStyle->font().fontMetrics().hasIdenticalAscentDescentAndLineGap(style().font().fontMetrics()) |
| 229 | || parentStyle->lineHeight() != style().lineHeight())) |
abucur@adobe.com | a043772 | 2014-01-10 10:38:18 +0000 | [diff] [blame] | 230 | || (flowThread && flowThread->isRenderNamedFlowThread()); // FIXME: Enable the optimization once we make overflow computation for culled inlines in regions. |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 231 | |
benjamin@webkit.org | 23358d7 | 2013-09-25 21:13:38 +0000 | [diff] [blame] | 232 | if (!alwaysCreateLineBoxes && checkFonts && document().styleSheetCollection().usesFirstLineRules()) { |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 233 | // Have to check the first line style as well. |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 234 | parentStyle = &parent()->firstLineStyle(); |
| 235 | RenderStyle& childStyle = firstLineStyle(); |
| 236 | alwaysCreateLineBoxes = !parentStyle->font().fontMetrics().hasIdenticalAscentDescentAndLineGap(childStyle.font().fontMetrics()) |
| 237 | || childStyle.verticalAlign() != BASELINE |
| 238 | || parentStyle->lineHeight() != childStyle.lineHeight(); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | if (alwaysCreateLineBoxes) { |
inferno@chromium.org | 88a424d | 2011-08-09 18:18:36 +0000 | [diff] [blame] | 242 | if (!fullLayout) |
| 243 | dirtyLineBoxes(false); |
akling@apple.com | 4ea8c6b | 2013-11-11 06:20:36 +0000 | [diff] [blame] | 244 | setAlwaysCreateLineBoxes(); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 245 | } |
| 246 | } |
| 247 | |
commit-queue@webkit.org | f5887ce | 2012-06-09 01:56:42 +0000 | [diff] [blame] | 248 | LayoutRect RenderInline::localCaretRect(InlineBox* inlineBox, int, LayoutUnit* extraWidthToEndOfLine) |
| 249 | { |
| 250 | if (firstChild()) { |
| 251 | // This condition is possible if the RenderInline is at an editing boundary, |
| 252 | // i.e. the VisiblePosition is: |
| 253 | // <RenderInline editingBoundary=true>|<RenderText> </RenderText></RenderInline> |
| 254 | // FIXME: need to figure out how to make this return a valid rect, note that |
| 255 | // there are no line boxes created in the above case. |
| 256 | return LayoutRect(); |
| 257 | } |
| 258 | |
| 259 | ASSERT_UNUSED(inlineBox, !inlineBox); |
| 260 | |
| 261 | if (extraWidthToEndOfLine) |
| 262 | *extraWidthToEndOfLine = 0; |
| 263 | |
bjonesbe@adobe.com | 562a50d | 2014-02-20 20:01:19 +0000 | [diff] [blame] | 264 | LayoutRect caretRect = localCaretRectForEmptyElement(horizontalBorderAndPaddingExtent(), 0); |
commit-queue@webkit.org | f5887ce | 2012-06-09 01:56:42 +0000 | [diff] [blame] | 265 | |
| 266 | if (InlineBox* firstBox = firstLineBox()) |
zalan@apple.com | 83de8f8 | 2014-08-26 02:11:44 +0000 | [diff] [blame] | 267 | caretRect.moveBy(LayoutPoint(firstBox->topLeft())); |
commit-queue@webkit.org | f5887ce | 2012-06-09 01:56:42 +0000 | [diff] [blame] | 268 | |
| 269 | return caretRect; |
| 270 | } |
| 271 | |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 272 | void RenderInline::addChild(RenderObject* newChild, RenderObject* beforeChild) |
| 273 | { |
| 274 | if (continuation()) |
| 275 | return addChildToContinuation(newChild, beforeChild); |
| 276 | return addChildIgnoringContinuation(newChild, beforeChild); |
| 277 | } |
| 278 | |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 279 | static RenderBoxModelObject* nextContinuation(RenderObject* renderer) |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 280 | { |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 281 | if (is<RenderInline>(*renderer) && !renderer->isReplaced()) |
| 282 | return downcast<RenderInline>(*renderer).continuation(); |
| 283 | return downcast<RenderBlock>(*renderer).inlineElementContinuation(); |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 284 | } |
| 285 | |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 286 | RenderBoxModelObject* RenderInline::continuationBefore(RenderObject* beforeChild) |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 287 | { |
| 288 | if (beforeChild && beforeChild->parent() == this) |
| 289 | return this; |
| 290 | |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 291 | RenderBoxModelObject* curr = nextContinuation(this); |
| 292 | RenderBoxModelObject* nextToLast = this; |
| 293 | RenderBoxModelObject* last = this; |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 294 | while (curr) { |
| 295 | if (beforeChild && beforeChild->parent() == curr) { |
| 296 | if (curr->firstChild() == beforeChild) |
| 297 | return last; |
| 298 | return curr; |
| 299 | } |
| 300 | |
| 301 | nextToLast = last; |
| 302 | last = curr; |
| 303 | curr = nextContinuation(curr); |
| 304 | } |
| 305 | |
| 306 | if (!beforeChild && !last->firstChild()) |
| 307 | return nextToLast; |
| 308 | return last; |
| 309 | } |
| 310 | |
| 311 | void RenderInline::addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 312 | { |
| 313 | // Make sure we don't append things after :after-generated content if we have it. |
darin | f465695 | 2007-01-04 00:27:25 +0000 | [diff] [blame] | 314 | if (!beforeChild && isAfterContent(lastChild())) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 315 | beforeChild = lastChild(); |
| 316 | |
commit-queue@webkit.org | 5ef063d | 2012-07-26 18:50:48 +0000 | [diff] [blame] | 317 | if (!newChild->isInline() && !newChild->isFloatingOrOutOfFlowPositioned()) { |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 318 | // We are placing a block inside an inline. We have to perform a split of this |
| 319 | // inline into continuations. This involves creating an anonymous block box to hold |
| 320 | // |newChild|. We then make that block box a continuation of this inline. We take all of |
| 321 | // the children after |beforeChild| and put them in a clone of this object. |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 322 | auto newStyle = RenderStyle::createAnonymousStyleWithDisplay(&style(), BLOCK); |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 323 | |
simon.fraser@apple.com | ea93fa0 | 2012-08-24 00:52:53 +0000 | [diff] [blame] | 324 | // If inside an inline affected by in-flow positioning the block needs to be affected by it too. |
robert@webkit.org | 6722a65 | 2012-02-19 15:24:50 +0000 | [diff] [blame] | 325 | // Giving the block a layer like this allows it to collect the x/y offsets from inline parents later. |
akling@apple.com | 1414155 | 2013-10-14 07:58:09 +0000 | [diff] [blame] | 326 | if (auto positionedAncestor = inFlowPositionedInlineAncestor(this)) |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 327 | newStyle.get().setPosition(positionedAncestor->style().position()); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 328 | |
dbates@webkit.org | 0cefe4f | 2014-07-03 22:13:54 +0000 | [diff] [blame] | 329 | RenderBlock* newBox = new RenderBlockFlow(document(), WTF::move(newStyle)); |
akling@apple.com | 8f40c5b | 2013-10-27 22:54:07 +0000 | [diff] [blame] | 330 | newBox->initializeStyle(); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 331 | RenderBoxModelObject* oldContinuation = continuation(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 332 | setContinuation(newBox); |
| 333 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 334 | splitFlow(beforeChild, newBox, newChild, oldContinuation); |
| 335 | return; |
| 336 | } |
| 337 | |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 338 | RenderBoxModelObject::addChild(newChild, beforeChild); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 339 | |
darin | 7e7c8e4 | 2007-04-25 01:14:03 +0000 | [diff] [blame] | 340 | newChild->setNeedsLayoutAndPrefWidthsRecalc(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 341 | } |
| 342 | |
akling@apple.com | 9444187 | 2014-01-06 09:47:01 +0000 | [diff] [blame] | 343 | RenderPtr<RenderInline> RenderInline::clone() const |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 344 | { |
akling@apple.com | 9444187 | 2014-01-06 09:47:01 +0000 | [diff] [blame] | 345 | RenderPtr<RenderInline> cloneInline = createRenderer<RenderInline>(*element(), style()); |
akling@apple.com | 8f40c5b | 2013-10-27 22:54:07 +0000 | [diff] [blame] | 346 | cloneInline->initializeStyle(); |
hyatt@apple.com | 6276bf8 | 2013-03-01 16:58:25 +0000 | [diff] [blame] | 347 | cloneInline->setFlowThreadState(flowThreadState()); |
mihnea@adobe.com | 54cc544 | 2012-08-12 15:57:25 +0000 | [diff] [blame] | 348 | return cloneInline; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | void RenderInline::splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, |
| 352 | RenderBlock* middleBlock, |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 353 | RenderObject* beforeChild, RenderBoxModelObject* oldCont) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 354 | { |
| 355 | // Create a clone of this inline. |
akling@apple.com | 9444187 | 2014-01-06 09:47:01 +0000 | [diff] [blame] | 356 | RenderPtr<RenderInline> cloneInline = clone(); |
mihnea@adobe.com | 54cc544 | 2012-08-12 15:57:25 +0000 | [diff] [blame] | 357 | cloneInline->setContinuation(oldCont); |
weinig | c24ab18 | 2006-10-30 22:41:29 +0000 | [diff] [blame] | 358 | |
ossy@webkit.org | 8d01a73 | 2013-05-22 20:30:41 +0000 | [diff] [blame] | 359 | #if ENABLE(FULLSCREEN_API) |
rniwa@webkit.org | 39c8c1b | 2013-05-22 19:21:52 +0000 | [diff] [blame] | 360 | // If we're splitting the inline containing the fullscreened element, |
| 361 | // |beforeChild| may be the renderer for the fullscreened element. However, |
| 362 | // that renderer is wrapped in a RenderFullScreen, so |this| is not its |
| 363 | // parent. Since the splitting logic expects |this| to be the parent, set |
| 364 | // |beforeChild| to be the RenderFullScreen. |
akling@apple.com | 836b22b | 2013-08-25 21:22:06 +0000 | [diff] [blame] | 365 | const Element* fullScreenElement = document().webkitCurrentFullScreenElement(); |
rniwa@webkit.org | 39c8c1b | 2013-05-22 19:21:52 +0000 | [diff] [blame] | 366 | if (fullScreenElement && beforeChild && beforeChild->node() == fullScreenElement) |
akling@apple.com | 836b22b | 2013-08-25 21:22:06 +0000 | [diff] [blame] | 367 | beforeChild = document().fullScreenRenderer(); |
ossy@webkit.org | 8d01a73 | 2013-05-22 20:30:41 +0000 | [diff] [blame] | 368 | #endif |
rniwa@webkit.org | 39c8c1b | 2013-05-22 19:21:52 +0000 | [diff] [blame] | 369 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 370 | // Now take all of the children from beforeChild to the end and remove |
| 371 | // them from |this| and place them in the clone. |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 372 | RenderObject* renderer = beforeChild; |
| 373 | while (renderer) { |
| 374 | RenderObject* tmp = renderer; |
| 375 | renderer = tmp->nextSibling(); |
akling@apple.com | 49d4d3b | 2013-10-16 12:40:09 +0000 | [diff] [blame] | 376 | removeChildInternal(*tmp, NotifyChildren); |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 377 | cloneInline->addChildIgnoringContinuation(tmp); |
darin | 7e7c8e4 | 2007-04-25 01:14:03 +0000 | [diff] [blame] | 378 | tmp->setNeedsLayoutAndPrefWidthsRecalc(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | // Hook |clone| up as the continuation of the middle block. |
akling@apple.com | 9444187 | 2014-01-06 09:47:01 +0000 | [diff] [blame] | 382 | middleBlock->setContinuation(cloneInline.get()); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 383 | |
| 384 | // We have been reparented and are now under the fromBlock. We need |
| 385 | // to walk up our inline parent chain until we hit the containing block. |
| 386 | // Once we hit the containing block we're done. |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 387 | RenderBoxModelObject* current = downcast<RenderBoxModelObject>(parent()); |
| 388 | RenderBoxModelObject* currentChild = this; |
hyatt | 6adcd9d | 2007-04-24 01:27:57 +0000 | [diff] [blame] | 389 | |
| 390 | // FIXME: Because splitting is O(n^2) as tags nest pathologically, we cap the depth at which we're willing to clone. |
| 391 | // There will eventually be a better approach to this problem that will let us nest to a much |
| 392 | // greater depth (see bugzilla bug 13430) but for now we have a limit. This *will* result in |
| 393 | // incorrect rendering, but the alternative is to hang forever. |
| 394 | unsigned splitDepth = 1; |
| 395 | const unsigned cMaxSplitDepth = 200; |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 396 | while (current && current != fromBlock) { |
hyatt | 6adcd9d | 2007-04-24 01:27:57 +0000 | [diff] [blame] | 397 | if (splitDepth < cMaxSplitDepth) { |
| 398 | // Create a new clone. |
dbates@webkit.org | 0cefe4f | 2014-07-03 22:13:54 +0000 | [diff] [blame] | 399 | RenderPtr<RenderInline> cloneChild = WTF::move(cloneInline); |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 400 | cloneInline = downcast<RenderInline>(*current).clone(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 401 | |
hyatt | 6adcd9d | 2007-04-24 01:27:57 +0000 | [diff] [blame] | 402 | // Insert our child clone as the first child. |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 403 | cloneInline->addChildIgnoringContinuation(cloneChild.leakPtr()); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 404 | |
hyatt | 6adcd9d | 2007-04-24 01:27:57 +0000 | [diff] [blame] | 405 | // Hook the clone up as a continuation of |curr|. |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 406 | RenderInline& currentInline = downcast<RenderInline>(*current); |
| 407 | oldCont = currentInline.continuation(); |
| 408 | currentInline.setContinuation(cloneInline.get()); |
mihnea@adobe.com | 54cc544 | 2012-08-12 15:57:25 +0000 | [diff] [blame] | 409 | cloneInline->setContinuation(oldCont); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 410 | |
hyatt | 6adcd9d | 2007-04-24 01:27:57 +0000 | [diff] [blame] | 411 | // Now we need to take all of the children starting from the first child |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 412 | // *after* currentChild and append them all to the clone. |
| 413 | renderer = currentChild->nextSibling(); |
| 414 | while (renderer) { |
| 415 | RenderObject* tmp = renderer; |
| 416 | renderer = tmp->nextSibling(); |
| 417 | currentInline.removeChildInternal(*tmp, NotifyChildren); |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 418 | cloneInline->addChildIgnoringContinuation(tmp); |
darin | 7e7c8e4 | 2007-04-25 01:14:03 +0000 | [diff] [blame] | 419 | tmp->setNeedsLayoutAndPrefWidthsRecalc(); |
hyatt | 6adcd9d | 2007-04-24 01:27:57 +0000 | [diff] [blame] | 420 | } |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 421 | } |
hyatt | 6adcd9d | 2007-04-24 01:27:57 +0000 | [diff] [blame] | 422 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 423 | // Keep walking up the chain. |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 424 | currentChild = current; |
| 425 | current = downcast<RenderBoxModelObject>(current->parent()); |
| 426 | ++splitDepth; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | // Now we are at the block level. We need to put the clone into the toBlock. |
akling@apple.com | 9444187 | 2014-01-06 09:47:01 +0000 | [diff] [blame] | 430 | toBlock->insertChildInternal(cloneInline.leakPtr(), nullptr, NotifyChildren); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 431 | |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 432 | // Now take all the children after currentChild and remove them from the fromBlock |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 433 | // and put them in the toBlock. |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 434 | renderer = currentChild->nextSibling(); |
| 435 | while (renderer) { |
| 436 | RenderObject* tmp = renderer; |
| 437 | renderer = tmp->nextSibling(); |
akling@apple.com | 49d4d3b | 2013-10-16 12:40:09 +0000 | [diff] [blame] | 438 | fromBlock->removeChildInternal(*tmp, NotifyChildren); |
antti@apple.com | da4d316 | 2013-09-23 17:43:04 +0000 | [diff] [blame] | 439 | toBlock->insertChildInternal(tmp, nullptr, NotifyChildren); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 440 | } |
| 441 | } |
| 442 | |
| 443 | void RenderInline::splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox, |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 444 | RenderObject* newChild, RenderBoxModelObject* oldCont) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 445 | { |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 446 | RenderBlock* pre = nullptr; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 447 | RenderBlock* block = containingBlock(); |
hyatt | d55a81b | 2007-08-06 21:50:48 +0000 | [diff] [blame] | 448 | |
| 449 | // Delete our line boxes before we do the inline split into continuations. |
antti@apple.com | a2c7f24 | 2013-10-22 22:37:25 +0000 | [diff] [blame] | 450 | block->deleteLines(); |
hyatt | d55a81b | 2007-08-06 21:50:48 +0000 | [diff] [blame] | 451 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 452 | bool madeNewBeforeBlock = false; |
darin | fcd2c93 | 2006-06-28 15:42:13 +0000 | [diff] [blame] | 453 | if (block->isAnonymousBlock() && (!block->parent() || !block->parent()->createsAnonymousWrapper())) { |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 454 | // We can reuse this block and make it the preBlock of the next continuation. |
| 455 | pre = block; |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 456 | pre->removePositionedObjects(nullptr); |
bjonesbe@adobe.com | 2419975 | 2013-10-08 23:20:42 +0000 | [diff] [blame] | 457 | // FIXME-BLOCKFLOW: The enclosing method should likely be switched over |
| 458 | // to only work on RenderBlockFlow, in which case this conversion can be |
| 459 | // removed. |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 460 | if (is<RenderBlockFlow>(*pre)) |
| 461 | downcast<RenderBlockFlow>(*pre).removeFloatingObjects(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 462 | block = block->containingBlock(); |
darin | 45d6dcf | 2006-04-17 06:15:47 +0000 | [diff] [blame] | 463 | } else { |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 464 | // No anonymous block available for use. Make one. |
| 465 | pre = block->createAnonymousBlock(); |
| 466 | madeNewBeforeBlock = true; |
| 467 | } |
| 468 | |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 469 | RenderBlock& post = downcast<RenderBlock>(*pre->createAnonymousBoxWithSameTypeAs(block)); |
weinig | c24ab18 | 2006-10-30 22:41:29 +0000 | [diff] [blame] | 470 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 471 | RenderObject* boxFirst = madeNewBeforeBlock ? block->firstChild() : pre->nextSibling(); |
| 472 | if (madeNewBeforeBlock) |
antti@apple.com | da4d316 | 2013-09-23 17:43:04 +0000 | [diff] [blame] | 473 | block->insertChildInternal(pre, boxFirst, NotifyChildren); |
| 474 | block->insertChildInternal(newBlockBox, boxFirst, NotifyChildren); |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 475 | block->insertChildInternal(&post, boxFirst, NotifyChildren); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 476 | block->setChildrenInline(false); |
hyatt | d55a81b | 2007-08-06 21:50:48 +0000 | [diff] [blame] | 477 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 478 | if (madeNewBeforeBlock) { |
| 479 | RenderObject* o = boxFirst; |
weinig | c24ab18 | 2006-10-30 22:41:29 +0000 | [diff] [blame] | 480 | while (o) { |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 481 | RenderObject* no = o; |
| 482 | o = no->nextSibling(); |
akling@apple.com | 49d4d3b | 2013-10-16 12:40:09 +0000 | [diff] [blame] | 483 | block->removeChildInternal(*no, NotifyChildren); |
antti@apple.com | da4d316 | 2013-09-23 17:43:04 +0000 | [diff] [blame] | 484 | pre->insertChildInternal(no, nullptr, NotifyChildren); |
darin | 7e7c8e4 | 2007-04-25 01:14:03 +0000 | [diff] [blame] | 485 | no->setNeedsLayoutAndPrefWidthsRecalc(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 486 | } |
| 487 | } |
| 488 | |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 489 | splitInlines(pre, &post, newBlockBox, beforeChild, oldCont); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 490 | |
| 491 | // We already know the newBlockBox isn't going to contain inline kids, so avoid wasting |
| 492 | // time in makeChildrenNonInline by just setting this explicitly up front. |
| 493 | newBlockBox->setChildrenInline(false); |
| 494 | |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 495 | // We delayed adding the newChild until now so that the |newBlockBox| would be fully |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 496 | // connected, thus allowing newChild access to a renderArena should it need |
| 497 | // to wrap itself in additional boxes (e.g., table construction). |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 498 | newBlockBox->addChild(newChild); |
weinig | c24ab18 | 2006-10-30 22:41:29 +0000 | [diff] [blame] | 499 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 500 | // Always just do a full layout in order to ensure that line boxes (especially wrappers for images) |
| 501 | // get deleted properly. Because objects moves from the pre block into the post block, we want to |
| 502 | // make new line boxes instead of leaving the old line boxes around. |
darin | 7e7c8e4 | 2007-04-25 01:14:03 +0000 | [diff] [blame] | 503 | pre->setNeedsLayoutAndPrefWidthsRecalc(); |
| 504 | block->setNeedsLayoutAndPrefWidthsRecalc(); |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 505 | post.setNeedsLayoutAndPrefWidthsRecalc(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 506 | } |
| 507 | |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 508 | void RenderInline::addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild) |
| 509 | { |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 510 | RenderBoxModelObject* flow = continuationBefore(beforeChild); |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 511 | ASSERT(!beforeChild || is<RenderBlock>(*beforeChild->parent()) || is<RenderInline>(*beforeChild->parent())); |
| 512 | RenderBoxModelObject* beforeChildParent = nullptr; |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 513 | if (beforeChild) |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 514 | beforeChildParent = downcast<RenderBoxModelObject>(beforeChild->parent()); |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 515 | else { |
cdumez@apple.com | dd2b64a | 2014-10-10 15:49:24 +0000 | [diff] [blame] | 516 | if (RenderBoxModelObject* continuation = nextContinuation(flow)) |
| 517 | beforeChildParent = continuation; |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 518 | else |
| 519 | beforeChildParent = flow; |
| 520 | } |
| 521 | |
simon.fraser@apple.com | 2f07185 | 2012-06-25 00:11:30 +0000 | [diff] [blame] | 522 | if (newChild->isFloatingOrOutOfFlowPositioned()) |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 523 | return beforeChildParent->addChildIgnoringContinuation(newChild, beforeChild); |
| 524 | |
| 525 | // A continuation always consists of two potential candidates: an inline or an anonymous |
| 526 | // block box holding block children. |
| 527 | bool childInline = newChild->isInline(); |
| 528 | bool bcpInline = beforeChildParent->isInline(); |
| 529 | bool flowInline = flow->isInline(); |
| 530 | |
| 531 | if (flow == beforeChildParent) |
| 532 | return flow->addChildIgnoringContinuation(newChild, beforeChild); |
| 533 | else { |
| 534 | // The goal here is to match up if we can, so that we can coalesce and create the |
| 535 | // minimal # of continuations needed for the inline. |
| 536 | if (childInline == bcpInline) |
| 537 | return beforeChildParent->addChildIgnoringContinuation(newChild, beforeChild); |
| 538 | else if (flowInline == childInline) |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 539 | return flow->addChildIgnoringContinuation(newChild); // Just treat like an append. |
hyatt@apple.com | c05db8d2 | 2009-01-29 21:39:21 +0000 | [diff] [blame] | 540 | else |
| 541 | return beforeChildParent->addChildIgnoringContinuation(newChild, beforeChild); |
| 542 | } |
| 543 | } |
| 544 | |
leviw@chromium.org | b375750 | 2011-06-29 21:33:11 +0000 | [diff] [blame] | 545 | void RenderInline::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 546 | { |
leviw@chromium.org | 61ca137 | 2011-06-07 18:56:41 +0000 | [diff] [blame] | 547 | m_lineBoxes.paint(this, paintInfo, paintOffset); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 548 | } |
| 549 | |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 550 | template<typename GeneratorContext> |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 551 | void RenderInline::generateLineBoxRects(GeneratorContext& context) const |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 552 | { |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 553 | if (!alwaysCreateLineBoxes()) |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 554 | generateCulledLineBoxRects(context, this); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 555 | else if (InlineFlowBox* curr = firstLineBox()) { |
weinig@apple.com | bcc5793 | 2009-03-18 20:02:18 +0000 | [diff] [blame] | 556 | for (; curr; curr = curr->nextLineBox()) |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 557 | context.addRect(FloatRect(curr->topLeft(), curr->size())); |
weinig@apple.com | bcc5793 | 2009-03-18 20:02:18 +0000 | [diff] [blame] | 558 | } else |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 559 | context.addRect(FloatRect()); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | template<typename GeneratorContext> |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 563 | void RenderInline::generateCulledLineBoxRects(GeneratorContext& context, const RenderInline* container) const |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 564 | { |
| 565 | if (!culledInlineFirstLineBox()) { |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 566 | context.addRect(FloatRect()); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 567 | return; |
| 568 | } |
| 569 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 570 | bool isHorizontal = style().isHorizontalWritingMode(); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 571 | |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 572 | for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { |
| 573 | if (current->isFloatingOrOutOfFlowPositioned()) |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 574 | continue; |
| 575 | |
| 576 | // We want to get the margin box in the inline direction, and then use our font ascent/descent in the block |
| 577 | // direction (aligned to the root box's baseline). |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 578 | if (is<RenderBox>(*current)) { |
| 579 | RenderBox& renderBox = downcast<RenderBox>(*current); |
| 580 | if (renderBox.inlineBoxWrapper()) { |
| 581 | const RootInlineBox& rootBox = renderBox.inlineBoxWrapper()->root(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 582 | const RenderStyle& containerStyle = rootBox.isFirstLine() ? container->firstLineStyle() : container->style(); |
antti@apple.com | b0608f6 | 2013-09-28 18:30:16 +0000 | [diff] [blame] | 583 | int logicalTop = rootBox.logicalTop() + (rootBox.lineStyle().font().fontMetrics().ascent() - containerStyle.font().fontMetrics().ascent()); |
| 584 | int logicalHeight = containerStyle.font().fontMetrics().height(); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 585 | if (isHorizontal) |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 586 | context.addRect(FloatRect(renderBox.inlineBoxWrapper()->x() - renderBox.marginLeft(), logicalTop, renderBox.width() + renderBox.horizontalMarginExtent(), logicalHeight)); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 587 | else |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 588 | context.addRect(FloatRect(logicalTop, renderBox.inlineBoxWrapper()->y() - renderBox.marginTop(), logicalHeight, renderBox.height() + renderBox.verticalMarginExtent())); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 589 | } |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 590 | } else if (is<RenderInline>(*current)) { |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 591 | // If the child doesn't need line boxes either, then we can recur. |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 592 | RenderInline& renderInline = downcast<RenderInline>(*current); |
| 593 | if (!renderInline.alwaysCreateLineBoxes()) |
| 594 | renderInline.generateCulledLineBoxRects(context, container); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 595 | else { |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 596 | for (InlineFlowBox* childLine = renderInline.firstLineBox(); childLine; childLine = childLine->nextLineBox()) { |
akling@apple.com | dbf7030 | 2013-09-09 02:11:06 +0000 | [diff] [blame] | 597 | const RootInlineBox& rootBox = childLine->root(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 598 | const RenderStyle& containerStyle = rootBox.isFirstLine() ? container->firstLineStyle() : container->style(); |
antti@apple.com | b0608f6 | 2013-09-28 18:30:16 +0000 | [diff] [blame] | 599 | int logicalTop = rootBox.logicalTop() + (rootBox.lineStyle().font().fontMetrics().ascent() - containerStyle.font().fontMetrics().ascent()); |
| 600 | int logicalHeight = containerStyle.fontMetrics().height(); |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 601 | if (isHorizontal) { |
| 602 | context.addRect(FloatRect(childLine->x() - childLine->marginLogicalLeft(), |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 603 | logicalTop, |
| 604 | childLine->logicalWidth() + childLine->marginLogicalLeft() + childLine->marginLogicalRight(), |
| 605 | logicalHeight)); |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 606 | } else { |
| 607 | context.addRect(FloatRect(logicalTop, |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 608 | childLine->y() - childLine->marginLogicalLeft(), |
| 609 | logicalHeight, |
| 610 | childLine->logicalWidth() + childLine->marginLogicalLeft() + childLine->marginLogicalRight())); |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 611 | } |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 612 | } |
| 613 | } |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 614 | } else if (is<RenderText>(*current)) { |
| 615 | RenderText& currText = downcast<RenderText>(*current); |
| 616 | for (InlineTextBox* childText = currText.firstTextBox(); childText; childText = childText->nextTextBox()) { |
akling@apple.com | dbf7030 | 2013-09-09 02:11:06 +0000 | [diff] [blame] | 617 | const RootInlineBox& rootBox = childText->root(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 618 | const RenderStyle& containerStyle = rootBox.isFirstLine() ? container->firstLineStyle() : container->style(); |
antti@apple.com | b0608f6 | 2013-09-28 18:30:16 +0000 | [diff] [blame] | 619 | int logicalTop = rootBox.logicalTop() + (rootBox.lineStyle().font().fontMetrics().ascent() - containerStyle.font().fontMetrics().ascent()); |
| 620 | int logicalHeight = containerStyle.font().fontMetrics().height(); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 621 | if (isHorizontal) |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 622 | context.addRect(FloatRect(childText->x(), logicalTop, childText->logicalWidth(), logicalHeight)); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 623 | else |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 624 | context.addRect(FloatRect(logicalTop, childText->y(), logicalHeight, childText->logicalWidth())); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 625 | } |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 626 | } else if (is<RenderLineBreak>(*current)) { |
| 627 | if (InlineBox* inlineBox = downcast<RenderLineBreak>(*current).inlineBoxWrapper()) { |
antti@apple.com | 9d8157e | 2013-09-17 15:13:37 +0000 | [diff] [blame] | 628 | // FIXME: This could use a helper to share these with text path. |
| 629 | const RootInlineBox& rootBox = inlineBox->root(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 630 | const RenderStyle& containerStyle = rootBox.isFirstLine() ? container->firstLineStyle() : container->style(); |
antti@apple.com | b0608f6 | 2013-09-28 18:30:16 +0000 | [diff] [blame] | 631 | int logicalTop = rootBox.logicalTop() + (rootBox.lineStyle().font().fontMetrics().ascent() - containerStyle.font().fontMetrics().ascent()); |
| 632 | int logicalHeight = containerStyle.fontMetrics().height(); |
antti@apple.com | 9d8157e | 2013-09-17 15:13:37 +0000 | [diff] [blame] | 633 | if (isHorizontal) |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 634 | context.addRect(FloatRect(inlineBox->x(), logicalTop, inlineBox->logicalWidth(), logicalHeight)); |
antti@apple.com | 9d8157e | 2013-09-17 15:13:37 +0000 | [diff] [blame] | 635 | else |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 636 | context.addRect(FloatRect(logicalTop, inlineBox->y(), logicalHeight, inlineBox->logicalWidth())); |
antti@apple.com | 9d8157e | 2013-09-17 15:13:37 +0000 | [diff] [blame] | 637 | } |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 638 | } |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | namespace { |
| 643 | |
| 644 | class AbsoluteRectsGeneratorContext { |
| 645 | public: |
| 646 | AbsoluteRectsGeneratorContext(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) |
| 647 | : m_rects(rects) |
| 648 | , m_accumulatedOffset(accumulatedOffset) { } |
| 649 | |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 650 | void addRect(const FloatRect& rect) |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 651 | { |
| 652 | IntRect intRect = enclosingIntRect(rect); |
| 653 | intRect.move(m_accumulatedOffset.x(), m_accumulatedOffset.y()); |
| 654 | m_rects.append(intRect); |
| 655 | } |
| 656 | private: |
| 657 | Vector<IntRect>& m_rects; |
| 658 | const LayoutPoint& m_accumulatedOffset; |
| 659 | }; |
| 660 | |
| 661 | } // unnamed namespace |
| 662 | |
| 663 | void RenderInline::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const |
| 664 | { |
commit-queue@webkit.org | 39f4e3f | 2012-07-17 03:26:00 +0000 | [diff] [blame] | 665 | AbsoluteRectsGeneratorContext context(rects, accumulatedOffset); |
| 666 | generateLineBoxRects(context); |
weinig | c24ab18 | 2006-10-30 22:41:29 +0000 | [diff] [blame] | 667 | |
akling@apple.com | 194c6fc | 2013-09-24 16:20:20 +0000 | [diff] [blame] | 668 | if (RenderBoxModelObject* continuation = this->continuation()) { |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 669 | if (is<RenderBox>(*continuation)) { |
| 670 | auto& box = downcast<RenderBox>(*continuation); |
| 671 | continuation->absoluteRects(rects, toLayoutPoint(accumulatedOffset - containingBlock()->location() + box.locationOffset())); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 672 | } else |
akling@apple.com | 194c6fc | 2013-09-24 16:20:20 +0000 | [diff] [blame] | 673 | continuation->absoluteRects(rects, toLayoutPoint(accumulatedOffset - containingBlock()->location())); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 674 | } |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 675 | } |
| 676 | |
enrica@apple.com | 2e8c28f | 2011-07-30 23:51:31 +0000 | [diff] [blame] | 677 | |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 678 | namespace { |
| 679 | |
| 680 | class AbsoluteQuadsGeneratorContext { |
| 681 | public: |
dbates@webkit.org | 0303a64 | 2012-07-17 07:08:17 +0000 | [diff] [blame] | 682 | AbsoluteQuadsGeneratorContext(const RenderInline* renderer, Vector<FloatQuad>& quads) |
ddkilzer@apple.com | 939b220 | 2012-07-10 04:34:13 +0000 | [diff] [blame] | 683 | : m_quads(quads) |
ddkilzer@apple.com | 939b220 | 2012-07-10 04:34:13 +0000 | [diff] [blame] | 684 | , m_geometryMap() |
| 685 | { |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 686 | m_geometryMap.pushMappingsToAncestor(renderer, nullptr); |
ddkilzer@apple.com | 939b220 | 2012-07-10 04:34:13 +0000 | [diff] [blame] | 687 | } |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 688 | |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 689 | void addRect(const FloatRect& rect) |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 690 | { |
ddkilzer@apple.com | 939b220 | 2012-07-10 04:34:13 +0000 | [diff] [blame] | 691 | m_quads.append(m_geometryMap.absoluteRect(rect)); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 692 | } |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 693 | private: |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 694 | Vector<FloatQuad>& m_quads; |
ddkilzer@apple.com | 939b220 | 2012-07-10 04:34:13 +0000 | [diff] [blame] | 695 | RenderGeometryMap m_geometryMap; |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 696 | }; |
| 697 | |
| 698 | } // unnamed namespace |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 699 | |
fsamuel@chromium.org | bc05e3b | 2011-10-06 21:36:30 +0000 | [diff] [blame] | 700 | void RenderInline::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const |
simon.fraser@apple.com | aacf70e | 2008-11-12 23:43:52 +0000 | [diff] [blame] | 701 | { |
dbates@webkit.org | 0303a64 | 2012-07-17 07:08:17 +0000 | [diff] [blame] | 702 | AbsoluteQuadsGeneratorContext context(this, quads); |
commit-queue@webkit.org | 39f4e3f | 2012-07-17 03:26:00 +0000 | [diff] [blame] | 703 | generateLineBoxRects(context); |
weinig@apple.com | bcc5793 | 2009-03-18 20:02:18 +0000 | [diff] [blame] | 704 | |
akling@apple.com | 194c6fc | 2013-09-24 16:20:20 +0000 | [diff] [blame] | 705 | if (RenderBoxModelObject* continuation = this->continuation()) |
| 706 | continuation->absoluteQuads(quads, wasFixed); |
simon.fraser@apple.com | aacf70e | 2008-11-12 23:43:52 +0000 | [diff] [blame] | 707 | } |
| 708 | |
dbates@webkit.org | 395fca7 | 2013-12-06 19:59:38 +0000 | [diff] [blame] | 709 | #if PLATFORM(IOS) |
| 710 | void RenderInline::absoluteQuadsForSelection(Vector<FloatQuad>& quads) const |
| 711 | { |
| 712 | AbsoluteQuadsGeneratorContext context(this, quads); |
| 713 | generateLineBoxRects(context); |
| 714 | } |
| 715 | #endif |
| 716 | |
eae@chromium.org | 3097a25 | 2011-06-28 23:56:01 +0000 | [diff] [blame] | 717 | LayoutUnit RenderInline::offsetLeft() const |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 718 | { |
commit-queue@webkit.org | 3a27f9d | 2012-05-08 19:11:14 +0000 | [diff] [blame] | 719 | LayoutPoint topLeft; |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 720 | if (InlineBox* firstBox = firstLineBoxIncludingCulling()) |
commit-queue@webkit.org | 3a27f9d | 2012-05-08 19:11:14 +0000 | [diff] [blame] | 721 | topLeft = flooredLayoutPoint(firstBox->topLeft()); |
commit-queue@webkit.org | 24fb749 | 2012-05-30 20:30:51 +0000 | [diff] [blame] | 722 | return adjustedPositionRelativeToOffsetParent(topLeft).x(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 723 | } |
| 724 | |
eae@chromium.org | 3097a25 | 2011-06-28 23:56:01 +0000 | [diff] [blame] | 725 | LayoutUnit RenderInline::offsetTop() const |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 726 | { |
commit-queue@webkit.org | 3a27f9d | 2012-05-08 19:11:14 +0000 | [diff] [blame] | 727 | LayoutPoint topLeft; |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 728 | if (InlineBox* firstBox = firstLineBoxIncludingCulling()) |
commit-queue@webkit.org | 3a27f9d | 2012-05-08 19:11:14 +0000 | [diff] [blame] | 729 | topLeft = flooredLayoutPoint(firstBox->topLeft()); |
commit-queue@webkit.org | 24fb749 | 2012-05-30 20:30:51 +0000 | [diff] [blame] | 730 | return adjustedPositionRelativeToOffsetParent(topLeft).y(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 731 | } |
| 732 | |
eae@chromium.org | 0518156 | 2011-06-29 21:41:41 +0000 | [diff] [blame] | 733 | static LayoutUnit computeMargin(const RenderInline* renderer, const Length& margin) |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 734 | { |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 735 | if (margin.isAuto()) |
| 736 | return 0; |
| 737 | if (margin.isFixed()) |
| 738 | return margin.value(); |
| 739 | if (margin.isPercent()) |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 740 | return minimumValueForLength(margin, std::max<LayoutUnit>(0, renderer->containingBlock()->availableLogicalWidth())); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 741 | return 0; |
| 742 | } |
| 743 | |
eae@chromium.org | 0518156 | 2011-06-29 21:41:41 +0000 | [diff] [blame] | 744 | LayoutUnit RenderInline::marginLeft() const |
hyatt@apple.com | d2c45ea | 2010-09-21 17:49:19 +0000 | [diff] [blame] | 745 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 746 | return computeMargin(this, style().marginLeft()); |
hyatt@apple.com | d2c45ea | 2010-09-21 17:49:19 +0000 | [diff] [blame] | 747 | } |
| 748 | |
eae@chromium.org | 0518156 | 2011-06-29 21:41:41 +0000 | [diff] [blame] | 749 | LayoutUnit RenderInline::marginRight() const |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 750 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 751 | return computeMargin(this, style().marginRight()); |
hyatt@apple.com | d2c45ea | 2010-09-21 17:49:19 +0000 | [diff] [blame] | 752 | } |
| 753 | |
eae@chromium.org | 0518156 | 2011-06-29 21:41:41 +0000 | [diff] [blame] | 754 | LayoutUnit RenderInline::marginTop() const |
hyatt@apple.com | d2c45ea | 2010-09-21 17:49:19 +0000 | [diff] [blame] | 755 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 756 | return computeMargin(this, style().marginTop()); |
hyatt@apple.com | d2c45ea | 2010-09-21 17:49:19 +0000 | [diff] [blame] | 757 | } |
| 758 | |
eae@chromium.org | 0518156 | 2011-06-29 21:41:41 +0000 | [diff] [blame] | 759 | LayoutUnit RenderInline::marginBottom() const |
hyatt@apple.com | d2c45ea | 2010-09-21 17:49:19 +0000 | [diff] [blame] | 760 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 761 | return computeMargin(this, style().marginBottom()); |
hyatt@apple.com | d2c45ea | 2010-09-21 17:49:19 +0000 | [diff] [blame] | 762 | } |
| 763 | |
eae@chromium.org | f58ceed | 2012-05-22 11:16:16 +0000 | [diff] [blame] | 764 | LayoutUnit RenderInline::marginStart(const RenderStyle* otherStyle) const |
hyatt@apple.com | d2c45ea | 2010-09-21 17:49:19 +0000 | [diff] [blame] | 765 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 766 | return computeMargin(this, style().marginStartUsing(otherStyle ? otherStyle : &style())); |
hyatt@apple.com | d2c45ea | 2010-09-21 17:49:19 +0000 | [diff] [blame] | 767 | } |
| 768 | |
eae@chromium.org | f58ceed | 2012-05-22 11:16:16 +0000 | [diff] [blame] | 769 | LayoutUnit RenderInline::marginEnd(const RenderStyle* otherStyle) const |
hyatt@apple.com | d2c45ea | 2010-09-21 17:49:19 +0000 | [diff] [blame] | 770 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 771 | return computeMargin(this, style().marginEndUsing(otherStyle ? otherStyle : &style())); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 772 | } |
| 773 | |
eae@chromium.org | f58ceed | 2012-05-22 11:16:16 +0000 | [diff] [blame] | 774 | LayoutUnit RenderInline::marginBefore(const RenderStyle* otherStyle) const |
hyatt@apple.com | 9bcbad6 | 2011-03-22 19:03:50 +0000 | [diff] [blame] | 775 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 776 | return computeMargin(this, style().marginBeforeUsing(otherStyle ? otherStyle : &style())); |
hyatt@apple.com | 9bcbad6 | 2011-03-22 19:03:50 +0000 | [diff] [blame] | 777 | } |
| 778 | |
eae@chromium.org | f58ceed | 2012-05-22 11:16:16 +0000 | [diff] [blame] | 779 | LayoutUnit RenderInline::marginAfter(const RenderStyle* otherStyle) const |
hyatt@apple.com | 9bcbad6 | 2011-03-22 19:03:50 +0000 | [diff] [blame] | 780 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 781 | return computeMargin(this, style().marginAfterUsing(otherStyle ? otherStyle : &style())); |
hyatt@apple.com | 9bcbad6 | 2011-03-22 19:03:50 +0000 | [diff] [blame] | 782 | } |
| 783 | |
weinig | c24ab18 | 2006-10-30 22:41:29 +0000 | [diff] [blame] | 784 | const char* RenderInline::renderName() const |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 785 | { |
| 786 | if (isRelPositioned()) |
| 787 | return "RenderInline (relative positioned)"; |
simon.fraser@apple.com | 0281aee | 2012-08-27 17:39:45 +0000 | [diff] [blame] | 788 | if (isStickyPositioned()) |
| 789 | return "RenderInline (sticky positioned)"; |
commit-queue@webkit.org | fb6d226 | 2012-12-05 21:00:54 +0000 | [diff] [blame] | 790 | // FIXME: Temporary hack while the new generated content system is being implemented. |
| 791 | if (isPseudoElement()) |
| 792 | return "RenderInline (generated)"; |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 793 | if (isAnonymous()) |
| 794 | return "RenderInline (generated)"; |
| 795 | return "RenderInline"; |
| 796 | } |
| 797 | |
bdakin | c4d8acc | 2006-10-31 21:48:20 +0000 | [diff] [blame] | 798 | bool RenderInline::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, |
allan.jensen@nokia.com | 9a9045b | 2012-08-28 09:41:54 +0000 | [diff] [blame] | 799 | const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 800 | { |
allan.jensen@nokia.com | 9a9045b | 2012-08-28 09:41:54 +0000 | [diff] [blame] | 801 | return m_lineBoxes.hitTest(this, request, result, locationInContainer, accumulatedOffset, hitTestAction); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 802 | } |
| 803 | |
allan.jensen@digia.com | 4edbc3a | 2012-11-27 11:03:23 +0000 | [diff] [blame] | 804 | namespace { |
| 805 | |
| 806 | class HitTestCulledInlinesGeneratorContext { |
| 807 | public: |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 808 | HitTestCulledInlinesGeneratorContext(Region& region, const HitTestLocation& location) |
| 809 | : m_intersected(false) |
| 810 | , m_region(region) |
| 811 | , m_location(location) |
| 812 | { } |
| 813 | |
| 814 | void addRect(const FloatRect& rect) |
allan.jensen@digia.com | 4edbc3a | 2012-11-27 11:03:23 +0000 | [diff] [blame] | 815 | { |
| 816 | m_intersected = m_intersected || m_location.intersects(rect); |
| 817 | m_region.unite(enclosingIntRect(rect)); |
| 818 | } |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 819 | |
allan.jensen@digia.com | 4edbc3a | 2012-11-27 11:03:23 +0000 | [diff] [blame] | 820 | bool intersected() const { return m_intersected; } |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 821 | |
allan.jensen@digia.com | 4edbc3a | 2012-11-27 11:03:23 +0000 | [diff] [blame] | 822 | private: |
| 823 | bool m_intersected; |
| 824 | Region& m_region; |
| 825 | const HitTestLocation& m_location; |
| 826 | }; |
| 827 | |
| 828 | } // unnamed namespace |
| 829 | |
| 830 | bool RenderInline::hitTestCulledInline(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset) |
| 831 | { |
| 832 | ASSERT(result.isRectBasedTest() && !alwaysCreateLineBoxes()); |
| 833 | if (!visibleToHitTesting()) |
| 834 | return false; |
| 835 | |
| 836 | HitTestLocation tmpLocation(locationInContainer, -toLayoutSize(accumulatedOffset)); |
| 837 | |
| 838 | Region regionResult; |
| 839 | HitTestCulledInlinesGeneratorContext context(regionResult, tmpLocation); |
| 840 | generateCulledLineBoxRects(context, this); |
| 841 | |
| 842 | if (context.intersected()) { |
| 843 | updateHitTestResult(result, tmpLocation.point()); |
| 844 | // We can not use addNodeToRectBasedTestResult to determine if we fully enclose the hit-test area |
| 845 | // because it can only handle rectangular targets. |
antti@apple.com | 8f33508 | 2013-09-09 19:54:33 +0000 | [diff] [blame] | 846 | result.addNodeToRectBasedTestResult(element(), request, locationInContainer); |
rniwa@webkit.org | 563e829 | 2013-06-11 07:34:42 +0000 | [diff] [blame] | 847 | return regionResult.contains(tmpLocation.boundingBox()); |
allan.jensen@digia.com | 4edbc3a | 2012-11-27 11:03:23 +0000 | [diff] [blame] | 848 | } |
| 849 | return false; |
| 850 | } |
| 851 | |
stavila@adobe.com | 4ce2fff | 2014-04-25 13:56:12 +0000 | [diff] [blame] | 852 | VisiblePosition RenderInline::positionForPoint(const LayoutPoint& point, const RenderRegion* region) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 853 | { |
simon.fraser@apple.com | 0281aee | 2012-08-27 17:39:45 +0000 | [diff] [blame] | 854 | // FIXME: Does not deal with relative or sticky positioned inlines (should it?) |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 855 | RenderBlock& containingBlock = *this->containingBlock(); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 856 | if (firstLineBox()) { |
| 857 | // This inline actually has a line box. We must have clicked in the border/padding of one of these boxes. We |
| 858 | // should try to find a result by asking our containing block. |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 859 | return containingBlock.positionForPoint(point, region); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 860 | } |
| 861 | |
| 862 | // Translate the coords from the pre-anonymous block to the post-anonymous block. |
cdumez@apple.com | e943779 | 2014-10-08 23:33:43 +0000 | [diff] [blame] | 863 | LayoutPoint parentBlockPoint = containingBlock.location() + point; |
| 864 | RenderBoxModelObject* continuation = this->continuation(); |
| 865 | while (continuation) { |
| 866 | RenderBlock* currentBlock = continuation->isInline() ? continuation->containingBlock() : downcast<RenderBlock>(continuation); |
| 867 | if (continuation->isInline() || continuation->firstChild()) |
| 868 | return continuation->positionForPoint(parentBlockPoint - currentBlock->locationOffset(), region); |
| 869 | continuation = downcast<RenderBlock>(*continuation).inlineElementContinuation(); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 870 | } |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 871 | |
stavila@adobe.com | 4ce2fff | 2014-04-25 13:56:12 +0000 | [diff] [blame] | 872 | return RenderBoxModelObject::positionForPoint(point, region); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 873 | } |
| 874 | |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 875 | namespace { |
| 876 | |
| 877 | class LinesBoundingBoxGeneratorContext { |
| 878 | public: |
| 879 | LinesBoundingBoxGeneratorContext(FloatRect& rect) : m_rect(rect) { } |
simon.fraser@apple.com | e0de567 | 2014-09-19 01:01:39 +0000 | [diff] [blame] | 880 | |
| 881 | void addRect(const FloatRect& rect) |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 882 | { |
| 883 | m_rect.uniteIfNonZero(rect); |
| 884 | } |
| 885 | private: |
| 886 | FloatRect& m_rect; |
| 887 | }; |
| 888 | |
| 889 | } // unnamed namespace |
| 890 | |
leviw@chromium.org | 92e93e2 | 2012-03-27 10:06:49 +0000 | [diff] [blame] | 891 | IntRect RenderInline::linesBoundingBox() const |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 892 | { |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 893 | if (!alwaysCreateLineBoxes()) { |
| 894 | ASSERT(!firstLineBox()); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 895 | FloatRect floatResult; |
commit-queue@webkit.org | 39f4e3f | 2012-07-17 03:26:00 +0000 | [diff] [blame] | 896 | LinesBoundingBoxGeneratorContext context(floatResult); |
| 897 | generateCulledLineBoxRects(context, this); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 898 | return enclosingIntRect(floatResult); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 899 | } |
| 900 | |
leviw@chromium.org | 92e93e2 | 2012-03-27 10:06:49 +0000 | [diff] [blame] | 901 | IntRect result; |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 902 | |
| 903 | // See <rdar://problem/5289721>, for an unknown reason the linked list here is sometimes inconsistent, first is non-zero and last is zero. We have been |
| 904 | // unable to reproduce this at all (and consequently unable to figure ot why this is happening). The assert will hopefully catch the problem in debug |
| 905 | // builds and help us someday figure out why. We also put in a redundant check of lastLineBox() to avoid the crash for now. |
| 906 | ASSERT(!firstLineBox() == !lastLineBox()); // Either both are null or both exist. |
| 907 | if (firstLineBox() && lastLineBox()) { |
| 908 | // Return the width of the minimal left side and the maximal right side. |
hyatt@apple.com | 0acc935 | 2011-02-17 19:19:07 +0000 | [diff] [blame] | 909 | float logicalLeftSide = 0; |
| 910 | float logicalRightSide = 0; |
hyatt@apple.com | 9f47d58 | 2010-03-12 20:29:50 +0000 | [diff] [blame] | 911 | for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { |
hyatt@apple.com | 46ed555 | 2010-11-01 19:07:12 +0000 | [diff] [blame] | 912 | if (curr == firstLineBox() || curr->logicalLeft() < logicalLeftSide) |
| 913 | logicalLeftSide = curr->logicalLeft(); |
| 914 | if (curr == firstLineBox() || curr->logicalRight() > logicalRightSide) |
| 915 | logicalRightSide = curr->logicalRight(); |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 916 | } |
hyatt@apple.com | 46ed555 | 2010-11-01 19:07:12 +0000 | [diff] [blame] | 917 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 918 | bool isHorizontal = style().isHorizontalWritingMode(); |
hyatt@apple.com | 46ed555 | 2010-11-01 19:07:12 +0000 | [diff] [blame] | 919 | |
hyatt@apple.com | 0acc935 | 2011-02-17 19:19:07 +0000 | [diff] [blame] | 920 | float x = isHorizontal ? logicalLeftSide : firstLineBox()->x(); |
| 921 | float y = isHorizontal ? firstLineBox()->y() : logicalLeftSide; |
| 922 | float width = isHorizontal ? logicalRightSide - logicalLeftSide : lastLineBox()->logicalBottom() - x; |
| 923 | float height = isHorizontal ? lastLineBox()->logicalBottom() - y : logicalRightSide - logicalLeftSide; |
leviw@chromium.org | 92e93e2 | 2012-03-27 10:06:49 +0000 | [diff] [blame] | 924 | result = enclosingIntRect(FloatRect(x, y, width, height)); |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | return result; |
| 928 | } |
| 929 | |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 930 | InlineBox* RenderInline::culledInlineFirstLineBox() const |
| 931 | { |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 932 | for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { |
| 933 | if (current->isFloatingOrOutOfFlowPositioned()) |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 934 | continue; |
| 935 | |
| 936 | // We want to get the margin box in the inline direction, and then use our font ascent/descent in the block |
| 937 | // direction (aligned to the root box's baseline). |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 938 | if (is<RenderBox>(*current)) |
| 939 | return downcast<RenderBox>(*current).inlineBoxWrapper(); |
| 940 | if (is<RenderLineBreak>(*current)) { |
| 941 | RenderLineBreak& renderBR = downcast<RenderLineBreak>(*current); |
| 942 | if (renderBR.inlineBoxWrapper()) |
| 943 | return renderBR.inlineBoxWrapper(); |
| 944 | } else if (is<RenderInline>(*current)) { |
| 945 | RenderInline& renderInline = downcast<RenderInline>(*current); |
| 946 | if (InlineBox* result = renderInline.firstLineBoxIncludingCulling()) |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 947 | return result; |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 948 | } else if (is<RenderText>(*current)) { |
| 949 | RenderText& renderText = downcast<RenderText>(*current); |
| 950 | if (renderText.firstTextBox()) |
| 951 | return renderText.firstTextBox(); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 952 | } |
| 953 | } |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 954 | return nullptr; |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | InlineBox* RenderInline::culledInlineLastLineBox() const |
| 958 | { |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 959 | for (RenderObject* current = lastChild(); current; current = current->previousSibling()) { |
| 960 | if (current->isFloatingOrOutOfFlowPositioned()) |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 961 | continue; |
| 962 | |
| 963 | // We want to get the margin box in the inline direction, and then use our font ascent/descent in the block |
| 964 | // direction (aligned to the root box's baseline). |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 965 | if (is<RenderBox>(*current)) |
| 966 | return downcast<RenderBox>(*current).inlineBoxWrapper(); |
| 967 | if (is<RenderLineBreak>(*current)) { |
| 968 | RenderLineBreak& renderBR = downcast<RenderLineBreak>(*current); |
| 969 | if (renderBR.inlineBoxWrapper()) |
| 970 | return renderBR.inlineBoxWrapper(); |
| 971 | } else if (is<RenderInline>(*current)) { |
| 972 | RenderInline& renderInline = downcast<RenderInline>(*current); |
| 973 | if (InlineBox* result = renderInline.lastLineBoxIncludingCulling()) |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 974 | return result; |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 975 | } else if (is<RenderText>(*current)) { |
| 976 | RenderText& renderText = downcast<RenderText>(*current); |
| 977 | if (renderText.lastTextBox()) |
| 978 | return renderText.lastTextBox(); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 979 | } |
| 980 | } |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 981 | return nullptr; |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 982 | } |
| 983 | |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 984 | LayoutRect RenderInline::culledInlineVisualOverflowBoundingBox() const |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 985 | { |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 986 | FloatRect floatResult; |
commit-queue@webkit.org | 39f4e3f | 2012-07-17 03:26:00 +0000 | [diff] [blame] | 987 | LinesBoundingBoxGeneratorContext context(floatResult); |
| 988 | generateCulledLineBoxRects(context, this); |
commit-queue@webkit.org | 6f2377d | 2012-05-11 02:08:06 +0000 | [diff] [blame] | 989 | LayoutRect result(enclosingLayoutRect(floatResult)); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 990 | bool isHorizontal = style().isHorizontalWritingMode(); |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 991 | for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { |
| 992 | if (current->isFloatingOrOutOfFlowPositioned()) |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 993 | continue; |
| 994 | |
| 995 | // For overflow we just have to propagate by hand and recompute it all. |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 996 | if (is<RenderBox>(*current)) { |
| 997 | RenderBox& renderBox = downcast<RenderBox>(*current); |
| 998 | if (!renderBox.hasSelfPaintingLayer() && renderBox.inlineBoxWrapper()) { |
| 999 | LayoutRect logicalRect = renderBox.logicalVisualOverflowRectForPropagation(&style()); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1000 | if (isHorizontal) { |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 1001 | logicalRect.moveBy(renderBox.location()); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1002 | result.uniteIfNonZero(logicalRect); |
| 1003 | } else { |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 1004 | logicalRect.moveBy(renderBox.location()); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1005 | result.uniteIfNonZero(logicalRect.transposedRect()); |
| 1006 | } |
| 1007 | } |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 1008 | } else if (is<RenderInline>(*current)) { |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1009 | // If the child doesn't need line boxes either, then we can recur. |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 1010 | RenderInline& renderInline = downcast<RenderInline>(*current); |
| 1011 | if (!renderInline.alwaysCreateLineBoxes()) |
| 1012 | result.uniteIfNonZero(renderInline.culledInlineVisualOverflowBoundingBox()); |
| 1013 | else if (!renderInline.hasSelfPaintingLayer()) |
| 1014 | result.uniteIfNonZero(renderInline.linesVisualOverflowBoundingBox()); |
| 1015 | } else if (is<RenderText>(*current)) { |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1016 | // FIXME; Overflow from text boxes is lost. We will need to cache this information in |
| 1017 | // InlineTextBoxes. |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 1018 | RenderText& renderText = downcast<RenderText>(*current); |
| 1019 | result.uniteIfNonZero(renderText.linesVisualOverflowBoundingBox()); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1020 | } |
| 1021 | } |
| 1022 | return result; |
| 1023 | } |
| 1024 | |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 1025 | LayoutRect RenderInline::linesVisualOverflowBoundingBox() const |
mitz@apple.com | 3b8b9f4 | 2009-08-26 21:54:11 +0000 | [diff] [blame] | 1026 | { |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1027 | if (!alwaysCreateLineBoxes()) |
| 1028 | return culledInlineVisualOverflowBoundingBox(); |
| 1029 | |
mitz@apple.com | 3b8b9f4 | 2009-08-26 21:54:11 +0000 | [diff] [blame] | 1030 | if (!firstLineBox() || !lastLineBox()) |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 1031 | return LayoutRect(); |
mitz@apple.com | 3b8b9f4 | 2009-08-26 21:54:11 +0000 | [diff] [blame] | 1032 | |
| 1033 | // Return the width of the minimal left side and the maximal right side. |
eae@chromium.org | 9717cd8 | 2012-11-07 18:33:44 +0000 | [diff] [blame] | 1034 | LayoutUnit logicalLeftSide = LayoutUnit::max(); |
| 1035 | LayoutUnit logicalRightSide = LayoutUnit::min(); |
hyatt@apple.com | 9f47d58 | 2010-03-12 20:29:50 +0000 | [diff] [blame] | 1036 | for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 1037 | logicalLeftSide = std::min(logicalLeftSide, curr->logicalLeftVisualOverflow()); |
| 1038 | logicalRightSide = std::max(logicalRightSide, curr->logicalRightVisualOverflow()); |
mitz@apple.com | 3b8b9f4 | 2009-08-26 21:54:11 +0000 | [diff] [blame] | 1039 | } |
| 1040 | |
akling@apple.com | dbf7030 | 2013-09-09 02:11:06 +0000 | [diff] [blame] | 1041 | const RootInlineBox& firstRootBox = firstLineBox()->root(); |
| 1042 | const RootInlineBox& lastRootBox = lastLineBox()->root(); |
hyatt@apple.com | 61f2532 | 2011-03-31 20:40:48 +0000 | [diff] [blame] | 1043 | |
akling@apple.com | dbf7030 | 2013-09-09 02:11:06 +0000 | [diff] [blame] | 1044 | LayoutUnit logicalTop = firstLineBox()->logicalTopVisualOverflow(firstRootBox.lineTop()); |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 1045 | LayoutUnit logicalWidth = logicalRightSide - logicalLeftSide; |
akling@apple.com | dbf7030 | 2013-09-09 02:11:06 +0000 | [diff] [blame] | 1046 | LayoutUnit logicalHeight = lastLineBox()->logicalBottomVisualOverflow(lastRootBox.lineBottom()) - logicalTop; |
hyatt@apple.com | 61f2532 | 2011-03-31 20:40:48 +0000 | [diff] [blame] | 1047 | |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 1048 | LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1049 | if (!style().isHorizontalWritingMode()) |
hyatt@apple.com | 61f2532 | 2011-03-31 20:40:48 +0000 | [diff] [blame] | 1050 | rect = rect.transposedRect(); |
| 1051 | return rect; |
mitz@apple.com | 3b8b9f4 | 2009-08-26 21:54:11 +0000 | [diff] [blame] | 1052 | } |
| 1053 | |
abucur@adobe.com | a043772 | 2014-01-10 10:38:18 +0000 | [diff] [blame] | 1054 | LayoutRect RenderInline::linesVisualOverflowBoundingBoxInRegion(const RenderRegion* region) const |
| 1055 | { |
| 1056 | ASSERT(alwaysCreateLineBoxes()); |
| 1057 | ASSERT(region); |
| 1058 | |
| 1059 | if (!firstLineBox() || !lastLineBox()) |
| 1060 | return LayoutRect(); |
| 1061 | |
| 1062 | // Return the width of the minimal left side and the maximal right side. |
| 1063 | LayoutUnit logicalLeftSide = LayoutUnit::max(); |
| 1064 | LayoutUnit logicalRightSide = LayoutUnit::min(); |
| 1065 | LayoutUnit logicalTop; |
| 1066 | LayoutUnit logicalHeight; |
| 1067 | InlineFlowBox* lastInlineInRegion = 0; |
| 1068 | for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { |
| 1069 | const RootInlineBox& root = curr->root(); |
| 1070 | if (root.containingRegion() != region) { |
| 1071 | if (lastInlineInRegion) |
| 1072 | break; |
| 1073 | continue; |
| 1074 | } |
| 1075 | |
| 1076 | if (!lastInlineInRegion) |
| 1077 | logicalTop = curr->logicalTopVisualOverflow(root.lineTop()); |
| 1078 | |
| 1079 | lastInlineInRegion = curr; |
| 1080 | |
| 1081 | logicalLeftSide = std::min(logicalLeftSide, curr->logicalLeftVisualOverflow()); |
| 1082 | logicalRightSide = std::max(logicalRightSide, curr->logicalRightVisualOverflow()); |
| 1083 | } |
| 1084 | |
| 1085 | if (!lastInlineInRegion) |
| 1086 | return LayoutRect(); |
| 1087 | |
| 1088 | logicalHeight = lastInlineInRegion->logicalBottomVisualOverflow(lastInlineInRegion->root().lineBottom()) - logicalTop; |
| 1089 | |
| 1090 | LayoutUnit logicalWidth = logicalRightSide - logicalLeftSide; |
| 1091 | |
| 1092 | LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight); |
| 1093 | if (!style().isHorizontalWritingMode()) |
| 1094 | rect = rect.transposedRect(); |
| 1095 | return rect; |
| 1096 | } |
| 1097 | |
simon.fraser@apple.com | a482506 | 2012-11-08 05:15:10 +0000 | [diff] [blame] | 1098 | LayoutRect RenderInline::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 1099 | { |
akling@apple.com | 38f0a65 | 2014-02-06 21:24:17 +0000 | [diff] [blame] | 1100 | // Only first-letter renderers are allowed in here during layout. They mutate the tree triggering repaints. |
| 1101 | ASSERT(!view().layoutStateEnabled() || style().styleType() == FIRST_LETTER); |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 1102 | |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1103 | if (!firstLineBoxIncludingCulling() && !continuation()) |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 1104 | return LayoutRect(); |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 1105 | |
jchaffraix@webkit.org | 0e70bf8 | 2012-05-17 21:31:10 +0000 | [diff] [blame] | 1106 | LayoutRect repaintRect(linesVisualOverflowBoundingBox()); |
mitz@apple.com | 8296dea | 2012-03-13 23:58:59 +0000 | [diff] [blame] | 1107 | bool hitRepaintContainer = false; |
| 1108 | |
simon.fraser@apple.com | ea93fa0 | 2012-08-24 00:52:53 +0000 | [diff] [blame] | 1109 | // We need to add in the in-flow position offsets of any inlines (including us) up to our |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 1110 | // containing block. |
cdumez@apple.com | f802215 | 2014-10-15 00:29:51 +0000 | [diff] [blame] | 1111 | RenderBlock* containingBlock = this->containingBlock(); |
| 1112 | for (const RenderElement* inlineFlow = this; is<RenderInline>(inlineFlow) && inlineFlow != containingBlock; |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 1113 | inlineFlow = inlineFlow->parent()) { |
mitz@apple.com | 8296dea | 2012-03-13 23:58:59 +0000 | [diff] [blame] | 1114 | if (inlineFlow == repaintContainer) { |
| 1115 | hitRepaintContainer = true; |
| 1116 | break; |
| 1117 | } |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1118 | if (inlineFlow->style().hasInFlowPosition() && inlineFlow->hasLayer()) |
cdumez@apple.com | f802215 | 2014-10-15 00:29:51 +0000 | [diff] [blame] | 1119 | repaintRect.move(downcast<RenderInline>(*inlineFlow).layer()->offsetForInFlowPosition()); |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 1120 | } |
| 1121 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1122 | LayoutUnit outlineSize = style().outlineSize(); |
jchaffraix@webkit.org | 0e70bf8 | 2012-05-17 21:31:10 +0000 | [diff] [blame] | 1123 | repaintRect.inflate(outlineSize); |
hyatt@apple.com | 46ed555 | 2010-11-01 19:07:12 +0000 | [diff] [blame] | 1124 | |
cdumez@apple.com | f802215 | 2014-10-15 00:29:51 +0000 | [diff] [blame] | 1125 | if (hitRepaintContainer || !containingBlock) |
jchaffraix@webkit.org | 0e70bf8 | 2012-05-17 21:31:10 +0000 | [diff] [blame] | 1126 | return repaintRect; |
mitz@apple.com | 8296dea | 2012-03-13 23:58:59 +0000 | [diff] [blame] | 1127 | |
cdumez@apple.com | f802215 | 2014-10-15 00:29:51 +0000 | [diff] [blame] | 1128 | if (containingBlock->hasOverflowClip()) |
| 1129 | containingBlock->applyCachedClipAndScrollOffsetForRepaint(repaintRect); |
mitz@apple.com | 8296dea | 2012-03-13 23:58:59 +0000 | [diff] [blame] | 1130 | |
cdumez@apple.com | f802215 | 2014-10-15 00:29:51 +0000 | [diff] [blame] | 1131 | containingBlock->computeRectForRepaint(repaintContainer, repaintRect); |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 1132 | |
jchaffraix@webkit.org | 0e70bf8 | 2012-05-17 21:31:10 +0000 | [diff] [blame] | 1133 | if (outlineSize) { |
weinig@apple.com | c77041e | 2013-12-14 18:05:45 +0000 | [diff] [blame] | 1134 | for (auto& child : childrenOfType<RenderElement>(*this)) |
| 1135 | repaintRect.unite(child.rectWithOutlineForRepaint(repaintContainer, outlineSize)); |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 1136 | |
akling@apple.com | 194c6fc | 2013-09-24 16:20:20 +0000 | [diff] [blame] | 1137 | if (RenderBoxModelObject* continuation = this->continuation()) { |
| 1138 | if (!continuation->isInline() && continuation->parent()) |
| 1139 | repaintRect.unite(continuation->rectWithOutlineForRepaint(repaintContainer, outlineSize)); |
| 1140 | } |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 1141 | } |
| 1142 | |
jchaffraix@webkit.org | 0e70bf8 | 2012-05-17 21:31:10 +0000 | [diff] [blame] | 1143 | return repaintRect; |
hyatt@apple.com | 62dc001 | 2009-01-26 22:45:24 +0000 | [diff] [blame] | 1144 | } |
| 1145 | |
simon.fraser@apple.com | a482506 | 2012-11-08 05:15:10 +0000 | [diff] [blame] | 1146 | LayoutRect RenderInline::rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 1147 | { |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 1148 | LayoutRect r(RenderBoxModelObject::rectWithOutlineForRepaint(repaintContainer, outlineWidth)); |
weinig@apple.com | c77041e | 2013-12-14 18:05:45 +0000 | [diff] [blame] | 1149 | for (auto& child : childrenOfType<RenderElement>(*this)) |
| 1150 | r.unite(child.rectWithOutlineForRepaint(repaintContainer, outlineWidth)); |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 1151 | return r; |
| 1152 | } |
| 1153 | |
simon.fraser@apple.com | a482506 | 2012-11-08 05:15:10 +0000 | [diff] [blame] | 1154 | void RenderInline::computeRectForRepaint(const RenderLayerModelObject* repaintContainer, LayoutRect& rect, bool fixed) const |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1155 | { |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 1156 | // LayoutState is only valid for root-relative repainting |
| 1157 | if (view().layoutStateEnabled() && !repaintContainer) { |
| 1158 | LayoutState* layoutState = view().layoutState(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1159 | if (style().hasInFlowPosition() && layer()) |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 1160 | rect.move(layer()->offsetForInFlowPosition()); |
| 1161 | rect.move(layoutState->m_paintOffset); |
| 1162 | if (layoutState->m_clipped) |
| 1163 | rect.intersect(layoutState->m_clipRect); |
| 1164 | return; |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | if (repaintContainer == this) |
| 1168 | return; |
| 1169 | |
simon.fraser@apple.com | dcacba1 | 2009-09-28 16:14:18 +0000 | [diff] [blame] | 1170 | bool containerSkipped; |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1171 | RenderElement* container = this->container(repaintContainer, &containerSkipped); |
| 1172 | if (!container) |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1173 | return; |
| 1174 | |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 1175 | LayoutPoint topLeft = rect.location(); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1176 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1177 | if (style().hasInFlowPosition() && layer()) { |
simon.fraser@apple.com | ea93fa0 | 2012-08-24 00:52:53 +0000 | [diff] [blame] | 1178 | // Apply the in-flow position offset when invalidating a rectangle. The layer |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1179 | // is translated, but the render box isn't, so we need to do this to get the |
simon.fraser@apple.com | 0281aee | 2012-08-27 17:39:45 +0000 | [diff] [blame] | 1180 | // right dirty rect. Since this is called from RenderObject::setStyle, the relative or sticky position |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1181 | // flag on the RenderObject has been cleared, so use the one on the style(). |
commit-queue@webkit.org | 6362c30 | 2013-06-27 20:33:07 +0000 | [diff] [blame] | 1182 | topLeft += layer()->offsetForInFlowPosition(); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | // FIXME: We ignore the lightweight clipping rect that controls use, since if |o| is in mid-layout, |
| 1186 | // its controlClipRect will be wrong. For overflow clip we use the values cached by the layer. |
commit-queue@webkit.org | 9914ba6 | 2012-09-13 17:22:21 +0000 | [diff] [blame] | 1187 | rect.setLocation(topLeft); |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1188 | if (container->hasOverflowClip()) { |
| 1189 | downcast<RenderBox>(*container).applyCachedClipAndScrollOffsetForRepaint(rect); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1190 | if (rect.isEmpty()) |
| 1191 | return; |
commit-queue@webkit.org | 9914ba6 | 2012-09-13 17:22:21 +0000 | [diff] [blame] | 1192 | } |
simon.fraser@apple.com | dcacba1 | 2009-09-28 16:14:18 +0000 | [diff] [blame] | 1193 | |
| 1194 | if (containerSkipped) { |
| 1195 | // If the repaintContainer is below o, then we need to map the rect into repaintContainer's coordinates. |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1196 | LayoutSize containerOffset = repaintContainer->offsetFromAncestorContainer(*container); |
simon.fraser@apple.com | dcacba1 | 2009-09-28 16:14:18 +0000 | [diff] [blame] | 1197 | rect.move(-containerOffset); |
| 1198 | return; |
| 1199 | } |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1200 | |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1201 | container->computeRectForRepaint(repaintContainer, rect, fixed); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1202 | } |
| 1203 | |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1204 | LayoutSize RenderInline::offsetFromContainer(RenderElement& container, const LayoutPoint&, bool* offsetDependsOnPoint) const |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1205 | { |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1206 | ASSERT(&container == this->container()); |
hyatt@apple.com | 61bbedf | 2011-01-26 23:10:57 +0000 | [diff] [blame] | 1207 | |
eae@chromium.org | a468a4a | 2011-07-07 02:32:26 +0000 | [diff] [blame] | 1208 | LayoutSize offset; |
simon.fraser@apple.com | ea93fa0 | 2012-08-24 00:52:53 +0000 | [diff] [blame] | 1209 | if (isInFlowPositioned()) |
| 1210 | offset += offsetForInFlowPosition(); |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1211 | |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1212 | if (is<RenderBox>(container)) |
| 1213 | offset -= downcast<RenderBox>(container).scrolledContentOffset(); |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1214 | |
simon.fraser@apple.com | ca41ec6 | 2012-05-25 21:42:32 +0000 | [diff] [blame] | 1215 | if (offsetDependsOnPoint) |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1216 | *offsetDependsOnPoint = (is<RenderBox>(container) && container.style().isFlippedBlocksWritingMode()) || is<RenderFlowThread>(container); |
simon.fraser@apple.com | ca41ec6 | 2012-05-25 21:42:32 +0000 | [diff] [blame] | 1217 | |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1218 | return offset; |
| 1219 | } |
| 1220 | |
simon.fraser@apple.com | a482506 | 2012-11-08 05:15:10 +0000 | [diff] [blame] | 1221 | void RenderInline::mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed) const |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1222 | { |
| 1223 | if (repaintContainer == this) |
| 1224 | return; |
| 1225 | |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 1226 | if (view().layoutStateEnabled() && !repaintContainer) { |
| 1227 | LayoutState* layoutState = view().layoutState(); |
| 1228 | LayoutSize offset = layoutState->m_paintOffset; |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1229 | if (style().hasInFlowPosition() && layer()) |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 1230 | offset += layer()->offsetForInFlowPosition(); |
| 1231 | transformState.move(offset); |
| 1232 | return; |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1233 | } |
| 1234 | |
| 1235 | bool containerSkipped; |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1236 | RenderElement* container = this->container(repaintContainer, &containerSkipped); |
| 1237 | if (!container) |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1238 | return; |
| 1239 | |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1240 | if (mode & ApplyContainerFlip && is<RenderBox>(*container)) { |
| 1241 | if (container->style().isFlippedBlocksWritingMode()) { |
zalan@apple.com | 83de8f8 | 2014-08-26 02:11:44 +0000 | [diff] [blame] | 1242 | LayoutPoint centerPoint(transformState.mappedPoint()); |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1243 | transformState.move(downcast<RenderBox>(*container).flipForWritingMode(centerPoint) - centerPoint); |
mitz@apple.com | f9967cb | 2012-07-19 20:46:03 +0000 | [diff] [blame] | 1244 | } |
leviw@chromium.org | 0d46429 | 2012-08-03 22:23:42 +0000 | [diff] [blame] | 1245 | mode &= ~ApplyContainerFlip; |
mitz@apple.com | e2feae9 | 2012-05-03 16:32:33 +0000 | [diff] [blame] | 1246 | } |
hyatt@apple.com | 61bbedf | 2011-01-26 23:10:57 +0000 | [diff] [blame] | 1247 | |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1248 | LayoutSize containerOffset = offsetFromContainer(*container, LayoutPoint(transformState.mappedPoint())); |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1249 | |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1250 | bool preserve3D = mode & UseTransforms && (container->style().preserves3D() || style().preserves3D()); |
| 1251 | if (mode & UseTransforms && shouldUseTransformFromContainer(container)) { |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1252 | TransformationMatrix t; |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1253 | getTransformFromContainer(container, containerOffset, t); |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1254 | transformState.applyTransform(t, preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); |
| 1255 | } else |
| 1256 | transformState.move(containerOffset.width(), containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); |
| 1257 | |
| 1258 | if (containerSkipped) { |
| 1259 | // There can't be a transform between repaintContainer and o, because transforms create containers, so it should be safe |
| 1260 | // to just subtract the delta between the repaintContainer and o. |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1261 | LayoutSize containerOffset = repaintContainer->offsetFromAncestorContainer(*container); |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1262 | transformState.move(-containerOffset.width(), -containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); |
| 1263 | return; |
| 1264 | } |
| 1265 | |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1266 | container->mapLocalToContainer(repaintContainer, transformState, mode, wasFixed); |
mitz@apple.com | a0c027c | 2009-10-27 23:32:44 +0000 | [diff] [blame] | 1267 | } |
| 1268 | |
fmalita@chromium.org | 49d26f2 | 2012-10-01 22:04:56 +0000 | [diff] [blame] | 1269 | const RenderObject* RenderInline::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const |
simon.fraser@apple.com | ca41ec6 | 2012-05-25 21:42:32 +0000 | [diff] [blame] | 1270 | { |
| 1271 | ASSERT(ancestorToStopAt != this); |
| 1272 | |
| 1273 | bool ancestorSkipped; |
akling@apple.com | c096ce4 | 2013-09-23 23:55:20 +0000 | [diff] [blame] | 1274 | RenderElement* container = this->container(ancestorToStopAt, &ancestorSkipped); |
simon.fraser@apple.com | ca41ec6 | 2012-05-25 21:42:32 +0000 | [diff] [blame] | 1275 | if (!container) |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1276 | return nullptr; |
simon.fraser@apple.com | ca41ec6 | 2012-05-25 21:42:32 +0000 | [diff] [blame] | 1277 | |
simon.fraser@apple.com | ca41ec6 | 2012-05-25 21:42:32 +0000 | [diff] [blame] | 1278 | LayoutSize adjustmentForSkippedAncestor; |
| 1279 | if (ancestorSkipped) { |
| 1280 | // There can't be a transform between repaintContainer and o, because transforms create containers, so it should be safe |
| 1281 | // to just subtract the delta between the ancestor and o. |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1282 | adjustmentForSkippedAncestor = -ancestorToStopAt->offsetFromAncestorContainer(*container); |
simon.fraser@apple.com | ca41ec6 | 2012-05-25 21:42:32 +0000 | [diff] [blame] | 1283 | } |
| 1284 | |
simon.fraser@apple.com | 0e7f7d9 | 2012-05-27 00:43:12 +0000 | [diff] [blame] | 1285 | bool offsetDependsOnPoint = false; |
cdumez@apple.com | 225ce47 | 2014-10-15 05:01:31 +0000 | [diff] [blame] | 1286 | LayoutSize containerOffset = offsetFromContainer(*container, LayoutPoint(), &offsetDependsOnPoint); |
simon.fraser@apple.com | ca41ec6 | 2012-05-25 21:42:32 +0000 | [diff] [blame] | 1287 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1288 | bool preserve3D = container->style().preserves3D() || style().preserves3D(); |
simon.fraser@apple.com | ca41ec6 | 2012-05-25 21:42:32 +0000 | [diff] [blame] | 1289 | if (shouldUseTransformFromContainer(container)) { |
| 1290 | TransformationMatrix t; |
| 1291 | getTransformFromContainer(container, containerOffset, t); |
| 1292 | t.translateRight(adjustmentForSkippedAncestor.width(), adjustmentForSkippedAncestor.height()); // FIXME: right? |
| 1293 | geometryMap.push(this, t, preserve3D, offsetDependsOnPoint); |
| 1294 | } else { |
| 1295 | containerOffset += adjustmentForSkippedAncestor; |
| 1296 | geometryMap.push(this, containerOffset, preserve3D, offsetDependsOnPoint); |
| 1297 | } |
| 1298 | |
| 1299 | return ancestorSkipped ? ancestorToStopAt : container; |
| 1300 | } |
| 1301 | |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 1302 | void RenderInline::updateDragState(bool dragOn) |
| 1303 | { |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1304 | RenderBoxModelObject::updateDragState(dragOn); |
akling@apple.com | 194c6fc | 2013-09-24 16:20:20 +0000 | [diff] [blame] | 1305 | if (RenderBoxModelObject* continuation = this->continuation()) |
| 1306 | continuation->updateDragState(dragOn); |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 1307 | } |
| 1308 | |
commit-queue@webkit.org | 1ce868f | 2013-03-09 01:37:10 +0000 | [diff] [blame] | 1309 | void RenderInline::childBecameNonInline(RenderObject* child) |
| 1310 | { |
| 1311 | // We have to split the parent flow. |
| 1312 | RenderBlock* newBox = containingBlock()->createAnonymousBlock(); |
| 1313 | RenderBoxModelObject* oldContinuation = continuation(); |
| 1314 | setContinuation(newBox); |
| 1315 | RenderObject* beforeChild = child->nextSibling(); |
akling@apple.com | 49d4d3b | 2013-10-16 12:40:09 +0000 | [diff] [blame] | 1316 | removeChildInternal(*child, NotifyChildren); |
commit-queue@webkit.org | 1ce868f | 2013-03-09 01:37:10 +0000 | [diff] [blame] | 1317 | splitFlow(beforeChild, newBox, child, oldContinuation); |
| 1318 | } |
| 1319 | |
eae@chromium.org | 3108e1d | 2011-07-10 19:20:37 +0000 | [diff] [blame] | 1320 | void RenderInline::updateHitTestResult(HitTestResult& result, const LayoutPoint& point) |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 1321 | { |
| 1322 | if (result.innerNode()) |
| 1323 | return; |
| 1324 | |
eae@chromium.org | 3108e1d | 2011-07-10 19:20:37 +0000 | [diff] [blame] | 1325 | LayoutPoint localPoint(point); |
antti@apple.com | 8f33508 | 2013-09-09 19:54:33 +0000 | [diff] [blame] | 1326 | if (Element* element = this->element()) { |
hyatt@apple.com | ca8ce86 | 2010-05-22 04:23:04 +0000 | [diff] [blame] | 1327 | if (isInlineElementContinuation()) { |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 1328 | // We're in the continuation of a split inline. Adjust our local point to be in the coordinate space |
| 1329 | // of the principal renderer's containing block. This will end up being the innerNonSharedNode. |
antti@apple.com | 8f33508 | 2013-09-09 19:54:33 +0000 | [diff] [blame] | 1330 | RenderBlock* firstBlock = element->renderer()->containingBlock(); |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 1331 | |
| 1332 | // Get our containing block. |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1333 | RenderBox* block = containingBlock(); |
eae@chromium.org | 1146f21 | 2012-07-18 22:06:34 +0000 | [diff] [blame] | 1334 | localPoint.moveBy(block->location() - firstBlock->locationOffset()); |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 1335 | } |
| 1336 | |
antti@apple.com | 8f33508 | 2013-09-09 19:54:33 +0000 | [diff] [blame] | 1337 | result.setInnerNode(element); |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 1338 | if (!result.innerNonSharedNode()) |
antti@apple.com | 8f33508 | 2013-09-09 19:54:33 +0000 | [diff] [blame] | 1339 | result.setInnerNonSharedNode(element); |
hyatt@apple.com | cd6f895 | 2009-01-28 17:30:26 +0000 | [diff] [blame] | 1340 | result.setLocalPoint(localPoint); |
| 1341 | } |
| 1342 | } |
| 1343 | |
hyatt@apple.com | c92b735 | 2009-02-12 01:35:08 +0000 | [diff] [blame] | 1344 | void RenderInline::dirtyLineBoxes(bool fullLayout) |
hyatt@apple.com | d5c8cb6 | 2009-01-29 02:11:08 +0000 | [diff] [blame] | 1345 | { |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1346 | if (fullLayout) { |
akling@apple.com | 31dd4f4 | 2013-10-30 22:27:59 +0000 | [diff] [blame] | 1347 | m_lineBoxes.deleteLineBoxes(); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1348 | return; |
| 1349 | } |
| 1350 | |
| 1351 | if (!alwaysCreateLineBoxes()) { |
| 1352 | // We have to grovel into our children in order to dirty the appropriate lines. |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 1353 | for (RenderObject* current = firstChild(); current; current = current->nextSibling()) { |
| 1354 | if (current->isFloatingOrOutOfFlowPositioned()) |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1355 | continue; |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 1356 | if (is<RenderBox>(*current) && !current->needsLayout()) { |
| 1357 | RenderBox& renderBox = downcast<RenderBox>(*current); |
| 1358 | if (renderBox.inlineBoxWrapper()) |
| 1359 | renderBox.inlineBoxWrapper()->root().markDirty(); |
| 1360 | } else if (!current->selfNeedsLayout()) { |
| 1361 | if (is<RenderInline>(*current)) { |
| 1362 | RenderInline& renderInline = downcast<RenderInline>(*current); |
| 1363 | for (InlineFlowBox* childLine = renderInline.firstLineBox(); childLine; childLine = childLine->nextLineBox()) |
akling@apple.com | dbf7030 | 2013-09-09 02:11:06 +0000 | [diff] [blame] | 1364 | childLine->root().markDirty(); |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 1365 | } else if (is<RenderText>(*current)) { |
| 1366 | RenderText& renderText = downcast<RenderText>(*current); |
| 1367 | for (InlineTextBox* childText = renderText.firstTextBox(); childText; childText = childText->nextTextBox()) |
akling@apple.com | dbf7030 | 2013-09-09 02:11:06 +0000 | [diff] [blame] | 1368 | childText->root().markDirty(); |
cdumez@apple.com | 35094bd | 2014-10-07 19:33:53 +0000 | [diff] [blame] | 1369 | } else if (is<RenderLineBreak>(*current)) { |
| 1370 | RenderLineBreak& renderBR = downcast<RenderLineBreak>(*current); |
| 1371 | if (renderBR.inlineBoxWrapper()) |
| 1372 | renderBR.inlineBoxWrapper()->root().markDirty(); |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1373 | } |
| 1374 | } |
| 1375 | } |
| 1376 | } else |
hyatt@apple.com | d5c8cb6 | 2009-01-29 02:11:08 +0000 | [diff] [blame] | 1377 | m_lineBoxes.dirtyLineBoxes(); |
| 1378 | } |
| 1379 | |
antti@apple.com | a2c7f24 | 2013-10-22 22:37:25 +0000 | [diff] [blame] | 1380 | void RenderInline::deleteLines() |
inferno@chromium.org | f531ade | 2012-05-22 01:36:43 +0000 | [diff] [blame] | 1381 | { |
akling@apple.com | 31dd4f4 | 2013-10-30 22:27:59 +0000 | [diff] [blame] | 1382 | m_lineBoxes.deleteLineBoxTree(); |
inferno@chromium.org | f531ade | 2012-05-22 01:36:43 +0000 | [diff] [blame] | 1383 | } |
| 1384 | |
akling@apple.com | b5f2464 | 2013-11-06 04:47:12 +0000 | [diff] [blame] | 1385 | std::unique_ptr<InlineFlowBox> RenderInline::createInlineFlowBox() |
hyatt@apple.com | c3c7e90 | 2009-01-28 21:48:33 +0000 | [diff] [blame] | 1386 | { |
akling@apple.com | b5f2464 | 2013-11-06 04:47:12 +0000 | [diff] [blame] | 1387 | return std::make_unique<InlineFlowBox>(*this); |
hyatt@apple.com | c92b735 | 2009-02-12 01:35:08 +0000 | [diff] [blame] | 1388 | } |
| 1389 | |
eric@webkit.org | 49b9d95 | 2009-07-03 01:29:07 +0000 | [diff] [blame] | 1390 | InlineFlowBox* RenderInline::createAndAppendInlineFlowBox() |
hyatt@apple.com | c92b735 | 2009-02-12 01:35:08 +0000 | [diff] [blame] | 1391 | { |
hyatt@apple.com | a61b8a3 | 2011-04-06 18:20:52 +0000 | [diff] [blame] | 1392 | setAlwaysCreateLineBoxes(); |
akling@apple.com | b5f2464 | 2013-11-06 04:47:12 +0000 | [diff] [blame] | 1393 | auto newFlowBox = createInlineFlowBox(); |
| 1394 | auto flowBox = newFlowBox.get(); |
dbates@webkit.org | 0cefe4f | 2014-07-03 22:13:54 +0000 | [diff] [blame] | 1395 | m_lineBoxes.appendLineBox(WTF::move(newFlowBox)); |
hyatt@apple.com | c3c7e90 | 2009-01-28 21:48:33 +0000 | [diff] [blame] | 1396 | return flowBox; |
| 1397 | } |
| 1398 | |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 1399 | LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*direction*/, LinePositionMode /*linePositionMode*/) const |
hyatt@apple.com | 7c5bd58 | 2009-01-28 19:31:46 +0000 | [diff] [blame] | 1400 | { |
benjamin@webkit.org | 23358d7 | 2013-09-25 21:13:38 +0000 | [diff] [blame] | 1401 | if (firstLine && document().styleSheetCollection().usesFirstLineRules()) { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1402 | const RenderStyle& firstLineStyle = this->firstLineStyle(); |
| 1403 | if (&firstLineStyle != &style()) |
bjonesbe@adobe.com | 830e80f | 2014-05-28 01:33:26 +0000 | [diff] [blame] | 1404 | return firstLineStyle.computedLineHeight(); |
hyatt@apple.com | 7c5bd58 | 2009-01-28 19:31:46 +0000 | [diff] [blame] | 1405 | } |
kling@webkit.org | e19e6cf | 2012-01-24 20:22:00 +0000 | [diff] [blame] | 1406 | |
bjonesbe@adobe.com | 830e80f | 2014-05-28 01:33:26 +0000 | [diff] [blame] | 1407 | return style().computedLineHeight(); |
hyatt@apple.com | 7c5bd58 | 2009-01-28 19:31:46 +0000 | [diff] [blame] | 1408 | } |
| 1409 | |
eae@chromium.org | 82b9498 | 2012-10-22 18:38:29 +0000 | [diff] [blame] | 1410 | int RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const |
hyatt@apple.com | ddd8c30 | 2010-10-19 18:38:14 +0000 | [diff] [blame] | 1411 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1412 | const RenderStyle& style = firstLine ? firstLineStyle() : this->style(); |
antti@apple.com | b0608f6 | 2013-09-28 18:30:16 +0000 | [diff] [blame] | 1413 | const FontMetrics& fontMetrics = style.fontMetrics(); |
zimmermann@webkit.org | e8433cc | 2011-01-22 11:46:23 +0000 | [diff] [blame] | 1414 | return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2; |
hyatt@apple.com | 4f81f3e | 2009-02-10 23:00:37 +0000 | [diff] [blame] | 1415 | } |
| 1416 | |
simon.fraser@apple.com | ea93fa0 | 2012-08-24 00:52:53 +0000 | [diff] [blame] | 1417 | LayoutSize RenderInline::offsetForInFlowPositionedInline(const RenderBox* child) const |
hyatt@apple.com | 76dbdb5 | 2009-01-29 22:49:13 +0000 | [diff] [blame] | 1418 | { |
hyatt@apple.com | e16585a | 2011-02-28 23:21:36 +0000 | [diff] [blame] | 1419 | // FIXME: This function isn't right with mixed writing modes. |
| 1420 | |
simon.fraser@apple.com | ea93fa0 | 2012-08-24 00:52:53 +0000 | [diff] [blame] | 1421 | ASSERT(isInFlowPositioned()); |
| 1422 | if (!isInFlowPositioned()) |
eae@chromium.org | a468a4a | 2011-07-07 02:32:26 +0000 | [diff] [blame] | 1423 | return LayoutSize(); |
hyatt@apple.com | 76dbdb5 | 2009-01-29 22:49:13 +0000 | [diff] [blame] | 1424 | |
| 1425 | // When we have an enclosing relpositioned inline, we need to add in the offset of the first line |
| 1426 | // box from the rest of the content, but only in the cases where we know we're positioned |
| 1427 | // relative to the inline itself. |
| 1428 | |
eae@chromium.org | a468a4a | 2011-07-07 02:32:26 +0000 | [diff] [blame] | 1429 | LayoutSize logicalOffset; |
| 1430 | LayoutUnit inlinePosition; |
| 1431 | LayoutUnit blockPosition; |
hyatt@apple.com | 76dbdb5 | 2009-01-29 22:49:13 +0000 | [diff] [blame] | 1432 | if (firstLineBox()) { |
zalan@apple.com | 81badc1 | 2014-08-26 19:29:09 +0000 | [diff] [blame] | 1433 | inlinePosition = LayoutUnit::fromFloatRound(firstLineBox()->logicalLeft()); |
hyatt@apple.com | e16585a | 2011-02-28 23:21:36 +0000 | [diff] [blame] | 1434 | blockPosition = firstLineBox()->logicalTop(); |
hyatt@apple.com | 76dbdb5 | 2009-01-29 22:49:13 +0000 | [diff] [blame] | 1435 | } else { |
hyatt@apple.com | e16585a | 2011-02-28 23:21:36 +0000 | [diff] [blame] | 1436 | inlinePosition = layer()->staticInlinePosition(); |
| 1437 | blockPosition = layer()->staticBlockPosition(); |
hyatt@apple.com | 76dbdb5 | 2009-01-29 22:49:13 +0000 | [diff] [blame] | 1438 | } |
| 1439 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1440 | if (!child->style().hasStaticInlinePosition(style().isHorizontalWritingMode())) |
hyatt@apple.com | e16585a | 2011-02-28 23:21:36 +0000 | [diff] [blame] | 1441 | logicalOffset.setWidth(inlinePosition); |
| 1442 | |
hyatt@apple.com | 76dbdb5 | 2009-01-29 22:49:13 +0000 | [diff] [blame] | 1443 | // This is not terribly intuitive, but we have to match other browsers. Despite being a block display type inside |
| 1444 | // an inline, we still keep our x locked to the left of the relative positioned inline. Arguably the correct |
| 1445 | // behavior would be to go flush left to the block that contains the inline, but that isn't what other browsers |
| 1446 | // do. |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1447 | else if (!child->style().isOriginalDisplayInlineType()) |
hyatt@apple.com | 76dbdb5 | 2009-01-29 22:49:13 +0000 | [diff] [blame] | 1448 | // Avoid adding in the left border/padding of the containing block twice. Subtract it out. |
hyatt@apple.com | e16585a | 2011-02-28 23:21:36 +0000 | [diff] [blame] | 1449 | logicalOffset.setWidth(inlinePosition - child->containingBlock()->borderAndPaddingLogicalLeft()); |
hyatt@apple.com | 76dbdb5 | 2009-01-29 22:49:13 +0000 | [diff] [blame] | 1450 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1451 | if (!child->style().hasStaticBlockPosition(style().isHorizontalWritingMode())) |
hyatt@apple.com | e16585a | 2011-02-28 23:21:36 +0000 | [diff] [blame] | 1452 | logicalOffset.setHeight(blockPosition); |
hyatt@apple.com | 76dbdb5 | 2009-01-29 22:49:13 +0000 | [diff] [blame] | 1453 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1454 | return style().isHorizontalWritingMode() ? logicalOffset : logicalOffset.transposedSize(); |
hyatt@apple.com | 76dbdb5 | 2009-01-29 22:49:13 +0000 | [diff] [blame] | 1455 | } |
| 1456 | |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1457 | void RenderInline::imageChanged(WrappedImagePtr, const IntRect*) |
| 1458 | { |
| 1459 | if (!parent()) |
| 1460 | return; |
| 1461 | |
| 1462 | // FIXME: We can do better. |
| 1463 | repaint(); |
| 1464 | } |
| 1465 | |
wangxianzhu@chromium.org | 64f3829 | 2013-02-28 20:38:23 +0000 | [diff] [blame] | 1466 | void RenderInline::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) |
hyatt@apple.com | 9bfe16c | 2009-01-28 23:44:41 +0000 | [diff] [blame] | 1467 | { |
commit-queue@webkit.org | 39f4e3f | 2012-07-17 03:26:00 +0000 | [diff] [blame] | 1468 | AbsoluteRectsGeneratorContext context(rects, additionalOffset); |
| 1469 | generateLineBoxRects(context); |
hyatt@apple.com | 9bfe16c | 2009-01-28 23:44:41 +0000 | [diff] [blame] | 1470 | |
weinig@apple.com | c77041e | 2013-12-14 18:05:45 +0000 | [diff] [blame] | 1471 | for (auto& child : childrenOfType<RenderElement>(*this)) { |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 1472 | if (is<RenderListMarker>(child)) |
akling@apple.com | 1626ee0 | 2013-11-04 12:55:48 +0000 | [diff] [blame] | 1473 | continue; |
| 1474 | FloatPoint pos(additionalOffset); |
| 1475 | // FIXME: This doesn't work correctly with transforms. |
weinig@apple.com | c77041e | 2013-12-14 18:05:45 +0000 | [diff] [blame] | 1476 | if (child.hasLayer()) |
| 1477 | pos = child.localToContainerPoint(FloatPoint(), paintContainer); |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 1478 | else if (is<RenderBox>(child)) |
| 1479 | pos.move(downcast<RenderBox>(child).locationOffset()); |
weinig@apple.com | c77041e | 2013-12-14 18:05:45 +0000 | [diff] [blame] | 1480 | child.addFocusRingRects(rects, flooredIntPoint(pos), paintContainer); |
hyatt@apple.com | 9bfe16c | 2009-01-28 23:44:41 +0000 | [diff] [blame] | 1481 | } |
| 1482 | |
akling@apple.com | 194c6fc | 2013-09-24 16:20:20 +0000 | [diff] [blame] | 1483 | if (RenderBoxModelObject* continuation = this->continuation()) { |
| 1484 | if (continuation->isInline()) |
zalan@apple.com | b9d20ae | 2014-02-12 20:34:57 +0000 | [diff] [blame] | 1485 | continuation->addFocusRingRects(rects, flooredLayoutPoint(LayoutPoint(additionalOffset + continuation->containingBlock()->location() - containingBlock()->location())), paintContainer); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1486 | else |
cdumez@apple.com | 0abff8b | 2014-10-17 21:25:10 +0000 | [diff] [blame] | 1487 | continuation->addFocusRingRects(rects, flooredLayoutPoint(LayoutPoint(additionalOffset + downcast<RenderBox>(*continuation).location() - containingBlock()->location())), paintContainer); |
hyatt@apple.com | 0d4818f | 2009-02-08 05:39:22 +0000 | [diff] [blame] | 1488 | } |
hyatt@apple.com | 9bfe16c | 2009-01-28 23:44:41 +0000 | [diff] [blame] | 1489 | } |
| 1490 | |
wangxianzhu@chromium.org | 64f3829 | 2013-02-28 20:38:23 +0000 | [diff] [blame] | 1491 | void RenderInline::paintOutline(PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1492 | { |
| 1493 | if (!hasOutline()) |
| 1494 | return; |
dino@apple.com | 6abd334 | 2014-05-07 20:03:13 +0000 | [diff] [blame] | 1495 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1496 | RenderStyle& styleToUse = style(); |
dino@apple.com | c589bac | 2014-05-07 02:58:39 +0000 | [diff] [blame] | 1497 | // Only paint the focus ring by hand if the theme isn't able to draw it. |
achristensen@apple.com | 9fb77fc | 2014-06-25 21:04:17 +0000 | [diff] [blame] | 1498 | if (styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(styleToUse)) |
dino@apple.com | c589bac | 2014-05-07 02:58:39 +0000 | [diff] [blame] | 1499 | paintFocusRing(paintInfo, paintOffset, &styleToUse); |
dino@apple.com | 6abd334 | 2014-05-07 20:03:13 +0000 | [diff] [blame] | 1500 | |
achristensen@apple.com | 9fb77fc | 2014-06-25 21:04:17 +0000 | [diff] [blame] | 1501 | if (hasOutlineAnnotation() && !styleToUse.outlineStyleIsAuto() && !theme().supportsFocusRing(styleToUse)) |
dino@apple.com | c589bac | 2014-05-07 02:58:39 +0000 | [diff] [blame] | 1502 | addPDFURLRect(paintInfo, paintOffset); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1503 | |
wangxianzhu@chromium.org | 64f3829 | 2013-02-28 20:38:23 +0000 | [diff] [blame] | 1504 | GraphicsContext* graphicsContext = paintInfo.context; |
simon.fraser@apple.com | 9650b15 | 2011-05-26 15:34:48 +0000 | [diff] [blame] | 1505 | if (graphicsContext->paintingDisabled()) |
| 1506 | return; |
| 1507 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1508 | if (styleToUse.outlineStyleIsAuto() || styleToUse.outlineStyle() == BNONE) |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1509 | return; |
| 1510 | |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1511 | Vector<LayoutRect> rects; |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1512 | |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1513 | rects.append(LayoutRect()); |
hyatt@apple.com | 9f47d58 | 2010-03-12 20:29:50 +0000 | [diff] [blame] | 1514 | for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { |
akling@apple.com | dbf7030 | 2013-09-09 02:11:06 +0000 | [diff] [blame] | 1515 | const RootInlineBox& rootBox = curr->root(); |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 1516 | LayoutUnit top = std::max<LayoutUnit>(rootBox.lineTop(), curr->logicalTop()); |
| 1517 | LayoutUnit bottom = std::min<LayoutUnit>(rootBox.lineBottom(), curr->logicalBottom()); |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1518 | rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - top)); |
hyatt@apple.com | d42ce1a | 2009-08-21 22:19:51 +0000 | [diff] [blame] | 1519 | } |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1520 | rects.append(LayoutRect()); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1521 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1522 | Color outlineColor = styleToUse.visitedDependentColor(CSSPropertyOutlineColor); |
commit-queue@webkit.org | 550a18c | 2011-05-12 07:04:24 +0000 | [diff] [blame] | 1523 | bool useTransparencyLayer = outlineColor.hasAlpha(); |
| 1524 | if (useTransparencyLayer) { |
| 1525 | graphicsContext->beginTransparencyLayer(static_cast<float>(outlineColor.alpha()) / 255); |
| 1526 | outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineColor.blue()); |
| 1527 | } |
commit-queue@webkit.org | 550a18c | 2011-05-12 07:04:24 +0000 | [diff] [blame] | 1528 | |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1529 | for (unsigned i = 1; i < rects.size() - 1; i++) |
leviw@chromium.org | 07d86ca | 2011-06-06 21:35:56 +0000 | [diff] [blame] | 1530 | paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects.at(i), rects.at(i + 1), outlineColor); |
commit-queue@webkit.org | 550a18c | 2011-05-12 07:04:24 +0000 | [diff] [blame] | 1531 | |
commit-queue@webkit.org | 550a18c | 2011-05-12 07:04:24 +0000 | [diff] [blame] | 1532 | if (useTransparencyLayer) |
| 1533 | graphicsContext->endTransparencyLayer(); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1534 | } |
| 1535 | |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1536 | void RenderInline::paintOutlineForLine(GraphicsContext* graphicsContext, const LayoutPoint& paintOffset, |
| 1537 | const LayoutRect& lastline, const LayoutRect& thisline, const LayoutRect& nextline, |
commit-queue@webkit.org | 550a18c | 2011-05-12 07:04:24 +0000 | [diff] [blame] | 1538 | const Color outlineColor) |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1539 | { |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1540 | const RenderStyle& styleToUse = style(); |
| 1541 | int outlineWidth = styleToUse.outlineWidth(); |
| 1542 | EBorderStyle outlineStyle = styleToUse.outlineStyle(); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1543 | |
darin@apple.com | afab5aa | 2011-09-23 03:00:38 +0000 | [diff] [blame] | 1544 | bool antialias = shouldAntialiasLines(graphicsContext); |
simon.fraser@apple.com | 9650b15 | 2011-05-26 15:34:48 +0000 | [diff] [blame] | 1545 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1546 | int offset = style().outlineOffset(); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1547 | |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1548 | LayoutRect box(LayoutPoint(paintOffset.x() + thisline.x() - offset, paintOffset.y() + thisline.y() - offset), |
| 1549 | LayoutSize(thisline.width() + offset, thisline.height() + offset)); |
| 1550 | |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 1551 | IntRect pixelSnappedBox = snappedIntRect(box); |
rwlbuis@webkit.org | 0be79dc | 2013-08-14 19:14:00 +0000 | [diff] [blame] | 1552 | if (pixelSnappedBox.isEmpty()) |
| 1553 | return; |
zalan@apple.com | 376339c | 2014-08-28 04:24:31 +0000 | [diff] [blame] | 1554 | IntRect pixelSnappedLastLine = snappedIntRect(paintOffset.x() + lastline.x(), 0, lastline.width(), 0); |
| 1555 | IntRect pixelSnappedNextLine = snappedIntRect(paintOffset.x() + nextline.x(), 0, nextline.width(), 0); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1556 | |
| 1557 | // left edge |
hyatt@apple.com | e68a9c0 | 2009-02-12 19:28:24 +0000 | [diff] [blame] | 1558 | drawLineForBoxSide(graphicsContext, |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1559 | pixelSnappedBox.x() - outlineWidth, |
| 1560 | pixelSnappedBox.y() - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : 0), |
| 1561 | pixelSnappedBox.x(), |
| 1562 | pixelSnappedBox.maxY() + (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : 0), |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1563 | BSLeft, |
| 1564 | outlineColor, outlineStyle, |
| 1565 | (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth), |
| 1566 | (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth), |
| 1567 | antialias); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1568 | |
| 1569 | // right edge |
hyatt@apple.com | e68a9c0 | 2009-02-12 19:28:24 +0000 | [diff] [blame] | 1570 | drawLineForBoxSide(graphicsContext, |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1571 | pixelSnappedBox.maxX(), |
| 1572 | pixelSnappedBox.y() - (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : 0), |
| 1573 | pixelSnappedBox.maxX() + outlineWidth, |
| 1574 | pixelSnappedBox.maxY() + (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : 0), |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1575 | BSRight, |
| 1576 | outlineColor, outlineStyle, |
| 1577 | (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : -outlineWidth), |
| 1578 | (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : -outlineWidth), |
| 1579 | antialias); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1580 | // upper edge |
| 1581 | if (thisline.x() < lastline.x()) |
hyatt@apple.com | e68a9c0 | 2009-02-12 19:28:24 +0000 | [diff] [blame] | 1582 | drawLineForBoxSide(graphicsContext, |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1583 | pixelSnappedBox.x() - outlineWidth, |
| 1584 | pixelSnappedBox.y() - outlineWidth, |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 1585 | std::min(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? 1000000 : pixelSnappedLastLine.x())), |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1586 | pixelSnappedBox.y(), |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1587 | BSTop, outlineColor, outlineStyle, |
| 1588 | outlineWidth, |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1589 | (!lastline.isEmpty() && paintOffset.x() + lastline.x() + 1 < pixelSnappedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth, |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1590 | antialias); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1591 | |
hyatt@apple.com | aa0cba0 | 2011-02-01 21:39:47 +0000 | [diff] [blame] | 1592 | if (lastline.maxX() < thisline.maxX()) |
hyatt@apple.com | e68a9c0 | 2009-02-12 19:28:24 +0000 | [diff] [blame] | 1593 | drawLineForBoxSide(graphicsContext, |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 1594 | std::max(lastline.isEmpty() ? -1000000 : pixelSnappedLastLine.maxX(), pixelSnappedBox.x() - outlineWidth), |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1595 | pixelSnappedBox.y() - outlineWidth, |
| 1596 | pixelSnappedBox.maxX() + outlineWidth, |
| 1597 | pixelSnappedBox.y(), |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1598 | BSTop, outlineColor, outlineStyle, |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1599 | (!lastline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOffset.x() + lastline.maxX()) ? -outlineWidth : outlineWidth, |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1600 | outlineWidth, antialias); |
robert@webkit.org | 0ef594d | 2011-09-22 16:14:30 +0000 | [diff] [blame] | 1601 | |
| 1602 | if (thisline.x() == thisline.maxX()) |
| 1603 | drawLineForBoxSide(graphicsContext, |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1604 | pixelSnappedBox.x() - outlineWidth, |
| 1605 | pixelSnappedBox.y() - outlineWidth, |
| 1606 | pixelSnappedBox.maxX() + outlineWidth, |
| 1607 | pixelSnappedBox.y(), |
robert@webkit.org | 0ef594d | 2011-09-22 16:14:30 +0000 | [diff] [blame] | 1608 | BSTop, outlineColor, outlineStyle, |
| 1609 | outlineWidth, |
| 1610 | outlineWidth, |
| 1611 | antialias); |
| 1612 | |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1613 | // lower edge |
| 1614 | if (thisline.x() < nextline.x()) |
hyatt@apple.com | e68a9c0 | 2009-02-12 19:28:24 +0000 | [diff] [blame] | 1615 | drawLineForBoxSide(graphicsContext, |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1616 | pixelSnappedBox.x() - outlineWidth, |
| 1617 | pixelSnappedBox.maxY(), |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 1618 | std::min(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? pixelSnappedNextLine.x() + 1 : 1000000), |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1619 | pixelSnappedBox.maxY() + outlineWidth, |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1620 | BSBottom, outlineColor, outlineStyle, |
| 1621 | outlineWidth, |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1622 | (!nextline.isEmpty() && paintOffset.x() + nextline.x() + 1 < pixelSnappedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth, |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1623 | antialias); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1624 | |
hyatt@apple.com | aa0cba0 | 2011-02-01 21:39:47 +0000 | [diff] [blame] | 1625 | if (nextline.maxX() < thisline.maxX()) |
hyatt@apple.com | e68a9c0 | 2009-02-12 19:28:24 +0000 | [diff] [blame] | 1626 | drawLineForBoxSide(graphicsContext, |
andersca@apple.com | 8629863 | 2013-11-10 19:32:33 +0000 | [diff] [blame] | 1627 | std::max(!nextline.isEmpty() ? pixelSnappedNextLine.maxX() : -1000000, pixelSnappedBox.x() - outlineWidth), |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1628 | pixelSnappedBox.maxY(), |
| 1629 | pixelSnappedBox.maxX() + outlineWidth, |
| 1630 | pixelSnappedBox.maxY() + outlineWidth, |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1631 | BSBottom, outlineColor, outlineStyle, |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1632 | (!nextline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOffset.x() + nextline.maxX()) ? -outlineWidth : outlineWidth, |
leviw@chromium.org | 890e9b0 | 2011-07-07 23:17:55 +0000 | [diff] [blame] | 1633 | outlineWidth, antialias); |
robert@webkit.org | 0ef594d | 2011-09-22 16:14:30 +0000 | [diff] [blame] | 1634 | |
| 1635 | if (thisline.x() == thisline.maxX()) |
| 1636 | drawLineForBoxSide(graphicsContext, |
leviw@chromium.org | c38fcdf | 2012-02-24 03:55:53 +0000 | [diff] [blame] | 1637 | pixelSnappedBox.x() - outlineWidth, |
| 1638 | pixelSnappedBox.maxY(), |
| 1639 | pixelSnappedBox.maxX() + outlineWidth, |
| 1640 | pixelSnappedBox.maxY() + outlineWidth, |
robert@webkit.org | 0ef594d | 2011-09-22 16:14:30 +0000 | [diff] [blame] | 1641 | BSBottom, outlineColor, outlineStyle, |
| 1642 | outlineWidth, |
| 1643 | outlineWidth, |
| 1644 | antialias); |
hyatt@apple.com | ced257d | 2009-01-29 01:33:16 +0000 | [diff] [blame] | 1645 | } |
| 1646 | |
commit-queue@webkit.org | 85192c5 | 2014-01-26 06:25:55 +0000 | [diff] [blame] | 1647 | #if ENABLE(DASHBOARD_SUPPORT) |
jianli@chromium.org | bd81dfe | 2012-10-10 00:06:59 +0000 | [diff] [blame] | 1648 | void RenderInline::addAnnotatedRegions(Vector<AnnotatedRegionValue>& regions) |
bdakin@apple.com | e3d43bb | 2009-02-05 00:19:31 +0000 | [diff] [blame] | 1649 | { |
| 1650 | // Convert the style regions to absolute coordinates. |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1651 | if (style().visibility() != VISIBLE) |
bdakin@apple.com | e3d43bb | 2009-02-05 00:19:31 +0000 | [diff] [blame] | 1652 | return; |
| 1653 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 1654 | const Vector<StyleDashboardRegion>& styleRegions = style().dashboardRegions(); |
bdakin@apple.com | e3d43bb | 2009-02-05 00:19:31 +0000 | [diff] [blame] | 1655 | unsigned i, count = styleRegions.size(); |
| 1656 | for (i = 0; i < count; i++) { |
| 1657 | StyleDashboardRegion styleRegion = styleRegions[i]; |
| 1658 | |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 1659 | LayoutRect linesBoundingBox = this->linesBoundingBox(); |
| 1660 | LayoutUnit w = linesBoundingBox.width(); |
| 1661 | LayoutUnit h = linesBoundingBox.height(); |
bdakin@apple.com | e3d43bb | 2009-02-05 00:19:31 +0000 | [diff] [blame] | 1662 | |
jianli@chromium.org | bd81dfe | 2012-10-10 00:06:59 +0000 | [diff] [blame] | 1663 | AnnotatedRegionValue region; |
bdakin@apple.com | e3d43bb | 2009-02-05 00:19:31 +0000 | [diff] [blame] | 1664 | region.label = styleRegion.label; |
leviw@chromium.org | fc30023 | 2011-08-18 19:23:22 +0000 | [diff] [blame] | 1665 | region.bounds = LayoutRect(linesBoundingBox.x() + styleRegion.offset.left().value(), |
bdakin@apple.com | e3d43bb | 2009-02-05 00:19:31 +0000 | [diff] [blame] | 1666 | linesBoundingBox.y() + styleRegion.offset.top().value(), |
| 1667 | w - styleRegion.offset.left().value() - styleRegion.offset.right().value(), |
| 1668 | h - styleRegion.offset.top().value() - styleRegion.offset.bottom().value()); |
| 1669 | region.type = styleRegion.type; |
| 1670 | |
| 1671 | RenderObject* container = containingBlock(); |
| 1672 | if (!container) |
| 1673 | container = this; |
| 1674 | |
| 1675 | region.clip = region.bounds; |
| 1676 | container->computeAbsoluteRepaintRect(region.clip); |
| 1677 | if (region.clip.height() < 0) { |
| 1678 | region.clip.setHeight(0); |
| 1679 | region.clip.setWidth(0); |
| 1680 | } |
| 1681 | |
| 1682 | FloatPoint absPos = container->localToAbsolute(); |
| 1683 | region.bounds.setX(absPos.x() + region.bounds.x()); |
| 1684 | region.bounds.setY(absPos.y() + region.bounds.y()); |
| 1685 | |
bdakin@apple.com | e3d43bb | 2009-02-05 00:19:31 +0000 | [diff] [blame] | 1686 | regions.append(region); |
| 1687 | } |
| 1688 | } |
| 1689 | #endif |
| 1690 | |
weinig | c24ab18 | 2006-10-30 22:41:29 +0000 | [diff] [blame] | 1691 | } // namespace WebCore |