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

Side by Side Diff: sky/engine/core/rendering/style/RenderStyle.cpp

Issue 851203003: Merge diffNeedsFullLayout methods. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/core/rendering/style/RenderStyle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 4 * Copyright (C) 2011 Adobe Systems Incorporated. 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 279 }
280 280
281 StyleDifference RenderStyle::visualInvalidationDiff(const RenderStyle& other) co nst 281 StyleDifference RenderStyle::visualInvalidationDiff(const RenderStyle& other) co nst
282 { 282 {
283 // Note, we use .get() on each DataRef below because DataRef::operator== wil l do a deep 283 // Note, we use .get() on each DataRef below because DataRef::operator== wil l do a deep
284 // compare, which is duplicate work when we're going to compare each propert y inside 284 // compare, which is duplicate work when we're going to compare each propert y inside
285 // this function anyway. 285 // this function anyway.
286 286
287 StyleDifference diff; 287 StyleDifference diff;
288 288
289 // FIXME(sky): Combine these two into one function call. 289 if (diffNeedsFullLayout(other)) {
290 if (diffNeedsFullLayoutAndPaintInvalidation(other)
291 || diffNeedsFullLayout(other))
292 diff.setNeedsFullLayout(); 290 diff.setNeedsFullLayout();
293 291 } else if (position() != StaticPosition && surround->offset != other.surroun d->offset) {
294 if (!diff.needsFullLayout() && position() != StaticPosition && surround->off set != other.surround->offset) {
295 // Optimize for the case where a positioned layer is moving but not chan ging size. 292 // Optimize for the case where a positioned layer is moving but not chan ging size.
296 if (positionedObjectMovedOnly(surround->offset, other.surround->offset, m_box->width())) 293 if (positionedObjectMovedOnly(surround->offset, other.surround->offset, m_box->width()))
297 diff.setNeedsPositionedMovementLayout(); 294 diff.setNeedsPositionedMovementLayout();
298 else 295 else
299 diff.setNeedsFullLayout(); 296 diff.setNeedsFullLayout();
300 } 297 }
301 298
302 updatePropertySpecificDifferences(other, diff); 299 updatePropertySpecificDifferences(other, diff);
303 300
304 // Cursors are not checked, since they will be set appropriately in response to mouse events, 301 // Cursors are not checked, since they will be set appropriately in response to mouse events,
305 // so they don't need to cause any paint invalidation or layout. 302 // so they don't need to cause any paint invalidation or layout.
306 303
307 // Animations don't need to be checked either. We always set the new style o n the RenderObject, so we will get a chance to fire off 304 // Animations don't need to be checked either. We always set the new style o n the RenderObject, so we will get a chance to fire off
308 // the resulting transition properly. 305 // the resulting transition properly.
309 306
310 return diff; 307 return diff;
311 } 308 }
312 309
313 bool RenderStyle::diffNeedsFullLayoutAndPaintInvalidation(const RenderStyle& oth er) const 310 bool RenderStyle::diffNeedsFullLayout(const RenderStyle& other) const
314 { 311 {
315 // FIXME: Not all cases in this method need both full layout and paint inval idation. 312 // FIXME: Not all cases in this method need both full layout and paint inval idation.
316 // Should move cases into diffNeedsFullLayout() if 313 // Should move cases into diffNeedsFullLayout() if
317 // - don't need paint invalidation at all; 314 // - don't need paint invalidation at all;
318 // - or the renderer knows how to exactly invalidate paints caused by the la yout change 315 // - or the renderer knows how to exactly invalidate paints caused by the la yout change
319 // instead of forced full paint invalidation. 316 // instead of forced full paint invalidation.
320 317
321 if (surround.get() != other.surround.get()) { 318 if (surround.get() != other.surround.get()) {
322 // If our border widths change, then we need to layout. Other changes to borders only necessitate a paint invalidation. 319 // If our border widths change, then we need to layout. Other changes to borders only necessitate a paint invalidation.
323 if (borderLeftWidth() != other.borderLeftWidth() 320 if (borderLeftWidth() != other.borderLeftWidth()
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 || noninherited_flags.unicodeBidi != other.noninherited_flags.unicodeBid i 412 || noninherited_flags.unicodeBidi != other.noninherited_flags.unicodeBid i
416 || noninherited_flags.position != other.noninherited_flags.position 413 || noninherited_flags.position != other.noninherited_flags.position
417 || noninherited_flags.originalDisplay != other.noninherited_flags.origin alDisplay) 414 || noninherited_flags.originalDisplay != other.noninherited_flags.origin alDisplay)
418 return true; 415 return true;
419 416
420 if (!m_background->outline().visuallyEqual(other.m_background->outline())) { 417 if (!m_background->outline().visuallyEqual(other.m_background->outline())) {
421 // FIXME: We only really need to recompute the overflow but we don't hav e an optimized layout for it. 418 // FIXME: We only really need to recompute the overflow but we don't hav e an optimized layout for it.
422 return true; 419 return true;
423 } 420 }
424 421
425 // Movement of non-static-positioned object is special cased in RenderStyle: :visualInvalidationDiff().
426
427 return false;
428 }
429
430 bool RenderStyle::diffNeedsFullLayout(const RenderStyle& other) const
431 {
432 if (m_box.get() != other.m_box.get()) { 422 if (m_box.get() != other.m_box.get()) {
433 if (m_box->width() != other.m_box->width() 423 if (m_box->width() != other.m_box->width()
434 || m_box->minWidth() != other.m_box->minWidth() 424 || m_box->minWidth() != other.m_box->minWidth()
435 || m_box->maxWidth() != other.m_box->maxWidth() 425 || m_box->maxWidth() != other.m_box->maxWidth()
436 || m_box->height() != other.m_box->height() 426 || m_box->height() != other.m_box->height()
437 || m_box->minHeight() != other.m_box->minHeight() 427 || m_box->minHeight() != other.m_box->minHeight()
438 || m_box->maxHeight() != other.m_box->maxHeight()) 428 || m_box->maxHeight() != other.m_box->maxHeight())
439 return true; 429 return true;
440 430
441 if (m_box->verticalAlign() != other.m_box->verticalAlign()) 431 if (m_box->verticalAlign() != other.m_box->verticalAlign())
442 return true; 432 return true;
443 433
444 if (m_box->boxSizing() != other.m_box->boxSizing()) 434 if (m_box->boxSizing() != other.m_box->boxSizing())
445 return true; 435 return true;
446 } 436 }
447 437
448 if (noninherited_flags.verticalAlign != other.noninherited_flags.verticalAli gn) 438 if (noninherited_flags.verticalAlign != other.noninherited_flags.verticalAli gn)
449 return true; 439 return true;
450 440
451 if (surround.get() != other.surround.get()) { 441 if (surround.get() != other.surround.get()) {
452 if (surround->margin != other.surround->margin) 442 if (surround->margin != other.surround->margin)
453 return true; 443 return true;
454 444
455 if (surround->padding != other.surround->padding) 445 if (surround->padding != other.surround->padding)
456 return true; 446 return true;
457 } 447 }
458 448
449 // Movement of non-static-positioned object is special cased in RenderStyle: :visualInvalidationDiff().
450
459 return false; 451 return false;
460 } 452 }
461 453
462 void RenderStyle::updatePropertySpecificDifferences(const RenderStyle& other, St yleDifference& diff) const 454 void RenderStyle::updatePropertySpecificDifferences(const RenderStyle& other, St yleDifference& diff) const
463 { 455 {
464 // StyleAdjuster has ensured that zIndex is non-auto only if it's applicable . 456 // StyleAdjuster has ensured that zIndex is non-auto only if it's applicable .
465 if (m_box->zIndex() != other.m_box->zIndex() || m_box->hasAutoZIndex() != ot her.m_box->hasAutoZIndex()) 457 if (m_box->zIndex() != other.m_box->zIndex() || m_box->hasAutoZIndex() != ot her.m_box->hasAutoZIndex())
466 diff.setZIndexChanged(); 458 diff.setZIndexChanged();
467 459
468 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) { 460 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) {
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 // right 1207 // right
1216 radiiSum = radii.topRight().height() + radii.bottomRight().height(); 1208 radiiSum = radii.topRight().height() + radii.bottomRight().height();
1217 if (radiiSum > rect.height()) 1209 if (radiiSum > rect.height())
1218 factor = std::min(rect.height() / radiiSum, factor); 1210 factor = std::min(rect.height() / radiiSum, factor);
1219 1211
1220 ASSERT(factor <= 1); 1212 ASSERT(factor <= 1);
1221 return factor; 1213 return factor;
1222 } 1214 }
1223 1215
1224 } // namespace blink 1216 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/style/RenderStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698