| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 static LayoutObject* inFlowPositionedInlineAncestor(LayoutObject* p) | 145 static LayoutObject* inFlowPositionedInlineAncestor(LayoutObject* p) |
| 146 { | 146 { |
| 147 while (p && p->isLayoutInline()) { | 147 while (p && p->isLayoutInline()) { |
| 148 if (p->isRelPositioned()) | 148 if (p->isRelPositioned()) |
| 149 return p; | 149 return p; |
| 150 p = p->parent(); | 150 p = p->parent(); |
| 151 } | 151 } |
| 152 return 0; | 152 return 0; |
| 153 } | 153 } |
| 154 | 154 |
| 155 static void updateStyleOfAnonymousBlockContinuations(LayoutObject* block, const
LayoutStyle& newStyle, const LayoutStyle& oldStyle) | 155 static void updateStyleOfAnonymousBlockContinuations(LayoutObject* block, const
ComputedStyle& newStyle, const ComputedStyle& oldStyle) |
| 156 { | 156 { |
| 157 for (;block && block->isAnonymousBlock(); block = block->nextSibling()) { | 157 for (;block && block->isAnonymousBlock(); block = block->nextSibling()) { |
| 158 if (!toLayoutBlock(block)->isAnonymousBlockContinuation()) | 158 if (!toLayoutBlock(block)->isAnonymousBlockContinuation()) |
| 159 continue; | 159 continue; |
| 160 | 160 |
| 161 RefPtr<LayoutStyle> newBlockStyle; | 161 RefPtr<ComputedStyle> newBlockStyle; |
| 162 | 162 |
| 163 if (!block->style()->isOutlineEquivalent(&newStyle)) { | 163 if (!block->style()->isOutlineEquivalent(&newStyle)) { |
| 164 newBlockStyle = LayoutStyle::clone(block->styleRef()); | 164 newBlockStyle = ComputedStyle::clone(block->styleRef()); |
| 165 newBlockStyle->setOutlineFromStyle(newStyle); | 165 newBlockStyle->setOutlineFromStyle(newStyle); |
| 166 } | 166 } |
| 167 | 167 |
| 168 if (block->style()->position() != newStyle.position()) { | 168 if (block->style()->position() != newStyle.position()) { |
| 169 // If we are no longer in-flow positioned but our descendant block(s
) still have an in-flow positioned ancestor then | 169 // If we are no longer in-flow positioned but our descendant block(s
) still have an in-flow positioned ancestor then |
| 170 // their containing anonymous block should keep its in-flow position
ing. | 170 // their containing anonymous block should keep its in-flow position
ing. |
| 171 if (oldStyle.hasInFlowPosition() | 171 if (oldStyle.hasInFlowPosition() |
| 172 && inFlowPositionedInlineAncestor(toLayoutBlock(block)->inlineEl
ementContinuation())) | 172 && inFlowPositionedInlineAncestor(toLayoutBlock(block)->inlineEl
ementContinuation())) |
| 173 continue; | 173 continue; |
| 174 if (!newBlockStyle) | 174 if (!newBlockStyle) |
| 175 newBlockStyle = LayoutStyle::clone(block->styleRef()); | 175 newBlockStyle = ComputedStyle::clone(block->styleRef()); |
| 176 newBlockStyle->setPosition(newStyle.position()); | 176 newBlockStyle->setPosition(newStyle.position()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 if (newBlockStyle) | 179 if (newBlockStyle) |
| 180 block->setStyle(newBlockStyle); | 180 block->setStyle(newBlockStyle); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 void LayoutInline::styleDidChange(StyleDifference diff, const LayoutStyle* oldSt
yle) | 184 void LayoutInline::styleDidChange(StyleDifference diff, const ComputedStyle* old
Style) |
| 185 { | 185 { |
| 186 LayoutBoxModelObject::styleDidChange(diff, oldStyle); | 186 LayoutBoxModelObject::styleDidChange(diff, oldStyle); |
| 187 | 187 |
| 188 // Ensure that all of the split inlines pick up the new style. We | 188 // Ensure that all of the split inlines pick up the new style. We |
| 189 // only do this if we're an inline, since we don't want to propagate | 189 // only do this if we're an inline, since we don't want to propagate |
| 190 // a block's style to the other inlines. | 190 // a block's style to the other inlines. |
| 191 // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before | 191 // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before |
| 192 // and after the block share the same style, but the block doesn't | 192 // and after the block share the same style, but the block doesn't |
| 193 // need to pass its style on to anyone else. | 193 // need to pass its style on to anyone else. |
| 194 const LayoutStyle& newStyle = styleRef(); | 194 const ComputedStyle& newStyle = styleRef(); |
| 195 LayoutInline* continuation = inlineElementContinuation(); | 195 LayoutInline* continuation = inlineElementContinuation(); |
| 196 for (LayoutInline* currCont = continuation; currCont; currCont = currCont->i
nlineElementContinuation()) { | 196 for (LayoutInline* currCont = continuation; currCont; currCont = currCont->i
nlineElementContinuation()) { |
| 197 LayoutBoxModelObject* nextCont = currCont->continuation(); | 197 LayoutBoxModelObject* nextCont = currCont->continuation(); |
| 198 currCont->setContinuation(0); | 198 currCont->setContinuation(0); |
| 199 currCont->setStyle(style()); | 199 currCont->setStyle(style()); |
| 200 currCont->setContinuation(nextCont); | 200 currCont->setContinuation(nextCont); |
| 201 } | 201 } |
| 202 | 202 |
| 203 // If an inline's outline or in-flow positioning has changed then any descen
dant blocks will need to change their styles accordingly. | 203 // If an inline's outline or in-flow positioning has changed then any descen
dant blocks will need to change their styles accordingly. |
| 204 // Do this by updating the styles of the descendant blocks' containing anony
mous blocks - there may be more than one. | 204 // Do this by updating the styles of the descendant blocks' containing anony
mous blocks - there may be more than one. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 void LayoutInline::updateAlwaysCreateLineBoxes(bool fullLayout) | 224 void LayoutInline::updateAlwaysCreateLineBoxes(bool fullLayout) |
| 225 { | 225 { |
| 226 // Once we have been tainted once, just assume it will happen again. This wa
y effects like hover highlighting that change the | 226 // Once we have been tainted once, just assume it will happen again. This wa
y effects like hover highlighting that change the |
| 227 // background color will only cause a layout on the first rollover. | 227 // background color will only cause a layout on the first rollover. |
| 228 if (alwaysCreateLineBoxes()) | 228 if (alwaysCreateLineBoxes()) |
| 229 return; | 229 return; |
| 230 | 230 |
| 231 const LayoutStyle& parentStyle = parent()->styleRef(); | 231 const ComputedStyle& parentStyle = parent()->styleRef(); |
| 232 LayoutInline* parentLayoutInline = parent()->isLayoutInline() ? toLayoutInli
ne(parent()) : 0; | 232 LayoutInline* parentLayoutInline = parent()->isLayoutInline() ? toLayoutInli
ne(parent()) : 0; |
| 233 bool checkFonts = document().inNoQuirksMode(); | 233 bool checkFonts = document().inNoQuirksMode(); |
| 234 bool alwaysCreateLineBoxesNew = (parentLayoutInline && parentLayoutInline->a
lwaysCreateLineBoxes()) | 234 bool alwaysCreateLineBoxesNew = (parentLayoutInline && parentLayoutInline->a
lwaysCreateLineBoxes()) |
| 235 || (parentLayoutInline && parentStyle.verticalAlign() != BASELINE) | 235 || (parentLayoutInline && parentStyle.verticalAlign() != BASELINE) |
| 236 || style()->verticalAlign() != BASELINE | 236 || style()->verticalAlign() != BASELINE |
| 237 || style()->textEmphasisMark() != TextEmphasisMarkNone | 237 || style()->textEmphasisMark() != TextEmphasisMarkNone |
| 238 || (checkFonts && (!parentStyle.font().fontMetrics().hasIdenticalAscentD
escentAndLineGap(style()->font().fontMetrics()) | 238 || (checkFonts && (!parentStyle.font().fontMetrics().hasIdenticalAscentD
escentAndLineGap(style()->font().fontMetrics()) |
| 239 || parentStyle.lineHeight() != style()->lineHeight())); | 239 || parentStyle.lineHeight() != style()->lineHeight())); |
| 240 | 240 |
| 241 if (!alwaysCreateLineBoxesNew && checkFonts && document().styleEngine().uses
FirstLineRules()) { | 241 if (!alwaysCreateLineBoxesNew && checkFonts && document().styleEngine().uses
FirstLineRules()) { |
| 242 // Have to check the first line style as well. | 242 // Have to check the first line style as well. |
| 243 const LayoutStyle& firstLineParentStyle = parent()->styleRef(true); | 243 const ComputedStyle& firstLineParentStyle = parent()->styleRef(true); |
| 244 const LayoutStyle& childStyle = styleRef(true); | 244 const ComputedStyle& childStyle = styleRef(true); |
| 245 alwaysCreateLineBoxesNew = !firstLineParentStyle.font().fontMetrics().ha
sIdenticalAscentDescentAndLineGap(childStyle.font().fontMetrics()) | 245 alwaysCreateLineBoxesNew = !firstLineParentStyle.font().fontMetrics().ha
sIdenticalAscentDescentAndLineGap(childStyle.font().fontMetrics()) |
| 246 || childStyle.verticalAlign() != BASELINE | 246 || childStyle.verticalAlign() != BASELINE |
| 247 || firstLineParentStyle.lineHeight() != childStyle.lineHeight(); | 247 || firstLineParentStyle.lineHeight() != childStyle.lineHeight(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 if (alwaysCreateLineBoxesNew) { | 250 if (alwaysCreateLineBoxesNew) { |
| 251 if (!fullLayout) | 251 if (!fullLayout) |
| 252 dirtyLineBoxes(false); | 252 dirtyLineBoxes(false); |
| 253 setAlwaysCreateLineBoxes(); | 253 setAlwaysCreateLineBoxes(); |
| 254 } | 254 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 { | 324 { |
| 325 // Make sure we don't append things after :after-generated content if we hav
e it. | 325 // Make sure we don't append things after :after-generated content if we hav
e it. |
| 326 if (!beforeChild && isAfterContent(lastChild())) | 326 if (!beforeChild && isAfterContent(lastChild())) |
| 327 beforeChild = lastChild(); | 327 beforeChild = lastChild(); |
| 328 | 328 |
| 329 if (!newChild->isInline() && !newChild->isFloatingOrOutOfFlowPositioned()) { | 329 if (!newChild->isInline() && !newChild->isFloatingOrOutOfFlowPositioned()) { |
| 330 // We are placing a block inside an inline. We have to perform a split o
f this | 330 // We are placing a block inside an inline. We have to perform a split o
f this |
| 331 // inline into continuations. This involves creating an anonymous block
box to hold | 331 // inline into continuations. This involves creating an anonymous block
box to hold |
| 332 // |newChild|. We then make that block box a continuation of this inlin
e. We take all of | 332 // |newChild|. We then make that block box a continuation of this inlin
e. We take all of |
| 333 // the children after |beforeChild| and put them in a clone of this obje
ct. | 333 // the children after |beforeChild| and put them in a clone of this obje
ct. |
| 334 RefPtr<LayoutStyle> newStyle = LayoutStyle::createAnonymousStyleWithDisp
lay(styleRef(), BLOCK); | 334 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWith
Display(styleRef(), BLOCK); |
| 335 | 335 |
| 336 // If inside an inline affected by in-flow positioning the block needs t
o be affected by it too. | 336 // If inside an inline affected by in-flow positioning the block needs t
o be affected by it too. |
| 337 // Giving the block a layer like this allows it to collect the x/y offse
ts from inline parents later. | 337 // Giving the block a layer like this allows it to collect the x/y offse
ts from inline parents later. |
| 338 if (LayoutObject* positionedAncestor = inFlowPositionedInlineAncestor(th
is)) | 338 if (LayoutObject* positionedAncestor = inFlowPositionedInlineAncestor(th
is)) |
| 339 newStyle->setPosition(positionedAncestor->style()->position()); | 339 newStyle->setPosition(positionedAncestor->style()->position()); |
| 340 | 340 |
| 341 // Push outline style to the block continuation. | 341 // Push outline style to the block continuation. |
| 342 if (!newStyle->isOutlineEquivalent(style())) | 342 if (!newStyle->isOutlineEquivalent(style())) |
| 343 newStyle->setOutlineFromStyle(*style()); | 343 newStyle->setOutlineFromStyle(*style()); |
| 344 | 344 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 LayoutUnit LayoutInline::marginTop() const | 749 LayoutUnit LayoutInline::marginTop() const |
| 750 { | 750 { |
| 751 return computeMargin(this, style()->marginTop()); | 751 return computeMargin(this, style()->marginTop()); |
| 752 } | 752 } |
| 753 | 753 |
| 754 LayoutUnit LayoutInline::marginBottom() const | 754 LayoutUnit LayoutInline::marginBottom() const |
| 755 { | 755 { |
| 756 return computeMargin(this, style()->marginBottom()); | 756 return computeMargin(this, style()->marginBottom()); |
| 757 } | 757 } |
| 758 | 758 |
| 759 LayoutUnit LayoutInline::marginStart(const LayoutStyle* otherStyle) const | 759 LayoutUnit LayoutInline::marginStart(const ComputedStyle* otherStyle) const |
| 760 { | 760 { |
| 761 return computeMargin(this, style()->marginStartUsing(otherStyle ? otherStyle
: style())); | 761 return computeMargin(this, style()->marginStartUsing(otherStyle ? otherStyle
: style())); |
| 762 } | 762 } |
| 763 | 763 |
| 764 LayoutUnit LayoutInline::marginEnd(const LayoutStyle* otherStyle) const | 764 LayoutUnit LayoutInline::marginEnd(const ComputedStyle* otherStyle) const |
| 765 { | 765 { |
| 766 return computeMargin(this, style()->marginEndUsing(otherStyle ? otherStyle :
style())); | 766 return computeMargin(this, style()->marginEndUsing(otherStyle ? otherStyle :
style())); |
| 767 } | 767 } |
| 768 | 768 |
| 769 LayoutUnit LayoutInline::marginBefore(const LayoutStyle* otherStyle) const | 769 LayoutUnit LayoutInline::marginBefore(const ComputedStyle* otherStyle) const |
| 770 { | 770 { |
| 771 return computeMargin(this, style()->marginBeforeUsing(otherStyle ? otherStyl
e : style())); | 771 return computeMargin(this, style()->marginBeforeUsing(otherStyle ? otherStyl
e : style())); |
| 772 } | 772 } |
| 773 | 773 |
| 774 LayoutUnit LayoutInline::marginAfter(const LayoutStyle* otherStyle) const | 774 LayoutUnit LayoutInline::marginAfter(const ComputedStyle* otherStyle) const |
| 775 { | 775 { |
| 776 return computeMargin(this, style()->marginAfterUsing(otherStyle ? otherStyle
: style())); | 776 return computeMargin(this, style()->marginAfterUsing(otherStyle ? otherStyle
: style())); |
| 777 } | 777 } |
| 778 | 778 |
| 779 const char* LayoutInline::name() const | 779 const char* LayoutInline::name() const |
| 780 { | 780 { |
| 781 if (isRelPositioned()) | 781 if (isRelPositioned()) |
| 782 return "LayoutInline (relative positioned)"; | 782 return "LayoutInline (relative positioned)"; |
| 783 if (isAnonymous()) | 783 if (isAnonymous()) |
| 784 return "LayoutInline (anonymous)"; | 784 return "LayoutInline (anonymous)"; |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 { | 1307 { |
| 1308 setAlwaysCreateLineBoxes(); | 1308 setAlwaysCreateLineBoxes(); |
| 1309 InlineFlowBox* flowBox = createInlineFlowBox(); | 1309 InlineFlowBox* flowBox = createInlineFlowBox(); |
| 1310 m_lineBoxes.appendLineBox(flowBox); | 1310 m_lineBoxes.appendLineBox(flowBox); |
| 1311 return flowBox; | 1311 return flowBox; |
| 1312 } | 1312 } |
| 1313 | 1313 |
| 1314 LayoutUnit LayoutInline::lineHeight(bool firstLine, LineDirectionMode /*directio
n*/, LinePositionMode /*linePositionMode*/) const | 1314 LayoutUnit LayoutInline::lineHeight(bool firstLine, LineDirectionMode /*directio
n*/, LinePositionMode /*linePositionMode*/) const |
| 1315 { | 1315 { |
| 1316 if (firstLine && document().styleEngine().usesFirstLineRules()) { | 1316 if (firstLine && document().styleEngine().usesFirstLineRules()) { |
| 1317 const LayoutStyle* s = style(firstLine); | 1317 const ComputedStyle* s = style(firstLine); |
| 1318 if (s != style()) | 1318 if (s != style()) |
| 1319 return s->computedLineHeight(); | 1319 return s->computedLineHeight(); |
| 1320 } | 1320 } |
| 1321 | 1321 |
| 1322 return style()->computedLineHeight(); | 1322 return style()->computedLineHeight(); |
| 1323 } | 1323 } |
| 1324 | 1324 |
| 1325 int LayoutInline::baselinePosition(FontBaseline baselineType, bool firstLine, Li
neDirectionMode direction, LinePositionMode linePositionMode) const | 1325 int LayoutInline::baselinePosition(FontBaseline baselineType, bool firstLine, Li
neDirectionMode direction, LinePositionMode linePositionMode) const |
| 1326 { | 1326 { |
| 1327 ASSERT(linePositionMode == PositionOnContainingLine); | 1327 ASSERT(linePositionMode == PositionOnContainingLine); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 } | 1455 } |
| 1456 | 1456 |
| 1457 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain
tInvalidationContainer) const | 1457 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain
tInvalidationContainer) const |
| 1458 { | 1458 { |
| 1459 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine
r); | 1459 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine
r); |
| 1460 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) | 1460 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) |
| 1461 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); | 1461 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 } // namespace blink | 1464 } // namespace blink |
| OLD | NEW |