WebKit Bugzilla
Attachment 362291 Details for
Bug 194764
: Some refinements for Node and Document
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194764-20190218044431.patch (text/plain), 62.47 KB, created by
Darin Adler
on 2019-02-18 04:44:32 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Adler
Created:
2019-02-18 04:44:32 PST
Size:
62.47 KB
patch
obsolete
>Subversion Revision: 241662 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 2141a8fc3dfb31427975501667bd3751a04b2ce6..8a648c8557caf0395b9e355036365dd5a6ba4b94 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,170 @@ >+2019-02-17 Darin Adler <darin@apple.com> >+ >+ Some refinements for Node and Document >+ https://bugs.webkit.org/show_bug.cgi?id=194764 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * accessibility/AccessibilityObject.cpp: >+ (WebCore::AccessibilityObject::press): Use shadowHost instead of >+ deprecatedShadowAncestorNode. >+ (WebCore::AccessibilityObject::axObjectCache const): Tweak coding style. >+ (WebCore::AccessibilityObject::focusedUIElement const): Use existing page >+ function to streamline. >+ >+ * accessibility/AccessibilityRenderObject.cpp: >+ (WebCore::AccessibilityRenderObject::accessKey const): Use >+ attributeWithoutSynchronization for efficiency and consistency with other >+ code working with the accesskey attribute. >+ >+ * dom/ContainerNode.cpp: >+ (WebCore::ContainerNode::childrenChanged): Added call to >+ invalidateAccessKeyCache, replacing old scheme tied to style recalculation. >+ >+ * dom/DecodedDataDocumentParser.cpp: >+ (WebCore::DecodedDataDocumentParser::appendBytes): Update for name and return >+ type change of createDecoderIfNeeded to decoder. >+ (WebCore::DecodedDataDocumentParser::flush): Ditto. >+ >+ * dom/Document.cpp: >+ (WebCore::Document::elementForAccessKey): Renamed from getElementForAccessKey >+ to match WebKit coding style. Changed to use unique_ptr instead of separate >+ boolean to keep track of map validity status. >+ (WebCore::Document::buildAccessKeyCache): Renamed from buildAccessKeyMap to >+ clarify that this is a cache. Changed to use composedTreeDescendants rather >+ than explicit calls to shadowRoot. Use add instead of set so that first element >+ in document order wins, instead of last element in document order. Updated >+ to make a new map in a new unique_ptr instead of populating a map. >+ (WebCore::Document::invalidateAccessKeyCacheSlowCase): Renamed from >+ invalidateAccessKeyMap, and left an inline part in the header so the fast case >+ of quickly checking for a null pointer can be inlined. >+ (WebCore::Document::doctype const): Use downcast instead of static_cast. >+ (WebCore::Document::scheduleStyleRecalc): Moved call to invalidateAccessKeyMap >+ from here to childrenChanged and accesskey attribute change handling. >+ (WebCore::Document::processFormatDetection): Set m_isTelephoneNumberParsingAllowed >+ directly since this is the only place that does it and we don't need to factor >+ that one line of code into a function. >+ (WebCore::Document::getOverrideStyle): Moved to header since it's just a stub >+ that always returns nullptr and can be inlined. >+ (WebCore::Document::setIsTelephoneNumberParsingAllowed): Deleted. >+ (WebCore::Document::ensureTemplateDocument): Removed nullptr frame argument to >+ the create function, since Document::create now always involves no frame. >+ (WebCore::Document::didAssociateFormControl): Changed argument type to a reference >+ and simplified the logic with a local variable. >+ (WebCore::Document::didAssociateFormControlsTimerFired): Simplified the null >+ checks and rearranged things so that m_associatedFormControls will always >+ get cleared even if the document is no longer associated with a page. >+ >+ * dom/Document.h: Removed unnnecessary explicit values for enumerations (first >+ value is always zero, etc.) and formatted simple enumerations in a single line >+ for easier reading. Moved Document::create fucntion bodies out of line, removed >+ the frame argument from the simple "create with URL" overload and made the frame >+ argument for createNonRenderedPlaceholder be a reference rather than a pointer. >+ Renamed getElementByAccessKey to elementForAccessKey, invalidateAccessKeyMap to >+ invalidateAccessKeyCache, buildAccessKeyMap to buildAccessKeCache, >+ m_elementsByAccessKey to m_accessKeyCache and changed its type. >+ Removed bogus "DOM methods" comment, unused setParserFeature friend declaration, >+ setIsTelephoneNumberParsingAllowed function, and m_accessKeyMapValid flag. >+ >+ * dom/Document.idl: Added comment highlighting that getOverrideStyle is just a >+ placeholder returning null. >+ >+ * dom/Element.cpp: >+ (WebCore::Element::attributeChanged): Call invalidateAccessKeyCache when the >+ value of the accesskey attribute is changed. Also moved the class attribute code >+ so the attributes here are in alphabetical order (only class and id were out of >+ alphabetical order). >+ >+ * dom/Node.cpp: >+ (WebCore::Node::isDescendantOrShadowDescendantOf const): Rewrote to no longer >+ use deprecatedShadowAncestorNode and used boolean operators to make it a >+ single line and easier to understand. Also added a FIXME since the >+ containsIncludingShadowDOM function is so similar, yet differently written. >+ (WebCore::Node::contains const): Rewrote as a single line to make this easier >+ to read and to *slightly* improve the speed in the "this == node" case. >+ (WebCore::Node::containsIncludingHostElements const): Use downcast. >+ (WebCore::Node::deprecatedShadowAncestorNode const): Deleted. >+ >+ * dom/Node.h: Deleted now-unused deprecatedShadowAncestorNode. >+ >+ * editing/ReplaceSelectionCommand.cpp: >+ (WebCore::ReplacementFragment::ReplacementFragment): Rewrote to use shadowHost >+ instead of deprecatedShadowAncestorNode. >+ >+ * html/FormAssociatedElement.cpp: >+ (WebCore::FormAssociatedElement::resetFormOwner): Pass reference to >+ didAssociateFormControl. >+ (WebCore::FormAssociatedElement::formAttributeChanged): Ditto. >+ >+ * html/HTMLAreaElement.cpp: >+ (WebCore::HTMLAreaElement::parseAttribute): Removed special case for accesskey >+ attribute, because we want to call the base class parseAttribute in that case. >+ >+ * html/HTMLFormElement.cpp: >+ (WebCore::HTMLFormElement::insertedIntoAncestor): Pass reference to >+ didAssociateFormControl. >+ >+ * html/HTMLSelectElement.cpp: >+ (WebCore::HTMLSelectElement::parseAttribute): Removed special case for accesskey >+ attribute with mysterious FIXME, because we want to call the base class >+ parseAttribute in that case. The old code had no effect before; the access key >+ logic would still find the attribute; if the goal is to ignore the attribute >+ for these elements we will need a different solution. >+ * html/HTMLTextAreaElement.cpp: >+ (WebCore::HTMLTextAreaElement::parseAttribute): Ditto. >+ >+ * loader/DocumentLoader.cpp: >+ (WebCore::DocumentLoader::DocumentLoader): Removed code that was always passing >+ nullptr as the frame for the newly created DocumentWriter. It used m_frame, but >+ m_frame was always null. >+ (WebCore::DocumentLoader::attachToFrame): Pass reference to DocumentWriter::setFrame. >+ >+ * loader/DocumentWriter.cpp: >+ (WebCore::DocumentWriter::DocumentWriter): Deleted. The old version set m_frame to >+ the passed in frame, which was always nullptr, and initialized some booleans and an >+ enumeration, which are now initialized in the class definition. >+ (WebCore::DocumentWriter::createDocument): Pass a reference for the frame. >+ (WebCore::DocumentWriter::begin): Updated now that State is an enum class. >+ (WebCore::DocumentWriter::decoder): Renamed from createDecoderIfNeeded and changed >+ to return a reference. >+ (WebCore::DocumentWriter::addData): Use RELEASE_ASSERT instead of if/CRASH and >+ updated now that State is an enum class. >+ (WebCore::DocumentWriter::insertDataSynchronously): Updated now that State is an >+ enum class. >+ (WebCore::DocumentWriter::end): Ditto. >+ >+ * loader/DocumentWriter.h: Removed unneeded include and forward declaration. >+ Removed the frame pointer argument to the constructor, caller was always passing a >+ nullptr. Changed argument to setFrame to be a reference. Renamed createDecoderIfNeeded >+ to decoder and changed it to return a reference. Initialized m_frame, >+ m_hasReceivedSomeData, m_encodingWasChosenByUser, and m_state here so we don't need >+ to initialize them in a constructor. Renamed the enum from WriterState to State since >+ it's a member of DocumentWriter already, and made it an enum class rather than ending >+ each enumeration value with WritingState. >+ >+ * page/DragController.cpp: >+ (WebCore::isEnabledColorInput): Removed boolean argument setToShadowAncestor. The >+ one caller that formerly passed true now calls the new hasEnabledColorInputAsShadowHost >+ function instead. >+ (WebCore::hasEnabledColorInputAsShadowHost): Added. >+ (WebCore::elementUnderMouse): Use shadowHost instead of deprecatedShadowAncestorNode. >+ Also added FIXME since it seems this should instead be using parentElementInComposedTree. >+ (WebCore::DragController::concludeEditDrag): Removed "false" argument to isEnabledColorInput. >+ (WebCore::DragController::canProcessDrag): Removed "true" argument to isEnabledColorInput >+ and added call to hasEnabledColorInputAsShadowHost. Also put the value of the node to drag >+ into a local variable to simplify code. >+ (WebCore::DragController::draggableElement const): Removed "false" argument to isEnabledColorInput. >+ >+ * page/EventHandler.cpp: >+ (WebCore::EventHandler::handleAccessKey): Update name of elementForAccessKey. >+ >+ * page/FocusController.cpp: >+ (WebCore::clearSelectionIfNeeded): Use shadowHost instead of deprecatedShadowAncestorNode. >+ >+ * workers/service/context/ServiceWorkerThreadProxy.cpp: >+ (WebCore::createPageForServiceWorker): Pass reference instead of pointer for frame to >+ Document::createNonRenderedPlaceholder. >+ > 2019-02-17 David Kilzer <ddkilzer@apple.com> > > Unreviewed, rolling out r241620. >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index c08f51c9a095dab908cf57c7527c8d073d08159d..7040e20c3dcc506f8850061ee9bd185e4cb4576f 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,14 @@ >+2019-02-17 Darin Adler <darin@apple.com> >+ >+ Some refinements for Node and Document >+ https://bugs.webkit.org/show_bug.cgi?id=194764 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * UserInterface/Models/NativeFunctionParameters.js: Removed getOverrideStyle >+ because this deprecated non-working function is no longer something web authors >+ should be thinking about or typing. >+ > 2019-02-17 Nikita Vasilyev <nvasilyev@apple.com> > > Web Inspector: Move CSS completion logic from SpreadsheetTextField to SpreadsheetStyleProperty >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index d0b91b0a519f5512dfb263e01769e40fbecb72fb..54689dfa52e491dc97463616931d342efb9fac05 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,20 @@ >+2019-02-17 Darin Adler <darin@apple.com> >+ >+ Some refinements for Node and Document >+ https://bugs.webkit.org/show_bug.cgi?id=194764 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp: >+ (webkit_dom_document_get_override_style): Changed to return nullptr directly instead of >+ calling a bunch of WebCore code first. No real value in checking arguments or doing any work. >+ >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: >+ (WebKit::WebFrameLoaderClient::shouldAlwaysUsePluginDocument const): Deleted. >+ No need to override the function inherited from the base class, nor to keep track of the >+ unnecessary task of implementing this some day. >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.h: Updated for the above. >+ > 2019-02-18 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK] Crash while filling selection data during drag and drop >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index d7a3f6fb90f8c807dffbb0ede0b11f8d9f428afe..46b8cefc7673e8294df0375f5ca8779b4e971047 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,15 @@ >+2019-02-17 Darin Adler <darin@apple.com> >+ >+ Some refinements for Node and Document >+ https://bugs.webkit.org/show_bug.cgi?id=194764 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * DOM/DOMDocument.mm: >+ (-[DOMDocument getOverrideStyle:pseudoElement:]): Return nil without calling >+ through to WebCore or even looking at the arguments. >+ (-[DOMDocument getOverrideStyle::]): Ditto. >+ > 2019-02-17 David Kilzer <ddkilzer@apple.com> > > Unreviewed, rolling out r241620. >diff --git a/Source/WebCore/accessibility/AccessibilityObject.cpp b/Source/WebCore/accessibility/AccessibilityObject.cpp >index 940afafd9d46074c8704ea3a26c762a5786c9b7e..5867a1a62ee701cdf084d6879ebbfd17bbefbe3b 100644 >--- a/Source/WebCore/accessibility/AccessibilityObject.cpp >+++ b/Source/WebCore/accessibility/AccessibilityObject.cpp >@@ -1010,16 +1010,16 @@ bool AccessibilityObject::press() > HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AccessibilityHitTest); > HitTestResult hitTestResult(clickPoint()); > document->renderView()->hitTest(request, hitTestResult); >- if (hitTestResult.innerNode()) { >- Node* innerNode = hitTestResult.innerNode()->deprecatedShadowAncestorNode(); >- if (is<Element>(*innerNode)) >- hitTestElement = downcast<Element>(innerNode); >- else if (innerNode) >+ if (auto* innerNode = hitTestResult.innerNode()) { >+ if (auto* shadowHost = innerNode->shadowHost()) >+ hitTestElement = shadowHost; >+ else if (is<Element>(*innerNode)) >+ hitTestElement = &downcast<Element>(*innerNode); >+ else > hitTestElement = innerNode->parentElement(); > } > } >- >- >+ > // Prefer the actionElement instead of this node, if the actionElement is inside this node. > Element* pressElement = this->element(); > if (!pressElement || actionElem->isDescendantOf(*pressElement)) >@@ -2706,23 +2706,14 @@ AccessibilityObjectInterface* AccessibilityObject::elementAccessibilityHitTest(c > > AXObjectCache* AccessibilityObject::axObjectCache() const > { >- Document* doc = document(); >- if (doc) >- return doc->axObjectCache(); >- return nullptr; >+ auto* document = this->document(); >+ return document ? document->axObjectCache() : nullptr; > } > > AccessibilityObjectInterface* AccessibilityObject::focusedUIElement() const > { >- Document* document = this->document(); >- if (!document) >- return nullptr; >- >- Page* page = document->page(); >- if (!page) >- return nullptr; >- >- return AXObjectCache::focusedUIElementForPage(page); >+ auto* page = this->page(); >+ return page ? AXObjectCache::focusedUIElementForPage(page) : nullptr; > } > > AccessibilitySortDirection AccessibilityObject::sortDirection() const >diff --git a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp >index 4ca302de72f6433495317a30c41f31a3f9855a26..fd27463e55051672c4921c88639c7844dba9a85f 100644 >--- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp >+++ b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp >@@ -1511,7 +1511,7 @@ const AtomicString& AccessibilityRenderObject::accessKey() const > Node* node = m_renderer->node(); > if (!is<Element>(node)) > return nullAtom(); >- return downcast<Element>(*node).getAttribute(accesskeyAttr); >+ return downcast<Element>(*node).attributeWithoutSynchronization(accesskeyAttr); > } > > VisibleSelection AccessibilityRenderObject::selection() const >diff --git a/Source/WebCore/dom/ContainerNode.cpp b/Source/WebCore/dom/ContainerNode.cpp >index 8c7747ee8144a85f444b270e19cf1e445bca6792..55b66696a795b00b477f12f74a410b850e2d42d2 100644 >--- a/Source/WebCore/dom/ContainerNode.cpp >+++ b/Source/WebCore/dom/ContainerNode.cpp >@@ -744,8 +744,28 @@ void ContainerNode::parserAppendChild(Node& newChild) > void ContainerNode::childrenChanged(const ChildChange& change) > { > document().incDOMTreeVersion(); >+ >+ switch (change.type) { >+ case ElementInserted: >+ case ElementRemoved: >+ case AllChildrenRemoved: >+ case AllChildrenReplaced: >+ document().invalidateAccessKeyCache(); >+ break; >+ case TextInserted: >+ case TextRemoved: >+ case TextChanged: >+ case NonContentsChildInserted: >+ case NonContentsChildRemoved: >+ break; >+ } >+ >+ // FIXME: Unclear why it's always safe to skip this when parser is adding children. >+ // FIXME: Seems like it's equally safe to skip for TextInserted and TextRemoved as for TextChanged. >+ // FIXME: Should use switch for change type so we remember to update when adding new types. > if (change.source == ChildChangeSource::API && change.type != TextChanged) > document().updateRangesAfterChildrenChanged(*this); >+ > invalidateNodeListAndCollectionCachesInAncestors(); > } > >diff --git a/Source/WebCore/dom/DecodedDataDocumentParser.cpp b/Source/WebCore/dom/DecodedDataDocumentParser.cpp >index ce38cede730ce8eeee699879b8077599b60758bc..ed856647a399d65b081117b8690415d2429af770 100644 >--- a/Source/WebCore/dom/DecodedDataDocumentParser.cpp >+++ b/Source/WebCore/dom/DecodedDataDocumentParser.cpp >@@ -42,7 +42,7 @@ void DecodedDataDocumentParser::appendBytes(DocumentWriter& writer, const char* > if (!length) > return; > >- String decoded = writer.createDecoderIfNeeded()->decode(data, length); >+ String decoded = writer.decoder().decode(data, length); > if (decoded.isEmpty()) > return; > >@@ -52,7 +52,7 @@ void DecodedDataDocumentParser::appendBytes(DocumentWriter& writer, const char* > > void DecodedDataDocumentParser::flush(DocumentWriter& writer) > { >- String remainingData = writer.createDecoderIfNeeded()->flush(); >+ String remainingData = writer.decoder().flush(); > if (remainingData.isEmpty()) > return; > >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index 050555ba9491f47ca0bb4dfdaaa193d9ac54edf9..734bf52b9b72f28fe56ac712003939a18afb5ab1 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -45,6 +45,7 @@ > #include "ChromeClient.h" > #include "Comment.h" > #include "CommonVM.h" >+#include "ComposedTreeIterator.h" > #include "CompositionEvent.h" > #include "ConstantPropertyMap.h" > #include "ContentSecurityPolicy.h" >@@ -731,36 +732,35 @@ void Document::commonTeardown() > clearScriptedAnimationController(); > } > >-Element* Document::getElementByAccessKey(const String& key) >+Element* Document::elementForAccessKey(const String& key) > { > if (key.isEmpty()) > return nullptr; >- // FIXME: Would be nice to use WTF::Optional on the map instead of using a >- // separate boolean. >- if (!m_accessKeyMapValid) { >- buildAccessKeyMap(*this); >- m_accessKeyMapValid = true; >- } >- return m_elementsByAccessKey.get(key.impl()); >+ if (!m_accessKeyCache) >+ buildAccessKeyCache(); >+ return m_accessKeyCache->get(key); > } > >-void Document::buildAccessKeyMap(TreeScope& scope) >+void Document::buildAccessKeyCache() > { >- // FIXME: Consider using composedTreeDescendants instead, obviating the need for >- // recursion and the "scope" argument. Might be nice to have an Element-only version. >- for (auto& element : descendantsOfType<Element>(scope.rootNode())) { >- auto& accessKey = element.attributeWithoutSynchronization(accesskeyAttr); >- if (!accessKey.isEmpty()) >- m_elementsByAccessKey.set(accessKey.impl(), &element); >- if (auto* root = element.shadowRoot()) >- buildAccessKeyMap(*root); >- } >+ m_accessKeyCache = std::make_unique<HashMap<String, Element*, ASCIICaseInsensitiveHash>>([this] { >+ HashMap<String, Element*, ASCIICaseInsensitiveHash> map; >+ for (auto& node : composedTreeDescendants(*this)) { >+ if (!is<Element>(node)) >+ continue; >+ auto& element = downcast<Element>(node); >+ auto& key = element.attributeWithoutSynchronization(accesskeyAttr); >+ if (key.isEmpty()) >+ continue; >+ map.add(key, &element); >+ } >+ return map; >+ }()); > } > >-void Document::invalidateAccessKeyMap() >+void Document::invalidateAccessKeyCacheSlowCase() > { >- m_accessKeyMapValid = false; >- m_elementsByAccessKey.clear(); >+ m_accessKeyCache = nullptr; > } > > ExceptionOr<SelectorQuery&> Document::selectorQueryForString(const String& selectorString) >@@ -845,8 +845,8 @@ bool Document::hasManifest() const > DocumentType* Document::doctype() const > { > for (Node* node = firstChild(); node; node = node->nextSibling()) { >- if (node->isDocumentTypeNode()) >- return static_cast<DocumentType*>(node); >+ if (is<DocumentType>(node)) >+ return downcast<DocumentType>(node); > } > return nullptr; > } >@@ -1818,9 +1818,6 @@ void Document::scheduleStyleRecalc() > } > #endif > >- // FIXME: Why on earth is this here? This is clearly misplaced. >- invalidateAccessKeyMap(); >- > auto shouldThrottleStyleRecalc = [&] { > if (!view() || !view()->isVisuallyNonEmpty()) > return false; >@@ -3743,7 +3740,7 @@ void Document::processFormatDetection(const String& features) > // FIXME: Find a better place for this function. > processFeaturesString(features, FeatureMode::Viewport, [this](StringView key, StringView value) { > if (equalLettersIgnoringASCIICase(key, "telephone") && equalLettersIgnoringASCIICase(value, "no")) >- setIsTelephoneNumberParsingAllowed(false); >+ m_isTelephoneNumberParsingAllowed = false; > }); > } > >@@ -3907,7 +3904,7 @@ Ref<Document> Document::cloneDocumentWithoutChildren() const > return XMLDocument::createXHTML(nullptr, url()); > return XMLDocument::create(nullptr, url()); > } >- return create(nullptr, url()); >+ return create(url()); > } > > void Document::cloneDataFromDocument(const Document& other) >@@ -4847,11 +4844,6 @@ void Document::addListenerTypeIfNeeded(const AtomicString& eventType) > addListenerType(RESIZE_LISTENER); > } > >-CSSStyleDeclaration* Document::getOverrideStyle(Element*, const String&) >-{ >- return nullptr; >-} >- > HTMLFrameOwnerElement* Document::ownerElement() const > { > if (!frame()) >@@ -5832,11 +5824,6 @@ bool Document::isTelephoneNumberParsingEnabled() const > return settings().telephoneNumberParsingEnabled() && m_isTelephoneNumberParsingAllowed; > } > >-void Document::setIsTelephoneNumberParsingAllowed(bool isTelephoneNumberParsingAllowed) >-{ >- m_isTelephoneNumberParsingAllowed = isTelephoneNumberParsingAllowed; >-} >- > bool Document::isTelephoneNumberParsingAllowed() const > { > return m_isTelephoneNumberParsingAllowed; >@@ -7464,7 +7451,7 @@ Document& Document::ensureTemplateDocument() > if (isHTMLDocument()) > m_templateDocument = HTMLDocument::create(nullptr, WTF::blankURL()); > else >- m_templateDocument = Document::create(nullptr, WTF::blankURL()); >+ m_templateDocument = create(WTF::blankURL()); > > m_templateDocument->setContextDocument(contextDocument()); > m_templateDocument->setTemplateDocumentHost(this); // balanced in dtor. >@@ -7542,22 +7529,22 @@ OptionSet<StyleColor::Options> Document::styleColorOptions(const RenderStyle* st > return options; > } > >-void Document::didAssociateFormControl(Element* element) >+void Document::didAssociateFormControl(Element& element) > { >- if (!frame() || !frame()->page() || !frame()->page()->chrome().client().shouldNotifyOnFormChanges()) >+ auto* page = this->page(); >+ if (!page || !page->chrome().client().shouldNotifyOnFormChanges()) > return; >- m_associatedFormControls.add(element); >+ m_associatedFormControls.add(&element); > if (!m_didAssociateFormControlsTimer.isActive()) > m_didAssociateFormControlsTimer.startOneShot(0_s); > } > > void Document::didAssociateFormControlsTimerFired() > { >- if (!frame() || !frame()->page()) >- return; >- >- frame()->page()->chrome().client().didAssociateFormControls(copyToVector(m_associatedFormControls)); >+ auto vector = copyToVector(m_associatedFormControls); > m_associatedFormControls.clear(); >+ if (auto* page = this->page()) >+ page->chrome().client().didAssociateFormControls(vector); > } > > void Document::setCachedDOMCookies(const String& cookies) >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index db8988dc3708520670e8e0c47ff9e7b9dcc4c037..fb423677a9343e5229b1e47b2e8dfc0c197a2040 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -252,13 +252,10 @@ class Scope; > > const uint64_t HTMLMediaElementInvalidID = 0; > >-enum PageshowEventPersistence { >- PageshowEventNotPersisted = 0, >- PageshowEventPersisted = 1 >-}; >+enum PageshowEventPersistence { PageshowEventNotPersisted, PageshowEventPersisted }; > > enum NodeListInvalidationType { >- DoNotInvalidateOnAttributeChanges = 0, >+ DoNotInvalidateOnAttributeChanges, > InvalidateOnClassAttrChange, > InvalidateOnIdNameAttrChange, > InvalidateOnNameAttrChange, >@@ -283,7 +280,6 @@ enum DocumentClass { > TextDocumentClass = 1 << 6, > XMLDocumentClass = 1 << 7, > }; >- > typedef unsigned char DocumentClassFlags; > > enum class DocumentCompatibilityMode : unsigned char { >@@ -294,10 +290,7 @@ enum class DocumentCompatibilityMode : unsigned char { > > enum DimensionsCheck { WidthDimensionsCheck = 1 << 0, HeightDimensionsCheck = 1 << 1, AllDimensionsCheck = 1 << 2 }; > >-enum class SelectionRestorationMode { >- Restore, >- SetDefault, >-}; >+enum class SelectionRestorationMode { Restore, SetDefault }; > > enum class HttpEquivPolicy { > Enabled, >@@ -352,15 +345,8 @@ class Document > , public Logger::Observer { > WTF_MAKE_ISO_ALLOCATED(Document); > public: >- static Ref<Document> create(Frame* frame, const URL& url) >- { >- return adoptRef(*new Document(frame, url)); >- } >- >- static Ref<Document> createNonRenderedPlaceholder(Frame* frame, const URL& url) >- { >- return adoptRef(*new Document(frame, url, DefaultDocumentClass, NonRenderedPlaceholder)); >- } >+ static Ref<Document> create(const URL&); >+ static Ref<Document> createNonRenderedPlaceholder(Frame&, const URL&); > static Ref<Document> create(Document&); > > virtual ~Document(); >@@ -406,14 +392,12 @@ public: > > bool canContainRangeEndPoint() const final { return true; } > >- Element* getElementByAccessKey(const String& key); >- void invalidateAccessKeyMap(); >+ Element* elementForAccessKey(const String& key); >+ void invalidateAccessKeyCache(); > > ExceptionOr<SelectorQuery&> selectorQueryForString(const String&); > void clearSelectorQueryCache(); > >- // DOM methods & attributes for Document >- > void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; } > ViewportArguments viewportArguments() const { return m_viewportArguments; } > >@@ -431,10 +415,7 @@ public: > > WEBCORE_EXPORT DOMImplementation& implementation(); > >- Element* documentElement() const >- { >- return m_documentElement.get(); >- } >+ Element* documentElement() const { return m_documentElement.get(); } > static ptrdiff_t documentElementMemoryOffset() { return OBJECT_OFFSETOF(Document, m_documentElement); } > > WEBCORE_EXPORT Element* activeElement(); >@@ -462,11 +443,7 @@ public: > WEBCORE_EXPORT Element* scrollingElementForAPI(); > Element* scrollingElement(); > >- enum ReadyState { >- Loading, >- Interactive, >- Complete >- }; >+ enum ReadyState { Loading, Interactive, Complete }; > ReadyState readyState() const { return m_readyState; } > > WEBCORE_EXPORT String defaultCharsetForLegacyBindings() const; >@@ -570,8 +547,8 @@ public: > Vector<String> formElementsState() const; > void setStateForNewFormElements(const Vector<String>&); > >- WEBCORE_EXPORT FrameView* view() const; // can be NULL >- WEBCORE_EXPORT Page* page() const; // can be NULL >+ WEBCORE_EXPORT FrameView* view() const; // Can be null. >+ WEBCORE_EXPORT Page* page() const; // Can be null. > const Settings& settings() const { return m_settings.get(); } > Settings& mutableSettings() { return m_settings.get(); } > >@@ -606,10 +583,7 @@ public: > > // updateLayoutIgnorePendingStylesheets() forces layout even if we are waiting for pending stylesheet loads, > // so calling this may cause a flash of unstyled content (FOUC). >- enum class RunPostLayoutTasks { >- Asynchronously, >- Synchronously, >- }; >+ enum class RunPostLayoutTasks { Asynchronously, Synchronously }; > WEBCORE_EXPORT void updateLayoutIgnorePendingStylesheets(RunPostLayoutTasks = RunPostLayoutTasks::Asynchronously); > > std::unique_ptr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element&, const RenderStyle* parentStyle, PseudoId = PseudoId::None); >@@ -883,7 +857,7 @@ public: > bool hasMutationObservers() const { return m_mutationObserverTypes; } > void addMutationObserverTypes(MutationObserverOptions types) { m_mutationObserverTypes |= types; } > >- WEBCORE_EXPORT CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt); >+ CSSStyleDeclaration* getOverrideStyle(Element*, const String&) { return nullptr; } > > // Handles an HTTP header equivalent set by a meta tag using <meta http-equiv="..." content="...">. This is called > // when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta >@@ -1352,7 +1326,7 @@ public: > void setTemplateDocumentHost(Document* templateDocumentHost) { m_templateDocumentHost = templateDocumentHost; } > Document* templateDocumentHost() { return m_templateDocumentHost; } > >- void didAssociateFormControl(Element*); >+ void didAssociateFormControl(Element&); > bool hasDisabledFieldsetElement() const { return m_disabledFieldsetElementsCount; } > void addDisabledFieldsetElement() { m_disabledFieldsetElementsCount++; } > void removeDisabledFieldsetElement() { ASSERT(m_disabledFieldsetElementsCount); m_disabledFieldsetElementsCount--; } >@@ -1600,7 +1574,8 @@ private: > void updateTitle(const StringWithDirection&); > void updateBaseURL(); > >- void buildAccessKeyMap(TreeScope&); >+ void invalidateAccessKeyCacheSlowCase(); >+ void buildAccessKeyCache(); > > void moveNodeIteratorsToNewDocumentSlowCase(Node&, Document&); > >@@ -1623,11 +1598,6 @@ private: > > void dispatchDisabledAdaptationsDidChangeForMainFrame(); > >-#if ENABLE(TELEPHONE_NUMBER_DETECTION) >- friend void setParserFeature(const String& key, const String& value, Document*, void* userData); >- void setIsTelephoneNumberParsingAllowed(bool); >-#endif >- > void setVisualUpdatesAllowed(ReadyState); > void setVisualUpdatesAllowed(bool); > void visualUpdatesSuppressionTimerFired(); >@@ -1827,7 +1797,7 @@ private: > HashSet<HTMLMediaElement*> m_allowsMediaDocumentInlinePlaybackElements; > #endif > >- HashMap<StringImpl*, Element*, ASCIICaseInsensitiveHash> m_elementsByAccessKey; >+ std::unique_ptr<HashMap<String, Element*, ASCIICaseInsensitiveHash>> m_accessKeyCache; > > std::unique_ptr<ConstantPropertyMap> m_constantPropertyMap; > >@@ -2029,7 +1999,6 @@ private: > bool m_isDNSPrefetchEnabled { false }; > bool m_haveExplicitlyDisabledDNSPrefetch { false }; > >- bool m_accessKeyMapValid { false }; > bool m_isSynthesized { false }; > bool m_isNonRenderedPlaceholder { false }; > >@@ -2128,6 +2097,22 @@ inline AXObjectCache* Document::existingAXObjectCache() const > return existingAXObjectCacheSlow(); > } > >+inline Ref<Document> Document::create(const URL& url) >+{ >+ return adoptRef(*new Document(nullptr, url)); >+} >+ >+inline Ref<Document> Document::createNonRenderedPlaceholder(Frame& frame, const URL& url) >+{ >+ return adoptRef(*new Document(&frame, url, DefaultDocumentClass, NonRenderedPlaceholder)); >+} >+ >+inline void Document::invalidateAccessKeyCache() >+{ >+ if (UNLIKELY(m_accessKeyCache)) >+ invalidateAccessKeyCacheSlowCase(); >+} >+ > // These functions are here because they require the Document class definition and we want to inline them. > > inline ScriptExecutionContext* Node::scriptExecutionContext() const >diff --git a/Source/WebCore/dom/Document.idl b/Source/WebCore/dom/Document.idl >index 6f6379b8cffc95cf5d1c6ee807779667185419d8..523fffa352b86f34f9f10e429bc08777495481e5 100644 >--- a/Source/WebCore/dom/Document.idl >+++ b/Source/WebCore/dom/Document.idl >@@ -175,7 +175,8 @@ typedef ( > attribute boolean xmlStandalone; > > // FIXME: Blink has already dropped this (https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/s3ezjTuC8ig). >- CSSStyleDeclaration getOverrideStyle(optional Element? element = null, optional DOMString pseudoElement = "undefined"); >+ // And it's just a stub that always returns null, so we can probably remove it some time soon. >+ CSSStyleDeclaration? getOverrideStyle(optional Element? element = null, optional DOMString pseudoElement = "undefined"); > > // FIXME: Should be moved to GlobalEventHandlers (http://w3c.github.io/selection-api/#extensions-to-globaleventhandlers). > [NotEnumerable] attribute EventHandler onselectstart; // FIXME: Should be enumerable. >diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index 49a54da52728ead08917789cc27da9976a1e699f..4a0fd8e30abb47d696633af4f7505c87878b6d2a 100644 >--- a/Source/WebCore/dom/Element.cpp >+++ b/Source/WebCore/dom/Element.cpp >@@ -1555,7 +1555,11 @@ void Element::attributeChanged(const QualifiedName& name, const AtomicString& ol > bool valueIsSameAsBefore = oldValue == newValue; > > if (!valueIsSameAsBefore) { >- if (name == HTMLNames::idAttr) { >+ if (name == HTMLNames::accesskeyAttr) >+ document().invalidateAccessKeyCache(); >+ else if (name == classAttr) >+ classAttributeChanged(newValue); >+ else if (name == HTMLNames::idAttr) { > AtomicString oldId = elementData()->idForStyleResolution(); > AtomicString newId = makeIdForStyleResolution(newValue, document().inQuirksMode()); > if (newId != oldId) { >@@ -1567,15 +1571,12 @@ void Element::attributeChanged(const QualifiedName& name, const AtomicString& ol > treeScope().idTargetObserverRegistry().notifyObservers(*oldValue.impl()); > if (!newValue.isEmpty()) > treeScope().idTargetObserverRegistry().notifyObservers(*newValue.impl()); >- } else if (name == classAttr) >- classAttributeChanged(newValue); >- else if (name == HTMLNames::nameAttr) >+ } else if (name == HTMLNames::nameAttr) > elementData()->setHasNameAttribute(!newValue.isNull()); > else if (name == HTMLNames::pseudoAttr) { > if (needsStyleInvalidation() && isInShadowTree()) > invalidateStyleForSubtree(); >- } >- else if (name == HTMLNames::slotAttr) { >+ } else if (name == HTMLNames::slotAttr) { > if (auto* parent = parentElement()) { > if (auto* shadowRoot = parent->shadowRoot()) > shadowRoot->hostChildElementDidChangeSlotAttribute(*this, oldValue, newValue); >diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp >index 078bce0b22c702272e2e33e61799052550041444..697241f283fab8590959020f79ccf9f3d7cf4f94 100644 >--- a/Source/WebCore/dom/Node.cpp >+++ b/Source/WebCore/dom/Node.cpp >@@ -1008,21 +1008,14 @@ bool Node::isDescendantOf(const Node& other) const > > bool Node::isDescendantOrShadowDescendantOf(const Node* other) const > { >- if (!other) >- return false; >- if (isDescendantOf(*other)) >- return true; >- const Node* shadowAncestorNode = deprecatedShadowAncestorNode(); >- if (!shadowAncestorNode) >- return false; >- return shadowAncestorNode == other || shadowAncestorNode->isDescendantOf(*other); >+ // FIXME: Why is this implementation so different from containsIncludingShadowDOM >+ // function, given that the two functions' purposes are nearly identical? >+ return other && (isDescendantOf(*other) || other->contains(shadowHost())); > } > > bool Node::contains(const Node* node) const > { >- if (!node) >- return false; >- return this == node || node->isDescendantOf(*this); >+ return this == node || (node && node->isDescendantOf(*this)); > } > > bool Node::containsIncludingShadowDOM(const Node* node) const >@@ -1039,7 +1032,7 @@ bool Node::containsIncludingHostElements(const Node* node) const > while (node) { > if (node == this) > return true; >- if (node->isDocumentFragment() && static_cast<const DocumentFragment*>(node)->isTemplateContent()) >+ if (is<DocumentFragment>(*node) && downcast<DocumentFragment>(*node).isTemplateContent()) > node = static_cast<const TemplateContentDocumentFragment*>(node)->host(); > else > node = node->parentOrShadowHostNode(); >@@ -1139,14 +1132,6 @@ Element* Node::shadowHost() const > return nullptr; > } > >-Node* Node::deprecatedShadowAncestorNode() const >-{ >- if (ShadowRoot* root = containingShadowRoot()) >- return root->host(); >- >- return const_cast<Node*>(this); >-} >- > ShadowRoot* Node::containingShadowRoot() const > { > ContainerNode& root = treeScope().rootNode(); >diff --git a/Source/WebCore/dom/Node.h b/Source/WebCore/dom/Node.h >index 12439d78d35c4c2821a7254d032145035fb47f9f..a63c194b8b5073731cd9191b331261f0f88870c6 100644 >--- a/Source/WebCore/dom/Node.h >+++ b/Source/WebCore/dom/Node.h >@@ -234,9 +234,6 @@ public: > > // If this node is in a shadow tree, returns its shadow host. Otherwise, returns null. > WEBCORE_EXPORT Element* shadowHost() const; >- // If this node is in a shadow tree, returns its shadow host. Otherwise, returns this. >- // Deprecated. Should use shadowHost() and check the return value. >- WEBCORE_EXPORT Node* deprecatedShadowAncestorNode() const; > ShadowRoot* containingShadowRoot() const; > ShadowRoot* shadowRoot() const; > bool isClosedShadowHidden(const Node&) const; >diff --git a/Source/WebCore/editing/ReplaceSelectionCommand.cpp b/Source/WebCore/editing/ReplaceSelectionCommand.cpp >index 7311b2a2a5de24008e22783095613d6fe6cf0630..d5eced5825a055e8c0a8b42561af262a55e7dbb0 100644 >--- a/Source/WebCore/editing/ReplaceSelectionCommand.cpp >+++ b/Source/WebCore/editing/ReplaceSelectionCommand.cpp >@@ -167,10 +167,9 @@ ReplacementFragment::ReplacementFragment(Document& document, DocumentFragment* f > if (!editableRoot) > return; > >- Node* shadowAncestorNode = editableRoot->deprecatedShadowAncestorNode(); >- >+ auto* shadowHost = editableRoot->shadowHost(); > if (!editableRoot->attributeEventListener(eventNames().webkitBeforeTextInsertedEvent, mainThreadNormalWorld()) >- && !(shadowAncestorNode && shadowAncestorNode->renderer() && shadowAncestorNode->renderer()->isTextControl()) >+ && !(shadowHost && shadowHost->renderer() && shadowHost->renderer()->isTextControl()) > && editableRoot->hasRichlyEditableStyle()) { > removeInterchangeNodes(m_fragment.get()); > return; >diff --git a/Source/WebCore/html/FormAssociatedElement.cpp b/Source/WebCore/html/FormAssociatedElement.cpp >index 7aa5e761871e32faf1863436be5777a3e6056426..26cd8421087da124ec0af8879e6f2384246f81ac 100644 >--- a/Source/WebCore/html/FormAssociatedElement.cpp >+++ b/Source/WebCore/html/FormAssociatedElement.cpp >@@ -176,7 +176,7 @@ void FormAssociatedElement::resetFormOwner() > setForm(findAssociatedForm(&asHTMLElement(), m_form)); > HTMLElement& element = asHTMLElement(); > if (m_form && m_form != originalForm && m_form->isConnected()) >- element.document().didAssociateFormControl(&element); >+ element.document().didAssociateFormControl(element); > } > > void FormAssociatedElement::formAttributeChanged() >@@ -187,7 +187,7 @@ void FormAssociatedElement::formAttributeChanged() > RefPtr<HTMLFormElement> originalForm = m_form; > setForm(HTMLFormElement::findClosestFormAncestor(element)); > if (m_form && m_form != originalForm && m_form->isConnected()) >- element.document().didAssociateFormControl(&element); >+ element.document().didAssociateFormControl(element); > m_formAttributeTargetObserver = nullptr; > } else { > resetFormOwner(); >diff --git a/Source/WebCore/html/HTMLAreaElement.cpp b/Source/WebCore/html/HTMLAreaElement.cpp >index 7503f075a0c12b86a021add902ae76a1ad66d885..bab136e8a1c22b2c977586ac864b840fda100f97 100644 >--- a/Source/WebCore/html/HTMLAreaElement.cpp >+++ b/Source/WebCore/html/HTMLAreaElement.cpp >@@ -69,7 +69,7 @@ void HTMLAreaElement::parseAttribute(const QualifiedName& name, const AtomicStri > } else if (name == coordsAttr) { > m_coords = parseHTMLListOfOfFloatingPointNumberValues(value.string()); > invalidateCachedRegion(); >- } else if (name == altAttr || name == accesskeyAttr) { >+ } else if (name == altAttr) { > // Do nothing. > } else > HTMLAnchorElement::parseAttribute(name, value); >diff --git a/Source/WebCore/html/HTMLFormElement.cpp b/Source/WebCore/html/HTMLFormElement.cpp >index db996b98ada4752d46a9f6d4f3426bdae2a56cdc..bbf1648a3572acee77a63509d800a3e4df2a03c7 100644 >--- a/Source/WebCore/html/HTMLFormElement.cpp >+++ b/Source/WebCore/html/HTMLFormElement.cpp >@@ -129,7 +129,7 @@ Node::InsertedIntoAncestorResult HTMLFormElement::insertedIntoAncestor(Insertion > { > HTMLElement::insertedIntoAncestor(insertionType, parentOfInsertedTree); > if (insertionType.connectedToDocument) >- document().didAssociateFormControl(this); >+ document().didAssociateFormControl(*this); > return InsertedIntoAncestorResult::Done; > } > >diff --git a/Source/WebCore/html/HTMLSelectElement.cpp b/Source/WebCore/html/HTMLSelectElement.cpp >index d499b91b80d014353b8f36ab1f08f7bb53dffd39..3ea01c073cf7f13395e2e8231281fcebcbb7639a 100644 >--- a/Source/WebCore/html/HTMLSelectElement.cpp >+++ b/Source/WebCore/html/HTMLSelectElement.cpp >@@ -307,10 +307,7 @@ void HTMLSelectElement::parseAttribute(const QualifiedName& name, const AtomicSt > } > } else if (name == multipleAttr) > parseMultipleAttribute(value); >- else if (name == accesskeyAttr) { >- // FIXME: ignore for the moment. >- // >- } else >+ else > HTMLFormControlElementWithState::parseAttribute(name, value); > } > >diff --git a/Source/WebCore/html/HTMLTextAreaElement.cpp b/Source/WebCore/html/HTMLTextAreaElement.cpp >index fd9b2d62ae1cc5e1b2c3924d94f8cdb3a4e8afc8..beb96fae8fd239498091bcabc62285c226a7f63d 100644 >--- a/Source/WebCore/html/HTMLTextAreaElement.cpp >+++ b/Source/WebCore/html/HTMLTextAreaElement.cpp >@@ -193,8 +193,6 @@ void HTMLTextAreaElement::parseAttribute(const QualifiedName& name, const Atomic > if (renderer()) > renderer()->setNeedsLayoutAndPrefWidthsRecalc(); > } >- } else if (name == accesskeyAttr) { >- // ignore for the moment > } else if (name == maxlengthAttr) > maxLengthAttributeChanged(value); > else if (name == minlengthAttr) >diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp >index 1b30f2d59dd8250778f006ecab6a40a7f49f01e6..f963c5d8bece0f44f8d1d926982c97f1a9df9979 100644 >--- a/Source/WebCore/loader/DocumentLoader.cpp >+++ b/Source/WebCore/loader/DocumentLoader.cpp >@@ -146,7 +146,6 @@ static bool areAllLoadersPageCacheAcceptable(const ResourceLoaderMap& loaders) > DocumentLoader::DocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) > : FrameDestructionObserver(nullptr) > , m_cachedResourceLoader(CachedResourceLoader::create(this)) >- , m_writer(m_frame) > , m_originalRequest(request) > , m_substituteData(substituteData) > , m_originalRequestCopy(request) >@@ -1183,7 +1182,7 @@ void DocumentLoader::attachToFrame(Frame& frame) > > ASSERT(!m_frame); > observeFrame(&frame); >- m_writer.setFrame(&frame); >+ m_writer.setFrame(frame); > attachToFrame(); > > #ifndef NDEBUG >diff --git a/Source/WebCore/loader/DocumentWriter.cpp b/Source/WebCore/loader/DocumentWriter.cpp >index 86593c30aad576319c27dedf17d2152d2e89f921..b831d1adb41ca0df6366c26594618de642f966e2 100644 >--- a/Source/WebCore/loader/DocumentWriter.cpp >+++ b/Source/WebCore/loader/DocumentWriter.cpp >@@ -58,14 +58,6 @@ static inline bool canReferToParentFrameEncoding(const Frame* frame, const Frame > return parentFrame && parentFrame->document()->securityOrigin().canAccess(frame->document()->securityOrigin()); > } > >-DocumentWriter::DocumentWriter(Frame* frame) >- : m_frame(frame) >- , m_hasReceivedSomeData(false) >- , m_encodingWasChosenByUser(false) >- , m_state(NotStartedWritingState) >-{ >-} >- > // This is only called by ScriptController::executeIfJavaScriptURL > // and always contains the result of evaluating a javascript: url. > // This is the <iframe src="javascript:'html'"> case. >@@ -122,7 +114,7 @@ Ref<Document> DocumentWriter::createDocument(const URL& url) > return SinkDocument::create(m_frame, url); > #endif > if (!m_frame->loader().client().hasHTMLView()) >- return Document::createNonRenderedPlaceholder(m_frame, url); >+ return Document::createNonRenderedPlaceholder(*m_frame, url); > return DOMImplementation::createDocument(m_mimeType, m_frame, url); > } > >@@ -194,11 +186,11 @@ bool DocumentWriter::begin(const URL& urlReference, bool dispatch, Document* own > if (m_frame->view() && m_frame->loader().client().hasHTMLView()) > m_frame->view()->setContentsSize(IntSize()); > >- m_state = StartedWritingState; >+ m_state = State::Started; > return true; > } > >-TextResourceDecoder* DocumentWriter::createDecoderIfNeeded() >+TextResourceDecoder& DocumentWriter::decoder() > { > if (!m_decoder) { > m_decoder = TextResourceDecoder::create(m_mimeType, >@@ -225,7 +217,7 @@ TextResourceDecoder* DocumentWriter::createDecoderIfNeeded() > } > m_frame->document()->setDecoder(m_decoder.get()); > } >- return m_decoder.get(); >+ return *m_decoder; > } > > void DocumentWriter::reportDataReceived() >@@ -241,22 +233,17 @@ void DocumentWriter::reportDataReceived() > > void DocumentWriter::addData(const char* bytes, size_t length) > { >- // Check that we're inside begin()/end(). >- // FIXME: Change these to ASSERT once https://bugs.webkit.org/show_bug.cgi?id=80427 has >- // been resolved. >- if (m_state == NotStartedWritingState) >- CRASH(); >- if (m_state == FinishedWritingState) >- CRASH(); >- >+ // FIXME: Change these to ASSERT once https://bugs.webkit.org/show_bug.cgi?id=80427 has been resolved. >+ RELEASE_ASSERT(m_state != State::NotStarted); >+ RELEASE_ASSERT(m_state != State::Finished); > ASSERT(m_parser); > m_parser->appendBytes(*this, bytes, length); > } > > void DocumentWriter::insertDataSynchronously(const String& markup) > { >- ASSERT(m_state != NotStartedWritingState); >- ASSERT(m_state != FinishedWritingState); >+ ASSERT(m_state != State::NotStarted); >+ ASSERT(m_state != State::Finished); > ASSERT(m_parser); > m_parser->insert(markup); > } >@@ -268,7 +255,7 @@ void DocumentWriter::end() > > // The parser is guaranteed to be released after this point. begin() would > // have to be called again before we can start writing more data. >- m_state = FinishedWritingState; >+ m_state = State::Finished; > > // http://bugs.webkit.org/show_bug.cgi?id=10854 > // The frame's last ref may be removed and it can be deleted by checkCompleted(), >diff --git a/Source/WebCore/loader/DocumentWriter.h b/Source/WebCore/loader/DocumentWriter.h >index 3048c59e575137d85e0a99ce92c50e3de7baf64b..cae14d5fa6e46a6ca15a0c1e3eb9cc94ba377925 100644 >--- a/Source/WebCore/loader/DocumentWriter.h >+++ b/Source/WebCore/loader/DocumentWriter.h >@@ -28,7 +28,6 @@ > > #pragma once > >-#include <wtf/URL.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { >@@ -36,13 +35,12 @@ namespace WebCore { > class Document; > class DocumentParser; > class Frame; >-class SecurityOrigin; > class TextResourceDecoder; > > class DocumentWriter { > WTF_MAKE_NONCOPYABLE(DocumentWriter); > public: >- explicit DocumentWriter(Frame*); >+ DocumentWriter() = default; > > // This is only called by ScriptController::executeIfJavaScriptURL > // and always contains the result of evaluating a javascript: url. >@@ -54,7 +52,7 @@ public: > void insertDataSynchronously(const String&); // For an internal use only to prevent the parser from yielding. > WEBCORE_EXPORT void end(); > >- void setFrame(Frame* frame) { m_frame = frame; } >+ void setFrame(Frame& frame) { m_frame = &frame; } > > WEBCORE_EXPORT void setEncoding(const String& encoding, bool userChosen); > >@@ -62,7 +60,7 @@ public: > void setMIMEType(const String& type) { m_mimeType = type; } > > // Exposed for DocumentParser::appendBytes. >- TextResourceDecoder* createDecoderIfNeeded(); >+ TextResourceDecoder& decoder(); > void reportDataReceived(); > > void setDocumentWasLoadedAsPartOfNavigation(); >@@ -71,22 +69,18 @@ private: > Ref<Document> createDocument(const URL&); > void clear(); > >- Frame* m_frame; >+ Frame* m_frame { nullptr }; > >- bool m_hasReceivedSomeData; >+ bool m_hasReceivedSomeData { false }; > String m_mimeType; > >- bool m_encodingWasChosenByUser; >+ bool m_encodingWasChosenByUser { false }; > String m_encoding; > RefPtr<TextResourceDecoder> m_decoder; > RefPtr<DocumentParser> m_parser; > >- enum WriterState { >- NotStartedWritingState, >- StartedWritingState, >- FinishedWritingState, >- }; >- WriterState m_state; >+ enum class State { NotStarted, Started, Finished }; >+ State m_state { State::NotStarted }; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp >index c10154d9ea6aa025ba4ff9d4f79e48c869efe139..61ae8a2bfc247818fdf894dfd3e3591de52daf94 100644 >--- a/Source/WebCore/page/DragController.cpp >+++ b/Source/WebCore/page/DragController.cpp >@@ -341,17 +341,21 @@ static HTMLInputElement* asFileInput(Node& node) > } > > #if ENABLE(INPUT_TYPE_COLOR) >-static bool isEnabledColorInput(Node& node, bool setToShadowAncestor) >+ >+static bool isEnabledColorInput(Node& node) > { >- Node* candidate = setToShadowAncestor ? node.deprecatedShadowAncestorNode() : &node; >- if (is<HTMLInputElement>(*candidate)) { >- auto& input = downcast<HTMLInputElement>(*candidate); >- if (input.isColorControl() && !input.isDisabledFormControl()) >- return true; >- } >+ if (!is<HTMLInputElement>(node)) >+ return false; >+ auto& input = downcast<HTMLInputElement>(node); >+ return input.isColorControl() && !input.isDisabledFormControl(); >+} > >- return false; >+static bool hasEnabledColorInputAsShadowHost(Node& node) >+{ >+ auto* host = node.shadowHost(); >+ return host && isEnabledColorInput(*host); > } >+ > #endif > > // This can return null if an empty document is loaded. >@@ -364,13 +368,13 @@ static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& > HitTestResult result(point); > documentUnderMouse->renderView()->hitTest(HitTestRequest(), result); > >- Node* node = result.innerNode(); >- while (node && !is<Element>(*node)) >- node = node->parentNode(); >- if (node) >- node = node->deprecatedShadowAncestorNode(); >- >- return downcast<Element>(node); >+ auto* node = result.innerNode(); >+ if (!node) >+ return nullptr; >+ // FIXME: Use parentElementInComposedTree here. >+ auto* element = is<Element>(*node) ? &downcast<Element>(*node) : node->parentElement(); >+ auto* host = element->shadowHost(); >+ return host ? host : element; > } > > #if !ENABLE(DATA_INTERACTION) >@@ -551,7 +555,7 @@ bool DragController::concludeEditDrag(const DragData& dragData) > if (!color.isValid()) > return false; > #if ENABLE(INPUT_TYPE_COLOR) >- if (isEnabledColorInput(*element, false)) { >+ if (isEnabledColorInput(*element)) { > auto& input = downcast<HTMLInputElement>(*element); > input.setValue(color.serialized(), DispatchInputAndChangeEvent); > return true; >@@ -655,14 +659,15 @@ bool DragController::canProcessDrag(const DragData& dragData) > > result = m_page.mainFrame().eventHandler().hitTestResultAtPoint(point, HitTestRequest::ReadOnly | HitTestRequest::Active); > >- if (!result.innerNonSharedNode()) >+ auto* dragNode = result.innerNonSharedNode(); >+ if (!dragNode) > return false; > > DragData::DraggingPurpose dragPurpose = DragData::DraggingPurpose::ForEditing; >- if (asFileInput(*result.innerNonSharedNode())) >+ if (asFileInput(*dragNode)) > dragPurpose = DragData::DraggingPurpose::ForFileUpload; > #if ENABLE(INPUT_TYPE_COLOR) >- else if (isEnabledColorInput(*result.innerNonSharedNode(), true)) >+ else if (isEnabledColorInput(*dragNode) || hasEnabledColorInputAsShadowHost(*dragNode)) > dragPurpose = DragData::DraggingPurpose::ForColorControl; > #endif > >@@ -677,10 +682,10 @@ bool DragController::canProcessDrag(const DragData& dragData) > return true; > #endif > >- if (is<HTMLPlugInElement>(*result.innerNonSharedNode())) { >- if (!downcast<HTMLPlugInElement>(result.innerNonSharedNode())->canProcessDrag() && !result.innerNonSharedNode()->hasEditableStyle()) >+ if (is<HTMLPlugInElement>(*dragNode)) { >+ if (!downcast<HTMLPlugInElement>(dragNode)->canProcessDrag() && !dragNode->hasEditableStyle()) > return false; >- } else if (!result.innerNonSharedNode()->hasEditableStyle()) >+ } else if (!dragNode->hasEditableStyle()) > return false; > > if (m_didInitiateDrag && m_documentUnderMouse == m_dragInitiator && result.isSelected()) >@@ -813,8 +818,7 @@ Element* DragController::draggableElement(const Frame* sourceFrame, Element* sta > } > #endif > #if ENABLE(INPUT_TYPE_COLOR) >- if ((m_dragSourceAction & DragSourceActionColor) >- && isEnabledColorInput(*element, false)) { >+ if ((m_dragSourceAction & DragSourceActionColor) && isEnabledColorInput(*element)) { > state.type = static_cast<DragSourceAction>(state.type | DragSourceActionColor); > return element; > } >diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp >index 2024a76f4a15784e52595d7e14c0a14443531f2a..ade37f5af19aebaefce25cb9234212f354750ec3 100644 >--- a/Source/WebCore/page/EventHandler.cpp >+++ b/Source/WebCore/page/EventHandler.cpp >@@ -3121,7 +3121,7 @@ bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& event) > > if ((event.modifiers() - PlatformEvent::Modifier::ShiftKey) != accessKeyModifiers()) > return false; >- Element* element = m_frame.document()->getElementByAccessKey(event.unmodifiedText()); >+ auto* element = m_frame.document()->elementForAccessKey(event.unmodifiedText()); > if (!element) > return false; > element->accessKeyAction(false); >diff --git a/Source/WebCore/page/FocusController.cpp b/Source/WebCore/page/FocusController.cpp >index 439b1927c7377d41599ccb39871078fc1385f89c..75276b237556d3d639c181196df26843208a8372 100644 >--- a/Source/WebCore/page/FocusController.cpp >+++ b/Source/WebCore/page/FocusController.cpp >@@ -767,21 +767,23 @@ static void clearSelectionIfNeeded(Frame* oldFocusedFrame, Frame* newFocusedFram > if (caretBrowsing) > return; > >- Node* selectionStartNode = selection.start().deprecatedNode(); >- if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendantOf(newFocusedNode) || selectionStartNode->deprecatedShadowAncestorNode() == newFocusedNode) >- return; >- >+ if (newFocusedNode) { >+ Node* selectionStartNode = selection.start().deprecatedNode(); >+ if (newFocusedNode->contains(selectionStartNode) || selectionStartNode->shadowHost() == newFocusedNode) >+ return; >+ } >+ > if (Node* mousePressNode = newFocusedFrame->eventHandler().mousePressNode()) { > if (mousePressNode->renderer() && !mousePressNode->canStartSelection()) { > // Don't clear the selection for contentEditable elements, but do clear it for input and textarea. See bug 38696. >- Node * root = selection.rootEditableElement(); >+ auto* root = selection.rootEditableElement(); > if (!root) > return; >- >- if (Node* shadowAncestorNode = root->deprecatedShadowAncestorNode()) { >- if (!is<HTMLInputElement>(*shadowAncestorNode) && !is<HTMLTextAreaElement>(*shadowAncestorNode)) >- return; >- } >+ auto* host = root->shadowHost(); >+ // FIXME: Seems likely we can just do the check on "host" here instead of "rootOrHost". >+ auto* rootOrHost = host ? host : root; >+ if (!is<HTMLInputElement>(*rootOrHost) && !is<HTMLTextAreaElement>(*rootOrHost)) >+ return; > } > } > >diff --git a/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp b/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp >index f6fc8beac7b4998976ba9d7c6df105099d129af0..18d4d793938f0f487b0831527a3b77e92d5fad04 100644 >--- a/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp >+++ b/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp >@@ -57,7 +57,7 @@ static inline UniqueRef<Page> createPageForServiceWorker(PageConfiguration&& con > > auto& mainFrame = page->mainFrame(); > mainFrame.loader().initForSynthesizedDocument({ }); >- auto document = Document::createNonRenderedPlaceholder(&mainFrame, data.scriptURL); >+ auto document = Document::createNonRenderedPlaceholder(mainFrame, data.scriptURL); > document->createDOMWindow(); > > document->mutableSettings().setStorageBlockingPolicy(storageBlockingPolicy); >diff --git a/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js b/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js >index d885b0ca1d77f47acec358f20ba95f83c58f9e58..8b772663b38163ee1c8b39cc521289ca914ed722 100644 >--- a/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js >+++ b/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js >@@ -485,7 +485,6 @@ WI.NativePrototypeFunctionParameters = { > getCSSCanvasContext: "contextId, name, width, height", > getElementById: "id", > getElementsByName: "name", >- getOverrideStyle: "[element], [pseudoElement]", > importNode: "node, deep", > queryCommandEnabled: "command", > queryCommandIndeterm: "command", >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp b/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp >index 1b7e0dc496f698b1cd638da22199b59db792369e..533bee9ea769476aa0077e9247ab42e96142430c 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp >@@ -1119,16 +1119,9 @@ WebKitDOMTreeWalker* webkit_dom_document_create_tree_walker(WebKitDOMDocument* s > return WebKit::kit(gobjectResult.get()); > } > >-WebKitDOMCSSStyleDeclaration* webkit_dom_document_get_override_style(WebKitDOMDocument* self, WebKitDOMElement* element, const gchar* pseudoElement) >+WebKitDOMCSSStyleDeclaration* webkit_dom_document_get_override_style(WebKitDOMDocument*, WebKitDOMElement*, const gchar*) > { >- WebCore::JSMainThreadNullState state; >- g_return_val_if_fail(WEBKIT_DOM_IS_DOCUMENT(self), 0); >- g_return_val_if_fail(WEBKIT_DOM_IS_ELEMENT(element), 0); >- WebCore::Document* item = WebKit::core(self); >- WebCore::Element* convertedElement = WebKit::core(element); >- WTF::String convertedPseudoElement = WTF::String::fromUTF8(pseudoElement); >- RefPtr<WebCore::CSSStyleDeclaration> gobjectResult = WTF::getPtr(item->getOverrideStyle(convertedElement, convertedPseudoElement)); >- return WebKit::kit(gobjectResult.get()); >+ return nullptr; > } > > WebKitDOMXPathExpression* webkit_dom_document_create_expression(WebKitDOMDocument* self, const gchar* expression, WebKitDOMXPathNSResolver* resolver, GError** error) >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >index c5a1855f2f16cd23ac6afcd596ede5747b9eadf9..8c78e75fd6806b9e7eb42a0d079d24dd34181901 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >@@ -1781,12 +1781,6 @@ NSDictionary *WebFrameLoaderClient::dataDetectionContext() > > #endif // PLATFORM(COCOA) > >-bool WebFrameLoaderClient::shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const >-{ >- notImplemented(); >- return false; >-} >- > void WebFrameLoaderClient::didChangeScrollOffset() > { > WebPage* webPage = m_frame->page(); >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h >index 0742d1e094102cd2ece4ab18e2566064d13aa339..cfef8a8f9cc8c0ad986d769ceb66300f690426dc 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h >@@ -243,8 +243,6 @@ private: > NSDictionary *dataDetectionContext() final; > #endif > >- bool shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const final; >- > void didChangeScrollOffset() final; > > bool allowScript(bool enabledPerSettings) final; >diff --git a/Source/WebKitLegacy/mac/DOM/DOMDocument.mm b/Source/WebKitLegacy/mac/DOM/DOMDocument.mm >index 3b04d3933d24aae3335bd87b81069f4cce7bd614..46ccdfd1e3e7275f425e36aefe68daeb83123fd4 100644 >--- a/Source/WebKitLegacy/mac/DOM/DOMDocument.mm >+++ b/Source/WebKitLegacy/mac/DOM/DOMDocument.mm >@@ -574,8 +574,7 @@ - (DOMTreeWalker *)createTreeWalker:(DOMNode *)root whatToShow:(unsigned)whatToS > > - (DOMCSSStyleDeclaration *)getOverrideStyle:(DOMElement *)element pseudoElement:(NSString *)pseudoElement > { >- WebCore::JSMainThreadNullState state; >- return kit(WTF::getPtr(IMPL->getOverrideStyle(core(element), pseudoElement))); >+ return nil; > } > > static RefPtr<WebCore::XPathNSResolver> wrap(id <DOMXPathNSResolver> resolver) >@@ -787,7 +786,7 @@ - (DOMTreeWalker *)createTreeWalker:(DOMNode *)root :(unsigned)whatToShow :(id < > > - (DOMCSSStyleDeclaration *)getOverrideStyle:(DOMElement *)element :(NSString *)pseudoElement > { >- return [self getOverrideStyle:element pseudoElement:pseudoElement]; >+ return nil; > } > > - (DOMXPathExpression *)createExpression:(NSString *)expression :(id <DOMXPathNSResolver>)resolver
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194764
:
362243
|
362251
|
362252
|
362255
|
362258
|
362261
|
362291
|
362294
|
362295