Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: Source/core/rendering/RenderInline.cpp

Issue 889563002: Make RenderObject::style() return a const object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Blind fix for Mac. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle) 189 void RenderInline::styleDidChange(StyleDifference diff, const RenderStyle* oldSt yle)
190 { 190 {
191 RenderBoxModelObject::styleDidChange(diff, oldStyle); 191 RenderBoxModelObject::styleDidChange(diff, oldStyle);
192 192
193 // Ensure that all of the split inlines pick up the new style. We 193 // Ensure that all of the split inlines pick up the new style. We
194 // only do this if we're an inline, since we don't want to propagate 194 // only do this if we're an inline, since we don't want to propagate
195 // a block's style to the other inlines. 195 // a block's style to the other inlines.
196 // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before 196 // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before
197 // and after the block share the same style, but the block doesn't 197 // and after the block share the same style, but the block doesn't
198 // need to pass its style on to anyone else. 198 // need to pass its style on to anyone else.
199 RenderStyle* newStyle = style(); 199 // FIXME: For setStyle below.
200 RenderStyle* newStyle = deprecatedMutableStyle();
200 RenderInline* continuation = inlineElementContinuation(); 201 RenderInline* continuation = inlineElementContinuation();
201 for (RenderInline* currCont = continuation; currCont; currCont = currCont->i nlineElementContinuation()) { 202 for (RenderInline* currCont = continuation; currCont; currCont = currCont->i nlineElementContinuation()) {
202 RenderBoxModelObject* nextCont = currCont->continuation(); 203 RenderBoxModelObject* nextCont = currCont->continuation();
203 currCont->setContinuation(0); 204 currCont->setContinuation(0);
204 currCont->setStyle(newStyle); 205 currCont->setStyle(newStyle);
205 currCont->setContinuation(nextCont); 206 currCont->setContinuation(nextCont);
206 } 207 }
207 208
208 // If an inline's outline or in-flow positioning has changed then any descen dant blocks will need to change their styles accordingly. 209 // If an inline's outline or in-flow positioning has changed then any descen dant blocks will need to change their styles accordingly.
209 // Do this by updating the styles of the descendant blocks' containing anony mous blocks - there may be more than one. 210 // 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
226 } 227 }
227 } 228 }
228 229
229 void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout) 230 void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout)
230 { 231 {
231 // Once we have been tainted once, just assume it will happen again. This wa y effects like hover highlighting that change the 232 // Once we have been tainted once, just assume it will happen again. This wa y effects like hover highlighting that change the
232 // background color will only cause a layout on the first rollover. 233 // background color will only cause a layout on the first rollover.
233 if (alwaysCreateLineBoxes()) 234 if (alwaysCreateLineBoxes())
234 return; 235 return;
235 236
236 RenderStyle* parentStyle = parent()->style(); 237 const RenderStyle* parentStyle = parent()->style();
237 RenderInline* parentRenderInline = parent()->isRenderInline() ? toRenderInli ne(parent()) : 0; 238 RenderInline* parentRenderInline = parent()->isRenderInline() ? toRenderInli ne(parent()) : 0;
238 bool checkFonts = document().inNoQuirksMode(); 239 bool checkFonts = document().inNoQuirksMode();
239 bool alwaysCreateLineBoxesNew = (parentRenderInline && parentRenderInline->a lwaysCreateLineBoxes()) 240 bool alwaysCreateLineBoxesNew = (parentRenderInline && parentRenderInline->a lwaysCreateLineBoxes())
240 || (parentRenderInline && parentStyle->verticalAlign() != BASELINE) 241 || (parentRenderInline && parentStyle->verticalAlign() != BASELINE)
241 || style()->verticalAlign() != BASELINE 242 || style()->verticalAlign() != BASELINE
242 || style()->textEmphasisMark() != TextEmphasisMarkNone 243 || style()->textEmphasisMark() != TextEmphasisMarkNone
243 || (checkFonts && (!parentStyle->font().fontMetrics().hasIdenticalAscent DescentAndLineGap(style()->font().fontMetrics()) 244 || (checkFonts && (!parentStyle->font().fontMetrics().hasIdenticalAscent DescentAndLineGap(style()->font().fontMetrics())
244 || parentStyle->lineHeight() != style()->lineHeight())); 245 || parentStyle->lineHeight() != style()->lineHeight()));
245 246
246 if (!alwaysCreateLineBoxesNew && checkFonts && document().styleEngine()->use sFirstLineRules()) { 247 if (!alwaysCreateLineBoxesNew && checkFonts && document().styleEngine()->use sFirstLineRules()) {
247 // Have to check the first line style as well. 248 // Have to check the first line style as well.
248 parentStyle = parent()->style(true); 249 parentStyle = parent()->style(true);
249 RenderStyle* childStyle = style(true); 250 const RenderStyle* childStyle = style(true);
250 alwaysCreateLineBoxesNew = !parentStyle->font().fontMetrics().hasIdentic alAscentDescentAndLineGap(childStyle->font().fontMetrics()) 251 alwaysCreateLineBoxesNew = !parentStyle->font().fontMetrics().hasIdentic alAscentDescentAndLineGap(childStyle->font().fontMetrics())
251 || childStyle->verticalAlign() != BASELINE 252 || childStyle->verticalAlign() != BASELINE
252 || parentStyle->lineHeight() != childStyle->lineHeight(); 253 || parentStyle->lineHeight() != childStyle->lineHeight();
253 } 254 }
254 255
255 if (alwaysCreateLineBoxesNew) { 256 if (alwaysCreateLineBoxesNew) {
256 if (!fullLayout) 257 if (!fullLayout)
257 dirtyLineBoxes(false); 258 dirtyLineBoxes(false);
258 setAlwaysCreateLineBoxes(); 259 setAlwaysCreateLineBoxes();
259 } 260 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 358 }
358 359
359 RenderBoxModelObject::addChild(newChild, beforeChild); 360 RenderBoxModelObject::addChild(newChild, beforeChild);
360 361
361 newChild->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 362 newChild->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
362 } 363 }
363 364
364 RenderInline* RenderInline::clone() const 365 RenderInline* RenderInline::clone() const
365 { 366 {
366 RenderInline* cloneInline = new RenderInline(node()); 367 RenderInline* cloneInline = new RenderInline(node());
367 cloneInline->setStyle(style()); 368 cloneInline->setStyle(deprecatedMutableStyle());
368 cloneInline->setFlowThreadState(flowThreadState()); 369 cloneInline->setFlowThreadState(flowThreadState());
369 return cloneInline; 370 return cloneInline;
370 } 371 }
371 372
372 void RenderInline::moveChildrenToIgnoringContinuation(RenderInline* to, RenderOb ject* startChild) 373 void RenderInline::moveChildrenToIgnoringContinuation(RenderInline* to, RenderOb ject* startChild)
373 { 374 {
374 RenderObject* child = startChild; 375 RenderObject* child = startChild;
375 while (child) { 376 while (child) {
376 RenderObject* currentChild = child; 377 RenderObject* currentChild = child;
377 child = currentChild->nextSibling(); 378 child = currentChild->nextSibling();
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 { 1310 {
1310 setAlwaysCreateLineBoxes(); 1311 setAlwaysCreateLineBoxes();
1311 InlineFlowBox* flowBox = createInlineFlowBox(); 1312 InlineFlowBox* flowBox = createInlineFlowBox();
1312 m_lineBoxes.appendLineBox(flowBox); 1313 m_lineBoxes.appendLineBox(flowBox);
1313 return flowBox; 1314 return flowBox;
1314 } 1315 }
1315 1316
1316 LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*directio n*/, LinePositionMode /*linePositionMode*/) const 1317 LayoutUnit RenderInline::lineHeight(bool firstLine, LineDirectionMode /*directio n*/, LinePositionMode /*linePositionMode*/) const
1317 { 1318 {
1318 if (firstLine && document().styleEngine()->usesFirstLineRules()) { 1319 if (firstLine && document().styleEngine()->usesFirstLineRules()) {
1319 RenderStyle* s = style(firstLine); 1320 const RenderStyle* s = style(firstLine);
1320 if (s != style()) 1321 if (s != style())
1321 return s->computedLineHeight(); 1322 return s->computedLineHeight();
1322 } 1323 }
1323 1324
1324 return style()->computedLineHeight(); 1325 return style()->computedLineHeight();
1325 } 1326 }
1326 1327
1327 int RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, Li neDirectionMode direction, LinePositionMode linePositionMode) const 1328 int RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, Li neDirectionMode direction, LinePositionMode linePositionMode) const
1328 { 1329 {
1329 ASSERT(linePositionMode == PositionOnContainingLine); 1330 ASSERT(linePositionMode == PositionOnContainingLine);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 container = this; 1451 container = this;
1451 1452
1452 FloatPoint absPos = container->localToAbsolute(); 1453 FloatPoint absPos = container->localToAbsolute();
1453 region.bounds.setX(absPos.x() + region.bounds.x()); 1454 region.bounds.setX(absPos.x() + region.bounds.x());
1454 region.bounds.setY(absPos.y() + region.bounds.y()); 1455 region.bounds.setY(absPos.y() + region.bounds.y());
1455 1456
1456 regions.append(region); 1457 regions.append(region);
1457 } 1458 }
1458 1459
1459 } // namespace blink 1460 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698