From b6281314042e40f15885107ca89ff40b63186743 Mon Sep 17 00:00:00 2001 From: Andrew Paprocki Date: Tue, 22 Nov 2011 00:21:18 -0500 Subject: [PATCH 01/31] Bug 660747 - Reverting YARR begin characters optimization. r=dmandelin --- js/src/yarr/YarrInterpreter.cpp | 39 +---- js/src/yarr/YarrInterpreter.h | 6 - js/src/yarr/YarrPattern.cpp | 242 -------------------------------- js/src/yarr/YarrPattern.h | 19 --- 4 files changed, 2 insertions(+), 304 deletions(-) diff --git a/js/src/yarr/YarrInterpreter.cpp b/js/src/yarr/YarrInterpreter.cpp index b85ddd74aa1..0d2bd225d90 100644 --- a/js/src/yarr/YarrInterpreter.cpp +++ b/js/src/yarr/YarrInterpreter.cpp @@ -1046,39 +1046,10 @@ public: return JSRegExpErrorNoMatch; } - void lookupForBeginChars() - { - int character; - bool firstSingleCharFound; - - while (true) { - if (input.isNotAvailableInput(2)) - return; - - firstSingleCharFound = false; - - character = input.readPair(); - - for (unsigned i = 0; i < pattern->m_beginChars.size(); ++i) { - BeginChar bc = pattern->m_beginChars[i]; - - if (!firstSingleCharFound && bc.value <= 0xFFFF) { - firstSingleCharFound = true; - character &= 0xFFFF; - } - - if ((character | bc.mask) == bc.value) - return; - } - - input.next(); - } - } - #define MATCH_NEXT() { ++context->term; goto matchAgain; } #define BACKTRACK() { --context->term; goto backtrack; } #define currentTerm() (disjunction->terms[context->term]) - JSRegExpResult matchDisjunction(ByteDisjunction* disjunction, DisjunctionContext* context, bool btrack = false, bool isBody = false) + JSRegExpResult matchDisjunction(ByteDisjunction* disjunction, DisjunctionContext* context, bool btrack = false) { if (!--remainingMatchCount) return JSRegExpErrorHitLimit; @@ -1086,9 +1057,6 @@ public: if (btrack) BACKTRACK(); - if (pattern->m_containsBeginChars && isBody) - lookupForBeginChars(); - context->matchBegin = input.getPos(); context->term = 0; @@ -1266,9 +1234,6 @@ public: input.next(); - if (pattern->m_containsBeginChars && isBody) - lookupForBeginChars(); - context->matchBegin = input.getPos(); if (currentTerm().alternative.onceThrough) @@ -1397,7 +1362,7 @@ public: DisjunctionContext* context = allocDisjunctionContext(pattern->m_body.get()); - JSRegExpResult result = matchDisjunction(pattern->m_body.get(), context, false, true); + JSRegExpResult result = matchDisjunction(pattern->m_body.get(), context, false); if (result == JSRegExpMatch) { output[0] = context->matchBegin; output[1] = context->matchEnd; diff --git a/js/src/yarr/YarrInterpreter.h b/js/src/yarr/YarrInterpreter.h index c28c3fa66d6..37ad8d60a9c 100644 --- a/js/src/yarr/YarrInterpreter.h +++ b/js/src/yarr/YarrInterpreter.h @@ -335,7 +335,6 @@ public: : m_body(body) , m_ignoreCase(pattern.m_ignoreCase) , m_multiline(pattern.m_multiline) - , m_containsBeginChars(pattern.m_containsBeginChars) , m_allocator(allocator) { newlineCharacterClass = pattern.newlineCharacterClass(); @@ -347,8 +346,6 @@ public: // array, so that it won't delete them on destruction. We'll // take responsibility for that. pattern.m_userCharacterClasses.clear(); - - m_beginChars.append(pattern.m_beginChars); } ~BytecodePattern() @@ -360,7 +357,6 @@ public: OwnPtr m_body; bool m_ignoreCase; bool m_multiline; - bool m_containsBeginChars; // Each BytecodePattern is associated with a RegExp, each RegExp is associated // with a JSGlobalData. Cache a pointer to out JSGlobalData's m_regExpAllocator. BumpPointerAllocator* m_allocator; @@ -368,8 +364,6 @@ public: CharacterClass* newlineCharacterClass; CharacterClass* wordcharCharacterClass; - Vector m_beginChars; - private: Vector m_allParenthesesInfo; Vector m_userCharacterClasses; diff --git a/js/src/yarr/YarrPattern.cpp b/js/src/yarr/YarrPattern.cpp index ca5106eacf6..ae2882f057a 100644 --- a/js/src/yarr/YarrPattern.cpp +++ b/js/src/yarr/YarrPattern.cpp @@ -242,117 +242,11 @@ private: Vector m_rangesUnicode; }; -struct BeginCharHelper { - BeginCharHelper(Vector* beginChars, bool isCaseInsensitive = false) - : m_beginChars(beginChars) - , m_isCaseInsensitive(isCaseInsensitive) - {} - - void addBeginChar(BeginChar beginChar, Vector* hotTerms, QuantifierType quantityType, unsigned quantityCount) - { - if (quantityType == QuantifierFixedCount && quantityCount > 1) { - // We duplicate the first found character if the quantity of the term is more than one. eg.: /a{3}/ - beginChar.value |= beginChar.value << 16; - beginChar.mask |= beginChar.mask << 16; - addCharacter(beginChar); - } else if (quantityType == QuantifierFixedCount && quantityCount == 1 && hotTerms->size()) - // In case of characters with fixed quantifier we should check the next character as well. - linkHotTerms(beginChar, hotTerms); - else - // In case of greedy matching the next character checking is unnecessary therefore we just store - // the first character. - addCharacter(beginChar); - } - - // Merge two following BeginChars in the vector to reduce the number of character checks. - void merge(unsigned size) - { - for (unsigned i = 0; i < size; i++) { - BeginChar* curr = &m_beginChars->at(i); - BeginChar* next = &m_beginChars->at(i + 1); - - // If the current and the next size of value is different we should skip the merge process - // because the 16bit and 32bit values are unmergable. - if (curr->value <= 0xFFFF && next->value > 0xFFFF) - continue; - - unsigned diff = curr->value ^ next->value; - - curr->mask |= diff; - curr->value |= curr->mask; - - m_beginChars->remove(i + 1); - size--; - } - } - -private: - void addCharacter(BeginChar beginChar) - { - unsigned pos = 0; - unsigned range = m_beginChars->size(); - - // binary chop, find position to insert char. - while (range) { - unsigned index = range >> 1; - - int val = m_beginChars->at(pos+index).value - beginChar.value; - if (!val) - return; - if (val < 0) - range = index; - else { - pos += (index+1); - range -= (index+1); - } - } - - if (pos == m_beginChars->size()) - m_beginChars->append(beginChar); - else - m_beginChars->insert(pos, beginChar); - } - - // Create BeginChar objects by appending each terms from a hotTerms vector to an existing BeginChar object. - void linkHotTerms(BeginChar beginChar, Vector* hotTerms) - { - for (unsigned i = 0; i < hotTerms->size(); i++) { - PatternTerm hotTerm = hotTerms->at(i).term; - ASSERT(hotTerm.type == PatternTerm::TypePatternCharacter); - - UChar characterNext = hotTerm.patternCharacter; - - // Append a character to an existing BeginChar object. - if (characterNext <= 0x7f) { - unsigned mask = 0; - - if (m_isCaseInsensitive && isASCIIAlpha(characterNext)) { - mask = 32; - characterNext = toASCIILower(characterNext); - } - - addCharacter(BeginChar(beginChar.value | (characterNext << 16), beginChar.mask | (mask << 16))); - } else { - UChar upper, lower; - if (m_isCaseInsensitive && ((upper = Unicode::toUpper(characterNext)) != (lower = Unicode::toLower(characterNext)))) { - addCharacter(BeginChar(beginChar.value | (upper << 16), beginChar.mask)); - addCharacter(BeginChar(beginChar.value | (lower << 16), beginChar.mask)); - } else - addCharacter(BeginChar(beginChar.value | (characterNext << 16), beginChar.mask)); - } - } - } - - Vector* m_beginChars; - bool m_isCaseInsensitive; -}; - class YarrPatternConstructor { public: YarrPatternConstructor(YarrPattern& pattern) : m_pattern(pattern) , m_characterClassConstructor(pattern.m_ignoreCase) - , m_beginCharHelper(&pattern.m_beginChars, pattern.m_ignoreCase) , m_invertParentheticalAssertion(false) { m_pattern.m_body = js::OffTheBooks::new_(); @@ -789,144 +683,10 @@ public: } } - // This function collects the terms which are potentially matching the first number of depth characters in the result. - // If this function returns false then it found at least one term which makes the beginning character - // look-up optimization inefficient. - bool setupDisjunctionBeginTerms(PatternDisjunction* disjunction, Vector* beginTerms, unsigned depth) - { - for (unsigned alt = 0; alt < disjunction->m_alternatives.size(); ++alt) { - PatternAlternative* alternative = disjunction->m_alternatives[alt]; - - if (!setupAlternativeBeginTerms(alternative, beginTerms, 0, depth)) - return false; - } - - return true; - } - - bool setupAlternativeBeginTerms(PatternAlternative* alternative, Vector* beginTerms, unsigned termIndex, unsigned depth) - { - bool checkNext = true; - unsigned numTerms = alternative->m_terms.size(); - - while (checkNext && termIndex < numTerms) { - PatternTerm term = alternative->m_terms[termIndex]; - checkNext = false; - - switch (term.type) { - case PatternTerm::TypeAssertionBOL: - case PatternTerm::TypeAssertionEOL: - case PatternTerm::TypeAssertionWordBoundary: - return false; - - case PatternTerm::TypeBackReference: - case PatternTerm::TypeForwardReference: - return false; - - case PatternTerm::TypePatternCharacter: - if (termIndex != numTerms - 1) { - beginTerms->append(TermChain(term)); - termIndex++; - checkNext = true; - } else if (term.quantityType == QuantifierFixedCount) { - beginTerms->append(TermChain(term)); - if (depth < 2 && termIndex < numTerms - 1 && term.quantityCount == 1) - if (!setupAlternativeBeginTerms(alternative, &beginTerms->last().hotTerms, termIndex + 1, depth + 1)) - return false; - } - - break; - - case PatternTerm::TypeCharacterClass: - return false; - - case PatternTerm::TypeParentheticalAssertion: - if (term.invert()) - return false; - - case PatternTerm::TypeParenthesesSubpattern: - if (term.quantityType != QuantifierFixedCount) { - if (termIndex == numTerms - 1) - break; - - termIndex++; - checkNext = true; - } - - if (!setupDisjunctionBeginTerms(term.parentheses.disjunction, beginTerms, depth)) - return false; - - break; - } - } - - return true; - } - - void setupBeginChars() - { - Vector beginTerms; - bool containsFixedCharacter = false; - - if ((!m_pattern.m_body->m_hasFixedSize || m_pattern.m_body->m_alternatives.size() > 1) - && setupDisjunctionBeginTerms(m_pattern.m_body, &beginTerms, 0)) { - unsigned size = beginTerms.size(); - - // If we haven't collected any terms we should abort the preparation of beginning character look-up optimization. - if (!size) - return; - - m_pattern.m_containsBeginChars = true; - - for (unsigned i = 0; i < size; i++) { - PatternTerm term = beginTerms[i].term; - - // We have just collected PatternCharacter terms, other terms are not allowed. - ASSERT(term.type == PatternTerm::TypePatternCharacter); - - if (term.quantityType == QuantifierFixedCount) - containsFixedCharacter = true; - - UChar character = term.patternCharacter; - unsigned mask = 0; - - if (character <= 0x7f) { - if (m_pattern.m_ignoreCase && isASCIIAlpha(character)) { - mask = 32; - character = toASCIILower(character); - } - - m_beginCharHelper.addBeginChar(BeginChar(character, mask), &beginTerms[i].hotTerms, term.quantityType, term.quantityCount); - } else { - UChar upper, lower; - if (m_pattern.m_ignoreCase && ((upper = Unicode::toUpper(character)) != (lower = Unicode::toLower(character)))) { - m_beginCharHelper.addBeginChar(BeginChar(upper, mask), &beginTerms[i].hotTerms, term.quantityType, term.quantityCount); - m_beginCharHelper.addBeginChar(BeginChar(lower, mask), &beginTerms[i].hotTerms, term.quantityType, term.quantityCount); - } else - m_beginCharHelper.addBeginChar(BeginChar(character, mask), &beginTerms[i].hotTerms, term.quantityType, term.quantityCount); - } - } - - // If the pattern doesn't contain terms with fixed quantifiers then the beginning character look-up optimization is inefficient. - if (!containsFixedCharacter) { - m_pattern.m_containsBeginChars = false; - return; - } - - size = m_pattern.m_beginChars.size(); - - if (size > 2) - m_beginCharHelper.merge(size - 1); - else if (size <= 1) - m_pattern.m_containsBeginChars = false; - } - } - private: YarrPattern& m_pattern; PatternAlternative* m_alternative; CharacterClassConstructor m_characterClassConstructor; - BeginCharHelper m_beginCharHelper; bool m_invertCharacterClass; bool m_invertParentheticalAssertion; }; @@ -959,7 +719,6 @@ ErrorCode YarrPattern::compile(const UString& patternString) constructor.optimizeBOL(); constructor.setupOffsets(); - constructor.setupBeginChars(); return NoError; } @@ -968,7 +727,6 @@ YarrPattern::YarrPattern(const UString& pattern, bool ignoreCase, bool multiline : m_ignoreCase(ignoreCase) , m_multiline(multiline) , m_containsBackreferences(false) - , m_containsBeginChars(false) , m_containsBOL(false) , m_numSubpatterns(0) , m_maxBackReference(0) diff --git a/js/src/yarr/YarrPattern.h b/js/src/yarr/YarrPattern.h index 38ae10fcf28..28c12c85e0e 100644 --- a/js/src/yarr/YarrPattern.h +++ b/js/src/yarr/YarrPattern.h @@ -332,21 +332,6 @@ struct TermChain { Vector hotTerms; }; -struct BeginChar { - BeginChar() - : value(0) - , mask(0) - {} - - BeginChar(unsigned value, unsigned mask) - : value(value) - , mask(mask) - {} - - unsigned value; - unsigned mask; -}; - struct YarrPattern { YarrPattern(const UString& pattern, bool ignoreCase, bool multiline, ErrorCode* error); @@ -362,7 +347,6 @@ struct YarrPattern { m_maxBackReference = 0; m_containsBackreferences = false; - m_containsBeginChars = false; m_containsBOL = false; newlineCached = 0; @@ -377,7 +361,6 @@ struct YarrPattern { m_disjunctions.clear(); deleteAllValues(m_userCharacterClasses); m_userCharacterClasses.clear(); - m_beginChars.clear(); } bool containsIllegalBackReference() @@ -431,14 +414,12 @@ struct YarrPattern { bool m_ignoreCase : 1; bool m_multiline : 1; bool m_containsBackreferences : 1; - bool m_containsBeginChars : 1; bool m_containsBOL : 1; unsigned m_numSubpatterns; unsigned m_maxBackReference; PatternDisjunction* m_body; Vector m_disjunctions; Vector m_userCharacterClasses; - Vector m_beginChars; private: ErrorCode compile(const UString& patternString); From d0148db44a74f09ae7718483a1337206b772c5d9 Mon Sep 17 00:00:00 2001 From: Atul Aggarwal Date: Sun, 6 Nov 2011 20:22:02 +0530 Subject: [PATCH 02/31] Bug 686775 - Matching external API version of StripWhitespace with internal version by adding stripping of \b. r=bsmedberg --- xpcom/glue/nsStringAPI.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xpcom/glue/nsStringAPI.h b/xpcom/glue/nsStringAPI.h index 272c9eb3766..95987337ed7 100644 --- a/xpcom/glue/nsStringAPI.h +++ b/xpcom/glue/nsStringAPI.h @@ -199,7 +199,7 @@ public: /** * Strip whitespace characters from the string. */ - NS_HIDDEN_(void) StripWhitespace() { StripChars(" \t\n\r"); } + NS_HIDDEN_(void) StripWhitespace() { StripChars("\b\t\r\n "); } NS_HIDDEN_(void) Trim(const char *aSet, bool aLeading = true, bool aTrailing = true); @@ -542,7 +542,7 @@ public: /** * Strip whitespace characters from the string. */ - NS_HIDDEN_(void) StripWhitespace() { StripChars(" \t\r\n"); } + NS_HIDDEN_(void) StripWhitespace() { StripChars("\b\t\r\n "); } NS_HIDDEN_(void) Trim(const char *aSet, bool aLeading = true, bool aTrailing = true); From aef1a91235919e9a11f6a943237b0dfd37e74ee1 Mon Sep 17 00:00:00 2001 From: aceman Date: Sat, 26 Nov 2011 14:07:52 +0100 Subject: [PATCH 03/31] Bug 502492 - Change about:config text box label to Search:. r=dtownsend ui-r=limi --- toolkit/components/viewconfig/content/config.xul | 6 +++--- toolkit/locales/en-US/chrome/global/config.dtd | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/toolkit/components/viewconfig/content/config.xul b/toolkit/components/viewconfig/content/config.xul index 3c75253930d..c73fec0e6ed 100644 --- a/toolkit/components/viewconfig/content/config.xul +++ b/toolkit/components/viewconfig/content/config.xul @@ -81,7 +81,7 @@ - + @@ -101,12 +101,12 @@ - - + diff --git a/toolkit/locales/en-US/chrome/global/config.dtd b/toolkit/locales/en-US/chrome/global/config.dtd index eced809d04e..b79c6fe8b1c 100644 --- a/toolkit/locales/en-US/chrome/global/config.dtd +++ b/toolkit/locales/en-US/chrome/global/config.dtd @@ -43,9 +43,9 @@ - - - + + + From aa3f6fa9ee281f1bed9501b8d59e11452d3b2e3b Mon Sep 17 00:00:00 2001 From: Oleg Romashin Date: Sat, 26 Nov 2011 14:08:27 +0100 Subject: [PATCH 04/31] Bug 704735 - _state is not initialized in Android-MessagePumpForUI ctor. r=cjones --- ipc/chromium/src/base/message_pump_android.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ipc/chromium/src/base/message_pump_android.cc b/ipc/chromium/src/base/message_pump_android.cc index ca1eb17fca6..0c1ff0e237a 100644 --- a/ipc/chromium/src/base/message_pump_android.cc +++ b/ipc/chromium/src/base/message_pump_android.cc @@ -20,7 +20,8 @@ void NotifyEvent(); namespace base { MessagePumpForUI::MessagePumpForUI() - : pump(*this) + : state_(NULL) + , pump(*this) { } From 84ecf7a194f01d28c355467192de73768fc04488 Mon Sep 17 00:00:00 2001 From: Tom Schuster Date: Sat, 26 Nov 2011 18:51:06 +0100 Subject: [PATCH 05/31] Bug 554691 - Remove dead js_RegisterCloseableIterator definiton from header file. r=Ms2ger --HG-- extra : rebase_source : b8b5fe8b03ded91b37560d045d4fe5d2da7f7925 --- js/src/jsgc.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/src/jsgc.h b/js/src/jsgc.h index b56f1a85cb5..190cf0cd8a8 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -1312,9 +1312,6 @@ typedef struct JSPtrTable { void **array; } JSPtrTable; -extern JSBool -js_RegisterCloseableIterator(JSContext *cx, JSObject *obj); - extern JSBool js_LockGCThingRT(JSRuntime *rt, void *thing); From 9e076a40095efa40cef831bff8e6e1ac3786dbb9 Mon Sep 17 00:00:00 2001 From: Tom Schuster Date: Sat, 26 Nov 2011 18:52:27 +0100 Subject: [PATCH 06/31] Bug 647628 - Remove SKIP_POP_AFTER_SET. r=bhackett --HG-- extra : rebase_source : 1332f0176be3db638d112392b5265a12eeee5ec2 --- js/src/jsinterp.cpp | 70 ++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 46 deletions(-) diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 9b5dfbb747e..287e58208b9 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -2382,38 +2382,6 @@ END_CASE(JSOP_PICK) } \ JS_END_MACRO -/* - * Skip the JSOP_POP typically found after a JSOP_SET* opcode, where oplen is - * the constant length of the SET opcode sequence, and spdec is the constant - * by which to decrease the stack pointer to pop all of the SET op's operands. - * - * NB: unlike macros that could conceivably be replaced by functions (ignoring - * goto error), where a call should not have to be braced in order to expand - * correctly (e.g., in if (cond) FOO(); else BAR()), these three macros lack - * JS_{BEGIN,END}_MACRO brackets. They are also indented so as to align with - * nearby opcode code. - */ -#define SKIP_POP_AFTER_SET(oplen,spdec) \ - if (regs.pc[oplen] == JSOP_POP) { \ - regs.sp -= spdec; \ - regs.pc += oplen + JSOP_POP_LENGTH; \ - op = (JSOp) *regs.pc; \ - DO_OP(); \ - } - -#define END_SET_CASE(OP) \ - SKIP_POP_AFTER_SET(OP##_LENGTH, 1); \ - END_CASE(OP) - -#define END_SET_CASE_STORE_RVAL(OP,spdec) \ - SKIP_POP_AFTER_SET(OP##_LENGTH, spdec); \ - { \ - Value *newsp = regs.sp - ((spdec) - 1); \ - newsp[-1] = regs.sp[-1]; \ - regs.sp = newsp; \ - } \ - END_CASE(OP) - BEGIN_CASE(JSOP_SETCONST) { JSAtom *atom; @@ -2426,7 +2394,7 @@ BEGIN_CASE(JSOP_SETCONST) goto error; } } -END_SET_CASE(JSOP_SETCONST); +END_CASE(JSOP_SETCONST); #if JS_HAS_DESTRUCTURING BEGIN_CASE(JSOP_ENUMCONSTELEM) @@ -2935,17 +2903,23 @@ END_CASE(JSOP_DELELEM) BEGIN_CASE(JSOP_TOID) { /* + * Increment or decrement requires use to lookup the same property twice, but we need to avoid + * the oberservable stringification the second time. * There must be an object value below the id, which will not be popped * but is necessary in interning the id for XML. */ - JSObject *obj; - FETCH_OBJECT(cx, -2, obj); - - jsid id; - FETCH_ELEMENT_ID(obj, -1, id); - - if (!regs.sp[-1].isInt32()) + + Value &idval = regs.sp[-1]; + if (!idval.isInt32()) { + JSObject *obj; + FETCH_OBJECT(cx, -2, obj); + + jsid dummy; + if (!js_InternNonIntElementId(cx, obj, idval, &dummy, &idval)) + goto error; + TypeScript::MonitorUnknown(cx, script, regs.pc); + } } END_CASE(JSOP_TOID) @@ -3176,7 +3150,6 @@ BEGIN_CASE(JSOP_LOCALINC) if (JS_LIKELY(vp->isInt32() && CanIncDecWithoutOverflow(tmp = vp->toInt32()))) { vp->getInt32Ref() = tmp + incr; JS_ASSERT(JSOP_INCARG_LENGTH == js_CodeSpec[op].length); - SKIP_POP_AFTER_SET(JSOP_INCARG_LENGTH, 0); PUSH_INT32(tmp + incr2); } else { PUSH_COPY(*vp); @@ -3549,8 +3522,11 @@ BEGIN_CASE(JSOP_SETMETHOD) goto error; } } while (0); + + regs.sp[-2] = regs.sp[-1]; + regs.sp--; } -END_SET_CASE_STORE_RVAL(JSOP_SETPROP, 2); +END_CASE(JSOP_SETPROP) BEGIN_CASE(JSOP_GETELEM) { @@ -3695,9 +3671,11 @@ BEGIN_CASE(JSOP_SETELEM) rval = regs.sp[-1]; if (!obj->setGeneric(cx, id, &rval, script->strictModeCode)) goto error; - end_setelem:; + end_setelem: + regs.sp[-3] = regs.sp[-1]; + regs.sp -= 2; } -END_SET_CASE_STORE_RVAL(JSOP_SETELEM, 3) +END_CASE(JSOP_SETELEM) BEGIN_CASE(JSOP_ENUMELEM) { @@ -4213,7 +4191,7 @@ BEGIN_CASE(JSOP_SETARG) JS_ASSERT(slot < regs.fp()->numFormalArgs()); argv[slot] = regs.sp[-1]; } -END_SET_CASE(JSOP_SETARG) +END_CASE(JSOP_SETARG) BEGIN_CASE(JSOP_GETLOCAL) { @@ -4249,7 +4227,7 @@ BEGIN_CASE(JSOP_SETLOCAL) JS_ASSERT(slot < script->nslots); regs.fp()->slots()[slot] = regs.sp[-1]; } -END_SET_CASE(JSOP_SETLOCAL) +END_CASE(JSOP_SETLOCAL) BEGIN_CASE(JSOP_GETFCSLOT) BEGIN_CASE(JSOP_CALLFCSLOT) From e1300ce0f14ab0189030e4472d43ab0cb9529d77 Mon Sep 17 00:00:00 2001 From: Bernd Date: Thu, 27 Oct 2011 09:58:44 -0400 Subject: [PATCH 07/31] bug 460637 - the group cellmaps need to set the damageArea relative to the entire table, patch by Mats Palmgren, Randell Jesup and Bernd, r=mats, bernd --- layout/reftests/bugs/reftest.list | 2 +- layout/tables/crashtests/460637-1.xhtml | 41 +++++ layout/tables/crashtests/460637-2.xhtml | 24 +++ layout/tables/crashtests/460637-3.xhtml | 26 +++ layout/tables/crashtests/crashtests.list | 3 + layout/tables/nsCellMap.cpp | 212 ++++++++++++++--------- layout/tables/nsCellMap.h | 15 +- layout/tables/nsTableCellFrame.cpp | 2 +- layout/tables/nsTableColFrame.cpp | 2 +- layout/tables/nsTableColGroupFrame.cpp | 2 +- layout/tables/nsTableFrame.cpp | 168 +++++++++++------- layout/tables/nsTableFrame.h | 6 +- layout/tables/nsTableRowFrame.cpp | 2 +- layout/tables/nsTableRowGroupFrame.cpp | 2 +- 14 files changed, 346 insertions(+), 161 deletions(-) create mode 100644 layout/tables/crashtests/460637-1.xhtml create mode 100644 layout/tables/crashtests/460637-2.xhtml create mode 100644 layout/tables/crashtests/460637-3.xhtml diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index 2dce0ebcaf5..d9dee3d69dd 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -301,7 +301,7 @@ fails-if(Android) != 192767-17.xul 192767-37.xul == 283686-3.html about:blank == 289384-1.xhtml 289384-ref.xhtml fails-if(Android) random-if(d2d) HTTP == 289480.html#top 289480-ref.html # basically-verbatim acid2 test, HTTP for a 404 page -- bug 578114 for the d2d failures -asserts(1) == 290129-1.html 290129-1-ref.html # bug 315549/460637 +== 290129-1.html 290129-1-ref.html == 291078-1.html 291078-1-ref.html == 291078-2.html 291078-2-ref.html == 291262-1.html 291262-1-ref.html diff --git a/layout/tables/crashtests/460637-1.xhtml b/layout/tables/crashtests/460637-1.xhtml new file mode 100644 index 00000000000..1063730e329 --- /dev/null +++ b/layout/tables/crashtests/460637-1.xhtml @@ -0,0 +1,41 @@ + + + + + + diff --git a/layout/tables/crashtests/460637-2.xhtml b/layout/tables/crashtests/460637-2.xhtml new file mode 100644 index 00000000000..2bdaee93d16 --- /dev/null +++ b/layout/tables/crashtests/460637-2.xhtml @@ -0,0 +1,24 @@ + + + +
+ diff --git a/layout/tables/crashtests/460637-3.xhtml b/layout/tables/crashtests/460637-3.xhtml new file mode 100644 index 00000000000..2d73a1e7185 --- /dev/null +++ b/layout/tables/crashtests/460637-3.xhtml @@ -0,0 +1,26 @@ + + + + +
+ diff --git a/layout/tables/crashtests/crashtests.list b/layout/tables/crashtests/crashtests.list index a0f82cbcb0d..c3934945ce1 100644 --- a/layout/tables/crashtests/crashtests.list +++ b/layout/tables/crashtests/crashtests.list @@ -96,6 +96,9 @@ load 448988-1.xhtml load 450311-1.html load 456041.html load 457115.html +load 460637-1.xhtml +load 460637-2.xhtml +load 460637-3.xhtml load 467141-1.html load 488388-1.html load 512749-1.html diff --git a/layout/tables/nsCellMap.cpp b/layout/tables/nsCellMap.cpp index ead2d23cf24..6798989776a 100644 --- a/layout/tables/nsCellMap.cpp +++ b/layout/tables/nsCellMap.cpp @@ -41,6 +41,24 @@ #include "nsTableCellFrame.h" #include "nsTableRowGroupFrame.h" + +static void +SetDamageArea(PRInt32 aXOrigin, + PRInt32 aYOrigin, + PRInt32 aWidth, + PRInt32 aHeight, + nsRect& aDamageArea) +{ + NS_ASSERTION(aXOrigin >= 0, "negative col index"); + NS_ASSERTION(aYOrigin >= 0, "negative row index"); + NS_ASSERTION(aWidth >= 0, "negative horizontal damage"); + NS_ASSERTION(aHeight >= 0, "negative vertical damage"); + aDamageArea.x = aXOrigin; + aDamageArea.y = aYOrigin; + aDamageArea.width = aWidth; + aDamageArea.height = aHeight; +} + // Empty static array used for SafeElementAt() calls on mRows. static nsCellMap::CellDataArray * sEmptyRow; @@ -479,13 +497,13 @@ nsTableCellMap::InsertRows(nsTableRowGroupFrame* aParent, if ((numNewRows <= 0) || (aFirstRowIndex < 0)) ABORT0(); PRInt32 rowIndex = aFirstRowIndex; + PRInt32 rgStartRowIndex = 0; nsCellMap* cellMap = mFirstMap; while (cellMap) { nsTableRowGroupFrame* rg = cellMap->GetRowGroup(); if (rg == aParent) { - cellMap->InsertRows(*this, aRows, rowIndex, aConsiderSpans, aDamageArea); - aDamageArea.y = NS_MIN(aFirstRowIndex, aDamageArea.y); - aDamageArea.height = NS_MAX(0, GetRowCount() - aDamageArea.y); + cellMap->InsertRows(*this, aRows, rowIndex, aConsiderSpans, + rgStartRowIndex, aDamageArea); #ifdef DEBUG_TABLE_CELLMAP Dump("after InsertRows"); #endif @@ -507,7 +525,9 @@ nsTableCellMap::InsertRows(nsTableRowGroupFrame* aParent, } return; } - rowIndex -= cellMap->GetRowCount(); + PRInt32 rowCount = cellMap->GetRowCount(); + rgStartRowIndex += rowCount; + rowIndex -= rowCount; cellMap = cellMap->GetNextSibling(); } @@ -521,13 +541,13 @@ nsTableCellMap::RemoveRows(PRInt32 aFirstRowIndex, nsRect& aDamageArea) { PRInt32 rowIndex = aFirstRowIndex; + PRInt32 rgStartRowIndex = 0; nsCellMap* cellMap = mFirstMap; while (cellMap) { - if (cellMap->GetRowCount() > rowIndex) { - cellMap->RemoveRows(*this, rowIndex, aNumRowsToRemove, aConsiderSpans, aDamageArea); - nsTableRowGroupFrame* rg = cellMap->GetRowGroup(); - aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0; - aDamageArea.height = NS_MAX(0, GetRowCount() - aFirstRowIndex); + PRInt32 rowCount = cellMap->GetRowCount(); + if (rowCount > rowIndex) { + cellMap->RemoveRows(*this, rowIndex, aNumRowsToRemove, aConsiderSpans, + rgStartRowIndex, aDamageArea); if (mBCInfo) { for (PRInt32 rowX = aFirstRowIndex + aNumRowsToRemove - 1; rowX >= aFirstRowIndex; rowX--) { if (PRUint32(rowX) < mBCInfo->mRightBorders.Length()) { @@ -537,7 +557,8 @@ nsTableCellMap::RemoveRows(PRInt32 aFirstRowIndex, } break; } - rowIndex -= cellMap->GetRowCount(); + rgStartRowIndex += rowCount; + rowIndex -= rowCount; cellMap = cellMap->GetNextSibling(); } #ifdef DEBUG_TABLE_CELLMAP @@ -561,15 +582,18 @@ nsTableCellMap::AppendCell(nsTableCellFrame& aCellFrame, CellData* result = nsnull; PRInt32 rowIndex = aRowIndex; + PRInt32 rgStartRowIndex = 0; nsCellMap* cellMap = mFirstMap; while (cellMap) { if (cellMap->GetRowGroup() == rgFrame) { - result = cellMap->AppendCell(*this, &aCellFrame, rowIndex, aRebuildIfNecessary, aDamageArea); - nsTableRowGroupFrame* rg = cellMap->GetRowGroup(); - aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0; + result = cellMap->AppendCell(*this, &aCellFrame, rowIndex, + aRebuildIfNecessary, rgStartRowIndex, + aDamageArea); break; } - rowIndex -= cellMap->GetRowCount(); + PRInt32 rowCount = cellMap->GetRowCount(); + rgStartRowIndex += rowCount; + rowIndex -= rowCount; cellMap = cellMap->GetNextSibling(); } #ifdef DEBUG_TABLE_CELLMAP @@ -586,16 +610,17 @@ nsTableCellMap::InsertCells(nsTArray& aCellFrames, nsRect& aDamageArea) { PRInt32 rowIndex = aRowIndex; + PRInt32 rgStartRowIndex = 0; nsCellMap* cellMap = mFirstMap; while (cellMap) { - if (cellMap->GetRowCount() > rowIndex) { - cellMap->InsertCells(*this, aCellFrames, rowIndex, aColIndexBefore, aDamageArea); - nsTableRowGroupFrame* rg = cellMap->GetRowGroup(); - aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0; - aDamageArea.width = NS_MAX(0, GetColCount() - aColIndexBefore - 1); + PRInt32 rowCount = cellMap->GetRowCount(); + if (rowCount > rowIndex) { + cellMap->InsertCells(*this, aCellFrames, rowIndex, aColIndexBefore, + rgStartRowIndex, aDamageArea); break; } - rowIndex -= cellMap->GetRowCount(); + rgStartRowIndex += rowCount; + rowIndex -= rowCount; cellMap = cellMap->GetNextSibling(); } #ifdef DEBUG_TABLE_CELLMAP @@ -613,21 +638,20 @@ nsTableCellMap::RemoveCell(nsTableCellFrame* aCellFrame, NS_ASSERTION(aCellFrame == (nsTableCellFrame *)aCellFrame->GetFirstInFlow(), "invalid call on continuing frame"); PRInt32 rowIndex = aRowIndex; + PRInt32 rgStartRowIndex = 0; nsCellMap* cellMap = mFirstMap; while (cellMap) { - if (cellMap->GetRowCount() > rowIndex) { - cellMap->RemoveCell(*this, aCellFrame, rowIndex, aDamageArea); - nsTableRowGroupFrame* rg = cellMap->GetRowGroup(); - aDamageArea.y += (rg) ? rg->GetStartRowIndex() : 0; - PRInt32 colIndex; - aCellFrame->GetColIndex(colIndex); - aDamageArea.width = NS_MAX(0, GetColCount() - colIndex - 1); + PRInt32 rowCount = cellMap->GetRowCount(); + if (rowCount > rowIndex) { + cellMap->RemoveCell(*this, aCellFrame, rowIndex, rgStartRowIndex, + aDamageArea); #ifdef DEBUG_TABLE_CELLMAP Dump("after RemoveCell"); #endif return; } - rowIndex -= cellMap->GetRowCount(); + rgStartRowIndex += rowCount; + rowIndex -= rowCount; cellMap = cellMap->GetNextSibling(); } // if we reach this point - the cell did not get removed, the caller of this routine @@ -637,19 +661,6 @@ nsTableCellMap::RemoveCell(nsTableCellFrame* aCellFrame, NS_ERROR("nsTableCellMap::RemoveCell - could not remove cell"); } -void -SetDamageArea(PRInt32 aXOrigin, - PRInt32 aYOrigin, - PRInt32 aWidth, - PRInt32 aHeight, - nsRect& aDamageArea) -{ - aDamageArea.x = aXOrigin; - aDamageArea.y = aYOrigin; - aDamageArea.width = NS_MAX(1, aWidth); - aDamageArea.height = NS_MAX(1, aHeight); -} - void nsTableCellMap::RebuildConsideringCells(nsCellMap* aCellMap, nsTArray* aCellFrames, @@ -664,11 +675,12 @@ nsTableCellMap::RebuildConsideringCells(nsCellMap* aCellMap, PRInt32 rowCount = 0; while (cellMap) { if (cellMap == aCellMap) { - cellMap->RebuildConsideringCells(*this, numOrigCols, aCellFrames, aRowIndex, aColIndex, aInsert, aDamageArea); - + cellMap->RebuildConsideringCells(*this, numOrigCols, aCellFrames, + aRowIndex, aColIndex, aInsert); } else { - cellMap->RebuildConsideringCells(*this, numOrigCols, nsnull, -1, 0, false, aDamageArea); + cellMap->RebuildConsideringCells(*this, numOrigCols, nsnull, -1, 0, + false); } rowCount += cellMap->GetRowCount(); cellMap = cellMap->GetNextSibling(); @@ -692,10 +704,12 @@ nsTableCellMap::RebuildConsideringRows(nsCellMap* aCellMap, PRInt32 rowCount = 0; while (cellMap) { if (cellMap == aCellMap) { - cellMap->RebuildConsideringRows(*this, aStartRowIndex, aRowsToInsert, aNumRowsToRemove, aDamageArea); + cellMap->RebuildConsideringRows(*this, aStartRowIndex, aRowsToInsert, + aNumRowsToRemove); } else { - cellMap->RebuildConsideringCells(*this, numOrigCols, nsnull, -1, 0, false, aDamageArea); + cellMap->RebuildConsideringCells(*this, numOrigCols, nsnull, -1, 0, + false); } rowCount += cellMap->GetRowCount(); cellMap = cellMap->GetNextSibling(); @@ -1015,7 +1029,9 @@ nsTableCellMap::SetBCBorderEdge(mozilla::css::Side aSide, PRInt32 numRgRows = aCellMap.GetRowCount(); if (yPos < numRgRows) { // add a dead cell data nsRect damageArea; - cellData = (BCCellData*)aCellMap.AppendCell(*this, nsnull, rgYPos, false, damageArea); if (!cellData) ABORT0(); + cellData = (BCCellData*)aCellMap.AppendCell(*this, nsnull, rgYPos, + false, 0, damageArea); + if (!cellData) ABORT0(); } else { NS_ASSERTION(aSide == NS_SIDE_BOTTOM, "program error"); @@ -1028,7 +1044,9 @@ nsTableCellMap::SetBCBorderEdge(mozilla::css::Side aSide, cellData = (BCCellData*)cellMap->GetDataAt(0, xIndex); if (!cellData) { // add a dead cell nsRect damageArea; - cellData = (BCCellData*)cellMap->AppendCell(*this, nsnull, 0, false, damageArea); + cellData = (BCCellData*)cellMap->AppendCell(*this, nsnull, 0, + false, 0, + damageArea); } } else { // must be at the end of the table @@ -1121,7 +1139,8 @@ nsTableCellMap::SetBCBorderCorner(Corner aCorner, PRInt32 numRgRows = aCellMap.GetRowCount(); if (yPos < numRgRows) { // add a dead cell data nsRect damageArea; - cellData = (BCCellData*)aCellMap.AppendCell(*this, nsnull, rgYPos, false, damageArea); + cellData = (BCCellData*)aCellMap.AppendCell(*this, nsnull, rgYPos, + false, 0, damageArea); } else { // try the next non empty row group @@ -1133,7 +1152,8 @@ nsTableCellMap::SetBCBorderCorner(Corner aCorner, cellData = (BCCellData*)cellMap->GetDataAt(0, xPos); if (!cellData) { // add a dead cell nsRect damageArea; - cellData = (BCCellData*)cellMap->AppendCell(*this, nsnull, 0, false, damageArea); + cellData = (BCCellData*)cellMap->AppendCell(*this, nsnull, 0, + false, 0, damageArea); } } else { // must be at the bottom of the table @@ -1337,6 +1357,7 @@ nsCellMap::InsertRows(nsTableCellMap& aMap, nsTArray& aRows, PRInt32 aFirstRowIndex, bool aConsiderSpans, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea) { PRInt32 numCols = aMap.GetColCount(); @@ -1352,7 +1373,7 @@ nsCellMap::InsertRows(nsTableCellMap& aMap, if (!aConsiderSpans) { // update mContentRowCount, since non-empty rows will be added mContentRowCount = NS_MAX(aFirstRowIndex, mContentRowCount); - ExpandWithRows(aMap, aRows, aFirstRowIndex, aDamageArea); + ExpandWithRows(aMap, aRows, aFirstRowIndex, aRgFirstRowIndex, aDamageArea); return; } @@ -1368,12 +1389,11 @@ nsCellMap::InsertRows(nsTableCellMap& aMap, if (!spansCauseRebuild && (PRUint32(aFirstRowIndex) < mRows.Length())) { spansCauseRebuild = CellsSpanOut(aRows); } - if (spansCauseRebuild) { aMap.RebuildConsideringRows(this, aFirstRowIndex, &aRows, 0, aDamageArea); } else { - ExpandWithRows(aMap, aRows, aFirstRowIndex, aDamageArea); + ExpandWithRows(aMap, aRows, aFirstRowIndex, aRgFirstRowIndex, aDamageArea); } } @@ -1382,6 +1402,7 @@ nsCellMap::RemoveRows(nsTableCellMap& aMap, PRInt32 aFirstRowIndex, PRInt32 aNumRowsToRemove, bool aConsiderSpans, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea) { PRInt32 numRows = mRows.Length(); @@ -1395,7 +1416,8 @@ nsCellMap::RemoveRows(nsTableCellMap& aMap, return; } if (!aConsiderSpans) { - ShrinkWithoutRows(aMap, aFirstRowIndex, aNumRowsToRemove, aDamageArea); + ShrinkWithoutRows(aMap, aFirstRowIndex, aNumRowsToRemove, aRgFirstRowIndex, + aDamageArea); return; } PRInt32 endRowIndex = aFirstRowIndex + aNumRowsToRemove - 1; @@ -1405,12 +1427,13 @@ nsCellMap::RemoveRows(nsTableCellMap& aMap, } bool spansCauseRebuild = CellsSpanInOrOut(aFirstRowIndex, endRowIndex, 0, numCols - 1); - if (spansCauseRebuild) { - aMap.RebuildConsideringRows(this, aFirstRowIndex, nsnull, aNumRowsToRemove, aDamageArea); + aMap.RebuildConsideringRows(this, aFirstRowIndex, nsnull, aNumRowsToRemove, + aDamageArea); } else { - ShrinkWithoutRows(aMap, aFirstRowIndex, aNumRowsToRemove, aDamageArea); + ShrinkWithoutRows(aMap, aFirstRowIndex, aNumRowsToRemove, aRgFirstRowIndex, + aDamageArea); } } @@ -1422,6 +1445,7 @@ nsCellMap::AppendCell(nsTableCellMap& aMap, nsTableCellFrame* aCellFrame, PRInt32 aRowIndex, bool aRebuildIfNecessary, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea, PRInt32* aColToBeginSearch) { @@ -1514,7 +1538,15 @@ nsCellMap::AppendCell(nsTableCellMap& aMap, SetDataAt(aMap, *origData, aRowIndex, startColIndex); } - SetDamageArea(startColIndex, aRowIndex, 1 + endColIndex - startColIndex, 1 + endRowIndex - aRowIndex, aDamageArea); + if (aRebuildIfNecessary) { + //the caller depends on the damageArea + // The special case for zeroRowSpan is to adjust for the '2' in + // GetRowSpanForNewCell. + PRUint32 height = zeroRowSpan ? endRowIndex - aRowIndex : + 1 + endRowIndex - aRowIndex; + SetDamageArea(startColIndex, aRgFirstRowIndex + aRowIndex, + 1 + endColIndex - startColIndex, height, aDamageArea); + } if (!aCellFrame) { return origData; @@ -1723,6 +1755,7 @@ void nsCellMap::InsertCells(nsTableCellMap& aMap, nsTArray& aCellFrames, PRInt32 aRowIndex, PRInt32 aColIndexBefore, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea) { if (aCellFrames.Length() == 0) return; @@ -1779,12 +1812,13 @@ void nsCellMap::InsertCells(nsTableCellMap& aMap, spansCauseRebuild = CellsSpanInOrOut(aRowIndex, aRowIndex + rowSpan - 1, startColIndex, numCols - 1); } - if (spansCauseRebuild) { - aMap.RebuildConsideringCells(this, &aCellFrames, aRowIndex, startColIndex, true, aDamageArea); + aMap.RebuildConsideringCells(this, &aCellFrames, aRowIndex, startColIndex, + true, aDamageArea); } else { - ExpandWithCells(aMap, aCellFrames, aRowIndex, startColIndex, rowSpan, zeroRowSpan, aDamageArea); + ExpandWithCells(aMap, aCellFrames, aRowIndex, startColIndex, rowSpan, + zeroRowSpan, aRgFirstRowIndex, aDamageArea); } } @@ -1792,6 +1826,7 @@ void nsCellMap::ExpandWithRows(nsTableCellMap& aMap, nsTArray& aRowFrames, PRInt32 aStartRowIndexIn, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea) { PRInt32 startRowIndex = (aStartRowIndexIn >= 0) ? aStartRowIndexIn : 0; @@ -1818,14 +1853,15 @@ nsCellMap::ExpandWithRows(nsTableCellMap& aMap, while (cFrame) { nsTableCellFrame *cellFrame = do_QueryFrame(cFrame); if (cellFrame) { - AppendCell(aMap, cellFrame, rowX, false, aDamageArea, &colIndex); + AppendCell(aMap, cellFrame, rowX, false, aRgFirstRowIndex, aDamageArea, + &colIndex); } cFrame = cFrame->GetNextSibling(); } newRowIndex++; } - - SetDamageArea(0, startRowIndex, aMap.GetColCount(), 1 + endRowIndex - startRowIndex, aDamageArea); + SetDamageArea(0, aRgFirstRowIndex + startRowIndex, aMap.GetColCount(), + 1 + endRowIndex - startRowIndex, aDamageArea); } void nsCellMap::ExpandWithCells(nsTableCellMap& aMap, @@ -1834,6 +1870,7 @@ void nsCellMap::ExpandWithCells(nsTableCellMap& aMap, PRInt32 aColIndex, PRInt32 aRowSpan, // same for all cells bool aRowSpanIsZero, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea) { NS_ASSERTION(!!aMap.mBCInfo == mIsBC, "BC state mismatch"); @@ -1908,8 +1945,10 @@ void nsCellMap::ExpandWithCells(nsTableCellMap& aMap, } cellFrame->SetColIndex(startColIndex); } - PRInt32 damageHeight = NS_MIN(GetRowGroup()->GetRowCount() - aRowIndex, aRowSpan); - SetDamageArea(aColIndex, aRowIndex, 1 + endColIndex - aColIndex, damageHeight, aDamageArea); + PRInt32 damageHeight = NS_MIN(GetRowGroup()->GetRowCount() - aRowIndex, + aRowSpan); + SetDamageArea(aColIndex, aRgFirstRowIndex + aRowIndex, + 1 + endColIndex - aColIndex, damageHeight, aDamageArea); PRInt32 rowX; @@ -1951,6 +1990,7 @@ void nsCellMap::ExpandWithCells(nsTableCellMap& aMap, void nsCellMap::ShrinkWithoutRows(nsTableCellMap& aMap, PRInt32 aStartRowIndex, PRInt32 aNumRowsToRemove, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea) { NS_ASSERTION(!!aMap.mBCInfo == mIsBC, "BC state mismatch"); @@ -1988,8 +2028,8 @@ void nsCellMap::ShrinkWithoutRows(nsTableCellMap& aMap, mContentRowCount--; } aMap.RemoveColsAtEnd(); - - SetDamageArea(0, aStartRowIndex, aMap.GetColCount(), 0, aDamageArea); + SetDamageArea(0, aRgFirstRowIndex + aStartRowIndex, aMap.GetColCount(), 0, + aDamageArea); } PRInt32 nsCellMap::GetColSpanForNewCell(nsTableCellFrame& aCellFrameToAdd, @@ -2127,6 +2167,7 @@ void nsCellMap::ShrinkWithoutCell(nsTableCellMap& aMap, nsTableCellFrame& aCellFrame, PRInt32 aRowIndex, PRInt32 aColIndex, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea) { NS_ASSERTION(!!aMap.mBCInfo == mIsBC, "BC state mismatch"); @@ -2139,8 +2180,9 @@ void nsCellMap::ShrinkWithoutCell(nsTableCellMap& aMap, PRUint32 colSpan = GetEffectiveColSpan(aMap, aRowIndex, aColIndex, zeroColSpan); PRUint32 endRowIndex = aRowIndex + rowSpan - 1; PRUint32 endColIndex = aColIndex + colSpan - 1; - - SetDamageArea(aColIndex, aRowIndex, 1 + endColIndex - aColIndex, 1 + endRowIndex - aRowIndex, aDamageArea); + SetDamageArea(aColIndex, aRgFirstRowIndex + aRowIndex, + NS_MAX(0, aMap.GetColCount() - aColIndex - 1), + 1 + endRowIndex - aRowIndex, aDamageArea); if (aMap.mTableFrame.HasZeroColSpans()) { aMap.mTableFrame.SetNeedColSpanExpansion(true); @@ -2217,8 +2259,7 @@ void nsCellMap::RebuildConsideringRows(nsTableCellMap& aMap, PRInt32 aStartRowIndex, nsTArray* aRowsToInsert, - PRInt32 aNumRowsToRemove, - nsRect& aDamageArea) + PRInt32 aNumRowsToRemove) { NS_ASSERTION(!!aMap.mBCInfo == mIsBC, "BC state mismatch"); // copy the old cell map into a new array @@ -2252,7 +2293,7 @@ nsCellMap::RebuildConsideringRows(nsTableCellMap& aMap, // rowX keeps track of where we are in mRows while setting up the // new cellmap. PRUint32 rowX = 0; - + nsRect damageArea; // put back the rows before the affected ones just as before. Note that we // can't just copy the old rows in bit-for-bit, because they might be // spanning out into the rows we're adding/removing. @@ -2263,7 +2304,7 @@ nsCellMap::RebuildConsideringRows(nsTableCellMap& aMap, // put in the original cell from the cell map const CellData* data = row.ElementAt(colX); if (data && data->IsOrig()) { - AppendCell(aMap, data->GetCellFrame(), rowX, false, aDamageArea); + AppendCell(aMap, data->GetCellFrame(), rowX, false, 0, damageArea); } } } @@ -2280,7 +2321,7 @@ nsCellMap::RebuildConsideringRows(nsTableCellMap& aMap, while (cFrame) { nsTableCellFrame *cellFrame = do_QueryFrame(cFrame); if (cellFrame) { - AppendCell(aMap, cellFrame, rowX, false, aDamageArea); + AppendCell(aMap, cellFrame, rowX, false, 0, damageArea); } cFrame = cFrame->GetNextSibling(); } @@ -2303,7 +2344,7 @@ nsCellMap::RebuildConsideringRows(nsTableCellMap& aMap, // put in the original cell from the cell map CellData* data = row.ElementAt(colX); if (data && data->IsOrig()) { - AppendCell(aMap, data->GetCellFrame(), rowX, false, aDamageArea); + AppendCell(aMap, data->GetCellFrame(), rowX, false, 0, damageArea); } } rowX++; @@ -2317,8 +2358,6 @@ nsCellMap::RebuildConsideringRows(nsTableCellMap& aMap, DestroyCellData(row[colX]); } } - - SetDamageArea(0, 0, aMap.GetColCount(), GetRowCount(), aDamageArea); } void @@ -2327,8 +2366,7 @@ nsCellMap::RebuildConsideringCells(nsTableCellMap& aMap, nsTArray* aCellFrames, PRInt32 aRowIndex, PRInt32 aColIndex, - bool aInsert, - nsRect& aDamageArea) + bool aInsert) { NS_ASSERTION(!!aMap.mBCInfo == mIsBC, "BC state mismatch"); // copy the old cell map into a new array @@ -2345,6 +2383,7 @@ nsCellMap::RebuildConsideringCells(nsTableCellMap& aMap, // build the new cell map. Hard to say what, if anything, we can preallocate // here... Should come back to that sometime, perhaps. PRInt32 rowX; + nsRect damageArea; for (rowX = 0; rowX < numOrigRows; rowX++) { const CellDataArray& row = origRows[rowX]; for (PRInt32 colX = 0; colX < numCols; colX++) { @@ -2353,7 +2392,7 @@ nsCellMap::RebuildConsideringCells(nsTableCellMap& aMap, for (PRInt32 cellX = 0; cellX < numNewCells; cellX++) { nsTableCellFrame* cell = aCellFrames->ElementAt(cellX); if (cell) { - AppendCell(aMap, cell, rowX, false, aDamageArea); + AppendCell(aMap, cell, rowX, false, 0, damageArea); } } } @@ -2364,7 +2403,7 @@ nsCellMap::RebuildConsideringCells(nsTableCellMap& aMap, // put in the original cell from the cell map CellData* data = row.SafeElementAt(colX); if (data && data->IsOrig()) { - AppendCell(aMap, data->GetCellFrame(), rowX, false, aDamageArea); + AppendCell(aMap, data->GetCellFrame(), rowX, false, 0, damageArea); } } } @@ -2373,7 +2412,7 @@ nsCellMap::RebuildConsideringCells(nsTableCellMap& aMap, for (PRInt32 cellX = 0; cellX < numNewCells; cellX++) { nsTableCellFrame* cell = aCellFrames->ElementAt(cellX); if (cell) { - AppendCell(aMap, cell, aRowIndex, false, aDamageArea); + AppendCell(aMap, cell, aRowIndex, false, 0, damageArea); } } } @@ -2396,6 +2435,7 @@ nsCellMap::RebuildConsideringCells(nsTableCellMap& aMap, void nsCellMap::RemoveCell(nsTableCellMap& aMap, nsTableCellFrame* aCellFrame, PRInt32 aRowIndex, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea) { PRUint32 numRows = mRows.Length(); @@ -2429,10 +2469,12 @@ void nsCellMap::RemoveCell(nsTableCellMap& aMap, spansCauseRebuild = true; if (spansCauseRebuild) { - aMap.RebuildConsideringCells(this, nsnull, aRowIndex, startColIndex, false, aDamageArea); + aMap.RebuildConsideringCells(this, nsnull, aRowIndex, startColIndex, false, + aDamageArea); } else { - ShrinkWithoutCell(aMap, *aCellFrame, aRowIndex, startColIndex, aDamageArea); + ShrinkWithoutCell(aMap, *aCellFrame, aRowIndex, startColIndex, + aRgFirstRowIndex, aDamageArea); } } diff --git a/layout/tables/nsCellMap.h b/layout/tables/nsCellMap.h index 7792c921730..8625668fcd3 100644 --- a/layout/tables/nsCellMap.h +++ b/layout/tables/nsCellMap.h @@ -378,6 +378,7 @@ public: nsTableCellFrame* aCellFrame, PRInt32 aRowIndex, bool aRebuildIfNecessary, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea, PRInt32* aBeginSearchAtCol = nsnull); @@ -401,23 +402,27 @@ public: nsTArray& aCellFrames, PRInt32 aRowIndex, PRInt32 aColIndexBefore, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea); void RemoveCell(nsTableCellMap& aMap, nsTableCellFrame* aCellFrame, PRInt32 aRowIndex, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea); void InsertRows(nsTableCellMap& aMap, nsTArray& aRows, PRInt32 aFirstRowIndex, bool aConsiderSpans, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea); void RemoveRows(nsTableCellMap& aMap, PRInt32 aFirstRowIndex, PRInt32 aNumRowsToRemove, bool aConsiderSpans, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea); PRInt32 GetNumCellsOriginatingInRow(PRInt32 aRowIndex) const; @@ -499,6 +504,7 @@ protected: void ExpandWithRows(nsTableCellMap& aMap, nsTArray& aRowFrames, PRInt32 aStartRowIndex, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea); void ExpandWithCells(nsTableCellMap& aMap, @@ -507,17 +513,20 @@ protected: PRInt32 aColIndex, PRInt32 aRowSpan, bool aRowSpanIsZero, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea); void ShrinkWithoutRows(nsTableCellMap& aMap, PRInt32 aFirstRowIndex, PRInt32 aNumRowsToRemove, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea); void ShrinkWithoutCell(nsTableCellMap& aMap, nsTableCellFrame& aCellFrame, PRInt32 aRowIndex, PRInt32 aColIndex, + PRInt32 aRgFirstRowIndex, nsRect& aDamageArea); /** @@ -531,16 +540,14 @@ protected: void RebuildConsideringRows(nsTableCellMap& aMap, PRInt32 aStartRowIndex, nsTArray* aRowsToInsert, - PRInt32 aNumRowsToRemove, - nsRect& aDamageArea); + PRInt32 aNumRowsToRemove); void RebuildConsideringCells(nsTableCellMap& aMap, PRInt32 aNumOrigCols, nsTArray* aCellFrames, PRInt32 aRowIndex, PRInt32 aColIndex, - bool aInsert, - nsRect& aDamageArea); + bool aInsert); bool CellsSpanOut(nsTArray& aNewRows) const; diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 35d80ed5579..bd5d1dcdcd3 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -256,7 +256,7 @@ nsTableCellFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) GetColIndex(colIndex); GetRowIndex(rowIndex); nsRect damageArea(colIndex, rowIndex, GetColSpan(), GetRowSpan()); - tableFrame->SetBCDamageArea(damageArea); + tableFrame->AddBCDamageArea(damageArea); } } diff --git a/layout/tables/nsTableColFrame.cpp b/layout/tables/nsTableColFrame.cpp index 104236546c8..ff56d818c69 100644 --- a/layout/tables/nsTableColFrame.cpp +++ b/layout/tables/nsTableColFrame.cpp @@ -94,7 +94,7 @@ nsTableColFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) if (tableFrame->IsBorderCollapse() && tableFrame->BCRecalcNeeded(aOldStyleContext, GetStyleContext())) { nsRect damageArea = nsRect(GetColIndex(), 0, 1, tableFrame->GetRowCount()); - tableFrame->SetBCDamageArea(damageArea); + tableFrame->AddBCDamageArea(damageArea); } return; } diff --git a/layout/tables/nsTableColGroupFrame.cpp b/layout/tables/nsTableColGroupFrame.cpp index 5a9a0d1af24..98aa1d067df 100644 --- a/layout/tables/nsTableColGroupFrame.cpp +++ b/layout/tables/nsTableColGroupFrame.cpp @@ -205,7 +205,7 @@ nsTableColGroupFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) return; // this is a degenerated colgroup nsRect damageArea(GetFirstColumn()->GetColIndex(), 0, colCount, tableFrame->GetRowCount()); - tableFrame->SetBCDamageArea(damageArea); + tableFrame->AddBCDamageArea(damageArea); } return; } diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index a0451a60f4b..ac6625362d4 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -148,11 +148,10 @@ struct nsTableReflowState { struct BCPropertyData { - BCPropertyData() { mDamageArea.x = mDamageArea.y = mDamageArea.width = - mDamageArea.height = mTopBorderWidth = mRightBorderWidth = - mBottomBorderWidth = mLeftBorderWidth = - mLeftCellBorderWidth = mRightCellBorderWidth = 0; } - nsRect mDamageArea; + BCPropertyData() : mTopBorderWidth(0), mRightBorderWidth(0), + mBottomBorderWidth(0), mLeftBorderWidth(0), + mLeftCellBorderWidth(0), mRightCellBorderWidth(0) {} + nsRect mDamageArea; BCPixelSize mTopBorderWidth; BCPixelSize mRightBorderWidth; BCPixelSize mBottomBorderWidth; @@ -351,8 +350,7 @@ nsTableFrame::SetInitialChildList(ChildListID aListID, InsertRowGroups(mFrames); // calc collapsing borders if (IsBorderCollapse()) { - nsRect damageArea(0, 0, GetColCount(), GetRowCount()); - SetBCDamageArea(damageArea); + SetFullBCDamageArea(); } } @@ -604,8 +602,8 @@ void nsTableFrame::InsertCol(nsTableColFrame& aColFrame, } // for now, just bail and recalc all of the collapsing borders if (IsBorderCollapse()) { - nsRect damageArea(0, 0, NS_MAX(1, GetColCount()), NS_MAX(1, GetRowCount())); - SetBCDamageArea(damageArea); + nsRect damageArea(aColIndex, 0, 1, GetRowCount()); + AddBCDamageArea(damageArea); } } @@ -626,7 +624,7 @@ void nsTableFrame::RemoveCol(nsTableColGroupFrame* aColGroupFrame, // for now, just bail and recalc all of the collapsing borders if (IsBorderCollapse()) { nsRect damageArea(0, 0, GetColCount(), GetRowCount()); - SetBCDamageArea(damageArea); + AddBCDamageArea(damageArea); } } @@ -799,7 +797,7 @@ nsTableFrame::AppendCell(nsTableCellFrame& aCellFrame, cellMap->AppendCell(aCellFrame, aRowIndex, true, damageArea); MatchCellMapToColCache(cellMap); if (IsBorderCollapse()) { - SetBCDamageArea(damageArea); + AddBCDamageArea(damageArea); } } } @@ -814,7 +812,7 @@ void nsTableFrame::InsertCells(nsTArray& aCellFrames, cellMap->InsertCells(aCellFrames, aRowIndex, aColIndexBefore, damageArea); MatchCellMapToColCache(cellMap); if (IsBorderCollapse()) { - SetBCDamageArea(damageArea); + AddBCDamageArea(damageArea); } } } @@ -854,7 +852,7 @@ void nsTableFrame::RemoveCell(nsTableCellFrame* aCellFrame, cellMap->RemoveCell(aCellFrame, aRowIndex, damageArea); MatchCellMapToColCache(cellMap); if (IsBorderCollapse()) { - SetBCDamageArea(damageArea); + AddBCDamageArea(damageArea); } } } @@ -919,7 +917,7 @@ nsTableFrame::InsertRows(nsTableRowGroupFrame* aRowGroupFrame, rowFrame->SetRowIndex(aRowIndex + rowY); } if (IsBorderCollapse()) { - SetBCDamageArea(damageArea); + AddBCDamageArea(damageArea); } } #ifdef DEBUG_TABLE_CELLMAP @@ -962,7 +960,7 @@ void nsTableFrame::RemoveRows(nsTableRowFrame& aFirstRowFrame, cellMap->RemoveRows(firstRowIndex, aNumRowsToRemove, aConsiderSpans, damageArea); MatchCellMapToColCache(cellMap); if (IsBorderCollapse()) { - SetBCDamageArea(damageArea); + AddBCDamageArea(damageArea); } } AdjustRowIndices(firstRowIndex, -aNumRowsToRemove); @@ -2049,8 +2047,7 @@ nsTableFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) if (IsBorderCollapse() && BCRecalcNeeded(aOldStyleContext, GetStyleContext())) { - nsRect damageArea(0, 0, GetColCount(), GetRowCount()); - SetBCDamageArea(damageArea); + SetFullBCDamageArea(); } //avoid this on init or nextinflow @@ -2309,8 +2306,7 @@ nsTableFrame::RemoveFrame(ChildListID aListID, // for now, just bail and recalc all of the collapsing borders // as the cellmap changes we need to recalc if (IsBorderCollapse()) { - nsRect damageArea(0, 0, NS_MAX(1, GetColCount()), NS_MAX(1, GetRowCount())); - SetBCDamageArea(damageArea); + SetFullBCDamageArea(); } PresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); @@ -2357,6 +2353,20 @@ DestroyBCProperty(void* aPropertyValue) NS_DECLARE_FRAME_PROPERTY(TableBCProperty, DestroyBCProperty) +BCPropertyData* +nsTableFrame::GetBCProperty(bool aCreateIfNecessary) const +{ + FrameProperties props = Properties(); + BCPropertyData* value = static_cast + (props.Get(TableBCProperty())); + if (!value && aCreateIfNecessary) { + value = new BCPropertyData(); + props.Set(TableBCProperty(), value); + } + + return value; +} + static void DivideBCBorderSize(BCPixelSize aPixelSize, BCPixelSize& aSmallHalf, @@ -2374,8 +2384,7 @@ nsTableFrame::GetOuterBCBorder() const nsMargin border(0, 0, 0, 0); PRInt32 p2t = nsPresContext::AppUnitsPerCSSPixel(); - BCPropertyData* propData = static_cast - (Properties().Get(TableBCProperty())); + BCPropertyData* propData = GetBCProperty(); if (propData) { border.top = BC_BORDER_TOP_HALF_COORD(p2t, propData->mTopBorderWidth); border.right = BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mRightBorderWidth); @@ -2393,8 +2402,7 @@ nsTableFrame::GetIncludedOuterBCBorder() const nsMargin border(0, 0, 0, 0); PRInt32 p2t = nsPresContext::AppUnitsPerCSSPixel(); - BCPropertyData* propData = static_cast - (Properties().Get(TableBCProperty())); + BCPropertyData* propData = GetBCProperty(); if (propData) { border.top += BC_BORDER_TOP_HALF_COORD(p2t, propData->mTopBorderWidth); border.right += BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mRightCellBorderWidth); @@ -3767,22 +3775,6 @@ nsTableFrame::ColumnHasCellSpacingBefore(PRInt32 aColIndex) const return cellMap->GetNumCellsOriginatingInCol(aColIndex) > 0; } -static void -CheckFixDamageArea(PRInt32 aNumRows, - PRInt32 aNumCols, - nsRect& aDamageArea) -{ - if (((aDamageArea.XMost() > aNumCols) && (aDamageArea.width != 1) && (aNumCols != 0)) || - ((aDamageArea.YMost() > aNumRows) && (aDamageArea.height != 1) && (aNumRows != 0))) { - // the damage area was set incorrectly, just be safe and make it the entire table - NS_ASSERTION(false, "invalid BC damage area"); - aDamageArea.x = 0; - aDamageArea.y = 0; - aDamageArea.width = aNumCols; - aDamageArea.height = aNumRows; - } -} - /******************************************************************************** * Collapsing Borders * @@ -3796,31 +3788,77 @@ CheckFixDamageArea(PRInt32 aNumRows, * 5) if all border styles are NONE, then that's the computed border style. *******************************************************************************/ -void -nsTableFrame::SetBCDamageArea(const nsRect& aValue) -{ - nsRect newRect(aValue); - newRect.width = NS_MAX(1, newRect.width); - newRect.height = NS_MAX(1, newRect.height); +#ifdef DEBUG +#define VerifyNonNegativeDamageRect(r) \ + NS_ASSERTION((r).x >= 0, "negative col index"); \ + NS_ASSERTION((r).y >= 0, "negative row index"); \ + NS_ASSERTION((r).width >= 0, "negative horizontal damage"); \ + NS_ASSERTION((r).height >= 0, "negative vertical damage"); +#define VerifyDamageRect(r) \ + VerifyNonNegativeDamageRect(r); \ + NS_ASSERTION((r).XMost() <= GetColCount(), \ + "horizontal damage extends outside table"); \ + NS_ASSERTION((r).YMost() <= GetRowCount(), \ + "vertical damage extends outside table"); +#endif + +void +nsTableFrame::AddBCDamageArea(const nsRect& aValue) +{ + NS_ASSERTION(IsBorderCollapse(), "invalid AddBCDamageArea call"); +#ifdef DEBUG + VerifyDamageRect(aValue); +#endif - if (!IsBorderCollapse()) { - NS_ASSERTION(false, "invalid call - not border collapse model"); - return; - } SetNeedToCalcBCBorders(true); // Get the property - FrameProperties props = Properties(); - BCPropertyData* value = static_cast - (props.Get(TableBCProperty())); - if (!value) { - value = new BCPropertyData(); - props.Set(TableBCProperty(), value); + BCPropertyData* value = GetBCProperty(true); + if (value) { +#ifdef DEBUG + VerifyNonNegativeDamageRect(value->mDamageArea); +#endif + // Clamp the old damage area to the current table area in case it shrunk. + PRInt32 cols = GetColCount(); + if (value->mDamageArea.XMost() > cols) { + if (value->mDamageArea.x > cols) { + value->mDamageArea.x = cols; + value->mDamageArea.width = 0; + } + else { + value->mDamageArea.width = cols - value->mDamageArea.x; + } + } + PRInt32 rows = GetRowCount(); + if (value->mDamageArea.YMost() > rows) { + if (value->mDamageArea.y > rows) { + value->mDamageArea.y = rows; + value->mDamageArea.height = 0; + } + else { + value->mDamageArea.height = rows - value->mDamageArea.y; + } + } + + // Construct a union of the new and old damage areas. + value->mDamageArea.UnionRect(value->mDamageArea, aValue); } - // for now just construct a union of the new and old damage areas - value->mDamageArea.UnionRect(value->mDamageArea, newRect); - CheckFixDamageArea(GetRowCount(), GetColCount(), value->mDamageArea); } + +void +nsTableFrame::SetFullBCDamageArea() +{ + NS_ASSERTION(IsBorderCollapse(), "invalid SetFullBCDamageArea call"); + + SetNeedToCalcBCBorders(true); + + BCPropertyData* value = GetBCProperty(true); + if (value) { + value->mDamageArea = nsRect(0, 0, GetColCount(), GetRowCount()); + } +} + + /* BCCellBorder represents a border segment which can be either a horizontal * or a vertical segment. For each segment we need to know the color, width, * style, who owns it and how long it is in cellmap coordinates. @@ -4216,7 +4254,9 @@ BCMapCellIterator::SetNewRow(nsTableRowFrame* aRow) CellData* cellData = row.SafeElementAt(mColIndex); if (!cellData) { // add a dead cell data nsRect damageArea; - cellData = mCellMap->AppendCell(*mTableCellMap, nsnull, rgRowIndex, false, damageArea); if (!cellData) ABORT1(false); + cellData = mCellMap->AppendCell(*mTableCellMap, nsnull, rgRowIndex, + false, 0, damageArea); + if (!cellData) ABORT1(false); } if (cellData && (cellData->IsOrig() || cellData->IsDead())) { break; @@ -4312,7 +4352,7 @@ BCMapCellIterator::Next(BCMapCellInfo& aMapInfo) nsRect damageArea; cellData = static_cast(mCellMap->AppendCell(*mTableCellMap, nsnull, - rgRowIndex, false, + rgRowIndex, false, 0, damageArea)); if (!cellData) ABORT0(); } @@ -4347,7 +4387,7 @@ BCMapCellIterator::PeekRight(BCMapCellInfo& aRefInfo, nsRect damageArea; cellData = static_cast(mCellMap->AppendCell(*mTableCellMap, nsnull, - rgRowIndex, false, + rgRowIndex, false, 0, damageArea)); if (!cellData) ABORT0(); } @@ -4405,7 +4445,7 @@ BCMapCellIterator::PeekBottom(BCMapCellInfo& aRefInfo, nsRect damageArea; cellData = static_cast(cellMap->AppendCell(*mTableCellMap, nsnull, - rgRowIndex, false, + rgRowIndex, false, 0, damageArea)); if (!cellData) ABORT0(); } @@ -5469,13 +5509,11 @@ nsTableFrame::CalcBCBorders() return; // nothing to do // Get the property holding the table damage area and border widths - BCPropertyData* propData = static_cast - (Properties().Get(TableBCProperty())); + BCPropertyData* propData = GetBCProperty(); if (!propData) ABORT0(); - CheckFixDamageArea(numRows, numCols, propData->mDamageArea); // calculate an expanded damage area nsRect damageArea(propData->mDamageArea); ExpandBCDamageArea(damageArea); diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index 60d671c89fd..9df26667e63 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -58,6 +58,7 @@ class nsStyleContext; struct nsTableReflowState; struct nsStylePosition; +struct BCPropertyData; static inline bool IS_TABLE_CELL(nsIAtom* frameType) { return nsGkAtoms::tableCellFrame == frameType || @@ -291,7 +292,7 @@ public: friend class nsDelayedCalcBCBorders; - void SetBCDamageArea(const nsRect& aValue); + void AddBCDamageArea(const nsRect& aValue); bool BCRecalcNeeded(nsStyleContext* aOldStyleContext, nsStyleContext* aNewStyleContext); void PaintBCBorders(nsRenderingContext& aRenderingContext, @@ -688,10 +689,13 @@ public: nsTArray& GetColCache(); + protected: void SetBorderCollapse(bool aValue); + BCPropertyData* GetBCProperty(bool aCreateIfNecessary = false) const; + void SetFullBCDamageArea(); void CalcBCBorders(); void ExpandBCDamageArea(nsRect& aRect) const; diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 7508c2c5da3..6835b1d968c 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -195,7 +195,7 @@ nsTableRowFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) if (tableFrame->IsBorderCollapse() && tableFrame->BCRecalcNeeded(aOldStyleContext, GetStyleContext())) { nsRect damageArea(0, GetRowIndex(), tableFrame->GetColCount(), 1); - tableFrame->SetBCDamageArea(damageArea); + tableFrame->AddBCDamageArea(damageArea); } return; } diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index c6c64f49bc2..7f650ea3dd4 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -1389,7 +1389,7 @@ nsTableRowGroupFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) tableFrame->BCRecalcNeeded(aOldStyleContext, GetStyleContext())) { nsRect damageArea(0, GetStartRowIndex(), tableFrame->GetColCount(), GetRowCount()); - tableFrame->SetBCDamageArea(damageArea); + tableFrame->AddBCDamageArea(damageArea); } return; } From 81697e5d429765a0fc9b66d01158a05a2e0e2cd1 Mon Sep 17 00:00:00 2001 From: Andrew Paprocki Date: Mon, 21 Nov 2011 21:54:35 -0500 Subject: [PATCH 08/31] Bug 620452 - Always define sharpnum to prevent compiler error when JS_HAS_SHARP_VARS is undefined. r=mrbkap --- js/src/frontend/BytecodeEmitter.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index e7ae6518b8f..3a875e62749 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -5757,9 +5757,7 @@ frontend::EmitTree(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn) JSOp op; uint32 argc; EmitLevelManager elm(bce); -#if JS_HAS_SHARP_VARS - jsint sharpnum; -#endif + jsint sharpnum = -1; JS_CHECK_RECURSION(cx, return JS_FALSE); From 59db32c5ad6d0e3e0d4f2419319a4c2a06cda90d Mon Sep 17 00:00:00 2001 From: David Marteau Date: Sat, 26 Nov 2011 20:48:35 +0100 Subject: [PATCH 09/31] Bug 700829 - Thebes gfxPlatform.h file depends on internal api nsString.h. r=bsmedberg --- gfx/thebes/gfxPlatform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index f43f66659ca..8c0d3dfd056 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -42,7 +42,7 @@ #include "prtypes.h" #include "prlog.h" #include "nsTArray.h" -#include "nsString.h" +#include "nsStringGlue.h" #include "nsIObserver.h" #include "gfxTypes.h" From affeb7444e4c17d1f312849687aeceed9121fea1 Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Sat, 26 Nov 2011 20:48:55 +0100 Subject: [PATCH 10/31] Bug 451161 - Part 1: Allow overriding system accesibility settings without SystemPref module. r=surkov.alexander --- .../src/atk/nsApplicationAccessibleWrap.cpp | 27 +++++++++++++------ widget/src/gtk2/nsWindow.cpp | 20 ++++++++------ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/accessible/src/atk/nsApplicationAccessibleWrap.cpp b/accessible/src/atk/nsApplicationAccessibleWrap.cpp index c8ee40cf0e0..d08280d8890 100644 --- a/accessible/src/atk/nsApplicationAccessibleWrap.cpp +++ b/accessible/src/atk/nsApplicationAccessibleWrap.cpp @@ -44,7 +44,8 @@ #include "nsMai.h" #include "prlink.h" #include "prenv.h" -#include "nsIPrefBranch.h" +#include "mozilla/Preferences.h" +#include "nsIGConfService.h" #include "nsIServiceManager.h" #include "nsAutoPtr.h" #include "nsAccessibilityService.h" @@ -53,6 +54,8 @@ #include #include +using namespace mozilla; + typedef GType (* AtkGetTypeType) (void); GType g_atk_hyperlink_impl_type = G_TYPE_INVALID; static bool sATKChecked = false; @@ -61,10 +64,12 @@ static const char sATKLibName[] = "libatk-1.0.so.0"; static const char sATKHyperlinkImplGetTypeSymbol[] = "atk_hyperlink_impl_get_type"; static const char sAccEnv [] = "GNOME_ACCESSIBILITY"; -static const char sSysPrefService [] = - "@mozilla.org/system-preference-service;1"; +static const char sUseSystemPrefsKey[] = + "config.use_system_prefs"; static const char sAccessibilityKey [] = "config.use_system_prefs.accessibility"; +static const char sGconfAccessibilityKey[] = + "/desktop/gnome/interface/accessibility"; /* gail function pointer */ static guint (* gail_add_global_event_listener) (GSignalEmissionHook listener, @@ -625,11 +630,17 @@ nsApplicationAccessibleWrap::Init() isGnomeATEnabled = !!atoi(envValue); } else { //check gconf-2 setting - nsresult rv; - nsCOMPtr sysPrefService = - do_GetService(sSysPrefService, &rv); - if (NS_SUCCEEDED(rv) && sysPrefService) { - sysPrefService->GetBoolPref(sAccessibilityKey, &isGnomeATEnabled); + if (Preferences::GetBool(sUseSystemPrefsKey, false)) { + nsresult rv; + nsCOMPtr gconf = + do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv) && gconf) { + gconf->GetBool(NS_LITERAL_CSTRING(sGconfAccessibilityKey), + &isGnomeATEnabled); + } + } else { + isGnomeATEnabled = + Preferences::GetBool(sAccessibilityKey, false); } } diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index f3d2d4fe1e2..7213896644a 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -99,7 +99,7 @@ #include "mozilla/Preferences.h" #include "nsIPrefService.h" -#include "nsIPrefBranch.h" +#include "nsIGConfService.h" #include "nsIServiceManager.h" #include "nsIStringBundle.h" #include "nsGfxCIID.h" @@ -119,9 +119,10 @@ using namespace mozilla; static bool sAccessibilityChecked = false; /* static */ bool nsWindow::sAccessibilityEnabled = false; -static const char sSysPrefService [] = "@mozilla.org/system-preference-service;1"; static const char sAccEnv [] = "GNOME_ACCESSIBILITY"; +static const char sUseSystemPrefsKey[] = "config.use_system_prefs"; static const char sAccessibilityKey [] = "config.use_system_prefs.accessibility"; +static const char sGconfAccessibilityKey[] = "/desktop/gnome/interface/accessibility"; #endif /* For SetIcon */ @@ -4293,17 +4294,20 @@ nsWindow::Create(nsIWidget *aParent, LOG(("Accessibility Env %s=%s\n", sAccEnv, envValue)); } //check gconf-2 setting - else { - nsCOMPtr sysPrefService = - do_GetService(sSysPrefService, &rv); - if (NS_SUCCEEDED(rv) && sysPrefService) { + else if (Preferences::GetBool(sUseSystemPrefsKey, false)) { + nsCOMPtr gconf = + do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv) && gconf) { // do the work to get gconf setting. // will be done soon later. - sysPrefService->GetBoolPref(sAccessibilityKey, - &sAccessibilityEnabled); + gconf->GetBool(NS_LITERAL_CSTRING(sGconfAccessibilityKey), + &sAccessibilityEnabled); } + } else { + sAccessibilityEnabled = + Preferences::GetBool(sAccessibilityKey, false); } } #endif From 2bb41de1f8e4d46e656fe40ae619672b372f6957 Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Sat, 26 Nov 2011 20:49:31 +0100 Subject: [PATCH 11/31] Bug 451161 - Part 2: Remove SystemPref module from the tree. r=roc --- configure.in | 5 +- extensions/pref/Makefile.in | 4 - extensions/pref/makefiles.sh | 7 - extensions/pref/system-pref/src/Makefile.in | 67 -- .../pref/system-pref/src/gconf/Makefile.in | 75 -- .../system-pref/src/gconf/gconf_pref_list.inc | 19 - .../src/gconf/nsSystemPrefService.cpp | 915 ------------------ .../src/gconf/nsSystemPrefService.h | 93 -- .../pref/system-pref/src/nsSystemPref.cpp | 474 --------- .../pref/system-pref/src/nsSystemPref.h | 116 --- .../system-pref/src/nsSystemPrefFactory.cpp | 77 -- .../pref/system-pref/src/nsSystemPrefLog.h | 45 - toolkit/library/Makefile.in | 3 - toolkit/library/nsStaticXULComponents.cpp | 1 - 14 files changed, 2 insertions(+), 1899 deletions(-) delete mode 100644 extensions/pref/system-pref/src/Makefile.in delete mode 100644 extensions/pref/system-pref/src/gconf/Makefile.in delete mode 100644 extensions/pref/system-pref/src/gconf/gconf_pref_list.inc delete mode 100644 extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp delete mode 100644 extensions/pref/system-pref/src/gconf/nsSystemPrefService.h delete mode 100644 extensions/pref/system-pref/src/nsSystemPref.cpp delete mode 100644 extensions/pref/system-pref/src/nsSystemPref.h delete mode 100644 extensions/pref/system-pref/src/nsSystemPrefFactory.cpp delete mode 100644 extensions/pref/system-pref/src/nsSystemPrefLog.h diff --git a/configure.in b/configure.in index f6ccc564eaa..0fe873a72a1 100644 --- a/configure.in +++ b/configure.in @@ -5935,12 +5935,11 @@ if test "$MOZ_XTF"; then fi dnl ======================================================== -dnl Pref extensions (autoconfig and system-pref) +dnl Pref extensions (autoconfig) dnl ======================================================== MOZ_ARG_DISABLE_BOOL(pref-extensions, [ --disable-pref-extensions - Disable pref extensions such as autoconfig and - system-pref], + Disable pref extensions such as autoconfig], MOZ_PREF_EXTENSIONS=, MOZ_PREF_EXTENSIONS=1 ) diff --git a/extensions/pref/Makefile.in b/extensions/pref/Makefile.in index d83319ed3e5..f6206dfec45 100644 --- a/extensions/pref/Makefile.in +++ b/extensions/pref/Makefile.in @@ -45,8 +45,4 @@ include $(DEPTH)/config/autoconf.mk DIRS = autoconfig -ifdef MOZ_ENABLE_GTK2 -DIRS += system-pref/src -endif - include $(topsrcdir)/config/rules.mk diff --git a/extensions/pref/makefiles.sh b/extensions/pref/makefiles.sh index 7e8679b0cc1..3320b128526 100755 --- a/extensions/pref/makefiles.sh +++ b/extensions/pref/makefiles.sh @@ -42,10 +42,3 @@ add_makefiles " extensions/pref/autoconfig/public/Makefile extensions/pref/autoconfig/src/Makefile " - -if [ "$MOZ_ENABLE_GTK2" ]; then - add_makefiles " - extensions/pref/system-pref/src/Makefile - extensions/pref/system-pref/src/gconf/Makefile - " -fi diff --git a/extensions/pref/system-pref/src/Makefile.in b/extensions/pref/system-pref/src/Makefile.in deleted file mode 100644 index 499d65f2ae3..00000000000 --- a/extensions/pref/system-pref/src/Makefile.in +++ /dev/null @@ -1,67 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is -# Sun Microsystems, Inc. -# Portions created by the Initial Developer are Copyright (C) 2003 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Bolian Yin -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = system-pref -LIBRARY_NAME = system-pref_s -SHORT_LIBNAME = syspref - -# We want to force the creation of a static lib. -FORCE_STATIC_LIB = 1 -LIBXUL_LIBRARY = 1 - -DIRS = gconf - -CPPSRCS = \ - nsSystemPref.cpp \ - $(NULL) - -EXPORTS = \ - nsSystemPrefLog.h \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - -INCLUDES += \ - -I$(srcdir)/gconf \ - $(NULL) diff --git a/extensions/pref/system-pref/src/gconf/Makefile.in b/extensions/pref/system-pref/src/gconf/Makefile.in deleted file mode 100644 index 1114c2c6b9a..00000000000 --- a/extensions/pref/system-pref/src/gconf/Makefile.in +++ /dev/null @@ -1,75 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is -# Sun Microsystems, Inc. -# Portions created by the Initial Developer are Copyright (C) 2003 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Bolian Yin -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MODULE = system-pref -LIBRARY_NAME = system-pref -LIBXUL_LIBRARY = 1 - - -CPPSRCS = \ - nsSystemPrefService.cpp \ - nsSystemPrefFactory.cpp \ - $(NULL) - -SHARED_LIBRARY_LIBS = ../libsystem-pref_s.a - -EXPORT_LIBRARY = 1 -IS_COMPONENT = 1 -MODULE_NAME = nsSystemPrefModule - -EXPORTS = \ - nsSystemPrefService.h \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - -CFLAGS += $(MOZ_GTK2_CFLAGS) -CXXFLAGS += $(MOZ_GTK2_CFLAGS) - -LOCAL_INCLUDES = -I$(srcdir)/.. - -export:: - $(INSTALL) $(srcdir)/../nsSystemPrefFactory.cpp . - -GARBAGE += nsSystemPrefFactory.cpp diff --git a/extensions/pref/system-pref/src/gconf/gconf_pref_list.inc b/extensions/pref/system-pref/src/gconf/gconf_pref_list.inc deleted file mode 100644 index 4e4973c6980..00000000000 --- a/extensions/pref/system-pref/src/gconf/gconf_pref_list.inc +++ /dev/null @@ -1,19 +0,0 @@ -/* This file is included as the content of an array - * - * the first column is the mozilla pref name, the second column is the - * the related gconf pref name. - * - *************************************************************************/ - - {"network.proxy.http", "/system/http_proxy/host"}, - {"network.proxy.http_port", "/system/http_proxy/port"}, - {"network.proxy.ftp", "/system/proxy/ftp_host"}, - {"network.proxy.ftp_port", "/system/proxy/ftp_port"}, - {"network.proxy.ssl", "/system/proxy/secure_host"}, - {"network.proxy.ssl_port", "/system/proxy/secure_port"}, - {"network.proxy.socks", "/system/proxy/socks_host"}, - {"network.proxy.socks_port", "/system/proxy/socks_port"}, - {"network.proxy.no_proxies_on", "/system/http_proxy/ignore_hosts"}, - {"network.proxy.autoconfig_url", "/system/proxy/autoconfig_url"}, - {"network.proxy.type", "/system/proxy/mode"}, - {"config.use_system_prefs.accessibility", "/desktop/gnome/interface/accessibility"}, diff --git a/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp b/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp deleted file mode 100644 index a54283adad1..00000000000 --- a/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp +++ /dev/null @@ -1,915 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * Portions created by Sun Microsystems are Copyright (C) 2003 Sun - * Microsystems, Inc. All Rights Reserved. - * - * Original Author: Bolian Yin (bolian.yin@sun.com) - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include -#include - -#include "plstr.h" -#include "nsCOMPtr.h" -#include "nsIPrefBranch.h" -#include "nsIPrefService.h" -#include "nsIServiceManager.h" -#include "nsIObserver.h" -#include "nsWeakReference.h" - -#include "nsString.h" -#include "nsSystemPrefLog.h" -#include "nsSystemPrefService.h" - -/************************************************************************* - * The strange thing here is that we load the gconf library manually and - * search the function pointers we need. If that process fails, no gconf - * support is available in mozilla. The aim is to make mozilla independent - * on gconf, in both compile time and run time. - ************************************************************************/ - -//gconf types -extern "C" { - - typedef enum { - GCONF_VALUE_INVALID, - GCONF_VALUE_STRING, - GCONF_VALUE_INT, - GCONF_VALUE_FLOAT, - GCONF_VALUE_BOOL, - GCONF_VALUE_SCHEMA, - - GCONF_VALUE_LIST, - GCONF_VALUE_PAIR - - }GConfValueType; - - typedef struct { - GConfValueType type; - }GConfValue; - - typedef void * (*GConfClientGetDefaultType) (void); - typedef bool (*GConfClientGetBoolType) (void *client, const gchar *key, - GError **err); - typedef gchar* (*GConfClientGetStringType) (void *client, const gchar *key, - GError **err); - typedef PRInt32 (*GConfClientGetIntType) (void *client, const gchar *key, - GError **err); - typedef GSList* (*GConfClientGetListType) (void *client, const gchar *key, - GConfValueType list_type, - GError **err); - typedef void (*GConfClientNotifyFuncType) (void* client, guint cnxn_id, - void *entry, - gpointer user_data); - typedef guint (*GConfClientNotifyAddType) (void* client, - const gchar* namespace_section, - GConfClientNotifyFuncType func, - gpointer user_data, - GFreeFunc destroy_notify, - GError** err); - typedef void (*GConfClientNotifyRemoveType) (void *client, - guint cnxn); - typedef void (*GConfClientAddDirType) (void *client, - const gchar *dir, - guint8 preload, - GError **err); - typedef void (*GConfClientRemoveDirType) (void *client, - const gchar *dir, - GError **err); - - typedef const char* (*GConfEntryGetKeyType) (const void *entry); - typedef GConfValue* (*GConfEntryGetValueType) (const void *entry); - - typedef const char* (*GConfValueGetStringType) (const GConfValue *value); - typedef PRInt32 (*GConfValueGetIntType) (const GConfValue *value); - typedef bool (*GConfValueGetBoolType) (const GConfValue *value); - - - static void gconf_key_listener (void* client, guint cnxn_id, - void *entry, gpointer user_data); -} - -struct GConfCallbackData -{ - GConfProxy *proxy; - void * userData; - PRUint32 atom; - PRUint32 notifyId; -}; -////////////////////////////////////////////////////////////////////// -// GConPrxoy is a thin wrapper for easy use of gconf funcs. It loads the -// gconf library and initializes the func pointers for later use. -////////////////////////////////////////////////////////////////////// -class GConfProxy -{ -public: - GConfProxy(nsSystemPrefService* aSysPrefService); - ~GConfProxy(); - bool Init(); - - nsresult GetBoolPref(const char *aMozKey, bool *retval); - nsresult GetCharPref(const char *aMozKey, char **retval); - nsresult GetIntPref(const char *aMozKey, PRInt32 *retval); - - nsresult NotifyAdd (PRUint32 aAtom, void *aUserData); - nsresult NotifyRemove (PRUint32 aAtom, const void *aUserData); - - nsresult GetAtomForMozKey(const char *aMozKey, PRUint32 *aAtom) { - return GetAtom(aMozKey, 0, aAtom); - } - const char *GetMozKey(PRUint32 aAtom) { - return GetKey(aAtom, 0); - } - - void OnNotify(void *aClient, void * aEntry, PRUint32 aNotifyId, - GConfCallbackData *aData); - -private: - void *mGConfClient; - PRLibrary *mGConfLib; - bool mInitialized; - nsSystemPrefService *mSysPrefService; - - //listeners - nsAutoVoidArray *mObservers; - - void InitFuncPtrs(); - //gconf public func ptrs - - //gconf client funcs - GConfClientGetDefaultType GConfClientGetDefault; - GConfClientGetBoolType GConfClientGetBool; - GConfClientGetStringType GConfClientGetString; - GConfClientGetIntType GConfClientGetInt; - GConfClientGetListType GConfClientGetList; - GConfClientNotifyAddType GConfClientNotifyAdd; - GConfClientNotifyRemoveType GConfClientNotifyRemove; - GConfClientAddDirType GConfClientAddDir; - GConfClientRemoveDirType GConfClientRemoveDir; - - //gconf entry funcs - GConfEntryGetValueType GConfEntryGetValue; - GConfEntryGetKeyType GConfEntryGetKey; - - //gconf value funcs - GConfValueGetBoolType GConfValueGetBool; - GConfValueGetStringType GConfValueGetString; - GConfValueGetIntType GConfValueGetInt; - - //pref name translating stuff - nsresult GetAtom(const char *aKey, PRUint8 aNameType, PRUint32 *aAtom); - nsresult GetAtomForGConfKey(const char *aGConfKey, PRUint32 *aAtom) \ - {return GetAtom(aGConfKey, 1, aAtom);} - const char *GetKey(PRUint32 aAtom, PRUint8 aNameType); - const char *GetGConfKey(PRUint32 aAtom) \ - {return GetKey(aAtom, 1); } - inline const char *MozKey2GConfKey(const char *aMozKey); - - //const strings - static const char sPrefGConfKey[]; - static const char sDefaultLibName1[]; - static const char sDefaultLibName2[]; -}; - -struct SysPrefCallbackData { - nsISupports *observer; - bool bIsWeakRef; - PRUint32 prefAtom; -}; - -bool -sysPrefDeleteObserver(void *aElement, void *aData) { - SysPrefCallbackData *pElement = - static_cast(aElement); - NS_RELEASE(pElement->observer); - nsMemory::Free(pElement); - return true; -} - -NS_IMPL_ISUPPORTS2(nsSystemPrefService, nsIPrefBranch, nsIPrefBranch2) - -/* public */ -nsSystemPrefService::nsSystemPrefService() - :mInitialized(false), - mGConf(nsnull), - mObservers(nsnull) -{ -} - -nsSystemPrefService::~nsSystemPrefService() -{ - mInitialized = false; - - delete mGConf; - if (mObservers) { - (void)mObservers->EnumerateForwards(sysPrefDeleteObserver, nsnull); - delete mObservers; - } -} - -nsresult -nsSystemPrefService::Init() -{ - if (!gSysPrefLog) { - gSysPrefLog = PR_NewLogModule("Syspref"); - if (!gSysPrefLog) return NS_ERROR_OUT_OF_MEMORY; - } - - SYSPREF_LOG(("Init SystemPref Service\n")); - if (mInitialized) - return NS_ERROR_FAILURE; - - if (!mGConf) { - mGConf = new GConfProxy(this); - if (!mGConf->Init()) { - delete mGConf; - mGConf = nsnull; - return NS_ERROR_FAILURE; - } - } - - mInitialized = true; - return NS_OK; -} - -/* readonly attribute string root; */ -NS_IMETHODIMP nsSystemPrefService::GetRoot(char * *aRoot) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* long getPrefType (in string aPrefName); */ -NS_IMETHODIMP nsSystemPrefService::GetPrefType(const char *aPrefName, PRInt32 *_retval) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* boolean getBoolPref (in string aPrefName); */ -NS_IMETHODIMP nsSystemPrefService::GetBoolPref(const char *aPrefName, bool *_retval) -{ - return mInitialized ? - mGConf->GetBoolPref(aPrefName, _retval) : NS_ERROR_FAILURE; -} - -/* void setBoolPref (in string aPrefName, in long aValue); */ -NS_IMETHODIMP nsSystemPrefService::SetBoolPref(const char *aPrefName, bool aValue) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* string getCharPref (in string aPrefName); */ -NS_IMETHODIMP nsSystemPrefService::GetCharPref(const char *aPrefName, char **_retval) -{ - return mInitialized ? - mGConf->GetCharPref(aPrefName, _retval) : NS_ERROR_FAILURE; -} - -/* void setCharPref (in string aPrefName, in string aValue); */ -NS_IMETHODIMP nsSystemPrefService::SetCharPref(const char *aPrefName, const char *aValue) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* long getIntPref (in string aPrefName); */ -NS_IMETHODIMP nsSystemPrefService::GetIntPref(const char *aPrefName, PRInt32 *_retval) -{ - return mInitialized ? - mGConf->GetIntPref(aPrefName, _retval) : NS_ERROR_FAILURE; -} - -/* void setIntPref (in string aPrefName, in long aValue); */ -NS_IMETHODIMP nsSystemPrefService::SetIntPref(const char *aPrefName, PRInt32 aValue) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void getComplexValue (in string aPrefName, in nsIIDRef aType, [iid_is (aType), retval] out nsQIResult aValue); */ -NS_IMETHODIMP nsSystemPrefService::GetComplexValue(const char *aPrefName, const nsIID & aType, void * *aValue) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void setComplexValue (in string aPrefName, in nsIIDRef aType, in nsISupports aValue); */ -NS_IMETHODIMP nsSystemPrefService::SetComplexValue(const char *aPrefName, const nsIID & aType, nsISupports *aValue) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void clearUserPref (in string aPrefName); */ -NS_IMETHODIMP nsSystemPrefService::ClearUserPref(const char *aPrefName) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void lockPref (in string aPrefName); */ -NS_IMETHODIMP nsSystemPrefService::LockPref(const char *aPrefName) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* boolean prefHasUserValue (in string aPrefName); */ -NS_IMETHODIMP nsSystemPrefService::PrefHasUserValue(const char *aPrefName, bool *_retval) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* boolean prefIsLocked (in string aPrefName); */ -NS_IMETHODIMP nsSystemPrefService::PrefIsLocked(const char *aPrefName, bool *_retval) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void unlockPref (in string aPrefName); */ -NS_IMETHODIMP nsSystemPrefService::UnlockPref(const char *aPrefName) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void deleteBranch (in string aStartingAt); */ -NS_IMETHODIMP nsSystemPrefService::DeleteBranch(const char *aStartingAt) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void getChildList (in string aStartingAt, [optional] out unsigned long aCount, [array, size_is (aCount), retval] out string aChildArray); */ -NS_IMETHODIMP nsSystemPrefService::GetChildList(const char *aStartingAt, PRUint32 *aCount, char ***aChildArray) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void resetBranch (in string aStartingAt); */ -NS_IMETHODIMP nsSystemPrefService::ResetBranch(const char *aStartingAt) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void addObserver (in string aDomain, in nsIObserver aObserver, in boolean aHoldWeak); */ -NS_IMETHODIMP nsSystemPrefService::AddObserver(const char *aDomain, nsIObserver *aObserver, bool aHoldWeak) -{ - nsresult rv; - - NS_ENSURE_ARG_POINTER(aDomain); - NS_ENSURE_ARG_POINTER(aObserver); - - NS_ENSURE_TRUE(mInitialized, NS_ERROR_FAILURE); - - PRUint32 prefAtom; - // make sure the pref name is supported - rv = mGConf->GetAtomForMozKey(aDomain, &prefAtom); - NS_ENSURE_SUCCESS(rv, rv); - - if (!mObservers) { - mObservers = new nsAutoVoidArray(); - if (mObservers == nsnull) - return NS_ERROR_OUT_OF_MEMORY; - } - - SysPrefCallbackData *pCallbackData = (SysPrefCallbackData *) - nsMemory::Alloc(sizeof(SysPrefCallbackData)); - if (pCallbackData == nsnull) - return NS_ERROR_OUT_OF_MEMORY; - - pCallbackData->bIsWeakRef = aHoldWeak; - pCallbackData->prefAtom = prefAtom; - // hold a weak reference to the observer if so requested - nsCOMPtr observerRef; - if (aHoldWeak) { - nsCOMPtr weakRefFactory = - do_QueryInterface(aObserver); - if (!weakRefFactory) { - // the caller didn't give us a object that supports weak reference. - // ... tell them - nsMemory::Free(pCallbackData); - return NS_ERROR_INVALID_ARG; - } - nsCOMPtr tmp = do_GetWeakReference(weakRefFactory); - observerRef = tmp; - } else { - observerRef = aObserver; - } - - rv = mGConf->NotifyAdd(prefAtom, pCallbackData); - if (NS_FAILED(rv)) { - nsMemory::Free(pCallbackData); - return rv; - } - - pCallbackData->observer = observerRef; - NS_ADDREF(pCallbackData->observer); - - mObservers->AppendElement(pCallbackData); - return NS_OK; -} - -/* void removeObserver (in string aDomain, in nsIObserver aObserver); */ -NS_IMETHODIMP nsSystemPrefService::RemoveObserver(const char *aDomain, nsIObserver *aObserver) -{ - nsresult rv; - - NS_ENSURE_ARG_POINTER(aDomain); - NS_ENSURE_ARG_POINTER(aObserver); - NS_ENSURE_TRUE(mInitialized, NS_ERROR_FAILURE); - - if (!mObservers) - return NS_OK; - - PRUint32 prefAtom; - // make sure the pref name is supported - rv = mGConf->GetAtomForMozKey(aDomain, &prefAtom); - NS_ENSURE_SUCCESS(rv, rv); - - // need to find the index of observer, so we can remove it - PRIntn count = mObservers->Count(); - if (count <= 0) - return NS_OK; - - PRIntn i; - SysPrefCallbackData *pCallbackData; - for (i = 0; i < count; ++i) { - pCallbackData = (SysPrefCallbackData *)mObservers->ElementAt(i); - if (pCallbackData) { - nsCOMPtr observerRef; - if (pCallbackData->bIsWeakRef) { - nsCOMPtr weakRefFactory = - do_QueryInterface(aObserver); - if (weakRefFactory) { - nsCOMPtr tmp = - do_GetWeakReference(aObserver); - observerRef = tmp; - } - } - if (!observerRef) - observerRef = aObserver; - - if (pCallbackData->observer == observerRef && - pCallbackData->prefAtom == prefAtom) { - rv = mGConf->NotifyRemove(prefAtom, pCallbackData); - if (NS_SUCCEEDED(rv)) { - mObservers->RemoveElementAt(i); - NS_RELEASE(pCallbackData->observer); - nsMemory::Free(pCallbackData); - } - return rv; - } - } - } - return NS_OK; -} - -void -nsSystemPrefService::OnPrefChange(PRUint32 aPrefAtom, void *aData) -{ - if (!mInitialized) - return; - - SysPrefCallbackData *pData = (SysPrefCallbackData *)aData; - if (pData->prefAtom != aPrefAtom) - return; - - nsCOMPtr observer; - if (pData->bIsWeakRef) { - nsCOMPtr weakRef = - do_QueryInterface(pData->observer); - if(weakRef) - observer = do_QueryReferent(weakRef); - if (!observer) { - // this weak referenced observer went away, remove it from the list - nsresult rv = mGConf->NotifyRemove(aPrefAtom, pData); - if (NS_SUCCEEDED(rv)) { - mObservers->RemoveElement(pData); - NS_RELEASE(pData->observer); - nsMemory::Free(pData); - } - return; - } - } - else - observer = do_QueryInterface(pData->observer); - - if (observer) - observer->Observe(static_cast(this), - NS_SYSTEMPREF_PREFCHANGE_TOPIC_ID, - NS_ConvertUTF8toUTF16(mGConf->GetMozKey(aPrefAtom)). - get()); -} - -/************************************************************* - * GConfProxy - * - ************************************************************/ - -struct GConfFuncListType { - const char *FuncName; - PRFuncPtr FuncPtr; -}; - -struct PrefNamePair { - const char *mozPrefName; - const char *gconfPrefName; -}; - -const char -GConfProxy::sPrefGConfKey[] = "accessibility.unix.gconf2.shared-library"; -const char GConfProxy::sDefaultLibName1[] = "libgconf-2.so.4"; -const char GConfProxy::sDefaultLibName2[] = "libgconf-2.so"; - -#define GCONF_FUNCS_POINTER_BEGIN \ - static GConfFuncListType sGConfFuncList[] = { -#define GCONF_FUNCS_POINTER_ADD(func_name) \ - {func_name, nsnull}, -#define GCONF_FUNCS_POINTER_END \ - {nsnull, nsnull}, }; - -GCONF_FUNCS_POINTER_BEGIN - GCONF_FUNCS_POINTER_ADD("gconf_client_get_default") // 0 - GCONF_FUNCS_POINTER_ADD("gconf_client_get_bool") // 1 - GCONF_FUNCS_POINTER_ADD("gconf_client_get_string") //2 - GCONF_FUNCS_POINTER_ADD("gconf_client_get_int") //3 - GCONF_FUNCS_POINTER_ADD("gconf_client_notify_add") //4 - GCONF_FUNCS_POINTER_ADD("gconf_client_notify_remove") //5 - GCONF_FUNCS_POINTER_ADD("gconf_client_add_dir") //6 - GCONF_FUNCS_POINTER_ADD("gconf_client_remove_dir") //7 - GCONF_FUNCS_POINTER_ADD("gconf_entry_get_value") //8 - GCONF_FUNCS_POINTER_ADD("gconf_entry_get_key") //9 - GCONF_FUNCS_POINTER_ADD("gconf_value_get_bool") //10 - GCONF_FUNCS_POINTER_ADD("gconf_value_get_string") //11 - GCONF_FUNCS_POINTER_ADD("gconf_value_get_int") //12 - GCONF_FUNCS_POINTER_ADD("gconf_client_get_list") //13 -GCONF_FUNCS_POINTER_END - -///////////////////////////////////////////////////////////////////////////// -// the list is the mapping table, between mozilla prefs and gconf prefs -// It is expected to include all the pref pairs that are related in mozilla -// and gconf. -// -// Note: the prefs listed here are not neccessarily be read from gconf, they -// are the prefs that could be read from gconf. Mozilla has another -// list (see sSysPrefList in nsSystemPref.cpp) that decide which prefs -// are really read. -////////////////////////////////////////////////////////////////////////////// - -static const PrefNamePair sPrefNameMapping[] = { -#include "gconf_pref_list.inc" - {nsnull, nsnull}, -}; - -bool -gconfDeleteObserver(void *aElement, void *aData) { - nsMemory::Free(aElement); - return true; -} - -GConfProxy::GConfProxy(nsSystemPrefService *aSysPrefService): - mGConfClient(nsnull), - mGConfLib(nsnull), - mInitialized(false), - mSysPrefService(aSysPrefService), - mObservers(nsnull) -{ -} - -GConfProxy::~GConfProxy() -{ - if (mGConfClient) - g_object_unref(G_OBJECT(mGConfClient)); - - if (mObservers) { - (void)mObservers->EnumerateForwards(gconfDeleteObserver, nsnull); - delete mObservers; - } - - // bug 379666: can't unload GConf-2 since it registers atexit handlers - //PR_UnloadLibrary(mGConfLib); -} - -bool -GConfProxy::Init() -{ - SYSPREF_LOG(("GConfProxy:: Init GConfProxy\n")); - if (!mSysPrefService) - return false; - if (mInitialized) - return true; - - nsCOMPtr pref = do_GetService(NS_PREFSERVICE_CONTRACTID); - - if (!pref) - return false; - - nsXPIDLCString gconfLibName; - nsresult rv; - - //check if gconf-2 library is given in prefs - rv = pref->GetCharPref(sPrefGConfKey, getter_Copies(gconfLibName)); - if (NS_SUCCEEDED(rv)) { - //use the library name in the preference - SYSPREF_LOG(("GConf library in prefs is %s\n", gconfLibName.get())); - mGConfLib = PR_LoadLibrary(gconfLibName.get()); - } - else { - SYSPREF_LOG(("GConf library not specified in prefs, try the default: " - "%s and %s\n", sDefaultLibName1, sDefaultLibName2)); - mGConfLib = PR_LoadLibrary(sDefaultLibName1); - if (!mGConfLib) - mGConfLib = PR_LoadLibrary(sDefaultLibName2); - } - - if (!mGConfLib) { - SYSPREF_LOG(("Fail to load GConf library\n")); - return false; - } - - //check every func we need in the gconf library - GConfFuncListType *funcList; - PRFuncPtr func; - for (funcList = sGConfFuncList; funcList->FuncName; ++funcList) { - func = PR_FindFunctionSymbol(mGConfLib, funcList->FuncName); - if (!func) { - SYSPREF_LOG(("Check GConf Func Error: %s", funcList->FuncName)); - goto init_failed_unload; - } - funcList->FuncPtr = func; - } - - InitFuncPtrs(); - - mGConfClient = GConfClientGetDefault(); - - // Don't unload past this point, since GConf's initialization of ORBit - // causes atexit handlers to be registered. - - if (!mGConfClient) { - SYSPREF_LOG(("Fail to Get default gconf client\n")); - goto init_failed; - } - mInitialized = true; - return true; - - init_failed_unload: - PR_UnloadLibrary(mGConfLib); - init_failed: - mGConfLib = nsnull; - return false; -} - -nsresult -GConfProxy::GetBoolPref(const char *aMozKey, bool *retval) -{ - NS_ENSURE_TRUE(mInitialized, NS_ERROR_FAILURE); - *retval = GConfClientGetBool(mGConfClient, MozKey2GConfKey(aMozKey), NULL); - return NS_OK; -} - -nsresult -GConfProxy::GetCharPref(const char *aMozKey, char **retval) -{ - NS_ENSURE_TRUE(mInitialized, NS_ERROR_FAILURE); - - const gchar *gconfkey = MozKey2GConfKey(aMozKey); - - if (!strcmp (aMozKey, "network.proxy.no_proxies_on")) { - GSList *s; - nsCString noproxy; - GSList *gslist = GConfClientGetList(mGConfClient, gconfkey, - GCONF_VALUE_STRING, NULL); - - for (s = gslist; s; s = g_slist_next(s)) { - noproxy += (char *)s->data; - noproxy += ", "; - g_free ((char *)s->data); - } - g_slist_free (gslist); - - *retval = PL_strdup(noproxy.get()); - } else { - gchar *str = GConfClientGetString(mGConfClient, gconfkey, NULL); - if (str) { - *retval = PL_strdup(str); - g_free (str); - } - } - - return NS_OK; -} - -nsresult -GConfProxy::GetIntPref(const char *aMozKey, PRInt32 *retval) -{ - NS_ENSURE_TRUE(mInitialized, NS_ERROR_FAILURE); - if (strcmp (aMozKey, "network.proxy.type") == 0) { - gchar *str; - - str = GConfClientGetString(mGConfClient, - MozKey2GConfKey (aMozKey), NULL); - - if (str) { - if (strcmp (str, "manual") == 0) - *retval = 1; - else if (strcmp (str, "auto") == 0) - *retval = 2; - else - *retval = 0; - - g_free (str); - } else - *retval = 0; - } else { - *retval = GConfClientGetInt(mGConfClient, - MozKey2GConfKey(aMozKey), NULL); - } - - return NS_OK; -} - -nsresult -GConfProxy::NotifyAdd (PRUint32 aAtom, void *aUserData) -{ - NS_ENSURE_TRUE(mInitialized, NS_ERROR_FAILURE); - - const char *gconfKey = GetGConfKey(aAtom); - if (!gconfKey) - return NS_ERROR_FAILURE; - - if (!mObservers) { - mObservers = new nsAutoVoidArray(); - if (mObservers == nsnull) - return NS_ERROR_OUT_OF_MEMORY; - } - - GConfCallbackData *pData = (GConfCallbackData *) - nsMemory::Alloc(sizeof(GConfCallbackData)); - NS_ENSURE_TRUE(pData, NS_ERROR_OUT_OF_MEMORY); - - pData->proxy = this; - pData->userData = aUserData; - pData->atom = aAtom; - mObservers->AppendElement(pData); - - GConfClientAddDir(mGConfClient, gconfKey, - 0, // GCONF_CLIENT_PRELOAD_NONE, don't preload anything - NULL); - - pData->notifyId = GConfClientNotifyAdd(mGConfClient, gconfKey, - gconf_key_listener, pData, - NULL, NULL); - return NS_OK; -} - -nsresult -GConfProxy::NotifyRemove (PRUint32 aAtom, const void *aUserData) -{ - NS_ENSURE_TRUE(mInitialized, NS_ERROR_FAILURE); - - PRIntn count = mObservers->Count(); - if (count <= 0) - return NS_OK; - - PRIntn i; - GConfCallbackData *pData; - for (i = 0; i < count; ++i) { - pData = (GConfCallbackData *)mObservers->ElementAt(i); - if (pData && pData->atom == aAtom && pData->userData == aUserData) { - GConfClientNotifyRemove(mGConfClient, pData->notifyId); - GConfClientRemoveDir(mGConfClient, - GetGConfKey(pData->atom), NULL); - mObservers->RemoveElementAt(i); - nsMemory::Free(pData); - break; - } - } - return NS_OK; -} - -void -GConfProxy::InitFuncPtrs() -{ - //gconf client funcs - GConfClientGetDefault = - (GConfClientGetDefaultType) sGConfFuncList[0].FuncPtr; - GConfClientGetBool = - (GConfClientGetBoolType) sGConfFuncList[1].FuncPtr; - GConfClientGetString = - (GConfClientGetStringType) sGConfFuncList[2].FuncPtr; - GConfClientGetInt = - (GConfClientGetIntType) sGConfFuncList[3].FuncPtr; - GConfClientNotifyAdd = - (GConfClientNotifyAddType) sGConfFuncList[4].FuncPtr; - GConfClientNotifyRemove = - (GConfClientNotifyRemoveType) sGConfFuncList[5].FuncPtr; - GConfClientAddDir = - (GConfClientAddDirType) sGConfFuncList[6].FuncPtr; - GConfClientRemoveDir = - (GConfClientRemoveDirType) sGConfFuncList[7].FuncPtr; - - //gconf entry funcs - GConfEntryGetValue = (GConfEntryGetValueType) sGConfFuncList[8].FuncPtr; - GConfEntryGetKey = (GConfEntryGetKeyType) sGConfFuncList[9].FuncPtr; - - //gconf value funcs - GConfValueGetBool = (GConfValueGetBoolType) sGConfFuncList[10].FuncPtr; - GConfValueGetString = (GConfValueGetStringType) sGConfFuncList[11].FuncPtr; - GConfValueGetInt = (GConfValueGetIntType) sGConfFuncList[12].FuncPtr; - - //gconf client list func - GConfClientGetList = - (GConfClientGetListType) sGConfFuncList[13].FuncPtr; -} - -void -GConfProxy::OnNotify(void *aClient, void * aEntry, PRUint32 aNotifyId, - GConfCallbackData *aData) -{ - if (!mInitialized || !aEntry || (mGConfClient != aClient) || !aData) - return; - - if (GConfEntryGetValue(aEntry) == NULL) - return; - - PRUint32 prefAtom; - nsresult rv = GetAtomForGConfKey(GConfEntryGetKey(aEntry), &prefAtom); - if (NS_FAILED(rv)) - return; - - mSysPrefService->OnPrefChange(prefAtom, aData->userData); -} - -nsresult -GConfProxy::GetAtom(const char *aKey, PRUint8 aNameType, PRUint32 *aAtom) -{ - if (!aKey) - return NS_ERROR_FAILURE; - PRUint32 prefSize = sizeof(sPrefNameMapping) / sizeof(sPrefNameMapping[0]); - for (PRUint32 index = 0; index < prefSize; ++index) { - if (!strcmp((aNameType == 0) ? sPrefNameMapping[index].mozPrefName : - sPrefNameMapping[index].gconfPrefName, aKey)) { - *aAtom = index; - return NS_OK; - } - } - return NS_ERROR_FAILURE; -} - -const char * -GConfProxy::GetKey(PRUint32 aAtom, PRUint8 aNameType) -{ - PRUint32 mapSize = sizeof(sPrefNameMapping) / sizeof(sPrefNameMapping[0]); - if (aAtom >= 0 && aAtom < mapSize) - return (aNameType == 0) ? sPrefNameMapping[aAtom].mozPrefName : - sPrefNameMapping[aAtom].gconfPrefName; - return NULL; -} - -inline const char * -GConfProxy::MozKey2GConfKey(const char *aMozKey) -{ - PRUint32 atom; - nsresult rv = GetAtomForMozKey(aMozKey, &atom); - if (NS_SUCCEEDED(rv)) - return GetGConfKey(atom); - return NULL; -} - -/* static */ -void gconf_key_listener (void* client, guint cnxn_id, - void *entry, gpointer user_data) -{ - SYSPREF_LOG(("...SYSPREF_LOG...key listener get called \n")); - if (!user_data) - return; - GConfCallbackData *pData = reinterpret_cast - (user_data); - pData->proxy->OnNotify(client, entry, cnxn_id, pData); -} diff --git a/extensions/pref/system-pref/src/gconf/nsSystemPrefService.h b/extensions/pref/system-pref/src/gconf/nsSystemPrefService.h deleted file mode 100644 index 22ee30aee4f..00000000000 --- a/extensions/pref/system-pref/src/gconf/nsSystemPrefService.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * Portions created by Sun Microsystems are Copyright (C) 2003 Sun - * Microsystems, Inc. All Rights Reserved. - * - * Original Author: Bolian Yin (bolian.yin@sun.com) - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __SYSTEM_PREF_SERVICE_H__ -#define __SYSTEM_PREF_SERVICE_H__ - -#include "prlink.h" -#include "nsVoidArray.h" -#include "nsWeakPtr.h" -#include "nsIPrefBranch.h" -#include "nsIPrefBranch2.h" - -class GConfProxy; - -//////////////////////////////////////////////////////////////////////////// -// nsSystemPrefService provide a interface for read system prefs. It is -// platform related. This directory (system-pref/gconf) impls it for gconf -// on the gconf platform. -//////////////////////////////////////////////////////////////////////////// - -class nsSystemPrefService : public nsIPrefBranch2 -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIPREFBRANCH - NS_DECL_NSIPREFBRANCH2 - - nsSystemPrefService(); - virtual ~nsSystemPrefService(); - nsresult Init(); - - void OnPrefChange(PRUint32 aPrefAtom, void *aData); - -private: - bool mInitialized; - GConfProxy *mGConf; - - //listeners - nsAutoVoidArray *mObservers; -}; - -#define NS_SYSTEMPREF_SERVICE_CID \ - { /* {94f1de09-d0e5-4ca8-94c2-98b049316b7f} */ \ - 0x94f1de09, \ - 0xd0e5, \ - 0x4ca8, \ - { 0x94, 0xc2, 0x98, 0xb0, 0x49, 0x31, 0x6b, 0x7f } \ - } - -#define NS_SYSTEMPREF_SERVICE_CONTRACTID "@mozilla.org/system-preference-service;1" -#define NS_SYSTEMPREF_SERVICE_CLASSNAME "System Preferences Service" - -#define NS_SYSTEMPREF_PREFCHANGE_TOPIC_ID "nsSystemPrefService:pref-changed" - -#endif /* __SYSTEM_PREF_SERVICE_H__ */ diff --git a/extensions/pref/system-pref/src/nsSystemPref.cpp b/extensions/pref/system-pref/src/nsSystemPref.cpp deleted file mode 100644 index 110535c0923..00000000000 --- a/extensions/pref/system-pref/src/nsSystemPref.cpp +++ /dev/null @@ -1,474 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * Portions created by Sun Microsystems are Copyright (C) 2003 Sun - * Microsystems, Inc. All Rights Reserved. - * - * Original Author: Bolian Yin (bolian.yin@sun.com) - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsSystemPref.h" -#include "nsIObserverService.h" - -#include "nsSystemPrefLog.h" -#include "nsSystemPrefService.h" -#include "nsString.h" - -const char sSysPrefString[] = "config.use_system_prefs"; -union MozPrefValue { - char * stringVal; - PRInt32 intVal; - bool boolVal; -}; - -struct SysPrefItem { - const char *prefName; // mozilla pref string name - MozPrefValue defaultValue; // store the mozilla default value - bool isLocked; // store the mozilla lock status - SysPrefItem() { - prefName = nsnull; - defaultValue.intVal = 0; - defaultValue.stringVal = nsnull; - defaultValue.boolVal = false; - isLocked = false; - } - void SetPrefName(const char *aPrefName) { - prefName = aPrefName; - } -}; - -// all prefs that mozilla need to read from host system if they are available -static const char *sSysPrefList[] = { - "network.proxy.http", - "network.proxy.http_port", - "network.proxy.ftp", - "network.proxy.ftp_port", - "network.proxy.ssl", - "network.proxy.ssl_port", - "network.proxy.socks", - "network.proxy.socks_port", - "network.proxy.no_proxies_on", - "network.proxy.autoconfig_url", - "network.proxy.type", - "config.use_system_prefs.accessibility", -}; - -PRLogModuleInfo *gSysPrefLog = NULL; - -NS_IMPL_ISUPPORTS2(nsSystemPref, nsIObserver, nsISupportsWeakReference) - -nsSystemPref::nsSystemPref(): - mSysPrefService(nsnull), - mEnabled(false), - mSysPrefs(nsnull) -{ -} - -nsSystemPref::~nsSystemPref() -{ - mSysPrefService = nsnull; - mEnabled = false; - delete [] mSysPrefs; -} - -/////////////////////////////////////////////////////////////////////////////// -// nsSystemPref::Init -// Setup log and listen on NS_PREFSERVICE_READ_TOPIC_ID from pref service -/////////////////////////////////////////////////////////////////////////////// -nsresult -nsSystemPref::Init(void) -{ - nsresult rv; - - if (!gSysPrefLog) { - gSysPrefLog = PR_NewLogModule("Syspref"); - if (!gSysPrefLog) - return NS_ERROR_OUT_OF_MEMORY; - } - - nsCOMPtr observerService = - do_GetService("@mozilla.org/observer-service;1", &rv); - - if (observerService) { - rv = observerService->AddObserver(this, NS_PREFSERVICE_READ_TOPIC_ID, - false); - rv = observerService->AddObserver(this, "profile-before-change", - false); - SYSPREF_LOG(("Add Observer for %s\n", NS_PREFSERVICE_READ_TOPIC_ID)); - } - return(rv); -} - -/////////////////////////////////////////////////////////////////////////////// -// nsSystemPref::Observe -// Observe notifications from mozilla pref system and system prefs (if enabled) -/////////////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP -nsSystemPref::Observe(nsISupports *aSubject, - const char *aTopic, - const PRUnichar *aData) -{ - nsresult rv = NS_OK; - - if (!aTopic) - return NS_OK; - - // if we are notified by pref service - // check the system pref settings - if (!nsCRT::strcmp(aTopic, NS_PREFSERVICE_READ_TOPIC_ID)) { - SYSPREF_LOG(("Observed: %s\n", aTopic)); - - nsCOMPtr prefBranch = - do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - - rv = prefBranch->GetBoolPref(sSysPrefString, &mEnabled); - if (NS_FAILED(rv)) { - SYSPREF_LOG(("...FAil to Get %s\n", sSysPrefString)); - return rv; - } - - // if there is no system pref service, assume nothing happen to us - mSysPrefService = do_GetService(NS_SYSTEMPREF_SERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv) || !mSysPrefService) { - SYSPREF_LOG(("...No System Pref Service\n")); - return NS_OK; - } - - // listen on its changes - rv = prefBranch->AddObserver(sSysPrefString, this, true); - if (NS_FAILED(rv)) { - SYSPREF_LOG(("...FAil to add observer for %s\n", sSysPrefString)); - return rv; - } - - if (!mEnabled) { - SYSPREF_LOG(("%s is disabled\n", sSysPrefString)); - return NS_OK; - } - SYSPREF_LOG(("%s is enabled\n", sSysPrefString)); - rv = UseSystemPrefs(); - - } - // sSysPrefString value was changed, update ... - else if (!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) && - NS_ConvertUTF8toUTF16(sSysPrefString).Equals(aData)) { - SYSPREF_LOG(("++++++ Notify: topic=%s data=%s\n", - aTopic, NS_ConvertUTF16toUTF8(aData).get())); - - nsCOMPtr prefBranch = - do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - - bool enabled = mEnabled; - rv = prefBranch->GetBoolPref(sSysPrefString, &mEnabled); - if (enabled != mEnabled) { - if (mEnabled) - //read prefs from system - rv = UseSystemPrefs(); - else - //roll back to mozilla prefs - rv = UseMozillaPrefs(); - } - } - - // if the system pref notify us that some pref has been changed by user - // outside mozilla. We need to read it again. - else if (!nsCRT::strcmp(aTopic, NS_SYSTEMPREF_PREFCHANGE_TOPIC_ID) && - aData) { - NS_ASSERTION(mEnabled, "Should not listen when disabled"); - SYSPREF_LOG(("====== System Pref Notify topic=%s data=%s\n", - aTopic, (char*)aData)); - rv = ReadSystemPref(NS_LossyConvertUTF16toASCII(aData).get()); - return NS_OK; - } else if (!nsCRT::strcmp(aTopic,"profile-before-change")) { - //roll back to mozilla prefs - if (mEnabled) - UseMozillaPrefs(); - mEnabled = false; - mSysPrefService = nsnull; - delete [] mSysPrefs; - mSysPrefs = nsnull; - } else - SYSPREF_LOG(("Not needed topic Received %s\n", aTopic)); - return rv; -} - -/* private */ - -//////////////////////////////////////////////////////////////// -// nsSystemPref::UseSystemPrefs -// Read all the prefs in the table from system, listen for their -// changes in system pref service. -//////////////////////////////////////////////////////////////// -nsresult -nsSystemPref::UseSystemPrefs() -{ - SYSPREF_LOG(("\n====Now Use system prefs==\n")); - nsresult rv = NS_OK; - if (!mSysPrefService) { - return NS_ERROR_FAILURE; - } - - PRIntn sysPrefCount= sizeof(sSysPrefList) / sizeof(sSysPrefList[0]); - - if (!mSysPrefs) { - mSysPrefs = new SysPrefItem[sysPrefCount]; - if (!mSysPrefs) - return NS_ERROR_OUT_OF_MEMORY; - for (PRIntn index = 0; index < sysPrefCount; ++index) - mSysPrefs[index].SetPrefName(sSysPrefList[index]); - } - - for (PRIntn index = 0; index < sysPrefCount; ++index) { - // save mozilla prefs - SaveMozDefaultPref(mSysPrefs[index].prefName, - &mSysPrefs[index].defaultValue, - &mSysPrefs[index].isLocked); - - // get the system prefs - ReadSystemPref(mSysPrefs[index].prefName); - SYSPREF_LOG(("Add Listener on %s\n", mSysPrefs[index].prefName)); - mSysPrefService->AddObserver(mSysPrefs[index].prefName, - this, true); - } - return rv; -} - -////////////////////////////////////////////////////////////////////// -// nsSystemPref::ReadSystemPref -// Read a pref value from system pref service, and lock it in mozilla. -////////////////////////////////////////////////////////////////////// -nsresult -nsSystemPref::ReadSystemPref(const char *aPrefName) -{ - if (!mSysPrefService) - return NS_ERROR_FAILURE; - nsresult rv; - - nsCOMPtr prefBranch - (do_GetService(NS_PREFSERVICE_CONTRACTID, &rv)); - if (NS_FAILED(rv)) - return rv; - - SYSPREF_LOG(("about to read aPrefName %s\n", aPrefName)); - - prefBranch->UnlockPref(aPrefName); - - PRInt32 prefType = nsIPrefBranch::PREF_INVALID; - nsXPIDLCString strValue; - PRInt32 intValue = 0; - bool boolValue = false; - - rv = prefBranch->GetPrefType(aPrefName, &prefType); - if (NS_FAILED(rv)) - return rv; - switch (prefType) { - case nsIPrefBranch::PREF_STRING: - mSysPrefService->GetCharPref(aPrefName, getter_Copies(strValue)); - SYSPREF_LOG(("system value is %s\n", strValue.get())); - - prefBranch->SetCharPref(aPrefName, strValue.get()); - break; - case nsIPrefBranch::PREF_INT: - mSysPrefService->GetIntPref(aPrefName, &intValue); - SYSPREF_LOG(("system value is %d\n", intValue)); - - prefBranch->SetIntPref(aPrefName, intValue); - break; - case nsIPrefBranch::PREF_BOOL: - mSysPrefService->GetBoolPref(aPrefName, &boolValue); - SYSPREF_LOG(("system value is %s\n", boolValue ? "TRUE" : "FALSE")); - - prefBranch->SetBoolPref(aPrefName, boolValue); - break; - default: - SYSPREF_LOG(("Fail to system value for it\n")); - return NS_ERROR_FAILURE; - } - prefBranch->LockPref(aPrefName); - return NS_OK; -} - -////////////////////////////////////////////////////////////////////// -// nsSystemPref::UseMozillaPrefs -// Restore mozilla default prefs, remove system pref listeners -///////////////////////////////////////////////////////////////////// -nsresult -nsSystemPref::UseMozillaPrefs() -{ - nsresult rv = NS_OK; - SYSPREF_LOG(("\n====Now rollback to Mozilla prefs==\n")); - - // if we did not use system prefs, do nothing - if (!mSysPrefService) - return NS_OK; - - PRIntn sysPrefCount= sizeof(sSysPrefList) / sizeof(sSysPrefList[0]); - for (PRIntn index = 0; index < sysPrefCount; ++index) { - // restore mozilla default value and free string memory if needed - RestoreMozDefaultPref(mSysPrefs[index].prefName, - &mSysPrefs[index].defaultValue, - mSysPrefs[index].isLocked); - SYSPREF_LOG(("stop listening on %s\n", mSysPrefs[index].prefName)); - mSysPrefService->RemoveObserver(mSysPrefs[index].prefName, - this); - } - return rv; -} - -//////////////////////////////////////////////////////////////////////////// -// nsSystemPref::RestoreMozDefaultPref -// Save the saved mozilla default value. -// It is also responsible for allocate the string memory when needed, because -// this method know what type of value is stored. -///////////////////////////////////////////////////////////////////////////// -nsresult -nsSystemPref::SaveMozDefaultPref(const char *aPrefName, - MozPrefValue *aPrefValue, - bool *aLocked) -{ - NS_ENSURE_ARG_POINTER(aPrefName); - NS_ENSURE_ARG_POINTER(aPrefValue); - NS_ENSURE_ARG_POINTER(aLocked); - - nsresult rv; - - nsCOMPtr prefBranch = - do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - - SYSPREF_LOG(("Save Mozilla value for %s\n", aPrefName)); - - PRInt32 prefType = nsIPrefBranch::PREF_INVALID; - nsXPIDLCString strValue; - - rv = prefBranch->GetPrefType(aPrefName, &prefType); - if (NS_FAILED(rv)) - return rv; - switch (prefType) { - case nsIPrefBranch::PREF_STRING: - prefBranch->GetCharPref(aPrefName, - getter_Copies(strValue)); - SYSPREF_LOG(("Mozilla value is %s", strValue.get())); - - if (aPrefValue->stringVal) - PL_strfree(aPrefValue->stringVal); - aPrefValue->stringVal = PL_strdup(strValue.get()); - break; - case nsIPrefBranch::PREF_INT: - prefBranch->GetIntPref(aPrefName, &aPrefValue->intVal); - SYSPREF_LOG(("Mozilla value is %d\n", aPrefValue->intVal)); - - break; - case nsIPrefBranch::PREF_BOOL: - prefBranch->GetBoolPref(aPrefName, &aPrefValue->boolVal); - SYSPREF_LOG(("Mozilla value is %s\n", - aPrefValue->boolVal ? "TRUE" : "FALSE")); - - break; - default: - SYSPREF_LOG(("Fail to Read Mozilla value for it\n")); - return NS_ERROR_FAILURE; - } - rv = prefBranch->PrefIsLocked(aPrefName, aLocked); - SYSPREF_LOG((" (%s).\n", aLocked ? "Locked" : "NOT Locked")); - return rv; -} - -//////////////////////////////////////////////////////////////////////////// -// nsSystemPref::RestoreMozDefaultPref -// Restore the saved mozilla default value to pref service. -// It is also responsible for free the string memory when needed, because -// this method know what type of value is stored. -///////////////////////////////////////////////////////////////////////////// -nsresult -nsSystemPref::RestoreMozDefaultPref(const char *aPrefName, - MozPrefValue *aPrefValue, - bool aLocked) -{ - NS_ENSURE_ARG_POINTER(aPrefName); - - nsresult rv; - - nsCOMPtr prefBranch = - do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - - SYSPREF_LOG(("Restore Mozilla value for %s\n", aPrefName)); - - PRInt32 prefType = nsIPrefBranch::PREF_INVALID; - rv = prefBranch->GetPrefType(aPrefName, &prefType); - if (NS_FAILED(rv)) - return rv; - - // unlock, if it is locked - prefBranch->UnlockPref(aPrefName); - - switch (prefType) { - case nsIPrefBranch::PREF_STRING: - prefBranch->SetCharPref(aPrefName, - aPrefValue->stringVal); - SYSPREF_LOG(("Mozilla value is %s\n", aPrefValue->stringVal)); - - PL_strfree(aPrefValue->stringVal); - aPrefValue->stringVal = nsnull; - - break; - case nsIPrefBranch::PREF_INT: - prefBranch->SetIntPref(aPrefName, aPrefValue->intVal); - SYSPREF_LOG(("Mozilla value is %d\n", aPrefValue->intVal)); - - break; - case nsIPrefBranch::PREF_BOOL: - prefBranch->SetBoolPref(aPrefName, aPrefValue->boolVal); - SYSPREF_LOG(("Mozilla value is %s\n", - aPrefValue->boolVal ? "TRUE" : "FALSE")); - - break; - default: - SYSPREF_LOG(("Fail to Restore Mozilla value for it\n")); - return NS_ERROR_FAILURE; - } - - // restore its old lock status - if (aLocked) - prefBranch->LockPref(aPrefName); - return NS_OK; -} diff --git a/extensions/pref/system-pref/src/nsSystemPref.h b/extensions/pref/system-pref/src/nsSystemPref.h deleted file mode 100644 index 2ef66d143b0..00000000000 --- a/extensions/pref/system-pref/src/nsSystemPref.h +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * Portions created by Sun Microsystems are Copyright (C) 2003 Sun - * Microsystems, Inc. All Rights Reserved. - * - * Original Author: Bolian Yin (bolian.yin@sun.com) - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __SYSTEM_PREF_H__ -#define __SYSTEM_PREF_H__ - -#include "nsCOMPtr.h" -#include "nsXPCOM.h" -#include "nsCRT.h" -#include "nsIAppStartupNotifier.h" -#include "nsICategoryManager.h" -#include "nsIServiceManager.h" -#include "nsWeakReference.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch2.h" - -#include - -union MozPrefValue; -struct SysPrefItem; - -////////////////////////////////////////////////////////////////////////// -// -// nsSystemPref, as an extension of mozilla pref service, reads some mozilla -// prefs from host system when the feature is enabled ("config.system-pref"). -// -// nsSystemPref listens on NS_PREFSERVICE_READ_TOPIC_ID. When notified, -// nsSystemPref will start the nsSystemPrefService (platform specific) to -// read all the interested prefs (listed in sSysPrefList table) from system -// and lock these prefs from user's modification. -// -// This feature will make mozilla integrated better into host platforms. If -// users want to change the prefs read from system, the system provided pref -// editor (i.e. gconf-editor in gnome) should be used. -////////////////////////////////////////////////////////////////////////// - -class nsSystemPref : public nsIObserver, - public nsSupportsWeakReference -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - - nsSystemPref(); - virtual ~nsSystemPref(); - nsresult Init(void); - -private: - // funcs used to load system prefs and save mozilla default prefs - nsresult UseSystemPrefs(); - nsresult ReadSystemPref(const char *aPrefName); - nsresult SaveMozDefaultPref(const char *aPrefName, - MozPrefValue *aPrefVal, - bool *aLocked); - - // funcs used to load mozilla default prefs - nsresult UseMozillaPrefs(); - nsresult RestoreMozDefaultPref(const char *aPrefName, - MozPrefValue *aPrefVal, - bool aLocked); - - nsCOMPtr mSysPrefService; - bool mEnabled; // system pref is enabled or not - SysPrefItem *mSysPrefs; -}; - -#define NS_SYSTEMPREF_CID \ - { /* {549abb24-7c9d-4aba-915e-7ce0b716b32f} */ \ - 0x549abb24, \ - 0x7c9d, \ - 0x4aba, \ - { 0x91, 0x5e, 0x7c, 0xe0, 0xb7, 0x16, 0xb3, 0x2f } \ - } - -#define NS_SYSTEMPREF_CONTRACTID "@mozilla.org/system-preferences;1" -#define NS_SYSTEMPREF_CLASSNAME "System Preferences" - -#endif /* __SYSTEM_PREF_H__ */ diff --git a/extensions/pref/system-pref/src/nsSystemPrefFactory.cpp b/extensions/pref/system-pref/src/nsSystemPrefFactory.cpp deleted file mode 100644 index 1f2ae5d273f..00000000000 --- a/extensions/pref/system-pref/src/nsSystemPrefFactory.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * Portions created by Sun Microsystems are Copyright (C) 2003 Sun - * Microsystems, Inc. All Rights Reserved. - * - * Original Author: Bolian Yin (bolian.yin@sun.com) - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsICategoryManager.h" -#include "mozilla/ModuleUtils.h" -#include "nsSystemPref.h" -#include "nsSystemPrefService.h" - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemPref, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemPrefService, Init) - -NS_DEFINE_NAMED_CID(NS_SYSTEMPREF_CID); -NS_DEFINE_NAMED_CID(NS_SYSTEMPREF_SERVICE_CID); - -static const mozilla::Module::CIDEntry kSysPrefCIDs[] = { - { &kNS_SYSTEMPREF_CID, false, NULL, nsSystemPrefConstructor }, - { &kNS_SYSTEMPREF_SERVICE_CID, false, NULL, nsSystemPrefServiceConstructor }, - { NULL } -}; - -static const mozilla::Module::ContractIDEntry kSysPrefContracts[] = { - { NS_SYSTEMPREF_CONTRACTID, &kNS_SYSTEMPREF_CID }, - { NS_SYSTEMPREF_SERVICE_CONTRACTID, &kNS_SYSTEMPREF_SERVICE_CID }, - { NULL } -}; - -static const mozilla::Module::CategoryEntry kSysPrefCategories[] = { - { APPSTARTUP_CATEGORY, "SystemPref Module", NS_SYSTEMPREF_CONTRACTID }, - { NULL } -}; - -static const mozilla::Module kSysPrefModule = { - mozilla::Module::kVersion, - kSysPrefCIDs, - kSysPrefContracts, - kSysPrefCategories -}; - -NSMODULE_DEFN(nsSystemPrefModule) = &kSysPrefModule; diff --git a/extensions/pref/system-pref/src/nsSystemPrefLog.h b/extensions/pref/system-pref/src/nsSystemPrefLog.h deleted file mode 100644 index fadb47eba90..00000000000 --- a/extensions/pref/system-pref/src/nsSystemPrefLog.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Sun Microsystems, Inc. - * Portions created by Sun Microsystems are Copyright (C) 2003 Sun - * Microsystems, Inc. All Rights Reserved. - * - * Original Author: Bolian Yin (bolian.yin@sun.com) - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "prlog.h" - -extern PRLogModuleInfo *gSysPrefLog; -#define SYSPREF_LOG(args) PR_LOG(gSysPrefLog, PR_LOG_DEBUG, args) diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index b1ded450499..f13a7b89f67 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -288,9 +288,6 @@ endif ifdef MOZ_ENABLE_GTK2 COMPONENT_LIBS += widget_gtk2 -ifdef MOZ_PREF_EXTENSIONS -COMPONENT_LIBS += system-pref -endif endif ifdef MOZ_ENABLE_GTK2 diff --git a/toolkit/library/nsStaticXULComponents.cpp b/toolkit/library/nsStaticXULComponents.cpp index f040d18e1b6..97c404edaed 100644 --- a/toolkit/library/nsStaticXULComponents.cpp +++ b/toolkit/library/nsStaticXULComponents.cpp @@ -104,7 +104,6 @@ #ifdef MOZ_PREF_EXTENSIONS #ifdef MOZ_ENABLE_GTK2 #define SYSTEMPREF_MODULES \ - MODULE(nsSystemPrefModule) \ MODULE(nsAutoConfigModule) #else #define SYSTEMPREF_MODULES MODULE(nsAutoConfigModule) From 314facaa0cb09338b8baf2a6955df729030a3138 Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Sat, 26 Nov 2011 20:50:05 +0100 Subject: [PATCH 12/31] Bug 451161 - Part 3: Reverse the reading order of user prefs and AutoConfig. r=roc --- modules/libpref/src/Preferences.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/libpref/src/Preferences.cpp b/modules/libpref/src/Preferences.cpp index c2bceeb7fa7..57796443bbd 100644 --- a/modules/libpref/src/Preferences.cpp +++ b/modules/libpref/src/Preferences.cpp @@ -401,11 +401,11 @@ Preferences::ReadUserPrefs(nsIFile *aFile) nsresult rv; if (nsnull == aFile) { - rv = UseDefaultPrefFile(); - UseUserPrefFile(); NotifyServiceObservers(NS_PREFSERVICE_READ_TOPIC_ID); + rv = UseDefaultPrefFile(); + UseUserPrefFile(); } else { rv = ReadAndOwnUserPrefFile(aFile); } From 6bc4a658d362e92ac0ff2a8ff9de6d6e0418d0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Sat, 26 Nov 2011 16:05:17 -0500 Subject: [PATCH 13/31] Bug 705461 - Use MOZ_CHECK_HEADER(S) everywhere. r=neil. --- build/autoconf/mozheader.m4 | 9 ++-- configure.in | 4 +- js/src/aclocal.m4 | 1 + js/src/build/autoconf/mozheader.m4 | 66 ++++++++++++++++++++++++++++++ js/src/configure.in | 56 ++++++++++++------------- 5 files changed, 102 insertions(+), 34 deletions(-) create mode 100644 js/src/build/autoconf/mozheader.m4 diff --git a/build/autoconf/mozheader.m4 b/build/autoconf/mozheader.m4 index a1c2a3c740e..50b3189944c 100644 --- a/build/autoconf/mozheader.m4 +++ b/build/autoconf/mozheader.m4 @@ -36,13 +36,14 @@ dnl the terms of any one of the MPL, the GPL or the LGPL. dnl dnl ***** END LICENSE BLOCK ***** -dnl MOZ_CHECK_HEADER(HEADER-FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl MOZ_CHECK_HEADER(HEADER-FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]]) AC_DEFUN([MOZ_CHECK_HEADER], [ dnl Do the transliteration at runtime so arg 1 can be a shell variable. ac_safe=`echo "$1" | sed 'y%./+-%__p_%'` AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(ac_cv_header_$ac_safe, - [ AC_TRY_COMPILE([#include <$1>], , + [ AC_TRY_COMPILE([$4 +#include <$1>], , eval "ac_cv_header_$ac_safe=yes", eval "ac_cv_header_$ac_safe=no") ]) if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then @@ -54,12 +55,12 @@ AC_DEFUN([MOZ_CHECK_HEADER], fi ]) -dnl MOZ_CHECK_HEADERS(HEADER-FILE... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl MOZ_CHECK_HEADERS(HEADER-FILE... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]]) AC_DEFUN([MOZ_CHECK_HEADERS], [ for ac_hdr in $1 do MOZ_CHECK_HEADER($ac_hdr, [ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - AC_DEFINE_UNQUOTED($ac_tr_hdr) $2], $3) + AC_DEFINE_UNQUOTED($ac_tr_hdr) $2], $3, [$4]) done ]) diff --git a/configure.in b/configure.in index 0fe873a72a1..3c6c7a81b1d 100644 --- a/configure.in +++ b/configure.in @@ -8760,8 +8760,8 @@ if test "$USE_FC_FREETYPE"; then if test "$COMPILE_ENVIRONMENT"; then _SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS" - AC_CHECK_HEADERS(fontconfig/fcfreetype.h, , - [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)]) + MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], , + [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include ]) CPPFLAGS="$_SAVE_CPPFLAGS" else AC_DEFINE(HAVE_FONTCONFIG_FCFREETYPE_H) diff --git a/js/src/aclocal.m4 b/js/src/aclocal.m4 index 144a8641298..e3ac8aa0d2e 100644 --- a/js/src/aclocal.m4 +++ b/js/src/aclocal.m4 @@ -8,6 +8,7 @@ builtin(include, build/autoconf/nspr.m4)dnl builtin(include, build/autoconf/altoptions.m4)dnl builtin(include, build/autoconf/moznbytetype.m4)dnl builtin(include, build/autoconf/mozprog.m4)dnl +builtin(include, build/autoconf/mozheader.m4)dnl builtin(include, build/autoconf/acwinpaths.m4)dnl builtin(include, build/autoconf/lto.m4)dnl builtin(include, build/autoconf/gcc-pr49911.m4)dnl diff --git a/js/src/build/autoconf/mozheader.m4 b/js/src/build/autoconf/mozheader.m4 new file mode 100644 index 00000000000..50b3189944c --- /dev/null +++ b/js/src/build/autoconf/mozheader.m4 @@ -0,0 +1,66 @@ +dnl ***** BEGIN LICENSE BLOCK ***** +dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1 +dnl +dnl The contents of this file are subject to the Mozilla Public License Version +dnl 1.1 (the "License"); you may not use this file except in compliance with +dnl the License. You may obtain a copy of the License at +dnl http://www.mozilla.org/MPL/ +dnl +dnl Software distributed under the License is distributed on an "AS IS" basis, +dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +dnl for the specific language governing rights and limitations under the +dnl License. +dnl +dnl The Original Code is mozilla.org code. +dnl +dnl The Initial Developer of the Original Code is the +dnl Mozilla Foundation +dnl +dnl Portions created by the Initial Developer are Copyright (C) 2009 +dnl the Initial Developer. All Rights Reserved. +dnl +dnl Contributor(s): +dnl Neil Rashbrook +dnl +dnl Alternatively, the contents of this file may be used under the terms of +dnl either of the GNU General Public License Version 2 or later (the "GPL"), +dnl or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +dnl in which case the provisions of the GPL or the LGPL are applicable instead +dnl of those above. If you wish to allow use of your version of this file only +dnl under the terms of either the GPL or the LGPL, and not to allow others to +dnl use your version of this file under the terms of the MPL, indicate your +dnl decision by deleting the provisions above and replace them with the notice +dnl and other provisions required by the GPL or the LGPL. If you do not delete +dnl the provisions above, a recipient may use your version of this file under +dnl the terms of any one of the MPL, the GPL or the LGPL. +dnl +dnl ***** END LICENSE BLOCK ***** + +dnl MOZ_CHECK_HEADER(HEADER-FILE, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]]) +AC_DEFUN([MOZ_CHECK_HEADER], +[ dnl Do the transliteration at runtime so arg 1 can be a shell variable. + ac_safe=`echo "$1" | sed 'y%./+-%__p_%'` + AC_MSG_CHECKING([for $1]) + AC_CACHE_VAL(ac_cv_header_$ac_safe, + [ AC_TRY_COMPILE([$4 +#include <$1>], , + eval "ac_cv_header_$ac_safe=yes", + eval "ac_cv_header_$ac_safe=no") ]) + if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + ifelse([$3], , , [$3]) + fi +]) + +dnl MOZ_CHECK_HEADERS(HEADER-FILE... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]]) +AC_DEFUN([MOZ_CHECK_HEADERS], +[ for ac_hdr in $1 + do + MOZ_CHECK_HEADER($ac_hdr, + [ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + AC_DEFINE_UNQUOTED($ac_tr_hdr) $2], $3, [$4]) + done +]) diff --git a/js/src/configure.in b/js/src/configure.in index cfefdda9497..35ef358c55a 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -803,7 +803,7 @@ case "$target" in # Identify which version of the SDK we're building with # Windows Server 2008 and newer SDKs have WinSDKVer.h, get the version # from there - AC_CHECK_HEADERS([winsdkver.h]) + MOZ_CHECK_HEADERS([winsdkver.h]) if test "$ac_cv_header_winsdkver_h" = "yes"; then # Get the highest _WIN32_WINNT and NTDDI versions supported # Take the higher of the two @@ -830,7 +830,7 @@ EOF else # The Vista SDK is the only one to have sdkddkver.h but not # WinSDKVer.h - AC_CHECK_HEADERS([sdkddkver.h]) + MOZ_CHECK_HEADERS([sdkddkver.h]) if test "$ac_cv_header_sdkddkver_h" = "yes"; then MOZ_WINSDK_MAXVER=0x06000000 else @@ -1190,7 +1190,7 @@ tools are selected during the Xcode/Developer Tools installation.]) CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}" CXXFLAGS="$CXXFLAGS -isysroot ${MACOS_SDK_DIR}" - dnl CPP/CXXCPP needs to be set for AC_CHECK_HEADER. + dnl CPP/CXXCPP needs to be set for MOZ_CHECK_HEADER. CPP="$CPP -isysroot ${MACOS_SDK_DIR}" CXXCPP="$CXXCPP -isysroot ${MACOS_SDK_DIR}" @@ -2164,7 +2164,7 @@ case "$target" in ;; esac if test "$COMPILE_ENVIRONMENT"; then - AC_CHECK_HEADERS(sys/inttypes.h) + MOZ_CHECK_HEADERS(sys/inttypes.h) fi AC_DEFINE(JS_SYS_TYPES_H_DEFINES_EXACT_SIZE_TYPES) AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES) @@ -2501,7 +2501,7 @@ ia64*-hpux*) CXXFLAGS="$CXXFLAGS -mstackrealign" fi - AC_CHECK_HEADERS(mmintrin.h) + MOZ_CHECK_HEADERS(mmintrin.h) AC_DEFINE(_X86_) ;; x86_64-*) @@ -2926,7 +2926,7 @@ dnl ======================================================== dnl Once this is working, we can delete the code for int16_t, dnl etc. below. -AC_CHECK_HEADER(stdint.h) +MOZ_CHECK_HEADER(stdint.h) if test "$ac_cv_header_stdint_h" = yes; then AC_DEFINE(JS_HAVE_STDINT_H) else @@ -2954,12 +2954,12 @@ fi MOZ_ALIGN_OF_TYPE(JS_ALIGN_OF_POINTER, void*, 2 4 8 16) MOZ_SIZE_OF_TYPE(JS_BYTES_PER_DOUBLE, double, 6 8 10 12 14) -AC_CHECK_HEADERS(endian.h) +MOZ_CHECK_HEADERS(endian.h) if test "$ac_cv_header_endian_h" = yes; then AC_DEFINE(JS_HAVE_ENDIAN_H) fi -AC_CHECK_HEADERS(sys/isa_defs.h) +MOZ_CHECK_HEADERS(sys/isa_defs.h) if test "$ac_cv_header_sys_isa_defs_h" = yes; then AC_DEFINE(JS_HAVE_SYS_ISA_DEFS_H) fi @@ -3248,30 +3248,30 @@ freebsd*) CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}" ;; esac -AC_CHECK_HEADERS(sys/byteorder.h compat.h getopt.h) -AC_CHECK_HEADERS(sys/bitypes.h memory.h unistd.h) -AC_CHECK_HEADERS(gnu/libc-version.h nl_types.h) -AC_CHECK_HEADERS(malloc.h) -AC_CHECK_HEADERS(X11/XKBlib.h) -AC_CHECK_HEADERS(io.h) +MOZ_CHECK_HEADERS(sys/byteorder.h compat.h getopt.h) +MOZ_CHECK_HEADERS(sys/bitypes.h memory.h unistd.h) +MOZ_CHECK_HEADERS(gnu/libc-version.h nl_types.h) +MOZ_CHECK_HEADERS(malloc.h) +MOZ_CHECK_HEADERS(X11/XKBlib.h) +MOZ_CHECK_HEADERS(io.h) dnl These are all the places some variant of statfs can be hiding. -AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h) +MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h) dnl Quota support -AC_CHECK_HEADERS(sys/quota.h) -AC_CHECK_HEADERS(linux/quota.h) +MOZ_CHECK_HEADERS(sys/quota.h) +MOZ_CHECK_HEADERS(linux/quota.h) dnl Try for MMX support dnl NB - later gcc versions require -mmmx for this header to be successfully dnl included (or another option which implies it, such as -march=pentium-mmx) -AC_CHECK_HEADERS(mmintrin.h) +MOZ_CHECK_HEADERS(mmintrin.h) dnl Check whether the compiler supports the new-style C++ standard dnl library headers (i.e. ) or needs the old "new.h" AC_LANG_CPLUSPLUS NEW_H=new.h -AC_CHECK_HEADER(new, [NEW_H=new]) +MOZ_CHECK_HEADER(new, [NEW_H=new]) AC_DEFINE_UNQUOTED(NEW_H, <$NEW_H>) AC_LANG_C @@ -3279,7 +3279,7 @@ AC_ARG_ENABLE(dtrace, [ --enable-dtrace build with dtrace support if available (default=no)], [enable_dtrace="yes"],) if test "x$enable_dtrace" = "xyes"; then - AC_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1) + MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1) if test -n "$HAVE_DTRACE"; then AC_DEFINE(INCLUDE_MOZILLA_DTRACE) else @@ -3292,12 +3292,12 @@ case $target in *-aix4.3*|*-aix5*) ;; *) - AC_CHECK_HEADERS(sys/cdefs.h) + MOZ_CHECK_HEADERS(sys/cdefs.h) ;; esac dnl Performance measurement headers. -AC_CHECK_HEADER(linux/perf_event.h, +MOZ_CHECK_HEADER(linux/perf_event.h, [AC_CACHE_CHECK(for perf_event_open system call,ac_cv_perf_event_open, [AC_TRY_COMPILE([#include ],[return sizeof(__NR_perf_event_open);], ac_cv_perf_event_open=yes, @@ -3332,7 +3332,7 @@ case $target in ;; *) AC_SEARCH_LIBS(dlopen, dl, - AC_CHECK_HEADER(dlfcn.h, + MOZ_CHECK_HEADER(dlfcn.h, AC_DEFINE(HAVE_DLOPEN))) ;; esac @@ -3905,11 +3905,11 @@ fi dnl Check for the existence of various allocation headers/functions MALLOC_H= -AC_CHECK_HEADER(malloc.h, [MALLOC_H=malloc.h]) +MOZ_CHECK_HEADER(malloc.h, [MALLOC_H=malloc.h]) if test "$MALLOC_H" = ""; then - AC_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h]) + MOZ_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h]) if test "$MALLOC_H" = ""; then - AC_CHECK_HEADER(sys/malloc.h, [MALLOC_H=sys/malloc.h]) + MOZ_CHECK_HEADER(sys/malloc.h, [MALLOC_H=sys/malloc.h]) fi fi if test "$MALLOC_H" != ""; then @@ -4462,7 +4462,7 @@ MOZ_ARG_ENABLE_BOOL(valgrind, MOZ_VALGRIND=1, MOZ_VALGRIND= ) if test -n "$MOZ_VALGRIND"; then - AC_CHECK_HEADER([valgrind/valgrind.h], [], + MOZ_CHECK_HEADER([valgrind/valgrind.h], [], AC_MSG_ERROR( [--enable-valgrind specified but Valgrind is not installed])) AC_DEFINE(MOZ_VALGRIND) @@ -4667,7 +4667,7 @@ dnl ======================================================== dnl = Support for gcc stack unwinding (from gcc 3.3) dnl ======================================================== if test -z "$SKIP_LIBRARY_CHECKS"; then - AC_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace)) + MOZ_CHECK_HEADER(unwind.h, AC_CHECK_FUNCS(_Unwind_Backtrace)) fi dnl ======================================================== From c51f52233071e5327405a0fea59f7d51f6ebe008 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Sun, 27 Nov 2011 09:36:36 +0900 Subject: [PATCH 14/31] Bug 697842 stopPropagation() shouldn't break IME composition r=ehsan --- .../libeditor/base/nsEditorEventListener.cpp | 18 ++- editor/libeditor/html/tests/Makefile.in | 1 + .../libeditor/html/tests/test_bug697842.html | 125 ++++++++++++++++++ .../mochitest/tests/SimpleTest/EventUtils.js | 6 + 4 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 editor/libeditor/html/tests/test_bug697842.html diff --git a/editor/libeditor/base/nsEditorEventListener.cpp b/editor/libeditor/base/nsEditorEventListener.cpp index e86aa73d48f..74eaef2d2a0 100644 --- a/editor/libeditor/base/nsEditorEventListener.cpp +++ b/editor/libeditor/base/nsEditorEventListener.cpp @@ -203,13 +203,16 @@ nsEditorEventListener::InstallToEditor() NS_EVENT_FLAG_CAPTURE); elmP->AddEventListenerByType(this, NS_LITERAL_STRING("text"), - NS_EVENT_FLAG_BUBBLE); + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); elmP->AddEventListenerByType(this, NS_LITERAL_STRING("compositionstart"), - NS_EVENT_FLAG_BUBBLE); + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); elmP->AddEventListenerByType(this, NS_LITERAL_STRING("compositionend"), - NS_EVENT_FLAG_BUBBLE); + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); return NS_OK; } @@ -289,13 +292,16 @@ nsEditorEventListener::UninstallFromEditor() NS_EVENT_FLAG_CAPTURE); elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("text"), - NS_EVENT_FLAG_BUBBLE); + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("compositionstart"), - NS_EVENT_FLAG_BUBBLE); + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("compositionend"), - NS_EVENT_FLAG_BUBBLE); + NS_EVENT_FLAG_BUBBLE | + NS_EVENT_FLAG_SYSTEM_EVENT); } already_AddRefed diff --git a/editor/libeditor/html/tests/Makefile.in b/editor/libeditor/html/tests/Makefile.in index 8efc32bbe2e..4fbb1705a3a 100644 --- a/editor/libeditor/html/tests/Makefile.in +++ b/editor/libeditor/html/tests/Makefile.in @@ -90,6 +90,7 @@ _TEST_FILES = \ test_bug674861.html \ test_bug676401.html \ test_bug677752.html \ + test_bug697842.html \ test_CF_HTML_clipboard.html \ test_contenteditable_focus.html \ test_htmleditor_keyevent_handling.html \ diff --git a/editor/libeditor/html/tests/test_bug697842.html b/editor/libeditor/html/tests/test_bug697842.html new file mode 100644 index 00000000000..9a6700b3969 --- /dev/null +++ b/editor/libeditor/html/tests/test_bug697842.html @@ -0,0 +1,125 @@ + + + + + Test for Bug 697842 + + + + + + +
+

