summaryrefslogtreecommitdiffstats
path: root/WebCore/dom
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/dom')
-rw-r--r--WebCore/dom/ClassNodeList.cpp2
-rw-r--r--WebCore/dom/ContainerNode.cpp17
-rw-r--r--WebCore/dom/ContainerNode.h1
-rw-r--r--WebCore/dom/DecodedDataDocumentParser.cpp2
-rw-r--r--WebCore/dom/Document.cpp263
-rw-r--r--WebCore/dom/Document.h72
-rw-r--r--WebCore/dom/Document.idl8
-rw-r--r--WebCore/dom/DocumentMarker.h3
-rw-r--r--WebCore/dom/Element.cpp52
-rw-r--r--WebCore/dom/Element.h13
-rw-r--r--WebCore/dom/Element.idl8
-rw-r--r--WebCore/dom/EventNames.h2
-rw-r--r--WebCore/dom/NamedNodeMap.cpp2
-rw-r--r--WebCore/dom/Node.cpp132
-rw-r--r--WebCore/dom/Node.h11
-rw-r--r--WebCore/dom/OptionElement.cpp2
-rw-r--r--WebCore/dom/ProcessingInstruction.cpp3
-rw-r--r--WebCore/dom/SelectorNodeList.cpp2
-rw-r--r--WebCore/dom/StyleElement.cpp5
-rw-r--r--WebCore/dom/StyledElement.cpp4
-rw-r--r--WebCore/dom/XMLDocumentParser.cpp2
-rw-r--r--WebCore/dom/XMLDocumentParserLibxml2.cpp27
-rw-r--r--WebCore/dom/XMLDocumentParserQt.cpp2
-rwxr-xr-xWebCore/dom/make_names.pl11
24 files changed, 436 insertions, 210 deletions
diff --git a/WebCore/dom/ClassNodeList.cpp b/WebCore/dom/ClassNodeList.cpp
index d482359..60d668b 100644
--- a/WebCore/dom/ClassNodeList.cpp
+++ b/WebCore/dom/ClassNodeList.cpp
@@ -37,7 +37,7 @@ namespace WebCore {
ClassNodeList::ClassNodeList(PassRefPtr<Node> rootNode, const String& classNames)
: DynamicNodeList(rootNode)
- , m_classNames(classNames, m_rootNode->document()->inCompatMode())
+ , m_classNames(classNames, m_rootNode->document()->inQuirksMode())
, m_originalClassNames(classNames)
{
}
diff --git a/WebCore/dom/ContainerNode.cpp b/WebCore/dom/ContainerNode.cpp
index ef62b38..064d4e5 100644
--- a/WebCore/dom/ContainerNode.cpp
+++ b/WebCore/dom/ContainerNode.cpp
@@ -72,6 +72,23 @@ void ContainerNode::removeAllChildren()
removeAllChildrenInContainer<Node, ContainerNode>(this);
}
+
+void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
+{
+ NodeVector children;
+ for (Node* child = oldParent->firstChild(); child; child = child->nextSibling())
+ children.append(child);
+ oldParent->removeAllChildren();
+
+ for (unsigned i = 0; i < children.size(); ++i) {
+ ExceptionCode ec = 0;
+ // FIXME: We need a no mutation event version of adoptNode.
+ RefPtr<Node> child = document()->adoptNode(children[i].release(), ec);
+ ASSERT(!ec);
+ parserAddChild(child.release());
+ }
+}
+
ContainerNode::~ContainerNode()
{
removeAllChildren();
diff --git a/WebCore/dom/ContainerNode.h b/WebCore/dom/ContainerNode.h
index ad0a54a..ab90783 100644
--- a/WebCore/dom/ContainerNode.h
+++ b/WebCore/dom/ContainerNode.h
@@ -75,6 +75,7 @@ public:
virtual bool removeChildren();
void removeAllChildren();
+ void takeAllChildrenFrom(ContainerNode*);
void cloneChildNodes(ContainerNode* clone);
diff --git a/WebCore/dom/DecodedDataDocumentParser.cpp b/WebCore/dom/DecodedDataDocumentParser.cpp
index 51cc847..39bf8e4 100644
--- a/WebCore/dom/DecodedDataDocumentParser.cpp
+++ b/WebCore/dom/DecodedDataDocumentParser.cpp
@@ -50,7 +50,7 @@ void DecodedDataDocumentParser::appendBytes(DocumentWriter* writer , const char*
if (decoded.isEmpty())
return;
- writer->reportDataRecieved();
+ writer->reportDataReceived();
append(decoded);
}
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 2528b3a..99ce273 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -82,7 +82,6 @@
#include "HTMLStyleElement.h"
#include "HTMLTitleElement.h"
#include "HTTPParsers.h"
-#include "HistoryItem.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
#include "ImageLoader.h"
@@ -136,6 +135,7 @@
#include "XMLHttpRequest.h"
#include "XMLNSNames.h"
#include "XMLNames.h"
+#include "XSSAuditor.h"
#include "htmlediting.h"
#include <wtf/CurrentTime.h>
#include <wtf/HashFunctions.h>
@@ -371,9 +371,12 @@ private:
Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
: ContainerNode(0)
+ , m_compatibilityMode(NoQuirksMode)
+ , m_compatibilityModeLocked(false)
, m_domTreeVersion(0)
, m_styleSheets(StyleSheetList::create(this))
, m_styleRecalcTimer(this, &Document::styleRecalcTimerFired)
+ , m_pendingStyleRecalcShouldForce(false)
, m_frameElementsShouldIgnoreScrolling(false)
, m_containsValidityStyleRules(false)
, m_updateFocusAppearanceRestoresSelection(false)
@@ -415,6 +418,11 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
#endif
, m_weakReference(DocumentWeakReference::create(this))
, m_idAttributeName(idAttr)
+#if ENABLE(FULLSCREEN_API)
+ , m_isFullScreen(0)
+ , m_areKeysEnabledInFullScreen(0)
+#endif
+ , m_loadEventDelayCount(0)
{
m_document = this;
@@ -442,8 +450,6 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
m_bParsing = false;
m_wellFormed = false;
- setParseMode(Strict);
-
m_textColor = Color::black;
m_listenerTypes = 0;
setInDocument();
@@ -502,6 +508,9 @@ void Document::removedLastRef()
m_activeNode = 0;
m_titleElement = 0;
m_documentElement = 0;
+#if ENABLE(FULLSCREEN_API)
+ m_fullScreenElement = 0;
+#endif
// removeAllChildren() doesn't always unregister IDs, do it upfront to avoid having stale references in the map.
m_elementsById.clear();
@@ -599,6 +608,20 @@ void Document::destroyAllWrapperCaches()
}
#endif
+void Document::setCompatibilityMode(CompatibilityMode mode)
+{
+ if (m_compatibilityModeLocked || mode == m_compatibilityMode)
+ return;
+ ASSERT(!documentElement() && !m_styleSheets->length());
+ bool wasInQuirksMode = inQuirksMode();
+ m_compatibilityMode = mode;
+ if (inQuirksMode() != wasInQuirksMode) {
+ // All user stylesheets have to reparse using the different mode.
+ clearPageUserSheet();
+ clearPageGroupUserSheets();
+ }
+}
+
void Document::resetLinkColor()
{
m_linkColor = Color(0, 0, 238);
@@ -617,13 +640,11 @@ void Document::resetActiveLinkColor()
void Document::setDocType(PassRefPtr<DocumentType> docType)
{
// This should never be called more than once.
- // Note: This is not a public DOM method and can only be called by the parser.
ASSERT(!m_docType || !docType);
- if (m_docType && docType)
- return;
m_docType = docType;
if (m_docType)
m_docType->setDocument(this);
+<<<<<<< HEAD
#ifdef ANDROID_META_SUPPORT
if (m_docType && !ownerElement()
&& m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", false)) {
@@ -635,6 +656,8 @@ void Document::setDocType(PassRefPtr<DocumentType> docType)
}
#endif
determineParseMode();
+=======
+>>>>>>> webkit.org at r66666
}
DOMImplementation* Document::implementation() const
@@ -1388,12 +1411,18 @@ PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho
return TreeWalker::create(root, whatToShow, filter, expandEntityReferences);
}
+void Document::scheduleForcedStyleRecalc()
+{
+ m_pendingStyleRecalcShouldForce = true;
+ scheduleStyleRecalc();
+}
+
void Document::scheduleStyleRecalc()
{
if (m_styleRecalcTimer.isActive() || inPageCache())
return;
- ASSERT(childNeedsStyleRecalc());
+ ASSERT(childNeedsStyleRecalc() || m_pendingStyleRecalcShouldForce);
if (!documentsThatNeedStyleRecalc)
documentsThatNeedStyleRecalc = new HashSet<Document*>;
@@ -1416,6 +1445,7 @@ void Document::unscheduleStyleRecalc()
documentsThatNeedStyleRecalc->remove(this);
m_styleRecalcTimer.stop();
+ m_pendingStyleRecalcShouldForce = false;
}
void Document::styleRecalcTimerFired(Timer<Document>*)
@@ -1457,6 +1487,9 @@ void Document::recalcStyle(StyleChange change)
ASSERT(!renderer() || renderArena());
if (!renderer() || !renderArena())
goto bail_out;
+
+ if (m_pendingStyleRecalcShouldForce)
+ change = Force;
if (change == Force) {
// style selector may set this again during recalc
@@ -1512,14 +1545,14 @@ void Document::updateStyleIfNeeded()
{
ASSERT(!view() || (!view()->isInLayout() && !view()->isPainting()));
- if (!childNeedsStyleRecalc() || inPageCache())
+ if ((!m_pendingStyleRecalcShouldForce && !childNeedsStyleRecalc()) || inPageCache())
return;
-
+
if (m_frame)
m_frame->animation()->beginAnimationUpdate();
recalcStyle(NoChange);
-
+
// Tell the animation controller that updateStyleIfNeeded is finished and it can do any post-processing
if (m_frame)
m_frame->animation()->endAnimationUpdate();
@@ -1534,7 +1567,6 @@ void Document::updateStyleForAllDocuments()
HashSet<Document*>::iterator it = documentsThatNeedStyleRecalc->begin();
Document* doc = *it;
documentsThatNeedStyleRecalc->remove(doc);
- ASSERT(doc->childNeedsStyleRecalc() && !doc->inPageCache());
doc->updateStyleIfNeeded();
}
}
@@ -1572,7 +1604,7 @@ void Document::updateLayoutIgnorePendingStylesheets()
// suspend JS instead of doing a layout with inaccurate information.
if (body() && !body()->renderer() && m_pendingSheetLayout == NoLayoutWithPendingSheets) {
m_pendingSheetLayout = DidLayoutWithPendingSheets;
- updateStyleSelector();
+ styleSelectorChanged(RecalcStyleImmediately);
} else if (m_hasNodesWithPlaceholderStyle)
// If new nodes have been added or style recalc has been done with style sheets still pending, some nodes
// may not have had their real style calculated yet. Normally this gets cleaned when style sheets arrive
@@ -1652,7 +1684,7 @@ void Document::createStyleSelector()
if (Settings* docSettings = settings())
matchAuthorAndUserStyles = docSettings->authorAndUserStylesEnabled();
m_styleSelector.set(new CSSStyleSelector(this, m_styleSheets.get(), m_mappedElementSheet.get(), pageUserSheet(), pageGroupUserSheets(),
- !inCompatMode(), matchAuthorAndUserStyles));
+ !inQuirksMode(), matchAuthorAndUserStyles));
}
void Document::attach()
@@ -1883,6 +1915,8 @@ void Document::implicitOpen()
removeChildren();
+ setCompatibilityMode(NoQuirksMode);
+
m_parser = createParser();
setParsing(true);
@@ -2036,8 +2070,7 @@ void Document::implicitClose()
ImageLoader::dispatchPendingLoadEvents();
dispatchWindowLoadEvent();
enqueuePageshowEvent(PageshowEventNotPersisted);
- if (m_pendingStateObject)
- enqueuePopstateEvent(m_pendingStateObject.release());
+ enqueuePopstateEvent(m_pendingStateObject ? m_pendingStateObject.release() : SerializedScriptValue::nullValue());
if (f)
f->loader()->handledOnloadEvents();
@@ -2212,12 +2245,6 @@ void Document::setURL(const KURL& url)
updateBaseURL();
}
-void Document::setBaseElementURL(const KURL& baseElementURL)
-{
- m_baseElementURL = baseElementURL;
- updateBaseURL();
-}
-
void Document::updateBaseURL()
{
// DOM 3 Core: When the Document supports the feature "HTML" [DOM Level 2 HTML], the base URI is computed using
@@ -2238,6 +2265,41 @@ void Document::updateBaseURL()
m_mappedElementSheet->setFinalURL(m_baseURL);
}
+void Document::processBaseElement()
+{
+ // Find the first href attribute in a base element and the first target attribute in a base element.
+ const AtomicString* href = 0;
+ const AtomicString* target = 0;
+ for (Node* node = document()->firstChild(); node && (!href || !target); node = node->traverseNextNode()) {
+ if (node->hasTagName(baseTag)) {
+ if (!href) {
+ const AtomicString& value = static_cast<Element*>(node)->fastGetAttribute(hrefAttr);
+ if (!value.isNull())
+ href = &value;
+ }
+ if (!target) {
+ const AtomicString& value = static_cast<Element*>(node)->fastGetAttribute(targetAttr);
+ if (!value.isNull())
+ target = &value;
+ }
+ }
+ }
+
+ // FIXME: Since this doesn't share code with completeURL it may not handle encodings correctly.
+ KURL baseElementURL;
+ if (href) {
+ String strippedHref = deprecatedParseURL(*href);
+ if (!strippedHref.isEmpty() && (!frame() || frame()->script()->xssAuditor()->canSetBaseElementURL(*href)))
+ baseElementURL = KURL(url(), strippedHref);
+ }
+ if (m_baseElementURL != baseElementURL) {
+ m_baseElementURL = baseElementURL;
+ updateBaseURL();
+ }
+
+ m_baseTarget = target ? *target : nullAtom;
+}
+
String Document::userAgent(const KURL& url) const
{
return frame() ? frame()->loader()->userAgent(url) : String();
@@ -2259,14 +2321,23 @@ CSSStyleSheet* Document::pageUserSheet()
// Parse the sheet and cache it.
m_pageUserSheet = CSSStyleSheet::createInline(this, settings()->userStyleSheetLocation());
m_pageUserSheet->setIsUserStyleSheet(true);
- m_pageUserSheet->parseString(userSheetText, !inCompatMode());
+ m_pageUserSheet->parseString(userSheetText, !inQuirksMode());
return m_pageUserSheet.get();
}
void Document::clearPageUserSheet()
{
- m_pageUserSheet = 0;
- updateStyleSelector();
+ if (m_pageUserSheet) {
+ m_pageUserSheet = 0;
+ styleSelectorChanged(DeferRecalcStyle);
+ }
+}
+
+void Document::updatePageUserSheet()
+{
+ clearPageUserSheet();
+ if (pageUserSheet())
+ styleSelectorChanged(RecalcStyleImmediately);
}
const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
@@ -2296,7 +2367,7 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
continue;
RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::createInline(const_cast<Document*>(this), sheet->url());
parsedSheet->setIsUserStyleSheet(sheet->level() == UserStyleSheet::UserLevel);
- parsedSheet->parseString(sheet->source(), !inCompatMode());
+ parsedSheet->parseString(sheet->source(), !inQuirksMode());
if (!m_pageGroupUserSheets)
m_pageGroupUserSheets.set(new Vector<RefPtr<CSSStyleSheet> >);
m_pageGroupUserSheets->append(parsedSheet.release());
@@ -2308,9 +2379,18 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const
void Document::clearPageGroupUserSheets()
{
- m_pageGroupUserSheets.clear();
m_pageGroupUserSheetCacheValid = false;
- updateStyleSelector();
+ if (m_pageGroupUserSheets && m_pageGroupUserSheets->size()) {
+ m_pageGroupUserSheets->clear();
+ styleSelectorChanged(DeferRecalcStyle);
+ }
+}
+
+void Document::updatePageGroupUserSheets()
+{
+ clearPageGroupUserSheets();
+ if (pageGroupUserSheets() && pageGroupUserSheets()->size())
+ styleSelectorChanged(RecalcStyleImmediately);
}
CSSStyleSheet* Document::elementSheet()
@@ -2480,7 +2560,7 @@ void Document::processHttpEquiv(const String& equiv, const String& content)
// -dwh
m_selectedStylesheetSet = content;
m_preferredStylesheetSet = content;
- updateStyleSelector();
+ styleSelectorChanged(DeferRecalcStyle);
} else if (equalIgnoringCase(equiv, "refresh")) {
double delay;
String url;
@@ -2746,9 +2826,7 @@ String Document::selectedStylesheetSet() const
void Document::setSelectedStylesheetSet(const String& aString)
{
m_selectedStylesheetSet = aString;
- updateStyleSelector();
- if (renderer())
- renderer()->repaint();
+ styleSelectorChanged(DeferRecalcStyle);
}
// This method is called whenever a top-level stylesheet has finished loading.
@@ -2764,35 +2842,44 @@ void Document::removePendingSheet()
printf("Stylesheet loaded at time %d. %d stylesheets still remain.\n", elapsedTime(), m_pendingStylesheets);
#endif
- updateStyleSelector();
+ styleSelectorChanged(RecalcStyleImmediately);
+
+ if (m_pendingStylesheets)
+ return;
ScriptableDocumentParser* parser = scriptableDocumentParser();
- if (!m_pendingStylesheets && parser)
+ if (parser)
parser->executeScriptsWaitingForStylesheets();
- if (!m_pendingStylesheets && m_gotoAnchorNeededAfterStylesheetsLoad && view())
+ if (m_gotoAnchorNeededAfterStylesheetsLoad && view())
view()->scrollToFragment(m_frame->loader()->url());
}
-void Document::updateStyleSelector()
+void Document::styleSelectorChanged(StyleSelectorUpdateFlag updateFlag)
{
// Don't bother updating, since we haven't loaded all our style info yet
// and haven't calculated the style selector for the first time.
- if (!m_didCalculateStyleSelector && !haveStylesheetsLoaded())
+ if (!attached() || (!m_didCalculateStyleSelector && !haveStylesheetsLoaded()))
return;
- if (didLayoutWithPendingStylesheets() && m_pendingStylesheets <= 0) {
- m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;
- if (renderer())
- renderer()->repaint();
- }
-
#ifdef INSTRUMENT_LAYOUT_SCHEDULING
if (!ownerElement())
printf("Beginning update of style selector at time %d.\n", elapsedTime());
#endif
recalcStyleSelector();
+
+ if (updateFlag == DeferRecalcStyle) {
+ scheduleForcedStyleRecalc();
+ return;
+ }
+
+ if (didLayoutWithPendingStylesheets() && m_pendingStylesheets <= 0) {
+ m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;
+ if (renderer())
+ renderer()->repaint();
+ }
+
// This recalcStyle initiates a new recalc cycle. We need to bracket it to
// make sure animations get the correct update time
if (m_frame)
@@ -3246,6 +3333,19 @@ void Document::nodeWillBeRemoved(Node* n)
frame->selection()->nodeWillBeRemoved(n);
frame->dragCaretController()->nodeWillBeRemoved(n);
}
+
+#if ENABLE(FULLSCREEN_API)
+ // If the current full screen element or any of its ancestors is removed, set the current
+ // full screen element to the document root, and fire a fullscreenchange event to inform
+ // clients of the DOM.
+ ASSERT(n);
+ if (n->contains(m_fullScreenElement.get())) {
+ ASSERT(n != documentElement());
+ m_fullScreenElement = documentElement();
+ m_fullScreenElement->setNeedsStyleRecalc();
+ m_fullScreenElement->dispatchEvent(Event::create(eventNames().webkitfullscreenchangeEvent, true, false));
+ }
+#endif
}
void Document::textInserted(Node* text, unsigned offset, unsigned length)
@@ -3767,7 +3867,7 @@ void Document::setInPageCache(bool flag)
m_savedRenderer = renderer();
if (FrameView* v = view())
v->resetScrollbars();
- unscheduleStyleRecalc();
+ m_styleRecalcTimer.stop();
} else {
ASSERT(!renderer() || renderer() == m_savedRenderer);
ASSERT(m_renderArena);
@@ -3984,7 +4084,7 @@ const SVGDocumentExtensions* Document::svgExtensions()
SVGDocumentExtensions* Document::accessSVGExtensions()
{
if (!m_svgExtensions)
- m_svgExtensions.set(new SVGDocumentExtensions(this));
+ m_svgExtensions = adoptPtr(new SVGDocumentExtensions(this));
return m_svgExtensions.get();
}
#endif
@@ -4560,7 +4660,7 @@ Element* Document::findAnchor(const String& name)
for (Node* node = this; node; node = node->traverseNextNode()) {
if (node->hasTagName(aTag)) {
HTMLAnchorElement* anchor = static_cast<HTMLAnchorElement*>(node);
- if (inCompatMode()) {
+ if (inQuirksMode()) {
// Quirks mode, case insensitive comparison of names.
if (equalIgnoringCase(anchor->name(), name))
return anchor;
@@ -4659,5 +4759,78 @@ InspectorController* Document::inspectorController() const
return page() ? page()->inspectorController() : 0;
}
#endif
+
+#if ENABLE(FULLSCREEN_API)
+void Document::webkitRequestFullScreenForElement(Element* element, unsigned short flags)
+{
+ if (!page() || !page()->settings()->fullScreenEnabled())
+ return;
+
+ if (!element)
+ element = documentElement();
+
+ if (!page()->chrome()->client()->supportsFullScreenForElement(element))
+ return;
+
+ m_areKeysEnabledInFullScreen = flags & Element::ALLOW_KEYBOARD_INPUT;
+ page()->chrome()->client()->enterFullScreenForElement(element);
+}
+
+void Document::webkitCancelFullScreen()
+{
+ if (!page() || !m_fullScreenElement)
+ return;
+
+ page()->chrome()->client()->exitFullScreenForElement(m_fullScreenElement.get());
+}
+
+void Document::webkitWillEnterFullScreenForElement(Element* element)
+{
+ ASSERT(element);
+ ASSERT(page() && page()->settings()->fullScreenEnabled());
+
+ m_fullScreenElement = element;
+ m_isFullScreen = true;
+ documentElement()->setNeedsStyleRecalc(FullStyleChange);
+ m_fullScreenElement->setNeedsStyleRecalc(FullStyleChange);
+ updateStyleIfNeeded();
+
+ m_fullScreenElement->dispatchEvent(Event::create(eventNames().webkitfullscreenchangeEvent, true, false));
+}
+
+void Document::webkitDidEnterFullScreenForElement(Element*)
+{
+}
+
+void Document::webkitWillExitFullScreenForElement(Element*)
+{
+}
+
+void Document::webkitDidExitFullScreenForElement(Element* element)
+{
+ ASSERT(element);
+ m_isFullScreen = false;
+ m_areKeysEnabledInFullScreen = false;
+
+ // m_fullScreenElement has already been cleared; recalc the style of
+ // the passed in element instead.
+ element->setNeedsStyleRecalc(FullStyleChange);
+ if (element != documentElement())
+ documentElement()->setNeedsStyleRecalc(FullStyleChange);
+ updateStyleIfNeeded();
+
+ element->dispatchEvent(Event::create(eventNames().webkitfullscreenchangeEvent, true, false));
+}
+
+#endif
+
+void Document::decrementLoadEventDelayCount()
+{
+ ASSERT(m_loadEventDelayCount);
+ --m_loadEventDelayCount;
+
+ if (frame() && !m_loadEventDelayCount)
+ frame()->loader()->checkCompleted();
+}
} // namespace WebCore
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 18dc838..ac0c2a2 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -85,7 +85,6 @@ class HTMLFrameOwnerElement;
class HTMLHeadElement;
class HTMLInputElement;
class HTMLMapElement;
-class HistoryItem;
class HitTestRequest;
class HitTestResult;
class InspectorTimelineAgent;
@@ -182,7 +181,9 @@ enum PageshowEventPersistence {
PageshowEventNotPersisted = 0,
PageshowEventPersisted = 1
};
-
+
+enum StyleSelectorUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle };
+
class Document : public ContainerNode, public ScriptExecutionContext {
public:
static PassRefPtr<Document> create(Frame* frame, const KURL& url)
@@ -271,6 +272,9 @@ public:
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel);
#endif
+#if ENABLE(FULLSCREEN_API)
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenchange);
+#endif
DocumentType* doctype() const { return m_docType.get(); }
@@ -440,8 +444,7 @@ public:
* constructed from these which is used to create the a new style selector which collates all of the stylesheets
* found and is used to calculate the derived styles for all rendering objects.
*/
- void updateStyleSelector();
-
+ void styleSelectorChanged(StyleSelectorUpdateFlag);
void recalcStyleSelector();
bool usesDescendantRules() const { return m_usesDescendantRules; }
@@ -539,12 +542,8 @@ public:
void setURL(const KURL&);
const KURL& baseURL() const { return m_baseURL; }
- // Setting the BaseElementURL will change the baseURL.
- void setBaseElementURL(const KURL&);
-
const String& baseTarget() const { return m_baseTarget; }
- // Setting the BaseElementTarget will change the baseTarget.
- void setBaseElementTarget(const String& baseTarget) { m_baseTarget = baseTarget; }
+ void processBaseElement();
KURL completeURL(const String&) const;
@@ -552,9 +551,11 @@ public:
CSSStyleSheet* pageUserSheet();
void clearPageUserSheet();
+ void updatePageUserSheet();
const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets() const;
void clearPageGroupUserSheets();
+ void updatePageGroupUserSheets();
CSSStyleSheet* elementSheet();
CSSStyleSheet* mappedElementSheet();
@@ -571,14 +572,16 @@ public:
bool paginated() const { return printing() || paginatedForScreen(); }
- enum ParseMode { Compat, AlmostStrict, Strict };
+ enum CompatibilityMode { QuirksMode, LimitedQuirksMode, NoQuirksMode };
- void setParseMode(ParseMode m) { m_parseMode = m; }
- ParseMode parseMode() const { return m_parseMode; }
+ virtual void setCompatibilityModeFromDoctype() { }
+ void setCompatibilityMode(CompatibilityMode m);
+ void lockCompatibilityMode() { m_compatibilityModeLocked = true; }
+ CompatibilityMode compatibilityMode() const { return m_compatibilityMode; }
- bool inCompatMode() const { return m_parseMode == Compat; }
- bool inAlmostStrictMode() const { return m_parseMode == AlmostStrict; }
- bool inStrictMode() const { return m_parseMode == Strict; }
+ bool inQuirksMode() const { return m_compatibilityMode == QuirksMode; }
+ bool inLimitedQuirksMode() const { return m_compatibilityMode == LimitedQuirksMode; }
+ bool inNoQuirksMode() const { return m_compatibilityMode == NoQuirksMode; }
void setParsing(bool);
bool parsing() const { return m_bParsing; }
@@ -640,6 +643,7 @@ public:
void setCSSTarget(Element*);
Element* cssTarget() const { return m_cssTarget; }
+ void scheduleForcedStyleRecalc();
void scheduleStyleRecalc();
void unscheduleStyleRecalc();
void styleRecalcTimerFired(Timer<Document>*);
@@ -993,16 +997,35 @@ public:
void enqueueEvent(PassRefPtr<Event>);
void enqueuePageshowEvent(PageshowEventPersistence);
void enqueueHashchangeEvent(const String& oldURL, const String& newURL);
+ void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
void addMediaCanStartListener(MediaCanStartListener*);
void removeMediaCanStartListener(MediaCanStartListener*);
MediaCanStartListener* takeAnyMediaCanStartListener();
const QualifiedName& idAttributeName() const { return m_idAttributeName; }
+
+#if ENABLE(FULLSCREEN_API)
+ bool webkitFullScreen() const { return m_isFullScreen; }
+ bool webkitFullScreenKeyboardInputAllowed() const { return m_isFullScreen && m_areKeysEnabledInFullScreen; }
+ Element* webkitCurrentFullScreenElement() const { return m_fullScreenElement.get(); }
+ void webkitRequestFullScreenForElement(Element*, unsigned short flags);
+ void webkitCancelFullScreen();
+
+ void webkitWillEnterFullScreenForElement(Element*);
+ void webkitDidEnterFullScreenForElement(Element*);
+ void webkitWillExitFullScreenForElement(Element*);
+ void webkitDidExitFullScreenForElement(Element*);
+#endif
bool writeDisabled() const { return m_writeDisabled; }
void setWriteDisabled(bool flag) { m_writeDisabled = flag; }
+ // Used to allow element that loads data without going through a FrameLoader to delay the 'load' event.
+ void incrementLoadEventDelayCount() { ++m_loadEventDelayCount; }
+ void decrementLoadEventDelayCount();
+ bool isDelayingLoadEvent() const { return m_loadEventDelayCount; }
+
protected:
Document(Frame*, const KURL&, bool isXHTML, bool isHTML);
@@ -1017,7 +1040,6 @@ private:
virtual bool isDocument() const { return true; }
virtual void removedLastRef();
- virtual void determineParseMode() { }
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
@@ -1045,7 +1067,6 @@ private:
void createStyleSelector();
- void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject);
void pendingEventTimerFired(Timer<Document>*);
PassRefPtr<NodeList> handleZeroPadding(const HitTestRequest&, HitTestResult&) const;
@@ -1105,7 +1126,8 @@ private:
bool m_ignoreAutofocus;
- ParseMode m_parseMode;
+ CompatibilityMode m_compatibilityMode;
+ bool m_compatibilityModeLocked; // This is cheaper than making setCompatibilityMode virtual.
Color m_textColor;
@@ -1142,9 +1164,12 @@ private:
bool m_loadingSheet;
bool m_visuallyOrdered;
bool m_bParsing;
+
Timer<Document> m_styleRecalcTimer;
+ bool m_pendingStyleRecalcShouldForce;
bool m_inStyleRecalc;
bool m_closeAfterStyleRecalc;
+
bool m_usesDescendantRules;
bool m_usesSiblingRules;
bool m_usesFirstLineRules;
@@ -1281,6 +1306,14 @@ private:
HashSet<MediaCanStartListener*> m_mediaCanStartListeners;
QualifiedName m_idAttributeName;
+
+#if ENABLE(FULLSCREEN_API)
+ bool m_isFullScreen;
+ bool m_areKeysEnabledInFullScreen;
+ RefPtr<Element> m_fullScreenElement;
+#endif
+
+ int m_loadEventDelayCount;
};
inline bool Document::hasElementWithId(AtomicStringImpl* id) const
@@ -1296,8 +1329,7 @@ inline bool Node::isDocumentNode() const
// here because it uses a Document method but we really want to inline it
inline Node::Node(Document* document, ConstructionType type)
- : TreeShared<ContainerNode>(initialRefCount(type))
- , m_document(document)
+ : m_document(document)
, m_previous(0)
, m_next(0)
, m_renderer(0)
diff --git a/WebCore/dom/Document.idl b/WebCore/dom/Document.idl
index 3ae551e..0bd93b8 100644
--- a/WebCore/dom/Document.idl
+++ b/WebCore/dom/Document.idl
@@ -245,6 +245,13 @@ module core {
[DontEnum] void initializeWMLPageState();
#endif
+#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
+ readonly attribute boolean webkitFullScreen;
+ readonly attribute boolean webkitFullScreenKeyboardInputAllowed;
+ readonly attribute Element webkitCurrentFullScreenElement;
+ void webkitCancelFullScreen();
+#endif
+
#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
// Event handler DOM attributes
attribute [DontEnum] EventListener onabort;
@@ -317,6 +324,7 @@ module core {
attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchmove;
attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchend;
attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchcancel;
+ attribute [DontEnum, Conditional=FULLSCREEN_API] EventListener onwebkitfullscreenchange;
#endif
#if defined(LANGUAGE_CPP) && LANGUAGE_CPP
diff --git a/WebCore/dom/DocumentMarker.h b/WebCore/dom/DocumentMarker.h
index 55d2e33..e6160ae 100644
--- a/WebCore/dom/DocumentMarker.h
+++ b/WebCore/dom/DocumentMarker.h
@@ -39,7 +39,8 @@ struct DocumentMarker {
Spelling,
Grammar,
TextMatch,
- Replacement
+ Replacement,
+ RejectedCorrection
};
MarkerType type;
diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp
index 2d44f62..1855101 100644
--- a/WebCore/dom/Element.cpp
+++ b/WebCore/dom/Element.cpp
@@ -273,8 +273,8 @@ static float localZoomForRenderer(RenderObject* renderer)
// FIXME: This does the wrong thing if two opposing zooms are in effect and canceled each
// other out, but the alternative is that we'd have to crawl up the whole render tree every
// time (or store an additional bit in the RenderStyle to indicate that a zoom was specified).
- float zoomFactor = 1.0f;
- if (renderer->style()->effectiveZoom() != 1.0f) {
+ float zoomFactor = 1;
+ if (renderer->style()->effectiveZoom() != 1) {
// Need to find the nearest enclosing RenderObject that set up
// a differing zoom, and then we divide our result by it to eliminate the zoom.
RenderObject* prev = renderer;
@@ -367,9 +367,9 @@ int Element::clientWidth()
// When in strict mode, clientWidth for the document element should return the width of the containing frame.
// When in quirks mode, clientWidth for the body element should return the width of the containing frame.
- bool inCompatMode = document()->inCompatMode();
- if ((!inCompatMode && document()->documentElement() == this) ||
- (inCompatMode && isHTMLElement() && document()->body() == this)) {
+ bool inQuirksMode = document()->inQuirksMode();
+ if ((!inQuirksMode && document()->documentElement() == this) ||
+ (inQuirksMode && isHTMLElement() && document()->body() == this)) {
if (FrameView* view = document()->view()) {
if (RenderView* renderView = document()->renderView())
return adjustForAbsoluteZoom(view->layoutWidth(), renderView);
@@ -387,10 +387,10 @@ int Element::clientHeight()
// When in strict mode, clientHeight for the document element should return the height of the containing frame.
// When in quirks mode, clientHeight for the body element should return the height of the containing frame.
- bool inCompatMode = document()->inCompatMode();
+ bool inQuirksMode = document()->inQuirksMode();
- if ((!inCompatMode && document()->documentElement() == this) ||
- (inCompatMode && isHTMLElement() && document()->body() == this)) {
+ if ((!inQuirksMode && document()->documentElement() == this) ||
+ (inQuirksMode && isHTMLElement() && document()->body() == this)) {
if (FrameView* view = document()->view()) {
if (RenderView* renderView = document()->renderView())
return adjustForAbsoluteZoom(view->layoutHeight(), renderView);
@@ -1313,8 +1313,11 @@ void Element::focus(bool restorePreviousSelection)
RefPtr<Node> protect;
if (Page* page = doc->page()) {
// Focus and change event handlers can cause us to lose our last ref.
+ // If a focus event handler changes the focus to a different node it
+ // does not make sense to continue and update appearence.
protect = this;
- page->focusController()->setFocusedNode(this, doc->frame());
+ if (!page->focusController()->setFocusedNode(this, doc->frame()))
+ return;
}
// Setting the focused node above might have invalidated the layout due to scripts.
@@ -1420,6 +1423,28 @@ RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier)
return pseudoElementSpecifier ? data->m_computedStyle->getCachedPseudoStyle(pseudoElementSpecifier) : data->m_computedStyle.get();
}
+AtomicString Element::computeInheritedLanguage() const
+{
+ const Node* n = this;
+ AtomicString value;
+ // The language property is inherited, so we iterate over the parents to find the first language.
+ while (n && value.isNull()) {
+ if (n->isElementNode()) {
+ // Spec: xml:lang takes precedence -- http://www.w3.org/TR/xhtml1/#C_7
+ value = static_cast<const Element*>(n)->fastGetAttribute(XMLNames::langAttr);
+ if (value.isNull())
+ value = static_cast<const Element*>(n)->fastGetAttribute(HTMLNames::langAttr);
+ } else if (n->isDocumentNode()) {
+ // checking the MIME content-language
+ value = static_cast<const Document*>(n)->contentLanguage();
+ }
+
+ n = n->parent();
+ }
+
+ return value;
+}
+
void Element::cancelFocusAppearanceUpdate()
{
if (hasRareData())
@@ -1498,7 +1523,7 @@ bool Element::webkitMatchesSelector(const String& selector, ExceptionCode& ec)
return false;
}
- bool strictParsing = !document()->inCompatMode();
+ bool strictParsing = !document()->inQuirksMode();
CSSParser p(strictParsing);
CSSSelectorList selectorList;
@@ -1591,5 +1616,12 @@ bool Element::childShouldCreateRenderer(Node* child) const
return Node::childShouldCreateRenderer(child);
}
#endif
+
+#if ENABLE(FULLSCREEN_API)
+void Element::webkitRequestFullScreen(unsigned short flags)
+{
+ document()->webkitRequestFullScreenForElement(this, flags);
+}
+#endif
} // namespace WebCore
diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h
index 694db98..5bbddc2 100644
--- a/WebCore/dom/Element.h
+++ b/WebCore/dom/Element.h
@@ -94,6 +94,9 @@ public:
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel);
#endif
+#if ENABLE(FULLSCREEN_API)
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenchange);
+#endif
virtual PassRefPtr<DocumentFragment> deprecatedCreateContextualFragment(const String&, FragmentScriptingPermission = FragmentScriptingAllowed);
@@ -215,6 +218,8 @@ public:
RenderStyle* computedStyle(PseudoId = NOPSEUDO);
+ AtomicString computeInheritedLanguage() const;
+
void dispatchAttrRemovalEvent(Attribute*);
void dispatchAttrAdditionEvent(Attribute*);
@@ -292,6 +297,14 @@ public:
#if ENABLE(SVG)
virtual bool childShouldCreateRenderer(Node*) const;
#endif
+
+#if ENABLE(FULLSCREEN_API)
+ enum {
+ ALLOW_KEYBOARD_INPUT = 1
+ };
+
+ void webkitRequestFullScreen(unsigned short flags);
+#endif
protected:
Element(const QualifiedName& tagName, Document* document, ConstructionType type)
diff --git a/WebCore/dom/Element.idl b/WebCore/dom/Element.idl
index 0ad3184..2b62a1a 100644
--- a/WebCore/dom/Element.idl
+++ b/WebCore/dom/Element.idl
@@ -100,10 +100,8 @@ module core {
NodeList getElementsByClassName(in DOMString name);
#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
-#if !defined(V8_BINDING) || !V8_BINDING
readonly attribute DOMStringMap dataset;
#endif
-#endif
// NodeSelector - Selector API
Element querySelector(in DOMString selectors)
@@ -133,6 +131,11 @@ module core {
readonly attribute DOMString innerText;
#endif
+#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
+ const unsigned short ALLOW_KEYBOARD_INPUT = 1;
+ void webkitRequestFullScreen(in unsigned short flags);
+#endif
+
#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
// Event handler DOM attributes
attribute [DontEnum] EventListener onabort;
@@ -205,6 +208,7 @@ module core {
attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchmove;
attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchend;
attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchcancel;
+ attribute [DontEnum, Conditional=FULLSCREEN_API] EventListener onwebkitfullscreenchange;
#endif
};
diff --git a/WebCore/dom/EventNames.h b/WebCore/dom/EventNames.h
index 85fe69b..6b8b908 100644
--- a/WebCore/dom/EventNames.h
+++ b/WebCore/dom/EventNames.h
@@ -170,6 +170,8 @@ namespace WebCore {
\
macro(loadend) \
\
+ macro(webkitfullscreenchange)
+ \
// end of DOM_EVENT_NAMES_FOR_EACH
class EventNames : public Noncopyable {
diff --git a/WebCore/dom/NamedNodeMap.cpp b/WebCore/dom/NamedNodeMap.cpp
index 7c9298a..bc56f7e 100644
--- a/WebCore/dom/NamedNodeMap.cpp
+++ b/WebCore/dom/NamedNodeMap.cpp
@@ -309,7 +309,7 @@ void NamedNodeMap::setClass(const String& classStr)
return;
}
- m_classNames.set(classStr, element()->document()->inCompatMode());
+ m_classNames.set(classStr, element()->document()->inQuirksMode());
}
int NamedNodeMap::declCount() const
diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp
index 2c63b62..9b27089 100644
--- a/WebCore/dom/Node.cpp
+++ b/WebCore/dom/Node.cpp
@@ -1076,21 +1076,27 @@ void Node::checkSetPrefix(const AtomicString& prefix, ExceptionCode& ec)
// Attribute-specific checks are in Attr::setPrefix().
}
-bool Node::canReplaceChild(Node* newChild, Node*)
+static bool isChildTypeAllowed(Node* newParent, Node* child)
{
- if (newChild->nodeType() != DOCUMENT_FRAGMENT_NODE) {
- if (!childTypeAllowed(newChild->nodeType()))
+ if (child->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) {
+ if (!newParent->childTypeAllowed(child->nodeType()))
return false;
- } else {
- for (Node *n = newChild->firstChild(); n; n = n->nextSibling()) {
- if (!childTypeAllowed(n->nodeType()))
- return false;
- }
}
+
+ for (Node *n = child->firstChild(); n; n = n->nextSibling()) {
+ if (!newParent->childTypeAllowed(n->nodeType()))
+ return false;
+ }
+
return true;
}
-void Node::checkReplaceChild(Node* newChild, Node* oldChild, ExceptionCode& ec)
+bool Node::canReplaceChild(Node* newChild, Node*)
+{
+ return isChildTypeAllowed(this, newChild);
+}
+
+static void checkAcceptChild(Node* newParent, Node* newChild, ExceptionCode& ec)
{
// Perform error checking as required by spec for adding a new child. Used by replaceChild().
@@ -1101,113 +1107,69 @@ void Node::checkReplaceChild(Node* newChild, Node* oldChild, ExceptionCode& ec)
}
// NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly
- if (isReadOnlyNode()) {
+ if (newParent->isReadOnlyNode()) {
ec = NO_MODIFICATION_ALLOWED_ERR;
return;
}
- bool shouldAdoptChild = false;
-
// WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that
// created this node.
// We assume that if newChild is a DocumentFragment, all children are created from the same document
// as the fragment itself (otherwise they could not have been added as children)
- if (newChild->document() != document()) {
+ if (newChild->document() != newParent->document() && newChild->inDocument()) {
// but if the child is not in a document yet then loosen the
// restriction, so that e.g. creating an element with the Option()
// constructor and then adding it to a different document works,
// as it does in Mozilla and Mac IE.
- if (!newChild->inDocument()) {
- shouldAdoptChild = true;
- } else {
- ec = WRONG_DOCUMENT_ERR;
- return;
- }
+ ec = WRONG_DOCUMENT_ERR;
+ return;
}
// HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the
// newChild node, or if the node to append is one of this node's ancestors.
-
+
// check for ancestor/same node
- if (newChild == this || isDescendantOf(newChild)) {
+ if (newChild == newParent || newParent->isDescendantOf(newChild)) {
ec = HIERARCHY_REQUEST_ERR;
return;
}
-
- if (!canReplaceChild(newChild, oldChild)) {
- ec = HIERARCHY_REQUEST_ERR;
- return;
- }
-
- // change the document pointer of newChild and all of its children to be the new document
- if (shouldAdoptChild)
- for (Node* node = newChild; node; node = node->traverseNextNode(newChild))
- node->setDocument(document());
}
-void Node::checkAddChild(Node *newChild, ExceptionCode& ec)
+static void transferOwnerDocument(Document* newDocument, Node* root)
{
- // Perform error checking as required by spec for adding a new child. Used by appendChild() and insertBefore().
-
- // Not mentioned in spec: throw NOT_FOUND_ERR if newChild is null
- if (!newChild) {
- ec = NOT_FOUND_ERR;
- return;
+ // FIXME: To match Gecko, we should do this for nodes that are already in the document as well.
+ if (root->document() != newDocument && !root->inDocument()) {
+ for (Node* node = root; node; node = node->traverseNextNode(root))
+ node->setDocument(newDocument);
}
+}
- // NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly
- if (isReadOnlyNode()) {
- ec = NO_MODIFICATION_ALLOWED_ERR;
+void Node::checkReplaceChild(Node* newChild, Node* oldChild, ExceptionCode& ec)
+{
+ checkAcceptChild(this, newChild, ec);
+ if (ec)
return;
- }
-
- bool shouldAdoptChild = false;
- // WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that
- // created this node.
- // We assume that if newChild is a DocumentFragment, all children are created from the same document
- // as the fragment itself (otherwise they could not have been added as children)
- if (newChild->document() != document()) {
- // but if the child is not in a document yet then loosen the
- // restriction, so that e.g. creating an element with the Option()
- // constructor and then adding it to a different document works,
- // as it does in Mozilla and Mac IE.
- if (!newChild->inDocument()) {
- shouldAdoptChild = true;
- } else {
- ec = WRONG_DOCUMENT_ERR;
- return;
- }
+ if (!canReplaceChild(newChild, oldChild)) {
+ ec = HIERARCHY_REQUEST_ERR;
+ return;
}
- // HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the
- // newChild node, or if the node to append is one of this node's ancestors.
+ transferOwnerDocument(document(), newChild);
+}
- // check for ancestor/same node
- if (newChild == this || isDescendantOf(newChild)) {
- ec = HIERARCHY_REQUEST_ERR;
+void Node::checkAddChild(Node *newChild, ExceptionCode& ec)
+{
+ checkAcceptChild(this, newChild, ec);
+ if (ec)
return;
- }
- if (newChild->nodeType() != DOCUMENT_FRAGMENT_NODE) {
- if (!childTypeAllowed(newChild->nodeType())) {
- ec = HIERARCHY_REQUEST_ERR;
- return;
- }
- }
- else {
- for (Node *n = newChild->firstChild(); n; n = n->nextSibling()) {
- if (!childTypeAllowed(n->nodeType())) {
- ec = HIERARCHY_REQUEST_ERR;
- return;
- }
- }
+ if (!isChildTypeAllowed(this, newChild)) {
+ ec = HIERARCHY_REQUEST_ERR;
+ return;
}
-
- // change the document pointer of newChild and all of its children to be the new document
- if (shouldAdoptChild)
- for (Node* node = newChild; node; node = node->traverseNextNode(newChild))
- node->setDocument(document());
+
+ transferOwnerDocument(document(), newChild);
}
bool Node::isDescendantOf(const Node *other) const
@@ -1646,7 +1608,7 @@ PassRefPtr<Element> Node::querySelector(const String& selectors, ExceptionCode&
ec = SYNTAX_ERR;
return 0;
}
- bool strictParsing = !document()->inCompatMode();
+ bool strictParsing = !document()->inQuirksMode();
CSSParser p(strictParsing);
CSSSelectorList querySelectorList;
@@ -1693,7 +1655,7 @@ PassRefPtr<NodeList> Node::querySelectorAll(const String& selectors, ExceptionCo
ec = SYNTAX_ERR;
return 0;
}
- bool strictParsing = !document()->inCompatMode();
+ bool strictParsing = !document()->inQuirksMode();
CSSParser p(strictParsing);
CSSSelectorList querySelectorList;
diff --git a/WebCore/dom/Node.h b/WebCore/dom/Node.h
index e4e2b4a..c7f07f1 100644
--- a/WebCore/dom/Node.h
+++ b/WebCore/dom/Node.h
@@ -647,7 +647,6 @@ private:
HasSVGRareDataFlag = 1 << 23, // SVGElement
#endif
StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1),
- CreateWithZeroRefCountFlag = 1 << 26,
#if ENABLE(SVG)
DefaultNodeFlags = IsParsingChildrenFinishedFlag | IsStyleAttributeValidFlag | AreSVGAttributesValidFlag
@@ -664,8 +663,6 @@ private:
void clearFlag(NodeFlags mask) const { m_nodeFlags &= ~mask; }
protected:
- // CreateWithZeroRefCountFlag is deprecated and can be removed once we convert all element
- // classes to start with a reference count of 1.
enum ConstructionType {
CreateOther = DefaultNodeFlags,
CreateText = DefaultNodeFlags | IsTextFlag,
@@ -673,10 +670,8 @@ protected:
CreateContainer = DefaultNodeFlags | IsContainerFlag,
CreateElement = CreateContainer | IsElementFlag,
CreateStyledElement = CreateElement | IsStyledElementFlag,
- CreateStyledElementZeroRefCount = CreateStyledElement | CreateWithZeroRefCountFlag,
CreateHTMLElement = CreateStyledElement | IsHTMLFlag,
CreateSVGElement = CreateStyledElement | IsSVGFlag,
- CreateSVGElementZeroRefCount = CreateSVGElement | CreateWithZeroRefCountFlag,
};
Node(Document*, ConstructionType);
@@ -696,7 +691,6 @@ private:
void markCachedNodeListsSlow(JSC::MarkStack&, JSC::JSGlobalData&);
#endif
- static bool initialRefCount(ConstructionType);
void setStyleChange(StyleChangeType);
virtual void refEventTarget() { ref(); }
@@ -753,11 +747,6 @@ private:
#endif
};
-inline bool Node::initialRefCount(ConstructionType type)
-{
- return !(type & CreateWithZeroRefCountFlag);
-}
-
// Used in Node::addSubresourceAttributeURLs() and in addSubresourceStyleURLs()
inline void addSubresourceURL(ListHashSet<KURL>& urls, const KURL& url)
{
diff --git a/WebCore/dom/OptionElement.cpp b/WebCore/dom/OptionElement.cpp
index 1de5fa4..240a8fc 100644
--- a/WebCore/dom/OptionElement.cpp
+++ b/WebCore/dom/OptionElement.cpp
@@ -73,7 +73,7 @@ String OptionElement::collectOptionLabelOrText(const OptionElementData& data, co
String text;
// WinIE does not use the label attribute, so as a quirk, we ignore it.
- if (!document->inCompatMode())
+ if (!document->inQuirksMode())
text = data.label();
if (text.isEmpty())
text = collectOptionInnerText(element);
diff --git a/WebCore/dom/ProcessingInstruction.cpp b/WebCore/dom/ProcessingInstruction.cpp
index 739d62f..8f4a0ce 100644
--- a/WebCore/dom/ProcessingInstruction.cpp
+++ b/WebCore/dom/ProcessingInstruction.cpp
@@ -274,9 +274,8 @@ void ProcessingInstruction::removedFromDocument()
document()->removeStyleSheetCandidateNode(this);
- // FIXME: It's terrible to do a synchronous update of the style selector just because a <style> or <link> element got removed.
if (m_cachedSheet)
- document()->updateStyleSelector();
+ document()->styleSelectorChanged(DeferRecalcStyle);
}
void ProcessingInstruction::finishParsingChildren()
diff --git a/WebCore/dom/SelectorNodeList.cpp b/WebCore/dom/SelectorNodeList.cpp
index 5beaaee..039a29f 100644
--- a/WebCore/dom/SelectorNodeList.cpp
+++ b/WebCore/dom/SelectorNodeList.cpp
@@ -46,7 +46,7 @@ PassRefPtr<StaticNodeList> createSelectorNodeList(Node* rootNode, const CSSSelec
Vector<RefPtr<Node> > nodes;
Document* document = rootNode->document();
CSSSelector* onlySelector = querySelectorList.hasOneSelector() ? querySelectorList.first() : 0;
- bool strictParsing = !document->inCompatMode();
+ bool strictParsing = !document->inQuirksMode();
CSSStyleSelector::SelectorChecker selectorChecker(document, strictParsing);
diff --git a/WebCore/dom/StyleElement.cpp b/WebCore/dom/StyleElement.cpp
index 4c0e56f..c3a7300 100644
--- a/WebCore/dom/StyleElement.cpp
+++ b/WebCore/dom/StyleElement.cpp
@@ -67,9 +67,8 @@ void StyleElement::removedFromDocument(Document* document, Element* element)
if (!document->renderer())
return;
- // FIXME: It's terrible to do a synchronous update of the style selector just because a <style> or <link> element got removed.
if (m_sheet)
- document->updateStyleSelector();
+ document->styleSelectorChanged(DeferRecalcStyle);
}
void StyleElement::childrenChanged(Element* element)
@@ -138,7 +137,7 @@ void StyleElement::createSheet(Element* e, int startLineNumber, const String& te
document->addPendingSheet();
m_loading = true;
m_sheet = CSSStyleSheet::create(e, String(), KURL(), document->inputEncoding());
- m_sheet->parseStringAtLine(text, !document->inCompatMode(), startLineNumber);
+ m_sheet->parseStringAtLine(text, !document->inQuirksMode(), startLineNumber);
m_sheet->setMedia(mediaList.get());
m_sheet->setTitle(e->title());
m_loading = false;
diff --git a/WebCore/dom/StyledElement.cpp b/WebCore/dom/StyledElement.cpp
index 9b22f1d..a158e2e 100644
--- a/WebCore/dom/StyledElement.cpp
+++ b/WebCore/dom/StyledElement.cpp
@@ -126,7 +126,7 @@ void StyledElement::createInlineStyleDecl()
m_inlineStyleDecl = CSSMutableStyleDeclaration::create();
m_inlineStyleDecl->setParent(document()->elementSheet());
m_inlineStyleDecl->setNode(this);
- m_inlineStyleDecl->setStrictParsing(isHTMLElement() && !document()->inCompatMode());
+ m_inlineStyleDecl->setStrictParsing(isHTMLElement() && !document()->inQuirksMode());
}
void StyledElement::destroyInlineStyleDecl()
@@ -234,7 +234,7 @@ void StyledElement::parseMappedAttribute(Attribute* attr)
if (attributeMap()) {
if (attr->isNull())
attributeMap()->setIdForStyleResolution(nullAtom);
- else if (document()->inCompatMode())
+ else if (document()->inQuirksMode())
attributeMap()->setIdForStyleResolution(attr->value().lower());
else
attributeMap()->setIdForStyleResolution(attr->value());
diff --git a/WebCore/dom/XMLDocumentParser.cpp b/WebCore/dom/XMLDocumentParser.cpp
index c6d9f89..4b76472 100644
--- a/WebCore/dom/XMLDocumentParser.cpp
+++ b/WebCore/dom/XMLDocumentParser.cpp
@@ -231,7 +231,7 @@ void XMLDocumentParser::end()
insertErrorMessageBlock();
else {
exitText();
- document()->updateStyleSelector();
+ document()->styleSelectorChanged(RecalcStyleImmediately);
}
clearCurrentNodeStack();
diff --git a/WebCore/dom/XMLDocumentParserLibxml2.cpp b/WebCore/dom/XMLDocumentParserLibxml2.cpp
index 37da83c..db94c50 100644
--- a/WebCore/dom/XMLDocumentParserLibxml2.cpp
+++ b/WebCore/dom/XMLDocumentParserLibxml2.cpp
@@ -361,6 +361,17 @@ private:
unsigned m_currentOffset;
};
+static void switchToUTF16(xmlParserCtxtPtr ctxt)
+{
+ // Hack around libxml2's lack of encoding overide support by manually
+ // resetting the encoding to UTF-16 before every chunk. Otherwise libxml
+ // will detect <?xml version="1.0" encoding="<encoding name>"?> blocks
+ // and switch encodings, causing the parse to fail.
+ const UChar BOM = 0xFEFF;
+ const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
+ xmlSwitchEncoding(ctxt, BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE : XML_CHAR_ENCODING_UTF16BE);
+}
+
static bool shouldAllowExternalLoad(const KURL& url)
{
String urlString = url.string();
@@ -476,9 +487,7 @@ PassRefPtr<XMLParserContext> XMLParserContext::createStringParser(xmlSAXHandlerP
xmlParserCtxtPtr parser = xmlCreatePushParserCtxt(handlers, 0, 0, 0, 0);
parser->_private = userData;
parser->replaceEntities = true;
- const UChar BOM = 0xFEFF;
- const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
- xmlSwitchEncoding(parser, BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE : XML_CHAR_ENCODING_UTF16BE);
+ switchToUTF16(parser);
return adoptRef(new XMLParserContext(parser));
}
@@ -645,14 +654,7 @@ void XMLDocumentParser::doWrite(const String& parseString)
// keep this alive until this function is done.
RefPtr<XMLDocumentParser> protect(this);
- // Hack around libxml2's lack of encoding overide support by manually
- // resetting the encoding to UTF-16 before every chunk. Otherwise libxml
- // will detect <?xml version="1.0" encoding="<encoding name>"?> blocks
- // and switch encodings, causing the parse to fail.
- const UChar BOM = 0xFEFF;
- const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
- xmlSwitchEncoding(context->context(), BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE : XML_CHAR_ENCODING_UTF16BE);
-
+ switchToUTF16(context->context());
XMLDocumentParserScope scope(document()->docLoader());
xmlParseChunk(context->context(), reinterpret_cast<const char*>(parseString.characters()), sizeof(UChar) * parseString.length(), 0);
@@ -1231,6 +1233,7 @@ static xmlEntityPtr getEntityHandler(void* closure, const xmlChar* name)
static void startDocumentHandler(void* closure)
{
xmlParserCtxt* ctxt = static_cast<xmlParserCtxt*>(closure);
+ switchToUTF16(ctxt);
getParser(closure)->startDocument(ctxt->version, ctxt->encoding, ctxt->standalone);
xmlSAX2StartDocument(closure);
}
@@ -1313,7 +1316,7 @@ void XMLDocumentParser::doEnd()
document()->setTransformSource(new TransformSource(doc));
document()->setParsing(false); // Make the doc think it's done, so it will apply xsl sheets.
- document()->updateStyleSelector();
+ document()->styleSelectorChanged(RecalcStyleImmediately);
document()->setParsing(true);
m_parserStopped = true;
}
diff --git a/WebCore/dom/XMLDocumentParserQt.cpp b/WebCore/dom/XMLDocumentParserQt.cpp
index 606770f..dfd6fb1 100644
--- a/WebCore/dom/XMLDocumentParserQt.cpp
+++ b/WebCore/dom/XMLDocumentParserQt.cpp
@@ -211,7 +211,7 @@ void XMLDocumentParser::doEnd()
if (m_sawXSLTransform) {
document()->setTransformSource(new TransformSource(m_originalSourceForTransform));
document()->setParsing(false); // Make the doc think it's done, so it will apply xsl sheets.
- document()->updateStyleSelector();
+ document()->styleSelectorChanged(RecalcStyleImmediately);
document()->setParsing(true);
m_parserStopped = true;
}
diff --git a/WebCore/dom/make_names.pl b/WebCore/dom/make_names.pl
index e111eb7..9dec124 100755
--- a/WebCore/dom/make_names.pl
+++ b/WebCore/dom/make_names.pl
@@ -128,7 +128,6 @@ sub defaultTagPropertyHash
return (
'constructorNeedsCreatedByParser' => 0,
'constructorNeedsFormElement' => 0,
- 'createWithNew' => 0,
'interfaceName' => defaultInterfaceName($_[0]),
# By default, the JSInterfaceName is the same as the interfaceName.
'JSInterfaceName' => defaultInterfaceName($_[0]),
@@ -317,16 +316,8 @@ END
;
}
- my $newPrefix = "";
- my $createSuffix = "::create";
-
- if ($enabledTags{$tagName}{createWithNew}) {
- $newPrefix = "new ";
- $createSuffix = "";
- }
-
# Call the constructor with the right parameters.
- print F " return $newPrefix$interfaceName${createSuffix}($constructorTagName, document";
+ print F " return ${interfaceName}::create($constructorTagName, document";
print F ", formElement" if $enabledTags{$tagName}{constructorNeedsFormElement};
print F ", createdByParser" if $enabledTags{$tagName}{constructorNeedsCreatedByParser};
print F ");\n}\n\n";