diff options
Diffstat (limited to 'Source/WebCore')
75 files changed, 315 insertions, 192 deletions
diff --git a/Source/WebCore/PlatformQt.cmake b/Source/WebCore/PlatformQt.cmake index 44ed482fb..c5466b6c7 100644 --- a/Source/WebCore/PlatformQt.cmake +++ b/Source/WebCore/PlatformQt.cmake @@ -162,6 +162,20 @@ list(APPEND WebCore_SOURCES platform/text/qt/TextBreakIteratorInternalICUQt.cpp ) +QTWEBKIT_GENERATE_MOC_FILES_CPP( + platform/network/qt/DNSQt.cpp + platform/qt/MainThreadSharedTimerQt.cpp +) + +QTWEBKIT_GENERATE_MOC_FILES_H( + platform/network/qt/CookieJarQt.h + platform/network/qt/QNetworkReplyHandler.h + platform/network/qt/QtMIMETypeSniffer.h +) + +QTWEBKIT_GENERATE_MOC_FILE_H(platform/network/qt/NetworkStateNotifierPrivate.h platform/network/qt/NetworkStateNotifierQt.cpp) +QTWEBKIT_GENERATE_MOC_FILE_H(platform/network/qt/SocketStreamHandlePrivate.h platform/network/qt/SocketStreamHandleQt.cpp) + if (COMPILER_IS_GCC_OR_CLANG) set_source_files_properties( platform/graphics/qt/ImageBufferDataQt.cpp @@ -183,6 +197,7 @@ if (ENABLE_GAMEPAD_DEPRECATED) list(APPEND WebCore_SOURCES platform/qt/GamepadsQt.cpp ) + QTWEBKIT_GENERATE_MOC_FILES_CPP(platform/qt/GamepadsQt.cpp) endif () if (ENABLE_GRAPHICS_CONTEXT_3D) @@ -359,6 +374,7 @@ if (USE_QT_MULTIMEDIA) list(APPEND WebCore_LIBRARIES ${Qt5Multimedia_LIBRARIES} ) + QTWEBKIT_GENERATE_MOC_FILES_H(platform/graphics/qt/MediaPlayerPrivateQt.h) endif () if (ENABLE_VIDEO) diff --git a/Source/WebCore/bindings/js/ScriptController.cpp b/Source/WebCore/bindings/js/ScriptController.cpp index 1bd6efcac..93bbd3cc4 100644 --- a/Source/WebCore/bindings/js/ScriptController.cpp +++ b/Source/WebCore/bindings/js/ScriptController.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006-2008, 2016 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -197,7 +197,7 @@ void ScriptController::getAllWorlds(Vector<Ref<DOMWrapperWorld>>& worlds) static_cast<JSVMClientData*>(JSDOMWindow::commonVM().clientData)->getAllWorlds(worlds); } -void ScriptController::clearWindowShell(DOMWindow* newDOMWindow, bool goingIntoPageCache) +void ScriptController::clearWindowShellsNotMatchingDOMWindow(DOMWindow* newDOMWindow, bool goingIntoPageCache) { if (m_windowShells.isEmpty()) return; @@ -205,16 +205,13 @@ void ScriptController::clearWindowShell(DOMWindow* newDOMWindow, bool goingIntoP JSLockHolder lock(JSDOMWindowBase::commonVM()); Vector<JSC::Strong<JSDOMWindowShell>> windowShells = this->windowShells(); - for (size_t i = 0; i < windowShells.size(); ++i) { - JSDOMWindowShell* windowShell = windowShells[i].get(); - + for (auto& windowShell : windowShells) { if (&windowShell->window()->wrapped() == newDOMWindow) continue; // Clear the debugger and console from the current window before setting the new window. - attachDebugger(windowShell, nullptr); + attachDebugger(windowShell.get(), nullptr); windowShell->window()->setConsoleClient(nullptr); - // FIXME: We should clear console profiles for each frame as soon as the frame is destroyed. // Instead of clearing all of them when the main frame is destroyed. if (m_frame.isMainFrame()) { @@ -223,24 +220,39 @@ void ScriptController::clearWindowShell(DOMWindow* newDOMWindow, bool goingIntoP } windowShell->window()->willRemoveFromWindowShell(); - windowShell->setWindow(newDOMWindow); + } + + // It's likely that resetting our windows created a lot of garbage, unless + // it went in a back/forward cache. + if (!goingIntoPageCache) + collectGarbageAfterWindowShellDestruction(); +} +void ScriptController::setDOMWindowForWindowShell(DOMWindow* newDOMWindow) +{ + if (m_windowShells.isEmpty()) + return; + + JSLockHolder lock(JSDOMWindowBase::commonVM()); + + Vector<JSC::Strong<JSDOMWindowShell>> windowShells = this->windowShells(); + for (auto& windowShell : windowShells) { + if (&windowShell->window()->wrapped() == newDOMWindow) + continue; + + windowShell->setWindow(newDOMWindow); + // An m_cacheableBindingRootObject persists between page navigations // so needs to know about the new JSDOMWindow. if (m_cacheableBindingRootObject) m_cacheableBindingRootObject->updateGlobalObject(windowShell->window()); - + if (Page* page = m_frame.page()) { - attachDebugger(windowShell, page->debugger()); + attachDebugger(windowShell.get(), page->debugger()); windowShell->window()->setProfileGroup(page->group().identifier()); windowShell->window()->setConsoleClient(&page->console()); } } - - // It's likely that resetting our windows created a lot of garbage, unless - // it went in a back/forward cache. - if (!goingIntoPageCache) - collectGarbageAfterWindowShellDestruction(); } JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld& world) diff --git a/Source/WebCore/bindings/js/ScriptController.h b/Source/WebCore/bindings/js/ScriptController.h index 62a51b855..6f65c722e 100644 --- a/Source/WebCore/bindings/js/ScriptController.h +++ b/Source/WebCore/bindings/js/ScriptController.h @@ -1,7 +1,7 @@ /* * Copyright (C) 1999 Harri Porten (porten@kde.org) * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2016 Apple Inc. All rights reserved. * Copyright (C) 2008 Eric Seidel <eric@webkit.org> * * This library is free software; you can redistribute it and/or @@ -135,7 +135,8 @@ public: const String* sourceURL() const { return m_sourceURL; } // 0 if we are not evaluating any script - void clearWindowShell(DOMWindow* newDOMWindow, bool goingIntoPageCache); + void clearWindowShellsNotMatchingDOMWindow(DOMWindow* newDOMWindow, bool goingIntoPageCache); + void setDOMWindowForWindowShell(DOMWindow* newDOMWindow); void updateDocument(); void namedItemAdded(HTMLDocument*, const AtomicString&) { } diff --git a/Source/WebCore/contentextensions/ContentExtensionStyleSheet.cpp b/Source/WebCore/contentextensions/ContentExtensionStyleSheet.cpp index d3126773f..44d7c5738 100644 --- a/Source/WebCore/contentextensions/ContentExtensionStyleSheet.cpp +++ b/Source/WebCore/contentextensions/ContentExtensionStyleSheet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Apple Inc. All rights reserved. + * Copyright (C) 2015-2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -43,6 +43,11 @@ ContentExtensionStyleSheet::ContentExtensionStyleSheet(Document& document) m_styleSheet->contents().setIsUserStyleSheet(true); } +ContentExtensionStyleSheet::~ContentExtensionStyleSheet() +{ + m_styleSheet->clearOwnerNode(); +} + bool ContentExtensionStyleSheet::addDisplayNoneSelector(const String& selector, uint32_t selectorID) { ASSERT(selectorID != std::numeric_limits<uint32_t>::max()); diff --git a/Source/WebCore/contentextensions/ContentExtensionStyleSheet.h b/Source/WebCore/contentextensions/ContentExtensionStyleSheet.h index a503b586a..514407676 100644 --- a/Source/WebCore/contentextensions/ContentExtensionStyleSheet.h +++ b/Source/WebCore/contentextensions/ContentExtensionStyleSheet.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Apple Inc. All rights reserved. + * Copyright (C) 2015-2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -45,6 +45,7 @@ public: { return adoptRef(*new ContentExtensionStyleSheet(document)); } + virtual ~ContentExtensionStyleSheet(); bool addDisplayNoneSelector(const String& selector, uint32_t selectorID); diff --git a/Source/WebCore/css/CSSValue.h b/Source/WebCore/css/CSSValue.h index 59dc61744..4b7edc785 100644 --- a/Source/WebCore/css/CSSValue.h +++ b/Source/WebCore/css/CSSValue.h @@ -27,6 +27,7 @@ #include <wtf/RefCounted.h> #include <wtf/RefPtr.h> #include <wtf/TypeCasts.h> +#include <functional> namespace WebCore { diff --git a/Source/WebCore/css/StyleSheetContents.h b/Source/WebCore/css/StyleSheetContents.h index f25662172..376e47951 100644 --- a/Source/WebCore/css/StyleSheetContents.h +++ b/Source/WebCore/css/StyleSheetContents.h @@ -30,6 +30,7 @@ #include <wtf/Vector.h> #include <wtf/text/AtomicStringHash.h> #include <wtf/text/TextPosition.h> +#include <functional> namespace WebCore { diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp index f34a1c15f..2598b0f1e 100644 --- a/Source/WebCore/dom/Document.cpp +++ b/Source/WebCore/dom/Document.cpp @@ -1769,6 +1769,8 @@ void Document::scheduleForcedStyleRecalc() void Document::scheduleStyleRecalc() { + ASSERT(!m_renderView || !m_renderView->inHitTesting()); + if (m_styleRecalcTimer.isActive() || inPageCache()) return; diff --git a/Source/WebCore/dom/InlineStyleSheetOwner.cpp b/Source/WebCore/dom/InlineStyleSheetOwner.cpp index e6e7acdb0..83574842c 100644 --- a/Source/WebCore/dom/InlineStyleSheetOwner.cpp +++ b/Source/WebCore/dom/InlineStyleSheetOwner.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2006, 2007 Rob Buis - * Copyright (C) 2008, 2013 Apple, Inc. All rights reserved. + * Copyright (C) 2008-2016 Apple, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -46,6 +46,8 @@ InlineStyleSheetOwner::InlineStyleSheetOwner(Document& document, bool createdByP InlineStyleSheetOwner::~InlineStyleSheetOwner() { + if (m_sheet) + clearSheet(); } static AuthorStyleSheets& authorStyleSheetsForElement(Element& element) diff --git a/Source/WebCore/editing/AlternativeTextController.cpp b/Source/WebCore/editing/AlternativeTextController.cpp index 73102571a..32c204d14 100644 --- a/Source/WebCore/editing/AlternativeTextController.cpp +++ b/Source/WebCore/editing/AlternativeTextController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006-2008, 2016 Apple Inc. All rights reserved. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) * * Redistribution and use in source and binary forms, with or without @@ -315,6 +315,8 @@ void AlternativeTextController::respondToUnappliedSpellCorrection(const VisibleS { if (AlternativeTextClient* client = alternativeTextClient()) client->recordAutocorrectionResponse(AutocorrectionReverted, corrected, correction); + + Ref<Frame> protector(m_frame); m_frame.document()->updateLayout(); m_frame.selection().setSelection(selectionOfCorrected, FrameSelection::defaultSetSelectionOptions() | FrameSelection::SpellCorrectionTriggered); RefPtr<Range> range = Range::create(*m_frame.document(), m_frame.selection().selection().start(), m_frame.selection().selection().end()); diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp index cdbfbda74..41a9730ab 100644 --- a/Source/WebCore/editing/Editor.cpp +++ b/Source/WebCore/editing/Editor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007, 2008, 2011, 2013-2015 Apple Inc. All rights reserved. + * Copyright (C) 2006-2008, 2011, 2013-2016 Apple Inc. All rights reserved. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) * * Redistribution and use in source and binary forms, with or without @@ -1743,6 +1743,8 @@ void Editor::setComposition(const String& text, SetCompositionMode mode) void Editor::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, unsigned selectionStart, unsigned selectionEnd) { + Ref<Frame> protection(m_frame); + UserTypingGestureIndicator typingGestureIndicator(m_frame); setIgnoreCompositionSelectionChange(true); @@ -1876,6 +1878,8 @@ void Editor::learnSpelling() #if !PLATFORM(IOS) void Editor::advanceToNextMisspelling(bool startBeforeSelection) { + Ref<Frame> protection(m_frame); + // The basic approach is to search in two phases - from the selection end to the end of the doc, and // then we wrap and search from the doc start to (approximately) where we started. @@ -2191,6 +2195,8 @@ void Editor::markMisspellingsAndBadGrammar(const VisibleSelection &movingSelecti void Editor::markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, const VisibleSelection& selectionAfterTyping, bool doReplacement) { + Ref<Frame> protection(m_frame); + #if PLATFORM(IOS) UNUSED_PARAM(selectionAfterTyping); UNUSED_PARAM(doReplacement); @@ -2437,6 +2443,7 @@ static void correctSpellcheckingPreservingTextCheckingParagraph(TextCheckingPara void Editor::markAndReplaceFor(PassRefPtr<SpellCheckRequest> request, const Vector<TextCheckingResult>& results) { + Ref<Frame> protection(m_frame); ASSERT(request); TextCheckingTypeMask textCheckingOptions = request->data().mask(); @@ -2889,6 +2896,8 @@ void Editor::dismissCorrectionPanelAsIgnored() void Editor::changeSelectionAfterCommand(const VisibleSelection& newSelection, FrameSelection::SetSelectionOptions options, AXTextStateChangeIntent intent) { + Ref<Frame> protection(m_frame); + // If the new selection is orphaned, then don't update the selection. if (newSelection.start().isOrphan() || newSelection.end().isOrphan()) return; @@ -3079,6 +3088,8 @@ void Editor::applyEditingStyleToElement(Element* element) const bool Editor::findString(const String& target, FindOptions options) { + Ref<Frame> protection(m_frame); + VisibleSelection selection = m_frame.selection().selection(); RefPtr<Range> resultRange = rangeOfString(target, selection.firstRange().get(), options); diff --git a/Source/WebCore/editing/EditorCommand.cpp b/Source/WebCore/editing/EditorCommand.cpp index 82e5daa66..92674c58a 100644 --- a/Source/WebCore/editing/EditorCommand.cpp +++ b/Source/WebCore/editing/EditorCommand.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007, 2008, 2014 Apple Inc. All rights reserved. + * Copyright (C) 2006-2008, 2014, 2016 Apple Inc. All rights reserved. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) * Copyright (C) 2009 Igalia S.L. * @@ -1064,6 +1064,7 @@ static bool executeSuperscript(Frame& frame, Event*, EditorCommandSource source, static bool executeSwapWithMark(Frame& frame, Event*, EditorCommandSource, const String&) { + Ref<Frame> protector(frame); const VisibleSelection& mark = frame.editor().mark(); const VisibleSelection& selection = frame.selection().selection(); if (mark.isNone() || selection.isNone()) { diff --git a/Source/WebCore/editing/TypingCommand.cpp b/Source/WebCore/editing/TypingCommand.cpp index a0f912ab0..f8b4509df 100644 --- a/Source/WebCore/editing/TypingCommand.cpp +++ b/Source/WebCore/editing/TypingCommand.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2005-2008, 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -438,6 +438,7 @@ bool TypingCommand::makeEditableRootEmpty() void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool shouldAddToKillRing) { Frame& frame = this->frame(); + Ref<Frame> protector(frame); frame.editor().updateMarkersForWordsAffectedByEditing(false); @@ -547,6 +548,7 @@ void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool shouldAdd void TypingCommand::forwardDeleteKeyPressed(TextGranularity granularity, bool shouldAddToKillRing) { Frame& frame = this->frame(); + Ref<Frame> protector(frame); frame.editor().updateMarkersForWordsAffectedByEditing(false); diff --git a/Source/WebCore/loader/DocumentWriter.cpp b/Source/WebCore/loader/DocumentWriter.cpp index 442e3bf57..593c0a5e7 100644 --- a/Source/WebCore/loader/DocumentWriter.cpp +++ b/Source/WebCore/loader/DocumentWriter.cpp @@ -71,6 +71,12 @@ DocumentWriter::DocumentWriter(Frame* frame) void DocumentWriter::replaceDocument(const String& source, Document* ownerDocument) { m_frame->loader().stopAllLoaders(); + + // If we are in the midst of changing the frame's document, don't execute script + // that modifes the document further: + if (m_frame->documentIsBeingReplaced()) + return; + begin(m_frame->document()->url(), true, ownerDocument); // begin() might fire an unload event, which will result in a situation where no new document has been attached, diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp index 705b0f5a5..1d6c60ba5 100644 --- a/Source/WebCore/loader/FrameLoader.cpp +++ b/Source/WebCore/loader/FrameLoader.cpp @@ -591,7 +591,7 @@ void FrameLoader::clear(Document* newDocument, bool clearWindowProperties, bool if (clearWindowProperties) { InspectorInstrumentation::frameWindowDiscarded(&m_frame, m_frame.document()->domWindow()); m_frame.document()->domWindow()->resetUnlessSuspendedForDocumentSuspension(); - m_frame.script().clearWindowShell(newDocument->domWindow(), m_frame.document()->inPageCache()); + m_frame.script().clearWindowShellsNotMatchingDOMWindow(newDocument->domWindow(), m_frame.document()->inPageCache()); } m_frame.selection().prepareForDestruction(); @@ -609,6 +609,9 @@ void FrameLoader::clear(Document* newDocument, bool clearWindowProperties, bool subframeLoader().clear(); + if (clearWindowProperties) + m_frame.script().setDOMWindowForWindowShell(newDocument->domWindow()); + if (clearScriptObjects) m_frame.script().clearScriptObjects(); diff --git a/Source/WebCore/loader/NetscapePlugInStreamLoader.h b/Source/WebCore/loader/NetscapePlugInStreamLoader.h index 9926c3312..0abadacc5 100644 --- a/Source/WebCore/loader/NetscapePlugInStreamLoader.h +++ b/Source/WebCore/loader/NetscapePlugInStreamLoader.h @@ -31,6 +31,7 @@ #include "ResourceLoader.h" #include <wtf/Forward.h> +#include <functional> namespace WebCore { diff --git a/Source/WebCore/loader/ResourceLoader.h b/Source/WebCore/loader/ResourceLoader.h index 189b3bc8a..649ddbc02 100644 --- a/Source/WebCore/loader/ResourceLoader.h +++ b/Source/WebCore/loader/ResourceLoader.h @@ -35,6 +35,7 @@ #include "ResourceRequest.h" #include "ResourceResponse.h" #include <wtf/Forward.h> +#include <functional> namespace WTF { class SchedulePair; diff --git a/Source/WebCore/page/ContextMenuController.cpp b/Source/WebCore/page/ContextMenuController.cpp index 47e5fc970..d528a92cd 100644 --- a/Source/WebCore/page/ContextMenuController.cpp +++ b/Source/WebCore/page/ContextMenuController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006-2007, 2016 Apple Inc. All rights reserved. * Copyright (C) 2010 Igalia S.L * * Redistribution and use in source and binary forms, with or without @@ -223,6 +223,8 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuAction action, co if (!frame) return; + Ref<Frame> protector(*frame); + switch (action) { case ContextMenuItemTagOpenLinkInNewWindow: openNewWindow(m_context.hitTestResult().absoluteLinkURL(), frame, ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes); diff --git a/Source/WebCore/page/DOMSelection.cpp b/Source/WebCore/page/DOMSelection.cpp index e119f64d8..064f76837 100644 --- a/Source/WebCore/page/DOMSelection.cpp +++ b/Source/WebCore/page/DOMSelection.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2009, 2016 Apple Inc. All rights reserved. * Copyright (C) 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -203,7 +203,7 @@ void DOMSelection::collapse(Node* node, int offset, ExceptionCode& ec) if (!isValidForPosition(node)) return; - // FIXME: Eliminate legacy editing positions + Ref<Frame> protector(*m_frame); m_frame->selection().moveTo(createLegacyEditingPosition(node, offset), DOWNSTREAM); } @@ -219,6 +219,7 @@ void DOMSelection::collapseToEnd(ExceptionCode& ec) return; } + Ref<Frame> protector(*m_frame); m_frame->selection().moveTo(selection.end(), DOWNSTREAM); } @@ -234,6 +235,7 @@ void DOMSelection::collapseToStart(ExceptionCode& ec) return; } + Ref<Frame> protector(*m_frame); m_frame->selection().moveTo(selection.start(), DOWNSTREAM); } @@ -257,7 +259,7 @@ void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) return; - // FIXME: Eliminate legacy editing positions + Ref<Frame> protector(*m_frame); m_frame->selection().moveTo(createLegacyEditingPosition(baseNode, baseOffset), createLegacyEditingPosition(extentNode, extentOffset), DOWNSTREAM); } @@ -273,7 +275,7 @@ void DOMSelection::setPosition(Node* node, int offset, ExceptionCode& ec) if (!isValidForPosition(node)) return; - // FIXME: Eliminate legacy editing positions + Ref<Frame> protector(*m_frame); m_frame->selection().moveTo(createLegacyEditingPosition(node, offset), DOWNSTREAM); } @@ -324,6 +326,7 @@ void DOMSelection::modify(const String& alterString, const String& directionStri else return; + Ref<Frame> protector(*m_frame); m_frame->selection().modify(alter, direction, granularity); } @@ -345,7 +348,7 @@ void DOMSelection::extend(Node* node, int offset, ExceptionCode& ec) if (!isValidForPosition(node)) return; - // FIXME: Eliminate legacy editing positions + Ref<Frame> protector(*m_frame); m_frame->selection().setExtent(createLegacyEditingPosition(node, offset), DOWNSTREAM); } @@ -385,6 +388,8 @@ void DOMSelection::addRange(Range* r) if (!r) return; + Ref<Frame> protector(*m_frame); + FrameSelection& selection = m_frame->selection(); if (selection.isNone()) { @@ -433,6 +438,7 @@ void DOMSelection::deleteFromDocument() if (!selectedRange) return; + Ref<Frame> protector(*m_frame); selectedRange->deleteContents(ASSERT_NO_EXCEPTION); setBaseAndExtent(&selectedRange->startContainer(), selectedRange->startOffset(), &selectedRange->startContainer(), selectedRange->startOffset(), ASSERT_NO_EXCEPTION); diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp index c4cbb67ef..7a874db56 100644 --- a/Source/WebCore/page/DragController.cpp +++ b/Source/WebCore/page/DragController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2009, 2010, 2013, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2009-2010, 2013, 2015-2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -432,6 +432,7 @@ DragOperation DragController::operationForLoad(DragData& dragData) static bool setSelectionToDragCaret(Frame* frame, VisibleSelection& dragCaret, RefPtr<Range>& range, const IntPoint& point) { + Ref<Frame> protector(*frame); frame->selection().setSelection(dragCaret); if (frame->selection().selection().isNone()) { dragCaret = frame->visiblePositionForPoint(point); @@ -752,6 +753,7 @@ bool DragController::startDrag(Frame& src, const DragState& state, DragOperation if (!src.view() || !src.contentRenderer() || !state.source) return false; + Ref<Frame> protector(src); HitTestResult hitTestResult = src.eventHandler().hitTestResultAtPoint(dragOrigin, HitTestRequest::ReadOnly | HitTestRequest::Active); // FIXME(136836): Investigate whether all elements should use the containsIncludingShadowDOM() path here. diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp index a40b4bfab..97a0d2d39 100644 --- a/Source/WebCore/page/EventHandler.cpp +++ b/Source/WebCore/page/EventHandler.cpp @@ -1138,8 +1138,8 @@ HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe } // We should always start hit testing a clean tree. - if (m_frame.document()) - m_frame.document()->updateLayoutIgnorePendingStylesheets(); + if (auto* frameView = m_frame.view()) + frameView->updateLayoutAndStyleIfNeededRecursive(); HitTestResult result(point, padding.height(), padding.width(), padding.height(), padding.width()); RenderView* renderView = m_frame.contentRenderer(); if (!renderView) diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp index 9315237af..f447d5ded 100644 --- a/Source/WebCore/page/Frame.cpp +++ b/Source/WebCore/page/Frame.cpp @@ -267,6 +267,11 @@ void Frame::setDocument(RefPtr<Document>&& newDocument) { ASSERT(!newDocument || newDocument->frame() == this); + if (m_documentIsBeingReplaced) + return; + + m_documentIsBeingReplaced = true; + if (m_doc && m_doc->pageCacheState() != Document::InPageCache) m_doc->prepareForDestruction(); @@ -280,6 +285,8 @@ void Frame::setDocument(RefPtr<Document>&& newDocument) newDocument->didBecomeCurrentDocumentInFrame(); InspectorInstrumentation::frameDocumentUpdated(this); + + m_documentIsBeingReplaced = false; } #if ENABLE(ORIENTATION_EVENTS) @@ -603,6 +610,8 @@ int Frame::checkOverflowScroll(OverflowScrollAction action) } } + Ref<Frame> protectedThis(*this); + if (action == PerformOverflowScroll && (deltaX || deltaY)) { layer->scrollToOffset(layer->scrollOffset() + IntSize(deltaX, deltaY)); diff --git a/Source/WebCore/page/Frame.h b/Source/WebCore/page/Frame.h index d0e22ef4e..f43a93ecb 100644 --- a/Source/WebCore/page/Frame.h +++ b/Source/WebCore/page/Frame.h @@ -162,6 +162,8 @@ namespace WebCore { WEBCORE_EXPORT RenderView* contentRenderer() const; // Root of the render tree for the document contained in this frame. WEBCORE_EXPORT RenderWidget* ownerRenderer() const; // Renderer for the element that contains this frame. + bool documentIsBeingReplaced() const { return m_documentIsBeingReplaced; } + // ======== All public functions below this point are candidates to move out of Frame into another class. ======== void injectUserScripts(UserScriptInjectionTime); @@ -329,6 +331,7 @@ namespace WebCore { int m_activeDOMObjectsAndAnimationsSuspendedCount; bool m_mainFrameWasDestroyed { false }; + bool m_documentIsBeingReplaced { false }; protected: std::unique_ptr<EventHandler> m_eventHandler; diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp index bf35cf8b2..2cddda42c 100644 --- a/Source/WebCore/page/FrameView.cpp +++ b/Source/WebCore/page/FrameView.cpp @@ -1565,7 +1565,7 @@ void FrameView::adjustMediaTypeForPrinting(bool printing) if (printing) { if (m_mediaTypeWhenNotPrinting.isNull()) m_mediaTypeWhenNotPrinting = mediaType(); - setMediaType("print"); + setMediaType("print"); } else { if (!m_mediaTypeWhenNotPrinting.isNull()) setMediaType(m_mediaTypeWhenNotPrinting); @@ -2741,8 +2741,10 @@ void FrameView::setNeedsLayout() return; } - if (RenderView* renderView = this->renderView()) + if (auto* renderView = this->renderView()) { + ASSERT(!renderView->inHitTesting()); renderView->setNeedsLayout(); + } } void FrameView::unscheduleRelayout() diff --git a/Source/WebCore/page/TextIndicator.cpp b/Source/WebCore/page/TextIndicator.cpp index fd0c0ba73..768fd9aa7 100644 --- a/Source/WebCore/page/TextIndicator.cpp +++ b/Source/WebCore/page/TextIndicator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2015-2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -69,6 +69,8 @@ RefPtr<TextIndicator> TextIndicator::createWithRange(const Range& range, TextInd if (!frame) return nullptr; + Ref<Frame> protector(*frame); + #if PLATFORM(IOS) frame->editor().setIgnoreCompositionSelectionChange(true); frame->selection().setUpdateAppearanceEnabled(true); diff --git a/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp b/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp index 9b0fe49fb..6340107aa 100644 --- a/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp +++ b/Source/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp @@ -241,7 +241,7 @@ ALWAYS_INLINE void setDestinationPixels(Uint8ClampedArray* image, int& pixel, fl image->set(pixel++, maxAlpha); } -#if defined(_MSC_VER) && (_MSC_VER >= 1700) +#if COMPILER(MSVC) // Incorrectly diagnosing overwrite of stack in |totals| due to |preserveAlphaValues|. #pragma warning(push) #pragma warning(disable: 4789) @@ -385,7 +385,7 @@ void FEConvolveMatrix::fastSetOuterPixels(PaintingData& paintingData, int x1, in } } -#if defined(_MSC_VER) && (_MSC_VER >= 1700) +#if COMPILER(MSVC) #pragma warning(pop) // Disable of 4789 #endif diff --git a/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp b/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp index 1222196dd..7be647748 100644 --- a/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp @@ -29,7 +29,6 @@ #include "FontDescription.h" #include "FontPlatformData.h" #include <utility> -#include <wtf/ListHashSet.h> #include <wtf/StdLibExtras.h> #include <wtf/text/StringHash.h> #include <wtf/text/WTFString.h> diff --git a/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp b/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp index 1ead333ce..47bcd8df6 100644 --- a/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontCascadeQt.cpp @@ -24,9 +24,7 @@ #include "Font.h" -#include "AffineTransform.h" #include "FontDescription.h" -#include "FontSelector.h" #include "GlyphBuffer.h" #include "Gradient.h" #include "GraphicsContext.h" @@ -264,8 +262,13 @@ void FontCascade::initFormatForTextLayout(QTextLayout* layout, const TextRun& ru if (isSmallCaps()) range.format.setFontCapitalization(QFont::SmallCaps); - if (range.format.propertyCount() && range.length) + if (range.format.propertyCount() && range.length) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + layout->setFormats(QVector<QTextLayout::FormatRange>() << range); +#else layout->setAdditionalFormats(QList<QTextLayout::FormatRange>() << range); +#endif + } } bool FontCascade::canReturnFallbackFontsForComplexText() diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h index 31d169f62..c2d0c9fa2 100644 --- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h +++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h @@ -22,7 +22,6 @@ #ifndef FontCustomPlatformData_h #define FontCustomPlatformData_h -#include "TextFlags.h" #include <QRawFont> #include <wtf/FastMalloc.h> #include <wtf/Forward.h> diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp index bc65c0511..908d881f1 100644 --- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp @@ -24,7 +24,6 @@ #include "FontPlatformData.h" #include "SharedBuffer.h" -#include "WOFFFileFormat.h" #include <QStringList> namespace WebCore { diff --git a/Source/WebCore/platform/graphics/qt/FontPlatformData.h b/Source/WebCore/platform/graphics/qt/FontPlatformData.h index c8375ebcd..8c1327e13 100644 --- a/Source/WebCore/platform/graphics/qt/FontPlatformData.h +++ b/Source/WebCore/platform/graphics/qt/FontPlatformData.h @@ -29,7 +29,6 @@ #include <QFont> #include <QHash> #include <QRawFont> -#include <wtf/Forward.h> #include <wtf/RefCounted.h> namespace WebCore { diff --git a/Source/WebCore/platform/graphics/qt/GradientQt.cpp b/Source/WebCore/platform/graphics/qt/GradientQt.cpp index 72bb00938..3412cfadd 100644 --- a/Source/WebCore/platform/graphics/qt/GradientQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GradientQt.cpp @@ -27,7 +27,6 @@ #include "config.h" #include "Gradient.h" -#include "CSSParser.h" #include "GraphicsContext.h" #include <QGradient> diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp index 7f2f07b60..fe63ff7bb 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp @@ -24,16 +24,13 @@ #include "GraphicsSurface.h" #include "HostWindow.h" #include "ImageBuffer.h" -#include "ImageData.h" #include "NativeImageQt.h" -#include "NotImplemented.h" #include "QWebPageClient.h" #include "SharedBuffer.h" #include "TextureMapperPlatformLayer.h" #include <QOffscreenSurface> #include <private/qopenglextensions_p.h> #include <qpa/qplatformpixmap.h> -#include <wtf/text/CString.h> #if USE(TEXTURE_MAPPER_GL) #include <texmap/TextureMapperGL.h> diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index 59519398e..260081946 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -47,10 +47,8 @@ #include "Color.h" #include "DisplayListRecorder.h" #include "FloatConversion.h" -#include "Font.h" #include "ImageBuffer.h" #include "ImageBufferDataQt.h" -#include "NotImplemented.h" #include "Path.h" #include "Pattern.h" #include "ShadowBlur.h" diff --git a/Source/WebCore/platform/graphics/qt/IconQt.cpp b/Source/WebCore/platform/graphics/qt/IconQt.cpp index 24f13067d..9bd3d5323 100644 --- a/Source/WebCore/platform/graphics/qt/IconQt.cpp +++ b/Source/WebCore/platform/graphics/qt/IconQt.cpp @@ -23,7 +23,6 @@ #include "GraphicsContext.h" #include "IntRect.h" -#include "NotImplemented.h" #include <QMimeDatabase> #include <wtf/text/WTFString.h> diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp index e76572134..9037ae6ac 100644 --- a/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp +++ b/Source/WebCore/platform/graphics/qt/ImageBufferDataQt.cpp @@ -32,7 +32,6 @@ #include "GraphicsContext.h" #include "GraphicsSurface.h" -#include "ImageData.h" #include "IntRect.h" #include "StillImageQt.h" diff --git a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp index 380d22bb5..2295362aa 100644 --- a/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp +++ b/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp @@ -31,14 +31,12 @@ #include "ImageBuffer.h" #include "GraphicsContext.h" -#include "ImageData.h" #include "IntRect.h" #include "MIMETypeRegistry.h" #include "StillImageQt.h" #include "TransparencyLayer.h" #include <runtime/JSCInlines.h> #include <runtime/TypedArrayInlines.h> -#include <wtf/text/CString.h> #include <wtf/text/WTFString.h> #include <QBuffer> diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp index 95548dff3..9091fdc72 100644 --- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp +++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp @@ -25,13 +25,10 @@ #include "GraphicsContext.h" #include "GraphicsLayer.h" #include "HTMLMediaElement.h" -#include "HTMLVideoElement.h" #include "Logging.h" #include "NetworkingContext.h" #include "NotImplemented.h" #include "RenderVideo.h" -#include "TimeRanges.h" -#include "Widget.h" #include <QMediaPlayerControl> #include <QMediaService> diff --git a/Source/WebCore/platform/graphics/qt/PathQt.cpp b/Source/WebCore/platform/graphics/qt/PathQt.cpp index ecafcdb0e..f3d7481ea 100644 --- a/Source/WebCore/platform/graphics/qt/PathQt.cpp +++ b/Source/WebCore/platform/graphics/qt/PathQt.cpp @@ -34,7 +34,6 @@ #include "AffineTransform.h" #include "FloatRect.h" #include "GraphicsContext.h" -#include "ImageBuffer.h" #include "NativeImageQt.h" #include "StrokeStyleApplier.h" #include <QPainterPath> diff --git a/Source/WebCore/platform/graphics/qt/PatternQt.cpp b/Source/WebCore/platform/graphics/qt/PatternQt.cpp index 7aae62599..8795f3547 100644 --- a/Source/WebCore/platform/graphics/qt/PatternQt.cpp +++ b/Source/WebCore/platform/graphics/qt/PatternQt.cpp @@ -26,8 +26,7 @@ #include "config.h" #include "Pattern.h" -#include "AffineTransform.h" -#include "GraphicsContext.h" +#include "Image.h" namespace WebCore { diff --git a/Source/WebCore/platform/graphics/qt/StillImageQt.cpp b/Source/WebCore/platform/graphics/qt/StillImageQt.cpp index 5569474f0..a2fc59e9f 100644 --- a/Source/WebCore/platform/graphics/qt/StillImageQt.cpp +++ b/Source/WebCore/platform/graphics/qt/StillImageQt.cpp @@ -29,7 +29,6 @@ #include "StillImageQt.h" #include "GraphicsContext.h" -#include "IntSize.h" #include "ShadowBlur.h" #include <QPainter> diff --git a/Source/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp b/Source/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp index 73a0e414f..bf3e8c6c5 100644 --- a/Source/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp +++ b/Source/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp @@ -27,8 +27,6 @@ #include "AffineTransform.h" #include "TransformationMatrix.h" -#include "FloatRect.h" -#include "IntRect.h" namespace WebCore { diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp index b6bdf60ca..0610c85b6 100644 --- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp +++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp @@ -47,6 +47,7 @@ #include <wtf/MainThread.h> #include <wtf/NeverDestroyed.h> +#include <wtf/text/win/WCharStringExtras.h> SOFT_LINK_LIBRARY(Mf); SOFT_LINK_OPTIONAL(Mf, MFCreateSourceResolver, HRESULT, STDAPICALLTYPE, (IMFSourceResolver**)); @@ -98,6 +99,7 @@ MediaPlayerPrivateMediaFoundation::MediaPlayerPrivateMediaFoundation(MediaPlayer , m_hasVideo(false) , m_preparingToPlay(false) , m_hwndVideo(nullptr) + , m_volume(1.0) , m_networkState(MediaPlayer::Empty) , m_readyState(MediaPlayer::HaveNothing) , m_weakPtrFactory(this) @@ -147,7 +149,7 @@ static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache() if (SUCCEEDED(hr)) { CALPWSTR mimeTypeArray = propVarMimeTypeArray.calpwstr; for (unsigned i = 0; i < mimeTypeArray.cElems; i++) - cachedTypes.get().add(mimeTypeArray.pElems[i]); + cachedTypes.get().add(nullTerminatedWCharToString(mimeTypeArray.pElems[i])); } PropVariantClear(&propVarMimeTypeArray); @@ -173,6 +175,11 @@ MediaPlayer::SupportsType MediaPlayerPrivateMediaFoundation::supportsType(const void MediaPlayerPrivateMediaFoundation::load(const String& url) { + { + LockHolder locker(m_cachedNaturalSizeLock); + m_cachedNaturalSize = FloatSize(); + } + startCreateMediaSource(url); m_networkState = MediaPlayer::Loading; @@ -215,9 +222,10 @@ bool MediaPlayerPrivateMediaFoundation::supportsFullscreen() const return true; } -FloatSize MediaPlayerPrivateMediaFoundation::naturalSize() const +FloatSize MediaPlayerPrivateMediaFoundation::naturalSize() const { - return m_size; + LockHolder locker(m_cachedNaturalSizeLock); + return m_cachedNaturalSize; } bool MediaPlayerPrivateMediaFoundation::hasVideo() const @@ -299,16 +307,27 @@ bool MediaPlayerPrivateMediaFoundation::paused() const return m_paused; } -void MediaPlayerPrivateMediaFoundation::setVolume(float volume) +bool MediaPlayerPrivateMediaFoundation::setAllChannelVolumes(float volume) { if (!MFGetServicePtr()) - return; + return false; - COMPtr<IMFSimpleAudioVolume> audioVolume; - if (SUCCEEDED(MFGetServicePtr()(m_mediaSession.get(), MR_POLICY_VOLUME_SERVICE, __uuidof(IMFSimpleAudioVolume), (void **)&audioVolume))) { - HRESULT hr = audioVolume->SetMasterVolume(volume); - ASSERT(SUCCEEDED(hr)); - } + COMPtr<IMFAudioStreamVolume> audioVolume; + if (!SUCCEEDED(MFGetServicePtr()(m_mediaSession.get(), MR_STREAM_VOLUME_SERVICE, __uuidof(IMFAudioStreamVolume), (void **)&audioVolume))) + return false; + + UINT32 channelsCount; + HRESULT hr = audioVolume->GetChannelCount(&channelsCount); + ASSERT(SUCCEEDED(hr)); + + Vector<float> volumes(channelsCount, volume); + return SUCCEEDED(audioVolume->SetAllVolumes(channelsCount, volumes.data())); +} + +void MediaPlayerPrivateMediaFoundation::setVolume(float volume) +{ + if (setAllChannelVolumes(volume)) + m_volume = volume; } bool MediaPlayerPrivateMediaFoundation::supportsMuting() const @@ -318,14 +337,7 @@ bool MediaPlayerPrivateMediaFoundation::supportsMuting() const void MediaPlayerPrivateMediaFoundation::setMuted(bool muted) { - if (!MFGetServicePtr()) - return; - - COMPtr<IMFSimpleAudioVolume> audioVolume; - if (SUCCEEDED(MFGetServicePtr()(m_mediaSession.get(), MR_POLICY_VOLUME_SERVICE, __uuidof(IMFSimpleAudioVolume), (void **)&audioVolume))) { - HRESULT hr = audioVolume->SetMute(muted ? TRUE : FALSE); - ASSERT(SUCCEEDED(hr)); - } + setAllChannelVolumes(muted ? 0.0 : m_volume); } MediaPlayer::NetworkState MediaPlayerPrivateMediaFoundation::networkState() const @@ -465,7 +477,7 @@ bool MediaPlayerPrivateMediaFoundation::startCreateMediaSource(const String& url return false; COMPtr<IUnknown> cancelCookie; - Vector<UChar> urlSource = url.charactersWithNullTermination(); + Vector<wchar_t> urlSource = stringToNullTerminatedWChar(url); AsyncCallback* callback = new AsyncCallback(this, false); @@ -749,6 +761,12 @@ void MediaPlayerPrivateMediaFoundation::notifyDeleted() (*it)->onMediaPlayerDeleted(); } +void MediaPlayerPrivateMediaFoundation::setNaturalSize(const FloatSize& size) +{ + LockHolder locker(m_cachedNaturalSizeLock); + m_cachedNaturalSize = size; +} + bool MediaPlayerPrivateMediaFoundation::createOutputNode(COMPtr<IMFStreamDescriptor> sourceSD, COMPtr<IMFTopologyNode>& node) { if (!MFCreateTopologyNodePtr() || !MFCreateAudioRendererActivatePtr() || !MFCreateVideoRendererActivatePtr()) @@ -1554,6 +1572,22 @@ static bool areMediaTypesEqual(IMFMediaType* type1, IMFMediaType* type2) return S_OK == type1->IsEqual(type2, &flags); } +static FloatSize calculateNaturalSize(IMFMediaType* mediaType) +{ + UINT32 width = 0, height = 0; + HRESULT hr = MFGetAttributeSize(mediaType, MF_MT_FRAME_SIZE, &width, &height); + if (FAILED(hr) || !height) + return FloatSize(); + + UINT32 pixelAspectRatioNumerator = 0; + UINT32 pixelAspectRatioDenominator = 0; + hr = MFGetAttributeRatio(mediaType, MF_MT_PIXEL_ASPECT_RATIO, &pixelAspectRatioNumerator, &pixelAspectRatioDenominator); + if (SUCCEEDED(hr) && pixelAspectRatioNumerator && pixelAspectRatioDenominator) + return FloatSize(float(width) * pixelAspectRatioNumerator / pixelAspectRatioDenominator, height); + + return FloatSize(); +} + HRESULT MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::setMediaType(IMFMediaType* mediaType) { if (!mediaType) { @@ -1611,6 +1645,10 @@ HRESULT MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::setMediaType(IM m_scheduler.setFrameRate(defaultFrameRate); } + // Update natural size + if (m_mediaPlayer) + m_mediaPlayer->setNaturalSize(calculateNaturalSize(mediaType)); + ASSERT(mediaType); m_mediaType = mediaType; diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h index 2fdce58ee..c3303cf7b 100644 --- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h +++ b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h @@ -112,6 +112,7 @@ private: bool m_hasAudio; bool m_hasVideo; bool m_preparingToPlay; + float m_volume; HWND m_hwndVideo; MediaPlayer::NetworkState m_networkState; MediaPlayer::ReadyState m_readyState; @@ -121,6 +122,9 @@ private: HashSet<MediaPlayerListener*> m_listeners; Lock m_mutexListeners; + FloatSize m_cachedNaturalSize; + mutable Lock m_cachedNaturalSizeLock; + WeakPtrFactory<MediaPlayerPrivateMediaFoundation> m_weakPtrFactory; COMPtr<IMFMediaSession> m_mediaSession; COMPtr<IMFSourceResolver> m_sourceResolver; @@ -158,10 +162,13 @@ private: void addListener(MediaPlayerListener*); void removeListener(MediaPlayerListener*); + void setNaturalSize(const FloatSize&); void notifyDeleted(); static LRESULT CALLBACK VideoViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); + bool setAllChannelVolumes(float); + class MediaPlayerListener { public: MediaPlayerListener() { } diff --git a/Source/WebCore/platform/mock/mediasource/MockBox.cpp b/Source/WebCore/platform/mock/mediasource/MockBox.cpp index 31028030d..149827610 100644 --- a/Source/WebCore/platform/mock/mediasource/MockBox.cpp +++ b/Source/WebCore/platform/mock/mediasource/MockBox.cpp @@ -31,6 +31,7 @@ #include <runtime/ArrayBuffer.h> #include <runtime/DataView.h> #include <runtime/Int8Array.h> +#include <runtime/TypedArrayInlines.h> #include <wtf/NeverDestroyed.h> #include <wtf/text/StringBuilder.h> diff --git a/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp b/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp index b850e2327..8b69383ff 100644 --- a/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp +++ b/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp @@ -30,10 +30,6 @@ #include "config.h" #include "ResourceHandle.h" -#include "CachedResourceLoader.h" -#include "Frame.h" -#include "FrameNetworkingContext.h" -#include "NotImplemented.h" #include "Page.h" #include "QNetworkReplyHandler.h" #include "ResourceHandleClient.h" diff --git a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp index d74073ec5..655724a4c 100644 --- a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp +++ b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp @@ -101,6 +101,12 @@ QNetworkRequest ResourceRequest::toNetworkRequest(NetworkingContext *context) co request.setUrl(newurl); request.setOriginatingObject(context ? context->originatingObject() : 0); +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) + // HTTP2AllowedAttribute enforces HTTP/2 instead of negotiating, see QTBUG-61397 + if (newurl.scheme().toLower() == QLatin1String("https")) + request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true); +#endif + const HTTPHeaderMap &headers = httpHeaderFields(); for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); it != end; ++it) { diff --git a/Source/WebCore/platform/qt/DeviceMotionClientQt.cpp b/Source/WebCore/platform/qt/DeviceMotionClientQt.cpp index 88fb5c1c6..5c01f29f5 100644 --- a/Source/WebCore/platform/qt/DeviceMotionClientQt.cpp +++ b/Source/WebCore/platform/qt/DeviceMotionClientQt.cpp @@ -23,7 +23,6 @@ #include "DeviceMotionProviderQt.h" -#include <wtf/RefPtr.h> namespace WebCore { diff --git a/Source/WebCore/platform/qt/GamepadsQt.cpp b/Source/WebCore/platform/qt/GamepadsQt.cpp index 6fff52f9a..70b4305de 100644 --- a/Source/WebCore/platform/qt/GamepadsQt.cpp +++ b/Source/WebCore/platform/qt/GamepadsQt.cpp @@ -37,7 +37,6 @@ #include <unistd.h> #include <wtf/HashMap.h> #include <wtf/NeverDestroyed.h> -#include <wtf/text/CString.h> #include <wtf/text/StringHash.h> // Forward declarations for libudev, they are all used opaque so we don't need the definitions. diff --git a/Source/WebCore/platform/qt/MIMETypeRegistryQt.cpp b/Source/WebCore/platform/qt/MIMETypeRegistryQt.cpp index 3e3f879ed..ab34c8333 100644 --- a/Source/WebCore/platform/qt/MIMETypeRegistryQt.cpp +++ b/Source/WebCore/platform/qt/MIMETypeRegistryQt.cpp @@ -31,7 +31,6 @@ #include <QMimeDatabase> #include <wtf/Assertions.h> -#include <wtf/MainThread.h> namespace WebCore { diff --git a/Source/WebCore/platform/qt/MainThreadSharedTimerQt.cpp b/Source/WebCore/platform/qt/MainThreadSharedTimerQt.cpp index 7aae3f1de..0f0864106 100644 --- a/Source/WebCore/platform/qt/MainThreadSharedTimerQt.cpp +++ b/Source/WebCore/platform/qt/MainThreadSharedTimerQt.cpp @@ -34,7 +34,6 @@ #include <QBasicTimer> #include <QCoreApplication> #include <QPointer> -#include <wtf/CurrentTime.h> namespace WebCore { diff --git a/Source/WebCore/platform/qt/PlatformGestureEvent.h b/Source/WebCore/platform/qt/PlatformGestureEvent.h index 1beac6a68..1a0006842 100644 --- a/Source/WebCore/platform/qt/PlatformGestureEvent.h +++ b/Source/WebCore/platform/qt/PlatformGestureEvent.h @@ -28,7 +28,6 @@ #if ENABLE(QT_GESTURE_EVENTS) -#include "FloatPoint.h" #include "IntPoint.h" #include "IntSize.h" #include "PlatformEvent.h" diff --git a/Source/WebCore/platform/qt/PlatformScreenQt.cpp b/Source/WebCore/platform/qt/PlatformScreenQt.cpp index 91ff0ab43..2790a0d9c 100644 --- a/Source/WebCore/platform/qt/PlatformScreenQt.cpp +++ b/Source/WebCore/platform/qt/PlatformScreenQt.cpp @@ -32,7 +32,6 @@ #include "PlatformScreen.h" #include "FloatRect.h" -#include "Frame.h" #include "FrameView.h" #include "HostWindow.h" #include "NotImplemented.h" diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp index 7373acca7..706570399 100644 --- a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp @@ -34,23 +34,17 @@ #include "CSSValueKeywords.h" #include "Chrome.h" #include "ChromeClient.h" -#include "Color.h" #include "Document.h" -#include "Font.h" -#include "FontSelector.h" #include "GraphicsContext.h" #include "HTMLInputElement.h" #include "HTMLNames.h" -#include "LocalizedStrings.h" #include "NotImplemented.h" #include "Page.h" #include "PaintInfo.h" #include "QWebPageClient.h" #include "RenderBox.h" #include "RenderProgress.h" -#include "RenderSlider.h" #include "ScrollbarThemeQStyle.h" -#include "SliderThumbElement.h" #include "StyleResolver.h" #include "UserAgentStyleSheets.h" diff --git a/Source/WebCore/platform/qt/RenderThemeQt.cpp b/Source/WebCore/platform/qt/RenderThemeQt.cpp index 2cd35700a..01968deba 100644 --- a/Source/WebCore/platform/qt/RenderThemeQt.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQt.cpp @@ -31,21 +31,15 @@ #include "RenderThemeQt.h" #include "CSSValueKeywords.h" -#include "Chrome.h" #include "ChromeClient.h" #include "Color.h" #include "ExceptionCodePlaceholder.h" #include "FileList.h" -#include "Font.h" -#include "FontSelector.h" #include "GraphicsContext.h" #include "HTMLInputElement.h" #include "HTMLMediaElement.h" #include "HTMLNames.h" #include "LocalizedStrings.h" -#if ENABLE(VIDEO) -#include "MediaControlElements.h" -#endif #include "NotImplemented.h" #include "Page.h" #include "PaintInfo.h" @@ -56,9 +50,6 @@ #include "ScrollbarTheme.h" #include "StyleResolver.h" #include "TimeRanges.h" -#if ENABLE(VIDEO) -#include "UserAgentScripts.h" -#endif #include "UserAgentStyleSheets.h" #include <wtf/text/StringBuilder.h> @@ -69,6 +60,10 @@ #include <QStyleHints> +#if ENABLE(VIDEO) +#include "UserAgentScripts.h" +#endif + namespace WebCore { using namespace HTMLNames; @@ -542,7 +537,7 @@ bool RenderThemeQt::supportsFocus(ControlPart appearance) const #if ENABLE(VIDEO) String RenderThemeQt::mediaControlsStyleSheet() { - return ASCIILiteral(mediaControlsBaseUserAgentStyleSheet); + return String(mediaControlsBaseUserAgentStyleSheet, sizeof(mediaControlsBaseUserAgentStyleSheet)); } String RenderThemeQt::mediaControlsScript() diff --git a/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp b/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp index e4a34de29..cf5f6491b 100644 --- a/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp @@ -30,11 +30,8 @@ #include "HTMLInputElement.h" #include "HTMLNames.h" #include "HTMLSelectElement.h" -#include "LocalizedStrings.h" -#include "NotImplemented.h" #include "Page.h" #include "PaintInfo.h" -#include "QWebPageClient.h" #include "RenderBox.h" #include "RenderProgress.h" #include "StyleResolver.h" diff --git a/Source/WebCore/platform/qt/TemporaryLinkStubsQt.cpp b/Source/WebCore/platform/qt/TemporaryLinkStubsQt.cpp index fb3352675..1ccc38a67 100644 --- a/Source/WebCore/platform/qt/TemporaryLinkStubsQt.cpp +++ b/Source/WebCore/platform/qt/TemporaryLinkStubsQt.cpp @@ -32,42 +32,17 @@ #include "config.h" -#include "AXObjectCache.h" -#include "CachedResource.h" -#include "CookieJar.h" #include "CookieStorage.h" -#include "Cursor.h" -#include "DNS.h" -#include "FTPDirectoryDocument.h" -#include "FileSystem.h" -#include "Font.h" -#include "Frame.h" -#include "FrameLoader.h" -#include "FrameView.h" -#include "GraphicsContext.h" -#include "IconLoader.h" -#include "IntPoint.h" -#include "URL.h" -#include "Language.h" -#include "LocalizedStrings.h" -#include "Node.h" #include "NotImplemented.h" -#include "Path.h" -#include "PlatformMouseEvent.h" -#include "RenderTheme.h" -#include "SharedBuffer.h" -#include "TextBoundaries.h" -#include "Widget.h" - -#include <float.h> -#include <stdio.h> -#include <stdlib.h> -#include <wtf/text/CString.h> +#include <wtf/Vector.h> +#include <wtf/text/WTFString.h> using namespace WebCore; namespace WebCore { +class URL; + void getSupportedKeySizes(Vector<String>&) { notImplemented(); diff --git a/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp b/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp index 3f2f572ad..4bfb7244f 100644 --- a/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp +++ b/Source/WebCore/platform/qt/ThirdPartyCookiesQt.cpp @@ -20,8 +20,6 @@ #include "config.h" #include "ThirdPartyCookiesQt.h" -#include "Cookie.h" -#include "CookieJar.h" #include "Document.h" #include "NetworkingContext.h" diff --git a/Source/WebCore/platform/qt/URLQt.cpp b/Source/WebCore/platform/qt/URLQt.cpp index 7b588fa5b..00ab8e7ab 100644 --- a/Source/WebCore/platform/qt/URLQt.cpp +++ b/Source/WebCore/platform/qt/URLQt.cpp @@ -20,10 +20,8 @@ #include "config.h" #include "URL.h" -#include "NotImplemented.h" #include "TextEncoding.h" #include "qurl.h" -#include <wtf/text/CString.h> namespace WebCore { diff --git a/Source/WebCore/platform/qt/WidgetQt.cpp b/Source/WebCore/platform/qt/WidgetQt.cpp index 0d1669941..715ed09ea 100644 --- a/Source/WebCore/platform/qt/WidgetQt.cpp +++ b/Source/WebCore/platform/qt/WidgetQt.cpp @@ -33,7 +33,6 @@ #include "Widget.h" #include "Cursor.h" -#include "Font.h" #include "GraphicsContext.h" #include "HostWindow.h" #include "IntRect.h" diff --git a/Source/WebCore/rendering/RenderBlock.cpp b/Source/WebCore/rendering/RenderBlock.cpp index bf1a78a7f..b2d056f94 100644 --- a/Source/WebCore/rendering/RenderBlock.cpp +++ b/Source/WebCore/rendering/RenderBlock.cpp @@ -2751,7 +2751,9 @@ void RenderBlock::computePreferredLogicalWidths() { ASSERT(preferredLogicalWidthsDirty()); - updateFirstLetter(); + // FIXME: Do not even try to reshuffle first letter renderers when we are not in layout + // until after webkit.org/b/163848 is fixed. + updateFirstLetter(view().frameView().isInRenderTreeLayout() ? RenderTreeMutationIsAllowed::Yes : RenderTreeMutationIsAllowed::No); m_minPreferredLogicalWidth = 0; m_maxPreferredLogicalWidth = 0; @@ -3301,7 +3303,7 @@ void RenderBlock::getFirstLetter(RenderObject*& firstLetter, RenderElement*& fir firstLetterContainer = nullptr; } -void RenderBlock::updateFirstLetter() +void RenderBlock::updateFirstLetter(RenderTreeMutationIsAllowed mutationAllowedOrNot) { RenderObject* firstLetterObj; RenderElement* firstLetterContainer; @@ -3322,6 +3324,8 @@ void RenderBlock::updateFirstLetter() if (!is<RenderText>(*firstLetterObj)) return; + if (mutationAllowedOrNot != RenderTreeMutationIsAllowed::Yes) + return; // Our layout state is not valid for the repaints we are going to trigger by // adding and removing children of firstLetterContainer. LayoutStateDisabler layoutStateDisabler(view()); diff --git a/Source/WebCore/rendering/RenderBlock.h b/Source/WebCore/rendering/RenderBlock.h index 49468c586..b8292b138 100644 --- a/Source/WebCore/rendering/RenderBlock.h +++ b/Source/WebCore/rendering/RenderBlock.h @@ -243,7 +243,8 @@ public: LayoutUnit collapsedMarginBeforeForChild(const RenderBox& child) const; LayoutUnit collapsedMarginAfterForChild(const RenderBox& child) const; - virtual void updateFirstLetter(); + enum class RenderTreeMutationIsAllowed { Yes, No }; + virtual void updateFirstLetter(RenderTreeMutationIsAllowed = RenderTreeMutationIsAllowed::Yes); void getFirstLetter(RenderObject*& firstLetter, RenderElement*& firstLetterContainer, RenderObject* skipObject = nullptr); virtual void scrollbarsChanged(bool /*horizontalScrollbarChanged*/, bool /*verticalScrollbarChanged*/) { } diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp index e4809d288..2fe6cbfa8 100644 --- a/Source/WebCore/rendering/RenderBox.cpp +++ b/Source/WebCore/rendering/RenderBox.cpp @@ -55,6 +55,7 @@ #include "RenderIterator.h" #include "RenderLayer.h" #include "RenderLayerCompositor.h" +#include "RenderMultiColumnFlowThread.h" #include "RenderNamedFlowFragment.h" #include "RenderNamedFlowThread.h" #include "RenderTableCell.h" @@ -2264,6 +2265,21 @@ LayoutRect RenderBox::computeRectForRepaint(const LayoutRect& rect, const Render adjustedRect.expand(locationOffset - flooredLocationOffset); locationOffset = flooredLocationOffset; } + + if (is<RenderMultiColumnFlowThread>(this)) { + // We won't normally run this code. Only when the repaintContainer is null (i.e., we're trying + // to get the rect in view coordinates) will we come in here, since normally repaintContainer + // will be set and we'll stop at the flow thread. This case is mainly hit by the check for whether + // or not images should animate. + // FIXME: Just as with offsetFromContainer, we aren't really handling objects that span + // multiple columns properly. + LayoutPoint physicalPoint(flipForWritingMode(adjustedRect.location())); + if (auto* region = downcast<RenderMultiColumnFlowThread>(*this).physicalTranslationFromFlowToRegion((physicalPoint))) { + adjustedRect.setLocation(region->flipForWritingMode(physicalPoint)); + return region->computeRectForRepaint(adjustedRect, repaintContainer, fixed); + } + } + LayoutPoint topLeft = adjustedRect.location(); topLeft.move(locationOffset); @@ -3107,17 +3123,22 @@ LayoutUnit RenderBox::computeReplacedLogicalHeightUsing(SizeType heightType, Len case Percent: case Calculated: { - auto cb = isOutOfFlowPositioned() ? container() : containingBlock(); - while (cb && cb->isAnonymous() && !is<RenderView>(*cb)) { - cb = cb->containingBlock(); - downcast<RenderBlock>(*cb).addPercentHeightDescendant(const_cast<RenderBox&>(*this)); + auto* container = isOutOfFlowPositioned() ? this->container() : containingBlock(); + while (container && container->isAnonymous()) { + // Stop at rendering context root. + if (is<RenderView>(*container) || is<RenderNamedFlowThread>(*container)) + break; + container = container->containingBlock(); + downcast<RenderBlock>(*container).addPercentHeightDescendant(const_cast<RenderBox&>(*this)); } // FIXME: This calculation is not patched for block-flow yet. // https://bugs.webkit.org/show_bug.cgi?id=46500 - if (cb->isOutOfFlowPositioned() && cb->style().height().isAuto() && !(cb->style().top().isAuto() || cb->style().bottom().isAuto())) { - ASSERT_WITH_SECURITY_IMPLICATION(cb->isRenderBlock()); - RenderBlock& block = downcast<RenderBlock>(*cb); + if (container->isOutOfFlowPositioned() + && container->style().height().isAuto() + && !(container->style().top().isAuto() || container->style().bottom().isAuto())) { + ASSERT_WITH_SECURITY_IMPLICATION(container->isRenderBlock()); + auto& block = downcast<RenderBlock>(*container); LogicalExtentComputedValues computedValues; block.computeLogicalHeight(block.logicalHeight(), 0, computedValues); LayoutUnit newContentHeight = computedValues.m_extent - block.borderAndPaddingLogicalHeight() - block.scrollbarLogicalHeight(); @@ -3130,7 +3151,7 @@ LayoutUnit RenderBox::computeReplacedLogicalHeightUsing(SizeType heightType, Len // https://bugs.webkit.org/show_bug.cgi?id=46496 LayoutUnit availableHeight; if (isOutOfFlowPositioned()) - availableHeight = containingBlockLogicalHeightForPositioned(downcast<RenderBoxModelObject>(cb)); + availableHeight = containingBlockLogicalHeightForPositioned(downcast<RenderBoxModelObject>(container)); else { availableHeight = containingBlockLogicalHeightForContent(IncludeMarginBorderPadding); // It is necessary to use the border-box to match WinIE's broken @@ -3138,15 +3159,16 @@ LayoutUnit RenderBox::computeReplacedLogicalHeightUsing(SizeType heightType, Len // table cells using percentage heights. // FIXME: This needs to be made block-flow-aware. If the cell and image are perpendicular block-flows, this isn't right. // https://bugs.webkit.org/show_bug.cgi?id=46997 - while (cb && !is<RenderView>(*cb) && (cb->style().logicalHeight().isAuto() || cb->style().logicalHeight().isPercentOrCalculated())) { - if (cb->isTableCell()) { + while (container && !is<RenderView>(*container) + && (container->style().logicalHeight().isAuto() || container->style().logicalHeight().isPercentOrCalculated())) { + if (container->isTableCell()) { // Don't let table cells squeeze percent-height replaced elements // <http://bugs.webkit.org/show_bug.cgi?id=15359> availableHeight = std::max(availableHeight, intrinsicLogicalHeight()); return valueForLength(logicalHeight, availableHeight - borderAndPaddingLogicalHeight()); } - downcast<RenderBlock>(*cb).addPercentHeightDescendant(const_cast<RenderBox&>(*this)); - cb = cb->containingBlock(); + downcast<RenderBlock>(*container).addPercentHeightDescendant(const_cast<RenderBox&>(*this)); + container = container->containingBlock(); } } return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logicalHeight, availableHeight)); diff --git a/Source/WebCore/rendering/RenderListItem.cpp b/Source/WebCore/rendering/RenderListItem.cpp index 9ce483c2b..06e75c28d 100644 --- a/Source/WebCore/rendering/RenderListItem.cpp +++ b/Source/WebCore/rendering/RenderListItem.cpp @@ -273,7 +273,7 @@ void RenderListItem::insertOrMoveMarkerRendererIfNeeded() if (!m_marker) return; - // FIXME: Do not even try reposition the marker when we are not in layout + // FIXME: Do not even try to reposition the marker when we are not in layout // until after we fixed webkit.org/b/163789. if (!view().frameView().isInRenderTreeLayout()) return; diff --git a/Source/WebCore/rendering/RenderRubyRun.cpp b/Source/WebCore/rendering/RenderRubyRun.cpp index 8abbf9549..3d614add1 100644 --- a/Source/WebCore/rendering/RenderRubyRun.cpp +++ b/Source/WebCore/rendering/RenderRubyRun.cpp @@ -106,7 +106,7 @@ RenderBlock* RenderRubyRun::firstLineBlock() const return 0; } -void RenderRubyRun::updateFirstLetter() +void RenderRubyRun::updateFirstLetter(RenderTreeMutationIsAllowed) { } diff --git a/Source/WebCore/rendering/RenderRubyRun.h b/Source/WebCore/rendering/RenderRubyRun.h index 65cf224a5..3e59ac5db 100644 --- a/Source/WebCore/rendering/RenderRubyRun.h +++ b/Source/WebCore/rendering/RenderRubyRun.h @@ -60,8 +60,8 @@ public: virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) override; virtual void removeChild(RenderObject&) override; - virtual RenderBlock* firstLineBlock() const override; - virtual void updateFirstLetter() override; + RenderBlock* firstLineBlock() const override; + void updateFirstLetter(RenderTreeMutationIsAllowed = RenderTreeMutationIsAllowed::Yes) override; void getOverhang(bool firstLine, RenderObject* startRenderer, RenderObject* endRenderer, float& startOverhang, float& endOverhang) const; diff --git a/Source/WebCore/rendering/RenderTable.cpp b/Source/WebCore/rendering/RenderTable.cpp index b3be2de98..4f325dfb9 100644 --- a/Source/WebCore/rendering/RenderTable.cpp +++ b/Source/WebCore/rendering/RenderTable.cpp @@ -1456,7 +1456,7 @@ RenderBlock* RenderTable::firstLineBlock() const return nullptr; } -void RenderTable::updateFirstLetter() +void RenderTable::updateFirstLetter(RenderTreeMutationIsAllowed) { } diff --git a/Source/WebCore/rendering/RenderTable.h b/Source/WebCore/rendering/RenderTable.h index e2b585146..f49592569 100644 --- a/Source/WebCore/rendering/RenderTable.h +++ b/Source/WebCore/rendering/RenderTable.h @@ -303,8 +303,8 @@ private: void invalidateCachedColumnOffsets(); - virtual RenderBlock* firstLineBlock() const override final; - virtual void updateFirstLetter() override final; + RenderBlock* firstLineBlock() const final; + void updateFirstLetter(RenderTreeMutationIsAllowed = RenderTreeMutationIsAllowed::Yes) final; virtual void updateLogicalWidth() override final; diff --git a/Source/WebCore/rendering/RenderView.cpp b/Source/WebCore/rendering/RenderView.cpp index 3c10cb5cf..5c374092c 100644 --- a/Source/WebCore/rendering/RenderView.cpp +++ b/Source/WebCore/rendering/RenderView.cpp @@ -52,6 +52,7 @@ #include "StyleInheritedData.h" #include "TransformState.h" #include <wtf/StackStats.h> +#include <wtf/TemporaryChange.h> namespace WebCore { @@ -195,6 +196,10 @@ bool RenderView::hitTest(const HitTestRequest& request, HitTestResult& result) bool RenderView::hitTest(const HitTestRequest& request, const HitTestLocation& location, HitTestResult& result) { document().updateLayout(); + +#if !ASSERT_DISABLED + TemporaryChange<bool> hitTestRestorer { m_inHitTesting, true }; +#endif FrameFlatteningLayoutDisallower disallower(frameView()); diff --git a/Source/WebCore/rendering/RenderView.h b/Source/WebCore/rendering/RenderView.h index 40aa58229..9279b9eec 100644 --- a/Source/WebCore/rendering/RenderView.h +++ b/Source/WebCore/rendering/RenderView.h @@ -1,6 +1,6 @@ /* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) - * Copyright (C) 2006, 2015 Apple Inc. + * Copyright (C) 2006, 2015-2016 Apple Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -252,6 +252,10 @@ public: const HashSet<const RenderBox*>& boxesWithScrollSnapCoordinates() { return m_boxesWithScrollSnapCoordinates; } #endif +#if !ASSERT_DISABLED + bool inHitTesting() const { return m_inHitTesting; } +#endif + protected: virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed) const override; virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override; @@ -369,6 +373,9 @@ private: bool m_hasSoftwareFilters; bool m_usesFirstLineRules { false }; bool m_usesFirstLetterRules { false }; +#if !ASSERT_DISABLED + bool m_inHitTesting { false }; +#endif HashSet<RenderElement*> m_renderersWithPausedImageAnimation; HashSet<RenderElement*> m_visibleInViewportRenderers; diff --git a/Source/WebCore/rendering/svg/RenderSVGText.cpp b/Source/WebCore/rendering/svg/RenderSVGText.cpp index 86063acb4..4bb8ef4bf 100644 --- a/Source/WebCore/rendering/svg/RenderSVGText.cpp +++ b/Source/WebCore/rendering/svg/RenderSVGText.cpp @@ -547,7 +547,7 @@ RenderBlock* RenderSVGText::firstLineBlock() const // Fix for <rdar://problem/8048875>. We should not render :first-letter CSS Style // in a SVG text element context. -void RenderSVGText::updateFirstLetter() +void RenderSVGText::updateFirstLetter(RenderTreeMutationIsAllowed) { } diff --git a/Source/WebCore/rendering/svg/RenderSVGText.h b/Source/WebCore/rendering/svg/RenderSVGText.h index 71be1cde3..b2271954b 100644 --- a/Source/WebCore/rendering/svg/RenderSVGText.h +++ b/Source/WebCore/rendering/svg/RenderSVGText.h @@ -91,8 +91,8 @@ private: virtual AffineTransform localTransform() const override { return m_localTransform; } virtual std::unique_ptr<RootInlineBox> createRootInlineBox() override; - virtual RenderBlock* firstLineBlock() const override; - virtual void updateFirstLetter() override; + RenderBlock* firstLineBlock() const override; + void updateFirstLetter(RenderTreeMutationIsAllowed = RenderTreeMutationIsAllowed::Yes) override; bool shouldHandleSubtreeMutations() const; diff --git a/Source/WebCore/style/StyleTreeResolver.cpp b/Source/WebCore/style/StyleTreeResolver.cpp index d6be6658c..8ab152277 100644 --- a/Source/WebCore/style/StyleTreeResolver.cpp +++ b/Source/WebCore/style/StyleTreeResolver.cpp @@ -49,6 +49,7 @@ #include "RenderWidget.h" #include "Settings.h" #include "ShadowRoot.h" +#include "StyleFontSizeFunctions.h" #include "StyleResolver.h" #include "Text.h" @@ -105,6 +106,15 @@ static void ensurePlaceholderStyle(Document& document) return; placeholderStyle = &RenderStyle::create().leakRef(); placeholderStyle->setDisplay(NONE); + + FontCascadeDescription fontDescription; + fontDescription.setOneFamily(standardFamily); + fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium); + float size = Style::fontSizeForKeyword(CSSValueMedium, false, document); + fontDescription.setSpecifiedSize(size); + fontDescription.setComputedSize(size); + placeholderStyle->setFontDescription(fontDescription); + placeholderStyle->fontCascade().update(&document.fontSelector()); } diff --git a/Source/WebCore/xml/XSLTUnicodeSort.cpp b/Source/WebCore/xml/XSLTUnicodeSort.cpp index 54d5abd10..def0f9482 100644 --- a/Source/WebCore/xml/XSLTUnicodeSort.cpp +++ b/Source/WebCore/xml/XSLTUnicodeSort.cpp @@ -33,6 +33,8 @@ #include <libxslt/templates.h> #include <libxslt/xsltutils.h> +#include <wtf/StringExtras.h> +#include <wtf/Vector.h> #include <wtf/unicode/Collator.h> #if OS(DARWIN) && !PLATFORM(EFL) && !PLATFORM(GTK) && !PLATFORM(QT) @@ -51,15 +53,19 @@ void xsltTransformErrorTrampoline(xsltTransformContextPtr context, xsltStyleshee { va_list args; va_start(args, message); - char* messageWithArgs; - vasprintf(&messageWithArgs, message, args); + + va_list preflightArgs; + va_copy(preflightArgs, args); + size_t stringLength = vsnprintf(nullptr, 0, message, preflightArgs); + va_end(preflightArgs); + + Vector<char, 1024> buffer(stringLength + 1); + vsnprintf(buffer.data(), stringLength + 1, message, args); va_end(args); static void (*xsltTransformErrorPointer)(xsltTransformContextPtr, xsltStylesheetPtr, xmlNodePtr, const char*, ...) WTF_ATTRIBUTE_PRINTF(4, 5) = reinterpret_cast<void (*)(xsltTransformContextPtr, xsltStylesheetPtr, xmlNodePtr, const char*, ...)>(dlsym(libxsltLibrary(), "xsltTransformError")); - xsltTransformErrorPointer(context, style, node, "%s", messageWithArgs); - - free(messageWithArgs); + xsltTransformErrorPointer(context, style, node, "%s", buffer.data()); } #define xsltTransformError xsltTransformErrorTrampoline diff --git a/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp b/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp index 0e77eac4d..0bcdc4c92 100644 --- a/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp +++ b/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp @@ -963,24 +963,19 @@ void XMLDocumentParser::error(XMLErrors::ErrorType type, const char* message, va if (isStopped()) return; -#if HAVE(VASPRINTF) - char* m; - if (vasprintf(&m, message, args) == -1) - return; -#else - char m[1024]; - vsnprintf(m, sizeof(m) - 1, message, args); -#endif + va_list preflightArgs; + va_copy(preflightArgs, args); + size_t stringLength = vsnprintf(nullptr, 0, message, preflightArgs); + va_end(preflightArgs); + + Vector<char, 1024> buffer(stringLength + 1); + vsnprintf(buffer.data(), stringLength + 1, message, args); TextPosition position = textPosition(); if (m_parserPaused) - m_pendingCallbacks->appendErrorCallback(type, reinterpret_cast<const xmlChar*>(m), position.m_line, position.m_column); + m_pendingCallbacks->appendErrorCallback(type, reinterpret_cast<const xmlChar*>(buffer.data()), position.m_line, position.m_column); else - handleError(type, m, textPosition()); - -#if HAVE(VASPRINTF) - free(m); -#endif + handleError(type, buffer.data(), textPosition()); } void XMLDocumentParser::processingInstruction(const xmlChar* target, const xmlChar* data) |