Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 if (diffNeedsFullLayoutAndPaintInvalidation(other)) { | 289 // FIXME(sky): Combine these two into one function call. |
| 290 diff.setNeedsFullLayout(); | 290 if (diffNeedsFullLayoutAndPaintInvalidation(other) |
| 291 diff.setNeedsPaintInvalidationObject(); | 291 || diffNeedsFullLayout(other)) |
|
ojan
2015/01/15 01:56:42
All needsPaintInvalidation does is clear the backg
| |
| 292 } | |
| 293 | |
| 294 if (!diff.needsFullLayout() && diffNeedsFullLayout(other)) | |
| 295 diff.setNeedsFullLayout(); | 292 diff.setNeedsFullLayout(); |
| 296 | 293 |
| 297 if (!diff.needsFullLayout() && position() != StaticPosition && surround->off set != other.surround->offset) { | 294 if (!diff.needsFullLayout() && position() != StaticPosition && surround->off set != other.surround->offset) { |
| 298 // Optimize for the case where a positioned layer is moving but not chan ging size. | 295 // Optimize for the case where a positioned layer is moving but not chan ging size. |
| 299 if (positionedObjectMovedOnly(surround->offset, other.surround->offset, m_box->width())) | 296 if (positionedObjectMovedOnly(surround->offset, other.surround->offset, m_box->width())) |
| 300 diff.setNeedsPositionedMovementLayout(); | 297 diff.setNeedsPositionedMovementLayout(); |
| 301 else | 298 else |
| 302 diff.setNeedsFullLayout(); | 299 diff.setNeedsFullLayout(); |
| 303 } | 300 } |
| 304 | 301 |
| 305 if (diffNeedsPaintInvalidationLayer(other)) | 302 if (diffNeedsPaintInvalidation(other)) |
| 306 diff.setNeedsPaintInvalidationLayer(); | 303 diff.setNeedsPaintInvalidation(); |
| 307 else if (diffNeedsPaintInvalidationObject(other)) | |
| 308 diff.setNeedsPaintInvalidationObject(); | |
| 309 | 304 |
| 310 updatePropertySpecificDifferences(other, diff); | 305 updatePropertySpecificDifferences(other, diff); |
| 311 | 306 |
| 312 // Cursors are not checked, since they will be set appropriately in response to mouse events, | 307 // Cursors are not checked, since they will be set appropriately in response to mouse events, |
| 313 // so they don't need to cause any paint invalidation or layout. | 308 // so they don't need to cause any paint invalidation or layout. |
| 314 | 309 |
| 315 // 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 | 310 // 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 |
| 316 // the resulting transition properly. | 311 // the resulting transition properly. |
| 317 | 312 |
| 318 return diff; | 313 return diff; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 if (surround->margin != other.surround->margin) | 455 if (surround->margin != other.surround->margin) |
| 461 return true; | 456 return true; |
| 462 | 457 |
| 463 if (surround->padding != other.surround->padding) | 458 if (surround->padding != other.surround->padding) |
| 464 return true; | 459 return true; |
| 465 } | 460 } |
| 466 | 461 |
| 467 return false; | 462 return false; |
| 468 } | 463 } |
| 469 | 464 |
| 470 bool RenderStyle::diffNeedsPaintInvalidationLayer(const RenderStyle& other) cons t | 465 bool RenderStyle::diffNeedsPaintInvalidation(const RenderStyle& other) const |
| 471 { | |
| 472 if (position() != StaticPosition && (visual->clip != other.visual->clip || v isual->hasAutoClip != other.visual->hasAutoClip)) | |
| 473 return true; | |
| 474 | |
| 475 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) { | |
| 476 if (rareNonInheritedData->m_mask != other.rareNonInheritedData->m_mask | |
| 477 || rareNonInheritedData->m_maskBoxImage != other.rareNonInheritedDat a->m_maskBoxImage) | |
| 478 return true; | |
| 479 } | |
| 480 | |
| 481 return false; | |
| 482 } | |
| 483 | |
| 484 bool RenderStyle::diffNeedsPaintInvalidationObject(const RenderStyle& other) con st | |
| 485 { | 466 { |
| 486 if (inherited_flags._visibility != other.inherited_flags._visibility | 467 if (inherited_flags._visibility != other.inherited_flags._visibility |
| 487 || !surround->border.visuallyEqual(other.surround->border) | 468 || !surround->border.visuallyEqual(other.surround->border) |
| 488 || !m_background->visuallyEqual(*other.m_background)) | 469 || !m_background->visuallyEqual(*other.m_background)) |
| 489 return true; | 470 return true; |
| 490 | 471 |
| 491 if (rareInheritedData.get() != other.rareInheritedData.get()) { | 472 if (rareInheritedData.get() != other.rareInheritedData.get()) { |
| 492 if (rareInheritedData->userModify != other.rareInheritedData->userModify | 473 if (rareInheritedData->userModify != other.rareInheritedData->userModify |
| 493 || rareInheritedData->userSelect != other.rareInheritedData->userSel ect | 474 || rareInheritedData->userSelect != other.rareInheritedData->userSel ect |
| 494 || rareInheritedData->m_imageRendering != other.rareInheritedData->m _imageRendering) | 475 || rareInheritedData->m_imageRendering != other.rareInheritedData->m _imageRendering) |
| 495 return true; | 476 return true; |
| 496 } | 477 } |
| 497 | 478 |
| 498 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) { | 479 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) { |
| 499 if (rareNonInheritedData->userDrag != other.rareNonInheritedData->userDr ag | 480 if (rareNonInheritedData->userDrag != other.rareNonInheritedData->userDr ag |
| 500 || rareNonInheritedData->m_objectFit != other.rareNonInheritedData-> m_objectFit | 481 || rareNonInheritedData->m_objectFit != other.rareNonInheritedData-> m_objectFit |
| 501 || rareNonInheritedData->m_objectPosition != other.rareNonInheritedD ata->m_objectPosition | 482 || rareNonInheritedData->m_objectPosition != other.rareNonInheritedD ata->m_objectPosition |
| 502 || !dataEquivalent(rareNonInheritedData->m_clipPath, other.rareNonIn heritedData->m_clipPath)) | 483 || !dataEquivalent(rareNonInheritedData->m_clipPath, other.rareNonIn heritedData->m_clipPath)) |
| 503 return true; | 484 return true; |
| 504 } | 485 } |
| 505 | 486 |
| 487 if (position() != StaticPosition && (visual->clip != other.visual->clip || v isual->hasAutoClip != other.visual->hasAutoClip)) | |
| 488 return true; | |
| 489 | |
| 490 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) { | |
| 491 if (rareNonInheritedData->m_mask != other.rareNonInheritedData->m_mask | |
| 492 || rareNonInheritedData->m_maskBoxImage != other.rareNonInheritedDat a->m_maskBoxImage) | |
| 493 return true; | |
| 494 } | |
| 495 | |
| 506 return false; | 496 return false; |
| 507 } | 497 } |
| 508 | 498 |
| 509 void RenderStyle::updatePropertySpecificDifferences(const RenderStyle& other, St yleDifference& diff) const | 499 void RenderStyle::updatePropertySpecificDifferences(const RenderStyle& other, St yleDifference& diff) const |
| 510 { | 500 { |
| 511 // StyleAdjuster has ensured that zIndex is non-auto only if it's applicable . | 501 // StyleAdjuster has ensured that zIndex is non-auto only if it's applicable . |
| 512 if (m_box->zIndex() != other.m_box->zIndex() || m_box->hasAutoZIndex() != ot her.m_box->hasAutoZIndex()) | 502 if (m_box->zIndex() != other.m_box->zIndex() || m_box->hasAutoZIndex() != ot her.m_box->hasAutoZIndex()) |
| 513 diff.setZIndexChanged(); | 503 diff.setZIndexChanged(); |
| 514 | 504 |
| 515 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) { | 505 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) { |
| 516 if (!transformDataEquivalent(other)) | 506 if (!transformDataEquivalent(other)) |
| 517 diff.setTransformChanged(); | 507 diff.setTransformChanged(); |
| 518 | 508 |
| 519 if (rareNonInheritedData->opacity != other.rareNonInheritedData->opacity ) | 509 if (rareNonInheritedData->opacity != other.rareNonInheritedData->opacity ) |
| 520 diff.setOpacityChanged(); | 510 diff.setOpacityChanged(); |
| 521 | 511 |
| 522 if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filt er) | 512 if (rareNonInheritedData->m_filter != other.rareNonInheritedData->m_filt er) |
| 523 diff.setFilterChanged(); | 513 diff.setFilterChanged(); |
| 524 } | 514 } |
| 525 | |
| 526 if (!diff.needsPaintInvalidation()) { | |
| 527 if (inherited->color != other.inherited->color | |
| 528 || inherited_flags.m_textUnderline != other.inherited_flags.m_textUn derline | |
| 529 || visual->textDecoration != other.visual->textDecoration) { | |
| 530 diff.setTextOrColorChanged(); | |
| 531 } else if (rareNonInheritedData.get() != other.rareNonInheritedData.get( )) { | |
| 532 if (rareNonInheritedData->m_textDecorationStyle != other.rareNonInhe ritedData->m_textDecorationStyle | |
| 533 || rareNonInheritedData->m_textDecorationColor != other.rareNonI nheritedData->m_textDecorationColor) | |
| 534 diff.setTextOrColorChanged(); | |
| 535 } else if (rareInheritedData.get() != other.rareInheritedData.get()) { | |
| 536 if (rareInheritedData->textFillColor() != other.rareInheritedData->t extFillColor() | |
| 537 || rareInheritedData->textStrokeColor() != other.rareInheritedDa ta->textStrokeColor() | |
| 538 || rareInheritedData->textEmphasisColor() != other.rareInherited Data->textEmphasisColor() | |
| 539 || rareInheritedData->textEmphasisFill != other.rareInheritedDat a->textEmphasisFill | |
| 540 || rareInheritedData->appliedTextDecorations != other.rareInheri tedData->appliedTextDecorations) | |
| 541 diff.setTextOrColorChanged(); | |
| 542 } | |
| 543 } | |
| 544 } | 515 } |
| 545 | 516 |
| 546 void RenderStyle::addCursor(PassRefPtr<StyleImage> image, const IntPoint& hotSpo t) | 517 void RenderStyle::addCursor(PassRefPtr<StyleImage> image, const IntPoint& hotSpo t) |
| 547 { | 518 { |
| 548 if (!rareInheritedData.access()->cursorData) | 519 if (!rareInheritedData.access()->cursorData) |
| 549 rareInheritedData.access()->cursorData = CursorList::create(); | 520 rareInheritedData.access()->cursorData = CursorList::create(); |
| 550 rareInheritedData.access()->cursorData->append(CursorData(image, hotSpot)); | 521 rareInheritedData.access()->cursorData->append(CursorData(image, hotSpot)); |
| 551 } | 522 } |
| 552 | 523 |
| 553 void RenderStyle::setCursorList(PassRefPtr<CursorList> other) | 524 void RenderStyle::setCursorList(PassRefPtr<CursorList> other) |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1281 // right | 1252 // right |
| 1282 radiiSum = radii.topRight().height() + radii.bottomRight().height(); | 1253 radiiSum = radii.topRight().height() + radii.bottomRight().height(); |
| 1283 if (radiiSum > rect.height()) | 1254 if (radiiSum > rect.height()) |
| 1284 factor = std::min(rect.height() / radiiSum, factor); | 1255 factor = std::min(rect.height() / radiiSum, factor); |
| 1285 | 1256 |
| 1286 ASSERT(factor <= 1); | 1257 ASSERT(factor <= 1); |
| 1287 return factor; | 1258 return factor; |
| 1288 } | 1259 } |
| 1289 | 1260 |
| 1290 } // namespace blink | 1261 } // namespace blink |
| OLD | NEW |