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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 | 630 |
631 MediaQueryMatcher& Document::mediaQueryMatcher() | 631 MediaQueryMatcher& Document::mediaQueryMatcher() |
632 { | 632 { |
633 if (!m_mediaQueryMatcher) | 633 if (!m_mediaQueryMatcher) |
634 m_mediaQueryMatcher = MediaQueryMatcher::create(*this); | 634 m_mediaQueryMatcher = MediaQueryMatcher::create(*this); |
635 return *m_mediaQueryMatcher; | 635 return *m_mediaQueryMatcher; |
636 } | 636 } |
637 | 637 |
638 void Document::mediaQueryAffectingValueChanged() | 638 void Document::mediaQueryAffectingValueChanged() |
639 { | 639 { |
640 styleResolverChanged(); | 640 styleEngine().resolverChanged(FullStyleUpdate); |
641 m_evaluateMediaQueriesOnStyleRecalc = true; | 641 m_evaluateMediaQueriesOnStyleRecalc = true; |
642 styleEngine().clearMediaQueryRuleSetStyleSheets(); | 642 styleEngine().clearMediaQueryRuleSetStyleSheets(); |
643 InspectorInstrumentation::mediaQueryResultChanged(this); | 643 InspectorInstrumentation::mediaQueryResultChanged(this); |
644 } | 644 } |
645 | 645 |
646 void Document::setCompatibilityMode(CompatibilityMode mode) | 646 void Document::setCompatibilityMode(CompatibilityMode mode) |
647 { | 647 { |
648 if (m_compatibilityModeLocked || mode == m_compatibilityMode) | 648 if (m_compatibilityModeLocked || mode == m_compatibilityMode) |
649 return; | 649 return; |
650 m_compatibilityMode = mode; | 650 m_compatibilityMode = mode; |
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. | 2008 // FIXME: We are willing to attempt to suppress painting with outdated s
tyle info only once. |
2009 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page | 2009 // Our assumption is that it would be dangerous to try to stop it a seco
nd time, after page |
2010 // content has already been loaded and displayed with accurate style inf
ormation. (Our | 2010 // content has already been loaded and displayed with accurate style inf
ormation. (Our |
2011 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we | 2011 // suppression involves blanking the whole page at the moment. If it wer
e more refined, we |
2012 // might be able to do something better.) It's worth noting though that
this entire method | 2012 // might be able to do something better.) It's worth noting though that
this entire method |
2013 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with | 2013 // is a hack, since what we really want to do is suspend JS instead of d
oing a layout with |
2014 // inaccurate information. | 2014 // inaccurate information. |
2015 HTMLElement* bodyElement = body(); | 2015 HTMLElement* bodyElement = body(); |
2016 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout
== NoLayoutWithPendingSheets) { | 2016 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout
== NoLayoutWithPendingSheets) { |
2017 m_pendingSheetLayout = DidLayoutWithPendingSheets; | 2017 m_pendingSheetLayout = DidLayoutWithPendingSheets; |
2018 styleResolverChanged(); | 2018 styleEngine().resolverChanged(FullStyleUpdate); |
2019 } else if (m_hasNodesWithPlaceholderStyle) { | 2019 } else if (m_hasNodesWithPlaceholderStyle) { |
2020 // If new nodes have been added or style recalc has been done with s
tyle sheets still | 2020 // If new nodes have been added or style recalc has been done with s
tyle sheets still |
2021 // pending, some nodes may not have had their real style calculated
yet. Normally this | 2021 // pending, some nodes may not have had their real style calculated
yet. Normally this |
2022 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. | 2022 // gets cleaned when style sheets arrive but here we need up-to-date
style immediately. |
2023 updateLayoutTree(Force); | 2023 updateLayoutTree(Force); |
2024 } | 2024 } |
2025 } | 2025 } |
2026 updateLayoutTreeIfNeeded(); | 2026 updateLayoutTreeIfNeeded(); |
2027 } | 2027 } |
2028 | 2028 |
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3442 } | 3442 } |
3443 | 3443 |
3444 String Document::selectedStylesheetSet() const | 3444 String Document::selectedStylesheetSet() const |
3445 { | 3445 { |
3446 return m_styleEngine->selectedStylesheetSetName(); | 3446 return m_styleEngine->selectedStylesheetSetName(); |
3447 } | 3447 } |
3448 | 3448 |
3449 void Document::setSelectedStylesheetSet(const String& aString) | 3449 void Document::setSelectedStylesheetSet(const String& aString) |
3450 { | 3450 { |
3451 styleEngine().setSelectedStylesheetSetName(aString); | 3451 styleEngine().setSelectedStylesheetSetName(aString); |
3452 styleResolverChanged(); | 3452 styleEngine().resolverChanged(FullStyleUpdate); |
3453 } | 3453 } |
3454 | 3454 |
3455 void Document::evaluateMediaQueryListIfNeeded() | 3455 void Document::evaluateMediaQueryListIfNeeded() |
3456 { | 3456 { |
3457 if (!m_evaluateMediaQueriesOnStyleRecalc) | 3457 if (!m_evaluateMediaQueriesOnStyleRecalc) |
3458 return; | 3458 return; |
3459 evaluateMediaQueryList(); | 3459 evaluateMediaQueryList(); |
3460 m_evaluateMediaQueriesOnStyleRecalc = false; | 3460 m_evaluateMediaQueriesOnStyleRecalc = false; |
3461 } | 3461 } |
3462 | 3462 |
3463 void Document::evaluateMediaQueryList() | 3463 void Document::evaluateMediaQueryList() |
3464 { | 3464 { |
3465 if (m_mediaQueryMatcher) | 3465 if (m_mediaQueryMatcher) |
3466 m_mediaQueryMatcher->mediaFeaturesChanged(); | 3466 m_mediaQueryMatcher->mediaFeaturesChanged(); |
3467 } | 3467 } |
3468 | 3468 |
3469 void Document::notifyResizeForViewportUnits() | 3469 void Document::notifyResizeForViewportUnits() |
3470 { | 3470 { |
3471 if (m_mediaQueryMatcher) | 3471 if (m_mediaQueryMatcher) |
3472 m_mediaQueryMatcher->viewportChanged(); | 3472 m_mediaQueryMatcher->viewportChanged(); |
3473 if (!hasViewportUnits()) | 3473 if (!hasViewportUnits()) |
3474 return; | 3474 return; |
3475 ensureStyleResolver().notifyResizeForViewportUnits(); | 3475 ensureStyleResolver().notifyResizeForViewportUnits(); |
3476 setNeedsStyleRecalcForViewportUnits(); | 3476 setNeedsStyleRecalcForViewportUnits(); |
3477 } | 3477 } |
3478 | 3478 |
3479 void Document::styleResolverChanged(StyleResolverUpdateMode updateMode) | 3479 void Document::styleResolverMayHaveChanged() |
3480 { | 3480 { |
3481 styleEngine().resolverChanged(updateMode); | 3481 styleEngine().resolverChanged(hasNodesWithPlaceholderStyle() ? FullStyleUpda
te : AnalyzedStyleUpdate); |
3482 | 3482 |
3483 if (didLayoutWithPendingStylesheets() && !styleEngine().hasPendingSheets())
{ | 3483 if (didLayoutWithPendingStylesheets() && !styleEngine().hasPendingSheets())
{ |
3484 // We need to manually repaint because we avoid doing all repaints in la
yout or style | 3484 // We need to manually repaint because we avoid doing all repaints in la
yout or style |
3485 // recalc while sheets are still loading to avoid FOUC. | 3485 // recalc while sheets are still loading to avoid FOUC. |
3486 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; | 3486 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; |
3487 | 3487 |
3488 ASSERT(layoutView() || importsController()); | 3488 ASSERT(layoutView() || importsController()); |
3489 if (layoutView()) | 3489 if (layoutView()) |
3490 layoutView()->invalidatePaintForViewAndCompositedLayers(); | 3490 layoutView()->invalidatePaintForViewAndCompositedLayers(); |
3491 } | 3491 } |
3492 } | 3492 } |
3493 | 3493 |
3494 void Document::styleResolverMayHaveChanged() | |
3495 { | |
3496 styleResolverChanged(hasNodesWithPlaceholderStyle() ? FullStyleUpdate : Anal
yzedStyleUpdate); | |
3497 } | |
3498 | |
3499 void Document::setHoverNode(PassRefPtrWillBeRawPtr<Node> newHoverNode) | 3494 void Document::setHoverNode(PassRefPtrWillBeRawPtr<Node> newHoverNode) |
3500 { | 3495 { |
3501 m_hoverNode = newHoverNode; | 3496 m_hoverNode = newHoverNode; |
3502 } | 3497 } |
3503 | 3498 |
3504 void Document::setActiveHoverElement(PassRefPtrWillBeRawPtr<Element> newActiveEl
ement) | 3499 void Document::setActiveHoverElement(PassRefPtrWillBeRawPtr<Element> newActiveEl
ement) |
3505 { | 3500 { |
3506 if (!newActiveElement) { | 3501 if (!newActiveElement) { |
3507 m_activeHoverElement.clear(); | 3502 m_activeHoverElement.clear(); |
3508 return; | 3503 return; |
(...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5681 } | 5676 } |
5682 | 5677 |
5683 float Document::devicePixelRatio() const | 5678 float Document::devicePixelRatio() const |
5684 { | 5679 { |
5685 return m_frame ? m_frame->devicePixelRatio() : 1.0; | 5680 return m_frame ? m_frame->devicePixelRatio() : 1.0; |
5686 } | 5681 } |
5687 | 5682 |
5688 void Document::removedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upda
teMode) | 5683 void Document::removedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upda
teMode) |
5689 { | 5684 { |
5690 // If we're in document teardown, then we don't need this notification of ou
r sheet's removal. | 5685 // If we're in document teardown, then we don't need this notification of ou
r sheet's removal. |
5691 // styleResolverChanged() is needed even when the document is inactive so th
at | 5686 // resolverChanged() is needed even when the document is inactive so that im
ported documents |
5692 // imported docuements (which is inactive) notifies the change to the master
document. | 5687 // (which are inactive) notify the change to the master document. |
5693 if (isActive()) | 5688 if (isActive()) |
5694 styleEngine().modifiedStyleSheet(sheet); | 5689 styleEngine().modifiedStyleSheet(sheet); |
5695 styleResolverChanged(updateMode); | 5690 styleEngine().resolverChanged(updateMode); |
| 5691 } |
| 5692 |
| 5693 void Document::addedStyleSheet(StyleSheet*) |
| 5694 { |
| 5695 styleEngine().resolverChanged(FullStyleUpdate); |
5696 } | 5696 } |
5697 | 5697 |
5698 void Document::modifiedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upd
ateMode) | 5698 void Document::modifiedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upd
ateMode) |
5699 { | 5699 { |
5700 // If we're in document teardown, then we don't need this notification of ou
r sheet's removal. | 5700 // If we're in document teardown, then we don't need this notification of ou
r sheet's removal. |
5701 // styleResolverChanged() is needed even when the document is inactive so th
at | 5701 // resolverChanged() is needed even when the document is inactive so that im
ported documents |
5702 // imported docuements (which is inactive) notifies the change to the master
document. | 5702 // (which are inactive) notify the change to the master document. |
5703 if (isActive()) | 5703 if (isActive()) |
5704 styleEngine().modifiedStyleSheet(sheet); | 5704 styleEngine().modifiedStyleSheet(sheet); |
5705 styleResolverChanged(updateMode); | 5705 styleEngine().resolverChanged(updateMode); |
| 5706 } |
| 5707 |
| 5708 void Document::changedSelectorWatch() |
| 5709 { |
| 5710 styleEngine().resolverChanged(FullStyleUpdate); |
5706 } | 5711 } |
5707 | 5712 |
5708 TextAutosizer* Document::textAutosizer() | 5713 TextAutosizer* Document::textAutosizer() |
5709 { | 5714 { |
5710 if (!m_textAutosizer) | 5715 if (!m_textAutosizer) |
5711 m_textAutosizer = TextAutosizer::create(this); | 5716 m_textAutosizer = TextAutosizer::create(this); |
5712 return m_textAutosizer.get(); | 5717 return m_textAutosizer.get(); |
5713 } | 5718 } |
5714 | 5719 |
5715 void Document::setAutofocusElement(Element* element) | 5720 void Document::setAutofocusElement(Element* element) |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5951 #ifndef NDEBUG | 5956 #ifndef NDEBUG |
5952 using namespace blink; | 5957 using namespace blink; |
5953 void showLiveDocumentInstances() | 5958 void showLiveDocumentInstances() |
5954 { | 5959 { |
5955 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5960 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
5956 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5961 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5957 for (Document* document : set) | 5962 for (Document* document : set) |
5958 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5963 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
5959 } | 5964 } |
5960 #endif | 5965 #endif |
OLD | NEW |