OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #include "core/css/resolver/MediaQueryResult.h" | 63 #include "core/css/resolver/MediaQueryResult.h" |
64 #include "core/css/resolver/ScopedStyleResolver.h" | 64 #include "core/css/resolver/ScopedStyleResolver.h" |
65 #include "core/css/resolver/SharedStyleFinder.h" | 65 #include "core/css/resolver/SharedStyleFinder.h" |
66 #include "core/css/resolver/StyleAdjuster.h" | 66 #include "core/css/resolver/StyleAdjuster.h" |
67 #include "core/css/resolver/StyleResolverParentScope.h" | 67 #include "core/css/resolver/StyleResolverParentScope.h" |
68 #include "core/css/resolver/StyleResolverState.h" | 68 #include "core/css/resolver/StyleResolverState.h" |
69 #include "core/css/resolver/StyleResolverStats.h" | 69 #include "core/css/resolver/StyleResolverStats.h" |
70 #include "core/css/resolver/ViewportStyleResolver.h" | 70 #include "core/css/resolver/ViewportStyleResolver.h" |
71 #include "core/dom/CSSSelectorWatch.h" | 71 #include "core/dom/CSSSelectorWatch.h" |
72 #include "core/dom/FirstLetterPseudoElement.h" | 72 #include "core/dom/FirstLetterPseudoElement.h" |
73 #include "core/dom/NodeLayoutStyle.h" | 73 #include "core/dom/NodeComputedStyle.h" |
74 #include "core/dom/StyleEngine.h" | 74 #include "core/dom/StyleEngine.h" |
75 #include "core/dom/Text.h" | 75 #include "core/dom/Text.h" |
76 #include "core/dom/shadow/ElementShadow.h" | 76 #include "core/dom/shadow/ElementShadow.h" |
77 #include "core/dom/shadow/ShadowRoot.h" | 77 #include "core/dom/shadow/ShadowRoot.h" |
78 #include "core/frame/FrameView.h" | 78 #include "core/frame/FrameView.h" |
79 #include "core/frame/LocalFrame.h" | 79 #include "core/frame/LocalFrame.h" |
80 #include "core/frame/Settings.h" | 80 #include "core/frame/Settings.h" |
81 #include "core/html/HTMLIFrameElement.h" | 81 #include "core/html/HTMLIFrameElement.h" |
82 #include "core/inspector/InspectorInstrumentation.h" | 82 #include "core/inspector/InspectorInstrumentation.h" |
83 #include "core/layout/LayoutView.h" | 83 #include "core/layout/LayoutView.h" |
(...skipping 14 matching lines...) Expand all Loading... |
98 if (state.animationUpdate()) | 98 if (state.animationUpdate()) |
99 element.ensureElementAnimations().cssAnimations().setPendingUpdate(state
.takeAnimationUpdate()); | 99 element.ensureElementAnimations().cssAnimations().setPendingUpdate(state
.takeAnimationUpdate()); |
100 } | 100 } |
101 | 101 |
102 } // namespace | 102 } // namespace |
103 | 103 |
104 namespace blink { | 104 namespace blink { |
105 | 105 |
106 using namespace HTMLNames; | 106 using namespace HTMLNames; |
107 | 107 |
108 LayoutStyle* StyleResolver::s_styleNotYetAvailable; | 108 ComputedStyle* StyleResolver::s_styleNotYetAvailable; |
109 | 109 |
110 static StylePropertySet* leftToRightDeclaration() | 110 static StylePropertySet* leftToRightDeclaration() |
111 { | 111 { |
112 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(MutableStylePropertySet, leftToRightDec
l, (MutableStylePropertySet::create())); | 112 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(MutableStylePropertySet, leftToRightDec
l, (MutableStylePropertySet::create())); |
113 if (leftToRightDecl->isEmpty()) | 113 if (leftToRightDecl->isEmpty()) |
114 leftToRightDecl->setProperty(CSSPropertyDirection, CSSValueLtr); | 114 leftToRightDecl->setProperty(CSSPropertyDirection, CSSValueLtr); |
115 return leftToRightDecl; | 115 return leftToRightDecl; |
116 } | 116 } |
117 | 117 |
118 static StylePropertySet* rightToLeftDeclaration() | 118 static StylePropertySet* rightToLeftDeclaration() |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 bool isInlineStyleCacheable = !state.element()->inlineStyle()->isMut
able(); | 468 bool isInlineStyleCacheable = !state.element()->inlineStyle()->isMut
able(); |
469 collector.addElementStyleProperties(state.element()->inlineStyle(),
isInlineStyleCacheable); | 469 collector.addElementStyleProperties(state.element()->inlineStyle(),
isInlineStyleCacheable); |
470 } | 470 } |
471 | 471 |
472 // Now check SMIL animation override style. | 472 // Now check SMIL animation override style. |
473 if (includeSMILProperties && state.element()->isSVGElement()) | 473 if (includeSMILProperties && state.element()->isSVGElement()) |
474 collector.addElementStyleProperties(toSVGElement(state.element())->a
nimatedSMILStyleProperties(), false /* isCacheable */); | 474 collector.addElementStyleProperties(toSVGElement(state.element())->a
nimatedSMILStyleProperties(), false /* isCacheable */); |
475 } | 475 } |
476 } | 476 } |
477 | 477 |
478 PassRefPtr<LayoutStyle> StyleResolver::styleForDocument(Document& document) | 478 PassRefPtr<ComputedStyle> StyleResolver::styleForDocument(Document& document) |
479 { | 479 { |
480 const LocalFrame* frame = document.frame(); | 480 const LocalFrame* frame = document.frame(); |
481 | 481 |
482 RefPtr<LayoutStyle> documentStyle = LayoutStyle::create(); | 482 RefPtr<ComputedStyle> documentStyle = ComputedStyle::create(); |
483 documentStyle->setRTLOrdering(document.visuallyOrdered() ? VisualOrder : Log
icalOrder); | 483 documentStyle->setRTLOrdering(document.visuallyOrdered() ? VisualOrder : Log
icalOrder); |
484 documentStyle->setZoom(frame && !document.printing() ? frame->pageZoomFactor
() : 1); | 484 documentStyle->setZoom(frame && !document.printing() ? frame->pageZoomFactor
() : 1); |
485 documentStyle->setLocale(document.contentLanguage()); | 485 documentStyle->setLocale(document.contentLanguage()); |
486 documentStyle->setZIndex(0); | 486 documentStyle->setZIndex(0); |
487 documentStyle->setUserModify(document.inDesignMode() ? READ_WRITE : READ_ONL
Y); | 487 documentStyle->setUserModify(document.inDesignMode() ? READ_WRITE : READ_ONL
Y); |
488 // These are designed to match the user-agent stylesheet values for the docu
ment element | 488 // These are designed to match the user-agent stylesheet values for the docu
ment element |
489 // so that the common case doesn't need to create a new LayoutStyle in | 489 // so that the common case doesn't need to create a new ComputedStyle in |
490 // Document::inheritHtmlAndBodyElementStyles. | 490 // Document::inheritHtmlAndBodyElementStyles. |
491 documentStyle->setDisplay(BLOCK); | 491 documentStyle->setDisplay(BLOCK); |
492 documentStyle->setScrollBlocksOn(WebScrollBlocksOnStartTouch | WebScrollBloc
ksOnWheelEvent); | 492 documentStyle->setScrollBlocksOn(WebScrollBlocksOnStartTouch | WebScrollBloc
ksOnWheelEvent); |
493 | 493 |
494 document.setupFontBuilder(*documentStyle); | 494 document.setupFontBuilder(*documentStyle); |
495 | 495 |
496 return documentStyle.release(); | 496 return documentStyle.release(); |
497 } | 497 } |
498 | 498 |
499 AuthorStyleInfo StyleResolver::authorStyleInfo(StyleResolverState& state) | 499 AuthorStyleInfo StyleResolver::authorStyleInfo(StyleResolverState& state) |
(...skipping 11 matching lines...) Expand all Loading... |
511 backgroundLayersCopy.setRepeatX(NoRepeatFill); | 511 backgroundLayersCopy.setRepeatX(NoRepeatFill); |
512 backgroundLayersCopy.setRepeatY(NoRepeatFill); | 512 backgroundLayersCopy.setRepeatY(NoRepeatFill); |
513 | 513 |
514 bool backgroundChanged = backgroundLayersCopy != backgroundCopy | 514 bool backgroundChanged = backgroundLayersCopy != backgroundCopy |
515 || state.style()->backgroundColor() != cachedUAStyle->backgroundColor; | 515 || state.style()->backgroundColor() != cachedUAStyle->backgroundColor; |
516 bool borderChanged = state.style()->border() != cachedUAStyle->border; | 516 bool borderChanged = state.style()->border() != cachedUAStyle->border; |
517 | 517 |
518 return AuthorStyleInfo(backgroundChanged, borderChanged); | 518 return AuthorStyleInfo(backgroundChanged, borderChanged); |
519 } | 519 } |
520 | 520 |
521 void StyleResolver::adjustLayoutStyle(StyleResolverState& state, Element* elemen
t) | 521 void StyleResolver::adjustComputedStyle(StyleResolverState& state, Element* elem
ent) |
522 { | 522 { |
523 StyleAdjuster adjuster(document().inQuirksMode()); | 523 StyleAdjuster adjuster(document().inQuirksMode()); |
524 adjuster.adjustLayoutStyle(state.mutableStyleRef(), *state.parentStyle(), el
ement, authorStyleInfo(state)); | 524 adjuster.adjustComputedStyle(state.mutableStyleRef(), *state.parentStyle(),
element, authorStyleInfo(state)); |
525 } | 525 } |
526 | 526 |
527 // Start loading resources referenced by this style. | 527 // Start loading resources referenced by this style. |
528 void StyleResolver::loadPendingResources(StyleResolverState& state) | 528 void StyleResolver::loadPendingResources(StyleResolverState& state) |
529 { | 529 { |
530 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 530 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
531 document().styleEngine().fontSelector()->fontLoader()->loadPendingFonts(); | 531 document().styleEngine().fontSelector()->fontLoader()->loadPendingFonts(); |
532 } | 532 } |
533 | 533 |
534 PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, const L
ayoutStyle* defaultParent, StyleSharingBehavior sharingBehavior, | 534 PassRefPtr<ComputedStyle> StyleResolver::styleForElement(Element* element, const
ComputedStyle* defaultParent, StyleSharingBehavior sharingBehavior, |
535 RuleMatchingBehavior matchingBehavior) | 535 RuleMatchingBehavior matchingBehavior) |
536 { | 536 { |
537 ASSERT(document().frame()); | 537 ASSERT(document().frame()); |
538 ASSERT(document().settings()); | 538 ASSERT(document().settings()); |
539 ASSERT(!hasPendingAuthorStyleSheets()); | 539 ASSERT(!hasPendingAuthorStyleSheets()); |
540 ASSERT(!m_needCollectFeatures); | 540 ASSERT(!m_needCollectFeatures); |
541 | 541 |
542 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 542 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer |
543 // will vanish if a style recalc happens during loading. | 543 // will vanish if a style recalc happens during loading. |
544 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->layoutObject()) { | 544 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->layoutObject()) { |
545 if (!s_styleNotYetAvailable) { | 545 if (!s_styleNotYetAvailable) { |
546 s_styleNotYetAvailable = LayoutStyle::create().leakRef(); | 546 s_styleNotYetAvailable = ComputedStyle::create().leakRef(); |
547 s_styleNotYetAvailable->setDisplay(NONE); | 547 s_styleNotYetAvailable->setDisplay(NONE); |
548 s_styleNotYetAvailable->font().update(document().styleEngine().fontS
elector()); | 548 s_styleNotYetAvailable->font().update(document().styleEngine().fontS
elector()); |
549 } | 549 } |
550 | 550 |
551 document().setHasNodesWithPlaceholderStyle(); | 551 document().setHasNodesWithPlaceholderStyle(); |
552 return s_styleNotYetAvailable; | 552 return s_styleNotYetAvailable; |
553 } | 553 } |
554 | 554 |
555 didAccess(); | 555 didAccess(); |
556 | 556 |
557 StyleResolverParentScope::ensureParentStackIsPushed(); | 557 StyleResolverParentScope::ensureParentStackIsPushed(); |
558 | 558 |
559 ElementResolveContext elementContext(*element); | 559 ElementResolveContext elementContext(*element); |
560 | 560 |
561 if (sharingBehavior == AllowStyleSharing && (defaultParent || elementContext
.parentStyle())) { | 561 if (sharingBehavior == AllowStyleSharing && (defaultParent || elementContext
.parentStyle())) { |
562 SharedStyleFinder styleFinder(elementContext, m_features, m_siblingRuleS
et.get(), m_uncommonAttributeRuleSet.get(), *this); | 562 SharedStyleFinder styleFinder(elementContext, m_features, m_siblingRuleS
et.get(), m_uncommonAttributeRuleSet.get(), *this); |
563 if (RefPtr<LayoutStyle> sharedStyle = styleFinder.findSharedStyle()) | 563 if (RefPtr<ComputedStyle> sharedStyle = styleFinder.findSharedStyle()) |
564 return sharedStyle.release(); | 564 return sharedStyle.release(); |
565 } | 565 } |
566 | 566 |
567 StyleResolverState state(document(), elementContext, defaultParent); | 567 StyleResolverState state(document(), elementContext, defaultParent); |
568 | 568 |
569 ElementAnimations* elementAnimations = element->elementAnimations(); | 569 ElementAnimations* elementAnimations = element->elementAnimations(); |
570 const LayoutStyle* baseLayoutStyle = elementAnimations ? elementAnimations->
baseLayoutStyle() : nullptr; | 570 const ComputedStyle* baseComputedStyle = elementAnimations ? elementAnimatio
ns->baseComputedStyle() : nullptr; |
571 | 571 |
572 if (baseLayoutStyle) { | 572 if (baseComputedStyle) { |
573 state.setStyle(LayoutStyle::clone(*baseLayoutStyle)); | 573 state.setStyle(ComputedStyle::clone(*baseComputedStyle)); |
574 if (!state.parentStyle()) | 574 if (!state.parentStyle()) |
575 state.setParentStyle(initialStyleForElement()); | 575 state.setParentStyle(initialStyleForElement()); |
576 } else { | 576 } else { |
577 if (state.parentStyle()) { | 577 if (state.parentStyle()) { |
578 RefPtr<LayoutStyle> style = LayoutStyle::create(); | 578 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
579 style->inheritFrom(*state.parentStyle(), isAtShadowBoundary(element)
? LayoutStyle::AtShadowBoundary : LayoutStyle::NotAtShadowBoundary); | 579 style->inheritFrom(*state.parentStyle(), isAtShadowBoundary(element)
? ComputedStyle::AtShadowBoundary : ComputedStyle::NotAtShadowBoundary); |
580 state.setStyle(style.release()); | 580 state.setStyle(style.release()); |
581 } else { | 581 } else { |
582 state.setStyle(initialStyleForElement()); | 582 state.setStyle(initialStyleForElement()); |
583 state.setParentStyle(LayoutStyle::clone(*state.style())); | 583 state.setParentStyle(ComputedStyle::clone(*state.style())); |
584 } | 584 } |
585 } | 585 } |
586 | 586 |
587 // contenteditable attribute (implemented by -webkit-user-modify) should | 587 // contenteditable attribute (implemented by -webkit-user-modify) should |
588 // be propagated from shadow host to distributed node. | 588 // be propagated from shadow host to distributed node. |
589 if (state.distributedToInsertionPoint()) { | 589 if (state.distributedToInsertionPoint()) { |
590 if (Element* parent = element->parentElement()) { | 590 if (Element* parent = element->parentElement()) { |
591 if (LayoutStyle* styleOfShadowHost = parent->mutableLayoutStyle()) | 591 if (ComputedStyle* styleOfShadowHost = parent->mutableComputedStyle(
)) |
592 state.style()->setUserModify(styleOfShadowHost->userModify()); | 592 state.style()->setUserModify(styleOfShadowHost->userModify()); |
593 } | 593 } |
594 } | 594 } |
595 | 595 |
596 if (element->isLink()) { | 596 if (element->isLink()) { |
597 state.style()->setIsLink(true); | 597 state.style()->setIsLink(true); |
598 EInsideLink linkState = state.elementLinkState(); | 598 EInsideLink linkState = state.elementLinkState(); |
599 if (linkState != NotInsideLink) { | 599 if (linkState != NotInsideLink) { |
600 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); | 600 bool forceVisited = InspectorInstrumentation::forcePseudoState(eleme
nt, CSSSelector::PseudoVisited); |
601 if (forceVisited) | 601 if (forceVisited) |
602 linkState = InsideVisitedLink; | 602 linkState = InsideVisitedLink; |
603 } | 603 } |
604 state.style()->setInsideLink(linkState); | 604 state.style()->setInsideLink(linkState); |
605 } | 605 } |
606 | 606 |
607 if (!baseLayoutStyle) { | 607 if (!baseComputedStyle) { |
608 | 608 |
609 bool needsCollection = false; | 609 bool needsCollection = false; |
610 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(ele
ment, needsCollection); | 610 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetsForElement(ele
ment, needsCollection); |
611 if (needsCollection) | 611 if (needsCollection) |
612 collectFeatures(); | 612 collectFeatures(); |
613 | 613 |
614 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); | 614 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); |
615 | 615 |
616 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludi
ngSMIL); | 616 matchAllRules(state, collector, matchingBehavior != MatchAllRulesExcludi
ngSMIL); |
617 | 617 |
618 if (element->layoutStyle() && element->layoutStyle()->textAutosizingMult
iplier() != state.style()->textAutosizingMultiplier()) { | 618 if (element->computedStyle() && element->computedStyle()->textAutosizing
Multiplier() != state.style()->textAutosizingMultiplier()) { |
619 // Preserve the text autosizing multiplier on style recalc. Autosize
r will update it during layout if needed. | 619 // Preserve the text autosizing multiplier on style recalc. Autosize
r will update it during layout if needed. |
620 // NOTE: this must occur before applyMatchedProperties for correct c
omputation of font-relative lengths. | 620 // NOTE: this must occur before applyMatchedProperties for correct c
omputation of font-relative lengths. |
621 state.style()->setTextAutosizingMultiplier(element->layoutStyle()->t
extAutosizingMultiplier()); | 621 state.style()->setTextAutosizingMultiplier(element->computedStyle()-
>textAutosizingMultiplier()); |
622 state.style()->setUnique(); | 622 state.style()->setUnique(); |
623 } | 623 } |
624 | 624 |
625 if (state.hasDirAutoAttribute()) | 625 if (state.hasDirAutoAttribute()) |
626 state.style()->setSelfOrAncestorHasDirAutoAttribute(true); | 626 state.style()->setSelfOrAncestorHasDirAutoAttribute(true); |
627 | 627 |
628 applyMatchedProperties(state, collector.matchedResult()); | 628 applyMatchedProperties(state, collector.matchedResult()); |
629 applyCallbackSelectors(state); | 629 applyCallbackSelectors(state); |
630 | 630 |
631 // Cache our original display. | 631 // Cache our original display. |
632 state.style()->setOriginalDisplay(state.style()->display()); | 632 state.style()->setOriginalDisplay(state.style()->display()); |
633 | 633 |
634 adjustLayoutStyle(state, element); | 634 adjustComputedStyle(state, element); |
635 | 635 |
636 if (elementAnimations) | 636 if (elementAnimations) |
637 elementAnimations->updateBaseLayoutStyle(state.style()); | 637 elementAnimations->updateBaseComputedStyle(state.style()); |
638 } | 638 } |
639 | 639 |
640 // FIXME: The CSSWG wants to specify that the effects of animations are appl
ied before | 640 // FIXME: The CSSWG wants to specify that the effects of animations are appl
ied before |
641 // important rules, but this currently happens here as we require adjustment
to have happened | 641 // important rules, but this currently happens here as we require adjustment
to have happened |
642 // before deciding which properties to transition. | 642 // before deciding which properties to transition. |
643 if (applyAnimatedProperties(state, element)) | 643 if (applyAnimatedProperties(state, element)) |
644 adjustLayoutStyle(state, element); | 644 adjustComputedStyle(state, element); |
645 | 645 |
646 if (isHTMLBodyElement(*element)) | 646 if (isHTMLBodyElement(*element)) |
647 document().textLinkColors().setTextColor(state.style()->color()); | 647 document().textLinkColors().setTextColor(state.style()->color()); |
648 | 648 |
649 setAnimationUpdateIfNeeded(state, *element); | 649 setAnimationUpdateIfNeeded(state, *element); |
650 | 650 |
651 if (state.style()->hasViewportUnits()) | 651 if (state.style()->hasViewportUnits()) |
652 document().setHasViewportUnits(); | 652 document().setHasViewportUnits(); |
653 | 653 |
654 // Now return the style. | 654 // Now return the style. |
655 return state.takeStyle(); | 655 return state.takeStyle(); |
656 } | 656 } |
657 | 657 |
658 PassRefPtr<LayoutStyle> StyleResolver::styleForKeyframe(Element& element, const
LayoutStyle& elementStyle, const LayoutStyle* parentStyle, const StyleRuleKeyfra
me* keyframe, const AtomicString& animationName) | 658 PassRefPtr<ComputedStyle> StyleResolver::styleForKeyframe(Element& element, cons
t ComputedStyle& elementStyle, const ComputedStyle* parentStyle, const StyleRule
Keyframe* keyframe, const AtomicString& animationName) |
659 { | 659 { |
660 ASSERT(document().frame()); | 660 ASSERT(document().frame()); |
661 ASSERT(document().settings()); | 661 ASSERT(document().settings()); |
662 ASSERT(!hasPendingAuthorStyleSheets()); | 662 ASSERT(!hasPendingAuthorStyleSheets()); |
663 | 663 |
664 StyleResolverState state(document(), &element, parentStyle); | 664 StyleResolverState state(document(), &element, parentStyle); |
665 | 665 |
666 MatchResult result; | 666 MatchResult result; |
667 result.addMatchedProperties(&keyframe->properties()); | 667 result.addMatchedProperties(&keyframe->properties()); |
668 | 668 |
669 ASSERT(!state.style()); | 669 ASSERT(!state.style()); |
670 | 670 |
671 // Create the style | 671 // Create the style |
672 state.setStyle(LayoutStyle::clone(elementStyle)); | 672 state.setStyle(ComputedStyle::clone(elementStyle)); |
673 | 673 |
674 // We don't need to bother with !important. Since there is only ever one | 674 // We don't need to bother with !important. Since there is only ever one |
675 // decl, there's nothing to override. So just add the first properties. | 675 // decl, there's nothing to override. So just add the first properties. |
676 // We also don't need to bother with animation properties since the only | 676 // We also don't need to bother with animation properties since the only |
677 // relevant one is animation-timing-function and we special-case that in | 677 // relevant one is animation-timing-function and we special-case that in |
678 // CSSAnimations.cpp | 678 // CSSAnimations.cpp |
679 bool inheritedOnly = false; | 679 bool inheritedOnly = false; |
680 applyMatchedProperties<HighPropertyPriority>(state, result, false, 0, result
.matchedProperties.size() - 1, inheritedOnly); | 680 applyMatchedProperties<HighPropertyPriority>(state, result, false, 0, result
.matchedProperties.size() - 1, inheritedOnly); |
681 | 681 |
682 // If our font got dirtied, go ahead and update it now. | 682 // If our font got dirtied, go ahead and update it now. |
683 updateFont(state); | 683 updateFont(state); |
684 | 684 |
685 // Now do rest of the properties. | 685 // Now do rest of the properties. |
686 applyMatchedProperties<LowPropertyPriority>(state, result, false, 0, result.
matchedProperties.size() - 1, inheritedOnly); | 686 applyMatchedProperties<LowPropertyPriority>(state, result, false, 0, result.
matchedProperties.size() - 1, inheritedOnly); |
687 | 687 |
688 loadPendingResources(state); | 688 loadPendingResources(state); |
689 | 689 |
690 didAccess(); | 690 didAccess(); |
691 | 691 |
692 return state.takeStyle(); | 692 return state.takeStyle(); |
693 } | 693 } |
694 | 694 |
695 // This function is used by the WebAnimations JavaScript API method animate(). | 695 // This function is used by the WebAnimations JavaScript API method animate(). |
696 // FIXME: Remove this when animate() switches away from resolution-dependent par
sing. | 696 // FIXME: Remove this when animate() switches away from resolution-dependent par
sing. |
697 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, const LayoutStyle* baseStyle, CSSPropertyID property, CSS
Value* value) | 697 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(Element& element, const ComputedStyle* baseStyle, CSSPropertyID property, C
SSValue* value) |
698 { | 698 { |
699 StyleResolverState state(element.document(), &element); | 699 StyleResolverState state(element.document(), &element); |
700 state.setStyle(baseStyle ? LayoutStyle::clone(*baseStyle) : LayoutStyle::cre
ate()); | 700 state.setStyle(baseStyle ? ComputedStyle::clone(*baseStyle) : ComputedStyle:
:create()); |
701 return createAnimatableValueSnapshot(state, property, value); | 701 return createAnimatableValueSnapshot(state, property, value); |
702 } | 702 } |
703 | 703 |
704 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue* value) | 704 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue* value) |
705 { | 705 { |
706 if (value) { | 706 if (value) { |
707 StyleBuilder::applyProperty(property, state, value); | 707 StyleBuilder::applyProperty(property, state, value); |
708 state.fontBuilder().createFont(state.document().styleEngine().fontSelect
or(), state.mutableStyleRef()); | 708 state.fontBuilder().createFont(state.document().styleEngine().fontSelect
or(), state.mutableStyleRef()); |
709 } | 709 } |
710 return CSSAnimatableValueFactory::create(property, *state.style()); | 710 return CSSAnimatableValueFactory::create(property, *state.style()); |
(...skipping 19 matching lines...) Expand all Loading... |
730 | 730 |
731 if (pseudoId == BACKDROP && !parent.isInTopLayer()) | 731 if (pseudoId == BACKDROP && !parent.isInTopLayer()) |
732 return nullptr; | 732 return nullptr; |
733 | 733 |
734 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo
Element::firstLetterTextRenderer(parent))) | 734 if (pseudoId == FIRST_LETTER && (parent.isSVGElement() || !FirstLetterPseudo
Element::firstLetterTextRenderer(parent))) |
735 return nullptr; | 735 return nullptr; |
736 | 736 |
737 if (!parentRenderer->canHaveGeneratedChildren()) | 737 if (!parentRenderer->canHaveGeneratedChildren()) |
738 return nullptr; | 738 return nullptr; |
739 | 739 |
740 LayoutStyle* parentStyle = parentRenderer->style(); | 740 ComputedStyle* parentStyle = parentRenderer->style(); |
741 if (LayoutStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId))
{ | 741 if (ComputedStyle* cachedStyle = parentStyle->getCachedPseudoStyle(pseudoId)
) { |
742 if (!pseudoElementRendererIsNeeded(cachedStyle)) | 742 if (!pseudoElementRendererIsNeeded(cachedStyle)) |
743 return nullptr; | 743 return nullptr; |
744 return createPseudoElement(&parent, pseudoId); | 744 return createPseudoElement(&parent, pseudoId); |
745 } | 745 } |
746 | 746 |
747 StyleResolverState state(document(), &parent, parentStyle); | 747 StyleResolverState state(document(), &parent, parentStyle); |
748 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 748 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
749 return nullptr; | 749 return nullptr; |
750 RefPtr<LayoutStyle> style = state.takeStyle(); | 750 RefPtr<ComputedStyle> style = state.takeStyle(); |
751 ASSERT(style); | 751 ASSERT(style); |
752 parentStyle->addCachedPseudoStyle(style); | 752 parentStyle->addCachedPseudoStyle(style); |
753 | 753 |
754 if (!pseudoElementRendererIsNeeded(style.get())) | 754 if (!pseudoElementRendererIsNeeded(style.get())) |
755 return nullptr; | 755 return nullptr; |
756 | 756 |
757 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu
doId); | 757 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu
doId); |
758 | 758 |
759 setAnimationUpdateIfNeeded(state, *pseudo); | 759 setAnimationUpdateIfNeeded(state, *pseudo); |
760 if (ElementAnimations* elementAnimations = pseudo->elementAnimations()) | 760 if (ElementAnimations* elementAnimations = pseudo->elementAnimations()) |
761 elementAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get())
; | 761 elementAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get())
; |
762 return pseudo.release(); | 762 return pseudo.release(); |
763 } | 763 } |
764 | 764 |
765 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, const LayoutStyle* parentStyle, StyleResolverS
tate& state) | 765 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, const ComputedStyle* parentStyle, StyleResolve
rState& state) |
766 { | 766 { |
767 ASSERT(document().frame()); | 767 ASSERT(document().frame()); |
768 ASSERT(document().settings()); | 768 ASSERT(document().settings()); |
769 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); | 769 ASSERT(pseudoStyleRequest.pseudoId != FIRST_LINE_INHERITED); |
770 ASSERT(state.parentStyle()); | 770 ASSERT(state.parentStyle()); |
771 | 771 |
772 StyleResolverParentScope::ensureParentStackIsPushed(); | 772 StyleResolverParentScope::ensureParentStackIsPushed(); |
773 | 773 |
774 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); | 774 Element* pseudoElement = element.pseudoElement(pseudoStyleRequest.pseudoId); |
775 | 775 |
776 ElementAnimations* elementAnimations = pseudoElement ? pseudoElement->elemen
tAnimations() : nullptr; | 776 ElementAnimations* elementAnimations = pseudoElement ? pseudoElement->elemen
tAnimations() : nullptr; |
777 const LayoutStyle* baseLayoutStyle = elementAnimations ? elementAnimations->
baseLayoutStyle() : nullptr; | 777 const ComputedStyle* baseComputedStyle = elementAnimations ? elementAnimatio
ns->baseComputedStyle() : nullptr; |
778 | 778 |
779 if (baseLayoutStyle) { | 779 if (baseComputedStyle) { |
780 state.setStyle(LayoutStyle::clone(*baseLayoutStyle)); | 780 state.setStyle(ComputedStyle::clone(*baseComputedStyle)); |
781 } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { | 781 } else if (pseudoStyleRequest.allowsInheritance(state.parentStyle())) { |
782 RefPtr<LayoutStyle> style = LayoutStyle::create(); | 782 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
783 style->inheritFrom(*state.parentStyle()); | 783 style->inheritFrom(*state.parentStyle()); |
784 state.setStyle(style.release()); | 784 state.setStyle(style.release()); |
785 } else { | 785 } else { |
786 state.setStyle(initialStyleForElement()); | 786 state.setStyle(initialStyleForElement()); |
787 state.setParentStyle(LayoutStyle::clone(*state.style())); | 787 state.setParentStyle(ComputedStyle::clone(*state.style())); |
788 } | 788 } |
789 | 789 |
790 state.style()->setStyleType(pseudoStyleRequest.pseudoId); | 790 state.style()->setStyleType(pseudoStyleRequest.pseudoId); |
791 | 791 |
792 // Since we don't use pseudo-elements in any of our quirk/print | 792 // Since we don't use pseudo-elements in any of our quirk/print |
793 // user agent rules, don't waste time walking those rules. | 793 // user agent rules, don't waste time walking those rules. |
794 | 794 |
795 if (!baseLayoutStyle) { | 795 if (!baseComputedStyle) { |
796 // Check UA, user and author rules. | 796 // Check UA, user and author rules. |
797 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); | 797 ElementRuleCollector collector(state.elementContext(), m_selectorFilter,
state.style()); |
798 collector.setPseudoStyleRequest(pseudoStyleRequest); | 798 collector.setPseudoStyleRequest(pseudoStyleRequest); |
799 | 799 |
800 matchUARules(collector); | 800 matchUARules(collector); |
801 matchAuthorRules(state.element(), collector, false); | 801 matchAuthorRules(state.element(), collector, false); |
802 | 802 |
803 if (collector.matchedResult().matchedProperties.isEmpty()) | 803 if (collector.matchedResult().matchedProperties.isEmpty()) |
804 return false; | 804 return false; |
805 | 805 |
806 applyMatchedProperties(state, collector.matchedResult()); | 806 applyMatchedProperties(state, collector.matchedResult()); |
807 applyCallbackSelectors(state); | 807 applyCallbackSelectors(state); |
808 | 808 |
809 // Cache our original display. | 809 // Cache our original display. |
810 state.style()->setOriginalDisplay(state.style()->display()); | 810 state.style()->setOriginalDisplay(state.style()->display()); |
811 | 811 |
812 // FIXME: Passing 0 as the Element* introduces a lot of complexity | 812 // FIXME: Passing 0 as the Element* introduces a lot of complexity |
813 // in the adjustLayoutStyle code. | 813 // in the adjustComputedStyle code. |
814 adjustLayoutStyle(state, 0); | 814 adjustComputedStyle(state, 0); |
815 | 815 |
816 if (elementAnimations) | 816 if (elementAnimations) |
817 elementAnimations->updateBaseLayoutStyle(state.style()); | 817 elementAnimations->updateBaseComputedStyle(state.style()); |
818 } | 818 } |
819 | 819 |
820 // FIXME: The CSSWG wants to specify that the effects of animations are appl
ied before | 820 // FIXME: The CSSWG wants to specify that the effects of animations are appl
ied before |
821 // important rules, but this currently happens here as we require adjustment
to have happened | 821 // important rules, but this currently happens here as we require adjustment
to have happened |
822 // before deciding which properties to transition. | 822 // before deciding which properties to transition. |
823 if (applyAnimatedProperties(state, pseudoElement)) | 823 if (applyAnimatedProperties(state, pseudoElement)) |
824 adjustLayoutStyle(state, 0); | 824 adjustComputedStyle(state, 0); |
825 | 825 |
826 didAccess(); | 826 didAccess(); |
827 | 827 |
828 if (state.style()->hasViewportUnits()) | 828 if (state.style()->hasViewportUnits()) |
829 document().setHasViewportUnits(); | 829 document().setHasViewportUnits(); |
830 | 830 |
831 return true; | 831 return true; |
832 } | 832 } |
833 | 833 |
834 PassRefPtr<LayoutStyle> StyleResolver::pseudoStyleForElement(Element* element, c
onst PseudoStyleRequest& pseudoStyleRequest, const LayoutStyle* parentStyle) | 834 PassRefPtr<ComputedStyle> StyleResolver::pseudoStyleForElement(Element* element,
const PseudoStyleRequest& pseudoStyleRequest, const ComputedStyle* parentStyle) |
835 { | 835 { |
836 ASSERT(parentStyle); | 836 ASSERT(parentStyle); |
837 if (!element) | 837 if (!element) |
838 return nullptr; | 838 return nullptr; |
839 | 839 |
840 StyleResolverState state(document(), element, parentStyle); | 840 StyleResolverState state(document(), element, parentStyle); |
841 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle
, state)) { | 841 if (!pseudoStyleForElementInternal(*element, pseudoStyleRequest, parentStyle
, state)) { |
842 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) | 842 if (pseudoStyleRequest.type == PseudoStyleRequest::ForRenderer) |
843 return nullptr; | 843 return nullptr; |
844 return state.takeStyle(); | 844 return state.takeStyle(); |
845 } | 845 } |
846 | 846 |
847 if (PseudoElement* pseudoElement = element->pseudoElement(pseudoStyleRequest
.pseudoId)) | 847 if (PseudoElement* pseudoElement = element->pseudoElement(pseudoStyleRequest
.pseudoId)) |
848 setAnimationUpdateIfNeeded(state, *pseudoElement); | 848 setAnimationUpdateIfNeeded(state, *pseudoElement); |
849 | 849 |
850 // Now return the style. | 850 // Now return the style. |
851 return state.takeStyle(); | 851 return state.takeStyle(); |
852 } | 852 } |
853 | 853 |
854 PassRefPtr<LayoutStyle> StyleResolver::styleForPage(int pageIndex) | 854 PassRefPtr<ComputedStyle> StyleResolver::styleForPage(int pageIndex) |
855 { | 855 { |
856 ASSERT(!hasPendingAuthorStyleSheets()); | 856 ASSERT(!hasPendingAuthorStyleSheets()); |
857 StyleResolverState state(document(), document().documentElement()); // m_roo
tElementStyle will be set to the document style. | 857 StyleResolverState state(document(), document().documentElement()); // m_roo
tElementStyle will be set to the document style. |
858 | 858 |
859 RefPtr<LayoutStyle> style = LayoutStyle::create(); | 859 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
860 const LayoutStyle* rootElementStyle = state.rootElementStyle() ? state.rootE
lementStyle() : document().layoutStyle(); | 860 const ComputedStyle* rootElementStyle = state.rootElementStyle() ? state.roo
tElementStyle() : document().computedStyle(); |
861 ASSERT(rootElementStyle); | 861 ASSERT(rootElementStyle); |
862 style->inheritFrom(*rootElementStyle); | 862 style->inheritFrom(*rootElementStyle); |
863 state.setStyle(style.release()); | 863 state.setStyle(style.release()); |
864 | 864 |
865 PageRuleCollector collector(rootElementStyle, pageIndex); | 865 PageRuleCollector collector(rootElementStyle, pageIndex); |
866 | 866 |
867 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle
()); | 867 collector.matchPageRules(CSSDefaultStyleSheets::instance().defaultPrintStyle
()); |
868 | 868 |
869 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) | 869 if (ScopedStyleResolver* scopedResolver = document().scopedStyleResolver()) |
870 scopedResolver->matchPageRules(collector); | 870 scopedResolver->matchPageRules(collector); |
871 | 871 |
872 bool inheritedOnly = false; | 872 bool inheritedOnly = false; |
873 | 873 |
874 MatchResult& result = collector.matchedResult(); | 874 MatchResult& result = collector.matchedResult(); |
875 applyMatchedProperties<HighPropertyPriority>(state, result, false, 0, result
.matchedProperties.size() - 1, inheritedOnly); | 875 applyMatchedProperties<HighPropertyPriority>(state, result, false, 0, result
.matchedProperties.size() - 1, inheritedOnly); |
876 | 876 |
877 // If our font got dirtied, go ahead and update it now. | 877 // If our font got dirtied, go ahead and update it now. |
878 updateFont(state); | 878 updateFont(state); |
879 | 879 |
880 applyMatchedProperties<LowPropertyPriority>(state, result, false, 0, result.
matchedProperties.size() - 1, inheritedOnly); | 880 applyMatchedProperties<LowPropertyPriority>(state, result, false, 0, result.
matchedProperties.size() - 1, inheritedOnly); |
881 | 881 |
882 loadPendingResources(state); | 882 loadPendingResources(state); |
883 | 883 |
884 didAccess(); | 884 didAccess(); |
885 | 885 |
886 // Now return the style. | 886 // Now return the style. |
887 return state.takeStyle(); | 887 return state.takeStyle(); |
888 } | 888 } |
889 | 889 |
890 PassRefPtr<LayoutStyle> StyleResolver::initialStyleForElement() | 890 PassRefPtr<ComputedStyle> StyleResolver::initialStyleForElement() |
891 { | 891 { |
892 RefPtr<LayoutStyle> style = LayoutStyle::create(); | 892 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
893 FontBuilder fontBuilder(document()); | 893 FontBuilder fontBuilder(document()); |
894 fontBuilder.setInitial(style->effectiveZoom()); | 894 fontBuilder.setInitial(style->effectiveZoom()); |
895 fontBuilder.createFont(document().styleEngine().fontSelector(), *style); | 895 fontBuilder.createFont(document().styleEngine().fontSelector(), *style); |
896 return style.release(); | 896 return style.release(); |
897 } | 897 } |
898 | 898 |
899 PassRefPtr<LayoutStyle> StyleResolver::styleForText(Text* textNode) | 899 PassRefPtr<ComputedStyle> StyleResolver::styleForText(Text* textNode) |
900 { | 900 { |
901 ASSERT(textNode); | 901 ASSERT(textNode); |
902 | 902 |
903 Node* parentNode = NodeRenderingTraversal::parent(*textNode); | 903 Node* parentNode = NodeRenderingTraversal::parent(*textNode); |
904 if (!parentNode || !parentNode->layoutStyle()) | 904 if (!parentNode || !parentNode->computedStyle()) |
905 return initialStyleForElement(); | 905 return initialStyleForElement(); |
906 return parentNode->mutableLayoutStyle(); | 906 return parentNode->mutableComputedStyle(); |
907 } | 907 } |
908 | 908 |
909 void StyleResolver::updateFont(StyleResolverState& state) | 909 void StyleResolver::updateFont(StyleResolverState& state) |
910 { | 910 { |
911 state.fontBuilder().createFont(document().styleEngine().fontSelector(), stat
e.mutableStyleRef()); | 911 state.fontBuilder().createFont(document().styleEngine().fontSelector(), stat
e.mutableStyleRef()); |
912 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); | 912 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); |
913 state.setConversionZoom(state.style()->effectiveZoom()); | 913 state.setConversionZoom(state.style()->effectiveZoom()); |
914 } | 914 } |
915 | 915 |
916 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) | 916 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 | 1336 |
1337 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(
matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; | 1337 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(
matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; |
1338 bool applyInheritedOnly = false; | 1338 bool applyInheritedOnly = false; |
1339 const CachedMatchedProperties* cachedMatchedProperties = cacheHash ? m_match
edPropertiesCache.find(cacheHash, state, matchResult) : 0; | 1339 const CachedMatchedProperties* cachedMatchedProperties = cacheHash ? m_match
edPropertiesCache.find(cacheHash, state, matchResult) : 0; |
1340 | 1340 |
1341 if (cachedMatchedProperties && MatchedPropertiesCache::isCacheable(element,
*state.style(), *state.parentStyle())) { | 1341 if (cachedMatchedProperties && MatchedPropertiesCache::isCacheable(element,
*state.style(), *state.parentStyle())) { |
1342 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheHit); | 1342 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheHit); |
1343 // We can build up the style by copying non-inherited properties from an
earlier style object built using the same exact | 1343 // We can build up the style by copying non-inherited properties from an
earlier style object built using the same exact |
1344 // style declarations. We then only need to apply the inherited properti
es, if any, as their values can depend on the | 1344 // style declarations. We then only need to apply the inherited properti
es, if any, as their values can depend on the |
1345 // element context. This is fast and saves memory by reusing the style d
ata structures. | 1345 // element context. This is fast and saves memory by reusing the style d
ata structures. |
1346 state.style()->copyNonInheritedFromCached(*cachedMatchedProperties->layo
utStyle); | 1346 state.style()->copyNonInheritedFromCached(*cachedMatchedProperties->comp
utedStyle); |
1347 if (state.parentStyle()->inheritedDataShared(*cachedMatchedProperties->p
arentLayoutStyle) && !isAtShadowBoundary(element) | 1347 if (state.parentStyle()->inheritedDataShared(*cachedMatchedProperties->p
arentComputedStyle) && !isAtShadowBoundary(element) |
1348 && (!state.distributedToInsertionPoint() || state.style()->userModif
y() == READ_ONLY)) { | 1348 && (!state.distributedToInsertionPoint() || state.style()->userModif
y() == READ_ONLY)) { |
1349 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi
t); | 1349 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheInheritedHi
t); |
1350 | 1350 |
1351 EInsideLink linkStatus = state.style()->insideLink(); | 1351 EInsideLink linkStatus = state.style()->insideLink(); |
1352 // If the cache item parent style has identical inherited properties
to the current parent style then the | 1352 // If the cache item parent style has identical inherited properties
to the current parent style then the |
1353 // resulting style will be identical too. We copy the inherited prop
erties over from the cache and are done. | 1353 // resulting style will be identical too. We copy the inherited prop
erties over from the cache and are done. |
1354 state.style()->inheritFrom(*cachedMatchedProperties->layoutStyle); | 1354 state.style()->inheritFrom(*cachedMatchedProperties->computedStyle); |
1355 | 1355 |
1356 // Unfortunately the link status is treated like an inherited proper
ty. We need to explicitly restore it. | 1356 // Unfortunately the link status is treated like an inherited proper
ty. We need to explicitly restore it. |
1357 state.style()->setInsideLink(linkStatus); | 1357 state.style()->setInsideLink(linkStatus); |
1358 | 1358 |
1359 updateFont(state); | 1359 updateFont(state); |
1360 | 1360 |
1361 return; | 1361 return; |
1362 } | 1362 } |
1363 applyInheritedOnly = true; | 1363 applyInheritedOnly = true; |
1364 } | 1364 } |
1365 | 1365 |
1366 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply | 1366 // Now we have all of the matched rules in the appropriate order. Walk the r
ules and apply |
1367 // high-priority properties first, i.e., those properties that other propert
ies depend on. | 1367 // high-priority properties first, i.e., those properties that other propert
ies depend on. |
1368 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important | 1368 // The order is (1) high-priority not important, (2) high-priority important
, (3) normal not important |
1369 // and (4) normal important. | 1369 // and (4) normal important. |
1370 applyMatchedProperties<HighPropertyPriority>(state, matchResult, false, 0, m
atchResult.matchedProperties.size() - 1, applyInheritedOnly); | 1370 applyMatchedProperties<HighPropertyPriority>(state, matchResult, false, 0, m
atchResult.matchedProperties.size() - 1, applyInheritedOnly); |
1371 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match
Result.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherited
Only); | 1371 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match
Result.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherited
Only); |
1372 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match
Result.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1372 applyMatchedProperties<HighPropertyPriority>(state, matchResult, true, match
Result.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
1373 | 1373 |
1374 if (UNLIKELY(isSVGForeignObjectElement(element))) { | 1374 if (UNLIKELY(isSVGForeignObjectElement(element))) { |
1375 // LayoutSVGRoot handles zooming for the whole SVG subtree, so foreignOb
ject content should not be scaled again. | 1375 // LayoutSVGRoot handles zooming for the whole SVG subtree, so foreignOb
ject content should not be scaled again. |
1376 // | 1376 // |
1377 // FIXME: The following hijacks the zoom property for foreignObject so t
hat children of foreignObject get the | 1377 // FIXME: The following hijacks the zoom property for foreignObject so t
hat children of foreignObject get the |
1378 // correct font-size in case of zooming. 'zoom' has HighPropertyPriority
, along with other font-related | 1378 // correct font-size in case of zooming. 'zoom' has HighPropertyPriority
, along with other font-related |
1379 // properties used as input to the FontBuilder, so resetting it here may
cause the FontBuilder to recompute the | 1379 // properties used as input to the FontBuilder, so resetting it here may
cause the FontBuilder to recompute the |
1380 // font used as inheritable font for foreignObject content. If we want t
o support zoom on foreignObject we'll | 1380 // font used as inheritable font for foreignObject content. If we want t
o support zoom on foreignObject we'll |
1381 // need to find another way of handling the SVG zoom model. | 1381 // need to find another way of handling the SVG zoom model. |
1382 state.setEffectiveZoom(LayoutStyle::initialZoom()); | 1382 state.setEffectiveZoom(ComputedStyle::initialZoom()); |
1383 } | 1383 } |
1384 | 1384 |
1385 if (cachedMatchedProperties && cachedMatchedProperties->layoutStyle->effecti
veZoom() != state.style()->effectiveZoom()) { | 1385 if (cachedMatchedProperties && cachedMatchedProperties->computedStyle->effec
tiveZoom() != state.style()->effectiveZoom()) { |
1386 state.fontBuilder().didChangeEffectiveZoom(); | 1386 state.fontBuilder().didChangeEffectiveZoom(); |
1387 applyInheritedOnly = false; | 1387 applyInheritedOnly = false; |
1388 } | 1388 } |
1389 | 1389 |
1390 // If our font got dirtied, go ahead and update it now. | 1390 // If our font got dirtied, go ahead and update it now. |
1391 updateFont(state); | 1391 updateFont(state); |
1392 | 1392 |
1393 // Many properties depend on the font. If it changes we just apply all prope
rties. | 1393 // Many properties depend on the font. If it changes we just apply all prope
rties. |
1394 if (cachedMatchedProperties && cachedMatchedProperties->layoutStyle->fontDes
cription() != state.style()->fontDescription()) | 1394 if (cachedMatchedProperties && cachedMatchedProperties->computedStyle->fontD
escription() != state.style()->fontDescription()) |
1395 applyInheritedOnly = false; | 1395 applyInheritedOnly = false; |
1396 | 1396 |
1397 // Now do the normal priority UA properties. | 1397 // Now do the normal priority UA properties. |
1398 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match
Result.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1398 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match
Result.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
1399 | 1399 |
1400 // Cache the UA properties to pass them to LayoutTheme in adjustLayoutStyle. | 1400 // Cache the UA properties to pass them to LayoutTheme in adjustComputedStyl
e. |
1401 state.cacheUserAgentBorderAndBackground(); | 1401 state.cacheUserAgentBorderAndBackground(); |
1402 | 1402 |
1403 // Now do the author and user normal priority properties and all the !import
ant properties. | 1403 // Now do the author and user normal priority properties and all the !import
ant properties. |
1404 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match
Result.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInh
eritedOnly); | 1404 applyMatchedProperties<LowPropertyPriority>(state, matchResult, false, match
Result.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInh
eritedOnly); |
1405 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR
esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO
nly); | 1405 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR
esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO
nly); |
1406 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR
esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1406 applyMatchedProperties<LowPropertyPriority>(state, matchResult, true, matchR
esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
1407 | 1407 |
1408 loadPendingResources(state); | 1408 loadPendingResources(state); |
1409 | 1409 |
1410 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, *state.style(), *state.parentStyle())) { | 1410 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, *state.style(), *state.parentStyle())) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 void StyleResolver::printStats() | 1461 void StyleResolver::printStats() |
1462 { | 1462 { |
1463 if (!m_styleResolverStats) | 1463 if (!m_styleResolverStats) |
1464 return; | 1464 return; |
1465 fprintf(stderr, "=== Style Resolver Stats (resolve #%u) (%s) ===\n", ++m_sty
leResolverStatsSequence, document().url().string().utf8().data()); | 1465 fprintf(stderr, "=== Style Resolver Stats (resolve #%u) (%s) ===\n", ++m_sty
leResolverStatsSequence, document().url().string().utf8().data()); |
1466 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); | 1466 fprintf(stderr, "%s\n", m_styleResolverStats->report().utf8().data()); |
1467 fprintf(stderr, "== Totals ==\n"); | 1467 fprintf(stderr, "== Totals ==\n"); |
1468 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); | 1468 fprintf(stderr, "%s\n", m_styleResolverStatsTotals->report().utf8().data()); |
1469 } | 1469 } |
1470 | 1470 |
1471 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, LayoutStyle* style) | 1471 void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, s
ize_t count, ComputedStyle* style) |
1472 { | 1472 { |
1473 StyleResolverState state(document(), document().documentElement(), style); | 1473 StyleResolverState state(document(), document().documentElement(), style); |
1474 state.setStyle(style); | 1474 state.setStyle(style); |
1475 | 1475 |
1476 for (size_t i = 0; i < count; ++i) { | 1476 for (size_t i = 0; i < count; ++i) { |
1477 if (properties[i].value) { | 1477 if (properties[i].value) { |
1478 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, | 1478 // As described in BUG66291, setting font-size and line-height on a
font may entail a CSSPrimitiveValue::computeLengthDouble call, |
1479 // which assumes the fontMetrics are available for the affected font
, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). | 1479 // which assumes the fontMetrics are available for the affected font
, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122). |
1480 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. | 1480 // The updateFont() call below updates the fontMetrics and ensure th
e proper setting of font-size and line-height. |
1481 switch (properties[i].property) { | 1481 switch (properties[i].property) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 visitor->trace(m_watchedSelectorsRules); | 1519 visitor->trace(m_watchedSelectorsRules); |
1520 visitor->trace(m_treeBoundaryCrossingRules); | 1520 visitor->trace(m_treeBoundaryCrossingRules); |
1521 visitor->trace(m_styleResourceLoader); | 1521 visitor->trace(m_styleResourceLoader); |
1522 visitor->trace(m_styleSharingLists); | 1522 visitor->trace(m_styleSharingLists); |
1523 visitor->trace(m_pendingStyleSheets); | 1523 visitor->trace(m_pendingStyleSheets); |
1524 visitor->trace(m_document); | 1524 visitor->trace(m_document); |
1525 #endif | 1525 #endif |
1526 } | 1526 } |
1527 | 1527 |
1528 } // namespace blink | 1528 } // namespace blink |
OLD | NEW |