Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/StyleElement.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/StyleElement.cpp b/third_party/WebKit/Source/core/dom/StyleElement.cpp |
| index b10eff3d83577e17d6bba2bd9746ae1cc8c1f1a8..b84fd77d39d598705900cfea400b29af4e9e9c0a 100644 |
| --- a/third_party/WebKit/Source/core/dom/StyleElement.cpp |
| +++ b/third_party/WebKit/Source/core/dom/StyleElement.cpp |
| @@ -47,6 +47,7 @@ StyleElement::StyleElement(Document* document, bool createdByParser) |
| : m_createdByParser(createdByParser) |
| , m_loading(false) |
| , m_registeredAsCandidate(false) |
| + , m_beforeBody(false) |
| , m_startPosition(TextPosition::belowRangePosition()) |
| { |
| if (createdByParser && document && document->scriptableDocumentParser() && !document->isInDocumentWrite()) |
| @@ -146,7 +147,7 @@ void StyleElement::clearSheet(Element* ownerElement) |
| DCHECK(m_sheet); |
| if (ownerElement && m_sheet->isLoading()) |
| - ownerElement->document().styleEngine().removePendingSheet(ownerElement); |
| + ownerElement->document().styleEngine().removePendingSheet(ownerElement, m_beforeBody); |
| m_sheet.release()->clearOwnerNode(); |
| } |
| @@ -191,7 +192,8 @@ StyleElement::ProcessingResult StyleElement::createSheet(Element* e, const Strin |
| if (screenEval.eval(mediaQueries) || printEval.eval(mediaQueries)) { |
| m_loading = true; |
| TextPosition startPosition = m_startPosition == TextPosition::belowRangePosition() ? TextPosition::minimumPosition() : m_startPosition; |
| - newSheet = document.styleEngine().createSheet(e, text, startPosition); |
| + m_beforeBody = m_beforeBody || !document.body(); |
|
esprehn
2016/05/06 21:50:15
Can we move this into the StyleEngine instead?
Pat Meenan
2016/05/09 18:51:05
The main issue is that we need to keep track of if
|
| + newSheet = document.styleEngine().createSheet(e, text, startPosition, m_beforeBody); |
| newSheet->setMediaQueries(mediaQueries); |
| m_loading = false; |
| } |
| @@ -219,13 +221,14 @@ bool StyleElement::sheetLoaded(Document& document) |
| if (isLoading()) |
| return false; |
| - document.styleEngine().removePendingSheet(m_sheet->ownerNode()); |
| + document.styleEngine().removePendingSheet(m_sheet->ownerNode(), m_beforeBody); |
| return true; |
| } |
| void StyleElement::startLoadingDynamicSheet(Document& document) |
| { |
| - document.styleEngine().addPendingSheet(); |
| + m_beforeBody = m_beforeBody || !document.body(); |
| + document.styleEngine().addPendingSheet(m_beforeBody); |
| } |
| DEFINE_TRACE(StyleElement) |