WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Whole WIP2
wip129034c.patch (text/plain), 15.65 KB, created by
Ryosuke Niwa
on 2015-02-25 01:28:02 PST
(
hide
)
Description:
Whole WIP2
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2015-02-25 01:28:02 PST
Size:
15.65 KB
patch
obsolete
>diff --git a/Source/WebCore/css/CSSGrammar.y.in b/Source/WebCore/css/CSSGrammar.y.in >index efdb2bb..1918fc9 100644 >--- a/Source/WebCore/css/CSSGrammar.y.in >+++ b/Source/WebCore/css/CSSGrammar.y.in >@@ -1700,7 +1700,7 @@ unary_term: > $$.fValue = $1; > $$.unit = CSSPrimitiveValue::CSS_REMS; > if (parser->m_styleSheet) >- parser->m_styleSheet->parserSetUsesRemUnits(true); >+ parser->m_styleSheet->parserSetUsesRemUnits(); > } > | CHS { $$.id = CSSValueInvalid; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_CHS; } > | VW { $$.id = CSSValueInvalid; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_VW; } >diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp >index f293ae5..e5c44be 100644 >--- a/Source/WebCore/css/CSSParser.cpp >+++ b/Source/WebCore/css/CSSParser.cpp >@@ -639,7 +639,7 @@ static bool parseSimpleLengthValue(MutableStyleProperties* declaration, CSSPrope > return true; > } > >-static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int valueID, const CSSParserContext& parserContext) >+static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int valueID, const CSSParserContext& parserContext, StyleSheetContents* styleSheetContents) > { > if (!valueID) > return false; >@@ -1014,12 +1014,20 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int > return true; > break; > case CSSPropertyWebkitUserModify: // read-only | read-write >- if (valueID == CSSValueReadOnly || valueID == CSSValueReadWrite || valueID == CSSValueReadWritePlaintextOnly) >+ if (valueID == CSSValueReadOnly || valueID == CSSValueReadWrite || valueID == CSSValueReadWritePlaintextOnly) { >+ if (styleSheetContents) >+ styleSheetContents->parserSetUsesStyleBasedEditability(); > return true; >+ } > break; > case CSSPropertyWebkitUserSelect: // auto | none | text | all >- if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueText || valueID == CSSValueAll) >+ if (valueID == CSSValueAuto || valueID == CSSValueNone || valueID == CSSValueText) >+ return true; >+ if (valueID == CSSValueAll) { >+ if (styleSheetContents) >+ styleSheetContents->parserSetUsesStyleBasedEditability(); > return true; >+ } > break; > case CSSPropertyWebkitWritingMode: > if (valueID >= CSSValueHorizontalTb && valueID <= CSSValueHorizontalBt) >@@ -1175,7 +1183,7 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId) > } > } > >-static bool parseKeywordValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext) >+static bool parseKeywordValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext, StyleSheetContents* styleSheetContents) > { > ASSERT(!string.isEmpty()); > >@@ -1202,7 +1210,7 @@ static bool parseKeywordValue(MutableStyleProperties* declaration, CSSPropertyID > value = cssValuePool().createInheritedValue(); > else if (valueID == CSSValueInitial) > value = cssValuePool().createExplicitInitialValue(); >- else if (isValidKeywordPropertyAndValue(propertyId, valueID, parserContext)) >+ else if (isValidKeywordPropertyAndValue(propertyId, valueID, parserContext, styleSheetContents)) > value = cssValuePool().createIdentifierValue(valueID); > else > return false; >@@ -1307,7 +1315,7 @@ bool CSSParser::parseValue(MutableStyleProperties* declaration, CSSPropertyID pr > context.mode = cssParserMode; > } > >- if (parseKeywordValue(declaration, propertyID, string, important, context)) >+ if (parseKeywordValue(declaration, propertyID, string, important, context, contextStyleSheet)) > return true; > if (parseTranslateTransformValue(declaration, propertyID, string, important)) > return true; >@@ -1885,7 +1893,7 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) > } > > if (isKeywordPropertyID(propId)) { >- if (!isValidKeywordPropertyAndValue(propId, id, m_context)) >+ if (!isValidKeywordPropertyAndValue(propId, id, m_context, m_styleSheet)) > return false; > if (m_valueList->next() && !inShorthand()) > return false; >@@ -6296,7 +6304,7 @@ bool CSSParser::parseFont(bool important) > bool fontWeightParsed = false; > CSSParserValue* value; > while ((value = m_valueList->current())) { >- if (!fontStyleParsed && isValidKeywordPropertyAndValue(CSSPropertyFontStyle, value->id, m_context)) { >+ if (!fontStyleParsed && isValidKeywordPropertyAndValue(CSSPropertyFontStyle, value->id, m_context, m_styleSheet)) { > addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(value->id), important); > fontStyleParsed = true; > } else if (!fontVariantParsed && (value->id == CSSValueNormal || value->id == CSSValueSmallCaps)) { >diff --git a/Source/WebCore/css/StyleSheetContents.cpp b/Source/WebCore/css/StyleSheetContents.cpp >index eafbd92..741cb64 100644 >--- a/Source/WebCore/css/StyleSheetContents.cpp >+++ b/Source/WebCore/css/StyleSheetContents.cpp >@@ -64,6 +64,7 @@ StyleSheetContents::StyleSheetContents(StyleRuleImport* ownerRule, const String& > , m_hasSyntacticallyValidCSSHeader(true) > , m_didLoadErrorOccur(false) > , m_usesRemUnits(false) >+ , m_usesStyleBasedEditability(false) > , m_isMutable(false) > , m_isInMemoryCache(false) > , m_parserContext(context) >@@ -83,6 +84,7 @@ StyleSheetContents::StyleSheetContents(const StyleSheetContents& o) > , m_hasSyntacticallyValidCSSHeader(o.m_hasSyntacticallyValidCSSHeader) > , m_didLoadErrorOccur(false) > , m_usesRemUnits(o.m_usesRemUnits) >+ , m_usesStyleBasedEditability(o.m_usesStyleBasedEditability) > , m_isMutable(false) > , m_isInMemoryCache(false) > , m_parserContext(o.m_parserContext) >diff --git a/Source/WebCore/css/StyleSheetContents.h b/Source/WebCore/css/StyleSheetContents.h >index 62a93d5..e14b07a 100644 >--- a/Source/WebCore/css/StyleSheetContents.h >+++ b/Source/WebCore/css/StyleSheetContents.h >@@ -91,7 +91,8 @@ public: > void parserAddNamespace(const AtomicString& prefix, const AtomicString& uri); > void parserAppendRule(PassRefPtr<StyleRuleBase>); > void parserSetEncodingFromCharsetRule(const String& encoding); >- void parserSetUsesRemUnits(bool b) { m_usesRemUnits = b; } >+ void parserSetUsesRemUnits() { m_usesRemUnits = true; } >+ void parserSetUsesStyleBasedEditability() { m_usesStyleBasedEditability = true; } > > void clearRules(); > >@@ -117,6 +118,7 @@ public: > StyleRuleBase* ruleAt(unsigned index) const; > > bool usesRemUnits() const { return m_usesRemUnits; } >+ bool usesStyleBasedEditability() const { return m_usesStyleBasedEditability; } > > unsigned estimatedSizeInBytes() const; > >@@ -159,6 +161,7 @@ private: > bool m_hasSyntacticallyValidCSSHeader : 1; > bool m_didLoadErrorOccur : 1; > bool m_usesRemUnits : 1; >+ bool m_usesStyleBasedEditability : 1; > bool m_isMutable : 1; > bool m_isInMemoryCache : 1; > >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index 6d322d2..3b7c71a 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -1746,8 +1746,14 @@ void Document::recalcStyle(Style::Change change) > > InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalculateStyle(*this); > >- if (m_elementSheet && m_elementSheet->contents().usesRemUnits()) >- m_styleSheetCollection.setUsesRemUnit(true); >+ if (m_elementSheet) { >+ // FIXME: We never reset these flags. >+ auto& contents = m_elementSheet->contents(); >+ if (contents.usesRemUnits()) >+ m_styleSheetCollection.setUsesRemUnit(true); >+ if (contents.usesStyleBasedEditability()) >+ m_styleSheetCollection.setUsesStyleBasedEditability(true); >+ } > > m_inStyleRecalc = true; > { >@@ -1807,7 +1813,7 @@ void Document::updateStyleIfNeeded() > if (m_optimizedStyleSheetUpdateTimer.isActive()) > styleResolverChanged(RecalcStyleIfNeeded); > >- if ((!m_pendingStyleRecalcShouldForce && !childNeedsStyleRecalc()) || inPageCache()) >+ if (!needsStyleRecalc()) > return; > > recalcStyle(Style::NoChange); >@@ -2682,9 +2688,13 @@ void Document::updateBaseURL() > // Element sheet is silly. It never contains anything. > ASSERT(!m_elementSheet->contents().ruleCount()); > bool usesRemUnits = m_elementSheet->contents().usesRemUnits(); >+ bool usesStyleBasedEditability = m_elementSheet->contents().usesStyleBasedEditability(); > m_elementSheet = CSSStyleSheet::createInline(*this, m_baseURL); > // FIXME: So we are not really the parser. The right fix is to eliminate the element sheet completely. >- m_elementSheet->contents().parserSetUsesRemUnits(usesRemUnits); >+ if (usesRemUnits) >+ m_elementSheet->contents().parserSetUsesRemUnits(); >+ if (usesStyleBasedEditability) >+ m_elementSheet->contents().parserSetUsesStyleBasedEditability(); > } > > if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) { >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 76fb1b7..d9ddea2 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -601,6 +601,7 @@ public: > > void recalcStyle(Style::Change = Style::NoChange); > WEBCORE_EXPORT void updateStyleIfNeeded(); >+ bool needsStyleRecalc() const { return !inPageCache() && (m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || m_optimizedStyleSheetUpdateTimer.isActive()); } > > WEBCORE_EXPORT void updateLayout(); > >diff --git a/Source/WebCore/dom/DocumentStyleSheetCollection.cpp b/Source/WebCore/dom/DocumentStyleSheetCollection.cpp >index 8ae31e9..736a507 100644 >--- a/Source/WebCore/dom/DocumentStyleSheetCollection.cpp >+++ b/Source/WebCore/dom/DocumentStyleSheetCollection.cpp >@@ -60,6 +60,7 @@ DocumentStyleSheetCollection::DocumentStyleSheetCollection(Document& document) > , m_usesFirstLineRules(false) > , m_usesFirstLetterRules(false) > , m_usesRemUnits(false) >+ , m_usesStyleBasedEditability(false) > { > } > >@@ -390,15 +391,6 @@ void DocumentStyleSheetCollection::analyzeStyleSheetChange(UpdateFlag updateFlag > requiresFullStyleRecalc = false; > } > >-static bool styleSheetsUseRemUnits(const Vector<RefPtr<CSSStyleSheet>>& sheets) >-{ >- for (unsigned i = 0; i < sheets.size(); ++i) { >- if (sheets[i]->contents().usesRemUnits()) >- return true; >- } >- return false; >-} >- > static void filterEnabledNonemptyCSSStyleSheets(Vector<RefPtr<CSSStyleSheet>>& result, const Vector<RefPtr<StyleSheet>>& sheets) > { > for (unsigned i = 0; i < sheets.size(); ++i) { >@@ -457,7 +449,12 @@ bool DocumentStyleSheetCollection::updateActiveStyleSheets(UpdateFlag updateFlag > m_activeAuthorStyleSheets.swap(activeCSSStyleSheets); > m_styleSheetsForStyleSheetList.swap(activeStyleSheets); > >- m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); >+ for (auto sheet: m_activeAuthorStyleSheets) { >+ if (sheet->contents().usesRemUnits()) >+ m_usesRemUnits = true; >+ if (sheet->contents().usesStyleBasedEditability()) >+ m_usesStyleBasedEditability = true; >+ } > m_pendingUpdateType = NoUpdate; > > return requiresFullStyleRecalc; >diff --git a/Source/WebCore/dom/DocumentStyleSheetCollection.h b/Source/WebCore/dom/DocumentStyleSheetCollection.h >index eede7bf..60fb783 100644 >--- a/Source/WebCore/dom/DocumentStyleSheetCollection.h >+++ b/Source/WebCore/dom/DocumentStyleSheetCollection.h >@@ -105,6 +105,8 @@ public: > bool usesFirstLetterRules() const { return m_usesFirstLetterRules; } > bool usesRemUnits() const { return m_usesRemUnits; } > void setUsesRemUnit(bool b) { m_usesRemUnits = b; } >+ bool usesStyleBasedEditability() { return m_usesStyleBasedEditability; } >+ void setUsesStyleBasedEditability(bool b) { m_usesStyleBasedEditability = b; } > > void combineCSSFeatureFlags(); > void resetCSSFeatureFlags(); >@@ -157,6 +159,7 @@ private: > bool m_usesFirstLineRules; > bool m_usesFirstLetterRules; > bool m_usesRemUnits; >+ bool m_usesStyleBasedEditability; > }; > > } >diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp >index ebf4618..2a53cdd 100644 >--- a/Source/WebCore/dom/Node.cpp >+++ b/Source/WebCore/dom/Node.cpp >@@ -555,15 +555,49 @@ void Node::inspect() > document().page()->inspectorController().inspect(this); > } > >-bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment treatment) const >+static inline bool determineEditabilityIndependentOfStyle(const Node& node, bool isEditable) > { >- if (!document().hasLivingRenderTree()) >- return false; >- if (document().frame() && document().frame()->page() && document().frame()->page()->isEditable() && !containingShadowRoot()) >+ if (!node.document().hasLivingRenderTree()) { >+ isEditable = false; > return true; >+ } > >- if (isPseudoElement()) >- return false; >+ Frame* frame = node.document().frame(); >+ if (frame) { >+ Page* page = frame->page(); >+ if (page->isEditable() && !node.isInShadowTree()) { >+ isEditable = true; >+ return true; >+ } >+ } >+ >+ if (node.isPseudoElement()) { >+ isEditable = false; >+ return true; >+ } >+ >+ return false; >+} >+ >+bool Node::isEditableIgnoringStyle() const >+{ >+ ASSERT(!document().styleSheetCollection().usesStyleBasedEditability()); >+ bool isEditable = false; >+ if (determineEditabilityIndependentOfStyle(*this, isEditable)) >+ return isEditable; >+ >+ for (const Node* node = this; node; node = node->parentNode()) { >+ if (node->isElementNode()) >+ return downcast<Element>(node)->matchesReadWritePseudoClass(); >+ } >+ return false; >+} >+ >+bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment treatment) const >+{ >+ bool isEditable = false; >+ if (determineEditabilityIndependentOfStyle(*this, isEditable)) >+ return isEditable; > > // Ideally we'd call ASSERT(!needsStyleRecalc()) here, but > // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion >diff --git a/Source/WebCore/dom/Node.h b/Source/WebCore/dom/Node.h >index dcce27a..f52b246 100644 >--- a/Source/WebCore/dom/Node.h >+++ b/Source/WebCore/dom/Node.h >@@ -363,6 +363,8 @@ public: > > WEBCORE_EXPORT void inspect(); > >+ bool isEditableIgnoringStyle() const; >+ > bool hasEditableStyle(EditableType editableType = ContentIsEditable, UserSelectAllTreatment treatment = UserSelectAllIsAlwaysNonEditable) const > { > switch (editableType) { >diff --git a/Source/WebCore/editing/htmlediting.cpp b/Source/WebCore/editing/htmlediting.cpp >index 23ec90b..e5224fa 100644 >--- a/Source/WebCore/editing/htmlediting.cpp >+++ b/Source/WebCore/editing/htmlediting.cpp >@@ -146,10 +146,17 @@ bool isEditablePosition(const Position& p, EditableType editableType, EUpdateSty > Node* node = p.containerNode(); > if (!node) > return false; >- if (updateStyle == UpdateStyle) >- node->document().updateStyleIfNeeded(); >- else >- ASSERT(updateStyle == DoNotUpdateStyle); >+ >+ Document& document = node->document(); >+ switch (updateStyle) { >+ case UpdateStyle: >+ if (document.needsStyleRecalc() && !document.styleSheetCollection().usesStyleBasedEditability() && editableType == ContentIsEditable) >+ return node->isEditableIgnoringStyle(); >+ document.updateStyleIfNeeded(); >+ break; >+ case DoNotUpdateStyle: >+ break; >+ } > > return node->hasEditableStyle(editableType); > }
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 129034
:
247316
|
247321
|
247323
|
247595
|
247596
|
247597