+
+ +
+
+ + + + + diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js index 91d0f2fd9c4..d2ea6d4bdc4 100644 --- a/testing/mochitest/tests/SimpleTest/EventUtils.js +++ b/testing/mochitest/tests/SimpleTest/EventUtils.js @@ -534,6 +534,12 @@ function _getDOMWindowUtils(aWindow) getInterface(Components.interfaces.nsIDOMWindowUtils); } +// Must be synchronized with nsIDOMWindowUtils. +const COMPOSITION_ATTR_RAWINPUT = 0x02; +const COMPOSITION_ATTR_SELECTEDRAWTEXT = 0x03; +const COMPOSITION_ATTR_CONVERTEDTEXT = 0x04; +const COMPOSITION_ATTR_SELECTEDCONVERTEDTEXT = 0x05; + /** * Synthesize a composition event. * From 9ac25e744a048b6ef56a82a3c86ca542cb75127a Mon Sep 17 00:00:00 2001 From: Serge Gautherie Date: Sun, 27 Nov 2011 12:24:37 +0100 Subject: [PATCH 15/31] Bug 632433 - Remove calls to Firefox stopSearch(), rename test_autocomplete.xul to test_autocomplete_mac_caret.xul. r=enn --HG-- rename : toolkit/content/tests/chrome/test_autocomplete.xul => toolkit/content/tests/chrome/test_autocomplete_mac_caret.xul --- toolkit/content/tests/chrome/Makefile.in | 2 +- toolkit/content/tests/chrome/test_autocomplete2.xul | 1 - toolkit/content/tests/chrome/test_autocomplete3.xul | 1 - toolkit/content/tests/chrome/test_autocomplete4.xul | 1 - .../{test_autocomplete.xul => test_autocomplete_mac_caret.xul} | 1 - 5 files changed, 1 insertion(+), 5 deletions(-) rename toolkit/content/tests/chrome/{test_autocomplete.xul => test_autocomplete_mac_caret.xul} (98%) diff --git a/toolkit/content/tests/chrome/Makefile.in b/toolkit/content/tests/chrome/Makefile.in index 9220e32b07e..e4e2233f539 100644 --- a/toolkit/content/tests/chrome/Makefile.in +++ b/toolkit/content/tests/chrome/Makefile.in @@ -193,7 +193,7 @@ _TEST_FILES += test_panel_focus.xul \ test_chromemargin.xul \ window_chromemargin.xul else -_TEST_FILES += test_autocomplete.xul +_TEST_FILES += test_autocomplete_mac_caret.xul endif ifeq ($(MOZ_WIDGET_TOOLKIT),windows) diff --git a/toolkit/content/tests/chrome/test_autocomplete2.xul b/toolkit/content/tests/chrome/test_autocomplete2.xul index 2dc3b5bb0f8..dfd4791ea8c 100644 --- a/toolkit/content/tests/chrome/test_autocomplete2.xul +++ b/toolkit/content/tests/chrome/test_autocomplete2.xul @@ -167,7 +167,6 @@ function checkResult() { setTimeout(function() { // Unregister the factory so that we don't get in the way of other tests componentManager.unregisterFactory(autoCompleteSimpleID, autoCompleteSimple); - autocomplete.controller.stopSearch(); SimpleTest.finish(); }, 0); } diff --git a/toolkit/content/tests/chrome/test_autocomplete3.xul b/toolkit/content/tests/chrome/test_autocomplete3.xul index 3c6044b4c6f..3f879c23115 100644 --- a/toolkit/content/tests/chrome/test_autocomplete3.xul +++ b/toolkit/content/tests/chrome/test_autocomplete3.xul @@ -167,7 +167,6 @@ function checkResult() { setTimeout(function() { // Unregister the factory so that we don't get in the way of other tests componentManager.unregisterFactory(autoCompleteSimpleID, autoCompleteSimple); - autocomplete.controller.stopSearch(); SimpleTest.finish(); }, 0); } diff --git a/toolkit/content/tests/chrome/test_autocomplete4.xul b/toolkit/content/tests/chrome/test_autocomplete4.xul index 30d93b96434..ae737881fd0 100644 --- a/toolkit/content/tests/chrome/test_autocomplete4.xul +++ b/toolkit/content/tests/chrome/test_autocomplete4.xul @@ -148,7 +148,6 @@ function nextTest() { if (!tests.length) { // No more tests to run, finish. setTimeout(function() { - $("autocomplete").controller.stopSearch(); // Unregister the factory so that we don't get in the way of other tests componentManager.unregisterFactory(autoCompleteSimpleID, autoCompleteSimple); SimpleTest.finish(); diff --git a/toolkit/content/tests/chrome/test_autocomplete.xul b/toolkit/content/tests/chrome/test_autocomplete_mac_caret.xul similarity index 98% rename from toolkit/content/tests/chrome/test_autocomplete.xul rename to toolkit/content/tests/chrome/test_autocomplete_mac_caret.xul index a9128c1ed26..21670215d48 100644 --- a/toolkit/content/tests/chrome/test_autocomplete.xul +++ b/toolkit/content/tests/chrome/test_autocomplete_mac_caret.xul @@ -46,7 +46,6 @@ function keyCaretTest() autocomplete.selectionEnd = 4; checkKeyCaretTest("VK_DOWN", 6, 6, true, "value down with selection"); - autocomplete.controller.stopSearch(); SimpleTest.finish(); } From b2261fa023a209faa17d6cd13b3a4567ced67282 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 23 Nov 2011 16:27:40 -0800 Subject: [PATCH 16/31] Bug 705009: Report DeviceMotion values in units of m/s^2, not Gs, per current spec. r=dougt --- embedding/android/GeckoEvent.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/embedding/android/GeckoEvent.java b/embedding/android/GeckoEvent.java index c164f019e9f..42adfcbcf06 100644 --- a/embedding/android/GeckoEvent.java +++ b/embedding/android/GeckoEvent.java @@ -148,9 +148,9 @@ public class GeckoEvent { if (s.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { mType = ACCELERATION_EVENT; - mX = s.values[0] / SensorManager.GRAVITY_EARTH; - mY = s.values[1] / SensorManager.GRAVITY_EARTH; - mZ = s.values[2] / SensorManager.GRAVITY_EARTH; + mX = s.values[0]; + mY = s.values[1]; + mZ = s.values[2]; } else { mType = ORIENTATION_EVENT; From 1251d362e045d7d9976b059f7987b107c6d8aa89 Mon Sep 17 00:00:00 2001 From: Markus Amalthea Magnuson Date: Sun, 27 Nov 2011 12:27:14 +0100 Subject: [PATCH 17/31] Bug 583510 - Set min-height on toolbar separators to prevent them from disappearing. r=dao --- browser/themes/pinstripe/browser.css | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/browser/themes/pinstripe/browser.css b/browser/themes/pinstripe/browser.css index 2a96556acd4..07b6e88a09d 100644 --- a/browser/themes/pinstripe/browser.css +++ b/browser/themes/pinstripe/browser.css @@ -88,6 +88,17 @@ padding: 2px 4px; } +/* Because of -moz-box-align: center above, separators will be invisible unless + we set their min-height. See bug 583510 for more information. */ +toolbarseparator { + min-height: 22px; +} + +/* We need more height when toolbar buttons show both icon and text. */ +toolbar[mode="full"] toolbarseparator { + min-height: 36px; +} + #nav-bar { padding-bottom: 4px !important; } From 1f646bf60b88008717e5097e7d268cfd9a94cdc8 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Sun, 27 Nov 2011 20:51:52 +0900 Subject: [PATCH 18/31] Bug 685395 part.1 Remove obsolete APIs (GetIMEEnabled() and SetIMEEnabled()) r=roc, sr=matspal --- widget/public/nsIWidget.h | 14 ++------------ widget/src/qt/mozqwidget.cpp | 3 +-- widget/src/xpwidgets/nsBaseWidget.cpp | 20 -------------------- widget/src/xpwidgets/nsBaseWidget.h | 2 -- 4 files changed, 3 insertions(+), 36 deletions(-) diff --git a/widget/public/nsIWidget.h b/widget/public/nsIWidget.h index 833d78de298..c3e2331a2d7 100644 --- a/widget/public/nsIWidget.h +++ b/widget/public/nsIWidget.h @@ -118,8 +118,8 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event); #endif #define NS_IWIDGET_IID \ - { 0xEAAF1019, 0x0CD8, 0x4DD8, \ - { 0xBE, 0xB9, 0x8D, 0x8D, 0xEB, 0x52, 0xFC, 0xF6 } } + { 0x7db4261e, 0xf356, 0x45a1, \ + { 0xb2, 0xc1, 0xf0, 0x85, 0xea, 0x93, 0xb3, 0xb4 } } /* * Window shadow styles @@ -1295,16 +1295,6 @@ class nsIWidget : public nsISupports { IME_STATUS_PLUGIN = 3 }; - /* - * Set the state to 'Enabled' or 'Disabled' or 'Password'. - */ - NS_IMETHOD SetIMEEnabled(PRUint32 aState) = 0; - - /* - * Get IME is 'Enabled' or 'Disabled' or 'Password'. - */ - NS_IMETHOD GetIMEEnabled(PRUint32* aState) = 0; - /* * Destruct and don't commit the IME composition string. */ diff --git a/widget/src/qt/mozqwidget.cpp b/widget/src/qt/mozqwidget.cpp index 828b379dbb9..b7efa3e7d76 100644 --- a/widget/src/qt/mozqwidget.cpp +++ b/widget/src/qt/mozqwidget.cpp @@ -61,8 +61,7 @@ /* Pure Qt is lacking a clear API to get the current state of the VKB (opened - or closed). So this global is used to track that state for - nsWindow::GetIMEEnabled(). + or closed). */ static bool gKeyboardOpen = false; diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index f76f3c52188..55d00db9dc2 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -1182,26 +1182,6 @@ nsBaseWidget::BeginMoveDrag(nsMouseEvent* aEvent) return NS_ERROR_NOT_IMPLEMENTED; } -// For backwards compatibility only -NS_IMETHODIMP -nsBaseWidget::SetIMEEnabled(PRUint32 aState) -{ - IMEContext context; - context.mStatus = aState; - return SetInputMode(context); -} - -NS_IMETHODIMP -nsBaseWidget::GetIMEEnabled(PRUint32* aState) -{ - IMEContext context; - nsresult rv = GetInputMode(context); - NS_ENSURE_SUCCESS(rv, rv); - - *aState = context.mStatus; - return NS_OK; -} - #ifdef DEBUG ////////////////////////////////////////////////////////////// // diff --git a/widget/src/xpwidgets/nsBaseWidget.h b/widget/src/xpwidgets/nsBaseWidget.h index bfa0c62777a..6e23bf12fc6 100644 --- a/widget/src/xpwidgets/nsBaseWidget.h +++ b/widget/src/xpwidgets/nsBaseWidget.h @@ -146,8 +146,6 @@ public: NS_IMETHOD GetIMEOpenState(bool* aState) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD SetInputMode(const IMEContext& aContext) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD GetInputMode(IMEContext& aContext) { return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD SetIMEEnabled(PRUint32 aState); - NS_IMETHOD GetIMEEnabled(PRUint32* aState); NS_IMETHOD CancelIMEComposition() { return NS_OK; } NS_IMETHOD SetAcceleratedRendering(bool aEnabled); virtual bool GetAcceleratedRendering(); From ba332c4403ff0e8de69bb4c2ebc94f8a2607c4cd Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Sun, 27 Nov 2011 20:51:52 +0900 Subject: [PATCH 19/31] Bug 685395 part.2 Move IMEContext to mozilla::widget::InputContext r=roc --- content/base/src/nsContentUtils.cpp | 11 +-- content/events/src/nsIMEStateManager.cpp | 27 ++++--- dom/base/nsDOMWindowUtils.cpp | 12 +-- dom/base/nsFocusManager.cpp | 24 +++--- dom/ipc/TabParent.cpp | 11 +-- widget/public/nsIWidget.h | 94 +++++++++++++----------- widget/src/android/nsWindow.cpp | 22 +++--- widget/src/android/nsWindow.h | 6 +- widget/src/cocoa/nsChildView.h | 6 +- widget/src/cocoa/nsChildView.mm | 18 ++--- widget/src/gtk2/nsGtkIMModule.cpp | 58 ++++++++------- widget/src/gtk2/nsGtkIMModule.h | 13 +++- widget/src/gtk2/nsWindow.cpp | 7 +- widget/src/gtk2/nsWindow.h | 4 +- widget/src/qt/nsWindow.cpp | 38 +++++----- widget/src/qt/nsWindow.h | 6 +- widget/src/windows/nsTextStore.cpp | 3 +- widget/src/windows/nsTextStore.h | 7 +- widget/src/windows/nsWindow.cpp | 26 ++++--- widget/src/windows/nsWindow.h | 11 ++- widget/src/xpwidgets/PuppetWidget.cpp | 9 ++- widget/src/xpwidgets/PuppetWidget.h | 4 +- widget/src/xpwidgets/nsBaseWidget.h | 4 +- 23 files changed, 236 insertions(+), 185 deletions(-) diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index f26ea0ca083..fcd5f0fc8f0 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -212,6 +212,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID); using namespace mozilla::dom; using namespace mozilla::layers; +using namespace mozilla::widget; using namespace mozilla; const char kLoadAsData[] = "loadAsData"; @@ -4032,16 +4033,16 @@ nsContentUtils::GetWidgetStatusFromIMEStatus(PRUint32 aState) { switch (aState & nsIContent::IME_STATUS_MASK_ENABLED) { case nsIContent::IME_STATUS_DISABLE: - return nsIWidget::IME_STATUS_DISABLED; + return InputContext::IME_DISABLED; case nsIContent::IME_STATUS_ENABLE: - return nsIWidget::IME_STATUS_ENABLED; + return InputContext::IME_ENABLED; case nsIContent::IME_STATUS_PASSWORD: - return nsIWidget::IME_STATUS_PASSWORD; + return InputContext::IME_PASSWORD; case nsIContent::IME_STATUS_PLUGIN: - return nsIWidget::IME_STATUS_PLUGIN; + return InputContext::IME_PLUGIN; default: NS_ERROR("The given state doesn't have valid enable state"); - return nsIWidget::IME_STATUS_ENABLED; + return InputContext::IME_ENABLED; } } diff --git a/content/events/src/nsIMEStateManager.cpp b/content/events/src/nsIMEStateManager.cpp index 573225a9872..add7cb8a516 100644 --- a/content/events/src/nsIMEStateManager.cpp +++ b/content/events/src/nsIMEStateManager.cpp @@ -68,6 +68,8 @@ #include "nsIForm.h" #include "nsHTMLFormElement.h" +using namespace mozilla::widget; + /******************************************************************/ /* nsIMEStateManager */ /******************************************************************/ @@ -88,7 +90,7 @@ nsIMEStateManager::OnDestroyPresContext(nsPresContext* aPresContext) nsCOMPtr widget = GetWidget(sPresContext); if (widget) { PRUint32 newState = GetNewIMEState(sPresContext, nsnull); - SetIMEState(newState, nsnull, widget, IMEContext::FOCUS_REMOVED); + SetIMEState(newState, nsnull, widget, InputContext::FOCUS_REMOVED); } sContent = nsnull; sPresContext = nsnull; @@ -113,7 +115,7 @@ nsIMEStateManager::OnRemoveContent(nsPresContext* aPresContext, if (NS_FAILED(rv)) widget->ResetInputState(); PRUint32 newState = GetNewIMEState(sPresContext, nsnull); - SetIMEState(newState, nsnull, widget, IMEContext::FOCUS_REMOVED); + SetIMEState(newState, nsnull, widget, InputContext::FOCUS_REMOVED); } sContent = nsnull; @@ -166,12 +168,12 @@ nsIMEStateManager::OnChangeFocus(nsPresContext* aPresContext, // the enabled state isn't changing, we should do nothing. return NS_OK; } - IMEContext context; + InputContext context; if (!widget || NS_FAILED(widget->GetInputMode(context))) { // this platform doesn't support IME controlling return NS_OK; } - if (context.mStatus == + if (context.mIMEEnabled == nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) { // the enabled state isn't changing. return NS_OK; @@ -205,8 +207,8 @@ nsIMEStateManager::OnInstalledMenuKeyboardListener(bool aInstalling) { sInstalledMenuKeyboardListener = aInstalling; - PRUint32 reason = aInstalling ? IMEContext::FOCUS_MOVED_TO_MENU - : IMEContext::FOCUS_MOVED_FROM_MENU; + PRUint32 reason = aInstalling ? InputContext::FOCUS_MOVED_TO_MENU + : InputContext::FOCUS_MOVED_FROM_MENU; OnChangeFocus(sPresContext, sContent, reason); } @@ -225,13 +227,13 @@ nsIMEStateManager::UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent) } // Don't update IME state when enabled state isn't actually changed. - IMEContext context; + InputContext context; nsresult rv = widget->GetInputMode(context); if (NS_FAILED(rv)) { return; // This platform doesn't support controling the IME state. } PRUint32 newEnabledState = aNewIMEState & nsIContent::IME_STATUS_MASK_ENABLED; - if (context.mStatus == + if (context.mIMEEnabled == nsContentUtils::GetWidgetStatusFromIMEStatus(newEnabledState)) { return; } @@ -239,7 +241,8 @@ nsIMEStateManager::UpdateIMEState(PRUint32 aNewIMEState, nsIContent* aContent) // commit current composition widget->ResetInputState(); - SetIMEState(aNewIMEState, aContent, widget, IMEContext::EDITOR_STATE_MODIFIED); + SetIMEState(aNewIMEState, aContent, widget, + InputContext::EDITOR_STATE_MODIFIED); } PRUint32 @@ -300,8 +303,8 @@ nsIMEStateManager::SetIMEState(PRUint32 aState, return; PRUint32 state = nsContentUtils::GetWidgetStatusFromIMEStatus(aState); - IMEContext context; - context.mStatus = state; + InputContext context; + context.mIMEEnabled = state; if (aContent && aContent->GetNameSpaceID() == kNameSpaceID_XHTML && (aContent->Tag() == nsGkAtoms::input || @@ -337,7 +340,7 @@ nsIMEStateManager::SetIMEState(PRUint32 aState, } if (XRE_GetProcessType() == GeckoProcessType_Content) { - context.mReason = aReason | IMEContext::FOCUS_FROM_CONTENT_PROCESS; + context.mReason = aReason | InputContext::FOCUS_FROM_CONTENT_PROCESS; } else { context.mReason = aReason; } diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index dc9507f9def..4e84e7995c8 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -86,6 +86,7 @@ using namespace mozilla::dom; using namespace mozilla::layers; +using namespace mozilla::widget; static bool IsUniversalXPConnectCapable() { @@ -1039,11 +1040,12 @@ nsDOMWindowUtils::GetIMEIsOpen(bool *aState) return NS_ERROR_FAILURE; // Open state should not be available when IME is not enabled. - IMEContext context; + InputContext context; nsresult rv = widget->GetInputMode(context); NS_ENSURE_SUCCESS(rv, rv); - if (context.mStatus != nsIWidget::IME_STATUS_ENABLED) + if (context.mIMEEnabled != InputContext::IME_ENABLED) { return NS_ERROR_NOT_AVAILABLE; + } return widget->GetIMEOpenState(aState); } @@ -1057,11 +1059,11 @@ nsDOMWindowUtils::GetIMEStatus(PRUint32 *aState) if (!widget) return NS_ERROR_FAILURE; - IMEContext context; + InputContext context; nsresult rv = widget->GetInputMode(context); NS_ENSURE_SUCCESS(rv, rv); - *aState = context.mStatus; + *aState = context.mIMEEnabled; return NS_OK; } @@ -1075,7 +1077,7 @@ nsDOMWindowUtils::GetFocusedInputType(char** aType) return NS_ERROR_FAILURE; } - IMEContext context; + InputContext context; nsresult rv = widget->GetInputMode(context); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 4f4ffb2c830..fed5b146dd1 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -96,6 +96,7 @@ using namespace mozilla; using namespace mozilla::dom; +using namespace mozilla::widget; //#define DEBUG_FOCUS 1 //#define DEBUG_FOCUS_NAVIGATION 1 @@ -340,13 +341,13 @@ nsFocusManager::GetRedirectedFocus(nsIContent* aContent) PRUint32 nsFocusManager::GetFocusMoveReason(PRUint32 aFlags) { - PRUint32 reason = IMEContext::FOCUS_MOVED_UNKNOWN; + PRUint32 reason = InputContext::FOCUS_MOVED_UNKNOWN; if (aFlags & nsIFocusManager::FLAG_BYMOUSE) { - reason = IMEContext::FOCUS_MOVED_BY_MOUSE; + reason = InputContext::FOCUS_MOVED_BY_MOUSE; } else if (aFlags & nsIFocusManager::FLAG_BYKEY) { - reason = IMEContext::FOCUS_MOVED_BY_KEY; + reason = InputContext::FOCUS_MOVED_BY_KEY; } else if (aFlags & nsIFocusManager::FLAG_BYMOVEFOCUS) { - reason = IMEContext::FOCUS_MOVED_BY_MOVEFOCUS; + reason = InputContext::FOCUS_MOVED_BY_MOVEFOCUS; } return reason; @@ -964,7 +965,8 @@ nsFocusManager::WindowHidden(nsIDOMWindow* aWindow) nsIMEStateManager::OnTextStateBlur(nsnull, nsnull); if (presShell) { - nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nsnull, IMEContext::FOCUS_REMOVED); + nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nsnull, + InputContext::FOCUS_REMOVED); SetCaretVisible(presShell, false, nsnull); } @@ -1523,8 +1525,10 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear, // This has to happen before the focus is cleared below, otherwise, the IME // compositionend event won't get fired at the element being blurred. nsIMEStateManager::OnTextStateBlur(nsnull, nsnull); - if (mActiveWindow) - nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nsnull, IMEContext::FOCUS_REMOVED); + if (mActiveWindow) { + nsIMEStateManager::OnChangeFocus(presShell->GetPresContext(), nsnull, + InputContext::FOCUS_REMOVED); + } // now adjust the actual focus, by clearing the fields in the focus manager // and in the window. @@ -1803,7 +1807,8 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, nsIMEStateManager::OnTextStateFocus(presContext, aContent); } else { nsIMEStateManager::OnTextStateBlur(presContext, nsnull); - nsIMEStateManager::OnChangeFocus(presContext, nsnull, IMEContext::FOCUS_REMOVED); + nsIMEStateManager::OnChangeFocus(presContext, nsnull, + InputContext::FOCUS_REMOVED); if (!aWindowRaised) { aWindow->UpdateCommands(NS_LITERAL_STRING("focus")); } @@ -1826,7 +1831,8 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, nsPresContext* presContext = presShell->GetPresContext(); nsIMEStateManager::OnTextStateBlur(presContext, nsnull); - nsIMEStateManager::OnChangeFocus(presContext, nsnull, IMEContext::FOCUS_REMOVED); + nsIMEStateManager::OnChangeFocus(presContext, nsnull, + InputContext::FOCUS_REMOVED); if (!aWindowRaised) aWindow->UpdateCommands(NS_LITERAL_STRING("focus")); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index f139b7f75bc..00f3f2df319 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -74,6 +74,7 @@ using namespace mozilla::dom; using namespace mozilla::ipc; using namespace mozilla::layout; +using namespace mozilla::widget; // The flags passed by the webProgress notifications are 16 bits shifted // from the ones registered by webProgressListeners. @@ -567,13 +568,13 @@ TabParent::RecvGetIMEEnabled(PRUint32* aValue) { nsCOMPtr widget = GetWidget(); if (!widget) { - *aValue = nsIWidget::IME_STATUS_DISABLED; + *aValue = InputContext::IME_DISABLED; return true; } - IMEContext context; + InputContext context; widget->GetInputMode(context); - *aValue = context.mStatus; + *aValue = context.mIMEEnabled; return true; } @@ -587,8 +588,8 @@ TabParent::RecvSetInputMode(const PRUint32& aValue, const nsString& aType, const if (!widget || !AllowContentIME()) return true; - IMEContext context; - context.mStatus = aValue; + InputContext context; + context.mIMEEnabled = aValue; context.mHTMLInputType.Assign(aType); context.mActionHint.Assign(aAction); context.mReason = aReason; diff --git a/widget/public/nsIWidget.h b/widget/public/nsIWidget.h index c3e2331a2d7..5614560200e 100644 --- a/widget/public/nsIWidget.h +++ b/widget/public/nsIWidget.h @@ -231,8 +231,51 @@ struct nsIMEUpdatePreference { * Contains IMEStatus plus information about the current * input context that the IME can use as hints if desired. */ -struct IMEContext { - PRUint32 mStatus; + +namespace mozilla { +namespace widget { + +struct InputContext { + /** + * IME enabled states, the mIMEEnabled value of SetInputMode()/GetInputMode() + * should be one value of following values. + * + * WARNING: If you change these values, you also need to edit: + * nsIDOMWindowUtils.idl + * nsDOMWindowUtils::SetIMEEnabled + * nsContentUtils::GetWidgetStatusFromIMEStatus + */ + enum { + /** + * 'Disabled' means the user cannot use IME. So, the IME open state should + * be 'closed' during 'disabled'. + */ + IME_DISABLED = 0, + /** + * 'Enabled' means the user can use IME. + */ + IME_ENABLED = 1, + /** + * 'Password' state is a special case for the password editors. + * E.g., on mac, the password editors should disable the non-Roman + * keyboard layouts at getting focus. Thus, the password editor may have + * special rules on some platforms. + */ + IME_PASSWORD = 2, + /** + * This state is used when a plugin is focused. + * When a plug-in is focused content, we should send native events + * directly. Because we don't process some native events, but they may + * be needed by the plug-in. + */ + IME_PLUGIN = 3, + /** + * IME enabled state mask. + */ + IME_ENABLED_STATE_MASK = 0xF + }; + + PRUint32 mIMEEnabled; /* Does the change come from a trusted source */ enum { @@ -264,6 +307,8 @@ struct IMEContext { nsString mActionHint; }; +} // namespace widget +} // namespace mozilla /** * The base class for all the widgets. It provides the interface for @@ -277,6 +322,7 @@ class nsIWidget : public nsISupports { typedef mozilla::layers::LayerManager LayerManager; typedef LayerManager::LayersBackend LayersBackend; typedef mozilla::layers::PLayersChild PLayersChild; + typedef mozilla::widget::InputContext InputContext; // Used in UpdateThemeGeometries. struct ThemeGeometry { @@ -1260,41 +1306,6 @@ class nsIWidget : public nsISupports { */ NS_IMETHOD GetIMEOpenState(bool* aState) = 0; - /* - * IME enabled states, the aState value of SetIMEEnabled/GetIMEEnabled - * should be one value of following values. - * - * WARNING: If you change these values, you also need to edit: - * nsIDOMWindowUtils.idl - * nsDOMWindowUtils::SetIMEEnabled - * nsContentUtils::GetWidgetStatusFromIMEStatus - */ - enum IMEStatus { - /* - * 'Disabled' means the user cannot use IME. So, the open state should be - * 'closed' during 'disabled'. - */ - IME_STATUS_DISABLED = 0, - /* - * 'Enabled' means the user can use IME. - */ - IME_STATUS_ENABLED = 1, - /* - * 'Password' state is a special case for the password editors. - * E.g., on mac, the password editors should disable the non-Roman - * keyboard layouts at getting focus. Thus, the password editor may have - * special rules on some platforms. - */ - IME_STATUS_PASSWORD = 2, - /* - * This state is used when a plugin is focused. - * When a plug-in is focused content, we should send native events - * directly. Because we don't process some native events, but they may - * be needed by the plug-in. - */ - IME_STATUS_PLUGIN = 3 - }; - /* * Destruct and don't commit the IME composition string. */ @@ -1304,14 +1315,15 @@ class nsIWidget : public nsISupports { * Notifies the IME if the input context changes. * * aContext cannot be null. - * Set mStatus to 'Enabled' or 'Disabled' or 'Password'. + * Set mIMEEnabled to 'Enabled' or 'Disabled' or 'Password' or 'Plugin'. */ - NS_IMETHOD SetInputMode(const IMEContext& aContext) = 0; + NS_IMETHOD SetInputMode(const InputContext& aContext) = 0; /* - * Get IME is 'Enabled' or 'Disabled' or 'Password' and other input context + * Get IME is 'Enabled' or 'Disabled' or 'Password' or 'Plugin' and + * other input context */ - NS_IMETHOD GetInputMode(IMEContext& aContext) = 0; + NS_IMETHOD GetInputMode(InputContext& aContext) = 0; /** * Set accelerated rendering to 'True' or 'False' diff --git a/widget/src/android/nsWindow.cpp b/widget/src/android/nsWindow.cpp index 14a3132684d..876793180e1 100644 --- a/widget/src/android/nsWindow.cpp +++ b/widget/src/android/nsWindow.cpp @@ -84,6 +84,7 @@ using mozilla::unused; #define TILE_HEIGHT 2048 using namespace mozilla; +using namespace mozilla::widget; NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget) @@ -2046,16 +2047,17 @@ nsWindow::ResetInputState() } NS_IMETHODIMP -nsWindow::SetInputMode(const IMEContext& aContext) +nsWindow::SetInputMode(const InputContext& aContext) { - ALOGIME("IME: SetInputMode: s=%d trusted=%d", aContext.mStatus, aContext.mReason); + ALOGIME("IME: SetInputMode: s=%d trusted=%d", + aContext.mIMEEnabled, aContext.mReason); - mIMEContext = aContext; + mInputContext = aContext; // Ensure that opening the virtual keyboard is allowed for this specific - // IMEContext depending on the content.ime.strict.policy pref - if (aContext.mStatus != nsIWidget::IME_STATUS_DISABLED && - aContext.mStatus != nsIWidget::IME_STATUS_PLUGIN) { + // InputContext depending on the content.ime.strict.policy pref + if (aContext.mIMEEnabled != InputContext::IME_DISABLED && + aContext.mIMEEnabled != InputContext::IME_PLUGIN) { if (Preferences::GetBool("content.ime.strict_policy", false) && !aContext.FocusMovedByUser() && aContext.FocusMovedInContentProcess()) { @@ -2063,14 +2065,16 @@ nsWindow::SetInputMode(const IMEContext& aContext) } } - AndroidBridge::NotifyIMEEnabled(int(aContext.mStatus), aContext.mHTMLInputType, aContext.mActionHint); + AndroidBridge::NotifyIMEEnabled(int(aContext.mIMEEnabled), + aContext.mHTMLInputType, + aContext.mActionHint); return NS_OK; } NS_IMETHODIMP -nsWindow::GetInputMode(IMEContext& aContext) +nsWindow::GetInputMode(InputContext& aContext) { - aContext = mIMEContext; + aContext = mInputContext; return NS_OK; } diff --git a/widget/src/android/nsWindow.h b/widget/src/android/nsWindow.h index f711ae8a1a4..bdba08cd3bb 100644 --- a/widget/src/android/nsWindow.h +++ b/widget/src/android/nsWindow.h @@ -155,8 +155,8 @@ public: NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVertical) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD ResetInputState(); - NS_IMETHOD SetInputMode(const IMEContext& aContext); - NS_IMETHOD GetInputMode(IMEContext& aContext); + NS_IMETHOD SetInputMode(const InputContext& aContext); + NS_IMETHOD GetInputMode(InputContext& aContext); NS_IMETHOD CancelIMEComposition(); NS_IMETHOD OnIMEFocusChange(bool aFocus); @@ -211,7 +211,7 @@ protected: nsString mIMELastDispatchedComposingText; nsAutoTArray mIMERanges; - IMEContext mIMEContext; + InputContext mInputContext; static void DumpWindows(); static void DumpWindows(const nsTArray& wins, int indent = 0); diff --git a/widget/src/cocoa/nsChildView.h b/widget/src/cocoa/nsChildView.h index b1cb66590e6..ec18f413c9d 100644 --- a/widget/src/cocoa/nsChildView.h +++ b/widget/src/cocoa/nsChildView.h @@ -448,8 +448,8 @@ public: NS_IMETHOD ResetInputState(); NS_IMETHOD SetIMEOpenState(bool aState); NS_IMETHOD GetIMEOpenState(bool* aState); - NS_IMETHOD SetInputMode(const IMEContext& aContext); - NS_IMETHOD GetInputMode(IMEContext& aContext); + NS_IMETHOD SetInputMode(const InputContext& aContext); + NS_IMETHOD GetInputMode(InputContext& aContext); NS_IMETHOD CancelIMEComposition(); NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, bool* aLEDState); @@ -543,7 +543,7 @@ protected: NSView* mView; // my parallel cocoa view (ChildView or NativeScrollbarView), [STRONG] nsRefPtr mTextInputHandler; - IMEContext mIMEContext; + InputContext mInputContext; NSView* mParentView; nsIWidget* mParentWidget; diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index ce245d37e22..27fe594f5a0 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -1689,21 +1689,21 @@ NS_IMETHODIMP nsChildView::GetIMEOpenState(bool* aState) return NS_OK; } -NS_IMETHODIMP nsChildView::SetInputMode(const IMEContext& aContext) +NS_IMETHODIMP nsChildView::SetInputMode(const InputContext& aContext) { NS_ENSURE_TRUE(mTextInputHandler, NS_ERROR_NOT_AVAILABLE); - mIMEContext = aContext; - switch (aContext.mStatus) { - case nsIWidget::IME_STATUS_ENABLED: - case nsIWidget::IME_STATUS_PLUGIN: + mInputContext = aContext; + switch (aContext.mIMEEnabled) { + case InputContext::IME_ENABLED: + case InputContext::IME_PLUGIN: mTextInputHandler->SetASCIICapableOnly(false); mTextInputHandler->EnableIME(true); break; - case nsIWidget::IME_STATUS_DISABLED: + case InputContext::IME_DISABLED: mTextInputHandler->SetASCIICapableOnly(false); mTextInputHandler->EnableIME(false); break; - case nsIWidget::IME_STATUS_PASSWORD: + case InputContext::IME_PASSWORD: mTextInputHandler->SetASCIICapableOnly(true); mTextInputHandler->EnableIME(false); break; @@ -1713,9 +1713,9 @@ NS_IMETHODIMP nsChildView::SetInputMode(const IMEContext& aContext) return NS_OK; } -NS_IMETHODIMP nsChildView::GetInputMode(IMEContext& aContext) +NS_IMETHODIMP nsChildView::GetInputMode(InputContext& aContext) { - aContext = mIMEContext; + aContext = mInputContext; return NS_OK; } diff --git a/widget/src/gtk2/nsGtkIMModule.cpp b/widget/src/gtk2/nsGtkIMModule.cpp index 27ce7600d1e..a8862bf5e62 100644 --- a/widget/src/gtk2/nsGtkIMModule.cpp +++ b/widget/src/gtk2/nsGtkIMModule.cpp @@ -58,6 +58,7 @@ #endif using namespace mozilla; +using namespace mozilla::widget; #ifdef PR_LOGGING PRLogModuleInfo* gGtkIMLog = nsnull; @@ -85,13 +86,13 @@ static const char* GetEnabledStateName(PRUint32 aState) { switch (aState) { - case nsIWidget::IME_STATUS_DISABLED: + case InputContext::IME_DISABLED: return "DISABLED"; - case nsIWidget::IME_STATUS_ENABLED: + case InputContext::IME_ENABLED: return "ENABLED"; - case nsIWidget::IME_STATUS_PASSWORD: + case InputContext::IME_PASSWORD: return "PASSWORD"; - case nsIWidget::IME_STATUS_PLUGIN: + case InputContext::IME_PLUGIN: return "PLUG_IN"; default: return "UNKNOWN ENABLED STATUS!!"; @@ -121,7 +122,7 @@ nsGtkIMModule::nsGtkIMModule(nsWindow* aOwnerWindow) : gGtkIMLog = PR_NewLogModule("nsGtkIMModuleWidgets"); } #endif - mIMEContext.mStatus = nsIWidget::IME_STATUS_ENABLED; + mInputContext.mIMEEnabled = InputContext::IME_ENABLED; Init(); } @@ -257,7 +258,7 @@ nsGtkIMModule::OnDestroyWindow(nsWindow* aWindow) mOwnerWindow = nsnull; mLastFocusedWindow = nsnull; - mIMEContext.mStatus = nsIWidget::IME_STATUS_DISABLED; + mInputContext.mIMEEnabled = InputContext::IME_DISABLED; PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, (" SUCCEEDED, Completely destroyed")); @@ -542,15 +543,16 @@ nsGtkIMModule::CancelIMEComposition(nsWindow* aCaller) } nsresult -nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext) +nsGtkIMModule::SetInputMode(nsWindow* aCaller, const InputContext* aContext) { - if (aContext->mStatus == mIMEContext.mStatus || NS_UNLIKELY(IsDestroyed())) { + if (aContext->mIMEEnabled == mInputContext.mIMEEnabled || + NS_UNLIKELY(IsDestroyed())) { return NS_OK; } PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, ("GtkIMModule(%p): SetInputMode, aCaller=%p, aState=%s mHTMLInputType=%s", - this, aCaller, GetEnabledStateName(aContext->mStatus), + this, aCaller, GetEnabledStateName(aContext->mIMEEnabled), NS_ConvertUTF16toUTF8(aContext->mHTMLInputType).get())); if (aCaller != mLastFocusedWindow) { @@ -568,7 +570,7 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext) if (sLastFocusedModule != this) { - mIMEContext = *aContext; + mInputContext = *aContext; PR_LOG(gGtkIMLog, PR_LOG_ALWAYS, (" SUCCEEDED, but we're not active")); return NS_OK; @@ -580,7 +582,7 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext) Blur(); } - mIMEContext = *aContext; + mInputContext = *aContext; // Even when aState is not enabled state, we need to set IME focus. // Because some IMs are updating the status bar of them at this time. @@ -593,14 +595,14 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext) if (im) { if (IsEnabled()) { // Ensure that opening the virtual keyboard is allowed for this specific - // IMEContext depending on the content.ime.strict.policy pref - if (mIMEContext.mStatus != nsIWidget::IME_STATUS_DISABLED && - mIMEContext.mStatus != nsIWidget::IME_STATUS_PLUGIN) { + // InputContext depending on the content.ime.strict.policy pref + if (mInputContext.mIMEEnabled != InputContext::IME_DISABLED && + mInputContext.mIMEEnabled != InputContext::IME_PLUGIN) { bool useStrictPolicy = Preferences::GetBool("content.ime.strict_policy", false); - if (useStrictPolicy && !mIMEContext.FocusMovedByUser() && - mIMEContext.FocusMovedInContentProcess()) { + if (useStrictPolicy && !mInputContext.FocusMovedByUser() && + mInputContext.FocusMovedInContentProcess()) { return NS_OK; } } @@ -611,10 +613,10 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext) int mode; g_object_get(im, "hildon-input-mode", &mode, NULL); - if (mIMEContext.mStatus == nsIWidget::IME_STATUS_ENABLED || - mIMEContext.mStatus == nsIWidget::IME_STATUS_PLUGIN) { + if (mInputContext.mIMEEnabled == InputContext::IME_ENABLED || + mInputContext.mIMEEnabled == InputContext::IME_PLUGIN) { mode &= ~HILDON_GTK_INPUT_MODE_INVISIBLE; - } else if (mIMEContext.mStatus == nsIWidget::IME_STATUS_PASSWORD) { + } else if (mInputContext.mIMEEnabled == InputContext::IME_PASSWORD) { mode |= HILDON_GTK_INPUT_MODE_INVISIBLE; } @@ -659,10 +661,10 @@ nsGtkIMModule::SetInputMode(nsWindow* aCaller, const IMEContext* aContext) } nsresult -nsGtkIMModule::GetInputMode(IMEContext* aContext) +nsGtkIMModule::GetInputMode(InputContext* aContext) { NS_ENSURE_ARG_POINTER(aContext); - *aContext = mIMEContext; + *aContext = mInputContext; return NS_OK; } @@ -685,7 +687,7 @@ nsGtkIMModule::GetContext() } #ifndef NS_IME_ENABLED_ON_PASSWORD_FIELD - if (mIMEContext.mStatus == nsIWidget::IME_STATUS_PASSWORD) { + if (mInputContext.mIMEEnabled == InputContext::IME_PASSWORD) { return mSimpleContext; } #endif // NS_IME_ENABLED_ON_PASSWORD_FIELD @@ -696,19 +698,19 @@ nsGtkIMModule::GetContext() bool nsGtkIMModule::IsEnabled() { - return mIMEContext.mStatus == nsIWidget::IME_STATUS_ENABLED || + return mInputContext.mIMEEnabled == InputContext::IME_ENABLED || #ifdef NS_IME_ENABLED_ON_PASSWORD_FIELD - mIMEContext.mStatus == nsIWidget::IME_STATUS_PASSWORD || + mInputContext.mIMEEnabled == InputContext::IME_PASSWORD || #endif // NS_IME_ENABLED_ON_PASSWORD_FIELD - mIMEContext.mStatus == nsIWidget::IME_STATUS_PLUGIN; + mInputContext.mIMEEnabled == InputContext::IME_PLUGIN; } bool nsGtkIMModule::IsEditable() { - return mIMEContext.mStatus == nsIWidget::IME_STATUS_ENABLED || - mIMEContext.mStatus == nsIWidget::IME_STATUS_PLUGIN || - mIMEContext.mStatus == nsIWidget::IME_STATUS_PASSWORD; + return mInputContext.mIMEEnabled == InputContext::IME_ENABLED || + mInputContext.mIMEEnabled == InputContext::IME_PLUGIN || + mInputContext.mIMEEnabled == InputContext::IME_PASSWORD; } void diff --git a/widget/src/gtk2/nsGtkIMModule.h b/widget/src/gtk2/nsGtkIMModule.h index db4e443fefa..391059bc0cb 100644 --- a/widget/src/gtk2/nsGtkIMModule.h +++ b/widget/src/gtk2/nsGtkIMModule.h @@ -47,6 +47,7 @@ #include "nsAutoPtr.h" #include "nsTArray.h" #include "nsGUIEvent.h" +#include "nsIWidget.h" // If software keyboard is needed in password field and uses GTK2 IM module // for inputting characters, we need to enable IME in password field too. @@ -58,6 +59,9 @@ class nsWindow; class nsGtkIMModule { +protected: + typedef mozilla::widget::InputContext InputContext; + public: nsrefcnt AddRef() { @@ -112,8 +116,9 @@ public: // IME related nsIWidget methods. nsresult ResetInputState(nsWindow* aCaller); - nsresult SetInputMode(nsWindow* aCaller, const IMEContext* aContext); - nsresult GetInputMode(IMEContext* aContext); + nsresult SetInputMode(nsWindow* aCaller, + const InputContext* aContext); + nsresult GetInputMode(InputContext* aContext); nsresult CancelIMEComposition(nsWindow* aCaller); // If a software keyboard has been opened, this returns TRUE. @@ -148,9 +153,9 @@ protected: // always "closed", so it closes IME forcedly. GtkIMContext *mDummyContext; - // IME enabled state and other things defined in IMEContext. + // IME enabled state and other things defined in InputContext. // Use following helper methods if you don't need the detail of the status. - IMEContext mIMEContext; + InputContext mInputContext; // mCompositionStart is the start offset of the composition string in the // current content. When