OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> | 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. | 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 | 436 |
437 static void logUnimplementedPropertyID(CSSPropertyID propertyID) | 437 static void logUnimplementedPropertyID(CSSPropertyID propertyID) |
438 { | 438 { |
439 DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ()); | 439 DEFINE_STATIC_LOCAL(HashSet<CSSPropertyID>, propertyIDSet, ()); |
440 if (!propertyIDSet.add(propertyID).isNewEntry) | 440 if (!propertyIDSet.add(propertyID).isNewEntry) |
441 return; | 441 return; |
442 | 442 |
443 WTF_LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", ge tPropertyName(propertyID)); | 443 WTF_LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", ge tPropertyName(propertyID)); |
444 } | 444 } |
445 | 445 |
446 static bool isLayoutDependent(CSSPropertyID propertyID, const ComputedStyle* sty le, LayoutObject* renderer) | 446 static bool isLayoutDependent(CSSPropertyID propertyID, const ComputedStyle* sty le, LayoutObject* layoutObject) |
447 { | 447 { |
448 // Some properties only depend on layout in certain conditions which | 448 // Some properties only depend on layout in certain conditions which |
449 // are specified in the main switch statement below. So we can avoid | 449 // are specified in the main switch statement below. So we can avoid |
450 // forcing layout in those conditions. The conditions in this switch | 450 // forcing layout in those conditions. The conditions in this switch |
451 // statement must remain in sync with the conditions in the main switch. | 451 // statement must remain in sync with the conditions in the main switch. |
452 // FIXME: Some of these cases could be narrowed down or optimized better. | 452 // FIXME: Some of these cases could be narrowed down or optimized better. |
453 switch (propertyID) { | 453 switch (propertyID) { |
454 case CSSPropertyBottom: | 454 case CSSPropertyBottom: |
455 case CSSPropertyGridTemplateColumns: | 455 case CSSPropertyGridTemplateColumns: |
456 case CSSPropertyGridTemplateRows: | 456 case CSSPropertyGridTemplateRows: |
457 case CSSPropertyHeight: | 457 case CSSPropertyHeight: |
458 case CSSPropertyLeft: | 458 case CSSPropertyLeft: |
459 case CSSPropertyRight: | 459 case CSSPropertyRight: |
460 case CSSPropertyTop: | 460 case CSSPropertyTop: |
461 case CSSPropertyPerspectiveOrigin: | 461 case CSSPropertyPerspectiveOrigin: |
462 case CSSPropertyTransform: | 462 case CSSPropertyTransform: |
463 case CSSPropertyTransformOrigin: | 463 case CSSPropertyTransformOrigin: |
464 case CSSPropertyMotionPath: | 464 case CSSPropertyMotionPath: |
465 case CSSPropertyMotionOffset: | 465 case CSSPropertyMotionOffset: |
466 case CSSPropertyMotionRotation: | 466 case CSSPropertyMotionRotation: |
467 case CSSPropertyWidth: | 467 case CSSPropertyWidth: |
468 case CSSPropertyWebkitFilter: | 468 case CSSPropertyWebkitFilter: |
469 case CSSPropertyX: | 469 case CSSPropertyX: |
470 case CSSPropertyY: | 470 case CSSPropertyY: |
471 case CSSPropertyRx: | 471 case CSSPropertyRx: |
472 case CSSPropertyRy: | 472 case CSSPropertyRy: |
473 return true; | 473 return true; |
474 case CSSPropertyMargin: | 474 case CSSPropertyMargin: |
475 return renderer && renderer->isBox() && (!style || !style->marginBottom( ).isFixed() || !style->marginTop().isFixed() || !style->marginLeft().isFixed() | | !style->marginRight().isFixed()); | 475 return layoutObject && layoutObject->isBox() && (!style || !style->margi nBottom().isFixed() || !style->marginTop().isFixed() || !style->marginLeft().isF ixed() || !style->marginRight().isFixed()); |
leviw_travelin_and_unemployed
2015/04/27 18:27:09
Nit: this may actually be wrap-worthy :p
dsinclair
2015/04/27 19:10:45
Done.
| |
476 case CSSPropertyMarginLeft: | 476 case CSSPropertyMarginLeft: |
477 return renderer && renderer->isBox() && (!style || !style->marginLeft(). isFixed()); | 477 return layoutObject && layoutObject->isBox() && (!style || !style->margi nLeft().isFixed()); |
478 case CSSPropertyMarginRight: | 478 case CSSPropertyMarginRight: |
479 return renderer && renderer->isBox() && (!style || !style->marginRight() .isFixed()); | 479 return layoutObject && layoutObject->isBox() && (!style || !style->margi nRight().isFixed()); |
480 case CSSPropertyMarginTop: | 480 case CSSPropertyMarginTop: |
481 return renderer && renderer->isBox() && (!style || !style->marginTop().i sFixed()); | 481 return layoutObject && layoutObject->isBox() && (!style || !style->margi nTop().isFixed()); |
482 case CSSPropertyMarginBottom: | 482 case CSSPropertyMarginBottom: |
483 return renderer && renderer->isBox() && (!style || !style->marginBottom( ).isFixed()); | 483 return layoutObject && layoutObject->isBox() && (!style || !style->margi nBottom().isFixed()); |
484 case CSSPropertyPadding: | 484 case CSSPropertyPadding: |
485 return renderer && renderer->isBox() && (!style || !style->paddingBottom ().isFixed() || !style->paddingTop().isFixed() || !style->paddingLeft().isFixed( ) || !style->paddingRight().isFixed()); | 485 return layoutObject && layoutObject->isBox() && (!style || !style->paddi ngBottom().isFixed() || !style->paddingTop().isFixed() || !style->paddingLeft(). isFixed() || !style->paddingRight().isFixed()); |
leviw_travelin_and_unemployed
2015/04/27 18:27:09
Ditto.
dsinclair
2015/04/27 19:10:45
Done.
| |
486 case CSSPropertyPaddingBottom: | 486 case CSSPropertyPaddingBottom: |
487 return renderer && renderer->isBox() && (!style || !style->paddingBottom ().isFixed()); | 487 return layoutObject && layoutObject->isBox() && (!style || !style->paddi ngBottom().isFixed()); |
488 case CSSPropertyPaddingLeft: | 488 case CSSPropertyPaddingLeft: |
489 return renderer && renderer->isBox() && (!style || !style->paddingLeft() .isFixed()); | 489 return layoutObject && layoutObject->isBox() && (!style || !style->paddi ngLeft().isFixed()); |
490 case CSSPropertyPaddingRight: | 490 case CSSPropertyPaddingRight: |
491 return renderer && renderer->isBox() && (!style || !style->paddingRight( ).isFixed()); | 491 return layoutObject && layoutObject->isBox() && (!style || !style->paddi ngRight().isFixed()); |
492 case CSSPropertyPaddingTop: | 492 case CSSPropertyPaddingTop: |
493 return renderer && renderer->isBox() && (!style || !style->paddingTop(). isFixed()); | 493 return layoutObject && layoutObject->isBox() && (!style || !style->paddi ngTop().isFixed()); |
494 default: | 494 default: |
495 return false; | 495 return false; |
496 } | 496 } |
497 } | 497 } |
498 | 498 |
499 const ComputedStyle* CSSComputedStyleDeclaration::computeComputedStyle() const | 499 const ComputedStyle* CSSComputedStyleDeclaration::computeComputedStyle() const |
500 { | 500 { |
501 Node* styledNode = this->styledNode(); | 501 Node* styledNode = this->styledNode(); |
502 ASSERT(styledNode); | 502 ASSERT(styledNode); |
503 return styledNode->ensureComputedStyle(styledNode->isPseudoElement() ? NOPSE UDO : m_pseudoElementSpecifier); | 503 return styledNode->ensureComputedStyle(styledNode->isPseudoElement() ? NOPSE UDO : m_pseudoElementSpecifier); |
504 } | 504 } |
505 | 505 |
506 Node* CSSComputedStyleDeclaration::styledNode() const | 506 Node* CSSComputedStyleDeclaration::styledNode() const |
507 { | 507 { |
508 if (!m_node) | 508 if (!m_node) |
509 return 0; | 509 return 0; |
510 if (m_node->isElementNode()) { | 510 if (m_node->isElementNode()) { |
511 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl ementSpecifier)) | 511 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl ementSpecifier)) |
512 return element; | 512 return element; |
513 } | 513 } |
514 return m_node.get(); | 514 return m_node.get(); |
515 } | 515 } |
516 | 516 |
517 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(CSSPropertyID propertyID) const | 517 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(CSSPropertyID propertyID) const |
518 { | 518 { |
519 Node* styledNode = this->styledNode(); | 519 Node* styledNode = this->styledNode(); |
520 if (!styledNode) | 520 if (!styledNode) |
521 return nullptr; | 521 return nullptr; |
522 LayoutObject* renderer = styledNode->layoutObject(); | 522 LayoutObject* layoutObject = styledNode->layoutObject(); |
523 const ComputedStyle* style; | 523 const ComputedStyle* style; |
524 | 524 |
525 Document& document = styledNode->document(); | 525 Document& document = styledNode->document(); |
526 | 526 |
527 // A timing update may be required if a compositor animation is running. | 527 // A timing update may be required if a compositor animation is running. |
528 DocumentAnimations::updateAnimationTimingForGetComputedStyle(*styledNode, pr opertyID); | 528 DocumentAnimations::updateAnimationTimingForGetComputedStyle(*styledNode, pr opertyID); |
529 | 529 |
530 document.updateRenderTreeForNodeIfNeeded(styledNode); | 530 document.updateRenderTreeForNodeIfNeeded(styledNode); |
531 | 531 |
532 // The style recalc could have caused the styled node to be discarded or rep laced | 532 // The style recalc could have caused the styled node to be discarded or rep laced |
533 // if it was a PseudoElement so we need to update it. | 533 // if it was a PseudoElement so we need to update it. |
534 styledNode = this->styledNode(); | 534 styledNode = this->styledNode(); |
535 renderer = styledNode->layoutObject(); | 535 layoutObject = styledNode->layoutObject(); |
536 | 536 |
537 style = computeComputedStyle(); | 537 style = computeComputedStyle(); |
538 | 538 |
539 bool forceFullLayout = isLayoutDependent(propertyID, style, renderer) | 539 bool forceFullLayout = isLayoutDependent(propertyID, style, layoutObject) |
540 || styledNode->isInShadowTree() | 540 || styledNode->isInShadowTree() |
541 || (document.ownerElement() && document.ensureStyleResolver().hasViewpor tDependentMediaQueries()); | 541 || (document.ownerElement() && document.ensureStyleResolver().hasViewpor tDependentMediaQueries()); |
542 | 542 |
543 if (forceFullLayout) { | 543 if (forceFullLayout) { |
544 document.updateLayoutIgnorePendingStylesheets(); | 544 document.updateLayoutIgnorePendingStylesheets(); |
545 styledNode = this->styledNode(); | 545 styledNode = this->styledNode(); |
546 style = computeComputedStyle(); | 546 style = computeComputedStyle(); |
547 renderer = styledNode->layoutObject(); | 547 layoutObject = styledNode->layoutObject(); |
548 } | 548 } |
549 | 549 |
550 if (!style) | 550 if (!style) |
551 return nullptr; | 551 return nullptr; |
552 | 552 |
553 RefPtrWillBeRawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(prope rtyID, *style, renderer, styledNode, m_allowVisitedStyle); | 553 RefPtrWillBeRawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(prope rtyID, *style, layoutObject, styledNode, m_allowVisitedStyle); |
554 if (value) | 554 if (value) |
555 return value; | 555 return value; |
556 | 556 |
557 logUnimplementedPropertyID(propertyID); | 557 logUnimplementedPropertyID(propertyID); |
558 return nullptr; | 558 return nullptr; |
559 } | 559 } |
560 | 560 |
561 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c onst | 561 String CSSComputedStyleDeclaration::getPropertyValue(CSSPropertyID propertyID) c onst |
562 { | 562 { |
563 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID); | 563 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(propertyID); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
671 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore the '" + getPropertyNameString(id) + "' property is r ead-only."); | 671 exceptionState.throwDOMException(NoModificationAllowedError, "These styles a re computed, and therefore the '" + getPropertyNameString(id) + "' property is r ead-only."); |
672 } | 672 } |
673 | 673 |
674 DEFINE_TRACE(CSSComputedStyleDeclaration) | 674 DEFINE_TRACE(CSSComputedStyleDeclaration) |
675 { | 675 { |
676 visitor->trace(m_node); | 676 visitor->trace(m_node); |
677 CSSStyleDeclaration::trace(visitor); | 677 CSSStyleDeclaration::trace(visitor); |
678 } | 678 } |
679 | 679 |
680 } // namespace blink | 680 } // namespace blink |
OLD | NEW |