OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1597 TRACE_EVENT0("webkit", "Document::recalcStyle"); | 1597 TRACE_EVENT0("webkit", "Document::recalcStyle"); |
1598 | 1598 |
1599 // FIXME: We should update style on our ancestor chain before proceeding (es pecially for seamless), | 1599 // FIXME: We should update style on our ancestor chain before proceeding (es pecially for seamless), |
1600 // however doing so currently causes several tests to crash, as Frame::setDo cument calls Document::attach | 1600 // however doing so currently causes several tests to crash, as Frame::setDo cument calls Document::attach |
1601 // before setting the DOMWindow on the Frame, or the SecurityOrigin on the d ocument. The attach, in turn | 1601 // before setting the DOMWindow on the Frame, or the SecurityOrigin on the d ocument. The attach, in turn |
1602 // resolves style (here) and then when we resolve style on the parent chain, we may end up | 1602 // resolves style (here) and then when we resolve style on the parent chain, we may end up |
1603 // re-attaching our containing iframe, which when asked HTMLFrameElementBase ::isURLAllowed | 1603 // re-attaching our containing iframe, which when asked HTMLFrameElementBase ::isURLAllowed |
1604 // hits a null-dereference due to security code always assuming the document has a SecurityOrigin. | 1604 // hits a null-dereference due to security code always assuming the document has a SecurityOrigin. |
1605 | 1605 |
1606 if (m_styleSheetCollection->needsUpdateActiveStylesheetsOnStyleRecalc()) | 1606 if (m_styleSheetCollection->needsUpdateActiveStylesheetsOnStyleRecalc()) |
1607 m_styleSheetCollection->updateActiveStyleSheets(DocumentStyleSheetCollec tion::FullUpdate); | 1607 m_styleSheetCollection->updateActiveStyleSheets(FullStyleUpdate); |
1608 | 1608 |
1609 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); | 1609 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); |
1610 | 1610 |
1611 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) | 1611 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) |
1612 m_styleSheetCollection->setUsesRemUnit(true); | 1612 m_styleSheetCollection->setUsesRemUnit(true); |
1613 | 1613 |
1614 m_inStyleRecalc = true; | 1614 m_inStyleRecalc = true; |
1615 { | 1615 { |
1616 PostAttachCallbackDisabler disabler(this); | 1616 PostAttachCallbackDisabler disabler(this); |
1617 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; | 1617 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2598 | 2598 |
2599 void Document::seamlessParentUpdatedStylesheets() | 2599 void Document::seamlessParentUpdatedStylesheets() |
2600 { | 2600 { |
2601 styleResolverChanged(RecalcStyleImmediately); | 2601 styleResolverChanged(RecalcStyleImmediately); |
2602 } | 2602 } |
2603 | 2603 |
2604 void Document::didRemoveAllPendingStylesheet() | 2604 void Document::didRemoveAllPendingStylesheet() |
2605 { | 2605 { |
2606 m_needsNotifyRemoveAllPendingStylesheet = false; | 2606 m_needsNotifyRemoveAllPendingStylesheet = false; |
2607 | 2607 |
2608 styleResolverChanged(RecalcStyleIfNeeded); | 2608 styleResolverChanged(DeferRecalcStyle, OptimizedStyleUpdate); |
2609 | 2609 |
2610 if (ScriptableDocumentParser* parser = scriptableDocumentParser()) | 2610 if (ScriptableDocumentParser* parser = scriptableDocumentParser()) |
2611 parser->executeScriptsWaitingForStylesheets(); | 2611 parser->executeScriptsWaitingForStylesheets(); |
adamk
2013/05/13 20:48:37
Do you know if there are tests covering this code
| |
2612 | 2612 |
2613 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) | 2613 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) { |
2614 updateStyleIfNeeded(); | |
2614 view()->scrollToFragment(m_url); | 2615 view()->scrollToFragment(m_url); |
2616 } | |
2615 } | 2617 } |
2616 | 2618 |
2617 CSSStyleSheet* Document::elementSheet() | 2619 CSSStyleSheet* Document::elementSheet() |
2618 { | 2620 { |
2619 if (!m_elemSheet) | 2621 if (!m_elemSheet) |
2620 m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL); | 2622 m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL); |
2621 return m_elemSheet.get(); | 2623 return m_elemSheet.get(); |
2622 } | 2624 } |
2623 | 2625 |
2624 int Document::nodeAbsIndex(Node *node) | 2626 int Document::nodeAbsIndex(Node *node) |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2951 m_styleSheetCollection->setSelectedStylesheetSetName(aString); | 2953 m_styleSheetCollection->setSelectedStylesheetSetName(aString); |
2952 styleResolverChanged(DeferRecalcStyle); | 2954 styleResolverChanged(DeferRecalcStyle); |
2953 } | 2955 } |
2954 | 2956 |
2955 void Document::evaluateMediaQueryList() | 2957 void Document::evaluateMediaQueryList() |
2956 { | 2958 { |
2957 if (m_mediaQueryMatcher) | 2959 if (m_mediaQueryMatcher) |
2958 m_mediaQueryMatcher->styleResolverChanged(); | 2960 m_mediaQueryMatcher->styleResolverChanged(); |
2959 } | 2961 } |
2960 | 2962 |
2961 void Document::styleResolverChanged(StyleResolverUpdateFlag updateFlag) | 2963 void Document::styleResolverChanged(StyleResolverUpdateType updateType, StyleRes olverUpdateMode updateMode) |
2962 { | 2964 { |
2963 // Don't bother updating, since we haven't loaded all our style info yet | 2965 // Don't bother updating, since we haven't loaded all our style info yet |
2964 // and haven't calculated the style selector for the first time. | 2966 // and haven't calculated the style selector for the first time. |
2965 if (!attached() || (!m_didCalculateStyleResolver && !haveStylesheetsLoaded() )) { | 2967 if (!attached() || (!m_didCalculateStyleResolver && !haveStylesheetsLoaded() )) { |
2966 m_styleResolver.clear(); | 2968 m_styleResolver.clear(); |
2967 return; | 2969 return; |
2968 } | 2970 } |
2969 m_didCalculateStyleResolver = true; | 2971 m_didCalculateStyleResolver = true; |
2970 | 2972 |
2971 #ifdef INSTRUMENT_LAYOUT_SCHEDULING | 2973 #ifdef INSTRUMENT_LAYOUT_SCHEDULING |
2972 if (!ownerElement()) | 2974 if (!ownerElement()) |
2973 printf("Beginning update of style selector at time %d.\n", elapsedTime() ); | 2975 printf("Beginning update of style selector at time %d.\n", elapsedTime() ); |
2974 #endif | 2976 #endif |
2975 | 2977 |
2976 DocumentStyleSheetCollection::UpdateFlag styleSheetUpdate = (updateFlag == R ecalcStyleIfNeeded) | 2978 bool needsRecalc = m_styleSheetCollection->updateActiveStyleSheets(updateMod e); |
2977 ? DocumentStyleSheetCollection::OptimizedUpdate | |
2978 : DocumentStyleSheetCollection::FullUpdate; | |
2979 bool stylesheetChangeRequiresStyleRecalc = m_styleSheetCollection->updateAct iveStyleSheets(styleSheetUpdate); | |
2980 | |
2981 if (updateFlag == DeferRecalcStyle) { | |
2982 scheduleForcedStyleRecalc(); | |
2983 return; | |
2984 } | |
2985 | 2979 |
2986 if (didLayoutWithPendingStylesheets() && !m_styleSheetCollection->hasPending Sheets()) { | 2980 if (didLayoutWithPendingStylesheets() && !m_styleSheetCollection->hasPending Sheets()) { |
2987 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; | 2981 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; |
2988 if (renderer()) | 2982 if (renderer()) |
2989 renderView()->repaintViewAndCompositedLayers(); | 2983 renderView()->repaintViewAndCompositedLayers(); |
2990 } | 2984 } |
2991 | 2985 |
2992 if (!stylesheetChangeRequiresStyleRecalc) | 2986 if (!needsRecalc) |
2993 return; | 2987 return; |
2994 | 2988 |
2995 // This recalcStyle initiates a new recalc cycle. We need to bracket it to | 2989 if (updateType >= DeferRecalcStyle) |
2996 // make sure animations get the correct update time | 2990 scheduleForcedStyleRecalc(); |
2997 { | 2991 else { |
2998 AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0); | 2992 AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0); |
2999 recalcStyle(Force); | 2993 recalcStyle(Force); |
3000 } | 2994 } |
3001 | 2995 |
3002 #ifdef INSTRUMENT_LAYOUT_SCHEDULING | 2996 #ifdef INSTRUMENT_LAYOUT_SCHEDULING |
3003 if (!ownerElement()) | 2997 if (!ownerElement()) |
3004 printf("Finished update of style selector at time %d\n", elapsedTime()); | 2998 printf("Finished update of style selector at time %d\n", elapsedTime()); |
3005 #endif | 2999 #endif |
3006 | 3000 |
3007 if (renderer()) { | 3001 if (renderer()) { |
(...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5643 return; | 5637 return; |
5644 | 5638 |
5645 Vector<RefPtr<Element> > associatedFormControls; | 5639 Vector<RefPtr<Element> > associatedFormControls; |
5646 copyToVector(m_associatedFormControls, associatedFormControls); | 5640 copyToVector(m_associatedFormControls, associatedFormControls); |
5647 | 5641 |
5648 frame()->page()->chrome()->client()->didAssociateFormControls(associatedForm Controls); | 5642 frame()->page()->chrome()->client()->didAssociateFormControls(associatedForm Controls); |
5649 m_associatedFormControls.clear(); | 5643 m_associatedFormControls.clear(); |
5650 } | 5644 } |
5651 | 5645 |
5652 } // namespace WebCore | 5646 } // namespace WebCore |
OLD | NEW |